pi-weave 0.1.8 → 0.1.9
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/README.md +9 -3
- package/package.json +2 -2
- package/skills/weave-notepad/SKILL.md +13 -4
- package/src/core/concurrency.ts +36 -0
- package/src/core/frontmatter.ts +53 -0
- package/src/core/graph/build.ts +60 -1
- package/src/core/graph/model.ts +15 -0
- package/src/core/graph/wikilinks.ts +5 -1
- package/src/core/index.ts +2 -0
- package/src/core/paths.ts +7 -0
- package/src/core/sessions.ts +929 -0
- package/src/core/summaries.ts +1 -19
- package/src/core/vault.ts +264 -16
- package/src/core/workspace.ts +3 -3
- package/src/pi/index.ts +144 -37
- package/src/pi/sessionScan.ts +104 -0
- package/src/pi/summarize.ts +24 -4
- package/src/pi/tools/noteTool.ts +13 -4
- package/src/pi/viewer/tui/branding.ts +8 -7
- package/src/pi/viewer/tui/explorer.ts +1 -1
- package/src/web/client/dist/app.js +52 -39
- package/src/web/client/graph/Graph.tsx +70 -19
- package/src/web/client/graph/column.model.ts +11 -70
- package/src/web/client/graph/dynamics.ts +176 -0
- package/src/web/client/graph/graph.model.ts +10 -2
- package/src/web/client/graph/positions.ts +51 -10
- package/src/web/client/graph/renderer.ts +61 -1
- package/src/web/client/selection.storage.ts +69 -0
- package/src/web/client/shell/Header.tsx +11 -1
- package/src/web/client/shell/Shell.tsx +17 -0
- package/src/web/client/shell/theme.ts +15 -2
- package/src/web/client/state.ts +11 -0
- package/src/web/client/tree/Tree.tsx +4 -1
- package/src/web/client/workspace.ts +69 -5
- package/src/web/server/page.ts +2 -0
- package/src/web/server/routes.ts +19 -7
- package/src/web/shared/graph.ts +7 -0
- package/src/web/shared/layout.ts +158 -341
- package/src/web/shared/logo.ts +11 -0
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
* sigma@3.0.3 — MIT
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
"use strict";(()=>{var Xf=Object.create;var ws=Object.defineProperty;var Zf=Object.getOwnPropertyDescriptor;var Qf=Object.getOwnPropertyNames;var Jf=Object.getPrototypeOf,ep=Object.prototype.hasOwnProperty;var bs=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var tp=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qf(e))!ep.call(t,i)&&i!==n&&ws(t,i,{get:()=>e[i],enumerable:!(r=Zf(e,i))||r.enumerable});return t};var bn=(t,e,n)=>(n=t!=null?Xf(Jf(t)):{},tp(e||!t||!t.__esModule?ws(n,"default",{value:t,enumerable:!0}):n,t));var Tr=bs((u_,fo)=>{"use strict";var Zt=typeof Reflect=="object"?Reflect:null,kl=Zt&&typeof Zt.apply=="function"?Zt.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},kr;Zt&&typeof Zt.ownKeys=="function"?kr=Zt.ownKeys:Object.getOwnPropertySymbols?kr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:kr=function(e){return Object.getOwnPropertyNames(e)};function Jp(t){console&&console.warn&&console.warn(t)}var Tl=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}fo.exports=W;fo.exports.once=rg;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var Sl=10;function Sr(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 Sl},set:function(t){if(typeof t!="number"||t<0||Tl(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Sl=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||Tl(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 Rl(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return Rl(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")kl(l,this,n);else for(var u=l.length,c=Dl(l,u),r=0;r<u;++r)kl(c[r],this,n);return!0};function Al(t,e,n,r){var i,o,a;if(Sr(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=Rl(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,Jp(s)}return t}W.prototype.addListener=function(e,n){return Al(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return Al(this,e,n,!0)};function eg(){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 Cl(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=eg.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return Sr(n),this.on(e,Cl(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return Sr(n),this.prependListener(e,Cl(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(Sr(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():tg(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 Ll(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?ng(i):Dl(i,i.length)}W.prototype.listeners=function(e){return Ll(this,e,!0)};W.prototype.rawListeners=function(e){return Ll(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Nl.call(t,e)};W.prototype.listenerCount=Nl;function Nl(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?kr(this._events):[]};function Dl(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function tg(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function ng(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function rg(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))}Pl(t,e,o,{once:!0}),e!=="error"&&ig(t,i,{once:!0})})}function ig(t,e,n){typeof t.on=="function"&&Pl(t,"error",e,n)}function Pl(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 po=bs((h_,Gl)=>{"use strict";Gl.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var vr,H,Ss,Wi,pt,xs,Ts,Rs,Ui,hr,xn,As,Ki,Hi,Bi,np,pr={},gr=[],rp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,yr=Array.isArray;function rt(t,e){for(var n in e)t[n]=e[n];return t}function Vi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ip(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?vr.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 fr(t,a,r,i,null)}function fr(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??++Ss,__i:-1,__u:0};return i==null&&H.vnode!=null&&H.vnode(o),o}function Pe(t){return t.children}function Vt(t,e){this.props=t,this.context=e}function kt(t,e){if(e==null)return t.__?kt(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"?kt(t):null}function op(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=rt({},e);o.__v=e.__v+1,H.vnode&&H.vnode(o),ji(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??kt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,Ps(r,o,i),e.__e=e.__=null,o.__e!=n&&Cs(o)}}function Cs(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}),Cs(t)}function _s(t){(!t.__d&&(t.__d=!0)&&pt.push(t)&&!mr.__r++||xs!=H.debounceRendering)&&((xs=H.debounceRendering)||Ts)(mr)}function mr(){try{for(var t,e=1;pt.length;)pt.length>e&&pt.sort(Rs),t=pt.shift(),e=pt.length,op(t)}finally{pt.length=mr.__r=0}}function Ls(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,g,m,v,w=r&&r.__k||gr,b=e.length;for(l=ap(n,e,w,l,b),h=0;h<b;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&w[f.__i]||pr,f.__i=h,v=ji(t,f,d,i,o,a,s,l,u,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&qi(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),4&f.__u?(l=Ns(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 ap(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]=fr(null,a,null,null,null):yr(a)?a=t.__k[o]=fr(Pe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=fr(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=sp(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=kt(s)),Gs(s,s));return r}function Ns(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=Ns(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=kt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function sp(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 Es(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||rp.test(e)?n:n+"px"}function dr(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||Es(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Es(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(As,"$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[xn]=r[xn]:(n[xn]=Ki,t.addEventListener(e,o?Bi:Hi,o)):t.removeEventListener(e,o?Bi:Hi,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 ks(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[hr]==null)e[hr]=Ki++;else if(e[hr]<n[xn])return;return n(H.event?H.event(e):e)}}}function ji(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,g,m,v,w,b,E,_,L,P,I,$,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=H.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(b=e.props,E=G.prototype&&G.prototype.render,_=(c=G.contextType)&&r[c.__c],L=c?_?_.props.value:c.__:r,n.__c?w=(d=e.__c=n.__c).__=d.__E:(E?e.__c=d=new G(b,L):(e.__c=d=new Vt(b,L),d.constructor=G,d.render=up),_&&_.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),E&&d.__s==null&&(d.__s=d.state),E&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=rt({},d.__s)),rt(d.__s,G.getDerivedStateFromProps(b,d.__s))),g=d.props,m=d.state,d.__v=e,f)E&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),E&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(E&&G.getDerivedStateFromProps==null&&b!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,L),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,L)===!1){e.__v!=n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),gr.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=kt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,L),E&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,m,v)})}if(d.context=L,d.props=b,d.__P=t,d.__e=!1,P=H.__r,I=0,E)d.state=d.__s,d.__d=!1,P&&P(e),c=d.render(d.props,d.state,d.context),gr.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,P&&P(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++I<25);d.state=d.__s,d.getChildContext!=null&&(r=rt(rt({},r),d.getChildContext())),E&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(g,m)),$=c!=null&&c.type===Pe&&c.key==null?Is(c.props.children):c,s=Ls(t,yr($)?$:[$],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),w&&(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--;)Vi(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||Ds(e),H.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=lp(n.__e,e,n,r,i,o,a,l,u);return(c=H.diffed)&&c(e),128&e.__u?void 0:s}function Ds(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Ds))}function Ps(t,e,n){for(var r=0;r<n.length;r++)qi(n[r],n[++r],n[++r]);H.__c&&H.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){H.__e(o,i.__v)}})}function Is(t){return typeof t!="object"||t==null||t.__b>0?t:yr(t)?t.map(Is):t.constructor!==void 0?null:rt({},t)}function lp(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,g,m,v=n.props||pr,w=e.props,b=e.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="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==!!b&&(b?f.localName==b:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(b==null)return document.createTextNode(w);t=document.createElementNS(i,b,w.is&&w),s&&(H.__m&&H.__m(e,o),s=!1),o=null}if(b==null)v===w||s&&t.data==w||(t.data=w);else{if(o=b=="textarea"&&w.defaultValue!=null?null:o&&vr.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 w||u=="value"&&"defaultValue"in w||u=="checked"&&"defaultChecked"in w||dr(t,u,null,f,i);for(u in w)f=w[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?g=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||dr(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=""),Ls(e.type=="template"?t.content:t,yr(d)?d:[d],e,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&kt(n,0),s,l),o!=null)for(u=o.length;u--;)Vi(o[u]);s&&b!="textarea"||(u="value",b=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||b=="progress"&&!g||b=="option"&&g!=v[u])&&dr(t,u,g,v[u],i),u="checked",m!=null&&m!=t[u]&&dr(t,u,m,v[u],i))}return t}function qi(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){H.__e(i,n)}}function Gs(t,e,n){var r,i;if(H.unmount&&H.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||qi(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){H.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Gs(r[i],e,n||typeof t.type!="function");n||Vi(t.__e),t.__c=t.__=t.__e=void 0}function up(t,e,n){return this.constructor(t,n)}function Ms(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),H.__&&H.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],ji(e,t=(!r&&n||e).__k=ip(Pe,null,[t]),i||pr,pr,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?vr.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),Ps(o,t,a),t.props.children=null}vr=gr.slice,H={__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}},Ss=0,Wi=function(t){return t!=null&&t.constructor===void 0},Vt.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=rt({},this.state),typeof t=="function"&&(t=t(rt({},n),this.props)),t&&rt(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),_s(this))},Vt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),_s(this))},Vt.prototype.render=Pe,pt=[],Ts=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Rs=function(t,e){return t.__v.__b-e.__v.__b},mr.__r=0,Ui=Math.random().toString(8),hr="__d"+Ui,xn="__a"+Ui,As=/(PointerCapture)$|Capture$/i,Ki=0,Hi=ks(!1),Bi=ks(!0),np=0;var cp=["vault","repo","git"],Os="change";function Fs(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.stamp!="string"?!1:cp.includes(e.scope)}var $s="weave-bootstrap";var Yi={cwd:"",vaultRoot:"",session:""};function dp(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.cwd=="string"&&typeof e.vaultRoot=="string"&&typeof e.session=="string"}function zs(t){if(t===null||t.trim()==="")return Yi;let e;try{e=JSON.parse(t)}catch{return Yi}return dp(e)?e:Yi}var jt,te,Xi,Us,br=0,Ys=[],re=H,Hs=re.__b,Bs=re.__r,Ws=re.diffed,Ks=re.__c,Vs=re.unmount,js=re.__;function xr(t,e){re.__h&&re.__h(te,t,br||e),br=0;var n=te.__H||(te.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function Ue(t){return br=1,hp(Zs,t)}function hp(t,e,n){var r=xr(jt++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):Zs(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 Re(t,e){var n=xr(jt++,3);!re.__s&&Qi(n.__H,e)&&(n.__=t,n.u=e,te.__H.__h.push(n))}function Xs(t,e){var n=xr(jt++,4);!re.__s&&Qi(n.__H,e)&&(n.__=t,n.u=e,te.__h.push(n))}function Ae(t){return br=5,Ie(function(){return{current:t}},[])}function Ie(t,e){var n=xr(jt++,7);return Qi(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function fp(){for(var t;t=Ys.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(wr),e.__h.some(Zi),e.__h=[]}catch(n){e.__h=[],re.__e(n,t.__v)}}}re.__b=function(t){te=null,Hs&&Hs(t)},re.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),js&&js(t,e)},re.__r=function(t){Bs&&Bs(t),jt=0;var e=(te=t.__c).__H;e&&(Xi===te?(e.__h=[],te.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(wr),e.__h.some(Zi),e.__h=[],jt=0)),Xi=te},re.diffed=function(t){Ws&&Ws(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ys.push(e)!==1&&Us===re.requestAnimationFrame||((Us=re.requestAnimationFrame)||pp)(fp)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Xi=te=null},re.__c=function(t,e){e.some(function(n){try{n.__h.some(wr),n.__h=n.__h.filter(function(r){return!r.__||Zi(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],re.__e(r,n.__v)}}),Ks&&Ks(t,e)},re.unmount=function(t){Vs&&Vs(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{wr(r)}catch(i){e=i}}),n.__H=void 0,e&&re.__e(e,n.__v))};var qs=typeof requestAnimationFrame=="function";function pp(t){var e,n=function(){clearTimeout(r),qs&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);qs&&(e=requestAnimationFrame(n))}function wr(t){var e=te,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),te=e}function Zi(t){var e=te;t.__c=t.__(),te=e}function Qi(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Zs(t,e){return typeof e=="function"?e(t):e}var qt=(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},credentials:"same-origin"});function gp(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 Tt(t){var e=gp(t,"string");return typeof e=="symbol"?e:e+""}function se(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Qs(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,Tt(r.key),r)}}function le(t,e,n){return e&&Qs(t.prototype,e),n&&Qs(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function St(t){return St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},St(t)}function Js(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Js=function(){return!!t})()}function mp(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function vp(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 mp(t)}function be(t,e,n){return e=St(e),vp(t,Js()?Reflect.construct(e,n||[],St(t).constructor):e.apply(t,n))}function Ji(t,e){return Ji=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Ji(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&&Ji(t,e)}function yp(t){if(Array.isArray(t))return t}function wp(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 _r(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 ro(t,e){if(t){if(typeof t=="string")return _r(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)?_r(t,e):void 0}}function bp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
24
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
23
|
+
"use strict";(()=>{var qf=Object.create;var gs=Object.defineProperty;var Yf=Object.getOwnPropertyDescriptor;var Xf=Object.getOwnPropertyNames;var Zf=Object.getPrototypeOf,Qf=Object.prototype.hasOwnProperty;var ms=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var Jf=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xf(e))!Qf.call(t,i)&&i!==n&&gs(t,i,{get:()=>e[i],enumerable:!(r=Yf(e,i))||r.enumerable});return t};var xn=(t,e,n)=>(n=t!=null?qf(Zf(t)):{},Jf(e||!t||!t.__esModule?gs(n,"default",{value:t,enumerable:!0}):n,t));var Sr=ms((r_,uo)=>{"use strict";var Zt=typeof Reflect=="object"?Reflect:null,xl=Zt&&typeof Zt.apply=="function"?Zt.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},Er;Zt&&typeof Zt.ownKeys=="function"?Er=Zt.ownKeys:Object.getOwnPropertySymbols?Er=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Er=function(e){return Object.getOwnPropertyNames(e)};function Zp(t){console&&console.warn&&console.warn(t)}var El=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}uo.exports=W;uo.exports.once=tg;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var _l=10;function kr(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 _l},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+".");_l=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 kl(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return kl(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")xl(l,this,n);else for(var u=l.length,c=Cl(l,u),r=0;r<u;++r)xl(c[r],this,n);return!0};function Sl(t,e,n,r){var i,o,a;if(kr(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=kl(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 Sl(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return Sl(this,e,n,!0)};function Qp(){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 Tl(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=Qp.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return kr(n),this.on(e,Tl(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return kr(n),this.prependListener(e,Tl(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(kr(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():Jp(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 Al(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?eg(i):Cl(i,i.length)}W.prototype.listeners=function(e){return Al(this,e,!0)};W.prototype.rawListeners=function(e){return Al(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Rl.call(t,e)};W.prototype.listenerCount=Rl;function Rl(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?Er(this._events):[]};function Cl(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function Jp(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function eg(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function tg(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))}Ll(t,e,o,{once:!0}),e!=="error"&&ng(t,i,{once:!0})})}function ng(t,e,n){typeof t.on=="function"&&Ll(t,"error",e,n)}function Ll(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 co=ms((a_,Pl)=>{"use strict";Pl.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var vr,H,xs,Ui,mt,vs,_s,Es,Fi,hr,_n,ks,Hi,zi,$i,ep,pr={},gr=[],tp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,yr=Array.isArray;function ot(t,e){for(var n in e)t[n]=e[n];return t}function Bi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function np(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?vr.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 fr(t,a,r,i,null)}function fr(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??++xs,__i:-1,__u:0};return i==null&&H.vnode!=null&&H.vnode(o),o}function Ge(t){return t.children}function jt(t,e){this.props=t,this.context=e}function kt(t,e){if(e==null)return t.__?kt(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"?kt(t):null}function rp(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=ot({},e);o.__v=e.__v+1,H.vnode&&H.vnode(o),Wi(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??kt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,Cs(r,o,i),e.__e=e.__=null,o.__e!=n&&Ss(o)}}function Ss(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}),Ss(t)}function ys(t){(!t.__d&&(t.__d=!0)&&mt.push(t)&&!mr.__r++||vs!=H.debounceRendering)&&((vs=H.debounceRendering)||_s)(mr)}function mr(){try{for(var t,e=1;mt.length;)mt.length>e&&mt.sort(Es),t=mt.shift(),e=mt.length,rp(t)}finally{mt.length=mr.__r=0}}function Ts(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,g,v,m,b=r&&r.__k||gr,w=e.length;for(l=ip(n,e,b,l,w),h=0;h<w;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&b[f.__i]||pr,f.__i=h,m=Wi(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)),v==null&&g!=null&&(v=g),4&f.__u?(l=As(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&m!==void 0?l=m:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=v,l}function ip(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]=fr(null,a,null,null,null):yr(a)?a=t.__k[o]=fr(Ge,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=fr(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=op(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=kt(s)),Ns(s,s));return r}function As(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=As(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=kt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function op(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 ws(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||tp.test(e)?n:n+"px"}function dr(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||ws(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||ws(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(ks,"$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[_n]=r[_n]:(n[_n]=Hi,t.addEventListener(e,o?$i:zi,o)):t.removeEventListener(e,o?$i:zi,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 bs(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[hr]==null)e[hr]=Hi++;else if(e[hr]<n[_n])return;return n(H.event?H.event(e):e)}}}function Wi(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,g,v,m,b,w,E,_,L,D,G,z,F,I=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=H.__b)&&c(e);e:if(typeof I=="function"){h=a.length;try{if(w=e.props,E=I.prototype&&I.prototype.render,_=(c=I.contextType)&&r[c.__c],L=c?_?_.props.value:c.__:r,n.__c?b=(d=e.__c=n.__c).__=d.__E:(E?e.__c=d=new I(w,L):(e.__c=d=new jt(w,L),d.constructor=I,d.render=sp),_&&_.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),E&&d.__s==null&&(d.__s=d.state),E&&I.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ot({},d.__s)),ot(d.__s,I.getDerivedStateFromProps(w,d.__s))),g=d.props,v=d.state,d.__v=e,f)E&&I.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),E&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(E&&I.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)}),gr.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=kt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(w,d.__s,L),E&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,v,m)})}if(d.context=L,d.props=w,d.__P=t,d.__e=!1,D=H.__r,G=0,E)d.state=d.__s,d.__d=!1,D&&D(e),c=d.render(d.props,d.state,d.context),gr.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,D&&D(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++G<25);d.state=d.__s,d.getChildContext!=null&&(r=ot(ot({},r),d.getChildContext())),E&&!f&&d.getSnapshotBeforeUpdate!=null&&(m=d.getSnapshotBeforeUpdate(g,v)),z=c!=null&&c.type===Ge&&c.key==null?Ls(c.props.children):c,s=Ts(t,yr(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),b&&(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--;)Bi(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||Rs(e),H.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=ap(n.__e,e,n,r,i,o,a,l,u);return(c=H.diffed)&&c(e),128&e.__u?void 0:s}function Rs(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Rs))}function Cs(t,e,n){for(var r=0;r<n.length;r++)Ki(n[r],n[++r],n[++r]);H.__c&&H.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){H.__e(o,i.__v)}})}function Ls(t){return typeof t!="object"||t==null||t.__b>0?t:yr(t)?t.map(Ls):t.constructor!==void 0?null:ot({},t)}function ap(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,g,v,m=n.props||pr,b=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(b);t=document.createElementNS(i,w,b.is&&b),s&&(H.__m&&H.__m(e,o),s=!1),o=null}if(w==null)m===b||s&&t.data==b||(t.data=b);else{if(o=w=="textarea"&&b.defaultValue!=null?null:o&&vr.call(t.childNodes),!s&&o!=null)for(m={},u=0;u<t.attributes.length;u++)m[(f=t.attributes[u]).name]=f.value;for(u in m)f=m[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in b||u=="value"&&"defaultValue"in b||u=="checked"&&"defaultChecked"in b||dr(t,u,null,f,i);for(u in b)f=b[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?g=f:u=="checked"?v=f:s&&typeof f!="function"||m[u]===f||dr(t,u,f,m[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=""),Ts(e.type=="template"?t.content:t,yr(d)?d:[d],e,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&kt(n,0),s,l),o!=null)for(u=o.length;u--;)Bi(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!=m[u])&&dr(t,u,g,m[u],i),u="checked",v!=null&&v!=t[u]&&dr(t,u,v,m[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){H.__e(i,n)}}function Ns(t,e,n){var r,i;if(H.unmount&&H.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){H.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Ns(r[i],e,n||typeof t.type!="function");n||Bi(t.__e),t.__c=t.__=t.__e=void 0}function sp(t,e,n){return this.constructor(t,n)}function Ps(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),H.__&&H.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],Wi(e,t=(!r&&n||e).__k=np(Ge,null,[t]),i||pr,pr,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?vr.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),Cs(o,t,a),t.props.children=null}vr=gr.slice,H={__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}},xs=0,Ui=function(t){return t!=null&&t.constructor===void 0},jt.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ot({},this.state),typeof t=="function"&&(t=t(ot({},n),this.props)),t&&ot(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ys(this))},jt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ys(this))},jt.prototype.render=Ge,mt=[],_s=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Es=function(t,e){return t.__v.__b-e.__v.__b},mr.__r=0,Fi=Math.random().toString(8),hr="__d"+Fi,_n="__a"+Fi,ks=/(PointerCapture)$|Capture$/i,Hi=0,zi=bs(!1),$i=bs(!0),ep=0;var lp=["vault","repo","git"],Ds="change";function Gs(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.stamp!="string"?!1:lp.includes(e.scope)}var Is="weave-bootstrap";var Vi={cwd:"",vaultRoot:"",session:""};function up(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.cwd=="string"&&typeof e.vaultRoot=="string"&&typeof e.session=="string"}function Ms(t){if(t===null||t.trim()==="")return Vi;let e;try{e=JSON.parse(t)}catch{return Vi}return up(e)?e:Vi}var qt,te,ji,Os,En=0,Ks=[],re=H,Fs=re.__b,zs=re.__r,$s=re.diffed,Us=re.__c,Hs=re.unmount,Bs=re.__;function br(t,e){re.__h&&re.__h(te,t,En||e),En=0;var n=te.__H||(te.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function He(t){return En=1,cp(qs,t)}function cp(t,e,n){var r=br(qt++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):qs(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 me(t,e){var n=br(qt++,3);!re.__s&&Yi(n.__H,e)&&(n.__=t,n.u=e,te.__H.__h.push(n))}function Vs(t,e){var n=br(qt++,4);!re.__s&&Yi(n.__H,e)&&(n.__=t,n.u=e,te.__h.push(n))}function ye(t){return En=5,Ce(function(){return{current:t}},[])}function Ce(t,e){var n=br(qt++,7);return Yi(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function js(t,e){return En=8,Ce(function(){return t},e)}function dp(){for(var t;t=Ks.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(wr),e.__h.some(qi),e.__h=[]}catch(n){e.__h=[],re.__e(n,t.__v)}}}re.__b=function(t){te=null,Fs&&Fs(t)},re.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Bs&&Bs(t,e)},re.__r=function(t){zs&&zs(t),qt=0;var e=(te=t.__c).__H;e&&(ji===te?(e.__h=[],te.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(wr),e.__h.some(qi),e.__h=[],qt=0)),ji=te},re.diffed=function(t){$s&&$s(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ks.push(e)!==1&&Os===re.requestAnimationFrame||((Os=re.requestAnimationFrame)||hp)(dp)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),ji=te=null},re.__c=function(t,e){e.some(function(n){try{n.__h.some(wr),n.__h=n.__h.filter(function(r){return!r.__||qi(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],re.__e(r,n.__v)}}),Us&&Us(t,e)},re.unmount=function(t){Hs&&Hs(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{wr(r)}catch(i){e=i}}),n.__H=void 0,e&&re.__e(e,n.__v))};var Ws=typeof requestAnimationFrame=="function";function hp(t){var e,n=function(){clearTimeout(r),Ws&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);Ws&&(e=requestAnimationFrame(n))}function wr(t){var e=te,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),te=e}function qi(t){var e=te;t.__c=t.__(),te=e}function Yi(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function qs(t,e){return typeof e=="function"?e(t):e}var St=(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},credentials:"same-origin"});function fp(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 At(t){var e=fp(t,"string");return typeof e=="symbol"?e:e+""}function se(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ys(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,At(r.key),r)}}function le(t,e,n){return e&&Ys(t.prototype,e),n&&Ys(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Tt(t){return Tt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Tt(t)}function Xs(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xs=function(){return!!t})()}function pp(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function gp(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 pp(t)}function _e(t,e,n){return e=Tt(e),gp(t,Xs()?Reflect.construct(e,n||[],Tt(t).constructor):e.apply(t,n))}function Xi(t,e){return Xi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Xi(t,e)}function Ee(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&&Xi(t,e)}function mp(t){if(Array.isArray(t))return t}function vp(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 xr(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 eo(t,e){if(t){if(typeof t=="string")return xr(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)?xr(t,e):void 0}}function yp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
24
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vt(t,e){return mp(t)||vp(t,e)||eo(t,e)||yp()}var Zi={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 Zs=new Int8Array(4),Qi=new Int32Array(Zs.buffer,0,1),wp=new Float32Array(Zs.buffer,0,1),bp=/^\s*rgba?\s*\(/,xp=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function _p(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(bp.test(t)){var o=t.match(xp);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 Yt={};for(kn in Zi)Yt[kn]=Xt(Zi[kn]),Yt[Zi[kn]]=Yt[kn];var kn;function Qs(t,e,n,r,i){return Qi[0]=r<<24|n<<16|e<<8|t,i&&(Qi[0]=Qi[0]&4278190079),wp[0]}function Xt(t){if(t=t.toLowerCase(),typeof Yt[t]<"u")return Yt[t];var e=_p(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=Qs(n,r,i,o,!0);return Yt[t]=a,a}var Ji={};function to(t){if(typeof Ji[t]<"u")return Ji[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=Qs(e,n,r,i,!0);return Ji[t]=o,o}function no(t,e,n,r){return n+(e<<8)+(t<<16)}function ro(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=vt(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=At(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Js(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 N(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Js(Object(n),!0).forEach(function(r){S(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Js(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ep(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=Tt(t))!==null;);return t}function ao(){return ao=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=Ep(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},ao.apply(null,arguments)}function al(t,e,n,r){var i=ao(Tt(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function kp(t){return t.normalized?1:t.size}function io(t){var e=0;return t.forEach(function(n){return e+=kp(n)}),e}function sl(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:
|
|
25
25
|
`.concat(a,`
|
|
26
|
-
`).concat(n))}return i}function
|
|
27
|
-
`,
|
|
26
|
+
`).concat(n))}return i}function Sp(t,e){return sl("VERTEX",t,e)}function Tp(t,e){return sl("FRAGMENT",t,e)}function Ap(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 el(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 tl=`#define PICKING_MODE
|
|
27
|
+
`,Rp=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 ll=(function(){function t(e,n,r){se(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=io(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,tl+i.VERTEX_SHADER_SOURCE,tl+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=io(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 le(t,[{key:"kill",value:function(){el(this.normalProgram),this.pickProgram&&(el(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=Sp(r,i),c=Tp(r,o),h=Ap(r,[u,c]),d={};s.UNIFORMS.forEach(function(v){var m=r.getUniformLocation(h,v);m&&(d[v]=m)});var f={};s.ATTRIBUTES.forEach(function(v){f[v.name]=r.getAttribLocation(h,v.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(v){f[v.name]=r.getAttribLocation(h,v.name)}),g=r.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:g||{},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=Rp[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:io(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(N(N({},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 Cp=(function(t){function e(){return se(this,e),_e(this,e,arguments)}return Ee(e,t),le(e,[{key:"kill",value:function(){al(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(to(r),a,o)}}])})(ll);var so=(function(t){function e(){var n;se(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=_e(this,e,[].concat(i)),S(n,"drawLabel",void 0),n}return Ee(e,t),le(e,[{key:"kill",value:function(){al(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(to(r),l,o,a,s)}}])})(ll);function Lp(t,e){return(function(){function n(r,i,o){se(this,n),S(this,"drawLabel",e),this.programs=t.map(function(a){return new a(r,i,o)})}return le(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 ul(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,g=r.x,v=r.y,m=(d+g)/2,b=(f+v)/2,w=g-d,E=v-f,_=Math.sqrt(w*w+E*E);if(!(_<c+h)){d+=w*c/_,f+=E*c/_,g-=w*h/_,v-=E*h/_,m=(d+g)/2,b=(f+v)/2,w=g-d,E=v-f,_=Math.sqrt(w*w+E*E);var L=t.measureText(u).width;if(L>_){var D="…";for(u=u+D,L=t.measureText(u).width;L>_&&u.length>1;)u=u.slice(0,-2)+D,L=t.measureText(u).width;if(u.length<4)return}var G;w>0?E>0?G=Math.acos(w/_):G=Math.asin(E/_):E>0?G=Math.acos(w/_)+Math.PI:G=Math.asin(w/_)+Math.PI/2,t.save(),t.translate(m,b),t.rotate(G),t.fillText(u,-L/2,e.size/2+o),t.restore()}}}function lo(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 cl(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,lo(t,e,n)}var Np=`
|
|
28
28
|
precision highp float;
|
|
29
29
|
|
|
30
30
|
varying vec4 v_color;
|
|
@@ -56,7 +56,7 @@ void main(void) {
|
|
|
56
56
|
gl_FragColor = mix(v_color, transparent, t);
|
|
57
57
|
#endif
|
|
58
58
|
}
|
|
59
|
-
`,
|
|
59
|
+
`,Pp=Np,Dp=`
|
|
60
60
|
attribute vec4 a_id;
|
|
61
61
|
attribute vec4 a_color;
|
|
62
62
|
attribute vec2 a_position;
|
|
@@ -97,7 +97,7 @@ void main() {
|
|
|
97
97
|
|
|
98
98
|
v_color.a *= bias;
|
|
99
99
|
}
|
|
100
|
-
`,
|
|
100
|
+
`,Gp=Dp,dl=WebGLRenderingContext,nl=dl.UNSIGNED_BYTE,oo=dl.FLOAT,Ip=["u_sizeRatio","u_correctionRatio","u_matrix"],Tn=(function(t){function e(){return se(this,e),_e(this,e,arguments)}return Ee(e,t),le(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Gp,FRAGMENT_SHADER_SOURCE:Pp,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ip,ATTRIBUTES:[{name:"a_position",size:2,type:oo},{name:"a_size",size:1,type:oo},{name:"a_color",size:4,type:nl,normalized:!0},{name:"a_id",size:4,type:nl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:oo}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Xt(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)}}])})(Cp);S(Tn,"ANGLE_1",0);S(Tn,"ANGLE_2",2*Math.PI/3);S(Tn,"ANGLE_3",4*Math.PI/3);var Mp=`
|
|
101
101
|
precision mediump float;
|
|
102
102
|
|
|
103
103
|
varying vec4 v_color;
|
|
@@ -105,7 +105,7 @@ varying vec4 v_color;
|
|
|
105
105
|
void main(void) {
|
|
106
106
|
gl_FragColor = v_color;
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
`,Op=Mp,Fp=`
|
|
109
109
|
attribute vec2 a_position;
|
|
110
110
|
attribute vec2 a_normal;
|
|
111
111
|
attribute float a_radius;
|
|
@@ -171,7 +171,7 @@ void main() {
|
|
|
171
171
|
|
|
172
172
|
v_color.a *= bias;
|
|
173
173
|
}
|
|
174
|
-
`,
|
|
174
|
+
`,zp=Fp,hl=WebGLRenderingContext,rl=hl.UNSIGNED_BYTE,_r=hl.FLOAT,$p=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],fl={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function pl(t){var e=N(N({},fl),t||{});return(function(n){function r(){return se(this,r),_e(this,r,arguments)}return Ee(r,n),le(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:zp,FRAGMENT_SHADER_SOURCE:Op,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$p,ATTRIBUTES:[{name:"a_position",size:2,type:_r},{name:"a_normal",size:2,type:_r},{name:"a_radius",size:1,type:_r},{name:"a_color",size:4,type:rl,normalized:!0},{name:"a_id",size:4,type:rl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:_r}],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,g=s.y,v=l.x,m=l.y,b=Xt(u.color),w=v-f,E=m-g,_=w*w+E*E,L=0,D=0;_&&(_=1/Math.sqrt(_),L=-E*_*h,D=w*_*h);var G=this.array;G[a++]=v,G[a++]=m,G[a++]=-L,G[a++]=-D,G[a++]=d,G[a++]=b,G[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,g=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(g,e.widenessToThicknessRatio)}}])})(so)}var e_=pl();var Up=`
|
|
175
175
|
precision mediump float;
|
|
176
176
|
|
|
177
177
|
varying vec4 v_color;
|
|
@@ -197,7 +197,7 @@ void main(void) {
|
|
|
197
197
|
gl_FragColor = mix(v_color, transparent, t);
|
|
198
198
|
#endif
|
|
199
199
|
}
|
|
200
|
-
`,
|
|
200
|
+
`,gl=Up,Hp=`
|
|
201
201
|
attribute vec4 a_id;
|
|
202
202
|
attribute vec4 a_color;
|
|
203
203
|
attribute vec2 a_normal;
|
|
@@ -265,7 +265,7 @@ void main() {
|
|
|
265
265
|
|
|
266
266
|
v_color.a *= bias;
|
|
267
267
|
}
|
|
268
|
-
`,
|
|
268
|
+
`,Bp=Hp,ml=WebGLRenderingContext,il=ml.UNSIGNED_BYTE,Rt=ml.FLOAT,Wp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Kp={lengthToThicknessRatio:fl.lengthToThicknessRatio};function vl(t){var e=N(N({},Kp),t||{});return(function(n){function r(){return se(this,r),_e(this,r,arguments)}return Ee(r,n),le(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Bp,FRAGMENT_SHADER_SOURCE:gl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Wp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Rt},{name:"a_positionEnd",size:2,type:Rt},{name:"a_normal",size:2,type:Rt},{name:"a_color",size:4,type:il,normalized:!0},{name:"a_id",size:4,type:il,normalized:!0},{name:"a_radius",size:1,type:Rt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Rt},{name:"a_normalCoef",size:1,type:Rt},{name:"a_radiusCoef",size:1,type:Rt}],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,g=l.y,v=Xt(u.color),m=f-h,b=g-d,w=l.size||1,E=m*m+b*b,_=0,L=0;E&&(E=1/Math.sqrt(E),_=-b*E*c,L=m*E*c);var D=this.array;D[a++]=h,D[a++]=d,D[a++]=f,D[a++]=g,D[a++]=_,D[a++]=L,D[a++]=v,D[a++]=o,D[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,g=l.u_sizeRatio,v=l.u_minEdgeThickness,m=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(g,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(v,o.minEdgeThickness),s.uniform1f(m,e.lengthToThicknessRatio)}}])})(so)}var t_=vl();function Vp(t){return Lp([vl(t),pl(t)])}var jp=Vp(),yl=jp,qp=`
|
|
269
269
|
attribute vec4 a_id;
|
|
270
270
|
attribute vec4 a_color;
|
|
271
271
|
attribute vec2 a_normal;
|
|
@@ -330,15 +330,15 @@ void main() {
|
|
|
330
330
|
|
|
331
331
|
v_color.a *= bias;
|
|
332
332
|
}
|
|
333
|
-
`,Zp=Xp,_l=WebGLRenderingContext,ll=_l.UNSIGNED_BYTE,En=_l.FLOAT,Qp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],El=(function(t){function e(){return se(this,e),be(this,e,arguments)}return xe(e,t),le(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Zp,FRAGMENT_SHADER_SOURCE:yl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Qp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:En},{name:"a_positionEnd",size:2,type:En},{name:"a_normal",size:2,type:En},{name:"a_color",size:4,type:ll,normalized:!0},{name:"a_id",size:4,type:ll,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:En},{name:"a_normalCoef",size:1,type:En}],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=Xt(s.color),g=h-u,m=d-c,v=g*g+m*m,w=0,b=0;v&&(v=1/Math.sqrt(v),w=-m*v*l,b=g*v*l);var E=this.array;E[i++]=u,E[i++]=c,E[i++]=h,E[i++]=d,E[i++]=w,E[i++]=b,E[i++]=f,E[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)}}])})(co);var Il=bn(Tr()),Rr=(function(t){function e(){var n;return se(this,e),n=be(this,e),n.rawEmitter=n,n}return xe(e,t),le(e)})(Il.EventEmitter);var Fl=bn(po());var og=function(e){return e},ag=function(e){return e*e},sg=function(e){return e*(2-e)},lg=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},ug=function(e){return e*e*e},cg=function(e){return--e*e*e+1},dg=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},$l={linear:og,quadraticIn:ag,quadraticOut:sg,quadraticInOut:lg,cubicIn:ug,cubicOut:cg,cubicInOut:dg},zl={easing:"quadraticInOut",duration:150};function Ge(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ar(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function Ml(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 Ol(t,e,n){return t[6]=e,t[7]=n,t}function mt(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],w=e[6],b=e[7],E=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]=w*n+b*o+E*l,t[7]=w*r+b*a+E*u,t[8]=w*i+b*s+E*c,t}function Cr(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 hg(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 Qt(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=Ge(),d=Math.min(u,c)-2*r,f=hg(e,n);return i?(mt(h,Ol(Ge(),s,l)),mt(h,Ar(Ge(),a)),mt(h,Ml(Ge(),o)),mt(h,Ar(Ge(),u/d/2/f,c/d/2/f))):(mt(h,Ar(Ge(),2*(d/u)*f,2*(d/c)*f)),mt(h,Ml(Ge(),-o)),mt(h,Ar(Ge(),1/a)),mt(h,Ol(Ge(),-s,-l))),h}function Ul(t,e,n){var r=Cr(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 Hl(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 Bl(t){if(!(0,Fl.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 Wl(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 go(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function mo(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 vo(t){var e=gt(t.x,2),n=e[0],r=e[1],i=gt(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 Lr(t){"@babel/helpers - typeof";return Lr=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},Lr(t)}function yo(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 Nr(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 Dr={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:hl,defaultDrawNodeLabel:ho,defaultDrawNodeHover:fl,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:{}},fg={circle:kn},pg={arrow:xl,line:El};function Pr(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 Kl(t){var e=Nr({},Dr,t);return e.nodeProgramClasses=Nr({},fg,e.nodeProgramClasses),e.edgeProgramClasses=Nr({},pg,e.edgeProgramClasses),e}var T_=bn(Tr()),R_=bn(po()),Ir=1.5,Vl=(function(t){function e(){var n;return se(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),le(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(N(N({},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=N(N({},zl),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:$l[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||Ir)},r):this.animate({ratio:this.ratio/Ir})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Ir)},r):this.animate({ratio:this.ratio*Ir})}},{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)}}])})(Rr);function He(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function it(t,e){var n=N(N({},He(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function Sn(t){var e="x"in t?t:N(N({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function gg(t,e){return N(N({},it(t,e)),{},{delta:Ql(t)})}var mg=2;function Gr(t){for(var e=[],n=0,r=Math.min(t.length,mg);n<r;n++)e.push(t[n]);return e}function Tn(t,e,n){var r={touches:Gr(t.touches).map(function(i){return He(i,n)}),previousTouches:e.map(function(i){return He(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Ql(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 Jl=(function(t){function e(n,r){var i;return se(this,e),i=be(this,e),i.container=n,i.renderer=r,i}return xe(e,t),le(e)})(Rr),vg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],yg=vg.reduce(function(t,e){return N(N({},t),{},S({},e,Dr[e]))},{}),wg=(function(t){function e(n,r){var i;return se(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",yg),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),le(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",it(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",it(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=it(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(He(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=He(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",it(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=He(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",it(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=it(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=He(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",it(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",it(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Ql(r);if(a){var s=gg(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(He(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}}])})(Jl),bg=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],xg=bg.reduce(function(t,e){return N(N({},t),{},S({},e,Dr[e]))},{}),_g=(function(t){function e(n,r){var i;return se(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",xg),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),le(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=Gr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return He(f,i.container)}),this.touchMode===2){var a=gt(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",Tn(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",Tn(r,this.lastTouches,this.container)),!r.touches.length){var s=He(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=Tn(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=Tn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Gr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Gr(r.touches),a=o.map(function(Xe){return He(Xe,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=Tn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Xe,gn){var De=i.startTouchesPositions[gn];return De&&(Xe.x!==De.x||Xe.y!==De.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,w=m.y;u.setState({x:c.x+f-v,y:c.y+g-w});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},E=a[0],_=E.x,L=E.y,P=a[1],I=P.x,$=P.y,F=Math.atan2($-L,I-_)-this.startTouchesAngle,G=Math.hypot($-L,I-_)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);b.ratio=U,b.angle=c.angle+F;var j=this.getDimensions(),J=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(j.width,j.height)-2*h,he=ge/j.width,Ye=ge/j.height,$t=U/ge,Fe=_-ge/2/he,$e=L-ge/2/Ye,ze=[Fe*Math.cos(-b.angle)-$e*Math.sin(-b.angle),$e*Math.cos(-b.angle)+Fe*Math.sin(-b.angle)];Fe=ze[0],$e=ze[1],b.x=J.x-Fe*$t,b.y=J.y+$e*$t,u.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Jl);function Eg(t){if(Array.isArray(t))return _r(t)}function kg(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Sg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
334
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jl(t){return Eg(t)||kg(t)||ro(t)||Sg()}function Tg(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 wo(t,e){if(t==null)return{};var n,r,i=Tg(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 ql=(function(){function t(e,n){se(this,t),this.key=e,this.size=n}return le(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Yl=(function(){function t(){se(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 le(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 ql(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(ql.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 Rg(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 Xl=150,Zl=50,ot=Object.prototype.hasOwnProperty;function Ag(t,e,n){if(!ot.call(n,"x")||!ot.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),ot.call(n,"hidden")||(n.hidden=!1),ot.call(n,"highlighted")||(n.highlighted=!1),ot.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Cg(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),ot.call(n,"hidden")||(n.hidden=!1),ot.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Lg=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(se(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 Yl),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",Ge()),S(i,"invMatrix",Ge()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",vo({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",go()),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=Kl(o),Pr(i.settings),Bl(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 Vl,i.bindCameraHandlers(),i.mouseCaptor=new wg(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new _g(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return xe(e,t),le(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=wo(i,[r].map(Tt));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=wo(s,[r].map(Tt));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=wo(i,[r].map(Tt));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=ao(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=oo.apply(void 0,jl(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=Sn(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",N(N({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",N(N({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",N(N({},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",N(N({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",N(N({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=Sn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Sn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",N(N({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",N(N({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",N({},s))},this.activeListeners.handleEnter=function(o){var a=Sn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",N({},s))};var i=function(a){return function(s){var l=Sn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),N(N({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),N(N({},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=ao(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=oo.apply(void 0,jl(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=Hl(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=vo(this.customBBox||this.nodeExtent);var d=new Vl,f=Qt(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},m={},v={},w={},b=1,E=i.nodes(),_=0,L=E.length;_<L;_++){var P=E[_],I=this.nodeDataCache[P],$=i.getNodeAttributes(P);I.x=$.x,I.y=$.y,this.normalizationFunction.applyTo(I),typeof I.label=="string"&&!I.hidden&&this.labelGrid.add(P,I.size,this.framedGraphToViewport(I,{matrix:f})),g[I.type]=(g[I.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!ot.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]&&(E=mo(this.nodeZExtent,function(mn){return r.nodeDataCache[mn].zIndex},E));for(var G=0,U=E.length;G<U;G++){var j=E[G];m[j]=b,w[m[j]]={type:"node",id:j},b++;var J=this.nodeDataCache[j];this.addNodeToProgram(j,m[j],g[J.type]++)}for(var ge={},he=i.edges(),Ye=0,$t=he.length;Ye<$t;Ye++){var Fe=he[Ye],$e=this.edgeDataCache[Fe];ge[$e.type]=(ge[$e.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=mo(this.edgeZExtent,function(mn){return r.edgeDataCache[mn].zIndex},he));for(var ze in this.edgePrograms){if(!ot.call(this.edgePrograms,ze))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ze,'"!'));this.edgePrograms[ze].reallocate(ge[ze]||0),ge[ze]=0}for(var Xe=0,gn=he.length;Xe<gn;Xe++){var De=he[Xe];v[De]=b,w[v[De]]={type:"edge",id:De},b++;var q=this.edgeDataCache[De];this.addEdgeToProgram(De,v[De],ge[q.type]++)}return this.itemIDsIndex=w,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&&Lr(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=N({},r),u=s||this.nodeExtent,c=gt(u.x,2),h=c[0],d=c[1],f=gt(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})],w=1/0,b=-1/0,E=1/0,_=-1/0;v.forEach(function(ge){var he=ge.x,Ye=ge.y;w=Math.min(w,he),b=Math.max(b,he),E=Math.min(E,Ye),_=Math.max(_,Ye)});var L=b-w,P=_-E,I=this.getDimensions(),$=I.width,F=I.height,G=0,U=0;if(L>=$?b<$-a?G=b-($-a):w>a&&(G=w-a):b>$+a?G=b-($+a):w<-a&&(G=w+a),P>=F?_<F-a?U=_-(F-a):E>a&&(U=E-a):_>F+a?U=_-(F+a):E<-a&&(U=E+a),G||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),J=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=J.x-j.x,U=J.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);yo(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<-Xl||h>this.width+Xl||d<-Zl||d>this.height+Zl)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||g;v(o,N(N({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=Rg({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});yo(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,N(N({key:l},d),{},{size:this.scaleSize(d.size)}),N(N(N({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),N(N(N({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,w=m.y,b=r.scaleSize(g.size),E=r.settings.defaultDrawNodeHover,_=r.nodePrograms[g.type],L=_?.drawHover||E;L(i,N(N({key:f},g),{},{size:b,x:v,y:w}),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=Qt(s,l,u,c),this.invMatrix=Qt(s,l,u,c,!0),this.correctionRatio=Ul(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=Ag(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=Cg(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 Yl,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=Wl(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=N({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 N({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=N({},this.settings);return this.settings[r]=i,Pr(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=N({},this.settings);return this.settings=N(N({},this.settings),r),Pr(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=go(),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,w=m.length;v<w;v++){var b=m[v];if(this.updateEdge(b),o){var E=this.edgeProgramIndex[b];if(E===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],E)}}}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(N(N({},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?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Cr(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?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Cr(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}}])})(Rr),eu=Lg;function tu(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return nu(this.cover(e,n),e,n,t)}function nu(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,w,b;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[w=v<<1|m]))return i[w]=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[w]=a:t._root=a,t;do i=i?i[w]=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((w=v<<1|m)===(b=(g>=d)<<1|f>=h));return i[b]=o,i[w]=a,t}function ru(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)nu(this,a[n],s[n],t[n]);return this}function iu(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 ou(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function au(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 su(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,w=(s+u)/2;d.push(new fe(f[3],v,w,l,u),new fe(f[2],a,w,v,u),new fe(f[1],v,s,l,w),new fe(f[0],a,s,v,w)),(m=(e>=w)<<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 b=t-+this._x.call(null,f.data),E=e-+this._y.call(null,f.data),_=b*b+E*E;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 lu(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,w;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,w=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[w]=n:this._root=n),this):(this._root=o,this)}function uu(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function cu(){return this._root}function du(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function hu(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 fu(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 pu(t){return t[0]}function gu(t){return arguments.length?(this._x=t,this):this._x}function mu(t){return t[1]}function vu(t){return arguments.length?(this._y=t,this):this._y}function At(t,e,n){var r=new bo(e??pu,n??mu,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function bo(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 yu(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var _e=At.prototype=bo.prototype;_e.copy=function(){var t=new bo(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=yu(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]=yu(r));return t};_e.add=tu;_e.addAll=ru;_e.cover=iu;_e.data=ou;_e.extent=au;_e.find=su;_e.remove=lu;_e.removeAll=uu;_e.root=cu;_e.size=du;_e.visit=hu;_e.visitAfter=fu;_e.x=gu;_e.y=vu;function ie(t){return function(){return t}}function Be(t){return(t()-.5)*1e-6}function Ng(t){return t.x+t.vx}function Dg(t){return t.y+t.vy}function xo(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ie(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,g,m,v,w=0;w<o;++w)for(h=At(e,Ng,Dg).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(b);function b(E,_,L,P,I){var $=E.data,F=E.r,G=m+F;if($){if($.index>d.index){var U=f-$.x-$.vx,j=g-$.y-$.vy,J=U*U+j*j;J<G*G&&(U===0&&(U=Be(r),J+=U*U),j===0&&(j=Be(r),J+=j*j),J=(G-(J=Math.sqrt(J)))/J*i,d.vx+=(U*=J)*(G=(F*=F)/(v+F)),d.vy+=(j*=J)*G,$.vx-=U*(G=1-G),$.vy-=j*G)}return}return _>f+G||P<f-G||L>g+G||I<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:ie(+u),l(),a):t},a}function Pg(t){return t.index}function wu(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function _o(t){var e=Pg,n=h,r,i=ie(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 w=0,b=t.length;w<c;++w)for(var E=0,_,L,P,I,$,F,G;E<b;++E)_=t[E],L=_.source,P=_.target,I=P.x+P.vx-L.x-L.vx||Be(u),$=P.y+P.vy-L.y-L.vy||Be(u),F=Math.sqrt(I*I+$*$),F=(F-o[E])/F*v*r[E],I*=F,$*=F,P.vx-=I*(G=l[E]),P.vy-=$*G,L.vx+=I*(G=1-G),L.vy+=$*G}function f(){if(a){var v,w=a.length,b=t.length,E=new Map(a.map((L,P)=>[e(L,P,a),L])),_;for(v=0,s=new Array(w);v<b;++v)_=t[v],_.index=v,typeof _.source!="object"&&(_.source=wu(E,_.source)),typeof _.target!="object"&&(_.target=wu(E,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(v=0,l=new Array(b);v<b;++v)_=t[v],l[v]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(b),g(),o=new Array(b),m()}}function g(){if(a)for(var v=0,w=t.length;v<w;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,w=t.length;v<w;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,w){a=v,u=w,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:ie(+v),g(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ie(+v),m(),d):i},d}var Ig={value:()=>{}};function xu(){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 Mr(n)}function Mr(t){this._=t}function Gg(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}})}Mr.prototype=xu.prototype={constructor:Mr,on:function(t,e){var n=this._,r=Gg(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=Mg(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]=bu(n[i],t.name,e);else if(e==null)for(i in n)n[i]=bu(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 Mr(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 Mg(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function bu(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 Eo=xu;var Jt=0,An=0,Rn=0,Eu=1e3,Or,Cn,Fr=0,Ct=0,$r=0,Ln=typeof performance=="object"&&performance.now?performance:Date,ku=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function To(){return Ct||(ku(Og),Ct=Ln.now()+$r)}function Og(){Ct=0}function ko(){this._call=this._time=this._next=null}ko.prototype=zr.prototype={constructor:ko,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?To():+n)+(e==null?0:+e),!this._next&&Cn!==this&&(Cn?Cn._next=this:Or=this,Cn=this),this._call=t,this._time=n,So()},stop:function(){this._call&&(this._call=null,this._time=1/0,So())}};function zr(t,e,n){var r=new ko;return r.restart(t,e,n),r}function Su(){To(),++Jt;for(var t=Or,e;t;)(e=Ct-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Jt}function _u(){Ct=(Fr=Ln.now())+$r,Jt=An=0;try{Su()}finally{Jt=0,$g(),Ct=0}}function Fg(){var t=Ln.now(),e=t-Fr;e>Eu&&($r-=e,Fr=t)}function $g(){for(var t,e=Or,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:Or=n);Cn=t,So(r)}function So(t){if(!Jt){An&&(An=clearTimeout(An));var e=t-Ct;e>24?(t<1/0&&(An=setTimeout(_u,t-Ln.now()-$r)),Rn&&(Rn=clearInterval(Rn))):(Rn||(Fr=Ln.now(),Rn=setInterval(Fg,Eu)),Jt=1,ku(_u))}}function Tu(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Ru(t){return t.x}function Au(t){return t.y}var zg=10,Ug=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=zr(h),u=Eo("tick","end"),c=Tu();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,w=t.length,b;m===void 0&&(m=1);for(var E=0;E<m;++E)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),v=0;v<w;++v)b=t[v],b.fx==null?b.x+=b.vx*=a:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=a:(b.y=b.fy,b.vy=0);return e}function f(){for(var m=0,v=t.length,w;m<v;++m){if(w=t[m],w.index=m,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var b=zg*Math.sqrt(.5+m),E=m*Ug;w.x=b*Math.cos(E),w.y=b*Math.sin(E)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.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,w){var b=0,E=t.length,_,L,P,I,$;for(w==null?w=1/0:w*=w,b=0;b<E;++b)I=t[b],_=m-I.x,L=v-I.y,P=_*_+L*L,P<w&&($=I,w=P);return $},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function Ao(){var t,e,n,r,i=ie(-30),o,a=1,s=1/0,l=.81;function u(f){var g,m=t.length,v=At(t,Ru,Au).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,w=0,b,E,_;if(f.length){for(b=E=_=0;_<4;++_)(m=f[_])&&(v=Math.abs(m.value))&&(g+=m.value,w+=v,b+=v*m.x,E+=v*m.y);f.x=b/w,f.y=E/w}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 w=f.x-e.x,b=f.y-e.y,E=v-g,_=w*w+b*b;if(E*E/l<_)return _<s&&(w===0&&(w=Be(n),_+=w*w),b===0&&(b=Be(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)),e.vx+=w*f.value*r/_,e.vy+=b*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(w===0&&(w=Be(n),_+=w*w),b===0&&(b=Be(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(E=o[f.data.index]*r/_,e.vx+=w*E,e.vy+=b*E);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:ie(+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 Co(t){var e=ie(.1),n,r,i;typeof t!="function"&&(t=ie(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:ie(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ie(+s),a(),o):t},o}function Lo(t){var e=ie(.1),n,r,i;typeof t!="function"&&(t=ie(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:ie(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ie(+s),a(),o):t},o}var Dn=9,Pn=Dn+9,Hg=2*Pn+4,Po=70,Bg=220,Wg=.35;function Kg(t,e){let n=Po;for(let r of t){let i=Br(e.get(r)?.length??0);i>n&&(n=i)}return n}var Vg=-180,jg=.1,qg=.02,Yg=.4,Xg=300,Zg=1,Nu=1280,Du=800,Cu=.001,Ur=Math.PI*2,Qg=-Math.PI/2;function Do(t){return t==="contains"||t==="anchored-at"}function Hr(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}function Nn(t,e){return Hr(`${e}\0${t}`)/4294967296}function Jg(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Br(t){return Math.max(Po,Hg*t/Ur)}function Pu(t){let e=[],n=new Set;for(let u of t.nodes)n.has(u.id)||(n.add(u.id),e.push(u.id));let r=[],i=new Set,o=new Map,a=new Map,s=new Map;for(let u of t.edges){if(u.source===u.target||!n.has(u.source)||!n.has(u.target))continue;let c=`${u.source}\0${u.target}\0${u.kind}`;if(i.has(c)||(i.add(c),r.push(u),s.set(u.source,(s.get(u.source)??0)+1),s.set(u.target,(s.get(u.target)??0)+1),!Do(u.kind)||o.has(u.target)))continue;o.set(u.target,u.source);let h=a.get(u.source);h?h.push(u.target):a.set(u.source,[u.target])}let l=e.filter(u=>!o.has(u));return{ids:e,parent:o,children:a,roots:l,edges:r,degree:s}}function em(t,e,n){return 2*Br(e.get(t)?.length??0)+n}function tm(t,e){let n=0;return t.forEach((r,i)=>{let o=r+t[(i+1)%t.length],a=o/(4*Math.sin(Math.PI*o/(2*e)));a>n&&(n=a)}),n}function nm(t,e,n){let r=0;return e.map((i,o)=>{let a=Qg+Ur*((r+i/2)/n)+(Nn(t[o],3)-.5)*.05;return r+=i,a})}function rm(t,e=Nu,n=Du){let{ids:r,children:i,roots:o}=Pu(t),a=new Map,s=e/2,l=n/2;if(o.length===1)a.set(o[0],{x:s,y:l});else if(o.length>1){let c=Kg(o,i),h=o.map(m=>em(m,i,c)),d=0;for(let m of h)d+=m;let f=tm(h,d),g=nm(o,h,d);o.forEach((m,v)=>{let w=g[v];a.set(m,{x:s+f*Math.cos(w),y:l+f*Math.sin(w)})})}let u=[...o];for(let c=0;c<u.length;c++){let h=u[c],d=i.get(h);if(d===void 0)continue;let f=a.get(h),g=.7*Br(d.length);for(let m of d){let v=Ur*Nn(m,1),w=.85+.3*Nn(m,2);a.set(m,{x:f.x+g*w*Math.cos(v),y:f.y+g*w*Math.sin(v)}),u.push(m)}}for(let c of r){if(a.has(c))continue;let h=Ur*Nn(c,4),d=Po*(1+Nn(c,5));a.set(c,{x:s+d*Math.cos(h),y:l+d*Math.sin(h)})}return a}function No(t){return t.id}function Iu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??Xg)),r=e.seed??Zg,i=e.width??Nu,o=e.height??Du,{ids:a,children:s,edges:l,degree:u,roots:c}=Pu(t),h=new Map;if(a.length===0)return h;let d=rm(t,i,o),f=e.initial,g=a.map(m=>{let v=d.get(m);return{id:m,...Lu(f?.get(m),v),vx:0,vy:0}});g.length>1&&im(g,l,s,u,d,new Set(c),{ticks:n,seed:r});for(let m of g)h.set(m.id,Lu(m,d.get(m.id)));return h}function Lu(t,e){return t===void 0?e:{x:Number.isFinite(t.x)?t.x:e.x,y:Number.isFinite(t.y)?t.y:e.y}}function im(t,e,n,r,i,o,a){let s=e.map(g=>({source:g.source,target:g.target,kind:g.kind})),l=g=>n.get(g)?.length??0,u=g=>Math.max(l(No(g.source)),l(No(g.target))),c=g=>r.get(No(g)),h=g=>o.has(g.id)?jg:qg,d=_o(s).id(g=>g.id).distance(g=>Do(g.kind)?Br(u(g)):Bg).strength(g=>{let m=1/Math.min(c(g.source),c(g.target));return Do(g.kind)?m:m*Wg}).iterations(2),f=Ro(t).randomSource(Jg(a.seed)).force("charge",Ao().strength(Vg)).force("link",d).force("collide",xo(Pn).strength(1).iterations(3)).force("x",Co(g=>i.get(g.id).x).strength(h)).force("y",Lo(g=>i.get(g.id).y).strength(h)).alpha(1).alphaMin(Cu).alphaDecay(a.ticks>0?1-Math.pow(Cu,1/a.ticks):0).velocityDecay(Yg);f.stop();for(let g=0;g<a.ticks;g++)f.tick()}function Ce(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 om(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 Mu(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 am(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function sm(t,e){return t.slice().sort((n,r)=>{let i=Ce(e.get(n)),o=Ce(e.get(r));return i.localeCompare(o)})}function Gu(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 lm(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?Gu(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?Gu(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 Io(t,e){let n=om(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let w=(i.get(g)??[]).filter(b=>{let E=r.get(b);if(!E||E.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(b))return!1;return!0}).concat(o.get(g)??[]);return w=w.filter(b=>r.has(b)),e.showInternals||(w=w.filter(b=>{let E=r.get(b);return!(E&&am(E.kind))})),sm(w,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Ce(g).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=g=>{let m=r.get(g),v=!1;for(let b of s(g))h(b)&&(v=!0);let w=u(m)||v;return w&&c.add(g),w};for(let g of a)h(g);let d=[],f=(g,m)=>{if(!c.has(g))return;let v=r.get(g),w=s(g),b=w.filter(_=>c.has(_)),E=l?b.length>0:e.expanded.has(g);if(d.push({id:g,depth:m,hasKids:w.length>0,expanded:E,label:Ce(v),kind:v.kind,provenance:v.provenance,meta:lm(v)}),E)for(let _ of b)f(_,m+1)};for(let g of a)f(g,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 In(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 um=7;function Mo(t,e){if(t===null)return"";switch(t.kind){case"relTime":return In(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,um);case"text":return t.text}}var cm=["path","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","warning","stale","preview","root","notes","state"];function Oo(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 cm){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} → ${Ce(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:`← ${Ce(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Ce(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Wr(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 dm=["contains","anchored-at"];function hm(t){return dm.includes(t)}function Kr(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=fm(t,n),i=Mu(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,pm(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:gm(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:mm(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function fm(t,e){let n=new Map;for(let r of t.edges){if(!hm(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 pm(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 gm(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 mm(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 Fo(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 en=[null,"human","agent","generated"];function Ou(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function Lt(t){return{...t.model,danglingLinks:t.dangling}}function Fu(t,e){return t===null?[]:Io(Lt(t),e)}function $u(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function ym(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function wm(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function zu(t,e){return t.query===e?t:{...t,query:e}}function Uu(t){let e=en.indexOf(t.provFilter),n=en[(e+1)%en.length]??null;return{...t,provFilter:n}}function Hu(t){return{...t,showInternals:!t.showInternals}}function jr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function zo(t,e){return t[e]?.id??null}function $o(t,e,n){if(t.length===0)return null;let r=jr(t,e),i=r===-1?n>0?-1:t.length:r;return zo(t,Math.min(t.length-1,Math.max(0,i+n)))}function bm(t,e){let n=jr(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 xm={j:"ArrowDown",k:"ArrowUp"};function _m(t){return xm[t]??t}function Bu(t,e,n,r){let i={state:e,selectedId:n,handled:!1},o=c=>({state:e,selectedId:c,handled:!0}),a=_m(r);if(a==="ArrowDown")return o($o(t,n,1));if(a==="ArrowUp")return o($o(t,n,-1));if(a==="Home")return o(zo(t,0));if(a==="End")return o(zo(t,t.length-1));if(a!=="ArrowRight"&&a!=="ArrowLeft")return i;let s=jr(t,n),l=s===-1?void 0:t[s];if(l===void 0||n===null)return i;if(a==="ArrowRight")return l.hasKids?l.expanded?o($o(t,n,1)):{state:ym(e,n),selectedId:n,handled:!0}:i;if(l.hasKids&&l.expanded)return{state:wm(e,n),selectedId:n,handled:!0};let u=bm(t,n);return u===null?i:o(u)}var Em={vault:"◆",note:"▪",repository:"▣",module:"▤",package:"◈",entryPoint:"▷",gitState:"◇",external:"↗",file:"·"};function Uo(t){return Em[t]}var km={human:"●",agent:"◐",generated:"○"};function Nt(t){return t===null?"":km[t]}function Gn(t){return t===null?"":`${t}-authored`}var Sm={open:"▾",closed:"▸",leaf:""};function Wu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Tm(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 Rm(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:Wu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindGlyph:Uo(t.kind),provenance:t.provenance,provenanceGlyph:Nt(t.provenance),provenanceTitle:Gn(t.provenance),twisty:i,twistyGlyph:Sm[i],hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:Mo(t.meta,n),level:t.depth+1}}function Ku(t,e,n){let r=Tm(t);return t.map((i,o)=>Rm(i,e,n,r[o]))}function Vu(t,e){return jr(t,e)===-1?null:Wu(e)}function ju(t){return{"--weave-depth":String(Math.max(0,t))}}function Vr(t){return t===null?"all":t}function qu(t){let e=en.indexOf(t),n=en[(e+1)%en.length]??null;return`provenance filter: ${Vr(t)} — click for ${Vr(n)}`}function Yu(t){return t?"internals":"knowledge"}function Xu(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 Zu="filter…",Qu="Vault and repository",Ju="Filter the tree",ec="Filter the tree (/)";function tc(t,e,n){if(t===null)return"loading…";let r=Go(Lt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter":"nothing to show"}function nc(t){return t.length===1?"1 row":`${t.length} rows`}var qr={dark:{accent:"#a48cff",success:"#4ade80",warning:"#fbbf24",dim:"#8f8a9c",text:"#e8e6ee",muted:"#5d5869",line:"#343141"},light:{accent:"#6d4aff",success:"#15803d",warning:"#b45309",dim:"#6f6b66",text:"#1c1b19",muted:"#9a958e",line:"#d2cec8"}},Am={vault:"accent",note:"text",repository:"accent",module:"success",package:"success",entryPoint:"warning",gitState:"warning",external:"warning",file:"dim"},Cm={contains:"line","anchored-at":"line","links-to":"accent",mentions:"warning"};function Lm(t,e){return qr[e][Am[t]]}function Nm(t,e){return qr[e][Cm[t]]}var Ho=3,Dm=32;function Pm(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Dm));return Ho+(Dn-Ho)*n}var Im={contains:.8,"anchored-at":.8,"links-to":1.4,mentions:1};function Gm(t){let e=Nt(t.provenance),n=Ce(t);return e===""?n:`${e} ${n}`}var rc={nodes:[],edges:[]};function ic(t){return`${t.source}\0${t.target}\0${t.kind}`}function Mm(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=ic(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 oc(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=Mm(e,o),s=[];for(let[c,h]of i){let d=n.get(c),f=Pm(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:Gm(h),color:Lm(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=ic(c);u.has(h)||(u.add(h),l.push({key:h,source:c.source,target:c.target,size:Im[c.kind],color:Nm(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function Om(t){return qr[t].muted}function ac(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+Fm}:{color:Om(r),label:null,zIndex:0}}var Fm=Dn+1;function sc(t){return(e,n)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1}:{hidden:!0}}var $m=(Ho+Dn)/2,zm=Pn*4,Um=1;function lc(t){let e=qr[t];return{hideEdgesOnMove:!0,renderEdgeLabels:!1,labelDensity:Um,labelGridCellSize:zm,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:Pn,allowInvalidContainer:!0}}var hc=bn(Tr(),1);function Hm(){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 ue=Hm;typeof Object.assign=="function"&&(ue=Object.assign);function Oe(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 fc(t){let e;for(e in t)return!1;return!0}function Me(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function We(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 uc(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function Bm(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function at(){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 nn(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Fn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},C=class t extends Fn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},R=class t extends Fn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends Fn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function pc(t,e){this.key=t,this.attributes=e,this.clear()}pc.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 gc(t,e){this.key=t,this.attributes=e,this.clear()}gc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function mc(t,e){this.key=t,this.attributes=e,this.clear()}mc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function rn(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}rn.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)};rn.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};rn.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]};rn.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 vc=0,yc=1,Wm=2,wc=3;function st(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===vc){if(s=t._nodes.get(r),!s)throw new R(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===wc){if(i=""+i,l=t._edges.get(i),!l)throw new R(`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 R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===yc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function Km(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);return a.attributes[s]}}function Vm(t,e,n){t.prototype[e]=function(r,i){let[o]=st(this,e,n,r,i);return o.attributes}}function jm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function qm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=st(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 Ym(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=st(this,e,n,r,i,o,a);if(typeof u!="function")throw new C(`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 Xm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(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 Zm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);if(!me(s))throw new C(`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 Qm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);if(!me(s))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return ue(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Jm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);if(typeof s!="function")throw new C(`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 ev=[{name:t=>`get${t}Attribute`,attacher:Km},{name:t=>`get${t}Attributes`,attacher:Vm},{name:t=>`has${t}Attribute`,attacher:jm},{name:t=>`set${t}Attribute`,attacher:qm},{name:t=>`update${t}Attribute`,attacher:Ym},{name:t=>`remove${t}Attribute`,attacher:Xm},{name:t=>`replace${t}Attributes`,attacher:Zm},{name:t=>`merge${t}Attributes`,attacher:Qm},{name:t=>`update${t}Attributes`,attacher:Jm}];function tv(t){ev.forEach(function({name:e,attacher:n}){n(t,e("Node"),vc),n(t,e("Source"),yc),n(t,e("Target"),Wm),n(t,e("Opposite"),wc)})}function nv(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=Oe(this,a,s,n),!o)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function rv(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=Oe(this,o,a,n),!i)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function iv(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=Oe(this,a,s,n),!o)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function ov(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=Oe(this,s,l,n),!a)throw new R(`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 R(`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 av(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=Oe(this,s,l,n),!a)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new C(`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 sv(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=Oe(this,a,s,n),!o)throw new R(`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 R(`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 lv(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=Oe(this,a,s,n),!o)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new C(`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 uv(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=Oe(this,a,s,n),!o)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return ue(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function cv(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=Oe(this,a,s,n),!o)throw new R(`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 R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new C(`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 dv=[{name:t=>`get${t}Attribute`,attacher:nv},{name:t=>`get${t}Attributes`,attacher:rv},{name:t=>`has${t}Attribute`,attacher:iv},{name:t=>`set${t}Attribute`,attacher:ov},{name:t=>`update${t}Attribute`,attacher:av},{name:t=>`remove${t}Attribute`,attacher:sv},{name:t=>`replace${t}Attributes`,attacher:lv},{name:t=>`merge${t}Attributes`,attacher:uv},{name:t=>`update${t}Attributes`,attacher:cv}];function hv(t){dv.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var fv=[{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 pv(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 gv(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 Bo(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 mv(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 vv(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 Wo(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 yv(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 bc(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 wv(t,e){if(t.size===0)return nn();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 Ko(t,e,n,r,i,o){let a=e?gv:pv,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 bv(t,e,n,r){let i=[];return Ko(!1,t,e,n,r,function(o){i.push(o)}),i}function xv(t,e,n){let r=nn();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=at(r,Bo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=at(r,Bo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=at(r,Bo(n.undirected))),r}function Vo(t,e,n,r,i,o,a){let s=n?vv:mv,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 _v(t,e,n,r,i){let o=[];return Vo(!1,t,e,n,r,i,function(a){o.push(a)}),o}function Ev(t,e,n,r){let i=nn();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=at(i,Wo(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=at(i,Wo(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=at(i,Wo(n.undirected,r))),i}function kv(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 yv(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new R(`Graph.${n}: could not find the "${o}" node in the graph.`);return bv(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 R(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new R(`Graph.${n}: could not find the "${a}" target node in the graph.`);return _v(r,this.multi,i,s,a)}throw new C(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sv(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,bc(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new R(`Graph.${o}: could not find the "${u}" node in the graph.`);return Ko(!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 R(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new R(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Vo(!1,r,this.multi,i,d,c,h)}throw new C(`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,w,b,E,_)=>{h[f++]=c(g,m,v,w,b,E,_)})}else h=[],u.push((d,f,g,m,v,w,b)=>{h.push(c(d,f,g,m,v,w,b))});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,w,b)=>{c(d,f,g,m,v,w,b)&&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 C(`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 C(`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,w,b,E)=>{d=c(d,f,g,m,v,w,b,E)}),this[o].apply(this,u),d}}function Tv(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,bc(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new R(`Graph.${o}: could not find the "${l}" node in the graph.`);return Ko(!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 R(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new R(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Vo(!0,r,this.multi,i,h,u,c)}throw new C(`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,w)=>u(h,d,f,g,m,v,w)),!!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,w)=>!u(h,d,f,g,m,v,w)),!this[o].apply(this,l)}}function Rv(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 nn();if(!arguments.length)return wv(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new R(`Graph.${o}: could not find the "${a}" node in the graph.`);return xv(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new R(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new R(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Ev(r,i,l,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Av(t){fv.forEach(e=>{kv(t,e),Sv(t,e),Tv(t,e),Rv(t,e)})}var Cv=[{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 ti(){this.A=null,this.B=null}ti.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};ti.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function Mn(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 jo(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return Mn(t,null,r,r.undirected,i);if(typeof n=="string")return Mn(t,null,r,r[n],i)}let o=new ti,a;if(e!=="undirected"){if(n!=="out"){if(a=Mn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Mn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=Mn(t,o,r,r.undirected,i),t&&a))return a}function Lv(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 jo(!1,t,e,n,function(i){r.push(i)}),r}function On(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 Nv(t,e,n){if(t!=="mixed"){if(t==="undirected")return On(null,n,n.undirected);if(typeof e=="string")return On(null,n,n[e])}let r=nn(),i=new ti;return t!=="undirected"&&(e!=="out"&&(r=at(r,On(i,n,n.in))),e!=="in"&&(r=at(r,On(i,n,n.out)))),t!=="directed"&&(r=at(r,On(i,n,n.undirected))),r}function Dv(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 R(`Graph.${n}: could not find the "${o}" node in the graph.`);return Lv(r==="mixed"?this.type:r,i,a)}}function Pv(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 R(`Graph.${o}: could not find the "${u}" node in the graph.`);jo(!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 C(`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 Iv(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 R(`Graph.${a}: could not find the "${u}" node in the graph.`);return jo(!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 Gv(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 nn();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new R(`Graph.${o}: could not find the "${a}" node in the graph.`);return Nv(r==="mixed"?this.type:r,i,s)}}function Mv(t){Cv.forEach(e=>{Dv(t,e),Pv(t,e),Iv(t,e),Gv(t,e)})}function Yr(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 Ov(t,e){let n={key:t};return fc(e.attributes)||(n.attributes=ue({},e.attributes)),n}function Fv(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return fc(n.attributes)||(r.attributes=ue({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function $v(t){if(!me(t))throw new C('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 C("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function zv(t){if(!me(t))throw new C('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 C("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new C("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new C("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var Uv=Bm(),Hv=new Set(["directed","undirected","mixed"]),cc=new Set(["domain","_events","_eventsCount","_maxListeners"]),Bv=[{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"}],Wv={allowSelfLoops:!0,multi:!1,type:"mixed"};function Kv(t,e,n){if(n&&!me(n))throw new C(`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 dc(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 xc(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 C(`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 R(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new R(`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 rn(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 Vv(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 C(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!me(s))throw new C(`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 b=[f.key,!1,!1,!1];if(l?!u:!s)return b;if(l){let E=f.attributes;f.attributes=u(E),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ue(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return b}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=dc(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=dc(t,a,{}),v=!0),d=new rn(r,i,c,h,s),t._edges.set(i,d);let w=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,w&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,w&&(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 tn(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 hc.EventEmitter{constructor(e){if(super(),e=ue({},Wv,e),typeof e.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Hv.has(e.type))throw new C(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new C(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?pc:e.type==="directed"?gc:mc;Me(this,"NodeDataClass",n);let r="geid_"+Uv()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Me(this,"_attributes",{}),Me(this,"_nodes",new Map),Me(this,"_edges",new Map),Me(this,"_directedSize",0),Me(this,"_undirectedSize",0),Me(this,"_directedSelfLoopCount",0),Me(this,"_undirectedSelfLoopCount",0),Me(this,"_edgeKeyGenerator",o),Me(this,"_options",e),cc.forEach(a=>Me(this,a,this[a])),We(this,"order",()=>this._nodes.size),We(this,"size",()=>this._edges.size),We(this,"directedSize",()=>this._directedSize),We(this,"undirectedSize",()=>this._undirectedSize),We(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),We(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),We(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),We(this,"multi",this._options.multi),We(this,"type",this._options.type),We(this,"allowSelfLoops",this._options.allowSelfLoops),We(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 C(`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 C(`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 C(`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 R(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`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 R(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`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 R(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return Kv(this,e,n).key}mergeNode(e,n){if(n&&!me(n))throw new C(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ue(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 C(`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 R(`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 tn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do tn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do tn(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=Oe(this,r,i,this.type),!n)throw new R(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new R(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return tn(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=Oe(this,e,n,"directed");if(!r)throw new R(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return tn(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=Oe(this,e,n,"undirected");if(!r)throw new R(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return tn(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 C("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 C("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 C("Graph.mergeAttributes: provided attributes are not a plain object.");return ue(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new C("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 C("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!uc(n))throw new C("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 C("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!uc(n))throw new C("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 C("Graph.forEachAdjacencyEntry: expecting a callback.");Yr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Yr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Yr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Yr(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new C("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 C("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 C("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 C("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 C("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 C("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 C("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new C("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++]=Ov(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=Fv(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 C("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!me(e.attributes))throw new C("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 C("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 C("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],zv(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(ue({},this._options,e));return n.replaceAttributes(ue({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ue({},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,xc(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ue({},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)&&!cc.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Me(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);Bv.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?xc:Vv;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")}})});tv(K);hv(K);Av(K);Mv(K);var Xr=class extends K{constructor(e){let n=ue({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new C("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new C('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Zr=class extends K{constructor(e){let n=ue({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new C("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new C('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Qr=class extends K{constructor(e){let n=ue({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Jr=class extends K{constructor(e){let n=ue({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new C('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},ei=class extends K{constructor(e){let n=ue({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new C('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function on(t){t.from=function(e,n){let r=ue({},e.options,n),i=new t(r);return i.import(e),i}}on(K);on(Xr);on(Zr);on(Qr);on(Jr);on(ei);K.Graph=K;K.DirectedGraph=Xr;K.UndirectedGraph=Zr;K.MultiGraph=Qr;K.MultiDirectedGraph=Jr;K.MultiUndirectedGraph=ei;K.InvalidArgumentsGraphError=C;K.NotFoundGraphError=R;K.UsageGraphError=M;function jv(){return new K({multi:!0,type:"directed"})}function qo(t){let e=jv();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 _c(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 Ec(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function kc(t,e){let n=null,r=qo({nodes:[],edges:[]}),i=null,o=()=>{},a=s=>{let l=ac(i),u=sc(i);s.setSetting("nodeReducer",(c,h)=>({...h,...l(c,h,e)})),s.setSetting("edgeReducer",(c,h)=>({...h,...u(c,h)}))};return{mount(s){if(n!==null)return;let l=t(r,s,lc(e));l.on("clickNode",({node:u})=>o(u)),l.on("clickStage",()=>o(null)),a(l),n=l},setGraph(s){r=qo(s),n?.setGraph(r)},setPositions(s){_c(r,s),n?.refresh()},setHighlight(s){i=s,n!==null&&a(n)},onSelect(s){o=s},fit(){n?.getCamera().animatedReset()},positions(){return Ec(r)},destroy(){n?.kill(),n=null}}}var qv=(t,e,n)=>new eu(t,e,n),Sc=t=>kc(qv,t);var Rc="/events";var Yv=2,ni={graph:!1,note:!1};function Ac(t){return!t.graph&&!t.note}function Xv(t,e){return{graph:!0,note:t==="vault"&&e}}function Tc(t){return{graph:!0,note:t}}function Cc(){return{connection:"live",stamp:null,opened:!1}}function Lc(t,e){return t.stamp===e?t:{...t,stamp:e}}function Zv(t){return t===Yv?"offline":"reconnecting"}function Nc(t,e,n){switch(e.type){case"open":{let r=t.opened?Tc(n):ni;return{state:{...t,connection:"live",opened:!0},plan:r}}case"error":return{state:{...t,connection:Zv(e.readyState)},plan:ni};case"frame":return e.event.stamp===t.stamp?{state:t,plan:ni}:{state:{...t,connection:"live"},plan:Xv(e.event.scope,n)};case"refresh":return{state:t,plan:Tc(n)};case"closed":return{state:{...t,connection:"offline"},plan:ni}}}function Dc(t){let e;try{e=JSON.parse(t)}catch{return null}return Fs(e)?e:null}var Qv=Symbol.for("preact-signals");function ai(){if(lt>1)lt--;else{var t,e=!1;for((function(){var i=ii;for(ii=void 0;i!==void 0;){var o=i.S;if(o.v===i.v)for(var a=o.t;a!==void 0;a=a.x)a.i===i.i&&(a.i=o.i);i=i.o}})();zn!==void 0;){var n=zn;for(zn=void 0,ri++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ic(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(ri=0,lt--,e)throw t}}function Xo(t){if(lt>0)return t();Yo=++Jv,lt++;try{return t()}finally{ai()}}var $n,Q=void 0;function Un(t){var e=Q,n=$n;Q=void 0,$n=void 0;try{return t()}finally{Q=e,$n=n}}var zn=void 0,lt=0,ri=0,Jv=0,Yo=0,ii=void 0,oi=0;function Pc(t){if(Q!==void 0){var e=t.n;if(e===void 0||e.t!==Q)return e={i:0,S:t,p:Q.s,n:void 0,t:Q,e:void 0,x:void 0,r:e},Q.s!==void 0&&(Q.s.n=e),Q.s=e,t.n=e,32&Q.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Q.s,e.n=void 0,Q.s.n=e,Q.s=e),e}}function ce(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}ce.prototype.brand=Qv;ce.prototype.h=function(){return!0};ce.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Un(function(){var r;(r=e.W)==null||r.call(e)}))};ce.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&Un(function(){var i;(i=e.Z)==null||i.call(e)}))}};ce.prototype.subscribe=function(t){var e=this;return Pt(function(){var n=e.value;Un(function(){return t(n)})},{name:"sub"})};ce.prototype.valueOf=function(){return this.value};ce.prototype.toString=function(){return this.value+""};ce.prototype.toJSON=function(){return this.value};ce.prototype.peek=function(){var t=this;return Un(function(){return t.value})};Object.defineProperty(ce.prototype,"value",{get:function(){var t=Pc(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(ri>100)throw new Error("Cycle detected");(function(n){lt!==0&&ri===0&&n.l!==Yo&&(n.l=Yo,ii={S:n,v:n.v,i:n.i,o:ii})})(this),this.v=t,this.i++,oi++,lt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ai()}}}});function et(t,e){return new ce(t,e)}function Ic(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Gc(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Mc(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function Dt(t,e){ce.call(this,void 0,e),this.x=t,this.s=void 0,this.g=oi-1,this.f=4}Dt.prototype=new ce;Dt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===oi))return!0;if(this.g=oi,this.f|=1,this.i>0&&!Ic(this))return this.f&=-2,!0;var t=Q;try{Gc(this),Q=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Q=t,Mc(this),this.f&=-2,!0};Dt.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}ce.prototype.S.call(this,t)};Dt.prototype.U=function(t){if(this.t!==void 0&&(ce.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Dt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Dt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Pc(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function si(t,e){return new Dt(t,e)}function Oc(t){var e=t.m;if(t.m=void 0,typeof e=="function"){lt++;var n=Q;Q=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,Zo(t),r}finally{Q=n,ai()}}}function Zo(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Oc(t)}function ey(t){if(Q!==this)throw new Error("Out-of-order effect");Mc(this),Q=t,this.f&=-2,8&this.f&&Zo(this),ai()}function an(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,$n&&$n.push(this)}an.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};an.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Oc(this),Gc(this),lt++;var t=Q;return Q=this,ey.bind(this,t)};an.prototype.N=function(){2&this.f||(this.f|=2,this.u=zn,zn=this)};an.prototype.d=function(){this.f|=8,1&this.f||Zo(this)};an.prototype.dispose=function(){this.d()};function Pt(t,e){var n=new an(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Fc,Qo,li,ty=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var $c=[];Pt(function(){Fc=this.N})();function sn(t,e){H[t]=e.bind(null,H[t]||function(){})}function ui(t){if(li){var e=li;li=void 0,e()}li=t&&t.S()}function zc(t){var e=this,n=t.data,r=ry(n);r.name="ReactiveDom",r.value=n;var i=Ie(function(){for(var s=e,l=e.__v;l=l.__;)if(l.__c){l.__c.__$f|=4;break}var u=si(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),c=si(function(){return!Array.isArray(u.value)&&!Wi(u.value)}),h=Pt(function(){if(this.N=Uc,c.value){var f=u.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=e.__$u.d;return e.__$u.d=function(){h(),d.call(this)},[c,u]},[]),o=i[0],a=i[1];return o.value?a.peek():a.value}zc.displayName="ReactiveTextNode";Object.defineProperties(ce.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:zc},props:{configurable:!0,get:function(){var t=this;return{data:{get value(){return t.value}}}}},__b:{configurable:!0,value:1}});sn("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof ce&&(n||(e.__np=n={}),n[i]=o,r[i]=o.peek())}}t(e)});sn("__r",function(t,e){if(t(e),e.type!==Pe){ui();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,o){var a;return Pt(function(){a=this},{name:o}),a.c=i,a})((function(i){return function(){var o;ty&&((o=this.y)==null||o.call(this)),i.__$f|=1,i.setState({})}})(r),typeof e.type=="function"?e.type.displayName||e.type.name:""))),Qo=r,ui(n)}});sn("__e",function(t,e,n,r){ui(),Qo=void 0,t(e,n,r)});sn("diffed",function(t,e){ui(),Qo=void 0;var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props,o=n.U;if(o)for(var a in o){var s=o[a];s===void 0||r&&a in r||(s.d(),o[a]=void 0)}if(r){o||(o={},n.U=o);for(var l in r){var u=o[l],c=r[l];u===void 0?(u=ny(n,l,c,i),o[l]=u):u.o(c,i)}}}t(e)});function ny(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,o=et(n);return{o:function(a,s){o.value=a,r=s},d:Pt(function(){this.N=Uc;var a=o.value.value;r[e]!==a&&(r[e]=a,i?t[e]=a:a!=null&&(a!==!1||e[4]==="-")?t.setAttribute(e,a):t.removeAttribute(e))})}}sn("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var o=r[i];o&&o.d()}}}var a=e.__np;if(a){var s=e.props;for(var l in a)s[l]=a[l]}e.__np=void 0}else{var u=e.__c;if(u){var c=u.__$u;c&&(u.__$u=void 0,c.d())}}t(e)});sn("__h",function(t,e,n,r){r<3&&(e.__$f|=2),t(e,n,r)});Vt.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(r||o||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var a in t)if(a!=="__source"&&t[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in t))return!0;return!1};function ry(t,e){return Ie(function(){return et(t,e)},[])}var iy=function(t){queueMicrotask(function(){queueMicrotask(t)})};function oy(){Xo(function(){for(var t;t=$c.shift();)Fc.call(t)})}function Uc(){$c.push(this)===1&&(H.requestAnimationFrame||iy)(oy)}function ay(){return{expanded:[]}}var vt=et(null),yt=et(null),Hn=et(null),Nk=et(ay()),ln=et("live");function Hc(t){let e=Cc(),n=!1,r=t.open(t.path??Rc),i=o=>{let a=Nc(e,o,t.hasSelection());e=a.state,ln.value=e.connection,Ac(a.plan)||t.refetch(a.plan)};return r.addEventListener("open",()=>i({type:"open"})),r.addEventListener("error",()=>i({type:"error",readyState:r.readyState})),r.addEventListener(Os,o=>{let a=Dc(o.data);a!==null&&i({type:"frame",event:a})}),{stop(){n||(n=!0,r.close(),i({type:"closed"}))},refresh(){i({type:"refresh"})},seen(o){e=Lc(e,o)},state(){return e}}}function Bc(t){return new EventSource(t)}function ci(t,e=!1){return{ok:!0,data:t,cached:e}}function Ee(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function Jo(t){return t===403?"auth":t===404?"missing":"server"}function ea(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function ta(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Ee("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Ee(Jo(i.status),i.status,ea(i.status));let o;try{o=await i.json()}catch{return Ee("malformed",i.status,"response was not valid JSON")}return n(o)?ci(o):Ee("malformed",i.status,"response did not match the expected shape")}function ut(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sy(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function ly(t){if(!ut(t)||typeof t.stamp!="string")return!1;let e=t.model;return!ut(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:ut(t.tags)&&ut(t.dangling)}function uy(t){if(!ut(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return sy(t.tags)}function na(t){return ut(t)&&typeof t.revision=="string"&&uy(t.note)}function cy(t){return!ut(t)||typeof t.error!="string"?!1:t.reason==="collision"?typeof t.slug=="string":t.reason!=="conflict"?!1:na(t.current)}function dy(t){return ut(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function hy(t){return ut(t)&&typeof t.opened=="boolean"}async function Wc(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 Ee("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Ee("malformed",304,"server sent 304 for an unconditional request"):ci(e,!0);if(!r.ok)return Ee(Jo(r.status),r.status,ea(r.status));let i;try{i=await r.json()}catch{return Ee("malformed",r.status,"response was not valid JSON")}return ly(i)?ci(i):Ee("malformed",r.status,"response did not match the expected shape")}function Kc(t,e){return ta(t,`/api/note/${encodeURIComponent(e)}`,na)}function fy(t,e=""){return`/api/note/${encodeURIComponent(t)}${e}`}function py(t,e){return{method:t,headers:{"content-type":"application/json"},body:JSON.stringify(e)}}async function gy(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Ee("network",0,a instanceof Error?a.message:"network request failed")}if(i.status===409){let a;try{a=await i.json()}catch{return Ee("malformed",409,"response was not valid JSON")}return cy(a)?{ok:!1,kind:"conflict",status:409,message:a.error,conflict:a}:Ee("malformed",409,"response did not match the expected shape")}if(!i.ok)return Ee(Jo(i.status),i.status,ea(i.status));let o;try{o=await i.json()}catch{return Ee("malformed",i.status,"response was not valid JSON")}return n(o)?ci(o):Ee("malformed",i.status,"response did not match the expected shape")}function Vc(t,e,n){return gy(t,fy(e),na,py("POST",n))}function jc(t,e){return ta(t,`/api/search?q=${encodeURIComponent(e)}`,dy)}function qc(t,e){return ta(t,"/api/open",hy,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function un(){return{mode:"read",slug:null,baseline:"",draft:"",revision:null,status:"idle",message:null,saving:null,conflict:null,external:null,pending:null}}function cn(t){return t.mode==="edit"&&t.draft!==t.baseline}function Xc(t){return cn(t)&&t.slug!==null&&t.status!=="saving"}function oe(t){return{state:t,effect:null}}function ra(t,e,n){return{...t,mode:n,slug:e.note.slug,baseline:e.note.body,draft:e.note.body,revision:e.revision,status:"idle",message:null,saving:null,conflict:null,external:null}}function my(t,e){return e.note.slug!==t.slug?ra(t,e,"read"):cn(t)&&e.revision!==t.revision?{...t,external:e}:ra(t,e,t.mode)}function Zc(t,e){switch(e.type){case"loaded":return oe(my(t,e.payload));case"cleared":return oe(un());case"toggle":return t.slug===null?oe(t):t.mode==="read"?oe({...t,mode:"edit",draft:t.baseline,status:"idle",message:null}):cn(t)?oe({...t,status:"error",message:Qc}):oe({...t,mode:"read",status:"idle",message:null});case"draft":return oe({...t,draft:e.text,status:t.status==="saving"?"saving":"idle",message:null});case"save":return!Xc(t)||t.slug===null||t.conflict!==null?oe(t):{state:{...t,status:"saving",message:null,saving:t.draft},effect:{type:"save",slug:t.slug,input:vy(t)}};case"saved":return oe(yy(t,e.payload));case"failed":return oe({...t,status:"error",message:e.message,saving:null});case"conflicted":return oe({...t,status:"error",message:e.conflict.error,saving:null,conflict:e.conflict});case"reload":return oe(wy(t));case"overwrite":return by(t);case"dismiss":return oe({...t,conflict:null,external:null,status:"idle",message:null});case"navigate":return xy(t,e.id);case"discard":return t.pending===null?oe(t):{state:un(),effect:{type:"select",id:t.pending.id}};case"stay":return oe({...t,pending:null});case"open":return t.slug===null?oe(t):{state:t,effect:{type:"open",slug:t.slug}};case"opened":return oe({...t,status:e.ok?"idle":"error",message:e.ok?Ey:ky})}}function vy(t){return t.revision===null?{body:t.draft}:{body:t.draft,expectedRevision:t.revision}}function yy(t,e){let n=t.saving!==null&&t.saving!==t.draft;return{...t,slug:e.note.slug,baseline:e.note.body,draft:n?t.draft:e.note.body,revision:e.revision,status:"saved",message:_y,saving:null,conflict:null,external:null}}function wy(t){let e=t.conflict?.reason==="conflict"?t.conflict.current:t.external;return e==null?t:ra(t,e,t.mode)}function by(t){return t.slug===null?oe(t):{state:{...t,status:"saving",message:null,saving:t.draft,conflict:null,external:null},effect:{type:"save",slug:t.slug,input:{body:t.draft}}}}function xy(t,e){return cn(t)?oe({...t,pending:{id:e}}):{state:t,effect:{type:"select",id:e}}}function ia(t){return cn(t)}var _y="saved",Qc="unsaved changes — save with the button, or discard them",Ey="opened in your editor",ky="could not open the note in an editor",Sy="Edit",Ty="Done",Ry="Save",Ay="Saving…",Jc="Open in $EDITOR",ed="Hand this note to $EDITOR (or your platform's opener)",Cy="Discard changes",di="Keep editing",Yc="Reload from disk",Ly="Overwrite",Ny="this note changed on disk while you were editing",Dy="pick a different name";function td(t){let e=t.conflict;return e?.reason==="conflict"?{kind:"conflict",message:e.error,actions:[{label:Yc,event:{type:"reload"}},{label:Ly,event:{type:"overwrite"}},{label:di,event:{type:"dismiss"}}]}:e?.reason==="collision"?{kind:"collision",message:`${e.error} (${e.slug}) — ${Dy}`,actions:[{label:di,event:{type:"dismiss"}}]}:t.pending!==null?{kind:"discard",message:Qc,actions:[{label:di,event:{type:"stay"}},{label:Cy,event:{type:"discard"}}]}:t.external!==null?{kind:"external",message:Ny,actions:[{label:Yc,event:{type:"reload"}},{label:di,event:{type:"dismiss"}}]}:null}function nd(t){let e=t.mode==="edit";return{toggleLabel:e?Ty:Sy,editing:e,saveLabel:t.status==="saving"?Ay:Ry,canSave:Xc(t)&&t.conflict===null,message:t.message,tone:t.message===null?"none":t.status==="error"?"warn":"ok",dirty:cn(t)}}function rd(t){let e=un(),n=i=>{let o=Zc(e,i);e=o.state,t.onChange(e),o.effect!==null&&r(o.effect)},r=i=>{if(i.type==="select"){t.select(i.id);return}if(i.type==="open"){(async()=>{let o=await qc(t.fetch,i.slug);n({type:"opened",ok:o.ok&&o.data.opened})})();return}(async()=>{let o=await Vc(t.fetch,i.slug,i.input);if(o.ok){n({type:"saved",payload:o.data});return}n(o.kind==="conflict"?{type:"conflicted",conflict:o.conflict}:{type:"failed",message:o.message})})()};return{state:()=>e,send:n}}function id(t,e){let n=r=>{e()&&(r.preventDefault(),r.returnValue="")};return t.addEventListener("beforeunload",n),()=>t.removeEventListener("beforeunload",n)}var od=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function ad(t,e,n){return t<=1?null:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function sd(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function ld(t){return t===null?!1:(t.focus(),!0)}function hi(){let t=Ae(null);return Re(()=>{let e=document.activeElement;return t.current?.focus(),()=>{ld(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!sd(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(od)??[]],r=ad(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function hd(t,e){let n=e.trim().toLowerCase();if(n==="")return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i===-1?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}var Py=10;function Iy(t){return Math.min(Math.max(t,0),Py)*2}function Gy(t){return`note:${t}`}function My(t,e){return hd(t.summary.title,e)+Iy(t.score)}function Oy(t,e){return hd(t.label,e)}var Fy=["path","manifest","url","slug"];function $y(t){for(let e of Fy){let n=t.detail[e];if(typeof n=="string"&&n!=="")return n}return""}function zy(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 Uy(t,e,n,r){let i=new Map;for(let o of t){let a=Gy(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:My(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=Oy(o,r);a!==0&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:$y(o),badge:o.kind,score:a})}return[...i.values()].sort(zy).slice(0,20)}function fi(){return{query:"",typedAt:0,issued:"",answered:"",seq:0,applied:0,hits:[],cursor:0,pending:!1,loading:!1,failed:!1}}var oa=140;function tt(t){return{state:t,request:null,schedule:null}}function ud(t,e){return e>t.applied}function fd(t,e){switch(e.type){case"query":{let n={...t,query:e.query,typedAt:e.now,cursor:0};return e.query.trim()===""?tt({...n,hits:[],answered:"",issued:"",loading:!1,failed:!1,pending:!1}):t.pending?tt(n):{state:{...n,pending:!0},request:null,schedule:oa}}case"tick":{if(!t.pending)return tt(t);let n=e.now-t.typedAt;if(n<oa)return{state:t,request:null,schedule:oa-n};let r=t.query.trim();if(r===""||r===t.issued)return tt({...t,pending:!1});let i=t.seq+1;return{state:{...t,pending:!1,loading:!0,seq:i,issued:r},request:{seq:i,query:r},schedule:null}}case"response":return ud(t,e.seq)?tt({...t,applied:e.seq,hits:e.hits,answered:e.query,loading:e.seq<t.seq,failed:!1,cursor:0}):tt(t);case"failed":return ud(t,e.seq)?tt({...t,applied:e.seq,loading:e.seq<t.seq,failed:!0}):tt(t);case"cursor":return tt({...t,cursor:e.cursor});case"dismiss":return tt({...t,pending:!1})}}function aa(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function cd(t,e,n){return n<=0?0:((t+e)%n+n)%n}function pd(t,e){return e===null?null:t[e]?.id??null}function gd(t,e,n){let r={state:t,activate:null,dismiss:!1,handled:!1},i=a=>({state:{...t,cursor:a},activate:null,dismiss:!1,handled:!0}),o=aa(t.cursor,n);return e==="ArrowDown"?i(cd(o,1,n)):e==="ArrowUp"?i(cd(o,-1,n)):e==="Home"?i(0):e==="End"?i(aa(n-1,n)):e==="Escape"?{state:t,activate:null,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{state:t,activate:o,dismiss:!0,handled:!0}}var pi="Search the workspace",md="Search notes and repository…",vd="↑↓ move · ↵ open · esc close";function Hy(t,e){return t.query.trim()===""?"Type to search notes, modules, files and entry points.":e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading||t.pending?"searching…":`no matches for “${t.query.trim()}”`}function By(t){return t===1?"1 result":`${t} results`}function dd(t){return`weave-search-row-${t}`}function yd(t,e){let n=Uy(t.hits,t.answered,e?.model.nodes??[],t.query),r=aa(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:dd(a)})),status:Hy(t,n.length),count:n.length,countLabel:By(n.length),cursor:r,activeDomId:n.length===0?null:dd(r)}}function wd(t){let e=fi(),n=r=>{let i=fd(e,r);e=i.state,t.onChange(e),i.schedule!==null&&t.delay(()=>n({type:"tick",now:t.now()}),i.schedule);let o=i.request;o!==null&&(async()=>{let a=await jc(t.fetch,o.query);n(a.ok?{type:"response",seq:o.seq,query:o.query,hits:a.data.hits}:{type:"failed",seq:o.seq})})()};return{state:()=>e,setQuery:r=>n({type:"query",query:r,now:t.now()}),setCursor:r=>n({type:"cursor",cursor:r}),dismiss:()=>n({type:"dismiss"})}}var Wy=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:--Wy,__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 H.vnode&&H.vnode(u),u}function Ky({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 bd(t){let[e,n]=Ue(fi),r=Ie(()=>wd({...t.ports,onChange:n}),[]),i=hi(),o=yd(e,t.graph),a=s=>{let l=pd(o.rows,s);l!==null&&t.onSelect(l),r.dismiss(),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>a(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":pi,tabIndex:-1,ref:i.ref,onClick:s=>s.stopPropagation(),onKeyDown:s=>{if(i.onKeyDown(s))return;let l=gd(e,s.key,o.count);l.handled&&(s.preventDefault(),r.setCursor(l.state.cursor),l.dismiss&&a(l.activate))},children:[x("input",{type:"search",class:"weave-palette-input",autofocus:!0,value:e.query,placeholder:md,"aria-label":pi,"aria-controls":"weave-search-results","aria-activedescendant":o.activeDomId??void 0,onInput:s=>r.setQuery(s.currentTarget.value)}),o.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":pi,children:o.rows.map((s,l)=>x(Ky,{row:s,onPick:()=>a(l),onHover:()=>r.setCursor(l)},s.id))}):x("p",{class:"weave-palette-status",role:"status",children:o.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:o.countLabel}),x("span",{class:"weave-palette-hint",children:vd})]})]})})}var gi=null;function _d(t){return gi=t,()=>{gi===t&&(gi=null)}}async function xd(t,e){let n=await Wc(t,yt.value);return n.ok&&(n.cached||(yt.value=n.data),e?.seen(n.data.stamp)),n}async function sa(t){let e=Ed(vt.value);if(e===null){Hn.value=null;return}let n=await Kc(t,e);n.ok&&(Hn.value=n.data,gi?.(n.data))}function Ed(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function kd(t){let e=null,n=r=>{(async()=>(r.graph&&await xd(t.fetch,e),r.note&&await sa(t.fetch)))()};return e=Hc({open:t.open,refetch:n,hasSelection:()=>Ed(vt.value)!==null,...t.path===void 0?{}:{path:t.path}}),xd(t.fetch,e),{refresh(){e?.refresh()},syncNote(){return sa(t.fetch)},stop(){e?.stop(),e=null}}}function la(t,e){return vt.value=e,sa(t)}var Vy=300,jy=1;function qy(t,e,n){let r={ticks:Vy,seed:jy};return Iu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e]},n===void 0?r:{...r,initial:n})}function Yy(t,e){let n=0,r=0;for(let o of t){let a=Hr(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=Hr(`${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 Td="pi-weave.graph.positions.v1";function Sd(t){return Math.round(t*10)/10}function Xy(t,e){let n={};for(let[r,i]of e)n[r]=[Sd(i.x),Sd(i.y)];return JSON.stringify({v:1,key:t,at:n})}function Zy(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||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 Qy(t,e){let n;try{n=t.getItem(Td)}catch{return null}return Zy(n,e)}function Jy(t,e,n){try{return t.setItem(Td,Xy(e,n)),!0}catch{return!1}}function Rd(t,e,n){let r=Yy(e,n),i=Qy(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=qy(e,n);return Jy(t,r,o),{key:r,positions:o,cached:!1}}var ua=[1,2,3],ew=120;function tw(t){return{expanded:t.nodes.length>ew?new Set:new Set(Kr(t,new Set).clusters.keys()),depth:1}}function Ad(t,e){return e!==null?e:t===null?{expanded:new Set,depth:1}:tw(Lt(t))}function nw(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function rw(t,e){return{...t,expanded:new Set(e.keys())}}function iw(t){return{...t,expanded:new Set}}function Cd(t,e){return t.depth===e?t:{...t,depth:e}}function ow(t,e,n){if(e===null)return null;let r=Wr(e,t);for(let i=1;i<n;i++){let o=new Set(r);for(let a of r)for(let s of Wr(a,t))o.add(s);if(o.size===r.size)break;r=o}return r}function Ld(t){return`depth ${t}`}function Nd(t){return t===1?"highlighting direct neighbours of the selection":`highlighting everything within ${t} hops of the selection`}function Dd(t){return t?"collapse":"expand"}function Pd(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function ca(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function Id(t,e){return ca(t,e)?iw(t):rw(t,e)}function Gd(t,e){let n=Number(t);return ua.includes(n)?n:e}var Md="fit",Od="frame the whole graph",da={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Fd(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function aw(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 sw={graph:rc,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function $d(t,e,n,r,i){if(t===null)return sw;let o=Lt(t),a=Kr(o,n.expanded),s=Rd(r,a.nodes,a.edges);return{graph:oc(a.nodes,a.edges,s.positions,i),highlight:ow(a.edges,e,n.depth),key:s.key,cached:s.cached,clusters:a.clusters,visible:a.nodes.length,total:o.nodes.length,empty:aw(t,a.nodes.length)}}function zd(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:nw(t,n),selectedId:n}}var lw="(prefers-color-scheme: light)";function Ud(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(lw).matches?"light":"dark"}function Hd(t){let e=Ae(null),n=Ae(null),[r,i]=Ue(null),o=Ie(()=>Ud(t.host),[t.host]),a=Ad(t.graph,r),s=$d(t.graph,t.selectedId,a,t.storage,o),l=ca(a,s.clusters),u=Ae({view:a,model:s,onSelect:t.onSelect});return u.current={view:a,model:s,onSelect:t.onSelect},Re(()=>{let c=t.renderer(o);return c.onSelect(h=>{let d=zd(u.current.view,u.current.model.clusters,h);i(d.state),u.current.onSelect(d.selectedId)}),c.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=c,t.fit.current=()=>c.fit(),()=>{c.destroy(),n.current=null,t.fit.current=null}},[t.renderer,o]),Re(()=>{n.current?.setGraph(s.graph)},[s.key]),Re(()=>{n.current?.setHighlight(s.highlight)},[s.highlight]),x("div",{class:"weave-graph",children:[s.empty===null?null:x("p",{class:"weave-graph-empty",children:s.empty}),x("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph"}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Od,onClick:()=>n.current?.fit(),children:Md}),x("button",{type:"button",class:"weave-chip",title:Pd(l),onClick:()=>i(Id(a,s.clusters)),children:Dd(l)}),x("select",{class:"weave-chip weave-depth",title:Nd(a.depth),"aria-label":"Highlight depth",value:String(a.depth),onChange:c=>i(Cd(a,Gd(c.currentTarget.value,a.depth))),children:ua.map(c=>x("option",{value:String(c),children:Ld(c)},c))}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",da.selected]}),x("span",{class:"weave-legend-near",children:["● ",da.neighborhood]})]})]}),x("p",{class:"weave-graph-count",children:Fd(s.visible,s.total)})]})}function Bd(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 uw(t){if(Array.isArray(t))return t}function cw(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 dw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
335
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hw(t,e){return uw(t)||cw(t,e)||fw(t,e)||dw()}function fw(t,e){if(t){if(typeof t=="string")return Bd(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)?Bd(t,e):void 0}}var ih=Object.entries,Wd=Object.setPrototypeOf,pw=Object.isFrozen,gw=Object.getPrototypeOf,mw=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,dn=Object.create,oh=typeof Reflect<"u"&&Reflect,ya=oh.apply,wa=oh.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});ya||(ya=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)});wa||(wa=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 Gt=ae(Array.prototype.forEach),vw=ae(Array.prototype.lastIndexOf),Kd=ae(Array.prototype.pop),Bn=ae(Array.prototype.push),yw=ae(Array.prototype.splice),hn=Array.isArray,Vn=ae(String.prototype.toLowerCase),ha=ae(String.prototype.toString),Vd=ae(String.prototype.match),Wn=ae(String.prototype.replace),jd=ae(String.prototype.indexOf),ww=ae(String.prototype.trim),bw=ae(Number.prototype.toString),xw=ae(Boolean.prototype.toString),qd=typeof BigInt>"u"?null:ae(BigInt.prototype.toString),Yd=typeof Symbol>"u"?null:ae(Symbol.prototype.toString),Te=ae(Object.prototype.hasOwnProperty),Kn=ae(Object.prototype.toString),ve=ae(RegExp.prototype.test),It=_w(TypeError);function ae(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 ya(t,e,r)}}function _w(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return wa(t,n)}}function B(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vn;if(Wd&&Wd(t,null),!hn(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(pw(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Ew(t){for(let e=0;e<t.length;e++)Te(t,e)||(t[e]=null);return t}function Ne(t){let e=dn(null);for(let r of ih(t)){var n=hw(r,2);let i=n[0],o=n[1];Te(t,i)&&(hn(o)?e[i]=Ew(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Ne(o):e[i]=o)}return e}function kw(t){switch(typeof t){case"string":return t;case"number":return bw(t);case"boolean":return xw(t);case"bigint":return qd?qd(t):"0";case"symbol":return Yd?Yd(t):"Symbol()";case"undefined":return Kn(t);case"function":case"object":{if(t===null)return Kn(t);let e=t,n=Ke(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Kn(r)}return Kn(t)}default:return Kn(t)}}function Ke(t,e){for(;t!==null;){let r=mw(t,e);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}t=gw(t)}function n(){return null}return n}function Sw(t){try{return ve(t,""),!0}catch{return!1}}var Xd=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"]),fa=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"]),pa=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"]),Tw=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"]),ga=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"]),Rw=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Zd=de(["#text"]),Qd=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"]),ma=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"]),Jd=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"]),mi=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Aw=pe(/{{[\w\W]*|^[\w\W]*}}/g),Cw=pe(/<%[\w\W]*|^[\w\W]*%>/g),Lw=pe(/\${[\w\W]*/g),Nw=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Dw=pe(/^aria-[\-\w]+$/),eh=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pw=pe(/^(?:\w+script|data):/i),Iw=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Gw=pe(/^html$/i),Mw=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),th=pe(/<[/\w!]/g),nh=pe(/<[/\w]/g),Ow=pe(/<\/no(script|embed|frames)/i),Fw=pe(/\/>/i),Le={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ah=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],$w=de(B({},ah)),zw=(function(){let t={};return Gt(ah,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),Uw=function(){return typeof window>"u"?null:window},Hw=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}},rh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wt=function(e,n,r,i){return Te(e,n)&&hn(e[n])?B(i.base?Ne(i.base):{},e[n],i.transform):r},va=function(e,n,r){let i=Te(e,n)?e[n]:void 0;return i&&typeof i=="object"?Ne(i):r()};function sh(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uw(),e=T=>sh(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Le.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=Ke(d,"cloneNode"),g=Ke(d,"remove"),m=Ke(d,"nextSibling"),v=Ke(d,"childNodes"),w=Ke(d,"parentNode"),b=Ke(d,"shadowRoot"),E=Ke(d,"attributes"),_=a&&a.prototype?Ke(a.prototype,"nodeType"):null,L=a&&a.prototype?Ke(a.prototype,"nodeName"):null,P=a&&a.prototype?Ke(a.prototype,"ownerDocument"):null,I=function(p){return _?_(p):p.nodeType},$=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,J=0,ge=function(){if(J>0)throw It('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(),J++;try{return F.createHTML(p)}finally{J--}},Ye=function(p){ge(),J++;try{return F.createScriptURL(p)}finally{J--}},$t=function(){return j||(U=Hw(h,i),j=!0),U},Fe=n,$e=Fe.implementation,ze=Fe.createNodeIterator,Xe=Fe.createDocumentFragment,gn=Fe.getElementsByTagName,De=r.importNode,q=rh();e.isSupported=typeof ih=="function"&&typeof w=="function"&&$e&&$e.createHTMLDocument!==void 0;let mn=Aw,Af=Cw,Cf=Lw,Lf=Nw,Nf=Dw,Df=Pw,Wa=Iw,Pf=Mw,Ka=eh,X=null,Ti=B({},[...Xd,...fa,...pa,...ga,...Zd]),Z=null,Ri=B({},[...Qd,...ma,...Jd,...mi]),Ze=Object.seal(dn(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}})),vn=null,Va=null,dt=Object.seal(dn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ja=!0,Ai=!0,qa=!1,Ya=!0,ht=!1,xt=!0,_t=!1,Ci=!1,Jn=null,er=null,Li=!1,zt=!1,tr=!1,nr=!1,Xa=!0,Za=!1,Qa="user-content-",Ni=!0,Di=!1,Ut={},Ht=null,Ja=B({},["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"]),es=null,ts=B({},["audio","video","img","source","image","track"]),ns=null,rs=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rr="http://www.w3.org/1998/Math/MathML",ir="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml",Bt=Qe,Pi=!1,Ii=null,If=B({},[rr,ir,Qe],ha),is=de(["mi","mo","mn","ms","mtext"]),Gi=B({},is),os=de(["annotation-xml"]),Mi=B({},os),Gf=B({},["title","style","font","a","script"]),yn=null,Mf=["application/xhtml+xml","text/html"],Of="text/html",ne=null,Wt=null,Ff=n.createElement("form"),as=function(p){return p instanceof RegExp||p instanceof Function},Oi=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Wt&&Wt===p)return;(!p||typeof p!="object")&&(p={}),p=Ne(p),yn=Mf.indexOf(p.PARSER_MEDIA_TYPE)===-1?Of:p.PARSER_MEDIA_TYPE,ne=yn==="application/xhtml+xml"?ha:Vn,X=wt(p,"ALLOWED_TAGS",Ti,{transform:ne}),Z=wt(p,"ALLOWED_ATTR",Ri,{transform:ne}),Ii=wt(p,"ALLOWED_NAMESPACES",If,{transform:ha}),ns=wt(p,"ADD_URI_SAFE_ATTR",rs,{transform:ne,base:rs}),es=wt(p,"ADD_DATA_URI_TAGS",ts,{transform:ne,base:ts}),Ht=wt(p,"FORBID_CONTENTS",Ja,{transform:ne}),vn=wt(p,"FORBID_TAGS",Ne({}),{transform:ne}),Va=wt(p,"FORBID_ATTR",Ne({}),{transform:ne}),Ut=Te(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Ne(p.USE_PROFILES):p.USE_PROFILES:!1,ja=p.ALLOW_ARIA_ATTR!==!1,Ai=p.ALLOW_DATA_ATTR!==!1,qa=p.ALLOW_UNKNOWN_PROTOCOLS||!1,Ya=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ht=p.SAFE_FOR_TEMPLATES||!1,xt=p.SAFE_FOR_XML!==!1,_t=p.WHOLE_DOCUMENT||!1,zt=p.RETURN_DOM||!1,tr=p.RETURN_DOM_FRAGMENT||!1,nr=p.RETURN_TRUSTED_TYPE||!1,Li=p.FORCE_BODY||!1,Xa=p.SANITIZE_DOM!==!1,Za=p.SANITIZE_NAMED_PROPS||!1,Ni=p.KEEP_CONTENT!==!1,Di=p.IN_PLACE||!1,Ka=Sw(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:eh,Bt=typeof p.NAMESPACE=="string"?p.NAMESPACE:Qe,Gi=va(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>B({},is)),Mi=va(p,"HTML_INTEGRATION_POINTS",()=>B({},os));let y=va(p,"CUSTOM_ELEMENT_HANDLING",()=>dn(null));if(Ze=dn(null),Te(y,"tagNameCheck")&&as(y.tagNameCheck)&&(Ze.tagNameCheck=y.tagNameCheck),Te(y,"attributeNameCheck")&&as(y.attributeNameCheck)&&(Ze.attributeNameCheck=y.attributeNameCheck),Te(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(Ze.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),pe(Ze),ht&&(Ai=!1),tr&&(zt=!0),Ut&&(X=B({},Zd),Z=dn(null),Ut.html===!0&&(B(X,Xd),B(Z,Qd)),Ut.svg===!0&&(B(X,fa),B(Z,ma),B(Z,mi)),Ut.svgFilters===!0&&(B(X,pa),B(Z,ma),B(Z,mi)),Ut.mathMl===!0&&(B(X,ga),B(Z,Jd),B(Z,mi))),dt.tagCheck=null,dt.attributeCheck=null,Te(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?dt.tagCheck=p.ADD_TAGS:hn(p.ADD_TAGS)&&(X===Ti&&(X=Ne(X)),B(X,p.ADD_TAGS,ne))),Te(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?dt.attributeCheck=p.ADD_ATTR:hn(p.ADD_ATTR)&&(Z===Ri&&(Z=Ne(Z)),B(Z,p.ADD_ATTR,ne))),Te(p,"ADD_FORBID_CONTENTS")&&hn(p.ADD_FORBID_CONTENTS)&&(Ht===Ja&&(Ht=Ne(Ht)),B(Ht,p.ADD_FORBID_CONTENTS,ne)),Ni&&(X["#text"]=!0),_t&&B(X,["html","head","body"]),X.table&&(B(X,["tbody"]),delete vn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let k=F;F=p.TRUSTED_TYPES_POLICY;try{G=he("")}catch(A){throw F=k,A}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=$t()),F&&typeof G=="string"&&(G=he("")));de&&de(p),Wt=p},ss=B({},[...fa,...pa,...Tw]),ls=B({},[...ga,...Rw]),$f=function(p,y,k){return y.namespaceURI===Qe?p==="svg":y.namespaceURI===rr?p==="svg"&&(k==="annotation-xml"||Gi[k]):!!ss[p]},zf=function(p,y,k){return y.namespaceURI===Qe?p==="math":y.namespaceURI===ir?p==="math"&&Mi[k]:!!ls[p]},Uf=function(p,y,k){return y.namespaceURI===ir&&!Mi[k]||y.namespaceURI===rr&&!Gi[k]?!1:!ls[p]&&(Gf[p]||!ss[p])},Hf=function(p){let y=w(p);(!y||!y.tagName)&&(y={namespaceURI:Bt,tagName:"template"});let k=Vn(p.tagName),A=Vn(y.tagName);return Ii[p.namespaceURI]?p.namespaceURI===ir?$f(k,y,A):p.namespaceURI===rr?zf(k,y,A):p.namespaceURI===Qe?Uf(k,y,A):!!(yn==="application/xhtml+xml"&&Ii[p.namespaceURI]):!1},ft=function(p){Bn(e.removed,{element:p});try{w(p).removeChild(p)}catch{if(g(p),!w(p))throw It("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},us=function(p,y,k){try{p.removeAttributeNode(y)}catch{try{p.removeAttribute(k)}catch{}}},or=function(p){ar(p);let y=v(p);if(y){let A=[];Gt(y,D=>{Bn(A,D)}),Gt(A,D=>{try{g(D)}catch{}})}let k=E(p);if(k)for(let A=k.length-1;A>=0;--A){let D=k[A],O=D&&D.name;typeof O=="string"&&us(p,D,O)}},Et=function(p,y,k){if(!k)try{k=y.getAttributeNode(p)}catch{k=null}Bn(e.removed,{attribute:k||null,from:y});try{k?y.removeAttributeNode(k):y.removeAttribute(p)}catch{try{y.removeAttribute(p)}catch{}}if(p==="is")if(zt||tr)try{ft(y)}catch{}else try{y.setAttribute(p,"")}catch{}},Bf=function(p){let y=E(p);if(y)for(let k=y.length-1;k>=0;--k){let A=y[k],D=A&&A.name;typeof D!="string"||Z[ne(D)]||us(p,A,D)}},ar=function(p){let y=[p];for(;y.length>0;){let k=y.pop();I(k)===Le.element&&Bf(k);let D=v(k);if(D)for(let O=D.length-1;O>=0;--O)y.push(D[O])}},cs=function(p,y){return xt?p==="patchsrc"?!0:p==="for"&&y!=="label"&&y!=="output":!1},Wf=function(p){if(!xt)return;let y=[p];for(;y.length>0;){let k=y.pop(),A=I(k);if(A===Le.processingInstruction||A===Le.comment&&ve(nh,k.data)){try{g(k)}catch{}continue}if(A===Le.element){let O=k,Y=ne($(k));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&cs("for",Y)&&O.removeAttribute("for")}catch{}}let D=v(k);if(D)for(let O=D.length-1;O>=0;--O)y.push(D[O])}},ds=function(p){let y=null,k=null;if(Li)p="<remove></remove>"+p;else{let O=Vd(p,/^[\r\n\t ]+/);k=O&&O[0]}yn==="application/xhtml+xml"&&Bt===Qe&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let A=F?he(p):p;if(Bt===Qe)try{y=new c().parseFromString(A,yn)}catch{}if(!y||!y.documentElement){y=$e.createDocument(Bt,"template",null);try{y.documentElement.innerHTML=Pi?G:A}catch{}}let D=y.body||y.documentElement;return p&&k&&D.insertBefore(n.createTextNode(k),D.childNodes[0]||null),Bt===Qe?gn.call(y,_t?"html":"body")[0]:_t?y.documentElement:D},hs=function(p){let y=P?P(p):p.ownerDocument;return ze.call(y||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},sr=function(p){return p=Wn(p,mn," "),p=Wn(p,Af," "),p=Wn(p,Cf," "),p},Fi=function(p){var y;p.normalize();let k=P?P(p):p.ownerDocument,A=ze.call(k||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),D=A.nextNode();for(;D;)D.data=sr(D.data),D=A.nextNode();let O=(y=p.querySelectorAll)===null||y===void 0?void 0:y.call(p,"template");O&&Gt(O,Y=>{Kt(Y.content)&&Fi(Y.content)})},lr=function(p){let y=L?L(p):null;return typeof y!="string"||ne(y)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==E(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)},Kt=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return _(p)===Le.documentFragment}catch{return!1}},wn=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return typeof _(p)=="number"}catch{return!1}};function Je(T,p,y){T.length!==0&&Gt(T,k=>{k.call(e,p,y,Wt)})}let Kf=function(p,y){return!!(xt&&p.hasChildNodes()&&!wn(p.firstElementChild)&&ve(th,p.textContent)&&ve(th,p.innerHTML)||xt&&p.namespaceURI===Qe&&$w[y]&&(wn(p.firstElementChild)||typeof p.textContent=="string"&&ve(zw[y],p.textContent))||p.nodeType===Le.processingInstruction||xt&&p.nodeType===Le.comment&&ve(nh,p.data))},ur=function(p,y){if(p instanceof RegExp)return ve(p,y);if(p instanceof Function){for(var k=arguments.length,A=new Array(k>2?k-2:0),D=2;D<k;D++)A[D-2]=arguments[D];return!!p(y,...A)}return!1},Vf=function(p,y,k){if(!vn[y]&&vs(y)&&ur(Ze.tagNameCheck,y))return!1;if(Ni&&!Ht[y]){let A=w(p),D=v(p);if(D&&A){let O=D.length;for(let Y=O-1;Y>=0;--Y){let ee=p===k?f(D[Y],!0):D[Y];A.insertBefore(ee,m(p))}}}return ft(p),!0},fs=function(p,y,k,A){return p.length===0?y:y===k||y===A?Ne(y):y},ps=function(p,y){return p===y||w(p)!==null?!1:(Di&&ar(p),!0)},gs=function(p,y){if(Je(q.beforeSanitizeElements,p,null),ps(p,y))return!0;if(lr(p))return ft(p),!0;let k=ne($(p));if(X=fs(q.uponSanitizeElement,X,Ti,Jn),Je(q.uponSanitizeElement,p,{tagName:k,allowedTags:X}),ps(p,y))return!0;if(Kf(p,k))return ft(p),!0;if(vn[k]||!(dt.tagCheck instanceof Function&&dt.tagCheck(k))&&!X[k]){let D=Vf(p,k,y);return D===!1&&Je(q.afterSanitizeElements,p,null),D}if(I(p)===Le.element&&!Hf(p)||(k==="noscript"||k==="noembed"||k==="noframes")&&ve(Ow,p.innerHTML))return ft(p),!0;if(ht&&p.nodeType===Le.text){let D=sr(p.textContent);p.textContent!==D&&(Bn(e.removed,{element:p.cloneNode()}),p.textContent=D)}return Je(q.afterSanitizeElements,p,null),!1},ms=function(p,y,k){if(Va[y]||cs(y,p)||Xa&&(y==="id"||y==="name")&&(k in n||k in Ff))return!1;let A=Z[y]||dt.attributeCheck instanceof Function&&dt.attributeCheck(y,p);return Ai&&ve(Lf,y)||ja&&ve(Nf,y)?!0:A?ns[y]||ve(Ka,Wn(k,Wa,""))||(y==="src"||y==="xlink:href"||y==="href")&&p!=="script"&&jd(k,"data:")===0&&es[p]||qa&&!ve(Df,Wn(k,Wa,""))?!0:!k:vs(p)&&ur(Ze.tagNameCheck,p)&&ur(Ze.attributeNameCheck,y,p)||y==="is"&&Ze.allowCustomizedBuiltInElements&&ur(Ze.tagNameCheck,k)},jf=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vs=function(p){return!jf[Vn(p)]&&ve(Pf,p)},qf=function(p,y,k,A){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!k)switch(h.getAttributeType(p,y)){case"TrustedHTML":return he(A);case"TrustedScriptURL":return Ye(A)}return A},Yf=function(p,y,k,A){try{k?p.setAttributeNS(k,y,A):p.setAttribute(y,A),lr(p)?ft(p):Kd(e.removed)}catch{Et(y,p)}},ys=function(p){Je(q.beforeSanitizeAttributes,p,null);let y=p.attributes;if(!y||lr(p))return;Z=fs(q.uponSanitizeAttribute,Z,Ri,er);let k={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0},A=y.length,D=ne(p.nodeName);for(;A--;){let O=y[A],Y=O.name,ee=O.namespaceURI,ke=O.value,Se=ne(Y),zi=ke,we=Y==="value"?zi:ww(zi);if(k.attrName=Se,k.attrValue=we,k.keepAttr=!0,k.forceKeepAttr=void 0,Je(q.uponSanitizeAttribute,p,k),we=k.attrValue,Za&&(Se==="id"||Se==="name")&&jd(we,Qa)!==0&&(Et(Y,p,O),we=Qa+we),xt&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){Et(Y,p,O);continue}if(Se==="attributename"&&Vd(we,"href")){Et(Y,p,O);continue}if(!k.forceKeepAttr){if(!k.keepAttr){Et(Y,p,O);continue}if(!Ya&&ve(Fw,we)){Et(Y,p,O);continue}if(ht&&(we=sr(we)),!ms(D,Se,we)){Et(Y,p,O);continue}we=qf(D,Se,ee,we),we!==zi&&Yf(p,Y,ee,we)}}Je(q.afterSanitizeAttributes,p,null)},cr=function(p){let y=null,k=hs(p);for(Je(q.beforeSanitizeShadowDOM,p,null);y=k.nextNode();)if(Je(q.uponSanitizeShadowNode,y,null),gs(y,p),ys(y),Kt(y.content)&&cr(y.content),I(y)===Le.element){let A=b(y);Kt(A)&&($i(A),cr(A))}Je(q.afterSanitizeShadowDOM,p,null)},$i=function(p){let y=[{node:p,shadow:null}];for(;y.length>0;){let k=y.pop();if(k.shadow){cr(k.shadow);continue}let A=k.node,O=I(A)===Le.element,Y=v(A);if(Y)for(let ee=Y.length-1;ee>=0;--ee)y.push({node:Y[ee],shadow:null});if(O){let ee=L?L(A):null;if(typeof ee=="string"&&ne(ee)==="template"){let ke=A.content;Kt(ke)&&y.push({node:ke,shadow:null})}}if(O){let ee=b(A);Kt(ee)&&y.push({node:null,shadow:ee},{node:ee,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,k=null,A=null,D=null;if(Pi=!T,Pi&&(T="<!-->"),typeof T!="string"&&!wn(T)&&(T=kw(T),typeof T!="string"))throw It("dirty is not a string, aborting");if(!e.isSupported)return T;Ci?(X=Jn,Z=er):Oi(p),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(X=Ne(X)),q.uponSanitizeAttribute.length>0&&(Z=Ne(Z)),e.removed=[];let O=Di&&typeof T!="string"&&wn(T);if(O){Wf(T);let ke=$(T);if(typeof ke=="string"){let Se=ne(ke);if(!X[Se]||vn[Se])throw or(T),It("root node is forbidden and cannot be sanitized in-place")}if(lr(T))throw or(T),It("root node is clobbered and cannot be sanitized in-place");try{$i(T)}catch(Se){throw or(T),Se}}else if(wn(T))y=ds("<!---->"),k=y.ownerDocument.importNode(T,!0),k.nodeType===Le.element&&k.nodeName==="BODY"||k.nodeName==="HTML"?y=k:y.appendChild(k),$i(k);else{if(!zt&&!ht&&!_t&&T.indexOf("<")===-1)return F&&nr?he(T):T;if(y=ds(T),!y)return zt?null:nr?G:""}y&&Li&&ft(y.firstChild);let Y=O?T:y;try{let ke=hs(Y);for(;A=ke.nextNode();)gs(A,Y),ys(A),Kt(A.content)&&cr(A.content)}catch(ke){throw O&&(or(T),Gt(e.removed,Se=>{Se.element&&ar(Se.element)})),ke}if(O)return Gt(e.removed,ke=>{ke.element&&ar(ke.element)}),ht&&Fi(T),T;if(zt){if(ht&&Fi(y),tr)for(D=Xe.call(y.ownerDocument);y.firstChild;)D.appendChild(y.firstChild);else D=y;return(Z.shadowroot||Z.shadowrootmode)&&(D=De.call(r,D,!0)),D}let ee=_t?y.outerHTML:y.innerHTML;return _t&&X["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&ve(Gw,y.ownerDocument.doctype.name)&&(ee="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
|
|
336
|
-
`+ee),
|
|
337
|
-
]`).replace("lheading",
|
|
338
|
-
`),n=e.length-1;for(;n>=0&&
|
|
339
|
-
`)}function
|
|
333
|
+
`,Yp=qp,wl=WebGLRenderingContext,ol=wl.UNSIGNED_BYTE,Sn=wl.FLOAT,Xp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],bl=(function(t){function e(){return se(this,e),_e(this,e,arguments)}return Ee(e,t),le(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Yp,FRAGMENT_SHADER_SOURCE:gl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Xp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Sn},{name:"a_positionEnd",size:2,type:Sn},{name:"a_normal",size:2,type:Sn},{name:"a_color",size:4,type:ol,normalized:!0},{name:"a_id",size:4,type:ol,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Sn},{name:"a_normalCoef",size:1,type:Sn}],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=Xt(s.color),g=h-u,v=d-c,m=g*g+v*v,b=0,w=0;m&&(m=1/Math.sqrt(m),b=-v*m*l,w=g*m*l);var E=this.array;E[i++]=u,E[i++]=c,E[i++]=h,E[i++]=d,E[i++]=b,E[i++]=w,E[i++]=f,E[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)}}])})(so);var Nl=xn(Sr()),Tr=(function(t){function e(){var n;return se(this,e),n=_e(this,e),n.rawEmitter=n,n}return Ee(e,t),le(e)})(Nl.EventEmitter);var Il=xn(co());var rg=function(e){return e},ig=function(e){return e*e},og=function(e){return e*(2-e)},ag=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},sg=function(e){return e*e*e},lg=function(e){return--e*e*e+1},ug=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},Ml={linear:rg,quadraticIn:ig,quadraticOut:og,quadraticInOut:ag,cubicIn:sg,cubicOut:lg,cubicInOut:ug},Ol={easing:"quadraticInOut",duration:150};function Ie(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ar(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function Dl(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 Gl(t,e,n){return t[6]=e,t[7]=n,t}function yt(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],v=e[4],m=e[5],b=e[6],w=e[7],E=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+v*o+m*l,t[4]=g*r+v*a+m*u,t[5]=g*i+v*s+m*c,t[6]=b*n+w*o+E*l,t[7]=b*r+w*a+E*u,t[8]=b*i+w*s+E*c,t}function Rr(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 cg(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 Qt(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=Ie(),d=Math.min(u,c)-2*r,f=cg(e,n);return i?(yt(h,Gl(Ie(),s,l)),yt(h,Ar(Ie(),a)),yt(h,Dl(Ie(),o)),yt(h,Ar(Ie(),u/d/2/f,c/d/2/f))):(yt(h,Ar(Ie(),2*(d/u)*f,2*(d/c)*f)),yt(h,Dl(Ie(),-o)),yt(h,Ar(Ie(),1/a)),yt(h,Gl(Ie(),-s,-l))),h}function Fl(t,e,n){var r=Rr(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 zl(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 $l(t){if(!(0,Il.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 Ul(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 ho(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function fo(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 po(t){var e=vt(t.x,2),n=e[0],r=e[1],i=vt(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 Cr(t){"@babel/helpers - typeof";return Cr=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},Cr(t)}function go(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 Lr(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 Nr={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:ul,defaultDrawNodeLabel:lo,defaultDrawNodeHover:cl,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:{}},dg={circle:Tn},hg={arrow:yl,line:bl};function Pr(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 Hl(t){var e=Lr({},Nr,t);return e.nodeProgramClasses=Lr({},dg,e.nodeProgramClasses),e.edgeProgramClasses=Lr({},hg,e.edgeProgramClasses),e}var b_=xn(Sr()),x_=xn(co()),Dr=1.5,Bl=(function(t){function e(){var n;return se(this,e),n=_e(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 Ee(e,t),le(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(N(N({},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=N(N({},Ol),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:Ml[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 v=u(g),m={};typeof l.x=="number"&&(m.x=h.x+(l.x-h.x)*v),typeof l.y=="number"&&(m.y=h.y+(l.y-h.y)*v),i.enabledRotation&&typeof l.angle=="number"&&(m.angle=h.angle+(l.angle-h.angle)*v),typeof l.ratio=="number"&&(m.ratio=h.ratio+(l.ratio-h.ratio)*v),i.setState(m),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||Dr)},r):this.animate({ratio:this.ratio/Dr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Dr)},r):this.animate({ratio:this.ratio*Dr})}},{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)}}])})(Tr);function Be(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function at(t,e){var n=N(N({},Be(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function An(t){var e="x"in t?t:N(N({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function fg(t,e){return N(N({},at(t,e)),{},{delta:Yl(t)})}var pg=2;function Gr(t){for(var e=[],n=0,r=Math.min(t.length,pg);n<r;n++)e.push(t[n]);return e}function Rn(t,e,n){var r={touches:Gr(t.touches).map(function(i){return Be(i,n)}),previousTouches:e.map(function(i){return Be(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Yl(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 Xl=(function(t){function e(n,r){var i;return se(this,e),i=_e(this,e),i.container=n,i.renderer=r,i}return Ee(e,t),le(e)})(Tr),gg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],mg=gg.reduce(function(t,e){return N(N({},t),{},S({},e,Nr[e]))},{}),vg=(function(t){function e(n,r){var i;return se(this,e),i=_e(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",mg),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 Ee(e,t),le(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",at(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",at(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=at(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(Be(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=Be(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",at(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=Be(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",at(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=at(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=Be(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(),v=g.x+d,m=g.y+f;a.setState({x:v,y:m}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",at(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",at(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Yl(r);if(a){var s=fg(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(Be(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}}])})(Xl),yg=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],wg=yg.reduce(function(t,e){return N(N({},t),{},S({},e,Nr[e]))},{}),bg=(function(t){function e(n,r){var i;return se(this,e),i=_e(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",wg),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 Ee(e,t),le(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=Gr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Be(f,i.container)}),this.touchMode===2){var a=vt(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",Rn(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",Rn(r,this.lastTouches,this.container)),!r.touches.length){var s=Be(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=Rn(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=Rn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Gr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Gr(r.touches),a=o.map(function(Je){return Be(Je,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=Rn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Je,mn){var De=i.startTouchesPositions[mn];return De&&(Je.x!==De.x||Je.y!==De.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,v=this.renderer.viewportToFramedGraph(a[0]),m=v.x,b=v.y;u.setState({x:c.x+f-m,y:c.y+g-b});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},E=a[0],_=E.x,L=E.y,D=a[1],G=D.x,z=D.y,F=Math.atan2(z-L,G-_)-this.startTouchesAngle,I=Math.hypot(z-L,G-_)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/I);w.ratio=U,w.angle=c.angle+F;var j=this.getDimensions(),J=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(j.width,j.height)-2*h,he=ge/j.width,Qe=ge/j.height,$t=U/ge,ze=_-ge/2/he,$e=L-ge/2/Qe,Ue=[ze*Math.cos(-w.angle)-$e*Math.sin(-w.angle),$e*Math.cos(-w.angle)+ze*Math.sin(-w.angle)];ze=Ue[0],$e=Ue[1],w.x=J.x-ze*$t,w.y=J.y+$e*$t,u.setState(w);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Xl);function xg(t){if(Array.isArray(t))return xr(t)}function _g(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Eg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
334
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Wl(t){return xg(t)||_g(t)||eo(t)||Eg()}function kg(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 mo(t,e){if(t==null)return{};var n,r,i=kg(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 Kl=(function(){function t(e,n){se(this,t),this.key=e,this.size=n}return le(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Vl=(function(){function t(){se(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 le(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 Kl(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(Kl.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 Sg(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 jl=150,ql=50,st=Object.prototype.hasOwnProperty;function Tg(t,e,n){if(!st.call(n,"x")||!st.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),st.call(n,"hidden")||(n.hidden=!1),st.call(n,"highlighted")||(n.highlighted=!1),st.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Ag(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),st.call(n,"hidden")||(n.hidden=!1),st.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Rg=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(se(this,e),i=_e(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 Vl),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",Ie()),S(i,"invMatrix",Ie()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",po({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",ho()),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=Hl(o),Pr(i.settings),$l(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 vg(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new bg(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ee(e,t),le(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=mo(i,[r].map(At));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=mo(s,[r].map(At));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=mo(i,[r].map(At));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=ro(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=no.apply(void 0,Wl(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=An(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",N(N({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",N(N({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",N(N({},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",N(N({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",N(N({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=An(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=An(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",N(N({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",N(N({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",N({},s))},this.activeListeners.handleEnter=function(o){var a=An(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",N({},s))};var i=function(a){return function(s){var l=An(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),N(N({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),N(N({},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=ro(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=no.apply(void 0,Wl(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=zl(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=po(this.customBBox||this.nodeExtent);var d=new Bl,f=Qt(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},v={},m={},b={},w=1,E=i.nodes(),_=0,L=E.length;_<L;_++){var D=E[_],G=this.nodeDataCache[D],z=i.getNodeAttributes(D);G.x=z.x,G.y=z.y,this.normalizationFunction.applyTo(G),typeof G.label=="string"&&!G.hidden&&this.labelGrid.add(D,G.size,this.framedGraphToViewport(G,{matrix:f})),g[G.type]=(g[G.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!st.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]&&(E=fo(this.nodeZExtent,function(vn){return r.nodeDataCache[vn].zIndex},E));for(var I=0,U=E.length;I<U;I++){var j=E[I];v[j]=w,b[v[j]]={type:"node",id:j},w++;var J=this.nodeDataCache[j];this.addNodeToProgram(j,v[j],g[J.type]++)}for(var ge={},he=i.edges(),Qe=0,$t=he.length;Qe<$t;Qe++){var ze=he[Qe],$e=this.edgeDataCache[ze];ge[$e.type]=(ge[$e.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=fo(this.edgeZExtent,function(vn){return r.edgeDataCache[vn].zIndex},he));for(var Ue in this.edgePrograms){if(!st.call(this.edgePrograms,Ue))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Ue,'"!'));this.edgePrograms[Ue].reallocate(ge[Ue]||0),ge[Ue]=0}for(var Je=0,mn=he.length;Je<mn;Je++){var De=he[Je];m[De]=w,b[m[De]]={type:"edge",id:De},w++;var q=this.edgeDataCache[De];this.addEdgeToProgram(De,m[De],ge[q.type]++)}return this.itemIDsIndex=b,this.nodeIndices=v,this.edgeIndices=m,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&&Cr(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=N({},r),u=s||this.nodeExtent,c=vt(u.x,2),h=c[0],d=c[1],f=vt(u.y,2),g=f[0],v=f[1],m=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:v},{cameraState:r}),this.graphToViewport({x:d,y:v},{cameraState:r})],b=1/0,w=-1/0,E=1/0,_=-1/0;m.forEach(function(ge){var he=ge.x,Qe=ge.y;b=Math.min(b,he),w=Math.max(w,he),E=Math.min(E,Qe),_=Math.max(_,Qe)});var L=w-b,D=_-E,G=this.getDimensions(),z=G.width,F=G.height,I=0,U=0;if(L>=z?w<z-a?I=w-(z-a):b>a&&(I=b-a):w>z+a?I=w-(z+a):b<-a&&(I=b+a),D>=F?_<F-a?U=_-(F-a):E>a&&(U=E-a):_>F+a?U=_-(F+a):E<-a&&(U=E+a),I||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),J=this.viewportToFramedGraph({x:I,y:U},{cameraState:r});I=J.x-j.x,U=J.y-j.y,l.x+=I,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);go(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<-jl||h>this.width+jl||d<-ql||d>this.height+ql)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,v=this.nodePrograms[u.type],m=v?.drawLabel||g;m(o,N(N({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=Sg({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});go(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],v=g?.drawLabel||f;v(r,N(N({key:l},d),{},{size:this.scaleSize(d.size)}),N(N(N({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),N(N(N({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],v=r.framedGraphToViewport(g),m=v.x,b=v.y,w=r.scaleSize(g.size),E=r.settings.defaultDrawNodeHover,_=r.nodePrograms[g.type],L=_?.drawHover||E;L(i,N(N({key:f},g),{},{size:w,x:m,y:b}),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(m){return r.resetWebGLTexture(m)}),!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=Qt(s,l,u,c),this.invMatrix=Qt(s,l,u,c,!0),this.correctionRatio=Fl(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 v=this.edgePrograms[g];v.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=Tg(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=Ag(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 Vl,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=Ul(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=N({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 N({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=N({},this.settings);return this.settings[r]=i,Pr(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=N({},this.settings);return this.settings=N(N({},this.settings),r),Pr(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=ho(),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 v=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],m=0,b=v.length;m<b;m++){var w=v[m];if(this.updateEdge(w),o){var E=this.edgeProgramIndex[w];if(E===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],E)}}}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(N(N({},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},v=this.viewportToFramedGraph(r),m=this.viewportToFramedGraph(g);return{angle:s,x:(v.x-m.x)*(1-f)+l,y:(v.y-m.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?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Rr(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?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Rr(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}}])})(Tr),Zl=Rg;function Ql(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return Jl(this.cover(e,n),e,n,t)}function Jl(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,v,m,b,w;if(!o)return t._root=a,t;for(;o.length;)if((v=e>=(h=(s+u)/2))?s=h:u=h,(m=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[b=m<<1|v]))return i[b]=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[b]=a:t._root=a,t;do i=i?i[b]=new Array(4):t._root=new Array(4),(v=e>=(h=(s+u)/2))?s=h:u=h,(m=n>=(d=(l+c)/2))?l=d:c=d;while((b=m<<1|v)===(w=(g>=d)<<1|f>=h));return i[w]=o,i[b]=a,t}function eu(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)Jl(this,a[n],s[n],t[n]);return this}function tu(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 nu(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function ru(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 iu(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,v;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 m=(a+l)/2,b=(s+u)/2;d.push(new fe(f[3],m,b,l,u),new fe(f[2],a,b,m,u),new fe(f[1],m,s,l,b),new fe(f[0],a,s,m,b)),(v=(e>=b)<<1|t>=m)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-v],d[d.length-1-v]=g)}else{var w=t-+this._x.call(null,f.data),E=e-+this._y.call(null,f.data),_=w*w+E*E;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 ou(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,v,m,b;if(!n)return this;if(n.length)for(;;){if((g=c>=(d=(a+l)/2))?a=d:l=d,(v=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[m=v<<1|g]))return this;if(!n.length)break;(e[m+1&3]||e[m+2&3]||e[m+3&3])&&(r=e,b=m)}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[m]=o:delete e[m],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[b]=n:this._root=n),this):(this._root=o,this)}function au(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function su(){return this._root}function lu(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function uu(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 cu(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 du(t){return t[0]}function hu(t){return arguments.length?(this._x=t,this):this._x}function fu(t){return t[1]}function pu(t){return arguments.length?(this._y=t,this):this._y}function Ct(t,e,n){var r=new vo(e??du,n??fu,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function vo(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 gu(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var ke=Ct.prototype=vo.prototype;ke.copy=function(){var t=new vo(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=gu(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]=gu(r));return t};ke.add=Ql;ke.addAll=eu;ke.cover=tu;ke.data=nu;ke.extent=ru;ke.find=iu;ke.remove=ou;ke.removeAll=au;ke.root=su;ke.size=lu;ke.visit=uu;ke.visitAfter=cu;ke.x=hu;ke.y=pu;function ie(t){return function(){return t}}function We(t){return(t()-.5)*1e-6}function Cg(t){return t.x+t.vx}function Lg(t){return t.y+t.vy}function yo(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ie(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,g,v,m,b=0;b<o;++b)for(h=Ct(e,Cg,Lg).visitAfter(s),u=0;u<c;++u)d=e[u],v=n[d.index],m=v*v,f=d.x+d.vx,g=d.y+d.vy,h.visit(w);function w(E,_,L,D,G){var z=E.data,F=E.r,I=v+F;if(z){if(z.index>d.index){var U=f-z.x-z.vx,j=g-z.y-z.vy,J=U*U+j*j;J<I*I&&(U===0&&(U=We(r),J+=U*U),j===0&&(j=We(r),J+=j*j),J=(I-(J=Math.sqrt(J)))/J*i,d.vx+=(U*=J)*(I=(F*=F)/(m+F)),d.vy+=(j*=J)*I,z.vx-=U*(I=1-I),z.vy-=j*I)}return}return _>f+I||D<f-I||L>g+I||G<g-I}}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:ie(+u),l(),a):t},a}function Ng(t){return t.index}function mu(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function wo(t){var e=Ng,n=h,r,i=ie(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(m){return 1/Math.min(s[m.source.index],s[m.target.index])}function d(m){for(var b=0,w=t.length;b<c;++b)for(var E=0,_,L,D,G,z,F,I;E<w;++E)_=t[E],L=_.source,D=_.target,G=D.x+D.vx-L.x-L.vx||We(u),z=D.y+D.vy-L.y-L.vy||We(u),F=Math.sqrt(G*G+z*z),F=(F-o[E])/F*m*r[E],G*=F,z*=F,D.vx-=G*(I=l[E]),D.vy-=z*I,L.vx+=G*(I=1-I),L.vy+=z*I}function f(){if(a){var m,b=a.length,w=t.length,E=new Map(a.map((L,D)=>[e(L,D,a),L])),_;for(m=0,s=new Array(b);m<w;++m)_=t[m],_.index=m,typeof _.source!="object"&&(_.source=mu(E,_.source)),typeof _.target!="object"&&(_.target=mu(E,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(m=0,l=new Array(w);m<w;++m)_=t[m],l[m]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(w),g(),o=new Array(w),v()}}function g(){if(a)for(var m=0,b=t.length;m<b;++m)r[m]=+n(t[m],m,t)}function v(){if(a)for(var m=0,b=t.length;m<b;++m)o[m]=+i(t[m],m,t)}return d.initialize=function(m,b){a=m,u=b,f()},d.links=function(m){return arguments.length?(t=m,f(),d):t},d.id=function(m){return arguments.length?(e=m,d):e},d.iterations=function(m){return arguments.length?(c=+m,d):c},d.strength=function(m){return arguments.length?(n=typeof m=="function"?m:ie(+m),g(),d):n},d.distance=function(m){return arguments.length?(i=typeof m=="function"?m:ie(+m),v(),d):i},d}var Pg={value:()=>{}};function yu(){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 Ir(n)}function Ir(t){this._=t}function Dg(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}})}Ir.prototype=yu.prototype={constructor:Ir,on:function(t,e){var n=this._,r=Dg(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=Gg(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]=vu(n[i],t.name,e);else if(e==null)for(i in n)n[i]=vu(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 Ir(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 Gg(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function vu(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Pg,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var bo=yu;var Jt=0,Ln=0,Cn=0,bu=1e3,Mr,Nn,Or=0,Lt=0,Fr=0,Pn=typeof performance=="object"&&performance.now?performance:Date,xu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Eo(){return Lt||(xu(Ig),Lt=Pn.now()+Fr)}function Ig(){Lt=0}function xo(){this._call=this._time=this._next=null}xo.prototype=zr.prototype={constructor:xo,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Eo():+n)+(e==null?0:+e),!this._next&&Nn!==this&&(Nn?Nn._next=this:Mr=this,Nn=this),this._call=t,this._time=n,_o()},stop:function(){this._call&&(this._call=null,this._time=1/0,_o())}};function zr(t,e,n){var r=new xo;return r.restart(t,e,n),r}function _u(){Eo(),++Jt;for(var t=Mr,e;t;)(e=Lt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Jt}function wu(){Lt=(Or=Pn.now())+Fr,Jt=Ln=0;try{_u()}finally{Jt=0,Og(),Lt=0}}function Mg(){var t=Pn.now(),e=t-Or;e>bu&&(Fr-=e,Or=t)}function Og(){for(var t,e=Mr,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:Mr=n);Nn=t,_o(r)}function _o(t){if(!Jt){Ln&&(Ln=clearTimeout(Ln));var e=t-Lt;e>24?(t<1/0&&(Ln=setTimeout(wu,t-Pn.now()-Fr)),Cn&&(Cn=clearInterval(Cn))):(Cn||(Or=Pn.now(),Cn=setInterval(Mg,bu)),Jt=1,xu(wu))}}function Eu(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function ku(t){return t.x}function Su(t){return t.y}var Fg=10,zg=Math.PI*(3-Math.sqrt(5));function ko(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=zr(h),u=bo("tick","end"),c=Eu();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(v){var m,b=t.length,w;v===void 0&&(v=1);for(var E=0;E<v;++E)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),m=0;m<b;++m)w=t[m],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 v=0,m=t.length,b;v<m;++v){if(b=t[v],b.index=v,b.fx!=null&&(b.x=b.fx),b.fy!=null&&(b.y=b.fy),isNaN(b.x)||isNaN(b.y)){var w=Fg*Math.sqrt(.5+v),E=v*zg;b.x=w*Math.cos(E),b.y=w*Math.sin(E)}(isNaN(b.vx)||isNaN(b.vy))&&(b.vx=b.vy=0)}}function g(v){return v.initialize&&v.initialize(t,c),v}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(v){return arguments.length?(t=v,f(),s.forEach(g),e):t},alpha:function(v){return arguments.length?(n=+v,e):n},alphaMin:function(v){return arguments.length?(r=+v,e):r},alphaDecay:function(v){return arguments.length?(i=+v,e):+i},alphaTarget:function(v){return arguments.length?(o=+v,e):o},velocityDecay:function(v){return arguments.length?(a=1-v,e):1-a},randomSource:function(v){return arguments.length?(c=v,s.forEach(g),e):c},force:function(v,m){return arguments.length>1?(m==null?s.delete(v):s.set(v,g(m)),e):s.get(v)},find:function(v,m,b){var w=0,E=t.length,_,L,D,G,z;for(b==null?b=1/0:b*=b,w=0;w<E;++w)G=t[w],_=v-G.x,L=m-G.y,D=_*_+L*L,D<b&&(z=G,b=D);return z},on:function(v,m){return arguments.length>1?(u.on(v,m),e):u.on(v)}}}function So(){var t,e,n,r,i=ie(-30),o,a=1,s=1/0,l=.81;function u(f){var g,v=t.length,m=Ct(t,ku,Su).visitAfter(h);for(r=f,g=0;g<v;++g)e=t[g],m.visit(d)}function c(){if(t){var f,g=t.length,v;for(o=new Array(g),f=0;f<g;++f)v=t[f],o[v.index]=+i(v,f,t)}}function h(f){var g=0,v,m,b=0,w,E,_;if(f.length){for(w=E=_=0;_<4;++_)(v=f[_])&&(m=Math.abs(v.value))&&(g+=v.value,b+=m,w+=m*v.x,E+=m*v.y);f.x=w/b,f.y=E/b}else{v=f,v.x=v.data.x,v.y=v.data.y;do g+=o[v.data.index];while(v=v.next)}f.value=g}function d(f,g,v,m){if(!f.value)return!0;var b=f.x-e.x,w=f.y-e.y,E=m-g,_=b*b+w*w;if(E*E/l<_)return _<s&&(b===0&&(b=We(n),_+=b*b),w===0&&(w=We(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),e.vx+=b*f.value*r/_,e.vy+=w*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(b===0&&(b=We(n),_+=b*b),w===0&&(w=We(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(E=o[f.data.index]*r/_,e.vx+=b*E,e.vy+=w*E);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:ie(+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 To(t){var e=ie(.1),n,r,i;typeof t!="function"&&(t=ie(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:ie(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ie(+s),a(),o):t},o}function Ao(t){var e=ie(.1),n,r,i;typeof t!="function"&&(t=ie(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:ie(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ie(+s),a(),o):t},o}var Dn=9,$r=Dn+9,$g=220,Ug=.05,Hg=-50,Bg=90,Wg=.02,Kg=300,Ru=1,Tu=.001;function Au(t){return t==="contains"||t==="anchored-at"}function Vg(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function jg(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 Cu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??Kg)),r=e.seed??Ru,{ids:i,edges:o}=jg(t),a=new Map;if(i.length===0)return a;let s=e.initial,l=i.map(u=>{let c=s?.get(u),h={id:u,vx:0,vy:0};return c!==void 0&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&(h.x=c.x,h.y=c.y,e.pinWarm===!0&&(h.fx=c.x,h.fy=c.y)),h});if(l.length>1&&qg(l,o,{ticks:n,seed:r,warm:s!==void 0}),e.pinWarm===!0)for(let u of l)u.fx=null,u.fy=null;for(let u of l)a.set(u.id,{x:Number.isFinite(u.x)?u.x:0,y:Number.isFinite(u.y)?u.y:0});return a}function Ro(t){let e=wo(t.links).id(n=>n.id).distance(n=>Au(n.kind)?Bg:$g).strength(n=>Au(n.kind)?Wg:Ug).iterations(2);return ko(t.nodes).randomSource(Vg(t.seed??Ru)).force("charge",So().strength(Hg)).force("link",e).force("collide",yo($r).strength(1).iterations(3)).force("x",To(n=>t.anchors?.get(n.id)?.x??0)).force("y",Ao(n=>t.anchors?.get(n.id)?.y??0)).stop()}function qg(t,e,n){let r=e.map(o=>({source:o.source,target:o.target,kind:o.kind})),i=Ro({nodes:t,links:r,seed:n.seed});i.alpha(n.warm?.3:1).alphaMin(Tu).alphaDecay(n.ticks>0?1-Math.pow(Tu,1/n.ticks):0);for(let o=0;o<n.ticks;o++)i.tick()}function Le(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 Yg(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 v=g.detail.path;u.startsWith(v+"/")&&v.length>h&&(c=f,h=v.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 Nu(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 Xg(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function Zg(t,e){return t.slice().sort((n,r)=>{let i=Le(e.get(n)),o=Le(e.get(r));return i.localeCompare(o)})}function Lu(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 Qg(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?Lu(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?Lu(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=Yg(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let b=(i.get(g)??[]).filter(w=>{let E=r.get(w);if(!E||E.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(w))return!1;return!0}).concat(o.get(g)??[]);return b=b.filter(w=>r.has(w)),e.showInternals||(b=b.filter(w=>{let E=r.get(w);return!(E&&Xg(E.kind))})),Zg(b,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Le(g).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=g=>{let v=r.get(g),m=!1;for(let w of s(g))h(w)&&(m=!0);let b=u(v)||m;return b&&c.add(g),b};for(let g of a)h(g);let d=[],f=(g,v)=>{if(!c.has(g))return;let m=r.get(g),b=s(g),w=b.filter(_=>c.has(_)),E=l?w.length>0:e.expanded.has(g);if(d.push({id:g,depth:v,hasKids:b.length>0,expanded:E,label:Le(m),kind:m.kind,provenance:m.provenance,meta:Qg(m)}),E)for(let _ of w)f(_,v+1)};for(let g of a)f(g,0);return d}function Lo(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 Gn(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 Jg=7;function No(t,e){if(t===null)return"";switch(t.kind){case"relTime":return Gn(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,Jg);case"text":return t.text}}var em=["path","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","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 em){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} → ${Le(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:`← ${Le(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Le(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Do(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 tm=["contains","anchored-at"];function nm(t){return tm.includes(t)}function Ur(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=rm(t,n),i=Nu(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,im(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(v=>l.get(v)===d),provenance:om(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:am(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function rm(t,e){let n=new Map;for(let r of t.edges){if(!nm(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 im(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 om(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 am(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 Go(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 en=[null,"human","agent","generated"];function Pu(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function Nt(t){return{...t.model,danglingLinks:t.dangling}}function Du(t,e){return t===null?[]:Co(Nt(t),e)}function Gu(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function lm(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function um(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function Iu(t,e){return t.query===e?t:{...t,query:e}}function Mu(t){let e=en.indexOf(t.provFilter),n=en[(e+1)%en.length]??null;return{...t,provFilter:n}}function Ou(t){return{...t,showInternals:!t.showInternals}}function Br(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function Mo(t,e){return t[e]?.id??null}function Io(t,e,n){if(t.length===0)return null;let r=Br(t,e),i=r===-1?n>0?-1:t.length:r;return Mo(t,Math.min(t.length-1,Math.max(0,i+n)))}function cm(t,e){let n=Br(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 dm={j:"ArrowDown",k:"ArrowUp"};function hm(t){return dm[t]??t}function Fu(t,e,n,r){let i={state:e,selectedId:n,handled:!1},o=c=>({state:e,selectedId:c,handled:!0}),a=hm(r);if(a==="ArrowDown")return o(Io(t,n,1));if(a==="ArrowUp")return o(Io(t,n,-1));if(a==="Home")return o(Mo(t,0));if(a==="End")return o(Mo(t,t.length-1));if(a!=="ArrowRight"&&a!=="ArrowLeft")return i;let s=Br(t,n),l=s===-1?void 0:t[s];if(l===void 0||n===null)return i;if(a==="ArrowRight")return l.hasKids?l.expanded?o(Io(t,n,1)):{state:lm(e,n),selectedId:n,handled:!0}:i;if(l.hasKids&&l.expanded)return{state:um(e,n),selectedId:n,handled:!0};let u=cm(t,n);return u===null?i:o(u)}var fm={vault:"◆",note:"▪",repository:"▣",module:"▤",package:"◈",entryPoint:"▷",gitState:"◇",external:"↗",file:"·"};function Oo(t){return fm[t]}var pm={human:"●",agent:"◐",generated:"○"};function Pt(t){return t===null?"":pm[t]}function In(t){return t===null?"":`${t}-authored`}var gm={open:"▾",closed:"▸",leaf:""};function zu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function mm(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 vm(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:zu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindGlyph:Oo(t.kind),provenance:t.provenance,provenanceGlyph:Pt(t.provenance),provenanceTitle:In(t.provenance),twisty:i,twistyGlyph:gm[i],hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:No(t.meta,n),level:t.depth+1}}function $u(t,e,n){let r=mm(t);return t.map((i,o)=>vm(i,e,n,r[o]))}function Uu(t,e){return Br(t,e)===-1?null:zu(e)}function Hu(t){return{"--weave-depth":String(Math.max(0,t))}}function Hr(t){return t===null?"all":t}function Bu(t){let e=en.indexOf(t),n=en[(e+1)%en.length]??null;return`provenance filter: ${Hr(t)} — click for ${Hr(n)}`}function Wu(t){return t?"internals":"knowledge"}function Ku(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 Vu="filter…",ju="Vault and repository",qu="Filter the tree",Yu="Filter the tree (/)";function Xu(t,e,n){if(t===null)return"loading…";let r=Lo(Nt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter":"nothing to show"}function Zu(t){return t.length===1?"1 row":`${t.length} rows`}var Wr={dark:{accent:"#a48cff",success:"#4ade80",warning:"#fbbf24",dim:"#8f8a9c",text:"#e8e6ee",muted:"#5d5869",line:"#343141"},light:{accent:"#6d4aff",success:"#15803d",warning:"#b45309",dim:"#6f6b66",text:"#1c1b19",muted:"#9a958e",line:"#d2cec8"}},ym={vault:"accent",note:"text",repository:"accent",module:"success",package:"success",entryPoint:"warning",gitState:"warning",external:"warning",file:"dim"},wm={contains:"line","anchored-at":"line","links-to":"accent",mentions:"warning"};function bm(t,e){return Wr[e][ym[t]]}function xm(t,e){return Wr[e][wm[t]]}var Fo=6,_m=32;function Em(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+_m));return Fo+(Dn-Fo)*n}var km={contains:.8,"anchored-at":.8,"links-to":1.4,mentions:1};function Sm(t){let e=Pt(t.provenance),n=Le(t);return e===""?n:`${e} ${n}`}var Qu={nodes:[],edges:[]};function Ju(t){return`${t.source}\0${t.target}\0${t.kind}`}function Tm(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 ec(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=Tm(e,o),s=[];for(let[c,h]of i){let d=n.get(c),f=Em(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:Sm(h),color:bm(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:km[c.kind],color:xm(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function Am(t){return Wr[t].muted}function tc(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+Rm}:{color:Am(r),label:null,zIndex:0}}var Rm=Dn+1;function nc(t){return(e,n)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1}:{hidden:!0}}var Cm=(Fo+Dn)/2,Lm=$r*4,Nm=1;function rc(t){let e=Wr[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Nm,labelGridCellSize:Lm,labelRenderedSizeThreshold:Cm,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:$r,allowInvalidContainer:!0}}var sc=xn(Sr(),1);function Pm(){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 ue=Pm;typeof Object.assign=="function"&&(ue=Object.assign);function Oe(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 ve(t){return typeof t=="object"&&t!==null}function lc(t){let e;for(e in t)return!1;return!0}function Me(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Ke(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 ic(t){return!(!ve(t)||t.attributes&&!Array.isArray(t.attributes))}function Dm(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function lt(){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 nn(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Fn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},C=class t extends Fn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},A=class t extends Fn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends Fn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function uc(t,e){this.key=t,this.attributes=e,this.clear()}uc.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 cc(t,e){this.key=t,this.attributes=e,this.clear()}cc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function dc(t,e){this.key=t,this.attributes=e,this.clear()}dc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function rn(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}rn.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)};rn.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};rn.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]};rn.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 hc=0,fc=1,Gm=2,pc=3;function ut(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===hc){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===pc){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===fc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function Im(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);return a.attributes[s]}}function Mm(t,e,n){t.prototype[e]=function(r,i){let[o]=ut(this,e,n,r,i);return o.attributes}}function Om(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function Fm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ut(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 zm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ut(this,e,n,r,i,o,a);if(typeof u!="function")throw new C(`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 $m(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(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 Um(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);if(!ve(s))throw new C(`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 Hm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);if(!ve(s))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return ue(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]=ut(this,e,n,r,i,o);if(typeof s!="function")throw new C(`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 Wm=[{name:t=>`get${t}Attribute`,attacher:Im},{name:t=>`get${t}Attributes`,attacher:Mm},{name:t=>`has${t}Attribute`,attacher:Om},{name:t=>`set${t}Attribute`,attacher:Fm},{name:t=>`update${t}Attribute`,attacher:zm},{name:t=>`remove${t}Attribute`,attacher:$m},{name:t=>`replace${t}Attributes`,attacher:Um},{name:t=>`merge${t}Attributes`,attacher:Hm},{name:t=>`update${t}Attributes`,attacher:Bm}];function Km(t){Wm.forEach(function({name:e,attacher:n}){n(t,e("Node"),hc),n(t,e("Source"),fc),n(t,e("Target"),Gm),n(t,e("Opposite"),pc)})}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=Oe(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 jm(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=Oe(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 qm(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=Oe(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 Ym(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=Oe(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 Xm(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=Oe(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 C(`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 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=Oe(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 Qm(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=Oe(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(!ve(i))throw new C(`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 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=Oe(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(!ve(i))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return ue(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function ev(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=Oe(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 C(`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 tv=[{name:t=>`get${t}Attribute`,attacher:Vm},{name:t=>`get${t}Attributes`,attacher:jm},{name:t=>`has${t}Attribute`,attacher:qm},{name:t=>`set${t}Attribute`,attacher:Ym},{name:t=>`update${t}Attribute`,attacher:Xm},{name:t=>`remove${t}Attribute`,attacher:Zm},{name:t=>`replace${t}Attributes`,attacher:Qm},{name:t=>`merge${t}Attributes`,attacher:Jm},{name:t=>`update${t}Attributes`,attacher:ev}];function nv(t){tv.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var rv=[{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 iv(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 ov(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 zo(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 av(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 sv(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 $o(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 lv(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 gc(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 uv(t,e){if(t.size===0)return nn();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 Uo(t,e,n,r,i,o){let a=e?ov:iv,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 cv(t,e,n,r){let i=[];return Uo(!1,t,e,n,r,function(o){i.push(o)}),i}function dv(t,e,n){let r=nn();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=lt(r,zo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=lt(r,zo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=lt(r,zo(n.undirected))),r}function Ho(t,e,n,r,i,o,a){let s=n?sv:av,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 hv(t,e,n,r,i){let o=[];return Ho(!1,t,e,n,r,i,function(a){o.push(a)}),o}function fv(t,e,n,r){let i=nn();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=lt(i,$o(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=lt(i,$o(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=lt(i,$o(n.undirected,r))),i}function pv(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 lv(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 cv(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 hv(r,this.multi,i,s,a)}throw new C(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function gv(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,gc(!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 Uo(!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 Ho(!1,r,this.multi,i,d,c,h)}throw new C(`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,v,m,b,w,E,_)=>{h[f++]=c(g,v,m,b,w,E,_)})}else h=[],u.push((d,f,g,v,m,b,w)=>{h.push(c(d,f,g,v,m,b,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,v,m,b,w)=>{c(d,f,g,v,m,b,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 C(`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 C(`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,v,m,b,w,E)=>{d=c(d,f,g,v,m,b,w,E)}),this[o].apply(this,u),d}}function mv(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,gc(!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 Uo(!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 Ho(!0,r,this.multi,i,h,u,c)}throw new C(`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,v,m,b)=>u(h,d,f,g,v,m,b)),!!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,v,m,b)=>!u(h,d,f,g,v,m,b)),!this[o].apply(this,l)}}function vv(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 nn();if(!arguments.length)return uv(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 dv(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 fv(r,i,l,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function yv(t){rv.forEach(e=>{pv(t,e),gv(t,e),mv(t,e),vv(t,e)})}var wv=[{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 Zr(){this.A=null,this.B=null}Zr.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Zr.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function Mn(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 Bo(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return Mn(t,null,r,r.undirected,i);if(typeof n=="string")return Mn(t,null,r,r[n],i)}let o=new Zr,a;if(e!=="undirected"){if(n!=="out"){if(a=Mn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Mn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=Mn(t,o,r,r.undirected,i),t&&a))return a}function bv(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 Bo(!1,t,e,n,function(i){r.push(i)}),r}function On(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 xv(t,e,n){if(t!=="mixed"){if(t==="undirected")return On(null,n,n.undirected);if(typeof e=="string")return On(null,n,n[e])}let r=nn(),i=new Zr;return t!=="undirected"&&(e!=="out"&&(r=lt(r,On(i,n,n.in))),e!=="in"&&(r=lt(r,On(i,n,n.out)))),t!=="directed"&&(r=lt(r,On(i,n,n.undirected))),r}function _v(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 bv(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.`);Bo(!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 C(`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 kv(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 Bo(!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 Sv(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 nn();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 xv(r==="mixed"?this.type:r,i,s)}}function Tv(t){wv.forEach(e=>{_v(t,e),Ev(t,e),kv(t,e),Sv(t,e)})}function Kr(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 Av(t,e){let n={key:t};return lc(e.attributes)||(n.attributes=ue({},e.attributes)),n}function Rv(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return lc(n.attributes)||(r.attributes=ue({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function Cv(t){if(!ve(t))throw new C('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 C("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!ve(t.attributes)||t.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Lv(t){if(!ve(t))throw new C('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 C("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new C("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!ve(t.attributes)||t.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new C("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var Nv=Dm(),Pv=new Set(["directed","undirected","mixed"]),oc=new Set(["domain","_events","_eventsCount","_maxListeners"]),Dv=[{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"}],Gv={allowSelfLoops:!0,multi:!1,type:"mixed"};function Iv(t,e,n){if(n&&!ve(n))throw new C(`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 ac(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 mc(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&&!ve(s))throw new C(`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 rn(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 Mv(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 C(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!ve(s))throw new C(`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 E=f.attributes;f.attributes=u(E),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ue(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 v=!1,m=!1;c||(c=ac(t,o,{}),v=!0,o===a&&(h=c,m=!0)),h||(h=ac(t,a,{}),m=!0),d=new rn(r,i,c,h,s),t._edges.set(i,d);let b=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,b&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,b&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,g.key=i,t.emit("edgeAdded",g),[i,!0,v,m]}function tn(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 sc.EventEmitter{constructor(e){if(super(),e=ue({},Gv,e),typeof e.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Pv.has(e.type))throw new C(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new C(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?uc:e.type==="directed"?cc:dc;Me(this,"NodeDataClass",n);let r="geid_"+Nv()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Me(this,"_attributes",{}),Me(this,"_nodes",new Map),Me(this,"_edges",new Map),Me(this,"_directedSize",0),Me(this,"_undirectedSize",0),Me(this,"_directedSelfLoopCount",0),Me(this,"_undirectedSelfLoopCount",0),Me(this,"_edgeKeyGenerator",o),Me(this,"_options",e),oc.forEach(a=>Me(this,a,this[a])),Ke(this,"order",()=>this._nodes.size),Ke(this,"size",()=>this._edges.size),Ke(this,"directedSize",()=>this._directedSize),Ke(this,"undirectedSize",()=>this._undirectedSize),Ke(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Ke(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Ke(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Ke(this,"multi",this._options.multi),Ke(this,"type",this._options.type),Ke(this,"allowSelfLoops",this._options.allowSelfLoops),Ke(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 C(`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 C(`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 C(`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 Iv(this,e,n).key}mergeNode(e,n){if(n&&!ve(n))throw new C(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ue(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 C(`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 tn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do tn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do tn(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=Oe(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 tn(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=Oe(this,e,n,"directed");if(!r)throw new A(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return tn(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=Oe(this,e,n,"undirected");if(!r)throw new A(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return tn(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 C("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(!ve(e))throw new C("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(!ve(e))throw new C("Graph.mergeAttributes: provided attributes are not a plain object.");return ue(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new C("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 C("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!ic(n))throw new C("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 C("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!ic(n))throw new C("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 C("Graph.forEachAdjacencyEntry: expecting a callback.");Kr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Kr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Kr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Kr(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new C("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 C("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 C("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 C("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 C("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 C("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 C("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new C("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++]=Av(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=Rv(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(!ve(e))throw new C("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!ve(e.attributes))throw new C("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 C("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],Cv(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 C("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],Lv(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(ue({},this._options,e));return n.replaceAttributes(ue({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ue({},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,mc(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ue({},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)&&!oc.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Me(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);Dv.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?mc:Mv;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")}})});Km(K);nv(K);yv(K);Tv(K);var Vr=class extends K{constructor(e){let n=ue({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new C("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new C('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},jr=class extends K{constructor(e){let n=ue({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new C("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new C('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},qr=class extends K{constructor(e){let n=ue({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Yr=class extends K{constructor(e){let n=ue({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new C('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Xr=class extends K{constructor(e){let n=ue({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new C('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function on(t){t.from=function(e,n){let r=ue({},e.options,n),i=new t(r);return i.import(e),i}}on(K);on(Vr);on(jr);on(qr);on(Yr);on(Xr);K.Graph=K;K.DirectedGraph=Vr;K.UndirectedGraph=jr;K.MultiGraph=qr;K.MultiDirectedGraph=Yr;K.MultiUndirectedGraph=Xr;K.InvalidArgumentsGraphError=C;K.NotFoundGraphError=A;K.UsageGraphError=M;function Ov(){return new K({multi:!0,type:"directed"})}function Wo(t){let e=Ov();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 vc(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 yc(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function wc(t,e){let n=null,r=Wo({nodes:[],edges:[]}),i=null,o=()=>{},a=()=>{},s=()=>{},l=()=>{},u=null,c=d=>{if(u===null)return;let f=u;u=null,n?.setSetting("enableCameraPanning",!0),(d===null||d===f)&&l(f)},h=d=>{let f=tc(i),g=nc(i);d.setSetting("nodeReducer",(v,m)=>({...m,...f(v,m,e)})),d.setSetting("edgeReducer",(v,m)=>({...m,...g(v,m)}))};return{mount(d){if(n!==null)return;let f=t(r,d,rc(e));f.on("clickNode",({node:g})=>o(g)),f.on("clickStage",()=>o(null)),f.on("downNode",({node:g})=>{u=g,n?.setSetting("enableCameraPanning",!1),a(g)}),f.on("moveBody",g=>{u!==null&&(g.preventSigmaDefault(),s(u,f.viewportToGraph({x:g.event.x,y:g.event.y})))}),f.on("upNode",()=>c(u)),f.on("upStage",()=>c(null)),h(f),n=f},setGraph(d){r=Wo(d),n?.setGraph(r)},setPositions(d){vc(r,d),n?.refresh()},setHighlight(d){i=d,n!==null&&h(n)},onSelect(d){o=d},onDragStart(d){a=d},onDragMove(d){s=d},onDragEnd(d){l=d},fit(){n?.getCamera().animatedReset()},positions(){return yc(r)},destroy(){n?.kill(),n=null}}}var Fv=(t,e,n)=>new Zl(t,e,n),bc=t=>wc(Fv,t);var _c="/events";var zv=2,Qr={graph:!1,note:!1};function Ec(t){return!t.graph&&!t.note}function $v(t,e){return{graph:!0,note:t==="vault"&&e}}function xc(t){return{graph:!0,note:t}}function kc(){return{connection:"live",stamp:null,opened:!1}}function Sc(t,e){return t.stamp===e?t:{...t,stamp:e}}function Uv(t){return t===zv?"offline":"reconnecting"}function Tc(t,e,n){switch(e.type){case"open":{let r=t.opened?xc(n):Qr;return{state:{...t,connection:"live",opened:!0},plan:r}}case"error":return{state:{...t,connection:Uv(e.readyState)},plan:Qr};case"frame":return e.event.stamp===t.stamp?{state:t,plan:Qr}:{state:{...t,connection:"live"},plan:$v(e.event.scope,n)};case"refresh":return{state:t,plan:xc(n)};case"closed":return{state:{...t,connection:"offline"},plan:Qr}}}function Ac(t){let e;try{e=JSON.parse(t)}catch{return null}return Gs(e)?e:null}var Hv=Symbol.for("preact-signals");function ni(){if(ct>1)ct--;else{var t,e=!1;for((function(){var i=ei;for(ei=void 0;i!==void 0;){var o=i.S;if(o.v===i.v)for(var a=o.t;a!==void 0;a=a.x)a.i===i.i&&(a.i=o.i);i=i.o}})();$n!==void 0;){var n=$n;for($n=void 0,Jr++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Cc(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(Jr=0,ct--,e)throw t}}function Vo(t){if(ct>0)return t();Ko=++Bv,ct++;try{return t()}finally{ni()}}var zn,Q=void 0;function Un(t){var e=Q,n=zn;Q=void 0,zn=void 0;try{return t()}finally{Q=e,zn=n}}var $n=void 0,ct=0,Jr=0,Bv=0,Ko=0,ei=void 0,ti=0;function Rc(t){if(Q!==void 0){var e=t.n;if(e===void 0||e.t!==Q)return e={i:0,S:t,p:Q.s,n:void 0,t:Q,e:void 0,x:void 0,r:e},Q.s!==void 0&&(Q.s.n=e),Q.s=e,t.n=e,32&Q.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Q.s,e.n=void 0,Q.s.n=e,Q.s=e),e}}function ce(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}ce.prototype.brand=Hv;ce.prototype.h=function(){return!0};ce.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Un(function(){var r;(r=e.W)==null||r.call(e)}))};ce.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&Un(function(){var i;(i=e.Z)==null||i.call(e)}))}};ce.prototype.subscribe=function(t){var e=this;return Gt(function(){var n=e.value;Un(function(){return t(n)})},{name:"sub"})};ce.prototype.valueOf=function(){return this.value};ce.prototype.toString=function(){return this.value+""};ce.prototype.toJSON=function(){return this.value};ce.prototype.peek=function(){var t=this;return Un(function(){return t.value})};Object.defineProperty(ce.prototype,"value",{get:function(){var t=Rc(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Jr>100)throw new Error("Cycle detected");(function(n){ct!==0&&Jr===0&&n.l!==Ko&&(n.l=Ko,ei={S:n,v:n.v,i:n.i,o:ei})})(this),this.v=t,this.i++,ti++,ct++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ni()}}}});function Ve(t,e){return new ce(t,e)}function Cc(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Lc(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Nc(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function Dt(t,e){ce.call(this,void 0,e),this.x=t,this.s=void 0,this.g=ti-1,this.f=4}Dt.prototype=new ce;Dt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ti))return!0;if(this.g=ti,this.f|=1,this.i>0&&!Cc(this))return this.f&=-2,!0;var t=Q;try{Lc(this),Q=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Q=t,Nc(this),this.f&=-2,!0};Dt.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}ce.prototype.S.call(this,t)};Dt.prototype.U=function(t){if(this.t!==void 0&&(ce.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Dt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Dt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Rc(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function ri(t,e){return new Dt(t,e)}function Pc(t){var e=t.m;if(t.m=void 0,typeof e=="function"){ct++;var n=Q;Q=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,jo(t),r}finally{Q=n,ni()}}}function jo(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Pc(t)}function Wv(t){if(Q!==this)throw new Error("Out-of-order effect");Nc(this),Q=t,this.f&=-2,8&this.f&&jo(this),ni()}function an(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,zn&&zn.push(this)}an.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};an.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Pc(this),Lc(this),ct++;var t=Q;return Q=this,Wv.bind(this,t)};an.prototype.N=function(){2&this.f||(this.f|=2,this.u=$n,$n=this)};an.prototype.d=function(){this.f|=8,1&this.f||jo(this)};an.prototype.dispose=function(){this.d()};function Gt(t,e){var n=new an(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Dc,qo,ii,Kv=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var Gc=[];Gt(function(){Dc=this.N})();function sn(t,e){H[t]=e.bind(null,H[t]||function(){})}function oi(t){if(ii){var e=ii;ii=void 0,e()}ii=t&&t.S()}function Ic(t){var e=this,n=t.data,r=jv(n);r.name="ReactiveDom",r.value=n;var i=Ce(function(){for(var s=e,l=e.__v;l=l.__;)if(l.__c){l.__c.__$f|=4;break}var u=ri(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),c=ri(function(){return!Array.isArray(u.value)&&!Ui(u.value)}),h=Gt(function(){if(this.N=Mc,c.value){var f=u.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=e.__$u.d;return e.__$u.d=function(){h(),d.call(this)},[c,u]},[]),o=i[0],a=i[1];return o.value?a.peek():a.value}Ic.displayName="ReactiveTextNode";Object.defineProperties(ce.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Ic},props:{configurable:!0,get:function(){var t=this;return{data:{get value(){return t.value}}}}},__b:{configurable:!0,value:1}});sn("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof ce&&(n||(e.__np=n={}),n[i]=o,r[i]=o.peek())}}t(e)});sn("__r",function(t,e){if(t(e),e.type!==Ge){oi();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,o){var a;return Gt(function(){a=this},{name:o}),a.c=i,a})((function(i){return function(){var o;Kv&&((o=this.y)==null||o.call(this)),i.__$f|=1,i.setState({})}})(r),typeof e.type=="function"?e.type.displayName||e.type.name:""))),qo=r,oi(n)}});sn("__e",function(t,e,n,r){oi(),qo=void 0,t(e,n,r)});sn("diffed",function(t,e){oi(),qo=void 0;var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props,o=n.U;if(o)for(var a in o){var s=o[a];s===void 0||r&&a in r||(s.d(),o[a]=void 0)}if(r){o||(o={},n.U=o);for(var l in r){var u=o[l],c=r[l];u===void 0?(u=Vv(n,l,c,i),o[l]=u):u.o(c,i)}}}t(e)});function Vv(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,o=Ve(n);return{o:function(a,s){o.value=a,r=s},d:Gt(function(){this.N=Mc;var a=o.value.value;r[e]!==a&&(r[e]=a,i?t[e]=a:a!=null&&(a!==!1||e[4]==="-")?t.setAttribute(e,a):t.removeAttribute(e))})}}sn("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var o=r[i];o&&o.d()}}}var a=e.__np;if(a){var s=e.props;for(var l in a)s[l]=a[l]}e.__np=void 0}else{var u=e.__c;if(u){var c=u.__$u;c&&(u.__$u=void 0,c.d())}}t(e)});sn("__h",function(t,e,n,r){r<3&&(e.__$f|=2),t(e,n,r)});jt.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(r||o||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var a in t)if(a!=="__source"&&t[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in t))return!0;return!1};function jv(t,e){return Ce(function(){return Ve(t,e)},[])}var qv=function(t){queueMicrotask(function(){queueMicrotask(t)})};function Yv(){Vo(function(){for(var t;t=Gc.shift();)Dc.call(t)})}function Mc(){Gc.push(this)===1&&(H.requestAnimationFrame||qv)(Yv)}function Xv(){return{expanded:[]}}var je=Ve(null),Fe=Ve(null),Hn=Ve(null),Sk=Ve(Xv()),ln=Ve("live"),un=Ve(new Set);function Oc(t){let e=kc(),n=!1,r=t.open(t.path??_c),i=o=>{let a=Tc(e,o,t.hasSelection());e=a.state,ln.value=e.connection,Ec(a.plan)||t.refetch(a.plan)};return r.addEventListener("open",()=>i({type:"open"})),r.addEventListener("error",()=>i({type:"error",readyState:r.readyState})),r.addEventListener(Ds,o=>{let a=Ac(o.data);a!==null&&i({type:"frame",event:a})}),{stop(){n||(n=!0,r.close(),i({type:"closed"}))},refresh(){i({type:"refresh"})},seen(o){e=Sc(e,o)},state(){return e}}}function Fc(t){return new EventSource(t)}function ai(t,e=!1){return{ok:!0,data:t,cached:e}}function Se(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function Yo(t){return t===403?"auth":t===404?"missing":"server"}function Xo(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function Zo(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Se("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Se(Yo(i.status),i.status,Xo(i.status));let o;try{o=await i.json()}catch{return Se("malformed",i.status,"response was not valid JSON")}return n(o)?ai(o):Se("malformed",i.status,"response did not match the expected shape")}function dt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Zv(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Qv(t){if(!dt(t)||typeof t.stamp!="string")return!1;let e=t.model;return!dt(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:dt(t.tags)&&dt(t.dangling)}function Jv(t){if(!dt(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return Zv(t.tags)}function Qo(t){return dt(t)&&typeof t.revision=="string"&&Jv(t.note)}function ey(t){return!dt(t)||typeof t.error!="string"?!1:t.reason==="collision"?typeof t.slug=="string":t.reason!=="conflict"?!1:Qo(t.current)}function ty(t){return dt(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function ny(t){return dt(t)&&typeof t.opened=="boolean"}async function zc(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 Se("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Se("malformed",304,"server sent 304 for an unconditional request"):ai(e,!0);if(!r.ok)return Se(Yo(r.status),r.status,Xo(r.status));let i;try{i=await r.json()}catch{return Se("malformed",r.status,"response was not valid JSON")}return Qv(i)?ai(i):Se("malformed",r.status,"response did not match the expected shape")}function $c(t,e){return Zo(t,`/api/note/${encodeURIComponent(e)}`,Qo)}function ry(t,e=""){return`/api/note/${encodeURIComponent(t)}${e}`}function iy(t,e){return{method:t,headers:{"content-type":"application/json"},body:JSON.stringify(e)}}async function oy(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Se("network",0,a instanceof Error?a.message:"network request failed")}if(i.status===409){let a;try{a=await i.json()}catch{return Se("malformed",409,"response was not valid JSON")}return ey(a)?{ok:!1,kind:"conflict",status:409,message:a.error,conflict:a}:Se("malformed",409,"response did not match the expected shape")}if(!i.ok)return Se(Yo(i.status),i.status,Xo(i.status));let o;try{o=await i.json()}catch{return Se("malformed",i.status,"response was not valid JSON")}return n(o)?ai(o):Se("malformed",i.status,"response did not match the expected shape")}function Uc(t,e,n){return oy(t,ry(e),Qo,iy("POST",n))}function Hc(t,e){return Zo(t,`/api/search?q=${encodeURIComponent(e)}`,ty)}function Bc(t,e){return Zo(t,"/api/open",ny,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function cn(){return{mode:"read",slug:null,baseline:"",draft:"",revision:null,status:"idle",message:null,saving:null,conflict:null,external:null,pending:null}}function dn(t){return t.mode==="edit"&&t.draft!==t.baseline}function Kc(t){return dn(t)&&t.slug!==null&&t.status!=="saving"}function oe(t){return{state:t,effect:null}}function Jo(t,e,n){return{...t,mode:n,slug:e.note.slug,baseline:e.note.body,draft:e.note.body,revision:e.revision,status:"idle",message:null,saving:null,conflict:null,external:null}}function ay(t,e){return e.note.slug!==t.slug?Jo(t,e,"read"):dn(t)&&e.revision!==t.revision?{...t,external:e}:Jo(t,e,t.mode)}function Vc(t,e){switch(e.type){case"loaded":return oe(ay(t,e.payload));case"cleared":return oe(cn());case"toggle":return t.slug===null?oe(t):t.mode==="read"?oe({...t,mode:"edit",draft:t.baseline,status:"idle",message:null}):dn(t)?oe({...t,status:"error",message:jc}):oe({...t,mode:"read",status:"idle",message:null});case"draft":return oe({...t,draft:e.text,status:t.status==="saving"?"saving":"idle",message:null});case"save":return!Kc(t)||t.slug===null||t.conflict!==null?oe(t):{state:{...t,status:"saving",message:null,saving:t.draft},effect:{type:"save",slug:t.slug,input:sy(t)}};case"saved":return oe(ly(t,e.payload));case"failed":return oe({...t,status:"error",message:e.message,saving:null});case"conflicted":return oe({...t,status:"error",message:e.conflict.error,saving:null,conflict:e.conflict});case"reload":return oe(uy(t));case"overwrite":return cy(t);case"dismiss":return oe({...t,conflict:null,external:null,status:"idle",message:null});case"navigate":return dy(t,e.id);case"discard":return t.pending===null?oe(t):{state:cn(),effect:{type:"select",id:t.pending.id}};case"stay":return oe({...t,pending:null});case"open":return t.slug===null?oe(t):{state:t,effect:{type:"open",slug:t.slug}};case"opened":return oe({...t,status:e.ok?"idle":"error",message:e.ok?fy:py})}}function sy(t){return t.revision===null?{body:t.draft}:{body:t.draft,expectedRevision:t.revision}}function ly(t,e){let n=t.saving!==null&&t.saving!==t.draft;return{...t,slug:e.note.slug,baseline:e.note.body,draft:n?t.draft:e.note.body,revision:e.revision,status:"saved",message:hy,saving:null,conflict:null,external:null}}function uy(t){let e=t.conflict?.reason==="conflict"?t.conflict.current:t.external;return e==null?t:Jo(t,e,t.mode)}function cy(t){return t.slug===null?oe(t):{state:{...t,status:"saving",message:null,saving:t.draft,conflict:null,external:null},effect:{type:"save",slug:t.slug,input:{body:t.draft}}}}function dy(t,e){return dn(t)?oe({...t,pending:{id:e}}):{state:t,effect:{type:"select",id:e}}}function ea(t){return dn(t)}var hy="saved",jc="unsaved changes — save with the button, or discard them",fy="opened in your editor",py="could not open the note in an editor",gy="Edit",my="Done",vy="Save",yy="Saving…",qc="Open in $EDITOR",Yc="Hand this note to $EDITOR (or your platform's opener)",wy="Discard changes",si="Keep editing",Wc="Reload from disk",by="Overwrite",xy="this note changed on disk while you were editing",_y="pick a different name";function Xc(t){let e=t.conflict;return e?.reason==="conflict"?{kind:"conflict",message:e.error,actions:[{label:Wc,event:{type:"reload"}},{label:by,event:{type:"overwrite"}},{label:si,event:{type:"dismiss"}}]}:e?.reason==="collision"?{kind:"collision",message:`${e.error} (${e.slug}) — ${_y}`,actions:[{label:si,event:{type:"dismiss"}}]}:t.pending!==null?{kind:"discard",message:jc,actions:[{label:si,event:{type:"stay"}},{label:wy,event:{type:"discard"}}]}:t.external!==null?{kind:"external",message:xy,actions:[{label:Wc,event:{type:"reload"}},{label:si,event:{type:"dismiss"}}]}:null}function Zc(t){let e=t.mode==="edit";return{toggleLabel:e?my:gy,editing:e,saveLabel:t.status==="saving"?yy:vy,canSave:Kc(t)&&t.conflict===null,message:t.message,tone:t.message===null?"none":t.status==="error"?"warn":"ok",dirty:dn(t)}}function Qc(t){let e=cn(),n=i=>{let o=Vc(e,i);e=o.state,t.onChange(e),o.effect!==null&&r(o.effect)},r=i=>{if(i.type==="select"){t.select(i.id);return}if(i.type==="open"){(async()=>{let o=await Bc(t.fetch,i.slug);n({type:"opened",ok:o.ok&&o.data.opened})})();return}(async()=>{let o=await Uc(t.fetch,i.slug,i.input);if(o.ok){n({type:"saved",payload:o.data});return}n(o.kind==="conflict"?{type:"conflicted",conflict:o.conflict}:{type:"failed",message:o.message})})()};return{state:()=>e,send:n}}function Jc(t,e){let n=r=>{e()&&(r.preventDefault(),r.returnValue="")};return t.addEventListener("beforeunload",n),()=>t.removeEventListener("beforeunload",n)}var ed=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function td(t,e,n){return t<=1?null:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function nd(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function rd(t){return t===null?!1:(t.focus(),!0)}function li(){let t=ye(null);return me(()=>{let e=document.activeElement;return t.current?.focus(),()=>{rd(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!nd(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(ed)??[]],r=td(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function sd(t,e){let n=e.trim().toLowerCase();if(n==="")return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i===-1?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}var Ey=10;function ky(t){return Math.min(Math.max(t,0),Ey)*2}function Sy(t){return`note:${t}`}function Ty(t,e){return sd(t.summary.title,e)+ky(t.score)}function Ay(t,e){return sd(t.label,e)}var Ry=["path","manifest","url","slug"];function Cy(t){for(let e of Ry){let n=t.detail[e];if(typeof n=="string"&&n!=="")return n}return""}function Ly(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 Ny(t,e,n,r){let i=new Map;for(let o of t){let a=Sy(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Ty(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=Ay(o,r);a!==0&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Cy(o),badge:o.kind,score:a})}return[...i.values()].sort(Ly).slice(0,20)}function ui(){return{query:"",typedAt:0,issued:"",answered:"",seq:0,applied:0,hits:[],cursor:0,pending:!1,loading:!1,failed:!1}}var ta=140;function rt(t){return{state:t,request:null,schedule:null}}function id(t,e){return e>t.applied}function ld(t,e){switch(e.type){case"query":{let n={...t,query:e.query,typedAt:e.now,cursor:0};return e.query.trim()===""?rt({...n,hits:[],answered:"",issued:"",loading:!1,failed:!1,pending:!1}):t.pending?rt(n):{state:{...n,pending:!0},request:null,schedule:ta}}case"tick":{if(!t.pending)return rt(t);let n=e.now-t.typedAt;if(n<ta)return{state:t,request:null,schedule:ta-n};let r=t.query.trim();if(r===""||r===t.issued)return rt({...t,pending:!1});let i=t.seq+1;return{state:{...t,pending:!1,loading:!0,seq:i,issued:r},request:{seq:i,query:r},schedule:null}}case"response":return id(t,e.seq)?rt({...t,applied:e.seq,hits:e.hits,answered:e.query,loading:e.seq<t.seq,failed:!1,cursor:0}):rt(t);case"failed":return id(t,e.seq)?rt({...t,applied:e.seq,loading:e.seq<t.seq,failed:!0}):rt(t);case"cursor":return rt({...t,cursor:e.cursor});case"dismiss":return rt({...t,pending:!1})}}function na(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function od(t,e,n){return n<=0?0:((t+e)%n+n)%n}function ud(t,e){return e===null?null:t[e]?.id??null}function cd(t,e,n){let r={state:t,activate:null,dismiss:!1,handled:!1},i=a=>({state:{...t,cursor:a},activate:null,dismiss:!1,handled:!0}),o=na(t.cursor,n);return e==="ArrowDown"?i(od(o,1,n)):e==="ArrowUp"?i(od(o,-1,n)):e==="Home"?i(0):e==="End"?i(na(n-1,n)):e==="Escape"?{state:t,activate:null,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{state:t,activate:o,dismiss:!0,handled:!0}}var ci="Search the workspace",dd="Search notes and repository…",hd="↑↓ move · ↵ open · esc close";function Py(t,e){return t.query.trim()===""?"Type to search notes, modules, files and entry points.":e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading||t.pending?"searching…":`no matches for “${t.query.trim()}”`}function Dy(t){return t===1?"1 result":`${t} results`}function ad(t){return`weave-search-row-${t}`}function fd(t,e){let n=Ny(t.hits,t.answered,e?.model.nodes??[],t.query),r=na(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:ad(a)})),status:Py(t,n.length),count:n.length,countLabel:Dy(n.length),cursor:r,activeDomId:n.length===0?null:ad(r)}}function pd(t){let e=ui(),n=r=>{let i=ld(e,r);e=i.state,t.onChange(e),i.schedule!==null&&t.delay(()=>n({type:"tick",now:t.now()}),i.schedule);let o=i.request;o!==null&&(async()=>{let a=await Hc(t.fetch,o.query);n(a.ok?{type:"response",seq:o.seq,query:o.query,hits:a.data.hits}:{type:"failed",seq:o.seq})})()};return{state:()=>e,setQuery:r=>n({type:"query",query:r,now:t.now()}),setCursor:r=>n({type:"cursor",cursor:r}),dismiss:()=>n({type:"dismiss"})}}var Gy=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:--Gy,__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 H.vnode&&H.vnode(u),u}function Iy({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 gd(t){let[e,n]=He(ui),r=Ce(()=>pd({...t.ports,onChange:n}),[]),i=li(),o=fd(e,t.graph),a=s=>{let l=ud(o.rows,s);l!==null&&t.onSelect(l),r.dismiss(),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>a(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":ci,tabIndex:-1,ref:i.ref,onClick:s=>s.stopPropagation(),onKeyDown:s=>{if(i.onKeyDown(s))return;let l=cd(e,s.key,o.count);l.handled&&(s.preventDefault(),r.setCursor(l.state.cursor),l.dismiss&&a(l.activate))},children:[x("input",{type:"search",class:"weave-palette-input",autofocus:!0,value:e.query,placeholder:dd,"aria-label":ci,"aria-controls":"weave-search-results","aria-activedescendant":o.activeDomId??void 0,onInput:s=>r.setQuery(s.currentTarget.value)}),o.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":ci,children:o.rows.map((s,l)=>x(Iy,{row:s,onPick:()=>a(l),onHover:()=>r.setCursor(l)},s.id))}):x("p",{class:"weave-palette-status",role:"status",children:o.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:o.countLabel}),x("span",{class:"weave-palette-hint",children:hd})]})]})})}var md="pi-weave.selection.v1";function vd(t,e){try{return t.setItem(md,e??""),!0}catch{return!1}}function yd(t,e){if(t===null)return null;let n;try{n=e.getItem(md)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}var My=3e3,ra=new Set;function Oy(t,e){if(t===null)return ra;let n=new Set(t.model.nodes.map(i=>i.id)),r=new Set;for(let i of e.model.nodes)n.has(i.id)||r.add(i.id);return r}var di=null;function bd(t){return di=t,()=>{di===t&&(di=null)}}async function wd(t,e,n){let r=Fe.value,i=await zc(t,Fe.value);return i.ok&&(i.cached||(Fe.value=i.data,n?.(r,i.data)),e?.seen(i.data.stamp)),i}async function ia(t){let e=xd(je.value);if(e===null){Hn.value=null;return}let n=await $c(t,e);n.ok&&(Hn.value=n.data,di?.(n.data))}function xd(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function _d(t){let e=null,n=null,r=t.defer??((a,s)=>{let l=setTimeout(a,s);return()=>clearTimeout(l)}),i=(a,s)=>{let l=Oy(a,s);un.value=l,n?.(),n=null,l.size>0&&(n=r(()=>{n=null,un.value=ra},My))},o=a=>{(async()=>(a.graph&&await wd(t.fetch,e,i),a.note&&await ia(t.fetch)))()};return e=Oc({open:t.open,refetch:o,hasSelection:()=>xd(je.value)!==null,...t.path===void 0?{}:{path:t.path}}),wd(t.fetch,e,i),{refresh(){e?.refresh()},syncNote(){return ia(t.fetch)},stop(){e?.stop(),e=null,n?.(),n=null,un.value=ra}}}function hi(t,e){return je.value=e,ia(t)}function Ed(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 Fy=300,zy=1;function $y(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:Fy,seed:zy,pinWarm:!0};return r.size>0&&(i.initial=r),Cu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function Uy(t,e){let n=0,r=0;for(let o of t){let a=Ed(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=Ed(`${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 Sd="pi-weave.graph.positions.v1";function kd(t){return Math.round(t*10)/10}function Hy(t,e){let n={};for(let[r,i]of e)n[r]=[kd(i.x),kd(i.y)];return JSON.stringify({v:1,key:t,at:n})}function By(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||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 Wy(t,e){let n;try{n=t.getItem(Sd)}catch{return null}return By(n,e)}function Ky(t,e,n){try{return t.setItem(Sd,Hy(e,n)),!0}catch{return!1}}function Td(t,e,n){let r=Uy(e,n),i=Wy(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=$y(e,n);return Ky(t,r,o),{key:r,positions:o,cached:!1}}var Vy=120;function jy(t){return{expanded:t.nodes.length>Vy?new Set:new Set(Ur(t,new Set).clusters.keys())}}function Ad(t,e){return e!==null?e:t===null?{expanded:new Set}:jy(Nt(t))}function qy(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Yy(t,e){return{...t,expanded:new Set(e.keys())}}function Xy(t){return{...t,expanded:new Set}}function Zy(t,e){return e===null?null:Do(e,t)}function Rd(t){return t?"collapse":"expand"}function Cd(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function oa(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function Ld(t,e){return oa(t,e)?Xy(t):Yy(t,e)}var Nd="fit",Pd="frame the whole graph",aa={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Dd(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function Qy(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 Jy={graph:Qu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Gd(t,e,n,r,i){if(t===null)return Jy;let o=Nt(t),a=Ur(o,n.expanded),s=Td(r,a.nodes,a.edges);return{graph:ec(a.nodes,a.edges,s.positions,i),highlight:Zy(a.edges,e),key:s.key,cached:s.cached,clusters:a.clusters,visible:a.nodes.length,total:o.nodes.length,empty:Qy(t,a.nodes.length)}}function Id(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:qy(t,n),selectedId:n}}var ew="(prefers-color-scheme: light)";function Md(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(ew).matches?"light":"dark"}var tw=.06,nw=.2,sa=.001;function Od(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(l=>{let u=e?.get(l.id);return{id:l.id,x:u!==void 0&&Number.isFinite(u.x)?u.x:l.x,y:u!==void 0&&Number.isFinite(u.y)?u.y:l.y,vx:0,vy:0}}),r=new Map(n.map(l=>[l.id,l])),i=new Set,o=[];for(let l of t.edges){if(l.source===l.target||!r.has(l.source)||!r.has(l.target))continue;let u=`${l.source}\0${l.target}\0${l.kind}`;i.has(u)||(i.add(u),o.push({source:l.source,target:l.target,kind:l.kind}))}let a=new Map,s=Ro({nodes:n,links:o,anchors:a,seed:1}).alpha(tw).alphaMin(sa);return{tick(){s.tick()},awake(){return s.alphaTarget()>sa||s.alpha()>sa},positions(){return new Map(n.map(l=>[l.id,{x:l.x??0,y:l.y??0}]))},pin(l,u){let c=r.get(l);c&&(c.fx=u.x,c.fy=u.y,s.alphaTarget(nw))},release(l){let u=r.get(l);u&&(a.set(l,{x:u.x??0,y:u.y??0}),u.fx=null,u.fy=null,s.alphaTarget(0))}}}function Fd(t){let e=ye(null),n=ye(null),r=ye(null),i=ye(null),o=js(()=>{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]=He(null),l=Ce(()=>Md(t.host),[t.host]),u=Ad(t.graph,a),c=Gd(t.graph,t.selectedId,u,t.storage,l),h=oa(u,c.clusters),d=ye({view:u,model:c,onSelect:t.onSelect});return d.current={view:u,model:c,onSelect:t.onSelect},me(()=>{let f=t.renderer(l);return f.onSelect(g=>{let v=Id(d.current.view,d.current.model.clusters,g);s(v.state),d.current.onSelect(v.selectedId)}),f.onDragStart(g=>{let v=n.current?.positions().get(g);v&&(r.current?.pin(g,v),o())}),f.onDragMove((g,v)=>{r.current?.pin(g,v)}),f.onDragEnd(g=>{r.current?.release(g)}),f.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=f,t.fit.current=()=>f.fit(),()=>{f.destroy(),n.current=null,t.fit.current=null}},[t.renderer,l]),me(()=>{n.current?.setGraph(c.graph)},[c.key]),me(()=>{let f=Od(c.graph,n.current?.positions());return r.current=f,f!==null&&o(),()=>{r.current=null}},[c.key,o]),me(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),me(()=>{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"}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Pd,onClick:()=>n.current?.fit(),children:Nd}),x("button",{type:"button",class:"weave-chip",title:Cd(h),onClick:()=>s(Ld(u,c.clusters)),children:Rd(h)}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",aa.selected]}),x("span",{class:"weave-legend-near",children:["● ",aa.neighborhood]})]})]}),x("p",{class:"weave-graph-count",children:Dd(c.visible,c.total)})]})}function zd(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 rw(t){if(Array.isArray(t))return t}function iw(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 ow(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
335
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aw(t,e){return rw(t)||iw(t,e)||sw(t,e)||ow()}function sw(t,e){if(t){if(typeof t=="string")return zd(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)?zd(t,e):void 0}}var eh=Object.entries,$d=Object.setPrototypeOf,lw=Object.isFrozen,uw=Object.getPrototypeOf,cw=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,hn=Object.create,th=typeof Reflect<"u"&&Reflect,pa=th.apply,ga=th.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});pa||(pa=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)});ga||(ga=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 Mt=ae(Array.prototype.forEach),dw=ae(Array.prototype.lastIndexOf),Ud=ae(Array.prototype.pop),Bn=ae(Array.prototype.push),hw=ae(Array.prototype.splice),fn=Array.isArray,Vn=ae(String.prototype.toLowerCase),la=ae(String.prototype.toString),Hd=ae(String.prototype.match),Wn=ae(String.prototype.replace),Bd=ae(String.prototype.indexOf),fw=ae(String.prototype.trim),pw=ae(Number.prototype.toString),gw=ae(Boolean.prototype.toString),Wd=typeof BigInt>"u"?null:ae(BigInt.prototype.toString),Kd=typeof Symbol>"u"?null:ae(Symbol.prototype.toString),Re=ae(Object.prototype.hasOwnProperty),Kn=ae(Object.prototype.toString),we=ae(RegExp.prototype.test),It=mw(TypeError);function ae(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 pa(t,e,r)}}function mw(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return ga(t,n)}}function B(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vn;if($d&&$d(t,null),!fn(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(lw(e)||(e[r]=o),i=o)}t[i]=!0}return t}function vw(t){for(let e=0;e<t.length;e++)Re(t,e)||(t[e]=null);return t}function Pe(t){let e=hn(null);for(let r of eh(t)){var n=aw(r,2);let i=n[0],o=n[1];Re(t,i)&&(fn(o)?e[i]=vw(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Pe(o):e[i]=o)}return e}function yw(t){switch(typeof t){case"string":return t;case"number":return pw(t);case"boolean":return gw(t);case"bigint":return Wd?Wd(t):"0";case"symbol":return Kd?Kd(t):"Symbol()";case"undefined":return Kn(t);case"function":case"object":{if(t===null)return Kn(t);let e=t,n=qe(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Kn(r)}return Kn(t)}default:return Kn(t)}}function qe(t,e){for(;t!==null;){let r=cw(t,e);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}t=uw(t)}function n(){return null}return n}function ww(t){try{return we(t,""),!0}catch{return!1}}var Vd=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"]),ua=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"]),ca=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"]),bw=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"]),da=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"]),xw=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),jd=de(["#text"]),qd=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"]),ha=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"]),Yd=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"]),fi=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_w=pe(/{{[\w\W]*|^[\w\W]*}}/g),Ew=pe(/<%[\w\W]*|^[\w\W]*%>/g),kw=pe(/\${[\w\W]*/g),Sw=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Tw=pe(/^aria-[\-\w]+$/),Xd=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Aw=pe(/^(?:\w+script|data):/i),Rw=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cw=pe(/^html$/i),Lw=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),Zd=pe(/<[/\w!]/g),Qd=pe(/<[/\w]/g),Nw=pe(/<\/no(script|embed|frames)/i),Pw=pe(/\/>/i),Ne={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Dw=de(B({},nh)),Gw=(function(){let t={};return Mt(nh,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),Iw=function(){return typeof window>"u"?null:window},Mw=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}},Jd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wt=function(e,n,r,i){return Re(e,n)&&fn(e[n])?B(i.base?Pe(i.base):{},e[n],i.transform):r},fa=function(e,n,r){let i=Re(e,n)?e[n]:void 0;return i&&typeof i=="object"?Pe(i):r()};function rh(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Iw(),e=T=>rh(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ne.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=qe(d,"cloneNode"),g=qe(d,"remove"),v=qe(d,"nextSibling"),m=qe(d,"childNodes"),b=qe(d,"parentNode"),w=qe(d,"shadowRoot"),E=qe(d,"attributes"),_=a&&a.prototype?qe(a.prototype,"nodeType"):null,L=a&&a.prototype?qe(a.prototype,"nodeName"):null,D=a&&a.prototype?qe(a.prototype,"ownerDocument"):null,G=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,I="",U,j=!1,J=0,ge=function(){if(J>0)throw It('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(),J++;try{return F.createHTML(p)}finally{J--}},Qe=function(p){ge(),J++;try{return F.createScriptURL(p)}finally{J--}},$t=function(){return j||(U=Mw(h,i),j=!0),U},ze=n,$e=ze.implementation,Ue=ze.createNodeIterator,Je=ze.createDocumentFragment,mn=ze.getElementsByTagName,De=r.importNode,q=Jd();e.isSupported=typeof eh=="function"&&typeof b=="function"&&$e&&$e.createHTMLDocument!==void 0;let vn=_w,Tf=Ew,Af=kw,Rf=Sw,Cf=Tw,Lf=Aw,$a=Rw,Nf=Lw,Ua=Xd,X=null,Ei=B({},[...Vd,...ua,...ca,...da,...jd]),Z=null,ki=B({},[...qd,...ha,...Yd,...fi]),et=Object.seal(hn(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}})),yn=null,Ha=null,ft=Object.seal(hn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ba=!0,Si=!0,Wa=!1,Ka=!0,pt=!1,xt=!0,_t=!1,Ti=!1,Jn=null,er=null,Ai=!1,Ut=!1,tr=!1,nr=!1,Va=!0,ja=!1,qa="user-content-",Ri=!0,Ci=!1,Ht={},Bt=null,Ya=B({},["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"]),Xa=null,Za=B({},["audio","video","img","source","image","track"]),Qa=null,Ja=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rr="http://www.w3.org/1998/Math/MathML",ir="http://www.w3.org/2000/svg",tt="http://www.w3.org/1999/xhtml",Wt=tt,Li=!1,Ni=null,Pf=B({},[rr,ir,tt],la),es=de(["mi","mo","mn","ms","mtext"]),Pi=B({},es),ts=de(["annotation-xml"]),Di=B({},ts),Df=B({},["title","style","font","a","script"]),wn=null,Gf=["application/xhtml+xml","text/html"],If="text/html",ne=null,Kt=null,Mf=n.createElement("form"),ns=function(p){return p instanceof RegExp||p instanceof Function},Gi=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Kt&&Kt===p)return;(!p||typeof p!="object")&&(p={}),p=Pe(p),wn=Gf.indexOf(p.PARSER_MEDIA_TYPE)===-1?If:p.PARSER_MEDIA_TYPE,ne=wn==="application/xhtml+xml"?la:Vn,X=wt(p,"ALLOWED_TAGS",Ei,{transform:ne}),Z=wt(p,"ALLOWED_ATTR",ki,{transform:ne}),Ni=wt(p,"ALLOWED_NAMESPACES",Pf,{transform:la}),Qa=wt(p,"ADD_URI_SAFE_ATTR",Ja,{transform:ne,base:Ja}),Xa=wt(p,"ADD_DATA_URI_TAGS",Za,{transform:ne,base:Za}),Bt=wt(p,"FORBID_CONTENTS",Ya,{transform:ne}),yn=wt(p,"FORBID_TAGS",Pe({}),{transform:ne}),Ha=wt(p,"FORBID_ATTR",Pe({}),{transform:ne}),Ht=Re(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Pe(p.USE_PROFILES):p.USE_PROFILES:!1,Ba=p.ALLOW_ARIA_ATTR!==!1,Si=p.ALLOW_DATA_ATTR!==!1,Wa=p.ALLOW_UNKNOWN_PROTOCOLS||!1,Ka=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,pt=p.SAFE_FOR_TEMPLATES||!1,xt=p.SAFE_FOR_XML!==!1,_t=p.WHOLE_DOCUMENT||!1,Ut=p.RETURN_DOM||!1,tr=p.RETURN_DOM_FRAGMENT||!1,nr=p.RETURN_TRUSTED_TYPE||!1,Ai=p.FORCE_BODY||!1,Va=p.SANITIZE_DOM!==!1,ja=p.SANITIZE_NAMED_PROPS||!1,Ri=p.KEEP_CONTENT!==!1,Ci=p.IN_PLACE||!1,Ua=ww(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:Xd,Wt=typeof p.NAMESPACE=="string"?p.NAMESPACE:tt,Pi=fa(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>B({},es)),Di=fa(p,"HTML_INTEGRATION_POINTS",()=>B({},ts));let y=fa(p,"CUSTOM_ELEMENT_HANDLING",()=>hn(null));if(et=hn(null),Re(y,"tagNameCheck")&&ns(y.tagNameCheck)&&(et.tagNameCheck=y.tagNameCheck),Re(y,"attributeNameCheck")&&ns(y.attributeNameCheck)&&(et.attributeNameCheck=y.attributeNameCheck),Re(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),pe(et),pt&&(Si=!1),tr&&(Ut=!0),Ht&&(X=B({},jd),Z=hn(null),Ht.html===!0&&(B(X,Vd),B(Z,qd)),Ht.svg===!0&&(B(X,ua),B(Z,ha),B(Z,fi)),Ht.svgFilters===!0&&(B(X,ca),B(Z,ha),B(Z,fi)),Ht.mathMl===!0&&(B(X,da),B(Z,Yd),B(Z,fi))),ft.tagCheck=null,ft.attributeCheck=null,Re(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?ft.tagCheck=p.ADD_TAGS:fn(p.ADD_TAGS)&&(X===Ei&&(X=Pe(X)),B(X,p.ADD_TAGS,ne))),Re(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?ft.attributeCheck=p.ADD_ATTR:fn(p.ADD_ATTR)&&(Z===ki&&(Z=Pe(Z)),B(Z,p.ADD_ATTR,ne))),Re(p,"ADD_FORBID_CONTENTS")&&fn(p.ADD_FORBID_CONTENTS)&&(Bt===Ya&&(Bt=Pe(Bt)),B(Bt,p.ADD_FORBID_CONTENTS,ne)),Ri&&(X["#text"]=!0),_t&&B(X,["html","head","body"]),X.table&&(B(X,["tbody"]),delete yn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let k=F;F=p.TRUSTED_TYPES_POLICY;try{I=he("")}catch(R){throw F=k,R}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,I=""):(F===void 0&&(F=$t()),F&&typeof I=="string"&&(I=he("")));de&&de(p),Kt=p},rs=B({},[...ua,...ca,...bw]),is=B({},[...da,...xw]),Of=function(p,y,k){return y.namespaceURI===tt?p==="svg":y.namespaceURI===rr?p==="svg"&&(k==="annotation-xml"||Pi[k]):!!rs[p]},Ff=function(p,y,k){return y.namespaceURI===tt?p==="math":y.namespaceURI===ir?p==="math"&&Di[k]:!!is[p]},zf=function(p,y,k){return y.namespaceURI===ir&&!Di[k]||y.namespaceURI===rr&&!Pi[k]?!1:!is[p]&&(Df[p]||!rs[p])},$f=function(p){let y=b(p);(!y||!y.tagName)&&(y={namespaceURI:Wt,tagName:"template"});let k=Vn(p.tagName),R=Vn(y.tagName);return Ni[p.namespaceURI]?p.namespaceURI===ir?Of(k,y,R):p.namespaceURI===rr?Ff(k,y,R):p.namespaceURI===tt?zf(k,y,R):!!(wn==="application/xhtml+xml"&&Ni[p.namespaceURI]):!1},gt=function(p){Bn(e.removed,{element:p});try{b(p).removeChild(p)}catch{if(g(p),!b(p))throw It("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},os=function(p,y,k){try{p.removeAttributeNode(y)}catch{try{p.removeAttribute(k)}catch{}}},or=function(p){ar(p);let y=m(p);if(y){let R=[];Mt(y,P=>{Bn(R,P)}),Mt(R,P=>{try{g(P)}catch{}})}let k=E(p);if(k)for(let R=k.length-1;R>=0;--R){let P=k[R],O=P&&P.name;typeof O=="string"&&os(p,P,O)}},Et=function(p,y,k){if(!k)try{k=y.getAttributeNode(p)}catch{k=null}Bn(e.removed,{attribute:k||null,from:y});try{k?y.removeAttributeNode(k):y.removeAttribute(p)}catch{try{y.removeAttribute(p)}catch{}}if(p==="is")if(Ut||tr)try{gt(y)}catch{}else try{y.setAttribute(p,"")}catch{}},Uf=function(p){let y=E(p);if(y)for(let k=y.length-1;k>=0;--k){let R=y[k],P=R&&R.name;typeof P!="string"||Z[ne(P)]||os(p,R,P)}},ar=function(p){let y=[p];for(;y.length>0;){let k=y.pop();G(k)===Ne.element&&Uf(k);let P=m(k);if(P)for(let O=P.length-1;O>=0;--O)y.push(P[O])}},as=function(p,y){return xt?p==="patchsrc"?!0:p==="for"&&y!=="label"&&y!=="output":!1},Hf=function(p){if(!xt)return;let y=[p];for(;y.length>0;){let k=y.pop(),R=G(k);if(R===Ne.processingInstruction||R===Ne.comment&&we(Qd,k.data)){try{g(k)}catch{}continue}if(R===Ne.element){let O=k,Y=ne(z(k));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&as("for",Y)&&O.removeAttribute("for")}catch{}}let P=m(k);if(P)for(let O=P.length-1;O>=0;--O)y.push(P[O])}},ss=function(p){let y=null,k=null;if(Ai)p="<remove></remove>"+p;else{let O=Hd(p,/^[\r\n\t ]+/);k=O&&O[0]}wn==="application/xhtml+xml"&&Wt===tt&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let R=F?he(p):p;if(Wt===tt)try{y=new c().parseFromString(R,wn)}catch{}if(!y||!y.documentElement){y=$e.createDocument(Wt,"template",null);try{y.documentElement.innerHTML=Li?I:R}catch{}}let P=y.body||y.documentElement;return p&&k&&P.insertBefore(n.createTextNode(k),P.childNodes[0]||null),Wt===tt?mn.call(y,_t?"html":"body")[0]:_t?y.documentElement:P},ls=function(p){let y=D?D(p):p.ownerDocument;return Ue.call(y||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},sr=function(p){return p=Wn(p,vn," "),p=Wn(p,Tf," "),p=Wn(p,Af," "),p},Ii=function(p){var y;p.normalize();let k=D?D(p):p.ownerDocument,R=Ue.call(k||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),P=R.nextNode();for(;P;)P.data=sr(P.data),P=R.nextNode();let O=(y=p.querySelectorAll)===null||y===void 0?void 0:y.call(p,"template");O&&Mt(O,Y=>{Vt(Y.content)&&Ii(Y.content)})},lr=function(p){let y=L?L(p):null;return typeof y!="string"||ne(y)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==E(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!==m(p)},Vt=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return _(p)===Ne.documentFragment}catch{return!1}},bn=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return typeof _(p)=="number"}catch{return!1}};function nt(T,p,y){T.length!==0&&Mt(T,k=>{k.call(e,p,y,Kt)})}let Bf=function(p,y){return!!(xt&&p.hasChildNodes()&&!bn(p.firstElementChild)&&we(Zd,p.textContent)&&we(Zd,p.innerHTML)||xt&&p.namespaceURI===tt&&Dw[y]&&(bn(p.firstElementChild)||typeof p.textContent=="string"&&we(Gw[y],p.textContent))||p.nodeType===Ne.processingInstruction||xt&&p.nodeType===Ne.comment&&we(Qd,p.data))},ur=function(p,y){if(p instanceof RegExp)return we(p,y);if(p instanceof Function){for(var k=arguments.length,R=new Array(k>2?k-2:0),P=2;P<k;P++)R[P-2]=arguments[P];return!!p(y,...R)}return!1},Wf=function(p,y,k){if(!yn[y]&&fs(y)&&ur(et.tagNameCheck,y))return!1;if(Ri&&!Bt[y]){let R=b(p),P=m(p);if(P&&R){let O=P.length;for(let Y=O-1;Y>=0;--Y){let ee=p===k?f(P[Y],!0):P[Y];R.insertBefore(ee,v(p))}}}return gt(p),!0},us=function(p,y,k,R){return p.length===0?y:y===k||y===R?Pe(y):y},cs=function(p,y){return p===y||b(p)!==null?!1:(Ci&&ar(p),!0)},ds=function(p,y){if(nt(q.beforeSanitizeElements,p,null),cs(p,y))return!0;if(lr(p))return gt(p),!0;let k=ne(z(p));if(X=us(q.uponSanitizeElement,X,Ei,Jn),nt(q.uponSanitizeElement,p,{tagName:k,allowedTags:X}),cs(p,y))return!0;if(Bf(p,k))return gt(p),!0;if(yn[k]||!(ft.tagCheck instanceof Function&&ft.tagCheck(k))&&!X[k]){let P=Wf(p,k,y);return P===!1&&nt(q.afterSanitizeElements,p,null),P}if(G(p)===Ne.element&&!$f(p)||(k==="noscript"||k==="noembed"||k==="noframes")&&we(Nw,p.innerHTML))return gt(p),!0;if(pt&&p.nodeType===Ne.text){let P=sr(p.textContent);p.textContent!==P&&(Bn(e.removed,{element:p.cloneNode()}),p.textContent=P)}return nt(q.afterSanitizeElements,p,null),!1},hs=function(p,y,k){if(Ha[y]||as(y,p)||Va&&(y==="id"||y==="name")&&(k in n||k in Mf))return!1;let R=Z[y]||ft.attributeCheck instanceof Function&&ft.attributeCheck(y,p);return Si&&we(Rf,y)||Ba&&we(Cf,y)?!0:R?Qa[y]||we(Ua,Wn(k,$a,""))||(y==="src"||y==="xlink:href"||y==="href")&&p!=="script"&&Bd(k,"data:")===0&&Xa[p]||Wa&&!we(Lf,Wn(k,$a,""))?!0:!k:fs(p)&&ur(et.tagNameCheck,p)&&ur(et.attributeNameCheck,y,p)||y==="is"&&et.allowCustomizedBuiltInElements&&ur(et.tagNameCheck,k)},Kf=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),fs=function(p){return!Kf[Vn(p)]&&we(Nf,p)},Vf=function(p,y,k,R){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!k)switch(h.getAttributeType(p,y)){case"TrustedHTML":return he(R);case"TrustedScriptURL":return Qe(R)}return R},jf=function(p,y,k,R){try{k?p.setAttributeNS(k,y,R):p.setAttribute(y,R),lr(p)?gt(p):Ud(e.removed)}catch{Et(y,p)}},ps=function(p){nt(q.beforeSanitizeAttributes,p,null);let y=p.attributes;if(!y||lr(p))return;Z=us(q.uponSanitizeAttribute,Z,ki,er);let k={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0},R=y.length,P=ne(p.nodeName);for(;R--;){let O=y[R],Y=O.name,ee=O.namespaceURI,Te=O.value,Ae=ne(Y),Oi=Te,xe=Y==="value"?Oi:fw(Oi);if(k.attrName=Ae,k.attrValue=xe,k.keepAttr=!0,k.forceKeepAttr=void 0,nt(q.uponSanitizeAttribute,p,k),xe=k.attrValue,ja&&(Ae==="id"||Ae==="name")&&Bd(xe,qa)!==0&&(Et(Y,p,O),xe=qa+xe),xt&&we(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,xe)){Et(Y,p,O);continue}if(Ae==="attributename"&&Hd(xe,"href")){Et(Y,p,O);continue}if(!k.forceKeepAttr){if(!k.keepAttr){Et(Y,p,O);continue}if(!Ka&&we(Pw,xe)){Et(Y,p,O);continue}if(pt&&(xe=sr(xe)),!hs(P,Ae,xe)){Et(Y,p,O);continue}xe=Vf(P,Ae,ee,xe),xe!==Oi&&jf(p,Y,ee,xe)}}nt(q.afterSanitizeAttributes,p,null)},cr=function(p){let y=null,k=ls(p);for(nt(q.beforeSanitizeShadowDOM,p,null);y=k.nextNode();)if(nt(q.uponSanitizeShadowNode,y,null),ds(y,p),ps(y),Vt(y.content)&&cr(y.content),G(y)===Ne.element){let R=w(y);Vt(R)&&(Mi(R),cr(R))}nt(q.afterSanitizeShadowDOM,p,null)},Mi=function(p){let y=[{node:p,shadow:null}];for(;y.length>0;){let k=y.pop();if(k.shadow){cr(k.shadow);continue}let R=k.node,O=G(R)===Ne.element,Y=m(R);if(Y)for(let ee=Y.length-1;ee>=0;--ee)y.push({node:Y[ee],shadow:null});if(O){let ee=L?L(R):null;if(typeof ee=="string"&&ne(ee)==="template"){let Te=R.content;Vt(Te)&&y.push({node:Te,shadow:null})}}if(O){let ee=w(R);Vt(ee)&&y.push({node:null,shadow:ee},{node:ee,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,k=null,R=null,P=null;if(Li=!T,Li&&(T="<!-->"),typeof T!="string"&&!bn(T)&&(T=yw(T),typeof T!="string"))throw It("dirty is not a string, aborting");if(!e.isSupported)return T;Ti?(X=Jn,Z=er):Gi(p),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(X=Pe(X)),q.uponSanitizeAttribute.length>0&&(Z=Pe(Z)),e.removed=[];let O=Ci&&typeof T!="string"&&bn(T);if(O){Hf(T);let Te=z(T);if(typeof Te=="string"){let Ae=ne(Te);if(!X[Ae]||yn[Ae])throw or(T),It("root node is forbidden and cannot be sanitized in-place")}if(lr(T))throw or(T),It("root node is clobbered and cannot be sanitized in-place");try{Mi(T)}catch(Ae){throw or(T),Ae}}else if(bn(T))y=ss("<!---->"),k=y.ownerDocument.importNode(T,!0),k.nodeType===Ne.element&&k.nodeName==="BODY"||k.nodeName==="HTML"?y=k:y.appendChild(k),Mi(k);else{if(!Ut&&!pt&&!_t&&T.indexOf("<")===-1)return F&&nr?he(T):T;if(y=ss(T),!y)return Ut?null:nr?I:""}y&&Ai&>(y.firstChild);let Y=O?T:y;try{let Te=ls(Y);for(;R=Te.nextNode();)ds(R,Y),ps(R),Vt(R.content)&&cr(R.content)}catch(Te){throw O&&(or(T),Mt(e.removed,Ae=>{Ae.element&&ar(Ae.element)})),Te}if(O)return Mt(e.removed,Te=>{Te.element&&ar(Te.element)}),pt&&Ii(T),T;if(Ut){if(pt&&Ii(y),tr)for(P=Je.call(y.ownerDocument);y.firstChild;)P.appendChild(y.firstChild);else P=y;return(Z.shadowroot||Z.shadowrootmode)&&(P=De.call(r,P,!0)),P}let ee=_t?y.outerHTML:y.innerHTML;return _t&&X["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&we(Cw,y.ownerDocument.doctype.name)&&(ee="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
|
|
336
|
+
`+ee),pt&&(ee=sr(ee)),F&&nr?he(ee):ee},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Gi(T),Ti=!0,Jn=X,er=Z},e.clearConfig=function(){Kt=null,Ti=!1,Jn=null,er=null,F=U,I=""},e.isValidAttribute=function(T,p,y){Kt||Gi({});let k=ne(T),R=ne(p);return hs(k,R,y)},e.addHook=function(T,p){typeof p=="function"&&Re(q,T)&&Bn(q[T],p)},e.removeHook=function(T,p){if(Re(q,T)){if(p!==void 0){let y=dw(q[T],p);return y===-1?void 0:hw(q[T],y,1)[0]}return Ud(q[T])}},e.removeHooks=function(T){Re(q,T)&&(q[T]=[])},e.removeAllHooks=function(){q=Jd()},e}var ih=rh();function Ow({prompt:t,send:e}){return x("div",{class:`weave-note-prompt weave-note-prompt-${t.kind}`,role:"alert",children:[x("p",{class:"weave-note-prompt-text",children:t.message}),x("p",{class:"weave-note-prompt-actions",children:t.actions.map(n=>x("button",{type:"button",class:"weave-note-action",onClick:()=>e(n.event),children:n.label},n.label))})]})}function oh(t){let{toolbar:e,send:n}=t;return x("div",{class:"weave-note-bar",children:[x("button",{type:"button",class:"weave-note-toggle","aria-pressed":e.editing,onClick:()=>n({type:"toggle"}),children:e.toggleLabel}),e.editing?x("button",{type:"button",class:"weave-note-save",disabled:!e.canSave,onClick:()=>n({type:"save"}),children:e.saveLabel}):null,x("button",{type:"button",class:"weave-note-open",title:Yc,onClick:()=>n({type:"open"}),children:qc}),e.dirty?x("span",{class:"weave-note-dirty",title:"unsaved changes","aria-hidden":"true",children:"•"}):null,e.message===null?null:x("span",{class:`weave-note-status weave-note-status-${e.tone}`,children:e.message}),t.prompt===null?null:x(Ow,{prompt:t.prompt,send:n})]})}function ah(t){return x("textarea",{class:"weave-note-editor","aria-label":"Note body",spellcheck:!0,value:t.draft,onInput:e=>t.send({type:"draft",text:e.target.value}),onKeyDown:e=>{e.key.toLowerCase()!=="s"||!(e.metaKey||e.ctrlKey)||(e.preventDefault(),t.send({type:"save"}))}})}function wa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var zt=wa();function ph(t){zt=t}var Ot={exec:()=>null};function pn(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(be.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var Fw=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),be={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:pn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:pn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:pn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:pn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:pn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:pn(t=>new RegExp(`^ {0,${t}}>`))},zw=/^(?:[ \t]*(?:\n|$))+/,$w=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Uw=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Hw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ba=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,gh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,mh=$(gh).replace(/bull/g,ba).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(),Bw=$(gh).replace(/bull/g,ba).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(),xa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ww=/^[^\n]+/,_a=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Kw=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_a).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vw=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ba).getRegex(),yi="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",Ea=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,jw=$("^ {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",Ea).replace("tag",yi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vh=t=>$(xa).replace("hr",Yn).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",yi).getRegex(),qw=vh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Yw=vh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Xw=$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Yw).getRegex(),ka={blockquote:Xw,code:$w,def:Kw,fences:Uw,heading:Hw,hr:Yn,html:jw,lheading:mh,list:Vw,newline:zw,paragraph:qw,table:Ot,text:Ww},sh=$("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yn).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",yi).getRegex(),Zw={...ka,lheading:Bw,table:sh,paragraph:$(xa).replace("hr",Yn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",sh).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",yi).getRegex()},Qw={...ka,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ea).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:Ot,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(xa).replace("hr",Yn).replace("heading",` *#{1,6} *[^
|
|
337
|
+
]`).replace("lheading",mh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Jw=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,eb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,yh=/^( {2,}|\\)\n(?!\s*$)/,tb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ht=/[\p{P}\p{S}]/u,gn=/[\s\p{P}\p{S}]/u,Xn=/[^\s\p{P}\p{S}]/u,nb=$(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,gn).getRegex(),rb=/[\p{Pi}\p{Ps}"']/u,wh=/(?!~)[\p{P}\p{S}]/u,ib=/(?!~)[\s\p{P}\p{S}]/u,ob=/(?:[^\s\p{P}\p{S}]|~)/u,ab=$(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Fw?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),bh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,sb=$(bh,"u").replace(/punct/g,ht).getRegex(),lb=$(bh,"u").replace(/punct/g,wh).getRegex(),ub=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,cb=$(ub,"u").replace(/openQuote/g,rb).replace(/punct/g,ht).getRegex(),xh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",db=$(xh,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,gn).replace(/punct/g,ht).getRegex(),hb=$(xh,"gu").replace(/notPunctSpace/g,ob).replace(/punctSpace/g,ib).replace(/punct/g,wh).getRegex(),fb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",pb=$(fb,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,gn).replace(/punct/g,ht).getRegex(),gb=$("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,gn).replace(/punct/g,ht).getRegex(),mb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",vb=$(mb,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,gn).replace(/punct/g,ht).getRegex(),yb=$(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ht).getRegex(),wb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",bb=$(wb,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,gn).replace(/punct/g,ht).getRegex(),xb=$(/\\(punct)/,"gu").replace(/punct/g,ht).getRegex(),_b=$(/^<(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(),Eb=$(Ea).replace("(?:-->|$)","-->").getRegex(),kb=$("^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",Eb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),gi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Sb=$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",gi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_h=$(/^!?\[(label)\]\[(ref)\]/).replace("label",gi).replace("ref",_a).getRegex(),Eh=$(/^!?\[(ref)\](?:\[\])?/).replace("ref",_a).getRegex(),Tb=$("reflink|nolink(?!\\()","g").replace("reflink",_h).replace("nolink",Eh).getRegex(),lh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Sa={_backpedal:Ot,anyPunctuation:xb,autolink:_b,blockSkip:ab,br:yh,code:eb,del:Ot,delLDelim:Ot,delRDelim:Ot,emStrongLDelim:sb,emStrongRDelimAst:db,emStrongRDelimUnd:gb,escape:Jw,link:Sb,nolink:Eh,punctuation:nb,reflink:_h,reflinkSearch:Tb,tag:kb,text:tb,url:Ot},Ab={...Sa,emStrongLDelim:cb,emStrongRDelimAst:pb,emStrongRDelimUnd:vb,link:$(/^!?\[(label)\]\((.*?)\)/).replace("label",gi).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",gi).getRegex()},ma={...Sa,emStrongRDelimAst:hb,emStrongLDelim:lb,delLDelim:yb,delRDelim:bb,url:$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",lh).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",lh).getRegex()},Rb={...ma,br:$(yh).replace("{2,}","*").getRegex(),text:$(ma.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pi={normal:ka,gfm:Zw,pedantic:Qw},jn={normal:Sa,gfm:ma,breaks:Rb,pedantic:Ab},Cb={"&":"&","<":"<",">":">",'"':""","'":"'"},uh=t=>Cb[t];function it(t,e){if(e){if(be.escapeTest.test(t))return t.replace(be.escapeReplace,uh)}else if(be.escapeTestNoEncode.test(t))return t.replace(be.escapeReplaceNoEncode,uh);return t}function ch(t){try{t=encodeURI(t).replace(be.percentDecode,"%")}catch{return null}return t}function dh(t,e){let n=t.replace(be.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(be.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(be.slashPipe,"|");return r}function bt(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 hh(t){let e=t.split(`
|
|
338
|
+
`),n=e.length-1;for(;n>=0&&be.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
339
|
+
`)}function Lb(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 Nb(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 fh(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 Pb(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
340
340
|
`).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(`
|
|
341
|
-
`)}var
|
|
341
|
+
`)}var mi=class{options;rules;lexer;constructor(t){this.options=t||zt}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]:hh(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=Pb(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=bt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:bt(e[0],`
|
|
342
342
|
`),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:bt(e[0],`
|
|
343
343
|
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=bt(e[0],`
|
|
344
344
|
`).split(`
|
|
@@ -347,25 +347,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
347
347
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
348
348
|
${u}`:u,i=i?`${i}
|
|
349
349
|
${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,g=n.join(`
|
|
350
|
-
`),
|
|
351
|
-
`+g.replace(this.rules.other.blockquoteSetextReplace2,""),
|
|
352
|
-
${g}`,i=i.substring(0,i.length-f.text.length)+
|
|
350
|
+
`),v=f.raw+`
|
|
351
|
+
`+g.replace(this.rules.other.blockquoteSetextReplace2,""),m=this.blockquote(v);o[o.length-1]=m,r=`${r}
|
|
352
|
+
${g}`,i=i.substring(0,i.length-f.text.length)+m.text;break}else if(d?.type==="list"){let f=d,g=f.raw+`
|
|
353
353
|
`+n.join(`
|
|
354
|
-
`),
|
|
355
|
-
`);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=
|
|
354
|
+
`),v=this.list(g);o[o.length-1]=v,r=r.substring(0,r.length-d.raw.length)+v.raw,i=i.substring(0,i.length-f.raw.length)+v.raw,n=g.substring(o.at(-1).raw.length).split(`
|
|
355
|
+
`);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=Nb(e[2].split(`
|
|
356
356
|
`,1)[0],e[1].length),d=t.split(`
|
|
357
357
|
`,1)[0],f=!h.trim(),g=0;if(this.options.pedantic?(g=2,c=h.trimStart()):f?g=e[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,c=h.slice(g),g+=e[1].length),f&&this.rules.other.blankLine.test(d)&&(u+=d+`
|
|
358
|
-
`,t=t.substring(d.length+1),l=!0),!l){let
|
|
359
|
-
`,1)[0],
|
|
360
|
-
`+
|
|
358
|
+
`,t=t.substring(d.length+1),l=!0),!l){let v=this.rules.other.nextBulletRegex(g),m=this.rules.other.hrRegex(g),b=this.rules.other.fencesBeginRegex(g),w=this.rules.other.headingBeginRegex(g),E=this.rules.other.htmlBeginRegex(g),_=this.rules.other.blockquoteBeginRegex(g);for(;t;){let L=t.split(`
|
|
359
|
+
`,1)[0],D;if(d=L,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),D=d):D=d.replace(this.rules.other.tabCharGlobal," "),b.test(d)||w.test(d)||E.test(d)||_.test(d)||v.test(d)||m.test(d))break;if(D.search(this.rules.other.nonSpaceChar)>=g||!d.trim())c+=`
|
|
360
|
+
`+D.slice(g);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||b.test(h)||w.test(h)||m.test(h))break;c+=`
|
|
361
361
|
`+d}f=!d.trim(),u+=L+`
|
|
362
|
-
`,t=t.substring(L.length+1),h=
|
|
363
|
-
`),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
|
+
`,t=t.substring(L.length+1),h=D.slice(g)}}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=hh(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:bt(e[0],`
|
|
363
|
+
`),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=dh(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
364
364
|
`):[],o={type:"table",raw:bt(e[0],`
|
|
365
|
-
`),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(
|
|
365
|
+
`),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(dh(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:bt(e[0],`
|
|
366
366
|
`),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)===`
|
|
367
|
-
`?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=bt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=
|
|
368
|
-
`),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(
|
|
367
|
+
`?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=bt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Lb(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)),fh(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 fh(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 v=f.slice(1,-1);return{type:"em",raw:f,text:v,tokens:this.lexer.inlineTokens(v)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}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}}}},Ye=class va{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||zt,this.options.tokenizer=this.options.tokenizer||new mi,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:be,block:pi.normal,inline:jn.normal};this.options.pedantic?(n.block=pi.pedantic,n.inline=jn.pedantic):this.options.gfm&&(n.block=pi.gfm,this.options.breaks?n.inline=jn.breaks:n.inline=jn.gfm),this.tokenizer.rules=n}static get rules(){return{block:pi,inline:jn}}static lex(e,n){return new va(n).lex(e)}static lexInline(e,n){return new va(n).inlineTokens(e)}lex(e){e=e.replace(be.carriageReturn,`
|
|
368
|
+
`),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(be.tabCharGlobal," ").replace(be.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+=`
|
|
369
369
|
`: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(`
|
|
370
370
|
`)?"":`
|
|
371
371
|
`)+o.raw,s.text+=`
|
|
@@ -378,9 +378,9 @@ ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="li
|
|
|
378
378
|
`+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(`
|
|
379
379
|
`)?"":`
|
|
380
380
|
`)+o.raw,s.text+=`
|
|
381
|
-
`+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)}},
|
|
382
|
-
`;return r?'<pre><code class="language-'+
|
|
383
|
-
`:"<pre><code>"+(n?i:
|
|
381
|
+
`+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)}},vi=class{options;parser;constructor(t){this.options=t||zt}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(be.notSpaceStart)?.[0],i=t.replace(be.endingNewline,"")+`
|
|
382
|
+
`;return r?'<pre><code class="language-'+it(r)+'">'+(n?i:it(i,!0))+`</code></pre>
|
|
383
|
+
`:"<pre><code>"+(n?i:it(i,!0))+`</code></pre>
|
|
384
384
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
385
385
|
${this.parser.parse(t)}</blockquote>
|
|
386
386
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
@@ -396,12 +396,13 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
396
396
|
`}tablerow({text:t}){return`<tr>
|
|
397
397
|
${t}</tr>
|
|
398
398
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
399
|
-
`}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>${
|
|
400
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+nt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ot=new Na;function V(t,e){return Ot.parse(t,e)}V.options=V.setOptions=function(t){return Ot.setOptions(t),V.defaults=Ot.defaults,yh(V.defaults),V};V.getDefaults=Ea;V.defaults=Ft;function $b(...t){return Ot.use(...t),V.defaults=Ot.defaults,yh(V.defaults),V}V.use=$b;V.walkTokens=function(t,e){return Ot.walkTokens(t,e)};V.parseInline=Ot.parseInline;V.Parser=je;V.parser=je.parse;V.Renderer=bi;V.TextRenderer=La;V.Lexer=Ve;V.lexer=Ve.lex;V.Tokenizer=wi;V.Hooks=qn;V.parse=V;var TS=V.options,RS=V.setOptions,AS=V.walkTokens,CS=V.parseInline;var LS=je.parse,NS=Ve.lex;var Ch={"&":"&","<":"<",">":">",'"':""","'":"'"},zb=new RegExp(`[${Object.keys(Ch).join("")}]`,"g");function qe(t){return t.replace(zb,e=>Ch[e])}var Ub=["http:","https:","mailto:"],Hb=/^[a-z][a-z0-9+.-]*:/i,Bb=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Ah(t){let e=t.replace(Bb,""),n=Hb.exec(e);return n===null?e===""?null:t:Ub.includes(n[0].toLowerCase())?t:null}var _i="data-weave-target",Ei="note:",Wb={bySpelling:new Map,hasGhosts:!1};function Kb(t){if(t.kind!=="note"||!t.id.startsWith(Ei))return null;let e=t.id.slice(Ei.length);return e===""?null:e}function Lh(t,e){if(t===null)return Wb;let n=new Map;for(let i of t.model.nodes){let o=Kb(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 Vb(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function jb(t){return t.hasGhosts}var qb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Yb(t){let e=t.indexOf("[[");return e===-1?void 0:e}function Xb(t){return{name:"wikilink",level:"inline",start:Yb,tokenizer(e){return Qb(e)},renderer(e){return Zb(t,e)}}}function Zb(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return Jb(t,n,r)}function Qb(t){let e=qb.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function Jb(t,e,n){let r=qe((n===""?e:n).trim());if(r==="")return"";let i=Vb(t,e);return i!==null?`<a class="weave-wiki" ${_i}="${qe(i)}" role="link" tabindex="0" title="${qe(e.trim())}">${r}</a>`:jb(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${qe(e.trim())}">${r}</span>`:r}function ex(t){return new Na({gfm:!0,async:!1,extensions:[Xb(t)],renderer:{html({text:e}){return qe(e)},link({href:e,title:n,tokens:r}){let i=Ah(e),o=this.parser.parseInline(r);return`<a${[i===null?"":` href="${qe(i)}"`,n==null||n===""?"":` title="${qe(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=Ah(e);if(i===null)return qe(r);let o=n==null||n===""?"":` title="${qe(n)}"`;return`<img src="${qe(i)}" alt="${qe(r)}"${o}>`}}})}function tx(t,e){return ex(e).parse(t,{async:!1})}function Zn(t){return Object.freeze(t)}var nx=Zn({ALLOWED_TAGS:Zn(["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:Zn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",_i]),ADD_URI_SAFE_ATTR:Zn([_i]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Zn({html:!0})});function Nh(t,e,n){return t.sanitize(tx(e,n),nx)}var rx=32;function Da(t){let e=t;for(let n=0;e!==null&&n<rx;n++){let r=e.getAttribute(_i);if(r!==null&&r!=="")return`${Ei}${r}`;e=e.parentElement}return null}function Dh(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Nt(t.source),provenanceTitle:Gn(t.source),updated:In(t.updated,e),updatedIso:t.updated,created:In(t.created,e),createdIso:t.created,tags:t.tags}}function Ph(t){return`#${t}`}function Ih(t,e){return e!==null?null:t===null?"Select a note to read it here.":t.startsWith(Ei)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function ix({view:t}){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("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:["updated ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:["created ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(e=>x("span",{class:"weave-tag",children:Ph(e)},e))})]})}function Gh(t){let e=t.note?.note??null,n=Ih(t.selectedId,e);if(e===null)return x("p",{class:"weave-note-empty",children:n});let r=Lh(t.graph,e.slug),i=t.toolbar,o={draft:t.draft,prompt:t.prompt,send:t.send};return x("article",{class:"weave-note",children:[x(ix,{view:Dh(e,t.now)}),i===null?null:x(uh,{toolbar:i,...o}),i!==null&&i.editing?x(ch,{toolbar:i,...o}):x("div",{class:"weave-note-body",onClick:a=>{let s=Da(a.target);s!==null&&t.onSelect(s)},onKeyDown:a=>{if(a.key!=="Enter"&&a.key!==" ")return;let s=Da(a.target);s!==null&&(a.preventDefault(),t.onSelect(s))},dangerouslySetInnerHTML:{__html:Nh(lh,e.body,r)}})]})}function ox({view:t,onSelect:e,onToggle:n}){return x("li",{id:t.domId,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}`,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:ju(t.depth),onClick:e,children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:r=>{r.stopPropagation(),n()},children:t.twistyGlyph}),x("span",{class:"weave-kind","aria-hidden":"true",children:t.kindGlyph}),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 Mh(t){let[e,n]=Ue(Ou),r=Fu(t.graph,e),i=tc(t.graph,r,e);return x("div",{class:"weave-tree",onKeyDown:o=>{let a=Bu(r,e,t.selectedId,o.key);a.handled&&(o.preventDefault(),n(a.state),a.selectedId!==null&&t.onSelect(a.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:Zu,"aria-label":Ju,title:ec,onInput:o=>n(zu(e,o.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:qu(e.provFilter),onClick:()=>n(Uu(e)),children:["◧ ",Vr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:Xu(e.showInternals),onClick:()=>n(Hu(e)),children:["◧ ",Yu(e.showInternals)]})]}),i===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Qu,"aria-activedescendant":Vu(r,t.selectedId)??void 0,children:Ku(r,t.selectedId,t.now).map(o=>x(ox,{view:o,onSelect:()=>t.onSelect(o.id),onToggle:()=>n($u(e,o.id))},o.id))}):x("p",{class:"weave-tree-empty",children:i}),x("p",{class:"weave-tree-count",children:nc(r)})]})}function Oh(t,e){if(t===null)return 0;for(let[n,r]of e)t.style.setProperty(n,r);return e.length}var Qn=["tree","note","graph"],Pa={tree:180,note:320,graph:260},$h={tree:.22,note:.46,graph:.32},ax=1100,sx=800;function zh(t){return!Number.isFinite(t)||t<sx?"narrow":t<ax?"medium":"wide"}function lx(t){return t==="wide"?Qn:t==="medium"?["tree","note"]:["note"]}function Uh(t,e){return Hh(Qn,t,e)}function Hh(t,e,n){let r={tree:0,note:0,graph:0};for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:$h[l]}let i=0;for(let l of t)i+=r[l];for(let l of t)r[l]=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 Ga(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:Pa.tree/e,note:Pa.note/e,graph:Pa.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 Bh(t,e,n=[]){return{fractions:Uh(t,Ga(e)),revealed:Qn.filter(r=>n.includes(r))}}function Fh(t){return Bh($h,t)}function Wh(t,e,n){let r=lx(n),i=Number.isFinite(e)&&e>0?e:0,o=Hh(r,t.fractions,Ga(i));return r.map(a=>({id:a,width:o[a]*i}))}var Kh=["tree","note"];function ux(t){return t==="tree"?["tree","note"]:["note","graph"]}function Ma(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]=ux(e),s=Ga(i),l=Math.max(0,t.fractions[o]-s[o]),u=Math.max(0,t.fractions[a]-s[a]),c=Math.max(-l,Math.min(u,n/i));if(c===0)return t;let h={...t.fractions,[o]:t.fractions[o]+c,[a]:t.fractions[a]-c};return{fractions:Uh(h,s),revealed:t.revealed}}var Vh="pi-weave.layout.v1";function cx(t){return JSON.stringify({v:1,tree:Ia(t.fractions.tree),note:Ia(t.fractions.note),graph:Ia(t.fractions.graph),revealed:[...t.revealed]})}function Ia(t){return Math.round(t*1e4)/1e4}function dx(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={tree:0,note:0,graph:0};for(let s of Qn){let l=r[s];if(typeof l!="number"||!Number.isFinite(l)||l<=0)return null;i[s]=l}let o=r.revealed,a=Array.isArray(o)?Qn.filter(s=>o.includes(s)):[];return Bh(i,e,a)}function jh(t,e){let n;try{n=t.getItem(Vh)}catch{return Fh(e)}return dx(n,e)??Fh(e)}function qh(t,e){try{return t.setItem(Vh,cx(e)),!0}catch{return!1}}function hx(t){return`--weave-col-${t}`}function fx(t){return`${Math.round(t)}px`}function Yh(t){return t.map(e=>[hx(e.id),fx(e.width)])}var Oa={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function Si(t,e,n){return{id:t,target:e.id,label:Ce(e),kind:e.kind,kindGlyph:Uo(e.kind),provenance:e.provenance,provenanceGlyph:Nt(e.provenance),provenanceTitle:Gn(e.provenance),selected:e.id===n}}function px(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:Si(t.id,i,n)}function gx(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var mx=["link:links-to:"];function vx(t){return mx.some(e=>t.id.startsWith(e))}function yx(t){return t.id.startsWith("link:mentions:")}function wx(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(Si(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function bx(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(Si(`mentioned-by:${o.source}`,a,r))}return i}function xx(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var ki={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 Fa(t){return{subject:null,groups:[],tags:[],empty:t}}function Xh(t,e){if(t===null)return Fa(ki.loading);if(e===null)return Fa(ki.noSelection);let n=Lt(t),r=Oo(n,e);if(r===null)return Fa(ki.unknown);let i=gx(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,rows:d})},s=h=>h.map(d=>px(d,i,e)).filter(d=>d!==null);a(Oa.links,s(r.links.filter(vx)));let l=Fo(n.edges).get(e)??[];a(Oa.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>Si(`backlink:${h.id}`,h,e))),a(Oa.mentions,[...s(r.links.filter(yx)),...bx(n,e,i,e)]);let u=xx(e),c=u===null?[]:wx(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],empty:ki.isolated}:{subject:r.label,groups:o,tags:c,empty:null}}var _x={notes:0,repo:null,nodes:0},Ex=["note"];function Zh(t){if(t===null)return _x;let e=t.model.nodes;return{notes:e.filter(n=>Ex.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function kx(t){return t===null||t==="missing"?"unindexed":t}function Qh(t){return[`vault:${t.notes}`,`repo:${kx(t.repo)}`,`${t.nodes} nodes`]}var Sx={live:{label:"live",tone:"ok",hint:"watching the vault and the repository for changes"},reconnecting:{label:"reconnecting",tone:"warn",hint:"the event stream dropped — retrying, and everything refetches when it returns"},offline:{label:"offline",tone:"bad",hint:"the workspace server is gone — use ⟳ to retry"}};function $a(t){return Sx[t]}var Tx={tree:{title:"Tree",body:"The vault and repository outline, expandable, filterable, with provenance markers.",phase:"P2"},note:{title:"Note",body:"Select anything to read it here — rendered Markdown, front matter, tags and wikilinks.",phase:"P2"},graph:{title:"Graph",body:"The knowledge graph, laid out and navigable, with the selection's neighbourhood highlighted.",phase:"P3"}};function Jh(t){return Tx[t]}var za={title:"Context",body:"Links, backlinks and mentions for whatever is selected.",phase:"P2"},ef="—";function tf(t,e,n,r){return{cwd:t===""?ef:t,selection:e??"nothing selected",connection:$a(n),stamp:r}}function nf(t){return t===null?ef:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}function rf(t){return t.map((e,n)=>({column:e,divider:n<t.length-1&&Rx(e.id)?e.id:null}))}function Rx(t){return Kh.includes(t)}var of="Search…";function Ua(t){return t?"⌘K":"Ctrl K"}function af(t){return`Search notes and repository (${t})`}function Ha(t){return/mac|iphone|ipad/i.test(t)}function sf({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:t.kindGlyph}),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 Ax({group:t,onSelect:e}){return x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:t.heading}),x("ul",{class:"weave-ctx-rows",children:t.rows.map(n=>x(sf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function Cx({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(sf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function lf(t){let e=Xh(t.graph,t.selectedId);return x("div",{class:"weave-rail","aria-label":za.title,children:[x("h2",{class:"weave-col-title",children:za.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(n=>x(Ax,{group:n,onSelect:t.onSelect},n.heading)),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:"TAGS"}),x("ul",{class:"weave-ctx-tags",children:e.tags.map(n=>x(Cx,{tag:n,onSelect:t.onSelect},n.tag))})]})]})}function uf(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,e.pointerId)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function Lx({id:t,props:e}){let n=Jh(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(Mh,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now}):null,t==="note"?x(Gh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,toolbar:e.toolbar,prompt:e.prompt,draft:e.draft,send:e.send}):null,t==="graph"?x(Hd,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,fit:e.fit}):null,t==="graph"?x(lf,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function Nx({slot:t,props:e}){let n=t.divider;return x(Pe,{children:[x(Lx,{id:t.column.id,props:e}),n===null?null:x(uf,{id:n,label:`Resize ${t.column.id} column`,onDown:(r,i)=>e.onDown(n,r,i),onMove:e.onMove,onUp:e.onUp,onKey:r=>e.onKey(n,r)})]})}function cf(t){let e=Ae(null);return Xs(()=>{Oh(e.current,Yh(t.resolved))},[t.resolved]),x("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:rf(t.resolved).map(n=>x(Nx,{slot:n,props:t},n.column.id))})}function Dx(t,e,n,r){return{divider:t,origin:e,base:n,pointerId:r}}function Px(t,e,n){return Ma(t.base,t.divider,e-t.origin,n)}function Ix(t,e){let n=t.base.fractions,r=e.fractions;return n.tree!==r.tree||n.note!==r.note||n.graph!==r.graph}var df=24;function Gx(t){return t==="ArrowLeft"?-df:t==="ArrowRight"?df:0}function hf(t){let e=null;return{onDown(n,r,i){e=Dx(n,r,t.layout(),i)},onMove(n){e!==null&&t.setLayout(Px(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&Ix(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=Ma(t.layout(),n,Gx(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}function ff(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:"🧵 pi-weave"}),x("button",{type:"button",class:"weave-search",title:af(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:of}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:Qh(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-refresh",onClick:t.onRefresh,title:"Refetch everything",children:"⟳"}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:[x("span",{class:"weave-conn-dot","aria-hidden":"true",children:"●"}),t.connection.label]})]})}var Mx={k:{type:"openSearch"},e:{type:"toggleEdit"},s:{type:"saveNote"}},pf={1:"tree",2:"note",3:"graph"};function Ox(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function Fx(t){return!t.ctrl&&!t.meta&&!t.alt}var $x={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"}};function gf(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(Ox(t)){let n=Mx[t.key.toLowerCase()];if(n!==void 0)return n;let r=pf[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!Fx(t)||t.typing?null:$x[t.key]??null}var zx=["INPUT","TEXTAREA","SELECT"];function Ux(t,e){return e?!0:t!==null&&zx.includes(t.toUpperCase())}function mf(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:Ux(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Hx={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},Bx=".weave-col-tree .weave-filter";function Wx(t){let e=t;return typeof e?.focus=="function"?e:null}function vf(t,e){let n=Wx(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function yf(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(Hx[t.column]);case"filterTree":return void e.focusSelector(Bx);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"toggleEdit":return e.toggleEdit();case"saveNote":return e.saveNote()}}function wf(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(pf).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column`})),{combo:"?",what:"This help"},{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:"Note",entries:[{combo:`${t}E`,what:"Toggle read / edit"},{combo:`${t}S`,what:"Save the open draft"}]},{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 Ba="Keyboard shortcuts",bf="esc close";function Kx({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 xf(t){let e=hi(),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":Ba,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:Ba}),x("div",{class:"weave-keys",children:wf(n).map(r=>x(Kx,{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:bf})]})]})})}function _f(t,e){let n=r=>{let i=gf(mf(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function Ef({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:nf(t.stamp)}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:t.connection.label})]})}function kf(t,e){let n=()=>e(t.innerWidth);return t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)}function Sf(t){let[e,n]=Ue(t.initialWidth),[r,i]=Ue(null),[o,a]=Ue(()=>jh(localStorage,t.initialWidth)),[s,l]=Ue(un),u=Ae(null),c=Ae(null),h=Ae({layout:o,width:e,overlay:r});h.current={layout:o,width:e,overlay:r};let d=Ie(()=>rd({fetch:qt,select:m=>{la(qt,m)},onChange:l}),[]);Re(()=>{let m=kd({fetch:qt,open:Bc});return u.current=m,()=>m.stop()},[]),Re(()=>_d(m=>d.send({type:"loaded",payload:m})),[]),Re(()=>id(window,()=>ia(d.state())),[]),Re(()=>kf(window,n),[]),Re(()=>_f(document,{context:()=>({overlay:h.current.overlay,hasSelection:vt.value!==null}),run:m=>yf(m,{setOverlay:i,focusSelector:v=>vf(document,v),fitGraph:()=>c.current?.(),clearSelection:()=>d.send({type:"navigate",id:null}),toggleEdit:()=>d.send({type:"toggle"}),saveNote:()=>d.send({type:"save"})})}),[]);let f=Ie(()=>Wh(o,e,zh(e)),[o,e]),g=Ie(()=>hf({layout:()=>h.current.layout,width:()=>h.current.width,setLayout:a,persist:m=>{qh(localStorage,m)}}),[]);return x(Pe,{children:[x(ff,{summary:Zh(yt.value),connection:$a(ln.value),shortcut:Ua(Ha(t.platform)),onRefresh:()=>u.current?.refresh(),onSearch:()=>i("search")}),x(cf,{resolved:f,onDown:g.onDown,onMove:g.onMove,onUp:g.onUp,onKey:g.onKey,graph:yt.value,note:Hn.value,selectedId:vt.value,onSelect:m=>d.send({type:"navigate",id:m}),now:Date.now(),toolbar:nd(s),prompt:td(s),draft:s.draft,send:d.send,renderer:Sc,storage:localStorage,host:window,fit:c}),x(Ef,{model:tf(t.cwd,vt.value,ln.value,yt.value?.model.generatedAt??null)}),r==="search"?x(bd,{graph:yt.value,onSelect:m=>{la(qt,m)},onClose:()=>i(null),ports:{fetch:qt,now:Date.now,delay:(m,v)=>{setTimeout(m,v)}}}):null,r==="help"?x(xf,{shortcut:Ua(Ha(t.platform)),onClose:()=>i(null)}):null]})}var Vx=`
|
|
399
|
+
`}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>${it(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=ch(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+it(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=ch(t);if(i===null)return it(n);t=i;let o=`<img src="${t}" alt="${it(n)}"`;return e&&(o+=` title="${it(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:it(t.text)}},Ta=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}},Xe=class ya{options;renderer;textRenderer;constructor(e){this.options=e||zt,this.options.renderer=this.options.renderer||new vi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ta}static parse(e,n){return new ya(n).parse(e)}static parseInline(e,n){return new ya(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}},qn=class{options;block;constructor(t){this.options=t||zt}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?Ye.lex:Ye.lexInline}provideParser(t=this.block){return t?Xe.parse:Xe.parseInline}},Aa=class{defaults=wa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Xe;Renderer=vi;TextRenderer=Ta;Lexer=Ye;Tokenizer=mi;Hooks=qn;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 vi(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 mi(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 qn;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];qn.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&qn.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 Ye.lex(t,e??this.defaults)}parser(t,e){return Xe.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?Ye.lex:Ye.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?Xe.parse:Xe.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?Ye.lex:Ye.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?Xe.parse:Xe.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+=`
|
|
400
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+it(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ft=new Aa;function V(t,e){return Ft.parse(t,e)}V.options=V.setOptions=function(t){return Ft.setOptions(t),V.defaults=Ft.defaults,ph(V.defaults),V};V.getDefaults=wa;V.defaults=zt;function Db(...t){return Ft.use(...t),V.defaults=Ft.defaults,ph(V.defaults),V}V.use=Db;V.walkTokens=function(t,e){return Ft.walkTokens(t,e)};V.parseInline=Ft.parseInline;V.Parser=Xe;V.parser=Xe.parse;V.Renderer=vi;V.TextRenderer=Ta;V.Lexer=Ye;V.lexer=Ye.lex;V.Tokenizer=mi;V.Hooks=qn;V.parse=V;var TS=V.options,AS=V.setOptions,RS=V.walkTokens,CS=V.parseInline;var LS=Xe.parse,NS=Ye.lex;var Sh={"&":"&","<":"<",">":">",'"':""","'":"'"},Gb=new RegExp(`[${Object.keys(Sh).join("")}]`,"g");function Ze(t){return t.replace(Gb,e=>Sh[e])}var Ib=["http:","https:","mailto:"],Mb=/^[a-z][a-z0-9+.-]*:/i,Ob=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function kh(t){let e=t.replace(Ob,""),n=Mb.exec(e);return n===null?e===""?null:t:Ib.includes(n[0].toLowerCase())?t:null}var wi="data-weave-target",bi="note:",Fb={bySpelling:new Map,hasGhosts:!1};function zb(t){if(t.kind!=="note"||!t.id.startsWith(bi))return null;let e=t.id.slice(bi.length);return e===""?null:e}function Th(t,e){if(t===null)return Fb;let n=new Map;for(let i of t.model.nodes){let o=zb(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 $b(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function Ub(t){return t.hasGhosts}var Hb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Bb(t){let e=t.indexOf("[[");return e===-1?void 0:e}function Wb(t){return{name:"wikilink",level:"inline",start:Bb,tokenizer(e){return Vb(e)},renderer(e){return Kb(t,e)}}}function Kb(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return jb(t,n,r)}function Vb(t){let e=Hb.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function jb(t,e,n){let r=Ze((n===""?e:n).trim());if(r==="")return"";let i=$b(t,e);return i!==null?`<a class="weave-wiki" ${wi}="${Ze(i)}" role="link" tabindex="0" title="${Ze(e.trim())}">${r}</a>`:Ub(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Ze(e.trim())}">${r}</span>`:r}function qb(t){return new Aa({gfm:!0,async:!1,extensions:[Wb(t)],renderer:{html({text:e}){return Ze(e)},link({href:e,title:n,tokens:r}){let i=kh(e),o=this.parser.parseInline(r);return`<a${[i===null?"":` href="${Ze(i)}"`,n==null||n===""?"":` title="${Ze(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=kh(e);if(i===null)return Ze(r);let o=n==null||n===""?"":` title="${Ze(n)}"`;return`<img src="${Ze(i)}" alt="${Ze(r)}"${o}>`}}})}function Yb(t,e){return qb(e).parse(t,{async:!1})}function Zn(t){return Object.freeze(t)}var Xb=Zn({ALLOWED_TAGS:Zn(["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:Zn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",wi]),ADD_URI_SAFE_ATTR:Zn([wi]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Zn({html:!0})});function Ah(t,e,n){return t.sanitize(Yb(e,n),Xb)}var Zb=32;function Ra(t){let e=t;for(let n=0;e!==null&&n<Zb;n++){let r=e.getAttribute(wi);if(r!==null&&r!=="")return`${bi}${r}`;e=e.parentElement}return null}function Rh(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Pt(t.source),provenanceTitle:In(t.source),updated:Gn(t.updated,e),updatedIso:t.updated,created:Gn(t.created,e),createdIso:t.created,tags:t.tags}}function Ch(t){return`#${t}`}function Lh(t,e){return e!==null?null:t===null?"Select a note to read it here.":t.startsWith(bi)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function Qb({view:t}){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("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:["updated ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:["created ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(e=>x("span",{class:"weave-tag",children:Ch(e)},e))})]})}function Nh(t){let e=t.note?.note??null,n=Lh(t.selectedId,e);if(e===null)return x("p",{class:"weave-note-empty",children:n});let r=Th(t.graph,e.slug),i=t.toolbar,o={draft:t.draft,prompt:t.prompt,send:t.send};return x("article",{class:"weave-note",children:[x(Qb,{view:Rh(e,t.now)}),i===null?null:x(oh,{toolbar:i,...o}),i!==null&&i.editing?x(ah,{toolbar:i,...o}):x("div",{class:"weave-note-body",onClick:a=>{let s=Ra(a.target);s!==null&&t.onSelect(s)},onKeyDown:a=>{if(a.key!=="Enter"&&a.key!==" ")return;let s=Ra(a.target);s!==null&&(a.preventDefault(),t.onSelect(s))},dangerouslySetInnerHTML:{__html:Ah(ih,e.body,r)}})]})}function Jb({view:t,onSelect:e,onToggle:n}){return x("li",{id:t.domId,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${un.value.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:Hu(t.depth),onClick:e,children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:r=>{r.stopPropagation(),n()},children:t.twistyGlyph}),x("span",{class:"weave-kind","aria-hidden":"true",children:t.kindGlyph}),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 Ph(t){let[e,n]=He(Pu),r=Du(t.graph,e),i=Xu(t.graph,r,e);return x("div",{class:"weave-tree",onKeyDown:o=>{let a=Fu(r,e,t.selectedId,o.key);a.handled&&(o.preventDefault(),n(a.state),a.selectedId!==null&&t.onSelect(a.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:Vu,"aria-label":qu,title:Yu,onInput:o=>n(Iu(e,o.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:Bu(e.provFilter),onClick:()=>n(Mu(e)),children:["◧ ",Hr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:Ku(e.showInternals),onClick:()=>n(Ou(e)),children:["◧ ",Wu(e.showInternals)]})]}),i===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":ju,"aria-activedescendant":Uu(r,t.selectedId)??void 0,children:$u(r,t.selectedId,t.now).map(o=>x(Jb,{view:o,onSelect:()=>t.onSelect(o.id),onToggle:()=>n(Gu(e,o.id))},o.id))}):x("p",{class:"weave-tree-empty",children:i}),x("p",{class:"weave-tree-count",children:Zu(r)})]})}function Dh(t,e){if(t===null)return 0;for(let[n,r]of e)t.style.setProperty(n,r);return e.length}var Qn=["tree","note","graph"],Ca={tree:180,note:320,graph:260},Ih={tree:.22,note:.46,graph:.32},ex=1100,tx=800;function Mh(t){return!Number.isFinite(t)||t<tx?"narrow":t<ex?"medium":"wide"}function nx(t){return t==="wide"?Qn:t==="medium"?["tree","note"]:["note"]}function Oh(t,e){return Fh(Qn,t,e)}function Fh(t,e,n){let r={tree:0,note:0,graph:0};for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:Ih[l]}let i=0;for(let l of t)i+=r[l];for(let l of t)r[l]=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 Na(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:Ca.tree/e,note:Ca.note/e,graph:Ca.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 zh(t,e,n=[]){return{fractions:Oh(t,Na(e)),revealed:Qn.filter(r=>n.includes(r))}}function Gh(t){return zh(Ih,t)}function $h(t,e,n){let r=nx(n),i=Number.isFinite(e)&&e>0?e:0,o=Fh(r,t.fractions,Na(i));return r.map(a=>({id:a,width:o[a]*i}))}var Uh=["tree","note"];function rx(t){return t==="tree"?["tree","note"]:["note","graph"]}function Pa(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]=rx(e),s=Na(i),l=Math.max(0,t.fractions[o]-s[o]),u=Math.max(0,t.fractions[a]-s[a]),c=Math.max(-l,Math.min(u,n/i));if(c===0)return t;let h={...t.fractions,[o]:t.fractions[o]+c,[a]:t.fractions[a]-c};return{fractions:Oh(h,s),revealed:t.revealed}}var Hh="pi-weave.layout.v1";function ix(t){return JSON.stringify({v:1,tree:La(t.fractions.tree),note:La(t.fractions.note),graph:La(t.fractions.graph),revealed:[...t.revealed]})}function La(t){return Math.round(t*1e4)/1e4}function ox(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={tree:0,note:0,graph:0};for(let s of Qn){let l=r[s];if(typeof l!="number"||!Number.isFinite(l)||l<=0)return null;i[s]=l}let o=r.revealed,a=Array.isArray(o)?Qn.filter(s=>o.includes(s)):[];return zh(i,e,a)}function Bh(t,e){let n;try{n=t.getItem(Hh)}catch{return Gh(e)}return ox(n,e)??Gh(e)}function Wh(t,e){try{return t.setItem(Hh,ix(e)),!0}catch{return!1}}function ax(t){return`--weave-col-${t}`}function sx(t){return`${Math.round(t)}px`}function Kh(t){return t.map(e=>[ax(e.id),sx(e.width)])}var Da={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function _i(t,e,n){return{id:t,target:e.id,label:Le(e),kind:e.kind,kindGlyph:Oo(e.kind),provenance:e.provenance,provenanceGlyph:Pt(e.provenance),provenanceTitle:In(e.provenance),selected:e.id===n}}function lx(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:_i(t.id,i,n)}function ux(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var cx=["link:links-to:"];function dx(t){return cx.some(e=>t.id.startsWith(e))}function hx(t){return t.id.startsWith("link:mentions:")}function fx(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(_i(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function px(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(_i(`mentioned-by:${o.source}`,a,r))}return i}function gx(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var xi={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 Ga(t){return{subject:null,groups:[],tags:[],empty:t}}function Vh(t,e){if(t===null)return Ga(xi.loading);if(e===null)return Ga(xi.noSelection);let n=Nt(t),r=Po(n,e);if(r===null)return Ga(xi.unknown);let i=ux(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,rows:d})},s=h=>h.map(d=>lx(d,i,e)).filter(d=>d!==null);a(Da.links,s(r.links.filter(dx)));let l=Go(n.edges).get(e)??[];a(Da.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>_i(`backlink:${h.id}`,h,e))),a(Da.mentions,[...s(r.links.filter(hx)),...px(n,e,i,e)]);let u=gx(e),c=u===null?[]:fx(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],empty:xi.isolated}:{subject:r.label,groups:o,tags:c,empty:null}}var mx={notes:0,repo:null,nodes:0},vx=["note"];function jh(t){if(t===null)return mx;let e=t.model.nodes;return{notes:e.filter(n=>vx.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function yx(t){return t===null||t==="missing"?"unindexed":t}function qh(t){return[`vault:${t.notes}`,`repo:${yx(t.repo)}`,`${t.nodes} nodes`]}var wx={live:{label:"live",tone:"ok",hint:"watching the vault and the repository for changes"},reconnecting:{label:"reconnecting",tone:"warn",hint:"the event stream dropped — retrying, and everything refetches when it returns"},offline:{label:"offline",tone:"bad",hint:"the workspace server is gone — use ⟳ to retry"}};function Ia(t){return wx[t]}var bx={tree:{title:"Tree",body:"The vault and repository outline, expandable, filterable, with provenance markers.",phase:"P2"},note:{title:"Note",body:"Select anything to read it here — rendered Markdown, front matter, tags and wikilinks.",phase:"P2"},graph:{title:"Graph",body:"The knowledge graph, laid out and navigable, with the selection's neighbourhood highlighted.",phase:"P3"}};function Yh(t){return bx[t]}var Ma={title:"Context",body:"Links, backlinks and mentions for whatever is selected.",phase:"P2"},Xh="—";function Zh(t,e,n,r){return{cwd:t===""?Xh:t,selection:e??"nothing selected",connection:Ia(n),stamp:r}}function Qh(t){return t===null?Xh:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}function Jh(t){return t.map((e,n)=>({column:e,divider:n<t.length-1&&xx(e.id)?e.id:null}))}function xx(t){return Uh.includes(t)}var ef="Search…";function Oa(t){return t?"⌘K":"Ctrl K"}function tf(t){return`Search notes and repository (${t})`}function Fa(t){return/mac|iphone|ipad/i.test(t)}function nf({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:t.kindGlyph}),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 _x({group:t,onSelect:e}){return x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:t.heading}),x("ul",{class:"weave-ctx-rows",children:t.rows.map(n=>x(nf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function Ex({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(nf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function rf(t){let e=Vh(t.graph,t.selectedId);return x("div",{class:"weave-rail","aria-label":Ma.title,children:[x("h2",{class:"weave-col-title",children:Ma.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(n=>x(_x,{group:n,onSelect:t.onSelect},n.heading)),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:"TAGS"}),x("ul",{class:"weave-ctx-tags",children:e.tags.map(n=>x(Ex,{tag:n,onSelect:t.onSelect},n.tag))})]})]})}function of(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,e.pointerId)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function kx({id:t,props:e}){let n=Yh(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(Ph,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now}):null,t==="note"?x(Nh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,toolbar:e.toolbar,prompt:e.prompt,draft:e.draft,send:e.send}):null,t==="graph"?x(Fd,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,fit:e.fit}):null,t==="graph"?x(rf,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function Sx({slot:t,props:e}){let n=t.divider;return x(Ge,{children:[x(kx,{id:t.column.id,props:e}),n===null?null:x(of,{id:n,label:`Resize ${t.column.id} column`,onDown:(r,i)=>e.onDown(n,r,i),onMove:e.onMove,onUp:e.onUp,onKey:r=>e.onKey(n,r)})]})}function af(t){let e=ye(null);return Vs(()=>{Dh(e.current,Kh(t.resolved))},[t.resolved]),x("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:Jh(t.resolved).map(n=>x(Sx,{slot:n,props:t},n.column.id))})}function Tx(t,e,n,r){return{divider:t,origin:e,base:n,pointerId:r}}function Ax(t,e,n){return Pa(t.base,t.divider,e-t.origin,n)}function Rx(t,e){let n=t.base.fractions,r=e.fractions;return n.tree!==r.tree||n.note!==r.note||n.graph!==r.graph}var sf=24;function Cx(t){return t==="ArrowLeft"?-sf:t==="ArrowRight"?sf:0}function lf(t){let e=null;return{onDown(n,r,i){e=Tx(n,r,t.layout(),i)},onMove(n){e!==null&&t.setLayout(Ax(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&Rx(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=Pa(t.layout(),n,Cx(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}var uf="image/png",cf="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 df(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:[x("img",{class:"weave-brand-mark",src:`data:${uf};base64,${cf}`,alt:"",width:18,height:18}),"pi-weave"]}),x("button",{type:"button",class:"weave-search",title:tf(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:ef}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:qh(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-refresh",onClick:t.onRefresh,title:"Refetch everything",children:"⟳"}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:[x("span",{class:"weave-conn-dot","aria-hidden":"true",children:"●"}),t.connection.label]})]})}var Lx={k:{type:"openSearch"},e:{type:"toggleEdit"},s:{type:"saveNote"}},hf={1:"tree",2:"note",3:"graph"};function Nx(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function Px(t){return!t.ctrl&&!t.meta&&!t.alt}var Dx={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"}};function ff(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(Nx(t)){let n=Lx[t.key.toLowerCase()];if(n!==void 0)return n;let r=hf[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!Px(t)||t.typing?null:Dx[t.key]??null}var Gx=["INPUT","TEXTAREA","SELECT"];function Ix(t,e){return e?!0:t!==null&&Gx.includes(t.toUpperCase())}function pf(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:Ix(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Mx={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},Ox=".weave-col-tree .weave-filter";function Fx(t){let e=t;return typeof e?.focus=="function"?e:null}function gf(t,e){let n=Fx(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function mf(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(Mx[t.column]);case"filterTree":return void e.focusSelector(Ox);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"toggleEdit":return e.toggleEdit();case"saveNote":return e.saveNote()}}function vf(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(hf).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column`})),{combo:"?",what:"This help"},{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:"Note",entries:[{combo:`${t}E`,what:"Toggle read / edit"},{combo:`${t}S`,what:"Save the open draft"}]},{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 za="Keyboard shortcuts",yf="esc close";function zx({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 wf(t){let e=li(),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":za,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:za}),x("div",{class:"weave-keys",children:vf(n).map(r=>x(zx,{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:yf})]})]})})}function bf(t,e){let n=r=>{let i=ff(pf(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function xf({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:Qh(t.stamp)}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:t.connection.label})]})}function _f(t,e){let n=()=>e(t.innerWidth);return t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)}function Ef(t){let[e,n]=He(t.initialWidth),[r,i]=He(null),[o,a]=He(()=>Bh(localStorage,t.initialWidth)),[s,l]=He(cn),u=ye(null),c=ye(null),h=ye({layout:o,width:e,overlay:r});h.current={layout:o,width:e,overlay:r};let d=Ce(()=>Qc({fetch:St,select:m=>{hi(St,m)},onChange:l}),[]);me(()=>{let m=_d({fetch:St,open:Fc});return u.current=m,()=>m.stop()},[]);let f=ye(!1);me(()=>{f.current&&vd(localStorage,je.value)},[je.value]),me(()=>{if(f.current||Fe.value===null||(f.current=!0,je.value!==null))return;let m=yd(Fe.value,localStorage);m!==null&&hi(St,m)},[Fe.value]),me(()=>bd(m=>d.send({type:"loaded",payload:m})),[]),me(()=>Jc(window,()=>ea(d.state())),[]),me(()=>_f(window,n),[]),me(()=>bf(document,{context:()=>({overlay:h.current.overlay,hasSelection:je.value!==null}),run:m=>mf(m,{setOverlay:i,focusSelector:b=>gf(document,b),fitGraph:()=>c.current?.(),clearSelection:()=>d.send({type:"navigate",id:null}),toggleEdit:()=>d.send({type:"toggle"}),saveNote:()=>d.send({type:"save"})})}),[]);let g=Ce(()=>$h(o,e,Mh(e)),[o,e]),v=Ce(()=>lf({layout:()=>h.current.layout,width:()=>h.current.width,setLayout:a,persist:m=>{Wh(localStorage,m)}}),[]);return x(Ge,{children:[x(df,{summary:jh(Fe.value),connection:Ia(ln.value),shortcut:Oa(Fa(t.platform)),onRefresh:()=>u.current?.refresh(),onSearch:()=>i("search")}),x(af,{resolved:g,onDown:v.onDown,onMove:v.onMove,onUp:v.onUp,onKey:v.onKey,graph:Fe.value,note:Hn.value,selectedId:je.value,onSelect:m=>d.send({type:"navigate",id:m}),now:Date.now(),toolbar:Zc(s),prompt:Xc(s),draft:s.draft,send:d.send,renderer:bc,storage:localStorage,host:window,fit:c}),x(xf,{model:Zh(t.cwd,je.value,ln.value,Fe.value?.model.generatedAt??null)}),r==="search"?x(gd,{graph:Fe.value,onSelect:m=>{hi(St,m)},onClose:()=>i(null),ports:{fetch:St,now:Date.now,delay:(m,b)=>{setTimeout(m,b)}}}):null,r==="help"?x(wf,{shortcut:Oa(Fa(t.platform)),onClose:()=>i(null)}):null]})}var $x=`
|
|
401
401
|
:root{
|
|
402
402
|
--weave-bg:#141317;--weave-panel:#191820;--weave-fg:#e8e6ee;--weave-dim:#8f8a9c;
|
|
403
403
|
--weave-faint:#5d5869;--weave-line:#26242e;--weave-line-strong:#343141;
|
|
404
404
|
--weave-accent:#a48cff;--weave-ok:#4ade80;--weave-warn:#fbbf24;--weave-bad:#f87171;
|
|
405
|
+
--weave-new:rgba(164,140,255,.20);
|
|
405
406
|
--weave-row:26px;--weave-gutter:10px;
|
|
406
407
|
}
|
|
407
408
|
@media (prefers-color-scheme: light){
|
|
@@ -409,6 +410,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
409
410
|
--weave-bg:#faf9f7;--weave-panel:#ffffff;--weave-fg:#1c1b19;--weave-dim:#6f6b66;
|
|
410
411
|
--weave-faint:#9a958e;--weave-line:#e6e3de;--weave-line-strong:#d2cec8;
|
|
411
412
|
--weave-accent:#6d4aff;--weave-ok:#15803d;--weave-warn:#b45309;--weave-bad:#b91c1c;
|
|
413
|
+
--weave-new:rgba(109,74,255,.14);
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
416
|
body{font-size:13px}
|
|
@@ -419,7 +421,8 @@ body{font-size:13px}
|
|
|
419
421
|
display:flex;align-items:center;gap:14px;padding:0 var(--weave-gutter);
|
|
420
422
|
height:34px;border-bottom:1px solid var(--weave-line);background:var(--weave-panel);
|
|
421
423
|
}
|
|
422
|
-
.weave-brand{font-weight:600;letter-spacing:.01em;white-space:nowrap}
|
|
424
|
+
.weave-brand{display:inline-flex;align-items:center;gap:6px;font-size:14px;font-weight:600;letter-spacing:.01em;white-space:nowrap}
|
|
425
|
+
.weave-brand-mark{height:20px;width:20px;border-radius:5px}
|
|
423
426
|
/* A button styled as a search field: the palette owns the only text input,
|
|
424
427
|
so this opens it rather than pretending to accept a query. */
|
|
425
428
|
.weave-search{
|
|
@@ -518,6 +521,17 @@ body{font-size:13px}
|
|
|
518
521
|
}
|
|
519
522
|
.weave-row:hover{background:var(--weave-line)}
|
|
520
523
|
.weave-row-on{background:var(--weave-line-strong);color:var(--weave-fg)}
|
|
524
|
+
/* A newly-arrived node (a file or note added since the last update, §6):
|
|
525
|
+
one short highlight that fades while the label settles from bold back to
|
|
526
|
+
normal. The class is computed from the frame diff in workspace.ts and
|
|
527
|
+
expires with it, so collapsing and re-expanding later does not replay the
|
|
528
|
+
arrival, and the first load never flashes the whole tree. */
|
|
529
|
+
.weave-row-new{animation:weave-row-new 2.6s ease-out both}
|
|
530
|
+
@keyframes weave-row-new{
|
|
531
|
+
0%{background:var(--weave-new);font-weight:700}
|
|
532
|
+
40%{font-weight:700}
|
|
533
|
+
100%{background:transparent;font-weight:400}
|
|
534
|
+
}
|
|
521
535
|
.weave-twisty{width:10px;flex:none;color:var(--weave-faint);cursor:pointer;text-align:center}
|
|
522
536
|
.weave-kind{flex:none;color:var(--weave-faint);font-size:11px}
|
|
523
537
|
.weave-prov{flex:none;font-size:9px}
|
|
@@ -642,7 +656,6 @@ body{font-size:13px}
|
|
|
642
656
|
display:flex;align-items:center;gap:6px;flex-wrap:wrap;
|
|
643
657
|
padding:5px var(--weave-gutter);border-top:1px solid var(--weave-line);
|
|
644
658
|
}
|
|
645
|
-
.weave-depth{font:inherit;font-size:10.5px;padding:3px 4px}
|
|
646
659
|
.weave-graph-legend{
|
|
647
660
|
margin-left:auto;display:flex;gap:9px;font-size:10.5px;color:var(--weave-faint);
|
|
648
661
|
white-space:nowrap;
|
|
@@ -743,7 +756,7 @@ body{font-size:13px}
|
|
|
743
756
|
/* focus ----------------------------------------------------------------- */
|
|
744
757
|
:focus-visible{outline:2px solid var(--weave-accent);outline-offset:1px}
|
|
745
758
|
@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
|
|
746
|
-
`,
|
|
759
|
+
`,Ux=["style[nonce]","style","script[nonce]","script[src]"];function Hx(t){for(let e of Ux){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function kf(t,e=$x){let n=t.createElement("style"),r=Hx(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var Sf=document.getElementById("app");if(Sf!==null){kf(document);let t=Ms(document.getElementById(Is)?.textContent??null);Ps(x(Ef,{cwd:t.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),Sf)}})();
|
|
747
760
|
/*! Bundled license information:
|
|
748
761
|
|
|
749
762
|
dompurify/dist/purify.es.mjs:
|