pi-weave 0.1.12 → 0.1.13
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 +8 -37
- package/package.json +1 -2
- package/src/core/concurrency.ts +3 -6
- package/src/core/frontmatter.ts +0 -53
- package/src/core/graph/build.ts +6 -7
- package/src/core/graph/current.ts +2 -4
- package/src/core/graph/model.ts +1 -1
- package/src/core/graph/wikilinks.ts +3 -3
- package/src/core/index.ts +26 -27
- package/src/core/paths.ts +0 -7
- package/src/core/vault.ts +16 -681
- package/src/core/view/detail.ts +1 -1
- package/src/core/view/health.ts +1 -1
- package/src/core/view/tree.ts +1 -1
- package/src/pi/index.ts +6 -85
- package/src/pi/summarize.ts +2 -2
- package/src/pi/viewer/tui/bodyStore.ts +4 -7
- package/src/pi/viewer/tui/branding.ts +7 -148
- package/src/pi/viewer/tui/run.ts +3 -17
- package/src/pi/viewer/tui/surface/base.ts +24 -3
- package/src/pi/viewer/tui/surface/explore.ts +41 -6
- package/src/pi/viewer/tui/workspace.ts +23 -351
- package/src/pi/viewer/tui/workspaceRoot.ts +31 -172
- package/src/pi/viewer/web/run.ts +7 -117
- package/src/web/client/api.dom.ts +2 -2
- package/src/web/client/api.ts +14 -223
- package/src/web/client/bootstrap.ts +5 -14
- package/src/web/client/context/context.model.ts +9 -11
- package/src/web/client/dist/app.js +93 -219
- package/src/web/client/graph/dynamics.ts +5 -65
- package/src/web/client/graph/renderer.dom.ts +7 -8
- package/src/web/client/graph/renderer.ts +9 -35
- package/src/web/client/main.tsx +1 -1
- package/src/web/client/note/Note.tsx +21 -63
- package/src/web/client/search/SearchPalette.tsx +45 -36
- package/src/web/client/search/search.model.ts +33 -454
- package/src/web/client/shell/Columns.tsx +13 -83
- package/src/web/client/shell/Header.tsx +2 -10
- package/src/web/client/shell/Shell.tsx +50 -125
- package/src/web/client/shell/StatusBar.tsx +1 -4
- package/src/web/client/shell/icons.model.ts +4 -7
- package/src/web/client/shell/keys.model.ts +5 -42
- package/src/web/client/shell/keys.ts +2 -2
- package/src/web/client/shell/shell.model.ts +10 -133
- package/src/web/client/shell/theme.model.ts +2 -2
- package/src/web/client/shell/theme.ts +33 -157
- package/src/web/client/state.ts +9 -89
- package/src/web/client/tree/Tree.tsx +25 -575
- package/src/web/client/tree/tree.model.ts +8 -162
- package/src/web/client/workspace.ts +72 -242
- package/src/web/server/page.ts +8 -10
- package/src/web/server/routes.ts +30 -563
- package/src/web/server/server.ts +6 -145
- package/src/web/shared/layout.ts +72 -624
- package/src/web/shared/wire.ts +10 -196
- package/src/core/sessions.ts +0 -929
- package/src/pi/sessionScan.ts +0 -104
- package/src/pi/viewer/tui/explorer.ts +0 -586
- package/src/web/client/live.model.ts +0 -275
- package/src/web/client/live.ts +0 -151
- package/src/web/client/note/Editor.tsx +0 -109
- package/src/web/client/note/editor.controller.ts +0 -151
- package/src/web/client/note/editor.model.ts +0 -686
- package/src/web/client/search/search.ts +0 -107
- package/src/web/client/shell/Divider.tsx +0 -44
- package/src/web/client/shell/cssvars.ts +0 -70
- package/src/web/client/shell/drag.model.ts +0 -170
- package/src/web/client/shell/layout.model.ts +0 -500
- package/src/web/client/shell/viewport.ts +0 -29
- package/src/web/server/sse.ts +0 -321
- package/src/web/server/watcher.ts +0 -507
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* pi-weave itself is MIT (see LICENSE).
|
|
6
6
|
*
|
|
7
7
|
* Bundled dependencies and their licences:
|
|
8
|
-
* @preact/signals@2.11.1 — MIT
|
|
9
|
-
* @preact/signals-core@1.14.4 — MIT
|
|
10
8
|
* d3-dispatch@3.0.1 — ISC
|
|
11
9
|
* d3-force@3.0.0 — ISC
|
|
12
10
|
* d3-quadtree@3.0.1 — ISC
|
|
@@ -20,11 +18,11 @@
|
|
|
20
18
|
* sigma@3.0.3 — MIT
|
|
21
19
|
*/
|
|
22
20
|
|
|
23
|
-
"use strict";(()=>{var mg=Object.create;var Ks=Object.defineProperty;var vg=Object.getOwnPropertyDescriptor;var yg=Object.getOwnPropertyNames;var wg=Object.getPrototypeOf,bg=Object.prototype.hasOwnProperty;var Vs=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var xg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yg(t))!bg.call(e,i)&&i!==n&&Ks(e,i,{get:()=>t[i],enumerable:!(r=vg(t,i))||r.enumerable});return e};var En=(e,t,n)=>(n=e!=null?mg(wg(e)):{},xg(t||!e||!e.__esModule?Ks(n,"default",{value:e,enumerable:!0}):n,e));var Or=Vs((jk,Mo)=>{"use strict";var Jt=typeof Reflect=="object"?Reflect:null,cu=Jt&&typeof Jt.apply=="function"?Jt.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Mr;Jt&&typeof Jt.ownKeys=="function"?Mr=Jt.ownKeys:Object.getOwnPropertySymbols?Mr=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Mr=function(t){return Object.getOwnPropertyNames(t)};function Sm(e){console&&console.warn&&console.warn(e)}var hu=Number.isNaN||function(t){return t!==t};function j(){j.init.call(this)}Mo.exports=j;Mo.exports.once=Cm;j.EventEmitter=j;j.prototype._events=void 0;j.prototype._eventsCount=0;j.prototype._maxListeners=void 0;var du=10;function Gr(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(j,"defaultMaxListeners",{enumerable:!0,get:function(){return du},set:function(e){if(typeof e!="number"||e<0||hu(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");du=e}});j.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};j.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||hu(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function fu(e){return e._maxListeners===void 0?j.defaultMaxListeners:e._maxListeners}j.prototype.getMaxListeners=function(){return fu(this)};j.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="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[t];if(l===void 0)return!1;if(typeof l=="function")cu(l,this,n);else for(var u=l.length,c=yu(l,u),r=0;r<u;++r)cu(c[r],this,n);return!0};function pu(e,t,n,r){var i,o,a;if(Gr(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),a===void 0)a=o[t]=n,++e._eventsCount;else if(typeof a=="function"?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=fu(e),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=a.length,Sm(s)}return e}j.prototype.addListener=function(t,n){return pu(this,t,n,!1)};j.prototype.on=j.prototype.addListener;j.prototype.prependListener=function(t,n){return pu(this,t,n,!0)};function Tm(){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 gu(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=Tm.bind(r);return i.listener=n,r.wrapFn=i,i}j.prototype.once=function(t,n){return Gr(n),this.on(t,gu(this,t,n)),this};j.prototype.prependOnceListener=function(t,n){return Gr(n),this.prependListener(t,gu(this,t,n)),this};j.prototype.removeListener=function(t,n){var r,i,o,a,s;if(Gr(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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():Am(r,o),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};j.prototype.off=j.prototype.removeListener;j.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),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[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this};function mu(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Rm(i):yu(i,i.length)}j.prototype.listeners=function(t){return mu(this,t,!0)};j.prototype.rawListeners=function(t){return mu(this,t,!1)};j.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):vu.call(e,t)};j.prototype.listenerCount=vu;function vu(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}j.prototype.eventNames=function(){return this._eventsCount>0?Mr(this._events):[]};function yu(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function Am(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Rm(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Cm(e,t){return new Promise(function(n,r){function i(a){e.removeListener(t,o),r(a)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}wu(e,t,o,{once:!0}),t!=="error"&&Nm(e,i,{once:!0})})}function Nm(e,t,n){typeof e.on=="function"&&wu(e,"error",t,n)}function wu(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var Go=Vs((Xk,xu)=>{"use strict";xu.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Tr,W,Zs,lo,vt,js,Qs,Js,oo,xr,Sn,el,uo,ao,so,_g,kr={},Er=[],kg=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ar=Array.isArray;function st(e,t){for(var n in t)e[n]=t[n];return e}function co(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Eg(e,t,n){var r,i,o,a={};for(o in t)o=="key"?r=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?Tr.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return _r(e,a,r,i,null)}function _r(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Zs,__i:-1,__u:0};return i==null&&W.vnode!=null&&W.vnode(o),o}function Ne(e){return e.children}function Yt(e,t){this.props=e,this.context=t}function Tt(e,t){if(t==null)return e.__?Tt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Tt(e):null}function Sg(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=st({},t);o.__v=t.__v+1,W.vnode&&W.vnode(o),ho(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Tt(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,ol(r,o,i),t.__e=t.__=null,o.__e!=n&&tl(o)}}function tl(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),tl(e)}function qs(e){(!e.__d&&(e.__d=!0)&&vt.push(e)&&!Sr.__r++||js!=W.debounceRendering)&&((js=W.debounceRendering)||Qs)(Sr)}function Sr(){try{for(var e,t=1;vt.length;)vt.length>t&&vt.sort(Js),e=vt.shift(),t=vt.length,Sg(e)}finally{vt.length=Sr.__r=0}}function nl(e,t,n,r,i,o,a,s,l,u,c){var h,d,f,g,m,v,w=r&&r.__k||Er,b=t.length;for(l=Tg(n,t,w,l,b),h=0;h<b;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&w[f.__i]||kr,f.__i=h,v=ho(e,f,d,i,o,a,s,l,u,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&fo(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),4&f.__u?(l=rl(f,l,e),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 Tg(e,t,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[o]=_r(null,a,null,null,null):Ar(a)?a=e.__k[o]=_r(Ne,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=_r(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,l=o+d,a.__=e,a.__b=e.__b+1,s=null,(u=a.__i=Ag(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))):e.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=Tt(s)),sl(s,s));return r}function rl(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=rl(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Tt(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ag(e,t,n,r){var i,o,a,s=e.key,l=e.type,u=t[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<t.length;)if((u=t[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function Ys(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||kg.test(t)?n:n+"px"}function br(e,t,n,r,i){var o,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Ys(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||Ys(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(el,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[Sn]=r[Sn]:(n[Sn]=uo,e.addEventListener(t,o?so:ao,o)):e.removeEventListener(t,o?so:ao,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Xs(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[xr]==null)t[xr]=uo++;else if(t[xr]<n[Sn])return;return n(W.event?W.event(t):t)}}}function ho(e,t,n,r,i,o,a,s,l,u){var c,h,d,f,g,m,v,w,b,E,k,I,D,N,z,U,_=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=t.__e=n.__e]),(c=W.__b)&&c(t);e:if(typeof _=="function"){h=a.length;try{if(b=t.props,E=_.prototype&&_.prototype.render,k=(c=_.contextType)&&r[c.__c],I=c?k?k.props.value:c.__:r,n.__c?w=(d=t.__c=n.__c).__=d.__E:(E?t.__c=d=new _(b,I):(t.__c=d=new Yt(b,I),d.constructor=_,d.render=Cg),k&&k.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&&_.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=st({},d.__s)),st(d.__s,_.getDerivedStateFromProps(b,d.__s))),g=d.props,m=d.state,d.__v=t,f)E&&_.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),E&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(E&&_.getDerivedStateFromProps==null&&b!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,I),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,I)===!1){t.__v!=n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(A){A&&(A.__=t)}),Er.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=Tt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,I),E&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,m,v)})}if(d.context=I,d.props=b,d.__P=e,d.__e=!1,D=W.__r,N=0,E)d.state=d.__s,d.__d=!1,D&&D(t),c=d.render(d.props,d.state,d.context),Er.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,D&&D(t),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++N<25);d.state=d.__s,d.getChildContext!=null&&(r=st(st({},r),d.getChildContext())),E&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(g,m)),z=c!=null&&c.type===Ne&&c.key==null?al(c.props.children):c,s=nl(e,Ar(z)?z:[z],t,n,r,i,o,a,s,l,u),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),w&&(d.__E=d.__=null)}catch(A){if(a.length=h,t.__v=null,l||o!=null){if(A.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),t.__e=s}else if(o!=null)for(U=o.length;U--;)co(o[U])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),A.then||il(t),W.__e(A,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Rg(n.__e,t,n,r,i,o,a,l,u);return(c=W.diffed)&&c(t),128&t.__u?void 0:s}function il(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(il))}function ol(e,t,n){for(var r=0;r<n.length;r++)fo(n[r],n[++r],n[++r]);W.__c&&W.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){W.__e(o,i.__v)}})}function al(e){return typeof e!="object"||e==null||e.__b>0?e:Ar(e)?e.map(al):e.constructor!==void 0?null:st({},e)}function Rg(e,t,n,r,i,o,a,s,l){var u,c,h,d,f,g,m,v=n.props||kr,w=t.props,b=t.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)){e=f,o[u]=null;break}}if(e==null){if(b==null)return document.createTextNode(w);e=document.createElementNS(i,b,w.is&&w),s&&(W.__m&&W.__m(t,o),s=!1),o=null}if(b==null)v===w||s&&e.data==w||(e.data=w);else{if(o=b=="textarea"&&w.defaultValue!=null?null:o&&Tr.call(e.childNodes),!s&&o!=null)for(v={},u=0;u<e.attributes.length;u++)v[(f=e.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||br(e,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||br(e,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(h&&(e.innerHTML=""),nl(t.type=="template"?e.content:e,Ar(d)?d:[d],t,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&Tt(n,0),s,l),o!=null)for(u=o.length;u--;)co(o[u]);s&&b!="textarea"||(u="value",b=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[u]||b=="progress"&&!g||b=="option"&&g!=v[u])&&br(e,u,g,v[u],i),u="checked",m!=null&&m!=e[u]&&br(e,u,m,v[u],i))}return e}function fo(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){W.__e(i,n)}}function sl(e,t,n){var r,i;if(W.unmount&&W.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||fo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){W.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&sl(r[i],t,n||typeof e.type!="function");n||co(e.__e),e.__c=e.__=e.__e=void 0}function Cg(e,t,n){return this.constructor(e,n)}function ll(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),W.__&&W.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,o=[],a=[],ho(t,e=(!r&&n||t).__k=Eg(Ne,null,[e]),i||kr,kr,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Tr.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),ol(o,e,a),e.props.children=null}Tr=Er.slice,W={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},Zs=0,lo=function(e){return e!=null&&e.constructor===void 0},Yt.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=st({},this.state),typeof e=="function"&&(e=e(st({},n),this.props)),e&&st(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qs(this))},Yt.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qs(this))},Yt.prototype.render=Ne,vt=[],Qs=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Js=function(e,t){return e.__v.__b-t.__v.__b},Sr.__r=0,oo=Math.random().toString(8),xr="__d"+oo,Sn="__a"+oo,el=/(PointerCapture)$|Capture$/i,uo=0,ao=Xs(!1),so=Xs(!0),_g=0;var Ng=["vault","repo","git"],ul="change";function cl(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.stamp!="string"?!1:Ng.includes(t.scope)}var dl="weave-bootstrap";var po={cwd:"",vaultRoot:"",session:""};function Lg(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.cwd=="string"&&typeof t.vaultRoot=="string"&&typeof t.session=="string"}function hl(e){if(e===null||e.trim()==="")return po;let t;try{t=JSON.parse(e)}catch{return po}return Lg(t)?t:po}var Xt,oe,go,fl,Tn=0,xl=[],le=W,pl=le.__b,gl=le.__r,ml=le.diffed,vl=le.__c,yl=le.unmount,wl=le.__;function Cr(e,t){le.__h&&le.__h(oe,e,Tn||t),Tn=0;var n=oe.__H||(oe.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function V(e){return Tn=1,Pg(kl,e)}function Pg(e,t,n){var r=Cr(Xt++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):kl(void 0,t),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=oe,!oe.__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};oe.__f=!0;var o=oe.shouldComponentUpdate,a=oe.componentWillUpdate;oe.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)},oe.shouldComponentUpdate=i}return r.__N||r.__}function re(e,t){var n=Cr(Xt++,3);!le.__s&&vo(n.__H,t)&&(n.__=e,n.u=t,oe.__H.__h.push(n))}function At(e,t){var n=Cr(Xt++,4);!le.__s&&vo(n.__H,t)&&(n.__=e,n.u=t,oe.__h.push(n))}function ee(e){return Tn=5,be(function(){return{current:e}},[])}function be(e,t){var n=Cr(Xt++,7);return vo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function _l(e,t){return Tn=8,be(function(){return e},t)}function Dg(){for(var e;e=xl.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Rr),t.__h.some(mo),t.__h=[]}catch(n){t.__h=[],le.__e(n,e.__v)}}}le.__b=function(e){oe=null,pl&&pl(e)},le.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),wl&&wl(e,t)},le.__r=function(e){gl&&gl(e),Xt=0;var t=(oe=e.__c).__H;t&&(go===oe?(t.__h=[],oe.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Rr),t.__h.some(mo),t.__h=[],Xt=0)),go=oe},le.diffed=function(e){ml&&ml(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xl.push(t)!==1&&fl===le.requestAnimationFrame||((fl=le.requestAnimationFrame)||Ig)(Dg)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),go=oe=null},le.__c=function(e,t){t.some(function(n){try{n.__h.some(Rr),n.__h=n.__h.filter(function(r){return!r.__||mo(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],le.__e(r,n.__v)}}),vl&&vl(e,t)},le.unmount=function(e){yl&&yl(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Rr(r)}catch(i){t=i}}),n.__H=void 0,t&&le.__e(t,n.__v))};var bl=typeof requestAnimationFrame=="function";function Ig(e){var t,n=function(){clearTimeout(r),bl&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);bl&&(t=requestAnimationFrame(n))}function Rr(e){var t=oe,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),oe=t}function mo(e){var t=oe;e.__c=e.__(),oe=t}function vo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function kl(e,t){return typeof t=="function"?t(e):t}var rt=(e,t)=>fetch(e,{...t?.method===void 0?{}:{method:t.method},...t?.headers===void 0?{}:{headers:t.headers},...t?.body===void 0?{}:{body:t.body},credentials:"same-origin"});function Nr(e,t=!1){return{ok:!0,data:e,cached:t}}function Ee(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function yo(e){return e===403?"auth":e===404?"missing":"server"}function wo(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function An(e,t,n,r){let i;try{i=await e(t,r)}catch(a){return Ee("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Ee(yo(i.status),i.status,wo(i.status));let o;try{o=await i.json()}catch{return Ee("malformed",i.status,"response was not valid JSON")}return n(o)?Nr(o):Ee("malformed",i.status,"response did not match the expected shape")}function it(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mg(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Gg(e){if(!it(e)||typeof e.stamp!="string")return!1;let t=e.model;return!it(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:it(e.tags)&&it(e.dangling)}function Og(e){if(!it(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return Mg(e.tags)}function Rn(e){return it(e)&&typeof e.revision=="string"&&Og(e.note)}function El(e){return it(e)&&e.deleted===!0}function Fg(e){return!it(e)||typeof e.error!="string"?!1:e.reason==="collision"?typeof e.slug=="string":e.reason!=="conflict"?!1:Rn(e.current)}function zg(e){return it(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function Sl(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.ok===!0&&typeof t.path=="string"}function $g(e){return it(e)&&typeof e.opened=="boolean"}async function Tl(e,t=null){let n=t===null?void 0:{"if-none-match":`"${t.stamp}"`},r;try{r=await e("/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 t===null?Ee("malformed",304,"server sent 304 for an unconditional request"):Nr(t,!0);if(!r.ok)return Ee(yo(r.status),r.status,wo(r.status));let i;try{i=await r.json()}catch{return Ee("malformed",r.status,"response was not valid JSON")}return Gg(i)?Nr(i):Ee("malformed",r.status,"response did not match the expected shape")}function Al(e,t){return An(e,`/api/note/${encodeURIComponent(t)}`,Rn)}function Lr(e,t=""){return`/api/note/${encodeURIComponent(e)}${t}`}function bo(e,t){return{method:e,headers:{"content-type":"application/json"},body:JSON.stringify(t)}}async function Cn(e,t,n,r){let i;try{i=await e(t,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 Fg(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(yo(i.status),i.status,wo(i.status));let o;try{o=await i.json()}catch{return Ee("malformed",i.status,"response was not valid JSON")}return n(o)?Nr(o):Ee("malformed",i.status,"response did not match the expected shape")}function Rl(e,t,n){return Cn(e,Lr(t),Rn,bo("POST",n))}function Cl(e,t,n,r){return Cn(e,Lr(t,"/rename"),Rn,bo("POST",{slug:n,...r!==void 0?{title:r}:{}}))}function Nl(e,t,n){return Cn(e,Lr(t,"/move"),Rn,bo("POST",{targetFolder:n}))}function xo(e,t){return An(e,"/api/folder",Sl,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:t})})}function Ll(e,t){return Cn(e,Lr(t),El,{method:"DELETE"})}function Pl(e,t){let n=t.split("/").map(encodeURIComponent).join("/");return Cn(e,`/api/folder/${n}`,El,{method:"DELETE"})}function Dl(e,t,n){let r=t.split("/").map(encodeURIComponent).join("/");return An(e,`/api/folder/${r}/rename`,Sl,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({newPath:n})})}function Il(e,t){return An(e,`/api/search?q=${encodeURIComponent(t)}`,zg)}function Ml(e,t){return An(e,"/api/open",$g,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}var Gl="(prefers-color-scheme: light)";function Pr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(Gl).matches?"light":"dark"}function Ol(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(Gl);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function Ug(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ct(e){var t=Ug(e,"string");return typeof t=="symbol"?t:t+""}function he(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fl(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Ct(r.key),r)}}function fe(e,t,n){return t&&Fl(e.prototype,t),n&&Fl(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Rt(e){return Rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rt(e)}function zl(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zl=function(){return!!e})()}function Hg(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Bg(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Hg(e)}function Se(e,t,n){return t=Rt(t),Bg(e,zl()?Reflect.construct(t,n||[],Rt(e).constructor):t.apply(e,n))}function _o(e,t){return _o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},_o(e,t)}function Te(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_o(e,t)}function Wg(e){if(Array.isArray(e))return e}function Kg(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);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 Dr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function To(e,t){if(e){if(typeof e=="string")return Dr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Dr(e,t):void 0}}function Vg(){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
|
|
21
|
+
"use strict";(()=>{var Vh=Object.create;var Oa=Object.defineProperty;var jh=Object.getOwnPropertyDescriptor;var qh=Object.getOwnPropertyNames;var Yh=Object.getPrototypeOf,Zh=Object.prototype.hasOwnProperty;var Fa=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var Xh=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qh(e))!Zh.call(t,i)&&i!==n&&Oa(t,i,{get:()=>e[i],enumerable:!(r=jh(e,i))||r.enumerable});return t};var on=(t,e,n)=>(n=t!=null?Vh(Yh(t)):{},Xh(e||!t||!t.__esModule?Oa(n,"default",{value:t,enumerable:!0}):n,t));var sr=Fa((Ab,Hi)=>{"use strict";var $t=typeof Reflect=="object"?Reflect:null,qs=$t&&typeof $t.apply=="function"?$t.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},or;$t&&typeof $t.ownKeys=="function"?or=$t.ownKeys:Object.getOwnPropertySymbols?or=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:or=function(e){return Object.getOwnPropertyNames(e)};function np(t){console&&console.warn&&console.warn(t)}var Zs=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}Hi.exports=W;Hi.exports.once=ap;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var Ys=10;function ar(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 Ys},set:function(t){if(typeof t!="number"||t<0||Zs(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ys=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||Zs(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 Xs(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return Xs(this)};W.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")qs(l,this,n);else for(var u=l.length,d=nl(l,u),r=0;r<u;++r)qs(d[r],this,n);return!0};function Qs(t,e,n,r){var i,o,a;if(ar(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=Xs(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,np(s)}return t}W.prototype.addListener=function(e,n){return Qs(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return Qs(this,e,n,!0)};function rp(){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 Js(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=rp.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return ar(n),this.on(e,Js(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return ar(n),this.prependListener(e,Js(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(ar(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():ip(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 el(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?op(i):nl(i,i.length)}W.prototype.listeners=function(e){return el(this,e,!0)};W.prototype.rawListeners=function(e){return el(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):tl.call(t,e)};W.prototype.listenerCount=tl;function tl(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?or(this._events):[]};function nl(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function ip(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function op(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function ap(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}rl(t,e,o,{once:!0}),e!=="error"&&sp(t,i,{once:!0})})}function sp(t,e,n){typeof t.on=="function"&&rl(t,"error",e,n)}function rl(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 Bi=Fa((Nb,ol)=>{"use strict";ol.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var Xn,B,Ba,Qh,ot,za,Wa,Ka,gi,Kn,an,Va,yi,mi,vi,Jh,qn={},Yn=[],ef=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Qn=Array.isArray;function Ye(t,e){for(var n in e)t[n]=e[n];return t}function wi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function tf(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?Xn.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 Vn(t,a,r,i,null)}function Vn(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??++Ba,__i:-1,__u:0};return i==null&&B.vnode!=null&&B.vnode(o),o}function at(t){return t.children}function jn(t,e){this.props=t,this.context=e}function mt(t,e){if(e==null)return t.__?mt(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"?mt(t):null}function nf(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=Ye({},e);o.__v=e.__v+1,B.vnode&&B.vnode(o),bi(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??mt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,Xa(r,o,i),e.__e=e.__=null,o.__e!=n&&ja(o)}}function ja(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}),ja(t)}function $a(t){(!t.__d&&(t.__d=!0)&&ot.push(t)&&!Zn.__r++||za!=B.debounceRendering)&&((za=B.debounceRendering)||Wa)(Zn)}function Zn(){try{for(var t,e=1;ot.length;)ot.length>e&&ot.sort(Ka),t=ot.shift(),e=ot.length,nf(t)}finally{ot.length=Zn.__r=0}}function qa(t,e,n,r,i,o,a,s,l,u,d){var h,c,f,g,v,m,y=r&&r.__k||Yn,b=e.length;for(l=rf(n,e,y,l,b),h=0;h<b;h++)(f=n.__k[h])!=null&&(c=f.__i!=-1&&y[f.__i]||qn,f.__i=h,m=bi(t,f,c,i,o,a,s,l,u,d),g=f.__e,f.ref&&c.ref!=f.ref&&(c.ref&&xi(c.ref,null,f),d.push(f.ref,f.__c||g,f)),v==null&&g!=null&&(v=g),4&f.__u?(l=Ya(f,l,t),c.__e&&(c.__e=null)):typeof f.type=="function"&&m!==void 0?l=m:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=v,l}function rf(t,e,n,r,i){var o,a,s,l,u,d=n.length,h=d,c=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]=Vn(null,a,null,null,null):Qn(a)?a=t.__k[o]=Vn(at,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=Vn(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+c,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=of(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>d?c--:i<d&&c++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?c--:u==l+1?c++:(u>l?c--:c++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<d;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=mt(s)),Ja(s,s));return r}function Ya(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=Ya(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=mt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function of(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],d=u!=null&&(2&u.__u)==0;if(u===null&&s==null||d&&s==u.key&&l==u.type)return n;if(r>(d?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 Ua(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||ef.test(e)?n:n+"px"}function Wn(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||Ua(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Ua(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(Va,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[an]=r[an]:(n[an]=yi,t.addEventListener(e,o?vi:mi,o)):t.removeEventListener(e,o?vi:mi,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 Ha(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[Kn]==null)e[Kn]=yi++;else if(e[Kn]<n[an])return;return n(B.event?B.event(e):e)}}}function bi(t,e,n,r,i,o,a,s,l,u){var d,h,c,f,g,v,m,y,b,k,_,N,D,I,z,F,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(d=B.__b)&&d(e);e:if(typeof G=="function"){h=a.length;try{if(b=e.props,k=G.prototype&&G.prototype.render,_=(d=G.contextType)&&r[d.__c],N=d?_?_.props.value:d.__:r,n.__c?y=(c=e.__c=n.__c).__=c.__E:(k?e.__c=c=new G(b,N):(e.__c=c=new jn(b,N),c.constructor=G,c.render=sf),_&&_.sub(c),c.state||(c.state={}),c.__n=r,f=c.__d=!0,c.__h=[],c._sb=[]),k&&c.__s==null&&(c.__s=c.state),k&&G.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ye({},c.__s)),Ye(c.__s,G.getDerivedStateFromProps(b,c.__s))),g=c.props,v=c.state,c.__v=e,f)k&&G.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),k&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(k&&G.getDerivedStateFromProps==null&&b!==g&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,N),e.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,N)===!1){e.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),Yn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&a.push(c),s=mt(n);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,N),k&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(g,v,m)})}if(c.context=N,c.props=b,c.__P=t,c.__e=!1,D=B.__r,I=0,k)c.state=c.__s,c.__d=!1,D&&D(e),d=c.render(c.props,c.state,c.context),Yn.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,D&&D(e),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++I<25);c.state=c.__s,c.getChildContext!=null&&(r=Ye(Ye({},r),c.getChildContext())),k&&!f&&c.getSnapshotBeforeUpdate!=null&&(m=c.getSnapshotBeforeUpdate(g,v)),z=d!=null&&d.type===at&&d.key==null?Qa(d.props.children):d,s=qa(t,Qn(z)?z:[z],e,n,r,i,o,a,s,l,u),c.base=e.__e,e.__u&=-161,c.__h.length&&a.push(c),y&&(c.__E=c.__=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--;)wi(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||Za(e),B.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=af(n.__e,e,n,r,i,o,a,l,u);return(d=B.diffed)&&d(e),128&e.__u?void 0:s}function Za(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Za))}function Xa(t,e,n){for(var r=0;r<n.length;r++)xi(n[r],n[++r],n[++r]);B.__c&&B.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){B.__e(o,i.__v)}})}function Qa(t){return typeof t!="object"||t==null||t.__b>0?t:Qn(t)?t.map(Qa):t.constructor!==void 0?null:Ye({},t)}function af(t,e,n,r,i,o,a,s,l){var u,d,h,c,f,g,v,m=n.props||qn,y=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(y);t=document.createElementNS(i,b,y.is&&y),s&&(B.__m&&B.__m(e,o),s=!1),o=null}if(b==null)m===y||s&&t.data==y||(t.data=y);else{if(o=b=="textarea"&&y.defaultValue!=null?null:o&&Xn.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 y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||Wn(t,u,null,f,i);for(u in y)f=y[u],u=="children"?c=f:u=="dangerouslySetInnerHTML"?d=f:u=="value"?g=f:u=="checked"?v=f:s&&typeof f!="function"||m[u]===f||Wn(t,u,f,m[u],i);if(d)s||h&&(d.__html==h.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(h&&(t.innerHTML=""),qa(e.type=="template"?t.content:t,Qn(c)?c:[c],e,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&mt(n,0),s,l),o!=null)for(u=o.length;u--;)wi(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!=m[u])&&Wn(t,u,g,m[u],i),u="checked",v!=null&&v!=t[u]&&Wn(t,u,v,m[u],i))}return t}function xi(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){B.__e(i,n)}}function Ja(t,e,n){var r,i;if(B.unmount&&B.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||xi(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){B.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Ja(r[i],e,n||typeof t.type!="function");n||wi(t.__e),t.__c=t.__=t.__e=void 0}function sf(t,e,n){return this.constructor(t,n)}function es(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),B.__&&B.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],bi(e,t=(!r&&n||e).__k=tf(at,null,[t]),i||qn,qn,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Xn.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),Xa(o,t,a),t.props.children=null}Xn=Yn.slice,B={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},Ba=0,Qh=function(t){return t!=null&&t.constructor===void 0},jn.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ye({},this.state),typeof t=="function"&&(t=t(Ye({},n),this.props)),t&&Ye(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),$a(this))},jn.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),$a(this))},jn.prototype.render=at,ot=[],Wa=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ka=function(t,e){return t.__v.__b-e.__v.__b},Zn.__r=0,gi=Math.random().toString(8),Kn="__d"+gi,an="__a"+gi,Va=/(PointerCapture)$|Capture$/i,yi=0,mi=Ha(!1),vi=Ha(!0),Jh=0;var ts="weave-bootstrap";var _i={cwd:""};function lf(t){return typeof t!="object"||t===null?!1:typeof t.cwd=="string"}function ns(t){if(t===null||t.trim()==="")return _i;let e;try{e=JSON.parse(t)}catch{return _i}return lf(e)?e:_i}var Ot,ee,ki,rs,sn=0,ds=[],ne=B,is=ne.__b,os=ne.__r,as=ne.diffed,ss=ne.__c,ls=ne.unmount,us=ne.__;function er(t,e){ne.__h&&ne.__h(ee,t,sn||e),sn=0;var n=ee.__H||(ee.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function he(t){return sn=1,uf(fs,t)}function uf(t,e,n){var r=er(Ot++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):fs(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=ee,!ee.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var d=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){d=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(h=!0)}}),o){var c=o.call(this,s,l,u);return d?c||h:c}return!d||h};ee.__f=!0;var o=ee.shouldComponentUpdate,a=ee.componentWillUpdate;ee.componentWillUpdate=function(s,l,u){if(this.__e){var d=o;o=void 0,i(s,l,u),o=d}a&&a.call(this,s,l,u)},ee.shouldComponentUpdate=i}return r.__N||r.__}function ie(t,e){var n=er(Ot++,3);!ne.__s&&Ti(n.__H,e)&&(n.__=t,n.u=e,ee.__H.__h.push(n))}function Si(t,e){var n=er(Ot++,4);!ne.__s&&Ti(n.__H,e)&&(n.__=t,n.u=e,ee.__h.push(n))}function re(t){return sn=5,vt(function(){return{current:t}},[])}function vt(t,e){var n=er(Ot++,7);return Ti(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function hs(t,e){return sn=8,vt(function(){return t},e)}function cf(){for(var t;t=ds.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(Jn),e.__h.some(Ei),e.__h=[]}catch(n){e.__h=[],ne.__e(n,t.__v)}}}ne.__b=function(t){ee=null,is&&is(t)},ne.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),us&&us(t,e)},ne.__r=function(t){os&&os(t),Ot=0;var e=(ee=t.__c).__H;e&&(ki===ee?(e.__h=[],ee.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(Jn),e.__h.some(Ei),e.__h=[],Ot=0)),ki=ee},ne.diffed=function(t){as&&as(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(ds.push(e)!==1&&rs===ne.requestAnimationFrame||((rs=ne.requestAnimationFrame)||df)(cf)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),ki=ee=null},ne.__c=function(t,e){e.some(function(n){try{n.__h.some(Jn),n.__h=n.__h.filter(function(r){return!r.__||Ei(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],ne.__e(r,n.__v)}}),ss&&ss(t,e)},ne.unmount=function(t){ls&&ls(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Jn(r)}catch(i){e=i}}),n.__H=void 0,e&&ne.__e(e,n.__v))};var cs=typeof requestAnimationFrame=="function";function df(t){var e,n=function(){clearTimeout(r),cs&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);cs&&(e=requestAnimationFrame(n))}function Jn(t){var e=ee,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ee=e}function Ei(t){var e=ee;t.__c=t.__(),ee=e}function Ti(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function fs(t,e){return typeof e=="function"?e(t):e}var tr=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},...e?.signal===void 0?{}:{signal:e.signal},credentials:"same-origin"});function Ai(t,e=!1){return{ok:!0,data:t,cached:e}}function Ze(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function ps(t){return t===403?"auth":t===404?"missing":"server"}function gs(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function Ri(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Ze("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Ze(ps(i.status),i.status,gs(i.status));let o;try{o=await i.json()}catch{return Ze("malformed",i.status,"response was not valid JSON")}return n(o)?Ai(o):Ze("malformed",i.status,"response did not match the expected shape")}function st(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function hf(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function ff(t){if(!st(t)||typeof t.stamp!="string")return!1;let e=t.model;return!st(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:st(t.tags)&&st(t.dangling)}function pf(t){if(!st(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return hf(t.tags)}function gf(t){return st(t)&&pf(t.note)}function mf(t){return st(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function vf(t){return st(t)&&typeof t.opened=="boolean"}async function ms(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return Ze("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Ze("malformed",304,"server sent 304 for an unconditional request"):Ai(e,!0);if(!r.ok)return Ze(ps(r.status),r.status,gs(r.status));let i;try{i=await r.json()}catch{return Ze("malformed",r.status,"response was not valid JSON")}return ff(i)?Ai(i):Ze("malformed",r.status,"response did not match the expected shape")}function vs(t,e){return Ri(t,`/api/note/${encodeURIComponent(e)}`,gf)}function ys(t,e,n){return Ri(t,`/api/search?q=${encodeURIComponent(e)}`,mf,n===void 0?void 0:{signal:n})}function ws(t,e){return Ri(t,"/api/open",vf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}var bs="(prefers-color-scheme: light)";function nr(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(bs).matches?"light":"dark"}function xs(t,e){if(typeof t.matchMedia!="function")return()=>{};let n=t.matchMedia(bs);if(typeof n.addEventListener!="function")return()=>{};let r=()=>e(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function yf(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function wt(t){var e=yf(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 _s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,wt(r.key),r)}}function le(t,e,n){return e&&_s(t.prototype,e),n&&_s(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function yt(t){return yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},yt(t)}function ks(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ks=function(){return!!t})()}function wf(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function bf(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 wf(t)}function be(t,e,n){return e=yt(e),bf(t,ks()?Reflect.construct(e,n||[],yt(t).constructor):e.apply(t,n))}function Ci(t,e){return Ci=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Ci(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&&Ci(t,e)}function xf(t){if(Array.isArray(t))return t}function _f(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(d){u=!0,i=d}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function rr(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 Di(t,e){if(t){if(typeof t=="string")return rr(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)?rr(t,e):void 0}}function kf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
22
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lt(t,e){return xf(t)||_f(t,e)||Di(t,e)||kf()}var Ni={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 Es=new Int8Array(4),Li=new Int32Array(Es.buffer,0,1),Ef=new Float32Array(Es.buffer,0,1),Sf=/^\s*rgba?\s*\(/,Tf=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Af(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(Sf.test(t)){var o=t.match(Tf);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 Ft={};for(ln in Ni)Ft[ln]=zt(Ni[ln]),Ft[Ni[ln]]=Ft[ln];var ln;function Ss(t,e,n,r,i){return Li[0]=r<<24|n<<16|e<<8|t,i&&(Li[0]=Li[0]&4278190079),Ef[0]}function zt(t){if(t=t.toLowerCase(),typeof Ft[t]<"u")return Ft[t];var e=Af(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=Ss(n,r,i,o,!0);return Ft[t]=a,a}var Pi={};function Ii(t){if(typeof Pi[t]<"u")return Pi[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=Ss(e,n,r,i,!0);return Pi[t]=o,o}function Gi(t,e,n,r){return n+(e<<8)+(t<<16)}function Mi(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=lt(l,4),d=u[0],h=u[1],c=u[2],f=u[3];return[d,h,c,f]}function S(t,e,n){return(e=wt(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ts(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 L(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ts(Object(n),!0).forEach(function(r){S(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ts(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rf(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=yt(t))!==null;);return t}function zi(){return zi=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=Rf(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},zi.apply(null,arguments)}function Ds(t,e,n,r){var i=zi(yt(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function Cf(t){return t.normalized?1:t.size}function Oi(t){var e=0;return t.forEach(function(n){return e+=Cf(n)}),e}function Is(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
23
|
`.concat(a,`
|
|
26
|
-
`).concat(n))}return i}function
|
|
27
|
-
`,
|
|
24
|
+
`).concat(n))}return i}function Nf(t,e){return Is("VERTEX",t,e)}function Lf(t,e){return Is("FRAGMENT",t,e)}function Pf(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 As(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 Rs=`#define PICKING_MODE
|
|
25
|
+
`,Df=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 Gs=(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=Oi(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,Rs+i.VERTEX_SHADER_SOURCE,Rs+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Oi(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(){As(this.normalProgram),this.pickProgram&&(As(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=Nf(r,i),d=Lf(r,o),h=Pf(r,[u,d]),c={};s.UNIFORMS.forEach(function(v){var m=r.getUniformLocation(h,v);m&&(c[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:c,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:d}}},{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=Df[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:Oi(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 d=l.getExtension("ANGLE_instanced_arrays");d&&d.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(L(L({},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 If=(function(t){function e(){return se(this,e),be(this,e,arguments)}return xe(e,t),le(e,[{key:"kill",value:function(){Ds(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(Ii(r),a,o)}}])})(Gs);var $i=(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=be(this,e,[].concat(i)),S(n,"drawLabel",void 0),n}return xe(e,t),le(e,[{key:"kill",value:function(){Ds(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(Ii(r),l,o,a,s)}}])})(Gs);function Gf(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 Ms(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 d=n.size,h=r.size,c=n.x,f=n.y,g=r.x,v=r.y,m=(c+g)/2,y=(f+v)/2,b=g-c,k=v-f,_=Math.sqrt(b*b+k*k);if(!(_<d+h)){c+=b*d/_,f+=k*d/_,g-=b*h/_,v-=k*h/_,m=(c+g)/2,y=(f+v)/2,b=g-c,k=v-f,_=Math.sqrt(b*b+k*k);var N=t.measureText(u).width;if(N>_){var D="…";for(u=u+D,N=t.measureText(u).width;N>_&&u.length>1;)u=u.slice(0,-2)+D,N=t.measureText(u).width;if(u.length<4)return}var I;b>0?k>0?I=Math.acos(b/_):I=Math.asin(k/_):k>0?I=Math.acos(b/_)+Math.PI:I=Math.asin(b/_)+Math.PI/2,t.save(),t.translate(m,y),t.rotate(I),t.fillText(u,-N/2,e.size/2+o),t.restore()}}}function Ui(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 Os(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),d=Math.max(e.size,r/2)+a,h=Math.asin(u/2/d),c=Math.sqrt(Math.abs(Math.pow(d,2)-Math.pow(u/2,2)));t.beginPath(),t.moveTo(e.x+c,e.y+u/2),t.lineTo(e.x+d+l,e.y+u/2),t.lineTo(e.x+d+l,e.y-u/2),t.lineTo(e.x+c,e.y-u/2),t.arc(e.x,e.y,d,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,Ui(t,e,n)}var Mf=`
|
|
28
26
|
precision highp float;
|
|
29
27
|
|
|
30
28
|
varying vec4 v_color;
|
|
@@ -56,7 +54,7 @@ void main(void) {
|
|
|
56
54
|
gl_FragColor = mix(v_color, transparent, t);
|
|
57
55
|
#endif
|
|
58
56
|
}
|
|
59
|
-
`,
|
|
57
|
+
`,Of=Mf,Ff=`
|
|
60
58
|
attribute vec4 a_id;
|
|
61
59
|
attribute vec4 a_color;
|
|
62
60
|
attribute vec2 a_position;
|
|
@@ -97,7 +95,7 @@ void main() {
|
|
|
97
95
|
|
|
98
96
|
v_color.a *= bias;
|
|
99
97
|
}
|
|
100
|
-
`,
|
|
98
|
+
`,zf=Ff,Fs=WebGLRenderingContext,Cs=Fs.UNSIGNED_BYTE,Fi=Fs.FLOAT,$f=["u_sizeRatio","u_correctionRatio","u_matrix"],cn=(function(t){function e(){return se(this,e),be(this,e,arguments)}return xe(e,t),le(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:zf,FRAGMENT_SHADER_SOURCE:Of,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$f,ATTRIBUTES:[{name:"a_position",size:2,type:Fi},{name:"a_size",size:1,type:Fi},{name:"a_color",size:4,type:Cs,normalized:!0},{name:"a_id",size:4,type:Cs,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Fi}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=zt(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)}}])})(If);S(cn,"ANGLE_1",0);S(cn,"ANGLE_2",2*Math.PI/3);S(cn,"ANGLE_3",4*Math.PI/3);var Uf=`
|
|
101
99
|
precision mediump float;
|
|
102
100
|
|
|
103
101
|
varying vec4 v_color;
|
|
@@ -105,7 +103,7 @@ varying vec4 v_color;
|
|
|
105
103
|
void main(void) {
|
|
106
104
|
gl_FragColor = v_color;
|
|
107
105
|
}
|
|
108
|
-
`,
|
|
106
|
+
`,Hf=Uf,Bf=`
|
|
109
107
|
attribute vec2 a_position;
|
|
110
108
|
attribute vec2 a_normal;
|
|
111
109
|
attribute float a_radius;
|
|
@@ -171,7 +169,7 @@ void main() {
|
|
|
171
169
|
|
|
172
170
|
v_color.a *= bias;
|
|
173
171
|
}
|
|
174
|
-
`,
|
|
172
|
+
`,Wf=Bf,zs=WebGLRenderingContext,Ns=zs.UNSIGNED_BYTE,ir=zs.FLOAT,Kf=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],$s={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Us(t){var e=L(L({},$s),t||{});return(function(n){function r(){return se(this,r),be(this,r,arguments)}return xe(r,n),le(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Wf,FRAGMENT_SHADER_SOURCE:Hf,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Kf,ATTRIBUTES:[{name:"a_position",size:2,type:ir},{name:"a_normal",size:2,type:ir},{name:"a_radius",size:1,type:ir},{name:"a_color",size:4,type:Ns,normalized:!0},{name:"a_id",size:4,type:Ns,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:ir}],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 d=[l,s];s=d[0],l=d[1]}var h=u.size||1,c=l.size||1,f=s.x,g=s.y,v=l.x,m=l.y,y=zt(u.color),b=v-f,k=m-g,_=b*b+k*k,N=0,D=0;_&&(_=1/Math.sqrt(_),N=-k*_*h,D=b*_*h);var I=this.array;I[a++]=v,I[a++]=m,I[a++]=-N,I[a++]=-D,I[a++]=c,I[a++]=y,I[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,d=l.u_sizeRatio,h=l.u_correctionRatio,c=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,g=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(d,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(c,o.minEdgeThickness),s.uniform1f(f,e.lengthToThicknessRatio),s.uniform1f(g,e.widenessToThicknessRatio)}}])})($i)}var Eb=Us();var Vf=`
|
|
175
173
|
precision mediump float;
|
|
176
174
|
|
|
177
175
|
varying vec4 v_color;
|
|
@@ -197,7 +195,7 @@ void main(void) {
|
|
|
197
195
|
gl_FragColor = mix(v_color, transparent, t);
|
|
198
196
|
#endif
|
|
199
197
|
}
|
|
200
|
-
`,
|
|
198
|
+
`,Hs=Vf,jf=`
|
|
201
199
|
attribute vec4 a_id;
|
|
202
200
|
attribute vec4 a_color;
|
|
203
201
|
attribute vec2 a_normal;
|
|
@@ -265,7 +263,7 @@ void main() {
|
|
|
265
263
|
|
|
266
264
|
v_color.a *= bias;
|
|
267
265
|
}
|
|
268
|
-
`,
|
|
266
|
+
`,qf=jf,Bs=WebGLRenderingContext,Ls=Bs.UNSIGNED_BYTE,bt=Bs.FLOAT,Yf=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Zf={lengthToThicknessRatio:$s.lengthToThicknessRatio};function Ws(t){var e=L(L({},Zf),t||{});return(function(n){function r(){return se(this,r),be(this,r,arguments)}return xe(r,n),le(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:qf,FRAGMENT_SHADER_SOURCE:Hs,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Yf,ATTRIBUTES:[{name:"a_positionStart",size:2,type:bt},{name:"a_positionEnd",size:2,type:bt},{name:"a_normal",size:2,type:bt},{name:"a_color",size:4,type:Ls,normalized:!0},{name:"a_id",size:4,type:Ls,normalized:!0},{name:"a_radius",size:1,type:bt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:bt},{name:"a_normalCoef",size:1,type:bt},{name:"a_radiusCoef",size:1,type:bt}],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 d=u.size||1,h=s.x,c=s.y,f=l.x,g=l.y,v=zt(u.color),m=f-h,y=g-c,b=l.size||1,k=m*m+y*y,_=0,N=0;k&&(k=1/Math.sqrt(k),_=-y*k*d,N=m*k*d);var D=this.array;D[a++]=h,D[a++]=c,D[a++]=f,D[a++]=g,D[a++]=_,D[a++]=N,D[a++]=v,D[a++]=o,D[a++]=b}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,d=l.u_zoomRatio,h=l.u_feather,c=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(d,o.zoomRatio),s.uniform1f(g,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(c,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(v,o.minEdgeThickness),s.uniform1f(m,e.lengthToThicknessRatio)}}])})($i)}var Sb=Ws();function Xf(t){return Gf([Ws(t),Us(t)])}var Qf=Xf(),Ks=Qf,Jf=`
|
|
269
267
|
attribute vec4 a_id;
|
|
270
268
|
attribute vec4 a_color;
|
|
271
269
|
attribute vec2 a_normal;
|
|
@@ -330,80 +328,80 @@ void main() {
|
|
|
330
328
|
|
|
331
329
|
v_color.a *= bias;
|
|
332
330
|
}
|
|
333
|
-
`,km=_m,lu=WebGLRenderingContext,ql=lu.UNSIGNED_BYTE,Ln=lu.FLOAT,Em=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],uu=(function(e){function t(){return he(this,t),Se(this,t,arguments)}return Te(t,e),fe(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:km,FRAGMENT_SHADER_SOURCE:iu,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Em,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ln},{name:"a_positionEnd",size:2,type:Ln},{name:"a_normal",size:2,type:Ln},{name:"a_color",size:4,type:ql,normalized:!0},{name:"a_id",size:4,type:ql,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ln},{name:"a_normalCoef",size:1,type:Ln}],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=Qt(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)}}])})(Do);var bu=En(Or()),Fr=(function(e){function t(){var n;return he(this,t),n=Se(this,t),n.rawEmitter=n,n}return Te(t,e),fe(t)})(bu.EventEmitter);var Eu=En(Go());var Lm=function(t){return t},Pm=function(t){return t*t},Dm=function(t){return t*(2-t)},Im=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},Mm=function(t){return t*t*t},Gm=function(t){return--t*t*t+1},Om=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},Su={linear:Lm,quadraticIn:Pm,quadraticOut:Dm,quadraticInOut:Im,cubicIn:Mm,cubicOut:Gm,cubicInOut:Om},Tu={easing:"quadraticInOut",duration:150};function Oe(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function zr(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function _u(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function ku(e,t,n){return e[6]=t,e[7]=n,e}function wt(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=t[0],d=t[1],f=t[2],g=t[3],m=t[4],v=t[5],w=t[6],b=t[7],E=t[8];return e[0]=h*n+d*o+f*l,e[1]=h*r+d*a+f*u,e[2]=h*i+d*s+f*c,e[3]=g*n+m*o+v*l,e[4]=g*r+m*a+v*u,e[5]=g*i+m*s+v*c,e[6]=w*n+b*o+E*l,e[7]=w*r+b*a+E*u,e[8]=w*i+b*s+E*c,e}function $r(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],a=e[4],s=e[6],l=e[7],u=t.x,c=t.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Fm(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function en(e,t,n,r,i){var o=e.angle,a=e.ratio,s=e.x,l=e.y,u=t.width,c=t.height,h=Oe(),d=Math.min(u,c)-2*r,f=Fm(t,n);return i?(wt(h,ku(Oe(),s,l)),wt(h,zr(Oe(),a)),wt(h,_u(Oe(),o)),wt(h,zr(Oe(),u/d/2/f,c/d/2/f))):(wt(h,zr(Oe(),2*(d/u)*f,2*(d/c)*f)),wt(h,_u(Oe(),-o)),wt(h,zr(Oe(),1/a)),wt(h,ku(Oe(),-s,-l))),h}function Au(e,t,n){var r=$r(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Ru(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,a){var s=a.x,l=a.y;s<t&&(t=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[t,n],y:[r,i]}}function Cu(e){if(!(0,Eu.default)(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Nu(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Oo(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Fo(e,t,n){return n.sort(function(r,i){var o=t(r)||0,a=t(i)||0;return o<a?-1:o>a?1:0})}function zo(e){var t=yt(e.x,2),n=t[0],r=t[1],i=yt(e.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 Ur(e){"@babel/helpers - typeof";return Ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ur(e)}function $o(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function Hr(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var Br={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:Ql,defaultDrawNodeLabel:Io,defaultDrawNodeHover:Jl,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:{}},zm={circle:Pn},$m={arrow:su,line:uu};function Wr(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Lu(e){var t=Hr({},Br,e);return t.nodeProgramClasses=Hr({},zm,t.nodeProgramClasses),t.edgeProgramClasses=Hr({},$m,t.edgeProgramClasses),t}var cE=En(Or()),dE=En(Go()),Kr=1.5,Pu=(function(e){function t(){var n;return he(this,t),n=Se(this,t),T(n,"x",.5),T(n,"y",.5),T(n,"angle",0),T(n,"ratio",1),T(n,"minRatio",null),T(n,"maxRatio",null),T(n,"enabledZooming",!0),T(n,"enabledPanning",!0),T(n,"enabledRotation",!0),T(n,"clean",null),T(n,"nextFrame",null),T(n,"previousState",null),T(n,"enabled",!0),n.previousState=n.getState(),n}return Te(t,e),fe(t,[{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(M(M({},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=M(M({},Tu),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:Su[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||Kr)},r):this.animate({ratio:this.ratio/Kr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Kr)},r):this.animate({ratio:this.ratio*Kr})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(Fr);function Ke(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function lt(e,t){var n=M(M({},Ke(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Dn(e){var t="x"in e?e:M(M({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function Um(e,t){return M(M({},lt(e,t)),{},{delta:Fu(e)})}var Hm=2;function Vr(e){for(var t=[],n=0,r=Math.min(e.length,Hm);n<r;n++)t.push(e[n]);return t}function In(e,t,n){var r={touches:Vr(e.touches).map(function(i){return Ke(i,n)}),previousTouches:t.map(function(i){return Ke(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Fu(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var zu=(function(e){function t(n,r){var i;return he(this,t),i=Se(this,t),i.container=n,i.renderer=r,i}return Te(t,e),fe(t)})(Fr),Bm=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Wm=Bm.reduce(function(e,t){return M(M({},e),{},T({},t,Br[t]))},{}),Km=(function(e){function t(n,r){var i;return he(this,t),i=Se(this,t,[n,r]),T(i,"enabled",!0),T(i,"draggedEvents",0),T(i,"downStartTime",null),T(i,"lastMouseX",null),T(i,"lastMouseY",null),T(i,"isMouseDown",!1),T(i,"isMoving",!1),T(i,"movingTimeout",null),T(i,"startCameraState",null),T(i,"clicks",0),T(i,"doubleClickTimeout",null),T(i,"currentWheelDirection",0),T(i,"settings",Wm),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 Te(t,e),fe(t,[{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",lt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",lt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=lt(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(Ke(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=Ke(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",lt(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=Ke(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",lt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=lt(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=Ke(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",lt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",lt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Fu(r);if(a){var s=Um(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(Ke(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}}])})(zu),Vm=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],jm=Vm.reduce(function(e,t){return M(M({},e),{},T({},t,Br[t]))},{}),qm=(function(e){function t(n,r){var i;return he(this,t),i=Se(this,t,[n,r]),T(i,"enabled",!0),T(i,"isMoving",!1),T(i,"hasMoved",!1),T(i,"touchMode",0),T(i,"startTouchesPositions",[]),T(i,"lastTouches",[]),T(i,"lastTap",null),T(i,"settings",jm),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 Te(t,e),fe(t,[{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=Vr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Ke(f,i.container)}),this.touchMode===2){var a=yt(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",In(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",In(r,this.lastTouches,this.container)),!r.touches.length){var s=Ke(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=In(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=In(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Vr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Vr(r.touches),a=o.map(function(Je){return Ke(Je,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=In(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Je,wn){var Ge=i.startTouchesPositions[wn];return Ge&&(Je.x!==Ge.x||Je.y!==Ge.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],k=E.x,I=E.y,D=a[1],N=D.x,z=D.y,U=Math.atan2(z-I,N-k)-this.startTouchesAngle,_=Math.hypot(z-I,N-k)/this.startTouchesDistance,A=u.getBoundedRatio(c.ratio/_);b.ratio=A,b.angle=c.angle+U;var O=this.getDimensions(),B=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ae=Math.min(O.width,O.height)-2*h,ie=ae/O.width,Qe=ae/O.height,Ht=A/ae,He=k-ae/2/ie,Be=I-ae/2/Qe,We=[He*Math.cos(-b.angle)-Be*Math.sin(-b.angle),Be*Math.cos(-b.angle)+He*Math.sin(-b.angle)];He=We[0],Be=We[1],b.x=B.x-He*Ht,b.y=B.y+Be*Ht,u.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(zu);function Ym(e){if(Array.isArray(e))return Dr(e)}function Xm(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Zm(){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 Du(e){return Ym(e)||Xm(e)||To(e)||Zm()}function Qm(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Uo(e,t){if(e==null)return{};var n,r,i=Qm(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Iu=(function(){function e(t,n){he(this,e),this.key=t,this.size=n}return fe(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Mu=(function(){function e(){he(this,e),T(this,"width",0),T(this,"height",0),T(this,"cellSize",0),T(this,"columns",0),T(this,"rows",0),T(this,"cells",{})}return fe(e,[{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 Iu(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(Iu.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 Jm(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.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 Gu=150,Ou=50,ut=Object.prototype.hasOwnProperty;function ev(e,t,n){if(!ut.call(n,"x")||!ut.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". 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=e.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),ut.call(n,"hidden")||(n.hidden=!1),ut.call(n,"highlighted")||(n.highlighted=!1),ut.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function tv(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),ut.call(n,"hidden")||(n.hidden=!1),ut.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var nv=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(he(this,t),i=Se(this,t),T(i,"elements",{}),T(i,"canvasContexts",{}),T(i,"webGLContexts",{}),T(i,"pickingLayers",new Set),T(i,"textures",{}),T(i,"frameBuffers",{}),T(i,"activeListeners",{}),T(i,"labelGrid",new Mu),T(i,"nodeDataCache",{}),T(i,"edgeDataCache",{}),T(i,"nodeProgramIndex",{}),T(i,"edgeProgramIndex",{}),T(i,"nodesWithForcedLabels",new Set),T(i,"edgesWithForcedLabels",new Set),T(i,"nodeExtent",{x:[0,1],y:[0,1]}),T(i,"nodeZExtent",[1/0,-1/0]),T(i,"edgeZExtent",[1/0,-1/0]),T(i,"matrix",Oe()),T(i,"invMatrix",Oe()),T(i,"correctionRatio",1),T(i,"customBBox",null),T(i,"normalizationFunction",zo({x:[0,1],y:[0,1]})),T(i,"graphToViewportRatio",1),T(i,"itemIDsIndex",{}),T(i,"nodeIndices",{}),T(i,"edgeIndices",{}),T(i,"width",0),T(i,"height",0),T(i,"pixelRatio",Oo()),T(i,"pickingDownSizingRatio",2*i.pixelRatio),T(i,"displayedNodeLabels",new Set),T(i,"displayedEdgeLabels",new Set),T(i,"highlightedNodes",new Set),T(i,"hoveredNode",null),T(i,"hoveredEdge",null),T(i,"renderFrame",null),T(i,"renderHighlightedNodesFrame",null),T(i,"needToProcess",!1),T(i,"checkEdgesEventsFrame",null),T(i,"nodePrograms",{}),T(i,"nodeHoverPrograms",{}),T(i,"edgePrograms",{}),i.settings=Lu(o),Wr(i.settings),Cu(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 Pu,i.bindCameraHandlers(),i.mouseCaptor=new Km(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new qm(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Te(t,e),fe(t,[{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=Uo(i,[r].map(Ct));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=Uo(s,[r].map(Ct));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=Uo(i,[r].map(Ct));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=Co(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=Ro.apply(void 0,Du(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=Dn(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",M(M({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",M(M({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",M(M({},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",M(M({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",M(M({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=Dn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Dn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",M(M({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",M(M({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",M({},s))},this.activeListeners.handleEnter=function(o){var a=Dn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",M({},s))};var i=function(a){return function(s){var l=Dn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),M(M({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),M(M({},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=Co(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=Ro.apply(void 0,Du(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=Ru(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=zo(this.customBBox||this.nodeExtent);var d=new Pu,f=en(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},m={},v={},w={},b=1,E=i.nodes(),k=0,I=E.length;k<I;k++){var D=E[k],N=this.nodeDataCache[D],z=i.getNodeAttributes(D);N.x=z.x,N.y=z.y,this.normalizationFunction.applyTo(N),typeof N.label=="string"&&!N.hidden&&this.labelGrid.add(D,N.size,this.framedGraphToViewport(N,{matrix:f})),g[N.type]=(g[N.type]||0)+1}this.labelGrid.organize();for(var U in this.nodePrograms){if(!ut.call(this.nodePrograms,U))throw new Error('Sigma: could not find a suitable program for node type "'.concat(U,'"!'));this.nodePrograms[U].reallocate(g[U]||0),g[U]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(E=Fo(this.nodeZExtent,function(bn){return r.nodeDataCache[bn].zIndex},E));for(var _=0,A=E.length;_<A;_++){var O=E[_];m[O]=b,w[m[O]]={type:"node",id:O},b++;var B=this.nodeDataCache[O];this.addNodeToProgram(O,m[O],g[B.type]++)}for(var ae={},ie=i.edges(),Qe=0,Ht=ie.length;Qe<Ht;Qe++){var He=ie[Qe],Be=this.edgeDataCache[He];ae[Be.type]=(ae[Be.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ie=Fo(this.edgeZExtent,function(bn){return r.edgeDataCache[bn].zIndex},ie));for(var We in this.edgePrograms){if(!ut.call(this.edgePrograms,We))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(We,'"!'));this.edgePrograms[We].reallocate(ae[We]||0),ae[We]=0}for(var Je=0,wn=ie.length;Je<wn;Je++){var Ge=ie[Je];v[Ge]=b,w[v[Ge]]={type:"edge",id:Ge},b++;var X=this.edgeDataCache[Ge];this.addEdgeToProgram(Ge,v[Ge],ae[X.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&&Ur(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=M({},r),u=s||this.nodeExtent,c=yt(u.x,2),h=c[0],d=c[1],f=yt(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,k=-1/0;v.forEach(function(ae){var ie=ae.x,Qe=ae.y;w=Math.min(w,ie),b=Math.max(b,ie),E=Math.min(E,Qe),k=Math.max(k,Qe)});var I=b-w,D=k-E,N=this.getDimensions(),z=N.width,U=N.height,_=0,A=0;if(I>=z?b<z-a?_=b-(z-a):w>a&&(_=w-a):b>z+a?_=b-(z+a):w<-a&&(_=w+a),D>=U?k<U-a?A=k-(U-a):E>a&&(A=E-a):k>U+a?A=k-(U+a):E<-a&&(A=E+a),_||A){var O=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),B=this.viewportToFramedGraph({x:_,y:A},{cameraState:r});_=B.x-O.x,A=B.y-O.y,l.x+=_,l.y+=A}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);$o(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<-Gu||h>this.width+Gu||d<-Ou||d>this.height+Ou)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||g;v(o,M(M({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=Jm({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});$o(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,M(M({key:l},d),{},{size:this.scaleSize(d.size)}),M(M(M({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),M(M(M({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,k=r.nodePrograms[g.type],I=k?.drawHover||E;I(i,M(M({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=en(s,l,u,c),this.invMatrix=en(s,l,u,c,!0),this.correctionRatio=Au(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=ev(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=tv(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 Mu,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=Nu(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=M({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 M({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=M({},this.settings);return this.settings[r]=i,Wr(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=M({},this.settings);return this.settings=M(M({},this.settings),r),Wr(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=Oo(),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(k){return i.addNode(k)}),this.graph.forEachEdge(function(k){return i.addEdge(k)});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(M(M({},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?en(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=$r(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?en(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=$r(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}}])})(Fr),$u=nv;function Uu(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Hu(this.cover(t,n),t,n,e)}function Hu(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o=e._root,a={data:r},s=e._x0,l=e._y0,u=e._x1,c=e._y1,h,d,f,g,m,v,w,b;if(!o)return e._root=a,e;for(;o.length;)if((m=t>=(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,e;if(f=+e._x.call(null,o.data),g=+e._y.call(null,o.data),t===f&&n===g)return a.next=o,i?i[w]=a:e._root=a,e;do i=i?i[w]=new Array(4):e._root=new Array(4),(m=t>=(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,e}function Bu(e){var t,n,r=e.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,t=e[n]))||isNaN(o=+this._y.call(null,t))||(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)Hu(this,a[n],s[n],e[n]);return this}function Wu(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,o=(r=Math.floor(t))+1;else{for(var a=i-n||1,s=this._root,l,u;n>e||e>=i||r>t||t>=o;)switch(u=(t<r)<<1|e<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 Ku(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Vu(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ve(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function ju(e,t,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 ve(f,i,o,c,h)),n==null?n=1/0:(i=e-n,o=t-n,c=e+n,h=t+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 ve(f[3],v,w,l,u),new ve(f[2],a,w,v,u),new ve(f[1],v,s,l,w),new ve(f[0],a,s,v,w)),(m=(t>=w)<<1|e>=v)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=g)}else{var b=e-+this._x.call(null,f.data),E=t-+this._y.call(null,f.data),k=b*b+E*E;if(k<n){var I=Math.sqrt(n=k);i=e-I,o=t-I,c=e+I,h=t+I,r=f.data}}return r}function qu(e){if(isNaN(c=+this._x.call(null,e))||isNaN(h=+this._y.call(null,e)))return this;var t,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,t=n,!(n=n[v=m<<1|g]))return this;if(!n.length)break;(t[v+1&3]||t[v+2&3]||t[v+3&3])&&(r=t,w=v)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):t?(o?t[v]=o:delete t[v],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[w]=n:this._root=n),this):(this._root=o,this)}function Yu(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Xu(){return this._root}function Zu(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Qu(e){var t=[],n,r=this._root,i,o,a,s,l;for(r&&t.push(new ve(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(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])&&t.push(new ve(i,u,c,s,l)),(i=r[2])&&t.push(new ve(i,o,c,u,l)),(i=r[1])&&t.push(new ve(i,u,a,s,c)),(i=r[0])&&t.push(new ve(i,o,a,u,c))}return this}function Ju(e){var t=[],n=[],r;for(this._root&&t.push(new ve(this._root,this._x0,this._y0,this._x1,this._y1));r=t.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])&&t.push(new ve(o,a,s,c,h)),(o=i[1])&&t.push(new ve(o,c,s,l,h)),(o=i[2])&&t.push(new ve(o,a,h,c,u)),(o=i[3])&&t.push(new ve(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function ec(e){return e[0]}function tc(e){return arguments.length?(this._x=e,this):this._x}function nc(e){return e[1]}function rc(e){return arguments.length?(this._y=e,this):this._y}function Lt(e,t,n){var r=new Ho(t??ec,n??nc,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function Ho(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function ic(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ae=Lt.prototype=Ho.prototype;Ae.copy=function(){var e=new Ho(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=ic(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=new Array(4)}):t.target[i]=ic(r));return e};Ae.add=Uu;Ae.addAll=Bu;Ae.cover=Wu;Ae.data=Ku;Ae.extent=Vu;Ae.find=ju;Ae.remove=qu;Ae.removeAll=Yu;Ae.root=Xu;Ae.size=Zu;Ae.visit=Qu;Ae.visitAfter=Ju;Ae.x=tc;Ae.y=rc;function ue(e){return function(){return e}}function Ve(e){return(e()-.5)*1e-6}function rv(e){return e.x+e.vx}function iv(e){return e.y+e.vy}function Bo(e){var t,n,r,i=1,o=1;typeof e!="function"&&(e=ue(e==null?1:+e));function a(){for(var u,c=t.length,h,d,f,g,m,v,w=0;w<o;++w)for(h=Lt(t,rv,iv).visitAfter(s),u=0;u<c;++u)d=t[u],m=n[d.index],v=m*m,f=d.x+d.vx,g=d.y+d.vy,h.visit(b);function b(E,k,I,D,N){var z=E.data,U=E.r,_=m+U;if(z){if(z.index>d.index){var A=f-z.x-z.vx,O=g-z.y-z.vy,B=A*A+O*O;B<_*_&&(A===0&&(A=Ve(r),B+=A*A),O===0&&(O=Ve(r),B+=O*O),B=(_-(B=Math.sqrt(B)))/B*i,d.vx+=(A*=B)*(_=(U*=U)/(v+U)),d.vy+=(O*=B)*_,z.vx-=A*(_=1-_),z.vy-=O*_)}return}return k>f+_||D<f-_||I>g+_||N<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(t){var u,c=t.length,h;for(n=new Array(c),u=0;u<c;++u)h=t[u],n[h.index]=+e(h,u,t)}}return a.initialize=function(u,c){t=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?(e=typeof u=="function"?u:ue(+u),l(),a):e},a}function ov(e){return e.index}function oc(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function Wo(e){var t=ov,n=h,r,i=ue(30),o,a,s,l,u,c=1;e==null&&(e=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var w=0,b=e.length;w<c;++w)for(var E=0,k,I,D,N,z,U,_;E<b;++E)k=e[E],I=k.source,D=k.target,N=D.x+D.vx-I.x-I.vx||Ve(u),z=D.y+D.vy-I.y-I.vy||Ve(u),U=Math.sqrt(N*N+z*z),U=(U-o[E])/U*v*r[E],N*=U,z*=U,D.vx-=N*(_=l[E]),D.vy-=z*_,I.vx+=N*(_=1-_),I.vy+=z*_}function f(){if(a){var v,w=a.length,b=e.length,E=new Map(a.map((I,D)=>[t(I,D,a),I])),k;for(v=0,s=new Array(w);v<b;++v)k=e[v],k.index=v,typeof k.source!="object"&&(k.source=oc(E,k.source)),typeof k.target!="object"&&(k.target=oc(E,k.target)),s[k.source.index]=(s[k.source.index]||0)+1,s[k.target.index]=(s[k.target.index]||0)+1;for(v=0,l=new Array(b);v<b;++v)k=e[v],l[v]=s[k.source.index]/(s[k.source.index]+s[k.target.index]);r=new Array(b),g(),o=new Array(b),m()}}function g(){if(a)for(var v=0,w=e.length;v<w;++v)r[v]=+n(e[v],v,e)}function m(){if(a)for(var v=0,w=e.length;v<w;++v)o[v]=+i(e[v],v,e)}return d.initialize=function(v,w){a=v,u=w,f()},d.links=function(v){return arguments.length?(e=v,f(),d):e},d.id=function(v){return arguments.length?(t=v,d):t},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ue(+v),g(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ue(+v),m(),d):i},d}var av={value:()=>{}};function sc(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new jr(n)}function jr(e){this._=e}function sv(e,t){return e.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&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}jr.prototype=sc.prototype={constructor:jr,on:function(e,t){var n=this._,r=sv(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=lv(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=ac(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ac(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new jr(e)},call:function(e,t){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(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function lv(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ac(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=av,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ko=sc;var tn=0,Gn=0,Mn=0,uc=1e3,qr,On,Yr=0,Pt=0,Xr=0,Fn=typeof performance=="object"&&performance.now?performance:Date,cc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qo(){return Pt||(cc(uv),Pt=Fn.now()+Xr)}function uv(){Pt=0}function Vo(){this._call=this._time=this._next=null}Vo.prototype=Zr.prototype={constructor:Vo,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qo():+n)+(t==null?0:+t),!this._next&&On!==this&&(On?On._next=this:qr=this,On=this),this._call=e,this._time=n,jo()},stop:function(){this._call&&(this._call=null,this._time=1/0,jo())}};function Zr(e,t,n){var r=new Vo;return r.restart(e,t,n),r}function dc(){qo(),++tn;for(var e=qr,t;e;)(t=Pt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}function lc(){Pt=(Yr=Fn.now())+Xr,tn=Gn=0;try{dc()}finally{tn=0,dv(),Pt=0}}function cv(){var e=Fn.now(),t=e-Yr;t>uc&&(Xr-=t,Yr=e)}function dv(){for(var e,t=qr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:qr=n);On=e,jo(r)}function jo(e){if(!tn){Gn&&(Gn=clearTimeout(Gn));var t=e-Pt;t>24?(e<1/0&&(Gn=setTimeout(lc,e-Fn.now()-Xr)),Mn&&(Mn=clearInterval(Mn))):(Mn||(Yr=Fn.now(),Mn=setInterval(cv,uc)),tn=1,cc(lc))}}function hc(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function fc(e){return e.x}function pc(e){return e.y}var hv=10,fv=Math.PI*(3-Math.sqrt(5));function Yo(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=Zr(h),u=Ko("tick","end"),c=hc();e==null&&(e=[]);function h(){d(),u.call("tick",t),n<r&&(l.stop(),u.call("end",t))}function d(m){var v,w=e.length,b;m===void 0&&(m=1);for(var E=0;E<m;++E)for(n+=(o-n)*i,s.forEach(function(k){k(n)}),v=0;v<w;++v)b=e[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 t}function f(){for(var m=0,v=e.length,w;m<v;++m){if(w=e[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=hv*Math.sqrt(.5+m),E=m*fv;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(e,c),m}return f(),t={tick:d,restart:function(){return l.restart(h),t},stop:function(){return l.stop(),t},nodes:function(m){return arguments.length?(e=m,f(),s.forEach(g),t):e},alpha:function(m){return arguments.length?(n=+m,t):n},alphaMin:function(m){return arguments.length?(r=+m,t):r},alphaDecay:function(m){return arguments.length?(i=+m,t):+i},alphaTarget:function(m){return arguments.length?(o=+m,t):o},velocityDecay:function(m){return arguments.length?(a=1-m,t):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(g),t):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,g(v)),t):s.get(m)},find:function(m,v,w){var b=0,E=e.length,k,I,D,N,z;for(w==null?w=1/0:w*=w,b=0;b<E;++b)N=e[b],k=m-N.x,I=v-N.y,D=k*k+I*I,D<w&&(z=N,w=D);return z},on:function(m,v){return arguments.length>1?(u.on(m,v),t):u.on(m)}}}function Xo(){var e,t,n,r,i=ue(-30),o,a=1,s=1/0,l=.81;function u(f){var g,m=e.length,v=Lt(e,fc,pc).visitAfter(h);for(r=f,g=0;g<m;++g)t=e[g],v.visit(d)}function c(){if(e){var f,g=e.length,m;for(o=new Array(g),f=0;f<g;++f)m=e[f],o[m.index]=+i(m,f,e)}}function h(f){var g=0,m,v,w=0,b,E,k;if(f.length){for(b=E=k=0;k<4;++k)(m=f[k])&&(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-t.x,b=f.y-t.y,E=v-g,k=w*w+b*b;if(E*E/l<k)return k<s&&(w===0&&(w=Ve(n),k+=w*w),b===0&&(b=Ve(n),k+=b*b),k<a&&(k=Math.sqrt(a*k)),t.vx+=w*f.value*r/k,t.vy+=b*f.value*r/k),!0;if(f.length||k>=s)return;(f.data!==t||f.next)&&(w===0&&(w=Ve(n),k+=w*w),b===0&&(b=Ve(n),k+=b*b),k<a&&(k=Math.sqrt(a*k)));do f.data!==t&&(E=o[f.data.index]*r/k,t.vx+=w*E,t.vy+=b*E);while(f=f.next)}return u.initialize=function(f,g){e=f,n=g,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ue(+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 Zo(e){var t=ue(.1),n,r,i;typeof e!="function"&&(e=ue(e==null?0:+e));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]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:ue(+s),a(),o):t},o.x=function(s){return arguments.length?(e=typeof s=="function"?s:ue(+s),a(),o):e},o}function Qo(e){var t=ue(.1),n,r,i;typeof e!="function"&&(e=ue(e==null?0:+e));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]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:ue(+s),a(),o):t},o.y=function(s){return arguments.length?(e=typeof s=="function"?s:ue(+s),a(),o):e},o}var pv={minX:0,minY:0,maxX:0,maxY:0,w:0,h:0,cx:0,cy:0};function gc(e){if(e.length===0)return pv;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let o of e)o.x<t&&(t=o.x),o.x>r&&(r=o.x),o.y<n&&(n=o.y),o.y>i&&(i=o.y);return{minX:t,minY:n,maxX:r,maxY:i,w:r-t,h:i-n,cx:(t+r)/2,cy:(n+i)/2}}var gv=9,Qr=6,zn=18,mv=32;function ta(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+mv));return Qr+(zn-Qr)*n}var vv=9;function Jr(e){return e+vv}var $n=gv+9,yv=170,wv=.05,bv=-50,xv=90,_v=.02,kv=8,mc=2*Jr(zn),vc=.09,Ev=300,bc=1,yc=.001;function ea(e){return e==="contains"||e==="anchored-at"}function Sv(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Tv(e){let t=[],n=new Set;for(let o of e.nodes)n.has(o.id)||(n.add(o.id),t.push(o.id));let r=[],i=new Set;for(let o of e.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:t,edges:r}}function Av(e){let t=new Set(e.nodes.map(o=>o.id)),n=new Map,r=new Set;for(let o of e.edges){if(!ea(o.kind)||o.source===o.target||!t.has(o.source)||!t.has(o.target)||r.has(o.target))continue;r.add(o.target);let a=n.get(o.source);a===void 0?n.set(o.source,[o.target]):a.push(o.target)}let i=e.nodes.filter(o=>!r.has(o.id)).map(o=>o.id);return{kids:n,roots:i}}function xc(e){let{kids:t,roots:n}=Av(e),r=(o,a)=>{if(a.has(o))return[];a.add(o);let s=[o];for(let l of t.get(o)??[])for(let u of r(l,a))s.push(u);return s},i=[];for(let o of n)for(let a of t.get(o)??[]){let s=r(a,new Set);s.length>=kv&&i.push({id:a,members:s})}return i.sort((o,a)=>o.id<a.id?-1:o.id>a.id?1:0),i}function Rv(e){let t=new Map;for(let n of e)n.x!==void 0&&n.y!==void 0&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&t.set(n.id,{x:n.x,y:n.y});return t}function wc(e,t){let n=[];for(let i of e){let o=t.get(i);o!==void 0&&n.push(o)}if(n.length===0)return $n;let r=gc(n);return Math.hypot(r.w,r.h)/2}function na(e,t,n){let r=n??xc(e);if(r.length===0)return new Map;let i=new Set;for(let f of r)for(let g of f.members)i.add(g);let o=e.nodes.filter(f=>!i.has(f.id)).map(f=>f.id),a=wc(o,t),s=r.map(f=>wc(f.members,t)),l=s.map(f=>2*f+mc),u=l.reduce((f,g)=>f+g,0),c=Math.max(u/(2*Math.PI),a+mc+Math.max(...s)),h=new Map,d=0;for(let f=0;f<r.length;f++){let g=r[f],m=l[f],v=-Math.PI/2+(d+m/2)/u*2*Math.PI;d+=m;let w={x:Math.cos(v)*c,y:Math.sin(v)*c};for(let b of g.members)h.set(b,w)}return h}function Cv(e,t,n,r){let i=new Map(e.map(o=>[o.id,o]));for(let o of t){let a=n.get(o.id);if(a===void 0)continue;let s=0,l=0,u=0;for(let d of o.members){let f=r.get(d);f!==void 0&&(s+=f.x,l+=f.y,u++)}if(u===0)continue;let c=a.x-s/u,h=a.y-l/u;for(let d of o.members){let f=i.get(d);f===void 0||f.x===void 0||f.y===void 0||f.fx!=null||f.fy!=null||(f.x+=c,f.y+=h)}}}function _c(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??Ev)),r=t.seed??bc,{ids:i,edges:o}=Tv(e),a=new Map;if(i.length===0)return a;let s=t.initial,l=i.map(c=>{let h=s?.get(c),d={id:c,vx:0,vy:0};return h!==void 0&&Number.isFinite(h.x)&&Number.isFinite(h.y)&&(d.x=h.x,d.y=h.y,t.pinWarm===!0&&(d.fx=h.x,d.fy=h.y)),d}),u=new Map;for(let c of o)u.set(c.source,(u.get(c.source)??0)+1),u.set(c.target,(u.get(c.target)??0)+1);for(let c of l)c.r=Jr(ta(u.get(c.id)??0));if(l.length>1){let c=xc(e);if(c.length===0||n===0)Jo(l,o,{ticks:n,seed:r,warm:s!==void 0});else{let h=Math.ceil(n/2);Jo(l,o,{ticks:h,seed:r,warm:s!==void 0});let d=Rv(l),f=na(e,d,c);Cv(l,c,f,d),Jo(l,o,{ticks:n-h,seed:r,warm:!0,anchors:f})}}if(t.pinWarm===!0)for(let c of l)c.fx=null,c.fy=null;for(let c of l)a.set(c.id,{x:Number.isFinite(c.x)?c.x:0,y:Number.isFinite(c.y)?c.y:0});return a}function ra(e){let t=Wo(e.links).id(n=>n.id).distance(n=>ea(n.kind)?xv:yv).strength(n=>ea(n.kind)?_v:wv).iterations(2);return Yo(e.nodes).randomSource(Sv(e.seed??bc)).force("charge",Xo().strength(bv)).force("link",t).force("collide",Bo(n=>n.r??$n).strength(1).iterations(1)).force("x",Zo(n=>e.anchors?.get(n.id)?.x??0).strength(vc)).force("y",Qo(n=>e.anchors?.get(n.id)?.y??0).strength(vc)).stop()}function Jo(e,t,n){let r=t.map(o=>({source:o.source,target:o.target,kind:o.kind})),i=ra({nodes:e,links:r,seed:n.seed,anchors:n.anchors});i.alpha(n.warm?.3:1).alphaMin(yc).alphaDecay(n.ticks>0?1-Math.pow(yc,1/n.ticks):0);for(let o=0;o<n.ticks;o++)i.tick()}function De(e){if(e.kind==="external"&&e.detail.url){let t=e.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(t)return t}return e.kind==="package"&&e.detail.manifest?`${e.label} (${e.detail.manifest})`:e.label}function Nv(e){let t=new Map;for(let l of e.nodes)t.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of e.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=t.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 e.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=e.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:t,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function Sc(e){let t=new Set;for(let n of e.edges)(n.kind==="contains"||n.kind==="anchored-at")&&t.add(n.target);return e.nodes.filter(n=>!t.has(n.id)).map(n=>n.id)}function Lv(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function kc(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function Pv(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),o=t.get(r),a=kc(i),s=kc(o);if(a!==s)return a?-1:1;let l=De(i),u=De(o);return l.localeCompare(u)})}function Ec(e,t,n){let r=Number(e);return Number.isFinite(r)?{kind:"count",n:r,unit:t,phrasing:n}:{kind:"text",text:n==="attribute"?`${t}=${e}`:`${e} ${t}`}}function Dv(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?Ec(e.detail.files,"files","attribute"):null;case"gitState":return e.detail.commit?{kind:"commit",sha:e.detail.commit}:null;case"repository":return e.detail.files?Ec(e.detail.files,"files","prose"):null;case"package":return e.detail.kind?{kind:"text",text:e.detail.kind}:null;case"entryPoint":return e.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function ia(e,t){let n=Nv(e),{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[,k]of o)if(k.includes(b))return!1;return!0}).concat(o.get(g)??[]);return w=w.filter(b=>r.has(b)),t.showInternals||(w=w.filter(b=>{let E=r.get(b);return!(E&&Lv(E.kind))})),Pv(w,r)},l=t.provFilter!==null||t.query.length>0,u=g=>!(t.provFilter!==null&&g.provenance!==t.provFilter||t.query.length>0&&!De(g).toLowerCase().includes(t.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(k=>c.has(k)),E=l?b.length>0:t.expanded.has(g);if(d.push({id:g,depth:m,hasKids:w.length>0,expanded:E,label:De(v),kind:v.kind,provenance:v.provenance,meta:Dv(v)}),E)for(let k of b)f(k,m+1)};for(let g of a)f(g,0);return d}function oa(e){if(!e.nodes.find(i=>i.kind==="vault"))return null;let n=e.nodes.some(i=>i.kind==="note"),r=e.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function Un(e,t){if(!e)return"";let n=Date.parse(e);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((t-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 Iv=7;function aa(e,t){if(e===null)return"";switch(e.kind){case"relTime":return Un(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,Iv);case"text":return e.text}}var Mv=["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 sa(e,t){let n=new Map;for(let s of e.nodes)n.set(s.id,s);let r=n.get(t);if(!r)return null;let i=[];for(let s of Mv){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of e.edges){if(s.source!==t)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${De(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of e.edges){if(s.kind!=="links-to"||s.target!==t)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${De(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:De(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function la(e,t){let n=new Set([e]);for(let r of t)r.source===e&&n.add(r.target),r.target===e&&n.add(r.source);return n}var Gv=["contains","anchored-at"];function Ov(e){return Gv.includes(e)}function ei(e,t){let n=new Map;for(let d of e.nodes)n.set(d.id,d);let r=Fv(e,n),i=Sc(e),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!t.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,zv(d,r));let l=new Map;for(let d of e.nodes)if(!(!o.has(d.id)||t.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 e.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:$v(g,n),expanded:t.has(d)})}let c=new Set,h=[];for(let d of e.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:Uv(e.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function Fv(e,t){let n=new Map;for(let r of e.edges){if(!Ov(r.kind)||!t.has(r.source)||!t.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 zv(e,t){let n=[],r=new Set([e]),i=o=>{for(let a of t.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(e),n}function $v(e,t){let n={human:0,agent:0,generated:0,none:0};for(let r of e){let i=t.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function Uv(e,t,n){let r=a=>t.has(a)?a:n.get(a),i=[],o=new Set;for(let a of e){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 ua(e){let t=new Map;for(let n of e){if(n.kind!=="links-to")continue;let r=t.get(n.target);r?r.push(n.source):t.set(n.target,[n.source])}return t}var nn=[null,"human","agent","generated"];function Tc(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function Dt(e){return{...e.model,danglingLinks:e.dangling}}function Ac(e,t){return e===null?[]:ia(Dt(e),t)}function ha(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function ni(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return n.add(t),{...e,expanded:n}}function Bv(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}var Rc="Create a new folder in the vault",Cc="Folder name…";function Nc(e){return e==="vault"||e.startsWith("vfolder:")}function Lc(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):null}function Pc(e,t){return e==="note"&&t.startsWith("note:")}function ri(e){return e.startsWith("note:")?{type:"note",slug:e.slice(5)}:e.startsWith("vfolder:")?{type:"folder",path:e.slice(8)}:null}function Dc(e,t){return e==="vault"?[{kind:"action",id:"new-folder",label:"New folder",icon:"📁"},{kind:"separator"},{kind:"action",id:"collapse-all",label:"Collapse all"}]:e.startsWith("vfolder:")?[{kind:"action",id:"new-subfolder",label:"New subfolder…",icon:"📁"},{kind:"action",id:"rename-folder",label:"Rename folder…",icon:"✏️"},{kind:"separator"},{kind:"action",id:"delete-folder",label:"Delete folder",icon:"🗑",destructive:!0}]:t==="note"&&e.startsWith("note:")?[{kind:"action",id:"open",label:"Open note",icon:"📄"},{kind:"action",id:"rename",label:"Rename note…",icon:"✏️"},{kind:"separator"},{kind:"action",id:"delete-note",label:"Delete note",icon:"🗑",destructive:!0}]:e.startsWith("module:")||e.startsWith("file:")||e.startsWith("entryPoint:")?[{kind:"action",id:"copy-id",label:"Copy node id",icon:"📋"}]:[]}function Ic(e,t,n,r,i,o,a=8){let s=e,l=t;return s+n>i-a&&(s=Math.max(a,i-n-a)),l+r>o-a&&(l=Math.max(a,o-r-a)),{x:s,y:l}}function Mc(e,t){return e.query===t?e:{...e,query:t}}function Gc(e){let t=nn.indexOf(e.provFilter),n=nn[(t+1)%nn.length]??null;return{...e,provFilter:n}}function Oc(e){return{...e,showInternals:!e.showInternals}}function ii(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function da(e,t){return e[t]?.id??null}function ca(e,t,n){if(e.length===0)return null;let r=ii(e,t),i=r===-1?n>0?-1:e.length:r;return da(e,Math.min(e.length-1,Math.max(0,i+n)))}function Wv(e,t){let n=ii(e,t),r=n<=0?void 0:e[n];if(r===void 0)return null;for(let i of e.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var Kv={j:"ArrowDown",k:"ArrowUp"};function Vv(e){return Kv[e]??e}function Fc(e,t,n,r,i=!1){let o={state:t,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:t,selectedId:h,handled:!0}),s=Vv(r);if(s==="ArrowDown")return a(ca(e,n,1));if(s==="ArrowUp")return a(ca(e,n,-1));if(s==="Home")return a(da(e,0));if(s==="End")return a(da(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=ii(e,n),u=l===-1?void 0:e[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(ca(e,n,1)):{state:ni(t,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:Bv(t,n),selectedId:n,handled:!0};let c=Wv(e,n);return c===null?o:a(c)}var jv={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function fa(e){return jv[e]}var qv="sessions";function pa(e){return e.startsWith(`note:${qv}/`)}function Yv(e,t){return e.id!==t&&pa(e.id)}var Xv={human:"●",agent:"◐",generated:"○"};function It(e){return e===null?"":Xv[e]}function rn(e){return e===null?"":`${e}-authored`}function zc(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Zv(e){let t=e.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())t[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of e.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),t}function Qv(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:zc(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:fa(e.kind),provenance:e.provenance,provenanceGlyph:It(e.provenance),provenanceTitle:rn(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,muted:Yv(e,t),meta:aa(e.meta,n),level:e.depth+1}}function $c(e,t,n){let r=Zv(e);return e.map((i,o)=>Qv(i,t,n,r[o]))}function Uc(e,t){return ii(e,t)===-1?null:zc(t)}function Hc(e){return{"--weave-depth":String(Math.max(0,e))}}function ti(e){return e===null?"all":e}function Bc(e){let t=nn.indexOf(e),n=nn[(t+1)%nn.length]??null;return`provenance filter: ${ti(e)} — click for ${ti(n)}`}function Wc(e){return e?"internals":"knowledge"}function Kc(e){return e?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var Vc="filter…",jc="Vault and repository",qc="Filter the tree",Yc="Filter the tree (/)";function Xc(e,t,n){if(e===null)return"loading…";let r=oa(Dt(e));return r!==null?r:t.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function Zc(e){return e.length===1?"1 row":`${e.length} rows`}var oi={dark:{accent:"#c6a0f6",success:"#a6da95",warning:"#eed49f",dim:"#a5adcb",text:"#cad3f5",muted:"#939ab7",line:"#494d64",ground:"#24273a"},light:{accent:"#7113ec",success:"#28641b",warning:"#7c4f10",dim:"#56586a",text:"#4c4f69",muted:"#606274",line:"#bcc0cc",ground:"#eff1f5"}},Jv={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},ey={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function ty(e,t){return oi[t][Jv[e]]}function Qc(e,t){return oi[t][ey[e]]}function ny(e,t){return ry(e)?ga(Qc(e,t),t,oy):Qc(e,t)}function ry(e){return e==="contains"||e==="anchored-at"}var iy=.85,oy=.3;function ay(e,t,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(e),o=r(t);if(i===null||o===null)return e;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,u)=>Math.round(l+(u-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function ga(e,t,n=iy){return ay(e,oi[t].ground,n)}var sy={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},ly=1.6,Jc=32,uy=Jc/2;function cy(e,t=Jc){if(t<=0)return e.length>0?"…":e;if(e.length<=t)return e;let n=t-1,i=e.slice(0,n).lastIndexOf(" "),o=i>=uy?i:n;return`${e.slice(0,o).trimEnd()}…`}function dy(e){let t=It(e.provenance),n=De(e);return cy(t===""?n:`${t} ${n}`)}function ed(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of e)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<t&&(t=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[t,r],y:[n,i]}}var td={nodes:[],edges:[]};function nd(e){return`${e.source}\0${e.target}\0${e.kind}`}function hy(e,t){let n=new Map,r=new Set;for(let i of e){if(i.source===i.target||!t.has(i.source)||!t.has(i.target))continue;let o=nd(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 rd(e,t,n,r){let i=new Map;for(let c of e){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=hy(t,o),s=[];for(let[c,h]of i){let d=n.get(c),f=ta(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:dy(h),color:ty(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(f),type:"circle"})}let l=[],u=new Set;for(let c of t){if(c.source===c.target||!o.has(c.source)||!o.has(c.target))continue;let h=nd(c);u.has(h)||(u.add(h),l.push({key:h,source:c.source,target:c.target,size:sy[c.kind],color:ny(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function id(e){return(t,n,r)=>e===null?{}:e.has(t)?{zIndex:n.zIndex+fy}:{color:ga(n.color,r),label:null,zIndex:0}}var fy=zn+1;function od(e){return(t,n,r)=>e===null?{}:e.has(n.source)&&e.has(n.target)?{zIndex:1,size:n.size*ly}:{color:ga(n.color,r)}}var py=(Qr+zn)/2,gy=$n*4,my=1;function ad(e){let t=oi[e];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:my,labelGridCellSize:gy,labelRenderedSizeThreshold:py,labelFont:"inherit",labelSize:11,labelColor:{color:t.text},defaultNodeColor:t.dim,defaultEdgeColor:t.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:$n,allowInvalidContainer:!0}}var cd=En(Or(),1);function vy(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let r in arguments[t])e[r]=arguments[t][r];return e}var pe=vy;typeof Object.assign=="function"&&(pe=Object.assign);function ze(e,t,n,r){let i=e._nodes.get(t),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 we(e){return typeof e=="object"&&e!==null}function dd(e){let t;for(t in e)return!1;return!0}function Fe(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function je(e,t,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function sd(e){return!(!we(e)||e.attributes&&!Array.isArray(e.attributes))}function yy(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function ct(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function an(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Wn=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},P=class e extends Wn{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},C=class e extends Wn{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},F=class e extends Wn{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function hd(e,t){this.key=e,this.attributes=t,this.clear()}hd.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 fd(e,t){this.key=e,this.attributes=t,this.clear()}fd.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function pd(e,t){this.key=e,this.attributes=t,this.clear()}pd.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function sn(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}sn.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");let n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};sn.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");let i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};sn.prototype.detach=function(){let e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};sn.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var gd=0,md=1,wy=2,vd=3;function dt(e,t,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===gd){if(s=e._nodes.get(r),!s)throw new C(`Graph.${t}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===vd){if(i=""+i,l=e._edges.get(i),!l)throw new C(`Graph.${t}: 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 C(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=e._edges.get(r),!l)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===md?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function by(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=dt(this,t,n,r,i,o);return a.attributes[s]}}function xy(e,t,n){e.prototype[t]=function(r,i){let[o]=dt(this,t,n,r,i);return o.attributes}}function _y(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=dt(this,t,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function ky(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,u]=dt(this,t,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 Ey(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,u]=dt(this,t,n,r,i,o,a);if(typeof u!="function")throw new P(`Graph.${t}: 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 Sy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=dt(this,t,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Ty(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=dt(this,t,n,r,i,o);if(!we(s))throw new P(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Ay(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=dt(this,t,n,r,i,o);if(!we(s))throw new P(`Graph.${t}: provided attributes are not a plain object.`);return pe(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Ry(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=dt(this,t,n,r,i,o);if(typeof s!="function")throw new P(`Graph.${t}: 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 Cy=[{name:e=>`get${e}Attribute`,attacher:by},{name:e=>`get${e}Attributes`,attacher:xy},{name:e=>`has${e}Attribute`,attacher:_y},{name:e=>`set${e}Attribute`,attacher:ky},{name:e=>`update${e}Attribute`,attacher:Ey},{name:e=>`remove${e}Attribute`,attacher:Sy},{name:e=>`replace${e}Attributes`,attacher:Ty},{name:e=>`merge${e}Attributes`,attacher:Ay},{name:e=>`update${e}Attributes`,attacher:Ry}];function Ny(e){Cy.forEach(function({name:t,attacher:n}){n(e,t("Node"),gd),n(e,t("Source"),md),n(e,t("Target"),wy),n(e,t("Opposite"),vd)})}function Ly(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new C(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function Py(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=ze(this,o,a,n),!i)throw new C(`Graph.${t}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function Dy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new C(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function Iy(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=ze(this,s,l,n),!a)throw new C(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new C(`Graph.${t}: 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 My(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=ze(this,s,l,n),!a)throw new C(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new P(`Graph.${t}: 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 Gy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new C(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${t}: 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 Oy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new C(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!we(i))throw new P(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Fy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new C(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!we(i))throw new P(`Graph.${t}: provided attributes are not a plain object.`);return pe(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function zy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new C(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new F(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new P(`Graph.${t}: 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 $y=[{name:e=>`get${e}Attribute`,attacher:Ly},{name:e=>`get${e}Attributes`,attacher:Py},{name:e=>`has${e}Attribute`,attacher:Dy},{name:e=>`set${e}Attribute`,attacher:Iy},{name:e=>`update${e}Attribute`,attacher:My},{name:e=>`remove${e}Attribute`,attacher:Gy},{name:e=>`replace${e}Attributes`,attacher:Oy},{name:e=>`merge${e}Attributes`,attacher:Fy},{name:e=>`update${e}Attributes`,attacher:zy}];function Uy(e){$y.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var Hy=[{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 By(e,t,n,r){let i=!1;for(let o in t){if(o===r)continue;let a=t[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),e&&i)return a.key}}function Wy(e,t,n,r){let i,o,a,s=!1;for(let l in t)if(l!==r){i=t[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),e&&s)return i.key;i=i.next}while(i!==void 0)}}function ma(e,t){let n=Object.keys(e),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===t){i=void 0;continue}i=e[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 Ky(e,t,n,r){let i=t[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)&&e)return i.key}function Vy(e,t,n,r){let i=t[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),e&&o)return i.key;i=i.next}while(i!==void 0)}function va(e,t){let n=e[t];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 jy(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());let n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._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 yd(e,t,n,r){if(t.size===0)return;let i=n!=="mixed"&&n!==t.type,o=n==="undirected",a,s,l=!1,u=t._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),e&&l)return c}}function qy(e,t){if(e.size===0)return an();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._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 ya(e,t,n,r,i,o){let a=t?Wy:By,s;if(n!=="undirected"&&(r!=="out"&&(s=a(e,i.in,o),e&&s)||r!=="in"&&(s=a(e,i.out,o,r?void 0:i.key),e&&s))||n!=="directed"&&(s=a(e,i.undirected,o),e&&s))return s}function Yy(e,t,n,r){let i=[];return ya(!1,e,t,n,r,function(o){i.push(o)}),i}function Xy(e,t,n){let r=an();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=ct(r,ma(n.in))),t!=="in"&&typeof n.out<"u"&&(r=ct(r,ma(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=ct(r,ma(n.undirected))),r}function wa(e,t,n,r,i,o,a){let s=n?Vy:Ky,l;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(e,i.in,o,a),e&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(e,i.out,o,a),e&&l))||t!=="directed"&&typeof i.undirected<"u"&&(l=s(e,i.undirected,o,a),e&&l))return l}function Zy(e,t,n,r,i){let o=[];return wa(!1,e,t,n,r,i,function(a){o.push(a)}),o}function Qy(e,t,n,r){let i=an();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=ct(i,va(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=ct(i,va(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=ct(i,va(n.undirected,r))),i}function Jy(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return jy(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new C(`Graph.${n}: could not find the "${o}" node in the graph.`);return Yy(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 C(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new C(`Graph.${n}: could not find the "${a}" target node in the graph.`);return Zy(r,this.multi,i,s,a)}throw new P(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ew(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,yd(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new C(`Graph.${o}: could not find the "${u}" node in the graph.`);return ya(!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 C(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new C(`Graph.${o}: could not find the "${c}" target node in the graph.`);return wa(!1,r,this.multi,i,d,c,h)}throw new P(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);e.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,k)=>{h[f++]=c(g,m,v,w,b,E,k)})}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);e.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);e.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new P(`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 P(`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 tw(e,t){let{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,yd(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new C(`Graph.${o}: could not find the "${l}" node in the graph.`);return ya(!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 C(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new C(`Graph.${o}: could not find the "${u}" target node in the graph.`);return wa(!0,r,this.multi,i,h,u,c)}throw new P(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);e.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);e.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 nw(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return an();if(!arguments.length)return qy(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new C(`Graph.${o}: could not find the "${a}" node in the graph.`);return Xy(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new C(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new C(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Qy(r,i,l,s)}throw new P(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rw(e){Hy.forEach(t=>{Jy(e,t),ew(e,t),tw(e,t),nw(e,t)})}var iw=[{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 hi(){this.A=null,this.B=null}hi.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};hi.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Hn(e,t,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(t&&t.has(u.key))continue;let c=i(u.key,u.attributes);if(e&&c)return u.key}}function ba(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Hn(e,null,r,r.undirected,i);if(typeof n=="string")return Hn(e,null,r,r[n],i)}let o=new hi,a;if(t!=="undirected"){if(n!=="out"){if(a=Hn(e,null,r,r.in,i),e&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Hn(e,o,r,r.out,i),e&&a)return a;o.wrap(r.out)}}if(t!=="directed"&&(a=Hn(e,o,r,r.undirected,i),e&&a))return a}function ow(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}let r=[];return ba(!1,e,t,n,function(i){r.push(i)}),r}function Bn(e,t,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 e&&e.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===t?u:l,e&&e.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function aw(e,t,n){if(e!=="mixed"){if(e==="undirected")return Bn(null,n,n.undirected);if(typeof t=="string")return Bn(null,n,n[t])}let r=an(),i=new hi;return e!=="undirected"&&(t!=="out"&&(r=ct(r,Bn(i,n,n.in))),t!=="in"&&(r=ct(r,Bn(i,n,n.out)))),e!=="directed"&&(r=ct(r,Bn(i,n,n.undirected))),r}function sw(e,t){let{name:n,type:r,direction:i}=t;e.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 C(`Graph.${n}: could not find the "${o}" node in the graph.`);return ow(r==="mixed"?this.type:r,i,a)}}function lw(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.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 C(`Graph.${o}: could not find the "${u}" node in the graph.`);ba(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);e.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);e.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);e.prototype[l]=function(u,c,h){if(arguments.length<3)throw new P(`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 uw(e,t){let{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;e.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 C(`Graph.${a}: could not find the "${u}" node in the graph.`);return ba(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;e.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;e.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function cw(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return an();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new C(`Graph.${o}: could not find the "${a}" node in the graph.`);return aw(r==="mixed"?this.type:r,i,s)}}function dw(e){iw.forEach(t=>{sw(e,t),lw(e,t),uw(e,t),cw(e,t)})}function ai(e,t,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),e&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(t&&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),e&&f)return h;h=h.next}while(h)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),e&&f))return null}}function hw(e,t){let n={key:e};return dd(t.attributes)||(n.attributes=pe({},t.attributes)),n}function fw(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return dd(n.attributes)||(r.attributes=pe({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function pw(e){if(!we(e))throw new P('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new P("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!we(e.attributes)||e.attributes===null))throw new P("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function gw(e){if(!we(e))throw new P('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new P("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new P("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!we(e.attributes)||e.attributes===null))throw new P("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new P("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var mw=yy(),vw=new Set(["directed","undirected","mixed"]),ld=new Set(["domain","_events","_eventsCount","_maxListeners"]),yw=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],ww={allowSelfLoops:!0,multi:!1,type:"mixed"};function bw(e,t,n){if(n&&!we(n))throw new P(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new F(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function ud(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function wd(e,t,n,r,i,o,a,s){if(!r&&e.type==="undirected")throw new F(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new F(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!we(s))throw new P(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!e.allowSelfLoops&&o===a)throw new F(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),u=e._nodes.get(a);if(!l)throw new C(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new C(`Graph.${t}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new F(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new F(`Graph.${t}: 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 sn(r,i,l,u,s);e._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,c.key=i,e.emit("edgeAdded",c),i}function xw(e,t,n,r,i,o,a,s,l){if(!r&&e.type==="undirected")throw new F(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new F(`Graph.${t}: 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 P(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!we(s))throw new P(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!e.allowSelfLoops&&o===a)throw new F(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=e._nodes.get(o),h=e._nodes.get(a),d,f;if(!n&&(d=e._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new F(`Graph.${t}: 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&&!e.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),e.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else pe(f.attributes,s),e.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=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new F(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=ud(e,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=ud(e,a,{}),v=!0),d=new sn(r,i,c,h,s),e._edges.set(i,d);let w=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,w&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,w&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,g.key=i,e.emit("edgeAdded",g),[i,!0,m,v]}function on(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,o=t.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}var q=class e extends cd.EventEmitter{constructor(t){if(super(),t=pe({},ww,t),typeof t.multi!="boolean")throw new P(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!vw.has(t.type))throw new P(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new P(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);let n=t.type==="mixed"?hd:t.type==="directed"?fd:pd;Fe(this,"NodeDataClass",n);let r="geid_"+mw()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Fe(this,"_attributes",{}),Fe(this,"_nodes",new Map),Fe(this,"_edges",new Map),Fe(this,"_directedSize",0),Fe(this,"_undirectedSize",0),Fe(this,"_directedSelfLoopCount",0),Fe(this,"_undirectedSelfLoopCount",0),Fe(this,"_edgeKeyGenerator",o),Fe(this,"_options",t),ld.forEach(a=>Fe(this,a,this[a])),je(this,"order",()=>this._nodes.size),je(this,"size",()=>this._edges.size),je(this,"directedSize",()=>this._directedSize),je(this,"undirectedSize",()=>this._undirectedSize),je(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),je(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),je(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),je(this,"multi",this._options.multi),je(this,"type",this._options.type),je(this,"allowSelfLoops",this._options.allowSelfLoops),je(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+t,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new P(`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(t,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+t,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new P(`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(t,n){if(arguments.length===1){let r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new P(`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(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new F("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(t);if(!r)throw new C(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new C(`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(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new F("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(t);if(!r)throw new C(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new C(`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(t,n){if(this.multi)throw new F("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new C(`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(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new C(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.degreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._edges.get(t);if(!n)throw new C(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;let n=this._edges.get(t);if(!n)throw new C(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;let n=this._edges.get(t);if(!n)throw new C(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;let r=this._edges.get(n);if(!r)throw new C(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new C(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;let r=this._edges.get(t);if(!r)throw new C(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;let n=this._edges.get(t);if(!n)throw new C(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;let n=this._edges.get(t);if(!n)throw new C(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;let n=this._edges.get(t);if(!n)throw new C(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return bw(this,t,n).key}mergeNode(t,n){if(n&&!we(n))throw new P(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(pe(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new P(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new C(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do on(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do on(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do on(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=ze(this,r,i,this.type),!n)throw new C(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new C(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return on(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new F("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 F("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.");t=""+t,n=""+n;let r=ze(this,t,n,"directed");if(!r)throw new C(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return on(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new F("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 F("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=ze(this,t,n,"undirected");if(!r)throw new C(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return on(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let t=this._nodes.values(),n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new P("Graph.updateAttribute: updater should be a function.");let r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!we(t))throw new P("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!we(t))throw new P("Graph.mergeAttributes: provided attributes are not a plain object.");return pe(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new P("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new P("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!sd(n))throw new P("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=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new P("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!sd(n))throw new P("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=t(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new P("Graph.forEachAdjacencyEntry: expecting a callback.");ai(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new P("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ai(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new P("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ai(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new P("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ai(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new P("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)}findNode(t){if(typeof t!="function")throw new P("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return i.key}mapNodes(t){if(typeof t!="function")throw new P("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++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new P("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new P("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!t(i.key,i.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new P("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new P("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new P("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=t(r,a.key,a.attributes);return r}nodeEntries(){let t=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=t.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let t=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{t[n++]=hw(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=fw(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof e)return t.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),t.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(!we(t))throw new P("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!we(t.attributes))throw new P("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,a,s;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new P("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],pw(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(t.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=t.edges,!Array.isArray(o))throw new P("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],gw(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(t){let n=new e(pe({},this._options,t));return n.replaceAttributes(pe({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let o=pe({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new F(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new F("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 t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new F("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(t),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,wd(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,pe({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let t={};this._nodes.forEach((o,a)=>{t[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)&&!ld.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Fe(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(q.prototype[Symbol.for("nodejs.util.inspect.custom")]=q.prototype.inspect);yw.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?wd:xw;e.generateKey?q.prototype[n]=function(i,o,a){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,a,t==="update")}:q.prototype[n]=function(i,o,a,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,a,s,t==="update")}})});Ny(q);Uy(q);rw(q);dw(q);var si=class extends q{constructor(t){let n=pe({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new P("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new P('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},li=class extends q{constructor(t){let n=pe({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new P("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new P('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},ui=class extends q{constructor(t){let n=pe({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new P("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},ci=class extends q{constructor(t){let n=pe({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new P("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new P('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},di=class extends q{constructor(t){let n=pe({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new P("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new P('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function ln(e){e.from=function(t,n){let r=pe({},t.options,n),i=new e(r);return i.import(t),i}}ln(q);ln(si);ln(li);ln(ui);ln(ci);ln(di);q.Graph=q;q.DirectedGraph=si;q.UndirectedGraph=li;q.MultiGraph=ui;q.MultiDirectedGraph=ci;q.MultiUndirectedGraph=di;q.InvalidArgumentsGraphError=P;q.NotFoundGraphError=C;q.UsageGraphError=F;function _w(){return new q({multi:!0,type:"directed"})}function xa(e){let t=_w();for(let n of e.nodes){let{id:r,...i}=n;t.addNode(r,i)}for(let n of e.edges){let{key:r,source:i,target:o,...a}=n;t.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return t}function bd(e,t){let n=0;for(let[r,i]of t)e.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(e.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function _a(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}function xd(e,t){let n=null,r=xa({nodes:[],edges:[]}),i=null,o=()=>{},a=()=>{},s=()=>{},l=()=>{},u=null,c=f=>{if(u===null)return;let g=u;u=null,n?.setSetting("enableCameraPanning",!0),(f===null||f===g)&&l(g)},h=()=>ed([..._a(r).values()]),d=f=>{let g=id(i),m=od(i);f.setSetting("nodeReducer",(v,w)=>({...w,...g(v,w,t)})),f.setSetting("edgeReducer",(v,w)=>({...w,...m(v,w,t)}))};return{mount(f){if(n!==null)return;let g=e(r,f,ad(t));g.on("clickNode",({node:m})=>o(m)),g.on("clickStage",()=>o(null)),g.on("downNode",({node:m})=>{u=m,n?.setSetting("enableCameraPanning",!1),a(m)}),g.on("moveBody",m=>{u!==null&&(m.preventSigmaDefault(),s(u,g.viewportToGraph({x:m.event.x,y:m.event.y})))}),g.on("upNode",()=>c(u)),g.on("upStage",()=>c(null)),d(g),g.setCustomBBox(h()),n=g},setGraph(f){r=xa(f),n?.setGraph(r),n?.setCustomBBox(h())},setPositions(f){bd(r,f),n?.refresh()},setHighlight(f){i=f,n!==null&&d(n)},onSelect(f){o=f},onDragStart(f){a=f},onDragMove(f){s=f},onDragEnd(f){l=f},fit(){n?.setCustomBBox(h()),n?.getCamera().animatedReset()},positions(){return _a(r)},destroy(){n?.kill(),n=null}}}var kw=(e,t,n)=>new $u(e,t,n),_d=e=>xd(kw,e);var Ed="/events";var Ew=2,fi={graph:!1,note:!1};function Sd(e){return!e.graph&&!e.note}function Sw(e,t){return{graph:!0,note:e==="vault"&&t}}function kd(e){return{graph:!0,note:e}}function Td(){return{connection:"live",stamp:null,opened:!1}}function Ad(e,t){return e.stamp===t?e:{...e,stamp:t}}function Tw(e){return e===Ew?"offline":"reconnecting"}function Rd(e,t,n){switch(t.type){case"open":{let r=e.opened?kd(n):fi;return{state:{...e,connection:"live",opened:!0},plan:r}}case"error":return{state:{...e,connection:Tw(t.readyState)},plan:fi};case"frame":return t.event.stamp===e.stamp?{state:e,plan:fi}:{state:{...e,connection:"live"},plan:Sw(t.event.scope,n)};case"refresh":return{state:e,plan:kd(n)};case"closed":return{state:{...e,connection:"offline"},plan:fi}}}function Cd(e){let t;try{t=JSON.parse(e)}catch{return null}return cl(t)?t:null}var Aw=Symbol.for("preact-signals");function vi(){if(ht>1)ht--;else{var e,t=!1;for((function(){var i=gi;for(gi=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}})();Vn!==void 0;){var n=Vn;for(Vn=void 0,pi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ld(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(pi=0,ht--,t)throw e}}function Ea(e){if(ht>0)return e();ka=++Rw,ht++;try{return e()}finally{vi()}}var Kn,te=void 0;function jn(e){var t=te,n=Kn;te=void 0,Kn=void 0;try{return e()}finally{te=t,Kn=n}}var Vn=void 0,ht=0,pi=0,Rw=0,ka=0,gi=void 0,mi=0;function Nd(e){if(te!==void 0){var t=e.n;if(t===void 0||t.t!==te)return t={i:0,S:e,p:te.s,n:void 0,t:te,e:void 0,x:void 0,r:t},te.s!==void 0&&(te.s.n=t),te.s=t,e.n=t,32&te.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=te.s,t.n=void 0,te.s.n=t,te.s=t),t}}function ge(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}ge.prototype.brand=Aw;ge.prototype.h=function(){return!0};ge.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:jn(function(){var r;(r=t.W)==null||r.call(t)}))};ge.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&jn(function(){var i;(i=t.Z)==null||i.call(t)}))}};ge.prototype.subscribe=function(e){var t=this;return Gt(function(){var n=t.value;jn(function(){return e(n)})},{name:"sub"})};ge.prototype.valueOf=function(){return this.value};ge.prototype.toString=function(){return this.value+""};ge.prototype.toJSON=function(){return this.value};ge.prototype.peek=function(){var e=this;return jn(function(){return e.value})};Object.defineProperty(ge.prototype,"value",{get:function(){var e=Nd(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(pi>100)throw new Error("Cycle detected");(function(n){ht!==0&&pi===0&&n.l!==ka&&(n.l=ka,gi={S:n,v:n.v,i:n.i,o:gi})})(this),this.v=e,this.i++,mi++,ht++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{vi()}}}});function $e(e,t){return new ge(e,t)}function Ld(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Pd(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Dd(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Mt(e,t){ge.call(this,void 0,t),this.x=e,this.s=void 0,this.g=mi-1,this.f=4}Mt.prototype=new ge;Mt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===mi))return!0;if(this.g=mi,this.f|=1,this.i>0&&!Ld(this))return this.f&=-2,!0;var e=te;try{Pd(this),te=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return te=e,Dd(this),this.f&=-2,!0};Mt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}ge.prototype.S.call(this,e)};Mt.prototype.U=function(e){if(this.t!==void 0&&(ge.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Mt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Mt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Nd(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function yi(e,t){return new Mt(e,t)}function Id(e){var t=e.m;if(e.m=void 0,typeof t=="function"){ht++;var n=te;te=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Sa(e),r}finally{te=n,vi()}}}function Sa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Id(e)}function Cw(e){if(te!==this)throw new Error("Out-of-order effect");Dd(this),te=e,this.f&=-2,8&this.f&&Sa(this),vi()}function un(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Kn&&Kn.push(this)}un.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};un.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Id(this),Pd(this),ht++;var e=te;return te=this,Cw.bind(this,e)};un.prototype.N=function(){2&this.f||(this.f|=2,this.u=Vn,Vn=this)};un.prototype.d=function(){this.f|=8,1&this.f||Sa(this)};un.prototype.dispose=function(){this.d()};function Gt(e,t){var n=new un(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Md,Ta,wi,Nw=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var Gd=[];Gt(function(){Md=this.N})();function cn(e,t){W[e]=t.bind(null,W[e]||function(){})}function bi(e){if(wi){var t=wi;wi=void 0,t()}wi=e&&e.S()}function Od(e){var t=this,n=e.data,r=Pw(n);r.name="ReactiveDom",r.value=n;var i=be(function(){for(var s=t,l=t.__v;l=l.__;)if(l.__c){l.__c.__$f|=4;break}var u=yi(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),c=yi(function(){return!Array.isArray(u.value)&&!lo(u.value)}),h=Gt(function(){if(this.N=Fd,c.value){var f=u.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=t.__$u.d;return t.__$u.d=function(){h(),d.call(this)},[c,u]},[]),o=i[0],a=i[1];return o.value?a.peek():a.value}Od.displayName="ReactiveTextNode";Object.defineProperties(ge.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Od},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});cn("__b",function(e,t){if(typeof t.type=="string"){var n,r=t.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof ge&&(n||(t.__np=n={}),n[i]=o,r[i]=o.peek())}}e(t)});cn("__r",function(e,t){if(e(t),t.type!==Ne){bi();var n,r=t.__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;Nw&&((o=this.y)==null||o.call(this)),i.__$f|=1,i.setState({})}})(r),typeof t.type=="function"?t.type.displayName||t.type.name:""))),Ta=r,bi(n)}});cn("__e",function(e,t,n,r){bi(),Ta=void 0,e(t,n,r)});cn("diffed",function(e,t){bi(),Ta=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var r=t.__np,i=t.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=Lw(n,l,c,i),o[l]=u):u.o(c,i)}}}e(t)});function Lw(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,o=$e(n);return{o:function(a,s){o.value=a,r=s},d:Gt(function(){this.N=Fd;var a=o.value.value;r[t]!==a&&(r[t]=a,i?e[t]=a:a!=null&&(a!==!1||t[4]==="-")?e.setAttribute(t,a):e.removeAttribute(t))})}}cn("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__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=t.__np;if(a){var s=t.props;for(var l in a)s[l]=a[l]}t.__np=void 0}else{var u=t.__c;if(u){var c=u.__$u;c&&(u.__$u=void 0,c.d())}}e(t)});cn("__h",function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)});Yt.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)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 e)if(a!=="__source"&&e[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function Pw(e,t){return be(function(){return $e(e,t)},[])}var Dw=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Iw(){Ea(function(){for(var e;e=Gd.shift();)Md.call(e)})}function Fd(){Gd.push(this)===1&&(W.requestAnimationFrame||Dw)(Iw)}function Mw(){return{expanded:[]}}var Ue=$e(null),Le=$e(null),qn=$e(!1),Yn=$e(null),v0=$e(Mw()),dn=$e("live"),hn=$e(new Set);function zd(e){let t=Td(),n=!1,r=e.open(e.path??Ed),i=o=>{let a=Rd(t,o,e.hasSelection());t=a.state,dn.value=t.connection,Sd(a.plan)||e.refetch(a.plan)};return r.addEventListener("open",()=>i({type:"open"})),r.addEventListener("error",()=>i({type:"error",readyState:r.readyState})),r.addEventListener(ul,o=>{let a=Cd(o.data);a!==null&&i({type:"frame",event:a})}),{stop(){n||(n=!0,r.close(),i({type:"closed"}))},refresh(){i({type:"refresh"})},seen(o){t=Ad(t,o)},state(){return t}}}function $d(e){return new EventSource(e)}function fn(){return{mode:"read",slug:null,baseline:"",draft:"",revision:null,status:"idle",message:null,saving:null,conflict:null,external:null,pending:null}}function pn(e){return e.mode==="edit"&&e.draft!==e.baseline}function Hd(e){return pn(e)&&e.slug!==null&&e.status!=="saving"}function ce(e){return{state:e,effect:null}}function Aa(e,t,n){return{...e,mode:n,slug:t.note.slug,baseline:t.note.body,draft:t.note.body,revision:t.revision,status:"idle",message:null,saving:null,conflict:null,external:null}}function Gw(e,t){return t.note.slug!==e.slug?Aa(e,t,"read"):pn(e)&&t.revision!==e.revision?{...e,external:t}:Aa(e,t,e.mode)}function Bd(e,t){switch(t.type){case"loaded":return ce(Gw(e,t.payload));case"cleared":return ce(fn());case"toggle":return e.slug===null?ce(e):e.mode==="read"?ce({...e,mode:"edit",draft:e.baseline,status:"idle",message:null}):pn(e)?ce({...e,status:"error",message:Wd}):ce({...e,mode:"read",status:"idle",message:null});case"draft":return ce({...e,draft:t.text,status:e.status==="saving"?"saving":"idle",message:null});case"save":return!Hd(e)||e.slug===null||e.conflict!==null?ce(e):{state:{...e,status:"saving",message:null,saving:e.draft},effect:{type:"save",slug:e.slug,input:Ow(e)}};case"saved":return ce(Fw(e,t.payload));case"failed":return ce({...e,status:"error",message:t.message,saving:null});case"conflicted":return ce({...e,status:"error",message:t.conflict.error,saving:null,conflict:t.conflict});case"reload":return ce(zw(e));case"overwrite":return $w(e);case"dismiss":return ce({...e,conflict:null,external:null,status:"idle",message:null});case"navigate":return Uw(e,t.id);case"discard":return e.pending===null?ce(e):{state:fn(),effect:{type:"select",id:e.pending.id}};case"stay":return ce({...e,pending:null});case"open":return e.slug===null?ce(e):{state:e,effect:{type:"open",slug:e.slug}};case"opened":return ce({...e,status:t.ok?"idle":"error",message:t.ok?Bw:Ww})}}function Ow(e){return e.revision===null?{body:e.draft}:{body:e.draft,expectedRevision:e.revision}}function Fw(e,t){let n=e.saving!==null&&e.saving!==e.draft;return{...e,slug:t.note.slug,baseline:t.note.body,draft:n?e.draft:t.note.body,revision:t.revision,status:"saved",message:Hw,saving:null,conflict:null,external:null}}function zw(e){let t=e.conflict?.reason==="conflict"?e.conflict.current:e.external;return t==null?e:Aa(e,t,e.mode)}function $w(e){return e.slug===null?ce(e):{state:{...e,status:"saving",message:null,saving:e.draft,conflict:null,external:null},effect:{type:"save",slug:e.slug,input:{body:e.draft}}}}function Uw(e,t){return pn(e)?ce({...e,pending:{id:t}}):{state:e,effect:{type:"select",id:t}}}function Ra(e){return pn(e)}var Hw="saved",Wd="unsaved changes — save with the button, or discard them",Bw="opened in your editor",Ww="could not open the note in an editor",Kw="Edit",Vw="Done",jw="Save",qw="Saving…",Kd="Open in $EDITOR",Vd="Hand this note to $EDITOR (or your platform's opener)",Yw="Discard changes",xi="Keep editing",Ud="Reload from disk",Xw="Overwrite",Zw="this note changed on disk while you were editing",Qw="pick a different name",jd='<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M9 2H3.6A1.6 1.6 0 0 0 2 3.6v8.8A1.6 1.6 0 0 0 3.6 14h8.8A1.6 1.6 0 0 0 14 12.4V9"/><path d="M11.3 2a1.9 1.9 0 1 1 2.7 2.7L5.6 13 2 14l1-3.6 8.3-8.4z"/></svg>';function qd(e){let t=e.conflict;return t?.reason==="conflict"?{kind:"conflict",message:t.error,actions:[{label:Ud,event:{type:"reload"}},{label:Xw,event:{type:"overwrite"}},{label:xi,event:{type:"dismiss"}}]}:t?.reason==="collision"?{kind:"collision",message:`${t.error} (${t.slug}) — ${Qw}`,actions:[{label:xi,event:{type:"dismiss"}}]}:e.pending!==null?{kind:"discard",message:Wd,actions:[{label:xi,event:{type:"stay"}},{label:Yw,event:{type:"discard"}}]}:e.external!==null?{kind:"external",message:Zw,actions:[{label:Ud,event:{type:"reload"}},{label:xi,event:{type:"dismiss"}}]}:null}function Yd(e){let t=e.mode==="edit";return{toggleLabel:t?Vw:Kw,editing:t,saveLabel:e.status==="saving"?qw:jw,canSave:Hd(e)&&e.conflict===null,message:e.message,tone:e.message===null?"none":e.status==="error"?"warn":"ok",dirty:pn(e)}}function Xd(e,t){return e.editing||e.message!==null||t!==null}function Zd(e){let t=fn(),n=i=>{let o=Bd(t,i);t=o.state,e.onChange(t),o.effect!==null&&r(o.effect)},r=i=>{if(i.type==="select"){e.select(i.id);return}if(i.type==="open"){(async()=>{let o=await Ml(e.fetch,i.slug);n({type:"opened",ok:o.ok&&o.data.opened})})();return}(async()=>{let o=await Rl(e.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:()=>t,send:n}}function Qd(e,t){let n=r=>{t()&&(r.preventDefault(),r.returnValue="")};return e.addEventListener("beforeunload",n),()=>e.removeEventListener("beforeunload",n)}var Jd=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function eh(e,t,n){return e===0?null:e===1?0:t<0?n?e-1:0:n?t===0?e-1:t-1:t===e-1?0:t+1}function th(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function nh(e){return e===null?!1:(e.focus(),!0)}function _i(){let e=ee(null);return re(()=>{let t=document.activeElement;return e.current?.focus(),()=>{nh(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!th(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Jd)??[]],r=eh(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}function ah(e,t){let n=t.trim().toLowerCase();if(n==="")return 0;let r=e.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 Jw=10;function eb(e){return Math.min(Math.max(e,0),Jw)*2}function tb(e){return`note:${e}`}function nb(e,t){return ah(e.summary.title,t)+eb(e.score)}function rb(e,t){return ah(e.label,t)}var ib=["path","manifest","url","slug"];function ob(e){for(let t of ib){let n=e.detail[t];if(typeof n=="string"&&n!=="")return n}return""}function ab(e,t){return e.score!==t.score?t.score-e.score:e.kind!==t.kind?e.kind==="note"?-1:1:e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function sb(e,t,n,r){let i=new Map;for(let o of e){let a=tb(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:nb(o,t)})}for(let o of n){if(i.has(o.id))continue;let a=rb(o,r);a!==0&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:ob(o),badge:o.kind,score:a})}return[...i.values()].sort(ab).slice(0,20)}function ki(){return{query:"",typedAt:0,issued:"",answered:"",seq:0,applied:0,hits:[],cursor:0,pending:!1,loading:!1,failed:!1}}var Ca=140;function ot(e){return{state:e,request:null,schedule:null}}function rh(e,t){return t>e.applied}function sh(e,t){switch(t.type){case"query":{let n={...e,query:t.query,typedAt:t.now,cursor:0};return t.query.trim()===""?ot({...n,hits:[],answered:"",issued:"",loading:!1,failed:!1,pending:!1}):e.pending?ot(n):{state:{...n,pending:!0},request:null,schedule:Ca}}case"tick":{if(!e.pending)return ot(e);let n=t.now-e.typedAt;if(n<Ca)return{state:e,request:null,schedule:Ca-n};let r=e.query.trim();if(r===""||r===e.issued)return ot({...e,pending:!1});let i=e.seq+1;return{state:{...e,pending:!1,loading:!0,seq:i,issued:r},request:{seq:i,query:r},schedule:null}}case"response":return rh(e,t.seq)?ot({...e,applied:t.seq,hits:t.hits,answered:t.query,loading:t.seq<e.seq,failed:!1,cursor:0}):ot(e);case"failed":return rh(e,t.seq)?ot({...e,applied:t.seq,loading:t.seq<e.seq,failed:!0}):ot(e);case"cursor":return ot({...e,cursor:t.cursor});case"dismiss":return ot({...e,pending:!1})}}function Na(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function ih(e,t,n){return n<=0?0:((e+t)%n+n)%n}function lh(e,t){return t===null?null:e[t]?.id??null}function uh(e,t,n){let r={state:e,activate:null,dismiss:!1,handled:!1},i=a=>({state:{...e,cursor:a},activate:null,dismiss:!1,handled:!0}),o=Na(e.cursor,n);return t==="ArrowDown"?i(ih(o,1,n)):t==="ArrowUp"?i(ih(o,-1,n)):t==="Home"?i(0):t==="End"?i(Na(n-1,n)):t==="Escape"?{state:e,activate:null,dismiss:!0,handled:!0}:t!=="Enter"||n===0?r:{state:e,activate:o,dismiss:!0,handled:!0}}var Ei="Search the workspace",ch="Search notes and repository…",dh="↑↓ move · ↵ open · esc close";function lb(e,t){return e.query.trim()===""?"Type to search notes, modules, files and entry points.":t>0?null:e.failed?"search failed — the workspace server may be gone":e.loading||e.pending?"searching…":`no matches for “${e.query.trim()}”`}function ub(e){return e===1?"1 result":`${e} results`}function oh(e){return`weave-search-row-${e}`}function hh(e,t){let n=sb(e.hits,e.answered,t?.model.nodes??[],e.query),r=Na(e.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:oh(a)})),status:lb(e,n.length),count:n.length,countLabel:ub(n.length),cursor:r,activeDomId:n.length===0?null:oh(r)}}function fh(e){let t=ki(),n=r=>{let i=sh(t,r);t=i.state,e.onChange(t),i.schedule!==null&&e.delay(()=>n({type:"tick",now:e.now()}),i.schedule);let o=i.request;o!==null&&(async()=>{let a=await Il(e.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:()=>t,setQuery:r=>n({type:"query",query:r,now:e.now()}),setCursor:r=>n({type:"cursor",cursor:r}),dismiss:()=>n({type:"dismiss"})}}var cb=0;function y(e,t,n,r,i,o){t||(t={});var a,s,l=t;if("ref"in l)for(s in l={},t)s=="ref"?a=t[s]:l[s]=t[s];var u={type:e,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--cb,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return W.vnode&&W.vnode(u),u}function db({row:e,onPick:t,onHover:n}){return y("li",{id:e.domId,role:"option","aria-selected":e.active,class:`weave-hit weave-hit-${e.kind}${e.active?" weave-hit-on":""}`,onMouseMove:n,onClick:t,children:[y("span",{class:"weave-hit-badge",children:e.badge}),y("span",{class:"weave-hit-label",children:e.label}),y("span",{class:"weave-hit-detail",children:e.detail})]})}function ph(e){let[t,n]=V(ki),r=be(()=>fh({...e.ports,onChange:n}),[]),i=_i(),o=ee(null);re(()=>{o.current?.focus()},[]);let a=hh(t,e.graph),s=l=>{let u=lh(a.rows,l);u!==null&&e.onSelect(u),r.dismiss(),e.onClose()};return y("div",{class:"weave-scrim",onClick:()=>s(null),children:y("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Ei,tabIndex:-1,ref:i.ref,onClick:l=>l.stopPropagation(),onKeyDown:l=>{if(i.onKeyDown(l))return;let u=uh(t,l.key,a.count);u.handled&&(l.preventDefault(),r.setCursor(u.state.cursor),u.dismiss&&s(u.activate))},children:[y("input",{type:"search",class:"weave-palette-input",ref:o,value:t.query,placeholder:ch,"aria-label":Ei,"aria-controls":"weave-search-results","aria-activedescendant":a.activeDomId??void 0,onInput:l=>r.setQuery(l.currentTarget.value)}),a.status===null?y("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Ei,children:a.rows.map((l,u)=>y(db,{row:l,onPick:()=>s(u),onHover:()=>r.setCursor(u)},l.id))}):y("p",{class:"weave-palette-status",role:"status",children:a.status}),y("p",{class:"weave-palette-foot",children:[y("span",{children:a.countLabel}),y("span",{class:"weave-palette-hint",children:dh})]})]})})}var gh="pi-weave.selection.v1";function mh(e,t){try{return e.setItem(gh,t??""),!0}catch{return!1}}function vh(e,t){if(e===null)return null;let n;try{n=t.getItem(gh)}catch{return null}return n===null||n===""?null:e.model.nodes.some(r=>r.id===n)?n:null}var hb=3e3,La=new Set;function fb(e,t){if(e===null)return La;let n=new Set(e.model.nodes.map(i=>i.id)),r=new Set;for(let i of t.model.nodes)n.has(i.id)||r.add(i.id);return r}var Si=null;function wh(e){return Si=e,()=>{Si===e&&(Si=null)}}async function yh(e,t,n){let r=Le.value,i=await Tl(e,Le.value);return i.ok?(qn.value=!1,i.cached||(Le.value=i.data,n?.(r,i.data)),t?.seen(i.data.stamp),i):(Le.value===null&&(qn.value=!0),i)}async function Pa(e){let t=bh(Ue.value);if(t===null){Yn.value=null;return}let n=await Al(e,t);n.ok&&(Yn.value=n.data,Si?.(n.data))}function bh(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function xh(e){let t=null,n=null,r=e.defer??((a,s)=>{let l=setTimeout(a,s);return()=>clearTimeout(l)}),i=(a,s)=>{let l=fb(a,s);hn.value=l,n?.(),n=null,l.size>0&&(n=r(()=>{n=null,hn.value=La},hb))},o=a=>{(async()=>(a.graph&&await yh(e.fetch,t,i),a.note&&await Pa(e.fetch)))()};return t=zd({open:e.open,refetch:o,hasSelection:()=>bh(Ue.value)!==null,...e.path===void 0?{}:{path:e.path}}),yh(e.fetch,t,i),{refresh(){t?.refresh()},syncNote(){return Pa(e.fetch)},stop(){t?.stop(),t=null,n?.(),n=null,hn.value=La}}}function Ti(e,t){return Ue.value=t,Pa(e)}function _h(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}var pb=300,gb=1;function mb(e,t,n){let r=new Map(n??[]);if(r.size>0)for(let o of t){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:pb,seed:gb,pinWarm:!0};return r.size>0&&(i.initial=r),_c({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function vb(e,t){let n=0,r=0;for(let o of e){let a=_h(o.id);n^=a,r=r+a>>>0}for(let o of t){let a=_h(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[e.length,t.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var Eh="pi-weave.graph.positions.v3";function kh(e){return Math.round(e*10)/10}function yb(e,t){let n={};for(let[r,i]of t)n[r]=[kh(i.x),kh(i.y)];return JSON.stringify({v:3,key:e,at:n})}function wb(e,t){if(e===null)return null;let n;try{n=JSON.parse(e)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==3||r.key!==t)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 bb(e,t){let n;try{n=e.getItem(Eh)}catch{return null}return wb(n,t)}function xb(e,t,n){try{return e.setItem(Eh,yb(t,n)),!0}catch{return!1}}function Sh(e,t,n){let r=vb(t,n),i=bb(e,r);if(i!==null&&t.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=mb(t,n);return xb(e,r,o),{key:r,positions:o,cached:!1}}function _b(e){return{expanded:new Set(ei(e,new Set).clusters.keys())}}function Ah(e,t){return t!==null?t:e===null?{expanded:new Set}:_b(Dt(e))}function kb(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Eb(e,t){return{...e,expanded:new Set(t.keys())}}function Sb(e){return{...e,expanded:new Set}}function Tb(e,t){return t===null?null:la(t,e)}function Rh(e){return e?"collapse":"expand"}function Ch(e){return e?"collapse every cluster back to the roots":"expand every cluster"}function Da(e,t){if(t.size===0)return!1;for(let n of t.keys())if(!e.expanded.has(n))return!1;return!0}function Nh(e,t){return Da(e,t)?Sb(e):Eb(e,t)}var Lh="fit",Ph="frame the whole graph",Ai={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Dh(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function Ab(e,t){return e===null?"Loading…":e.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":t===0?"Nothing to draw at this expansion.":null}var Rb="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",Th={graph:td,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Ih(e,t,n,r,i,o=!1){if(e===null)return o?{...Th,empty:Rb}:Th;let a=Dt(e),s=ei(a,n.expanded),l=Sh(r,s.nodes,s.edges);return{graph:rd(s.nodes,s.edges,l.positions,i),highlight:Tb(s.edges,t),key:l.key,cached:l.cached,clusters:s.clusters,visible:s.nodes.length,total:a.nodes.length,empty:Ab(e,s.nodes.length)}}function Mh(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:kb(e,n),selectedId:n}}var Cb=.06,Nb=.2,Ia=.001;function Gh(e,t){if(e.nodes.length===0)return null;let n=e.nodes.map(u=>{let c=t?.get(u.id);return{id:u.id,x:c!==void 0&&Number.isFinite(c.x)?c.x:u.x,y:c!==void 0&&Number.isFinite(c.y)?c.y:u.y,vx:0,vy:0,r:Jr(u.size)}}),r=new Map(n.map(u=>[u.id,u])),i=new Set,o=[];for(let u of e.edges){if(u.source===u.target||!r.has(u.source)||!r.has(u.target))continue;let c=`${u.source}\0${u.target}\0${u.kind}`;i.has(c)||(i.add(c),o.push({source:u.source,target:u.target,kind:u.kind}))}let a=new Map;for(let u of e.nodes)a.set(u.id,{x:u.x,y:u.y});let s=new Map(na(e,a)),l=ra({nodes:n,links:o,anchors:s,seed:1}).alpha(Cb).alphaMin(Ia);return{tick(){l.tick()},awake(){return l.alphaTarget()>Ia||l.alpha()>Ia},positions(){return new Map(n.map(u=>[u.id,{x:u.x??0,y:u.y??0}]))},pin(u,c){let h=r.get(u);h&&(h.fx=c.x,h.fy=c.y,l.alphaTarget(Nb))},release(u){let c=r.get(u);c&&(s.set(u,{x:c.x??0,y:c.y??0}),c.fx=null,c.fy=null,l.alphaTarget(0))}}}function Oh(e){let t=ee(null),n=ee(null),r=ee(null),i=ee(null),o=_l(()=>{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]=V(null),l=e.scheme??Pr(e.host),u=Ah(e.graph,a),c=be(()=>Ih(e.graph,e.selectedId,u,e.storage,l,e.bootFailed),[e.graph,e.selectedId,u,e.storage,l,e.bootFailed]),h=Da(u,c.clusters),d=ee({view:u,model:c,onSelect:e.onSelect});return d.current={view:u,model:c,onSelect:e.onSelect},re(()=>{let f=e.renderer(l);return f.onSelect(g=>{let m=Mh(d.current.view,d.current.model.clusters,g);s(m.state),d.current.onSelect(m.selectedId)}),f.onDragStart(g=>{let m=n.current?.positions().get(g);m&&(r.current?.pin(g,m),o())}),f.onDragMove((g,m)=>{r.current?.pin(g,m)}),f.onDragEnd(g=>{r.current?.release(g)}),f.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=f,f.setGraph(d.current.model.graph),f.setHighlight(d.current.model.highlight),e.fit.current=()=>f.fit(),()=>{f.destroy(),n.current=null,e.fit.current=null}},[e.renderer,l]),re(()=>{n.current?.setGraph(c.graph)},[c.key]),re(()=>{let f=Gh(c.graph,n.current?.positions());return r.current=f,f!==null&&o(),()=>{r.current=null}},[c.key,o]),re(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),re(()=>{n.current?.setHighlight(c.highlight)},[c.highlight]),y("div",{class:"weave-graph",children:[c.empty===null?null:y("p",{class:"weave-graph-empty",children:c.empty}),y("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),y("div",{class:"weave-graph-controls",children:[y("button",{type:"button",class:"weave-chip",title:Ph,onClick:()=>n.current?.fit(),children:Lh}),y("button",{type:"button",class:"weave-chip",title:Ch(h),onClick:()=>s(Nh(u,c.clusters)),children:Rh(h)}),y("span",{class:"weave-graph-legend",children:[y("span",{class:"weave-legend-on",children:["◉ ",Ai.selected]}),y("span",{class:"weave-legend-near",children:["● ",Ai.neighborhood]}),y("span",{class:"weave-legend-dim",children:["· ",Ai.dimmed]})]})]}),y("p",{class:"weave-graph-count",children:Dh(c.visible,c.total)})]})}function Fh(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Lb(e){if(Array.isArray(e))return e}function Pb(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);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 Db(){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 Ib(e,t){return Lb(e)||Pb(e,t)||Mb(e,t)||Db()}function Mb(e,t){if(e){if(typeof e=="string")return Fh(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fh(e,t):void 0}}var Jh=Object.entries,zh=Object.setPrototypeOf,Gb=Object.isFrozen,Ob=Object.getPrototypeOf,Fb=Object.getOwnPropertyDescriptor,me=Object.freeze,ye=Object.seal,gn=Object.create,ef=typeof Reflect<"u"&&Reflect,Ua=ef.apply,Ha=ef.construct;me||(me=function(t){return t});ye||(ye=function(t){return t});Ua||(Ua=function(t,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 t.apply(n,i)});Ha||(Ha=function(t){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 t(...r)});var Ft=de(Array.prototype.forEach),zb=de(Array.prototype.lastIndexOf),$h=de(Array.prototype.pop),Xn=de(Array.prototype.push),$b=de(Array.prototype.splice),mn=Array.isArray,Jn=de(String.prototype.toLowerCase),Ma=de(String.prototype.toString),Uh=de(String.prototype.match),Zn=de(String.prototype.replace),Hh=de(String.prototype.indexOf),Ub=de(String.prototype.trim),Hb=de(Number.prototype.toString),Bb=de(Boolean.prototype.toString),Bh=typeof BigInt>"u"?null:de(BigInt.prototype.toString),Wh=typeof Symbol>"u"?null:de(Symbol.prototype.toString),Pe=de(Object.prototype.hasOwnProperty),Qn=de(Object.prototype.toString),xe=de(RegExp.prototype.test),Ot=Wb(TypeError);function de(e){return function(t){t instanceof RegExp&&(t.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 Ua(e,t,r)}}function Wb(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ha(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jn;if(zh&&zh(e,null),!mn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let o=n(i);o!==i&&(Gb(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Kb(e){for(let t=0;t<e.length;t++)Pe(e,t)||(e[t]=null);return e}function Me(e){let t=gn(null);for(let r of Jh(e)){var n=Ib(r,2);let i=n[0],o=n[1];Pe(e,i)&&(mn(o)?t[i]=Kb(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=Me(o):t[i]=o)}return t}function Vb(e){switch(typeof e){case"string":return e;case"number":return Hb(e);case"boolean":return Bb(e);case"bigint":return Bh?Bh(e):"0";case"symbol":return Wh?Wh(e):"Symbol()";case"undefined":return Qn(e);case"function":case"object":{if(e===null)return Qn(e);let t=e,n=qe(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:Qn(r)}return Qn(e)}default:return Qn(e)}}function qe(e,t){for(;e!==null;){let r=Fb(e,t);if(r){if(r.get)return de(r.get);if(typeof r.value=="function")return de(r.value)}e=Ob(e)}function n(){return null}return n}function jb(e){try{return xe(e,""),!0}catch{return!1}}var Kh=me(["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"]),Ga=me(["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"]),Oa=me(["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"]),qb=me(["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"]),Fa=me(["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"]),Yb=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vh=me(["#text"]),jh=me(["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"]),za=me(["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"]),qh=me(["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"]),Ri=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Xb=ye(/{{[\w\W]*|^[\w\W]*}}/g),Zb=ye(/<%[\w\W]*|^[\w\W]*%>/g),Qb=ye(/\${[\w\W]*/g),Jb=ye(/^data-[\-\w.\u00B7-\uFFFF]+$/),ex=ye(/^aria-[\-\w]+$/),Yh=ye(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),tx=ye(/^(?:\w+script|data):/i),nx=ye(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),rx=ye(/^html$/i),ix=ye(/^[a-z][.\w]*(-[.\w]+)+$/i),Xh=ye(/<[/\w!]/g),Zh=ye(/<[/\w]/g),ox=ye(/<\/no(script|embed|frames)/i),ax=ye(/\/>/i),Ie={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},tf=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],sx=me(K({},tf)),lx=(function(){let e={};return Ft(tf,t=>{e[t]=ye(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),me(e)})(),ux=function(){return typeof window>"u"?null:window},cx=function(t,n){if(typeof t!="object"||typeof t.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 t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Qh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},bt=function(t,n,r,i){return Pe(t,n)&&mn(t[n])?K(i.base?Me(i.base):{},t[n],i.transform):r},$a=function(t,n,r){let i=Pe(t,n)?t[n]:void 0;return i&&typeof i=="object"?Me(i):r()};function nf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ux(),t=R=>nf(R);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Ie.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,a=e.Node,s=e.Element,l=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let c=e.DOMParser,h=e.trustedTypes,d=s.prototype,f=qe(d,"cloneNode"),g=qe(d,"remove"),m=qe(d,"nextSibling"),v=qe(d,"childNodes"),w=qe(d,"parentNode"),b=qe(d,"shadowRoot"),E=qe(d,"attributes"),k=a&&a.prototype?qe(a.prototype,"nodeType"):null,I=a&&a.prototype?qe(a.prototype,"nodeName"):null,D=a&&a.prototype?qe(a.prototype,"ownerDocument"):null,N=function(p){return k?k(p):p.nodeType},z=function(p){return I?I(p):p.nodeName};if(typeof o=="function"){let R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let U,_="",A,O=!1,B=0,ae=function(){if(B>0)throw Ot('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.')},ie=function(p){ae(),B++;try{return U.createHTML(p)}finally{B--}},Qe=function(p){ae(),B++;try{return U.createScriptURL(p)}finally{B--}},Ht=function(){return O||(A=cx(h,i),O=!0),A},He=n,Be=He.implementation,We=He.createNodeIterator,Je=He.createDocumentFragment,wn=He.getElementsByTagName,Ge=r.importNode,X=Qh();t.isSupported=typeof Jh=="function"&&typeof w=="function"&&Be&&Be.createHTMLDocument!==void 0;let bn=Xb,qp=Zb,Yp=Qb,Xp=Jb,Zp=ex,Qp=tx,ms=nx,Jp=ix,vs=Yh,Q=null,Wi=K({},[...Kh,...Ga,...Oa,...Fa,...Vh]),J=null,Ki=K({},[...jh,...za,...qh,...Ri]),et=Object.seal(gn(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}})),xn=null,ys=null,pt=Object.seal(gn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ws=!0,Vi=!0,bs=!1,xs=!0,gt=!1,kt=!0,Et=!1,ji=!1,lr=null,ur=null,qi=!1,Bt=!1,cr=!1,dr=!1,_s=!0,ks=!1,Es="user-content-",Yi=!0,Xi=!1,Wt={},Kt=null,Ss=K({},["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"]),Ts=null,As=K({},["audio","video","img","source","image","track"]),Rs=null,Cs=K({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),hr="http://www.w3.org/1998/Math/MathML",fr="http://www.w3.org/2000/svg",tt="http://www.w3.org/1999/xhtml",Vt=tt,Zi=!1,Qi=null,eg=K({},[hr,fr,tt],Ma),Ns=me(["mi","mo","mn","ms","mtext"]),Ji=K({},Ns),Ls=me(["annotation-xml"]),eo=K({},Ls),tg=K({},["title","style","font","a","script"]),_n=null,ng=["application/xhtml+xml","text/html"],rg="text/html",se=null,jt=null,ig=n.createElement("form"),Ps=function(p){return p instanceof RegExp||p instanceof Function},to=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(jt&&jt===p)return;(!p||typeof p!="object")&&(p={}),p=Me(p),_n=ng.indexOf(p.PARSER_MEDIA_TYPE)===-1?rg:p.PARSER_MEDIA_TYPE,se=_n==="application/xhtml+xml"?Ma:Jn,Q=bt(p,"ALLOWED_TAGS",Wi,{transform:se}),J=bt(p,"ALLOWED_ATTR",Ki,{transform:se}),Qi=bt(p,"ALLOWED_NAMESPACES",eg,{transform:Ma}),Rs=bt(p,"ADD_URI_SAFE_ATTR",Cs,{transform:se,base:Cs}),Ts=bt(p,"ADD_DATA_URI_TAGS",As,{transform:se,base:As}),Kt=bt(p,"FORBID_CONTENTS",Ss,{transform:se}),xn=bt(p,"FORBID_TAGS",Me({}),{transform:se}),ys=bt(p,"FORBID_ATTR",Me({}),{transform:se}),Wt=Pe(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Me(p.USE_PROFILES):p.USE_PROFILES:!1,ws=p.ALLOW_ARIA_ATTR!==!1,Vi=p.ALLOW_DATA_ATTR!==!1,bs=p.ALLOW_UNKNOWN_PROTOCOLS||!1,xs=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gt=p.SAFE_FOR_TEMPLATES||!1,kt=p.SAFE_FOR_XML!==!1,Et=p.WHOLE_DOCUMENT||!1,Bt=p.RETURN_DOM||!1,cr=p.RETURN_DOM_FRAGMENT||!1,dr=p.RETURN_TRUSTED_TYPE||!1,qi=p.FORCE_BODY||!1,_s=p.SANITIZE_DOM!==!1,ks=p.SANITIZE_NAMED_PROPS||!1,Yi=p.KEEP_CONTENT!==!1,Xi=p.IN_PLACE||!1,vs=jb(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:Yh,Vt=typeof p.NAMESPACE=="string"?p.NAMESPACE:tt,Ji=$a(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>K({},Ns)),eo=$a(p,"HTML_INTEGRATION_POINTS",()=>K({},Ls));let x=$a(p,"CUSTOM_ELEMENT_HANDLING",()=>gn(null));if(et=gn(null),Pe(x,"tagNameCheck")&&Ps(x.tagNameCheck)&&(et.tagNameCheck=x.tagNameCheck),Pe(x,"attributeNameCheck")&&Ps(x.attributeNameCheck)&&(et.attributeNameCheck=x.attributeNameCheck),Pe(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),ye(et),gt&&(Vi=!1),cr&&(Bt=!0),Wt&&(Q=K({},Vh),J=gn(null),Wt.html===!0&&(K(Q,Kh),K(J,jh)),Wt.svg===!0&&(K(Q,Ga),K(J,za),K(J,Ri)),Wt.svgFilters===!0&&(K(Q,Oa),K(J,za),K(J,Ri)),Wt.mathMl===!0&&(K(Q,Fa),K(J,qh),K(J,Ri))),pt.tagCheck=null,pt.attributeCheck=null,Pe(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?pt.tagCheck=p.ADD_TAGS:mn(p.ADD_TAGS)&&(Q===Wi&&(Q=Me(Q)),K(Q,p.ADD_TAGS,se))),Pe(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?pt.attributeCheck=p.ADD_ATTR:mn(p.ADD_ATTR)&&(J===Ki&&(J=Me(J)),K(J,p.ADD_ATTR,se))),Pe(p,"ADD_FORBID_CONTENTS")&&mn(p.ADD_FORBID_CONTENTS)&&(Kt===Ss&&(Kt=Me(Kt)),K(Kt,p.ADD_FORBID_CONTENTS,se)),Yi&&(Q["#text"]=!0),Et&&K(Q,["html","head","body"]),Q.table&&(K(Q,["tbody"]),delete xn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ot('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ot('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let S=U;U=p.TRUSTED_TYPES_POLICY;try{_=ie("")}catch(L){throw U=S,L}}else p.TRUSTED_TYPES_POLICY===null?(U=void 0,_=""):(U===void 0&&(U=Ht()),U&&typeof _=="string"&&(_=ie("")));me&&me(p),jt=p},Ds=K({},[...Ga,...Oa,...qb]),Is=K({},[...Fa,...Yb]),og=function(p,x,S){return x.namespaceURI===tt?p==="svg":x.namespaceURI===hr?p==="svg"&&(S==="annotation-xml"||Ji[S]):!!Ds[p]},ag=function(p,x,S){return x.namespaceURI===tt?p==="math":x.namespaceURI===fr?p==="math"&&eo[S]:!!Is[p]},sg=function(p,x,S){return x.namespaceURI===fr&&!eo[S]||x.namespaceURI===hr&&!Ji[S]?!1:!Is[p]&&(tg[p]||!Ds[p])},lg=function(p){let x=w(p);(!x||!x.tagName)&&(x={namespaceURI:Vt,tagName:"template"});let S=Jn(p.tagName),L=Jn(x.tagName);return Qi[p.namespaceURI]?p.namespaceURI===fr?og(S,x,L):p.namespaceURI===hr?ag(S,x,L):p.namespaceURI===tt?sg(S,x,L):!!(_n==="application/xhtml+xml"&&Qi[p.namespaceURI]):!1},mt=function(p){Xn(t.removed,{element:p});try{w(p).removeChild(p)}catch{if(g(p),!w(p))throw Ot("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ms=function(p,x,S){try{p.removeAttributeNode(x)}catch{try{p.removeAttribute(S)}catch{}}},pr=function(p){gr(p);let x=v(p);if(x){let L=[];Ft(x,G=>{Xn(L,G)}),Ft(L,G=>{try{g(G)}catch{}})}let S=E(p);if(S)for(let L=S.length-1;L>=0;--L){let G=S[L],$=G&&G.name;typeof $=="string"&&Ms(p,G,$)}},St=function(p,x,S){if(!S)try{S=x.getAttributeNode(p)}catch{S=null}Xn(t.removed,{attribute:S||null,from:x});try{S?x.removeAttributeNode(S):x.removeAttribute(p)}catch{try{x.removeAttribute(p)}catch{}}if(p==="is")if(Bt||cr)try{mt(x)}catch{}else try{x.setAttribute(p,"")}catch{}},ug=function(p){let x=E(p);if(x)for(let S=x.length-1;S>=0;--S){let L=x[S],G=L&&L.name;typeof G!="string"||J[se(G)]||Ms(p,L,G)}},gr=function(p){let x=[p];for(;x.length>0;){let S=x.pop();N(S)===Ie.element&&ug(S);let G=v(S);if(G)for(let $=G.length-1;$>=0;--$)x.push(G[$])}},Gs=function(p,x){return kt?p==="patchsrc"?!0:p==="for"&&x!=="label"&&x!=="output":!1},cg=function(p){if(!kt)return;let x=[p];for(;x.length>0;){let S=x.pop(),L=N(S);if(L===Ie.processingInstruction||L===Ie.comment&&xe(Zh,S.data)){try{g(S)}catch{}continue}if(L===Ie.element){let $=S,Z=se(z(S));try{$.hasAttribute&&$.hasAttribute("patchsrc")&&$.removeAttribute("patchsrc"),$.hasAttribute&&$.hasAttribute("for")&&Gs("for",Z)&&$.removeAttribute("for")}catch{}}let G=v(S);if(G)for(let $=G.length-1;$>=0;--$)x.push(G[$])}},Os=function(p){let x=null,S=null;if(qi)p="<remove></remove>"+p;else{let $=Uh(p,/^[\r\n\t ]+/);S=$&&$[0]}_n==="application/xhtml+xml"&&Vt===tt&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let L=U?ie(p):p;if(Vt===tt)try{x=new c().parseFromString(L,_n)}catch{}if(!x||!x.documentElement){x=Be.createDocument(Vt,"template",null);try{x.documentElement.innerHTML=Zi?_:L}catch{}}let G=x.body||x.documentElement;return p&&S&&G.insertBefore(n.createTextNode(S),G.childNodes[0]||null),Vt===tt?wn.call(x,Et?"html":"body")[0]:Et?x.documentElement:G},Fs=function(p){let x=D?D(p):p.ownerDocument;return We.call(x||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},mr=function(p){return p=Zn(p,bn," "),p=Zn(p,qp," "),p=Zn(p,Yp," "),p},no=function(p){var x;p.normalize();let S=D?D(p):p.ownerDocument,L=We.call(S||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),G=L.nextNode();for(;G;)G.data=mr(G.data),G=L.nextNode();let $=(x=p.querySelectorAll)===null||x===void 0?void 0:x.call(p,"template");$&&Ft($,Z=>{qt(Z.content)&&no(Z.content)})},vr=function(p){let x=I?I(p):null;return typeof x!="string"||se(x)!=="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!==k(p)||p.childNodes!==v(p)},qt=function(p){if(!k||typeof p!="object"||p===null)return!1;try{return k(p)===Ie.documentFragment}catch{return!1}},kn=function(p){if(!k||typeof p!="object"||p===null)return!1;try{return typeof k(p)=="number"}catch{return!1}};function nt(R,p,x){R.length!==0&&Ft(R,S=>{S.call(t,p,x,jt)})}let dg=function(p,x){return!!(kt&&p.hasChildNodes()&&!kn(p.firstElementChild)&&xe(Xh,p.textContent)&&xe(Xh,p.innerHTML)||kt&&p.namespaceURI===tt&&sx[x]&&(kn(p.firstElementChild)||typeof p.textContent=="string"&&xe(lx[x],p.textContent))||p.nodeType===Ie.processingInstruction||kt&&p.nodeType===Ie.comment&&xe(Zh,p.data))},yr=function(p,x){if(p instanceof RegExp)return xe(p,x);if(p instanceof Function){for(var S=arguments.length,L=new Array(S>2?S-2:0),G=2;G<S;G++)L[G-2]=arguments[G];return!!p(x,...L)}return!1},hg=function(p,x,S){if(!xn[x]&&Bs(x)&&yr(et.tagNameCheck,x))return!1;if(Yi&&!Kt[x]){let L=w(p),G=v(p);if(G&&L){let $=G.length;for(let Z=$-1;Z>=0;--Z){let ne=p===S?f(G[Z],!0):G[Z];L.insertBefore(ne,m(p))}}}return mt(p),!0},zs=function(p,x,S,L){return p.length===0?x:x===S||x===L?Me(x):x},$s=function(p,x){return p===x||w(p)!==null?!1:(Xi&&gr(p),!0)},Us=function(p,x){if(nt(X.beforeSanitizeElements,p,null),$s(p,x))return!0;if(vr(p))return mt(p),!0;let S=se(z(p));if(Q=zs(X.uponSanitizeElement,Q,Wi,lr),nt(X.uponSanitizeElement,p,{tagName:S,allowedTags:Q}),$s(p,x))return!0;if(dg(p,S))return mt(p),!0;if(xn[S]||!(pt.tagCheck instanceof Function&&pt.tagCheck(S))&&!Q[S]){let G=hg(p,S,x);return G===!1&&nt(X.afterSanitizeElements,p,null),G}if(N(p)===Ie.element&&!lg(p)||(S==="noscript"||S==="noembed"||S==="noframes")&&xe(ox,p.innerHTML))return mt(p),!0;if(gt&&p.nodeType===Ie.text){let G=mr(p.textContent);p.textContent!==G&&(Xn(t.removed,{element:p.cloneNode()}),p.textContent=G)}return nt(X.afterSanitizeElements,p,null),!1},Hs=function(p,x,S){if(ys[x]||Gs(x,p)||_s&&(x==="id"||x==="name")&&(S in n||S in ig))return!1;let L=J[x]||pt.attributeCheck instanceof Function&&pt.attributeCheck(x,p);return Vi&&xe(Xp,x)||ws&&xe(Zp,x)?!0:L?Rs[x]||xe(vs,Zn(S,ms,""))||(x==="src"||x==="xlink:href"||x==="href")&&p!=="script"&&Hh(S,"data:")===0&&Ts[p]||bs&&!xe(Qp,Zn(S,ms,""))?!0:!S:Bs(p)&&yr(et.tagNameCheck,p)&&yr(et.attributeNameCheck,x,p)||x==="is"&&et.allowCustomizedBuiltInElements&&yr(et.tagNameCheck,S)},fg=K({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Bs=function(p){return!fg[Jn(p)]&&xe(Jp,p)},pg=function(p,x,S,L){if(U&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!S)switch(h.getAttributeType(p,x)){case"TrustedHTML":return ie(L);case"TrustedScriptURL":return Qe(L)}return L},gg=function(p,x,S,L){try{S?p.setAttributeNS(S,x,L):p.setAttribute(x,L),vr(p)?mt(p):$h(t.removed)}catch{St(x,p)}},Ws=function(p){nt(X.beforeSanitizeAttributes,p,null);let x=p.attributes;if(!x||vr(p))return;J=zs(X.uponSanitizeAttribute,J,Ki,ur);let S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0},L=x.length,G=se(p.nodeName);for(;L--;){let $=x[L],Z=$.name,ne=$.namespaceURI,Re=$.value,Ce=se(Z),io=Re,ke=Z==="value"?io:Ub(io);if(S.attrName=Ce,S.attrValue=ke,S.keepAttr=!0,S.forceKeepAttr=void 0,nt(X.uponSanitizeAttribute,p,S),ke=S.attrValue,ks&&(Ce==="id"||Ce==="name")&&Hh(ke,Es)!==0&&(St(Z,p,$),ke=Es+ke),kt&&xe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ke)){St(Z,p,$);continue}if(Ce==="attributename"&&Uh(ke,"href")){St(Z,p,$);continue}if(!S.forceKeepAttr){if(!S.keepAttr){St(Z,p,$);continue}if(!xs&&xe(ax,ke)){St(Z,p,$);continue}if(gt&&(ke=mr(ke)),!Hs(G,Ce,ke)){St(Z,p,$);continue}ke=pg(G,Ce,ne,ke),ke!==io&&gg(p,Z,ne,ke)}}nt(X.afterSanitizeAttributes,p,null)},wr=function(p){let x=null,S=Fs(p);for(nt(X.beforeSanitizeShadowDOM,p,null);x=S.nextNode();)if(nt(X.uponSanitizeShadowNode,x,null),Us(x,p),Ws(x),qt(x.content)&&wr(x.content),N(x)===Ie.element){let L=b(x);qt(L)&&(ro(L),wr(L))}nt(X.afterSanitizeShadowDOM,p,null)},ro=function(p){let x=[{node:p,shadow:null}];for(;x.length>0;){let S=x.pop();if(S.shadow){wr(S.shadow);continue}let L=S.node,$=N(L)===Ie.element,Z=v(L);if(Z)for(let ne=Z.length-1;ne>=0;--ne)x.push({node:Z[ne],shadow:null});if($){let ne=I?I(L):null;if(typeof ne=="string"&&se(ne)==="template"){let Re=L.content;qt(Re)&&x.push({node:Re,shadow:null})}}if($){let ne=b(L);qt(ne)&&x.push({node:null,shadow:ne},{node:ne,shadow:null})}}};return t.sanitize=function(R){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,L=null,G=null;if(Zi=!R,Zi&&(R="<!-->"),typeof R!="string"&&!kn(R)&&(R=Vb(R),typeof R!="string"))throw Ot("dirty is not a string, aborting");if(!t.isSupported)return R;ji?(Q=lr,J=ur):to(p),(X.uponSanitizeElement.length>0||X.uponSanitizeAttribute.length>0)&&(Q=Me(Q)),X.uponSanitizeAttribute.length>0&&(J=Me(J)),t.removed=[];let $=Xi&&typeof R!="string"&&kn(R);if($){cg(R);let Re=z(R);if(typeof Re=="string"){let Ce=se(Re);if(!Q[Ce]||xn[Ce])throw pr(R),Ot("root node is forbidden and cannot be sanitized in-place")}if(vr(R))throw pr(R),Ot("root node is clobbered and cannot be sanitized in-place");try{ro(R)}catch(Ce){throw pr(R),Ce}}else if(kn(R))x=Os("<!---->"),S=x.ownerDocument.importNode(R,!0),S.nodeType===Ie.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S),ro(S);else{if(!Bt&&!gt&&!Et&&R.indexOf("<")===-1)return U&&dr?ie(R):R;if(x=Os(R),!x)return Bt?null:dr?_:""}x&&qi&&mt(x.firstChild);let Z=$?R:x;try{let Re=Fs(Z);for(;L=Re.nextNode();)Us(L,Z),Ws(L),qt(L.content)&&wr(L.content)}catch(Re){throw $&&(pr(R),Ft(t.removed,Ce=>{Ce.element&&gr(Ce.element)})),Re}if($)return Ft(t.removed,Re=>{Re.element&&gr(Re.element)}),gt&&no(R),R;if(Bt){if(gt&&no(x),cr)for(G=Je.call(x.ownerDocument);x.firstChild;)G.appendChild(x.firstChild);else G=x;return(J.shadowroot||J.shadowrootmode)&&(G=Ge.call(r,G,!0)),G}let ne=Et?x.outerHTML:x.innerHTML;return Et&&Q["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&xe(rx,x.ownerDocument.doctype.name)&&(ne="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
|
|
336
|
-
`+
|
|
337
|
-
]`).replace("lheading",
|
|
338
|
-
`),n=
|
|
339
|
-
`)}function
|
|
331
|
+
`,ep=Jf,Vs=WebGLRenderingContext,Ps=Vs.UNSIGNED_BYTE,un=Vs.FLOAT,tp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],js=(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:ep,FRAGMENT_SHADER_SOURCE:Hs,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:tp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:un},{name:"a_positionEnd",size:2,type:un},{name:"a_normal",size:2,type:un},{name:"a_color",size:4,type:Ps,normalized:!0},{name:"a_id",size:4,type:Ps,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:un},{name:"a_normalCoef",size:1,type:un}],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,d=o.y,h=a.x,c=a.y,f=zt(s.color),g=h-u,v=c-d,m=g*g+v*v,y=0,b=0;m&&(m=1/Math.sqrt(m),y=-v*m*l,b=g*m*l);var k=this.array;k[i++]=u,k[i++]=d,k[i++]=h,k[i++]=c,k[i++]=y,k[i++]=b,k[i++]=f,k[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,d=a.u_pixelRatio,h=a.u_correctionRatio,c=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(c,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(d,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})($i);var il=on(sr()),lr=(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 ll=on(Bi());var lp=function(e){return e},up=function(e){return e*e},cp=function(e){return e*(2-e)},dp=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},hp=function(e){return e*e*e},fp=function(e){return--e*e*e+1},pp=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},ul={linear:lp,quadraticIn:up,quadraticOut:cp,quadraticInOut:dp,cubicIn:hp,cubicOut:fp,cubicInOut:pp},cl={easing:"quadraticInOut",duration:150};function Ne(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function ur(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function al(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 sl(t,e,n){return t[6]=e,t[7]=n,t}function ut(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],d=t[8],h=e[0],c=e[1],f=e[2],g=e[3],v=e[4],m=e[5],y=e[6],b=e[7],k=e[8];return t[0]=h*n+c*o+f*l,t[1]=h*r+c*a+f*u,t[2]=h*i+c*s+f*d,t[3]=g*n+v*o+m*l,t[4]=g*r+v*a+m*u,t[5]=g*i+v*s+m*d,t[6]=y*n+b*o+k*l,t[7]=y*r+b*a+k*u,t[8]=y*i+b*s+k*d,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,d=e.y;return{x:u*r+d*o+s*n,y:u*i+d*a+l*n}}function gp(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Ut(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,d=e.height,h=Ne(),c=Math.min(u,d)-2*r,f=gp(e,n);return i?(ut(h,sl(Ne(),s,l)),ut(h,ur(Ne(),a)),ut(h,al(Ne(),o)),ut(h,ur(Ne(),u/c/2/f,d/c/2/f))):(ut(h,ur(Ne(),2*(c/u)*f,2*(c/d)*f)),ut(h,al(Ne(),-o)),ut(h,ur(Ne(),1/a)),ut(h,sl(Ne(),-s,-l))),h}function dl(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 fl(t){if(!(0,ll.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 pl(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 Wi(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ki(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 Vi(t){var e=lt(t.x,2),n=e[0],r=e[1],i=lt(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 d=function(c){return{x:.5+(c.x-l)/s,y:.5+(c.y-u)/s}};return d.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},d.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},d.ratio=s,d}function dr(t){"@babel/helpers - typeof";return dr=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},dr(t)}function ji(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 hr(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 fr={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:Ms,defaultDrawNodeLabel:Ui,defaultDrawNodeHover:Os,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:{}},mp={circle:cn},vp={arrow:Ks,line:js};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 gl(t){var e=hr({},fr,t);return e.nodeProgramClasses=hr({},mp,e.nodeProgramClasses),e.edgeProgramClasses=hr({},vp,e.edgeProgramClasses),e}var Wb=on(sr()),Kb=on(Bi()),gr=1.5,ml=(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(L(L({},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=L(L({},cl),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:ul[s.easing],d=Date.now(),h=this.getState(),c=function(){var g=(Date.now()-d)/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(c)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(c)):c(),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||gr)},r):this.animate({ratio:this.ratio/gr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||gr)},r):this.animate({ratio:this.ratio*gr})}},{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)}}])})(lr);function Me(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function Xe(t,e){var n=L(L({},Me(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function dn(t){var e="x"in t?t:L(L({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function yp(t,e){return L(L({},Xe(t,e)),{},{delta:_l(t)})}var wp=2;function mr(t){for(var e=[],n=0,r=Math.min(t.length,wp);n<r;n++)e.push(t[n]);return e}function hn(t,e,n){var r={touches:mr(t.touches).map(function(i){return Me(i,n)}),previousTouches:e.map(function(i){return Me(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function _l(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 kl=(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)})(lr),bp=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],xp=bp.reduce(function(t,e){return L(L({},t),{},S({},e,fr[e]))},{}),_p=(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",xp),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",Xe(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Xe(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Xe(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Me(r,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Me(r,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Xe(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=Me(r,this.container),s=a.x,l=a.y,u=o.getState(),d=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-d.x),y:u.y+this.settings.inertiaRatio*(u.y-d.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",Xe(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Xe(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=Me(r,this.container),l=s.x,u=s.y,d=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),c=d.x-h.x,f=d.y-h.y,g=a.getState(),v=g.x+c,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",Xe(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Xe(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=_l(r);if(a){var s=yp(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,d=o.getBoundedRatio(l*u),h=a>0?1:-1,c=Date.now();l!==d&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&c-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Me(r,this.container),d),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=c))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(kl),kp=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Ep=kp.reduce(function(t,e){return L(L({},t),{},S({},e,fr[e]))},{}),Sp=(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",Ep),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=mr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Me(f,i.container)}),this.touchMode===2){var a=lt(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,d=a[1],h=d.x,c=d.y;this.startTouchesAngle=Math.atan2(c-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(c-u,2))}this.emit("touchdown",hn(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",hn(r,this.lastTouches,this.container)),!r.touches.length){var s=Me(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var d=hn(r,this.lastTouches,this.container);if(this.emit("doubletap",d),this.lastTap=null,!d.sigmaDefaultPrevented){var h=this.renderer.getCamera(),c=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,c),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=hn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=mr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=mr(r.touches),a=o.map(function(We){return Me(We,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=hn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(We,Jt){var Ce=i.startTouchesPositions[Jt];return Ce&&(We.x!==Ce.x||We.y!==Ce.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),d=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var c=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=c.x,g=c.y,v=this.renderer.viewportToFramedGraph(a[0]),m=v.x,y=v.y;u.setState({x:d.x+f-m,y:d.y+g-y});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},k=a[0],_=k.x,N=k.y,D=a[1],I=D.x,z=D.y,F=Math.atan2(z-N,I-_)-this.startTouchesAngle,G=Math.hypot(z-N,I-_)/this.startTouchesDistance,U=u.getBoundedRatio(d.ratio/G);b.ratio=U,b.angle=d.angle+F;var j=this.getDimensions(),Q=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:d}),ge=Math.min(j.width,j.height)-2*h,de=ge/j.width,Be=ge/j.height,Nt=U/ge,De=_-ge/2/de,Ie=N-ge/2/Be,Ge=[De*Math.cos(-b.angle)-Ie*Math.sin(-b.angle),Ie*Math.cos(-b.angle)+De*Math.sin(-b.angle)];De=Ge[0],Ie=Ge[1],b.x=Q.x-De*Nt,b.y=Q.y+Ie*Nt,u.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(kl);function Tp(t){if(Array.isArray(t))return rr(t)}function Ap(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Rp(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
332
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vl(t){return Tp(t)||Ap(t)||Di(t)||Rp()}function Cp(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function qi(t,e){if(t==null)return{};var n,r,i=Cp(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 yl=(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}}])})(),wl=(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 yl(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(yl.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 d=this.cells[u],h=0;h<Math.min(s,d.length);h++)l.push(d[h].key);return l}}])})();function Np(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 bl=150,xl=50,Qe=Object.prototype.hasOwnProperty;function Lp(t,e,n){if(!Qe.call(n,"x")||!Qe.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),Qe.call(n,"hidden")||(n.hidden=!1),Qe.call(n,"highlighted")||(n.highlighted=!1),Qe.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Pp(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Qe.call(n,"hidden")||(n.hidden=!1),Qe.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Dp=(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 wl),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",Ne()),S(i,"invMatrix",Ne()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",Vi({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",Wi()),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=gl(o),pr(i.settings),fl(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 ml,i.bindCameraHandlers(),i.mouseCaptor=new _p(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new Sp(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=qi(i,[r].map(wt));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=qi(s,[r].map(wt));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=qi(i,[r].map(wt));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],a=this.textures[r];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[r]=s,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,a=Mi(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=Gi.apply(void 0,vl(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=dn(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",L(L({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",L(L({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",L(L({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var d=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);d!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",L(L({},s),{},{edge:r.hoveredEdge})),d&&r.emit("enterEdge",L(L({},s),{},{edge:d})),r.hoveredEdge=d)}},this.activeListeners.handleMoveBody=function(o){var a=dn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=dn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",L(L({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",L(L({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",L({},s))},this.activeListeners.handleEnter=function(o){var a=dn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",L({},s))};var i=function(a){return function(s){var l=dn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},d=r.getNodeAtPosition(l);if(d)return r.emit("".concat(a,"Node"),L(L({},u),{},{node:d}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),L(L({},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(d){return r.updateNode(d)});var u=!l||l.some(function(d){return o.has(d)});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(d){return r.updateEdge(d)});var u=l&&["zIndex","type"].some(function(d){return l?.includes(d)});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=Mi(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=Gi.apply(void 0,vl(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,d=u.x,h=u.y;this.nodeExtent={x:[(d[0]+d[1])/2-s/2,(d[0]+d[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=Vi(this.customBBox||this.nodeExtent);var c=new ml,f=Ut(c.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},v={},m={},y={},b=1,k=i.nodes(),_=0,N=k.length;_<N;_++){var D=k[_],I=this.nodeDataCache[D],z=i.getNodeAttributes(D);I.x=z.x,I.y=z.y,this.normalizationFunction.applyTo(I),typeof I.label=="string"&&!I.hidden&&this.labelGrid.add(D,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(!Qe.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(g[F]||0),g[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=Ki(this.nodeZExtent,function(en){return r.nodeDataCache[en].zIndex},k));for(var G=0,U=k.length;G<U;G++){var j=k[G];v[j]=b,y[v[j]]={type:"node",id:j},b++;var Q=this.nodeDataCache[j];this.addNodeToProgram(j,v[j],g[Q.type]++)}for(var ge={},de=i.edges(),Be=0,Nt=de.length;Be<Nt;Be++){var De=de[Be],Ie=this.edgeDataCache[De];ge[Ie.type]=(ge[Ie.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(de=Ki(this.edgeZExtent,function(en){return r.edgeDataCache[en].zIndex},de));for(var Ge in this.edgePrograms){if(!Qe.call(this.edgePrograms,Ge))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Ge,'"!'));this.edgePrograms[Ge].reallocate(ge[Ge]||0),ge[Ge]=0}for(var We=0,Jt=de.length;We<Jt;We++){var Ce=de[We];m[Ce]=b,y[m[Ce]]={type:"edge",id:Ce},b++;var q=this.edgeDataCache[Ce];this.addEdgeToProgram(Ce,m[Ce],ge[q.type]++)}return this.itemIDsIndex=y,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(d){return i.cleanCameraState(d,o.cameraPanBoundaries&&dr(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=L({},r),u=s||this.nodeExtent,d=lt(u.x,2),h=d[0],c=d[1],f=lt(u.y,2),g=f[0],v=f[1],m=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:c,y:g},{cameraState:r}),this.graphToViewport({x:h,y:v},{cameraState:r}),this.graphToViewport({x:c,y:v},{cameraState:r})],y=1/0,b=-1/0,k=1/0,_=-1/0;m.forEach(function(ge){var de=ge.x,Be=ge.y;y=Math.min(y,de),b=Math.max(b,de),k=Math.min(k,Be),_=Math.max(_,Be)});var N=b-y,D=_-k,I=this.getDimensions(),z=I.width,F=I.height,G=0,U=0;if(N>=z?b<z-a?G=b-(z-a):y>a&&(G=y-a):b>z+a?G=b-(z+a):y<-a&&(G=y+a),D>=F?_<F-a?U=_-(F-a):k>a&&(U=k-a):_>F+a?U=_-(F+a):k<-a&&(U=k+a),G||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Q=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=Q.x-j.x,U=Q.y-j.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);ji(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 d=this.framedGraphToViewport(u),h=d.x,c=d.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-bl||h>this.width+bl||c<-xl||c>this.height+xl)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,v=this.nodePrograms[u.type],m=v?.drawLabel||g;m(o,L(L({key:l},u),{},{size:f,x:h,y:c}),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=Np({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ji(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),d=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],c=this.edgeDataCache[l];if(!o.has(l)&&!(c.hidden||d.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[c.type],v=g?.drawLabel||f;v(r,L(L({key:l},c),{},{size:this.scaleSize(c.size)}),L(L(L({key:u[0]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),L(L(L({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,y=v.y,b=r.scaleSize(g.size),k=r.settings.defaultDrawNodeHover,_=r.nodePrograms[g.type],N=_?.drawHover||k;N(i,L(L({key:f},g),{},{size:b,x:m,y}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(c){c!==r.hoveredNode&&a.push(c)}),a.forEach(function(c){return o(c)});var s={};a.forEach(function(c){var f=r.nodeDataCache[c].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(c){var f=r.nodeDataCache[c];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 d in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[d];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(),d=this.getStagePadding();this.matrix=Ut(s,l,u,d),this.invMatrix=Ut(s,l,u,d,!0),this.correctionRatio=dl(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var c in this.nodePrograms){var f=this.nodePrograms[c];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=Lp(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=Pp(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 wl,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]],d=this.nodeDataCache[l[1]];s.process(i,o,u,d,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=pl(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=L({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 L({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=L({},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=L({},this.settings);return this.settings=L(L({},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=Wi(),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 d=this.webGLContexts[u];if(d.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&d.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,d=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,c=d?.length||0;h<c;h++){var f=d[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,y=v.length;m<y;m++){var b=v[m];if(this.updateEdge(b),o){var k=this.edgeProgramIndex[b];if(k===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],k)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(L(L({},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,d=this.settings,h=d.minCameraRatio,c=d.maxCameraRatio;typeof c=="number"&&(i=Math.min(i,c)),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?Ut(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?Ut(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}}])})(lr),El=Dp;function Sl(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return Tl(this.cover(e,n),e,n,t)}function Tl(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,d=t._y1,h,c,f,g,v,m,y,b;if(!o)return t._root=a,t;for(;o.length;)if((v=e>=(h=(s+u)/2))?s=h:u=h,(m=n>=(c=(l+d)/2))?l=c:d=c,i=o,!(o=o[y=m<<1|v]))return i[y]=a,t;if(f=+t._x.call(null,o.data),g=+t._y.call(null,o.data),e===f&&n===g)return a.next=o,i?i[y]=a:t._root=a,t;do i=i?i[y]=new Array(4):t._root=new Array(4),(v=e>=(h=(s+u)/2))?s=h:u=h,(m=n>=(c=(l+d)/2))?l=c:d=c;while((y=m<<1|v)===(b=(g>=c)<<1|f>=h));return i[b]=o,i[y]=a,t}function Al(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,d=-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>d&&(d=i),o<u&&(u=o),o>h&&(h=o));if(l>d||u>h)return this;for(this.cover(l,u).cover(d,h),n=0;n<r;++n)Tl(this,a[n],s[n],t[n]);return this}function Rl(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 Cl(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Nl(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 Ll(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,d=this._x1,h=this._y1,c=[],f=this._root,g,v;for(f&&c.push(new fe(f,i,o,d,h)),n==null?n=1/0:(i=t-n,o=e-n,d=t+n,h=e+n,n*=n);g=c.pop();)if(!(!(f=g.node)||(a=g.x0)>d||(s=g.y0)>h||(l=g.x1)<i||(u=g.y1)<o))if(f.length){var m=(a+l)/2,y=(s+u)/2;c.push(new fe(f[3],m,y,l,u),new fe(f[2],a,y,m,u),new fe(f[1],m,s,l,y),new fe(f[0],a,s,m,y)),(v=(e>=y)<<1|t>=m)&&(g=c[c.length-1],c[c.length-1]=c[c.length-1-v],c[c.length-1-v]=g)}else{var b=t-+this._x.call(null,f.data),k=e-+this._y.call(null,f.data),_=b*b+k*k;if(_<n){var N=Math.sqrt(n=_);i=t-N,o=e-N,d=t+N,h=e+N,r=f.data}}return r}function Pl(t){if(isNaN(d=+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,d,h,c,f,g,v,m,y;if(!n)return this;if(n.length)for(;;){if((g=d>=(c=(a+l)/2))?a=c:l=c,(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,y=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[y]=n:this._root=n),this):(this._root=o,this)}function Dl(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Il(){return this._root}function Gl(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Ml(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,d=(a+l)/2;(i=r[3])&&e.push(new fe(i,u,d,s,l)),(i=r[2])&&e.push(new fe(i,o,d,u,l)),(i=r[1])&&e.push(new fe(i,u,a,s,d)),(i=r[0])&&e.push(new fe(i,o,a,u,d))}return this}function Ol(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,d=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new fe(o,a,s,d,h)),(o=i[1])&&e.push(new fe(o,d,s,l,h)),(o=i[2])&&e.push(new fe(o,a,h,d,u)),(o=i[3])&&e.push(new fe(o,d,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Fl(t){return t[0]}function zl(t){return arguments.length?(this._x=t,this):this._x}function $l(t){return t[1]}function Ul(t){return arguments.length?(this._y=t,this):this._y}function xt(t,e,n){var r=new Yi(e??Fl,n??$l,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Yi(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 Hl(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var _e=xt.prototype=Yi.prototype;_e.copy=function(){var t=new Yi(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=Hl(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]=Hl(r));return t};_e.add=Sl;_e.addAll=Al;_e.cover=Rl;_e.data=Cl;_e.extent=Nl;_e.find=Ll;_e.remove=Pl;_e.removeAll=Dl;_e.root=Il;_e.size=Gl;_e.visit=Ml;_e.visitAfter=Ol;_e.x=zl;_e.y=Ul;function oe(t){return function(){return t}}function Oe(t){return(t()-.5)*1e-6}function Ip(t){return t.x+t.vx}function Gp(t){return t.y+t.vy}function Zi(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=oe(t==null?1:+t));function a(){for(var u,d=e.length,h,c,f,g,v,m,y=0;y<o;++y)for(h=xt(e,Ip,Gp).visitAfter(s),u=0;u<d;++u)c=e[u],v=n[c.index],m=v*v,f=c.x+c.vx,g=c.y+c.vy,h.visit(b);function b(k,_,N,D,I){var z=k.data,F=k.r,G=v+F;if(z){if(z.index>c.index){var U=f-z.x-z.vx,j=g-z.y-z.vy,Q=U*U+j*j;Q<G*G&&(U===0&&(U=Oe(r),Q+=U*U),j===0&&(j=Oe(r),Q+=j*j),Q=(G-(Q=Math.sqrt(Q)))/Q*i,c.vx+=(U*=Q)*(G=(F*=F)/(m+F)),c.vy+=(j*=Q)*G,z.vx-=U*(G=1-G),z.vy-=j*G)}return}return _>f+G||D<f-G||N>g+G||I<g-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var d=u.r=0;d<4;++d)u[d]&&u[d].r>u.r&&(u.r=u[d].r)}function l(){if(e){var u,d=e.length,h;for(n=new Array(d),u=0;u<d;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,d){e=u,r=d,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:oe(+u),l(),a):t},a}function Mp(t){return t.index}function Bl(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Xi(t){var e=Mp,n=h,r,i=oe(30),o,a,s,l,u,d=1;t==null&&(t=[]);function h(m){return 1/Math.min(s[m.source.index],s[m.target.index])}function c(m){for(var y=0,b=t.length;y<d;++y)for(var k=0,_,N,D,I,z,F,G;k<b;++k)_=t[k],N=_.source,D=_.target,I=D.x+D.vx-N.x-N.vx||Oe(u),z=D.y+D.vy-N.y-N.vy||Oe(u),F=Math.sqrt(I*I+z*z),F=(F-o[k])/F*m*r[k],I*=F,z*=F,D.vx-=I*(G=l[k]),D.vy-=z*G,N.vx+=I*(G=1-G),N.vy+=z*G}function f(){if(a){var m,y=a.length,b=t.length,k=new Map(a.map((N,D)=>[e(N,D,a),N])),_;for(m=0,s=new Array(y);m<b;++m)_=t[m],_.index=m,typeof _.source!="object"&&(_.source=Bl(k,_.source)),typeof _.target!="object"&&(_.target=Bl(k,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(m=0,l=new Array(b);m<b;++m)_=t[m],l[m]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(b),g(),o=new Array(b),v()}}function g(){if(a)for(var m=0,y=t.length;m<y;++m)r[m]=+n(t[m],m,t)}function v(){if(a)for(var m=0,y=t.length;m<y;++m)o[m]=+i(t[m],m,t)}return c.initialize=function(m,y){a=m,u=y,f()},c.links=function(m){return arguments.length?(t=m,f(),c):t},c.id=function(m){return arguments.length?(e=m,c):e},c.iterations=function(m){return arguments.length?(d=+m,c):d},c.strength=function(m){return arguments.length?(n=typeof m=="function"?m:oe(+m),g(),c):n},c.distance=function(m){return arguments.length?(i=typeof m=="function"?m:oe(+m),v(),c):i},c}var Op={value:()=>{}};function Kl(){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 vr(n)}function vr(t){this._=t}function Fp(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}})}vr.prototype=Kl.prototype={constructor:vr,on:function(t,e){var n=this._,r=Fp(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=zp(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]=Wl(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Wl(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 vr(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 zp(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Wl(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Op,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Qi=Kl;var Ht=0,pn=0,fn=0,jl=1e3,yr,gn,wr=0,_t=0,br=0,mn=typeof performance=="object"&&performance.now?performance:Date,ql=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function to(){return _t||(ql($p),_t=mn.now()+br)}function $p(){_t=0}function Ji(){this._call=this._time=this._next=null}Ji.prototype=xr.prototype={constructor:Ji,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&&gn!==this&&(gn?gn._next=this:yr=this,gn=this),this._call=t,this._time=n,eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,eo())}};function xr(t,e,n){var r=new Ji;return r.restart(t,e,n),r}function Yl(){to(),++Ht;for(var t=yr,e;t;)(e=_t-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ht}function Vl(){_t=(wr=mn.now())+br,Ht=pn=0;try{Yl()}finally{Ht=0,Hp(),_t=0}}function Up(){var t=mn.now(),e=t-wr;e>jl&&(br-=e,wr=t)}function Hp(){for(var t,e=yr,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:yr=n);gn=t,eo(r)}function eo(t){if(!Ht){pn&&(pn=clearTimeout(pn));var e=t-_t;e>24?(t<1/0&&(pn=setTimeout(Vl,t-mn.now()-br)),fn&&(fn=clearInterval(fn))):(fn||(wr=mn.now(),fn=setInterval(Up,jl)),Ht=1,ql(Vl))}}function Zl(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Xl(t){return t.x}function Ql(t){return t.y}var Bp=10,Wp=Math.PI*(3-Math.sqrt(5));function no(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=xr(h),u=Qi("tick","end"),d=Zl();t==null&&(t=[]);function h(){c(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function c(v){var m,y=t.length,b;v===void 0&&(v=1);for(var k=0;k<v;++k)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),m=0;m<y;++m)b=t[m],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 v=0,m=t.length,y;v<m;++v){if(y=t[v],y.index=v,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var b=Bp*Math.sqrt(.5+v),k=v*Wp;y.x=b*Math.cos(k),y.y=b*Math.sin(k)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function g(v){return v.initialize&&v.initialize(t,d),v}return f(),e={tick:c,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?(d=v,s.forEach(g),e):d},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,y){var b=0,k=t.length,_,N,D,I,z;for(y==null?y=1/0:y*=y,b=0;b<k;++b)I=t[b],_=v-I.x,N=m-I.y,D=_*_+N*N,D<y&&(z=I,y=D);return z},on:function(v,m){return arguments.length>1?(u.on(v,m),e):u.on(v)}}}function ro(){var t,e,n,r,i=oe(-30),o,a=1,s=1/0,l=.81;function u(f){var g,v=t.length,m=xt(t,Xl,Ql).visitAfter(h);for(r=f,g=0;g<v;++g)e=t[g],m.visit(c)}function d(){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,y=0,b,k,_;if(f.length){for(b=k=_=0;_<4;++_)(v=f[_])&&(m=Math.abs(v.value))&&(g+=v.value,y+=m,b+=m*v.x,k+=m*v.y);f.x=b/y,f.y=k/y}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 c(f,g,v,m){if(!f.value)return!0;var y=f.x-e.x,b=f.y-e.y,k=m-g,_=y*y+b*b;if(k*k/l<_)return _<s&&(y===0&&(y=Oe(n),_+=y*y),b===0&&(b=Oe(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)),e.vx+=y*f.value*r/_,e.vy+=b*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(y===0&&(y=Oe(n),_+=y*y),b===0&&(b=Oe(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(k=o[f.data.index]*r/_,e.vx+=y*k,e.vy+=b*k);while(f=f.next)}return u.initialize=function(f,g){t=f,n=g,d()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:oe(+f),d(),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 io(t){var e=oe(.1),n,r,i;typeof t!="function"&&(t=oe(t==null?0:+t));function o(s){for(var l=0,u=n.length,d;l<u;++l)d=n[l],d.vx+=(i[l]-d.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:oe(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:oe(+s),a(),o):t},o}function oo(t){var e=oe(.1),n,r,i;typeof t!="function"&&(t=oe(t==null?0:+t));function o(s){for(var l=0,u=n.length,d;l<u;++l)d=n[l],d.vy+=(i[l]-d.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:oe(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:oe(+s),a(),o):t},o}var Kp=9,_r=6,kr=18,Vp=32,nu=9,Er=Kp+nu;function ao(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Vp));return _r+(kr-_r)*n}function so(t){return t+nu}var jp=300,ru=1,Jl=.001,qp=90,Yp=.02,Zp=170,Xp=.05,Qp=-50,eu=.09;function tu(t){return t==="contains"||t==="anchored-at"}function Jp(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function eg(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 lo(t){let e=Xi(t.links).id(n=>n.id).distance(n=>tu(n.kind)?qp:Zp).strength(n=>tu(n.kind)?Yp:Xp).iterations(2);return no(t.nodes).randomSource(Jp(t.seed??ru)).force("charge",ro().strength(Qp)).force("link",e).force("collide",Zi(n=>n.r??Er).strength(1)).force("x",io(0).strength(eu)).force("y",oo(0).strength(eu)).stop()}function tg(t,e,n){let r=lo({nodes:t,links:e.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(Jl).alphaDecay(n.ticks>0?1-Math.pow(Jl,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function iu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??jp)),{ids:r,edges:i}=eg(t),o=r.map(l=>{let u=e.initial?.get(l),d={id:l,vx:0,vy:0};return u!==void 0&&Number.isFinite(u.x)&&Number.isFinite(u.y)&&(d.x=u.x,d.y=u.y,e.pinWarm===!0&&(d.fx=u.x,d.fy=u.y)),d}),a=new Map;for(let l of i)a.set(l.source,(a.get(l.source)??0)+1),a.set(l.target,(a.get(l.target)??0)+1);for(let l of o)l.r=so(ao(a.get(l.id)??0));o.length>1&&tg(o,i,{ticks:n,seed:e.seed??ru,warm:e.initial!==void 0});let s=new Map;for(let l of o)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}function Te(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function ng(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,d=null,h=0,c=n.get("repository")??[];for(let f of c){let g=e.get(f);if(g&&g.kind==="module"&&g.detail.path){let v=g.detail.path;u.startsWith(v+"/")&&v.length>h&&(d=f,h=v.length)}}return d},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let d=a.get(u);d?d.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 su(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 rg(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function ou(t){return t?t.kind==="module"||t.id.startsWith("vfolder:"):!1}function ig(t,e){return t.slice().sort((n,r)=>{let i=e.get(n),o=e.get(r),a=ou(i),s=ou(o);if(a!==s)return a?-1:1;let l=Te(i),u=Te(o);return l.localeCompare(u)})}function au(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 og(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?au(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?au(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 uo(t,e){let n=ng(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let y=(i.get(g)??[]).filter(b=>{let k=r.get(b);if(!k||k.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(b))return!1;return!0}).concat(o.get(g)??[]);return y=y.filter(b=>r.has(b)),e.showInternals||(y=y.filter(b=>{let k=r.get(b);return!(k&&rg(k.kind))})),ig(y,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Te(g).toLowerCase().includes(e.query.toLowerCase())),d=new Set,h=g=>{let v=r.get(g),m=!1;for(let b of s(g))h(b)&&(m=!0);let y=u(v)||m;return y&&d.add(g),y};for(let g of a)h(g);let c=[],f=(g,v)=>{if(!d.has(g))return;let m=r.get(g),y=s(g),b=y.filter(_=>d.has(_)),k=l?b.length>0:e.expanded.has(g);if(c.push({id:g,depth:v,hasKids:y.length>0,expanded:k,label:Te(m),kind:m.kind,provenance:m.provenance,meta:og(m)}),k)for(let _ of b)f(_,v+1)};for(let g of a)f(g,0);return c}function co(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 vn(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var ag=7;function ho(t,e){if(t===null)return"";switch(t.kind){case"relTime":return vn(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,ag);case"text":return t.text}}var sg=["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 fo(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 sg){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Te(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Te(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Te(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function po(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 lg=["contains","anchored-at"];function ug(t){return lg.includes(t)}function Sr(t,e){let n=new Map;for(let c of t.nodes)n.set(c.id,c);let r=cg(t,n),i=su(t),o=new Set,a=c=>{if(!o.has(c)&&(o.add(c),!!e.has(c)))for(let f of r.get(c)??[])a(f)};for(let c of i)a(c);let s=new Map;for(let c of r.keys())s.set(c,dg(c,r));let l=new Map;for(let c of t.nodes)if(!(!o.has(c.id)||e.has(c.id)))for(let f of s.get(c.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,c.id);for(let c of t.nodes)!o.has(c.id)&&!l.has(c.id)&&o.add(c.id);let u=new Map;for(let[c,f]of r){let g=s.get(c);u.set(c,{children:f,descendants:g,members:g.filter(v=>l.get(v)===c),provenance:hg(g,n),expanded:e.has(c)})}let d=new Set,h=[];for(let c of t.nodes)o.has(c.id)?h.push(c):d.add(c.id);return{nodes:h,edges:fg(t.edges,o,l),clusters:u,hidden:d,representative:l,roots:i}}function cg(t,e){let n=new Map;for(let r of t.edges){if(!ug(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 dg(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 hg(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 fg(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 Bt=[null,"human","agent","generated"];function lu(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function kt(t){return{...t.model,danglingLinks:t.dangling}}function uu(t,e){return t===null?[]:uo(kt(t),e)}function yo(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function gg(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function mg(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function cu(t,e){return t.query===e?t:{...t,query:e}}function du(t){let e=Bt.indexOf(t.provFilter),n=Bt[(e+1)%Bt.length]??null;return{...t,provFilter:n}}function hu(t){return{...t,showInternals:!t.showInternals}}function Ar(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function vo(t,e){return t[e]?.id??null}function mo(t,e,n){if(t.length===0)return null;let r=Ar(t,e),i=r===-1?n>0?-1:t.length:r;return vo(t,Math.min(t.length-1,Math.max(0,i+n)))}function vg(t,e){let n=Ar(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 yg={j:"ArrowDown",k:"ArrowUp"};function wg(t){return yg[t]??t}function fu(t,e,n,r,i=!1){let o={state:e,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:e,selectedId:h,handled:!0}),s=wg(r);if(s==="ArrowDown")return a(mo(t,n,1));if(s==="ArrowUp")return a(mo(t,n,-1));if(s==="Home")return a(vo(t,0));if(s==="End")return a(vo(t,t.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=Ar(t,n),u=l===-1?void 0:t[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(mo(t,n,1)):{state:gg(e,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:mg(e,n),selectedId:n,handled:!0};let d=vg(t,n);return d===null?o:a(d)}var bg={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function wo(t){return bg[t]}var xg={human:"●",agent:"◐",generated:"○"};function Et(t){return t===null?"":xg[t]}function Wt(t){return t===null?"":`${t}-authored`}function pu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function _g(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 kg(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:pu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindIcon:wo(t.kind),provenance:t.provenance,provenanceGlyph:Et(t.provenance),provenanceTitle:Wt(t.provenance),twisty:i,hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:ho(t.meta,n),level:t.depth+1}}function gu(t,e,n){let r=_g(t);return t.map((i,o)=>kg(i,e,n,r[o]))}function mu(t,e){return Ar(t,e)===-1?null:pu(e)}function vu(t){return{"--weave-depth":String(Math.max(0,t))}}function Tr(t){return t===null?"all":t}function yu(t){let e=Bt.indexOf(t),n=Bt[(e+1)%Bt.length]??null;return`provenance filter: ${Tr(t)} — click for ${Tr(n)}`}function wu(t){return t?"internals":"knowledge"}function bu(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 xu="filter…",_u="Vault and repository",ku="Filter the tree",Eu="Filter the tree (/)";function Su(t,e,n){if(t===null)return"loading…";let r=co(kt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function Tu(t){return t.length===1?"1 row":`${t.length} rows`}var Rr={dark:{accent:"#c6a0f6",success:"#a6da95",warning:"#eed49f",dim:"#a5adcb",text:"#cad3f5",muted:"#939ab7",line:"#494d64",ground:"#24273a"},light:{accent:"#7113ec",success:"#28641b",warning:"#7c4f10",dim:"#56586a",text:"#4c4f69",muted:"#606274",line:"#bcc0cc",ground:"#eff1f5"}},Eg={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},Sg={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function Tg(t,e){return Rr[e][Eg[t]]}function Au(t,e){return Rr[e][Sg[t]]}function Ag(t,e){return Rg(t)?bo(Au(t,e),e,Ng):Au(t,e)}function Rg(t){return t==="contains"||t==="anchored-at"}var Cg=.85,Ng=.3;function Lg(t,e,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(t),o=r(e);if(i===null||o===null)return t;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,u)=>Math.round(l+(u-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function bo(t,e,n=Cg){return Lg(t,Rr[e].ground,n)}var Pg={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},Dg=1.6,Ru=32,Ig=Ru/2;function Gg(t,e=Ru){if(e<=0)return t.length>0?"…":t;if(t.length<=e)return t;let n=e-1,i=t.slice(0,n).lastIndexOf(" "),o=i>=Ig?i:n;return`${t.slice(0,o).trimEnd()}…`}function Mg(t){let e=Et(t.provenance),n=Te(t);return Gg(e===""?n:`${e} ${n}`)}function Cu(t){let e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of t)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<e&&(e=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[e,r],y:[n,i]}}var Nu={nodes:[],edges:[]};function Lu(t){return`${t.source}\0${t.target}\0${t.kind}`}function Og(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=Lu(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 Pu(t,e,n,r){let i=new Map;for(let d of t){if(i.has(d.id))continue;let h=n.get(d.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||i.set(d.id,d)}let o=new Set(i.keys()),a=Og(e,o),s=[];for(let[d,h]of i){let c=n.get(d),f=ao(a.get(d)??0);s.push({id:d,x:c.x,y:c.y,size:f,label:Mg(h),color:Tg(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(f),type:"circle"})}let l=[],u=new Set;for(let d of e){if(d.source===d.target||!o.has(d.source)||!o.has(d.target))continue;let h=Lu(d);u.has(h)||(u.add(h),l.push({key:h,source:d.source,target:d.target,size:Pg[d.kind],color:Ag(d.kind,r),kind:d.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function Du(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+Fg}:{color:bo(n.color,r),label:null,zIndex:0}}var Fg=kr+1;function Iu(t){return(e,n,r)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1,size:n.size*Dg}:{color:bo(n.color,r)}}var zg=(_r+kr)/2,$g=Er*4,Ug=1;function Gu(t){let e=Rr[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Ug,labelGridCellSize:$g,labelRenderedSizeThreshold:zg,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:Er,allowInvalidContainer:!0}}var zu=on(sr(),1);function Hg(){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=Hg;typeof Object.assign=="function"&&(ue=Object.assign);function Pe(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function me(t){return typeof t=="object"&&t!==null}function $u(t){let e;for(e in t)return!1;return!0}function Le(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Fe(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function Mu(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function Bg(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function Je(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function Vt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var bn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},C=class t extends bn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},A=class t extends bn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends bn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function Uu(t,e){this.key=t,this.attributes=e,this.clear()}Uu.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 Hu(t,e){this.key=t,this.attributes=e,this.clear()}Hu.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Bu(t,e){this.key=t,this.attributes=e,this.clear()}Bu.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function jt(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}jt.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};jt.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};jt.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};jt.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Wu=0,Ku=1,Wg=2,Vu=3;function et(t,e,n,r,i,o,a){let s,l,u,d;if(r=""+r,n===Wu){if(s=t._nodes.get(r),!s)throw new A(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,d=o}else if(n===Vu){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,c=l.target.key;if(r===h)s=l.target;else if(r===c)s=l.source;else throw new A(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${c}).`);u=o,d=a}else{if(l=t._edges.get(r),!l)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===Ku?s=l.source:s=l.target,u=i,d=o}return[s,u,d]}function Kg(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=et(this,e,n,r,i,o);return a.attributes[s]}}function Vg(t,e,n){t.prototype[e]=function(r,i){let[o]=et(this,e,n,r,i);return o.attributes}}function jg(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=et(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function qg(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=et(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 Yg(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=et(this,e,n,r,i,o,a);if(typeof u!="function")throw new C(`Graph.${e}: updater should be a function.`);let d=s.attributes,h=u(d[l]);return d[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Zg(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=et(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 Xg(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=et(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 Qg(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=et(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 Jg(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=et(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 em=[{name:t=>`get${t}Attribute`,attacher:Kg},{name:t=>`get${t}Attributes`,attacher:Vg},{name:t=>`has${t}Attribute`,attacher:jg},{name:t=>`set${t}Attribute`,attacher:qg},{name:t=>`update${t}Attribute`,attacher:Yg},{name:t=>`remove${t}Attribute`,attacher:Zg},{name:t=>`replace${t}Attributes`,attacher:Xg},{name:t=>`merge${t}Attributes`,attacher:Qg},{name:t=>`update${t}Attributes`,attacher:Jg}];function tm(t){em.forEach(function({name:e,attacher:n}){n(t,e("Node"),Wu),n(t,e("Source"),Ku),n(t,e("Target"),Wg),n(t,e("Opposite"),Vu)})}function nm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function rm(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=Pe(this,o,a,n),!i)throw new A(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function im(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function om(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Pe(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function am(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Pe(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new 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 sm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function lm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!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 um(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}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 cm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(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 dm=[{name:t=>`get${t}Attribute`,attacher:nm},{name:t=>`get${t}Attributes`,attacher:rm},{name:t=>`has${t}Attribute`,attacher:im},{name:t=>`set${t}Attribute`,attacher:om},{name:t=>`update${t}Attribute`,attacher:am},{name:t=>`remove${t}Attribute`,attacher:sm},{name:t=>`replace${t}Attributes`,attacher:lm},{name:t=>`merge${t}Attributes`,attacher:um},{name:t=>`update${t}Attributes`,attacher:cm}];function hm(t){dm.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var fm=[{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 pm(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 gm(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 xo(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 mm(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 vm(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 ym(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 ju(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:d,attributes:h,source:c,target:f}=s;if(l=r(d,h,c.key,f.key,c.attributes,f.attributes,s.undirected),t&&l)return d}}function wm(t,e){if(t.size===0)return Vt();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function ko(t,e,n,r,i,o){let a=e?gm:pm,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 bm(t,e,n,r){let i=[];return ko(!1,t,e,n,r,function(o){i.push(o)}),i}function xm(t,e,n){let r=Vt();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=Je(r,xo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=Je(r,xo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=Je(r,xo(n.undirected))),r}function Eo(t,e,n,r,i,o,a){let s=n?vm:mm,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 _m(t,e,n,r,i){let o=[];return Eo(!1,t,e,n,r,i,function(a){o.push(a)}),o}function km(t,e,n,r){let i=Vt();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=Je(i,_o(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=Je(i,_o(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=Je(i,_o(n.undirected,r))),i}function Em(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 ym(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 bm(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 _m(r,this.multi,i,s,a)}throw new C(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sm(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,d,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,ju(!1,this,r,h);if(arguments.length===2){u=""+u,h=d;let c=this._nodes.get(u);if(typeof c>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);return ko(!1,this.multi,r==="mixed"?this.type:r,i,c,h)}if(arguments.length===3){u=""+u,d=""+d;let c=this._nodes.get(u);if(!c)throw new A(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(d))throw new A(`Graph.${o}: could not find the "${d}" target node in the graph.`);return Eo(!1,r,this.multi,i,c,d,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),d=u.pop(),h;if(u.length===0){let c=0;r!=="directed"&&(c+=this.undirectedSize),r!=="undirected"&&(c+=this.directedSize),h=new Array(c);let f=0;u.push((g,v,m,y,b,k,_)=>{h[f++]=d(g,v,m,y,b,k,_)})}else h=[],u.push((c,f,g,v,m,y,b)=>{h.push(d(c,f,g,v,m,y,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),d=u.pop(),h=[];return u.push((c,f,g,v,m,y,b)=>{d(c,f,g,v,m,y,b)&&h.push(c)}),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 d,h;u.length===2?(d=u[0],h=u[1],u=[]):u.length===3?(d=u[1],h=u[2],u=[u[0]]):u.length===4&&(d=u[2],h=u[3],u=[u[0],u[1]]);let c=h;return u.push((f,g,v,m,y,b,k)=>{c=d(c,f,g,v,m,y,b,k)}),this[o].apply(this,u),c}}function Tm(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,d){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return d=l,ju(!0,this,r,d);if(arguments.length===2){l=""+l,d=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 ko(!0,this.multi,r==="mixed"?this.type:r,i,h,d)}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 Eo(!0,r,this.multi,i,h,u,d)}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,c,f,g,v,m,y)=>u(h,c,f,g,v,m,y)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,c,f,g,v,m,y)=>!u(h,c,f,g,v,m,y)),!this[o].apply(this,l)}}function Am(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Vt();if(!arguments.length)return wm(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 xm(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 km(r,i,l,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Rm(t){fm.forEach(e=>{Em(t,e),Sm(t,e),Tm(t,e),Am(t,e)})}var Cm=[{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 Gr(){this.A=null,this.B=null}Gr.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Gr.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function yn(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 d=i(u.key,u.attributes);if(t&&d)return u.key}}function So(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return yn(t,null,r,r.undirected,i);if(typeof n=="string")return yn(t,null,r,r[n],i)}let o=new Gr,a;if(e!=="undirected"){if(n!=="out"){if(a=yn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=yn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=yn(t,o,r,r.undirected,i),t&&a))return a}function Nm(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 So(!1,t,e,n,function(i){r.push(i)}),r}function wn(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 Lm(t,e,n){if(t!=="mixed"){if(t==="undirected")return wn(null,n,n.undirected);if(typeof e=="string")return wn(null,n,n[e])}let r=Vt(),i=new Gr;return t!=="undirected"&&(e!=="out"&&(r=Je(r,wn(i,n,n.in))),e!=="in"&&(r=Je(r,wn(i,n,n.out)))),t!=="directed"&&(r=Je(r,wn(i,n,n.undirected))),r}function Pm(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 Nm(r==="mixed"?this.type:r,i,a)}}function Dm(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,d){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.`);So(!1,r==="mixed"?this.type:r,i,h,d)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,d){let h=[];return this[o](u,(c,f)=>{h.push(d(c,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,d){let h=[];return this[o](u,(c,f)=>{d(c,f)&&h.push(c)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,d,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 c=h;return this[o](u,(f,g)=>{c=d(c,f,g)}),c}}function Im(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,d){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 So(!0,r==="mixed"?this.type:r,i,h,d)};let s="some"+o;t.prototype[s]=function(u,d){return!!this[a](u,d)};let l="every"+o;t.prototype[l]=function(u,d){return!this[a](u,(c,f)=>!d(c,f))}}function Gm(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Vt();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return Lm(r==="mixed"?this.type:r,i,s)}}function Mm(t){Cm.forEach(e=>{Pm(t,e),Dm(t,e),Im(t,e),Gm(t,e)})}function Cr(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,d,h,c,f;for(;s=o.next(),s.done!==!0;){let g=!1;if(l=s.value,a!=="undirected"){d=l.out;for(u in d){h=d[u];do{if(c=h.target,g=!0,f=i(l.key,c.key,l.attributes,c.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){d=l.undirected;for(u in d)if(!(e&&l.key>u)){h=d[u];do{if(c=h.target,c.key!==u&&(c=h.source),g=!0,f=i(l.key,c.key,l.attributes,c.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 Om(t,e){let n={key:t};return $u(e.attributes)||(n.attributes=ue({},e.attributes)),n}function Fm(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return $u(n.attributes)||(r.attributes=ue({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function zm(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 $m(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 Um=Bg(),Hm=new Set(["directed","undirected","mixed"]),Ou=new Set(["domain","_events","_eventsCount","_maxListeners"]),Bm=[{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"}],Wm={allowSelfLoops:!0,multi:!1,type:"mixed"};function Km(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 Fu(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function qu(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!me(s))throw new 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 d={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let h=new jt(r,i,l,u,s);t._edges.set(i,h);let c=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,c&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,c&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,d.key=i,t.emit("edgeAdded",d),i}function Vm(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 d=t._nodes.get(o),h=t._nodes.get(a),c,f;if(!n&&(c=t._edges.get(i),c)){if((c.source.key!==o||c.target.key!==a)&&(!r||c.source.key!==a||c.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!t.multi&&d&&(f=r?d.undirected[a]:d.out[a]),f){let b=[f.key,!1,!1,!1];if(l?!u:!s)return b;if(l){let k=f.attributes;f.attributes=u(k),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 v=!1,m=!1;d||(d=Fu(t,o,{}),v=!0,o===a&&(h=d,m=!0)),h||(h=Fu(t,a,{}),m=!0),c=new jt(r,i,d,h,s),t._edges.set(i,c);let y=o===a;return r?(d.undirectedDegree++,h.undirectedDegree++,y&&(d.undirectedLoops++,t._undirectedSelfLoopCount++)):(d.outDegree++,h.inDegree++,y&&(d.directedLoops++,t._directedSelfLoopCount++)),t.multi?c.attachMulti():c.attach(),r?t._undirectedSize++:t._directedSize++,g.key=i,t.emit("edgeAdded",g),[i,!0,v,m]}function Kt(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var K=class t extends zu.EventEmitter{constructor(e){if(super(),e=ue({},Wm,e),typeof e.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Hm.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"?Uu:e.type==="directed"?Hu:Bu;Le(this,"NodeDataClass",n);let r="geid_"+Um()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Le(this,"_attributes",{}),Le(this,"_nodes",new Map),Le(this,"_edges",new Map),Le(this,"_directedSize",0),Le(this,"_undirectedSize",0),Le(this,"_directedSelfLoopCount",0),Le(this,"_undirectedSelfLoopCount",0),Le(this,"_edgeKeyGenerator",o),Le(this,"_options",e),Ou.forEach(a=>Le(this,a,this[a])),Fe(this,"order",()=>this._nodes.size),Fe(this,"size",()=>this._edges.size),Fe(this,"directedSize",()=>this._directedSize),Fe(this,"undirectedSize",()=>this._undirectedSize),Fe(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Fe(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Fe(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Fe(this,"multi",this._options.multi),Fe(this,"type",this._options.type),Fe(this,"allowSelfLoops",this._options.allowSelfLoops),Fe(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new 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 Km(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 A(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Kt(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Kt(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Kt(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=Pe(this,r,i,this.type),!n)throw new A(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new A(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Kt(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,n=""+n;let r=Pe(this,e,n,"directed");if(!r)throw new A(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Kt(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let r=Pe(this,e,n,"undirected");if(!r)throw new A(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Kt(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new 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&&!Mu(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&&!Mu(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.");Cr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Cr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Cr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Cr(!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++]=Om(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=Fm(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,d,h,c,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,d,h,u):this.mergeDirectedEdgeWithKey(l,d,h,u):g?this.addUndirectedEdgeWithKey(l,d,h,u):this.addDirectedEdgeWithKey(l,d,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],zm(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],$m(s);let{source:u,target:d,attributes:h,undirected:c=l}=s,f;"key"in s?(f=n?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,d,h)):(f=n?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,d,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,qu(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,d=o.target.key,h;o.undirected&&u>d&&(h=u,u=d,d=h);let c=`(${u})${s}(${d})`;a.startsWith("geid_")?this.multi&&(typeof r[c]>"u"?r[c]=0:r[c]++,l+=`${r[c]}. `):l+=`[${a}]: `,l+=c,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!Ou.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Le(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);Bm.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?qu:Vm;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")}})});tm(K);hm(K);Rm(K);Mm(K);var Nr=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)}},Lr=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)}},Pr=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)}},Dr=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)}},Ir=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 qt(t){t.from=function(e,n){let r=ue({},e.options,n),i=new t(r);return i.import(e),i}}qt(K);qt(Nr);qt(Lr);qt(Pr);qt(Dr);qt(Ir);K.Graph=K;K.DirectedGraph=Nr;K.UndirectedGraph=Lr;K.MultiGraph=Pr;K.MultiDirectedGraph=Dr;K.MultiUndirectedGraph=Ir;K.InvalidArgumentsGraphError=C;K.NotFoundGraphError=A;K.UsageGraphError=M;function jm(){return new K({multi:!0,type:"directed"})}function To(t){let e=jm();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 Yu(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 Ao(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function Zu(t,e){let n=null,r=To({nodes:[],edges:[]}),i=null,o=()=>{},a=()=>{},s=()=>{},l=()=>{},u=null,d=f=>{if(u===null)return;let g=u;u=null,n?.setSetting("enableCameraPanning",!0),(f===null||f===g)&&l(g)},h=()=>Cu([...Ao(r).values()]),c=f=>{let g=Du(i),v=Iu(i);f.setSetting("nodeReducer",(m,y)=>({...y,...g(m,y,e)})),f.setSetting("edgeReducer",(m,y)=>({...y,...v(m,y,e)}))};return{mount(f){if(n!==null)return;let g=t(r,f,Gu(e));g.on("clickNode",({node:v})=>o(v)),g.on("clickStage",()=>o(null)),g.on("downNode",({node:v})=>{u=v,n?.setSetting("enableCameraPanning",!1),a(v)}),g.on("moveBody",v=>{u!==null&&(v.preventSigmaDefault(),s(u,g.viewportToGraph({x:v.event.x,y:v.event.y})))}),g.on("upNode",()=>d(u)),g.on("upStage",()=>d(null)),c(g),g.setCustomBBox(h()),n=g},setGraph(f){r=To(f),n?.setGraph(r),n?.setCustomBBox(h())},setPositions(f){Yu(r,f),n?.refresh()},setHighlight(f){i=f,n!==null&&c(n)},onSelect(f){o=f},onDragStart(f){a=f},onDragMove(f){s=f},onDragEnd(f){l=f},fit(){n?.setCustomBBox(h()),n?.getCamera().animatedReset()},positions(){return Ao(r)},destroy(){n?.kill(),n=null}}}var Xu=t=>Zu((e,n,r)=>new El(e,n,r),t);var Qu=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Ju(t,e,n){return t===0?null:t===1?0:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function ec(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function tc(t){return t===null?!1:(t.focus(),!0)}function Mr(){let t=re(null);return ie(()=>{let e=document.activeElement;return t.current?.focus(),()=>{tc(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!ec(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(Qu)??[]],r=Ju(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function ic(t,e){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i<0?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}function qm(t){return Math.min(Math.max(t,0),10)*2}function Ym(t){return`note:${t}`}function Zm(t,e){return ic(t.summary.title,e)+qm(t.score)}function Xm(t,e){return ic(t.label,e)}var Qm=["path","manifest","url","slug"];function Jm(t){for(let e of Qm){let n=t.detail[e];if(typeof n=="string"&&n)return n}return""}function ev(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 tv(t,e,n,r){let i=new Map;for(let o of t){let a=Ym(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Zm(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=Xm(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Jm(o),badge:o.kind,score:a})}return[...i.values()].sort(ev).slice(0,20)}function oc(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Ro(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function nc(t,e,n){return n<=0?0:((t+e)%n+n)%n}function ac(t,e){return e===null?null:t[e]?.id??null}function sc(t,e,n){let r={cursor:t,activate:null,dismiss:!1,handled:!1},i=Ro(t,n);return e==="ArrowDown"?{...r,cursor:nc(i,1,n),handled:!0}:e==="ArrowUp"?{...r,cursor:nc(i,-1,n),handled:!0}:e==="Home"?{...r,cursor:0,handled:!0}:e==="End"?{...r,cursor:Ro(n-1,n),handled:!0}:e==="Escape"?{...r,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var Or="Search the workspace",lc="Search notes and repository…",uc="↑↓ move · ↵ open · esc close";function nv(t,e){return t.query.trim()?e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading?"searching…":`no matches for “${t.query.trim()}”`:"Type to search notes, modules, files and entry points."}function rv(t){return t===1?"1 result":`${t} results`}function rc(t){return`weave-search-row-${t}`}function cc(t,e){let n=tv(t.hits,t.answered,e?.model.nodes??[],t.query),r=Ro(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:rc(a)})),status:nv(t,n.length),count:n.length,countLabel:rv(n.length),cursor:r,activeDomId:n.length?rc(r):null}}var iv=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:--iv,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return B.vnode&&B.vnode(u),u}function av({row:t,onPick:e,onHover:n}){return x("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[x("span",{class:"weave-hit-badge",children:t.badge}),x("span",{class:"weave-hit-label",children:t.label}),x("span",{class:"weave-hit-detail",children:t.detail})]})}function dc(t){let[e,n]=he(oc),r=re(0),i=re(null),o=Mr(),a=re(null);ie(()=>{a.current?.focus()},[]),ie(()=>{let u=e.query.trim(),d=!0;if(!u)return i.current?.abort(),n(c=>({...c,hits:[],answered:"",loading:!1,failed:!1})),()=>{d=!1};let h=window.setTimeout(async()=>{let c=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(v=>({...v,loading:!0,failed:!1}));let g=await ys(t.ports.fetch,u,f.signal);!d||f.signal.aborted||c!==r.current||n(v=>g.ok?{...v,hits:g.data.hits,answered:u,loading:!1,failed:!1,cursor:0}:{...v,loading:!1,failed:!0})},140);return()=>{d=!1,window.clearTimeout(h),i.current?.abort()}},[e.query,t.ports.fetch]);let s=cc(e,t.graph),l=u=>{let d=ac(s.rows,u);d!==null&&t.onSelect(d),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>l(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Or,tabIndex:-1,ref:o.ref,onClick:u=>u.stopPropagation(),onKeyDown:u=>{if(o.onKeyDown(u))return;let d=sc(e.cursor,u.key,s.count);d.handled&&(u.preventDefault(),n(h=>({...h,cursor:d.cursor})),d.dismiss&&l(d.activate))},children:[x("input",{type:"search",class:"weave-palette-input",ref:a,value:e.query,placeholder:lc,"aria-label":Or,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:u=>n(d=>({...d,query:u.currentTarget.value,cursor:0}))}),s.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Or,children:s.rows.map((u,d)=>x(av,{row:u,onPick:()=>l(d),onHover:()=>n(h=>({...h,cursor:d}))},u.id))}):x("p",{class:"weave-palette-status",role:"status",children:s.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:s.countLabel}),x("span",{class:"weave-palette-hint",children:uc})]})]})})}var hc="pi-weave.selection.v1";function fc(t,e){try{return t.setItem(hc,e??""),!0}catch{return!1}}function pc(t,e){if(t===null)return null;let n;try{n=e.getItem(hc)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}function gc(){return{graph:null,graphFailed:!1,note:null,recentIds:new Set,selectedId:null}}var sv=2e3,lv=3e3,vc=new Set;function uv(t,e){if(t===null)return vc;let n=new Set(t.model.nodes.map(r=>r.id));return new Set(e.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function mc(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function yc(t){let e=t.state,n=!1,r=!1,i=null,o=c=>{Object.entries(c).every(([f,g])=>e[f]===g)||(e={...e,...c},t.setState(e))},a=t.defer??((c,f)=>{let g=setTimeout(c,f);return()=>clearTimeout(g)}),s=async()=>{let c=mc(e.selectedId);if(c===null){o({note:null});return}let f=await vs(t.fetch,c);f.ok&&o({note:f.data})},l=async()=>{let c=e.graph,f=await ms(t.fetch,e.graph);if(!f.ok)return e.graph===null&&o({graphFailed:!0}),f;if(!f.cached){let g=uv(c,f.data);o({graph:f.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=a(()=>{i=null,o({recentIds:vc})},lv))}return f},u=async()=>{if(!(n||r)){r=!0;try{let c=await l();c.ok&&!c.cached&&mc(e.selectedId)!==null&&await s()}finally{r=!1}}},h=(t.repeat??((c,f)=>{let g=setInterval(c,f);return()=>clearInterval(g)}))(()=>{u()},sv);return u(),{refresh:()=>{u()},select:async c=>{o({selectedId:c}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function wc(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 cv=300,dv=1;function hv(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:cv,seed:dv,pinWarm:!0};return r.size>0&&(i.initial=r),iu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function fv(t,e){let n=0,r=0;for(let o of t){let a=wc(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=wc(`${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 xc="pi-weave.graph.positions.v3";function bc(t){return Math.round(t*10)/10}function pv(t,e){let n={};for(let[r,i]of e)n[r]=[bc(i.x),bc(i.y)];return JSON.stringify({v:3,key:t,at:n})}function gv(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==3||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function mv(t,e){let n;try{n=t.getItem(xc)}catch{return null}return gv(n,e)}function vv(t,e,n){try{return t.setItem(xc,pv(e,n)),!0}catch{return!1}}function _c(t,e,n){let r=fv(e,n),i=mv(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=hv(e,n);return vv(t,r,o),{key:r,positions:o,cached:!1}}function yv(t){return{expanded:new Set(Sr(t,new Set).clusters.keys())}}function Ec(t,e){return e!==null?e:t===null?{expanded:new Set}:yv(kt(t))}function wv(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function bv(t,e){return{...t,expanded:new Set(e.keys())}}function xv(t){return{...t,expanded:new Set}}function _v(t,e){return e===null?null:po(e,t)}function Sc(t){return t?"collapse":"expand"}function Tc(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function Co(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function Ac(t,e){return Co(t,e)?xv(t):bv(t,e)}var Rc="fit",Cc="frame the whole graph",Fr={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Nc(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function kv(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 Ev="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",kc={graph:Nu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Lc(t,e,n,r,i,o=!1){if(t===null)return o?{...kc,empty:Ev}:kc;let a=kt(t),s=Sr(a,n.expanded),l=_c(r,s.nodes,s.edges);return{graph:Pu(s.nodes,s.edges,l.positions,i),highlight:_v(s.edges,e),key:l.key,cached:l.cached,clusters:s.clusters,visible:s.nodes.length,total:a.nodes.length,empty:kv(t,s.nodes.length)}}function Pc(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:wv(t,n),selectedId:n}}var Sv=.06,Tv=.2,No=.001;function Dc(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(s=>{let l=e?.get(s.id);return{id:s.id,x:l!==void 0&&Number.isFinite(l.x)?l.x:s.x,y:l!==void 0&&Number.isFinite(l.y)?l.y:s.y,vx:0,vy:0,r:so(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of t.edges){if(s.source===s.target||!r.has(s.source)||!r.has(s.target))continue;let l=`${s.source}\0${s.target}\0${s.kind}`;i.has(l)||(i.add(l),o.push({source:s.source,target:s.target,kind:s.kind}))}let a=lo({nodes:n,links:o,seed:1}).alpha(Sv).alphaMin(No);return{tick(){a.tick()},awake(){return a.alphaTarget()>No||a.alpha()>No},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let u=r.get(s);u&&(u.fx=l.x,u.fy=l.y,a.alphaTarget(Tv))},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}function Ic(t){let e=re(null),n=re(null),r=re(null),i=re(null),o=hs(()=>{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=t.scheme??nr(t.host),u=Ec(t.graph,a),d=vt(()=>Lc(t.graph,t.selectedId,u,t.storage,l,t.bootFailed),[t.graph,t.selectedId,u,t.storage,l,t.bootFailed]),h=Co(u,d.clusters),c=re({view:u,model:d,onSelect:t.onSelect});return c.current={view:u,model:d,onSelect:t.onSelect},ie(()=>{let f=t.renderer(l);return f.onSelect(g=>{let v=Pc(c.current.view,c.current.model.clusters,g);s(v.state),c.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,f.setGraph(c.current.model.graph),f.setHighlight(c.current.model.highlight),t.fit.current=()=>f.fit(),()=>{f.destroy(),n.current=null,t.fit.current=null}},[t.renderer,l]),ie(()=>{n.current?.setGraph(d.graph)},[d.key]),ie(()=>{let f=Dc(d.graph,n.current?.positions());return r.current=f,f!==null&&o(),()=>{r.current=null}},[d.key,o]),ie(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),ie(()=>{n.current?.setHighlight(d.highlight)},[d.highlight]),x("div",{class:"weave-graph",children:[d.empty===null?null:x("p",{class:"weave-graph-empty",children:d.empty}),x("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Cc,onClick:()=>n.current?.fit(),children:Rc}),x("button",{type:"button",class:"weave-chip",title:Tc(h),onClick:()=>s(Ac(u,d.clusters)),children:Sc(h)}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",Fr.selected]}),x("span",{class:"weave-legend-near",children:["● ",Fr.neighborhood]}),x("span",{class:"weave-legend-dim",children:["· ",Fr.dimmed]})]})]}),x("p",{class:"weave-graph-count",children:Nc(d.visible,d.total)})]})}function Gc(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 Av(t){if(Array.isArray(t))return t}function Rv(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(d){u=!0,i=d}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function Cv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
333
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nv(t,e){return Av(t)||Rv(t,e)||Lv(t,e)||Cv()}function Lv(t,e){if(t){if(typeof t=="string")return Gc(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)?Gc(t,e):void 0}}var Zc=Object.entries,Mc=Object.setPrototypeOf,Pv=Object.isFrozen,Dv=Object.getPrototypeOf,Iv=Object.getOwnPropertyDescriptor,ce=Object.freeze,pe=Object.seal,Yt=Object.create,Xc=typeof Reflect<"u"&&Reflect,Oo=Xc.apply,Fo=Xc.construct;ce||(ce=function(e){return e});pe||(pe=function(e){return e});Oo||(Oo=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)});Fo||(Fo=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Tt=ae(Array.prototype.forEach),Gv=ae(Array.prototype.lastIndexOf),Oc=ae(Array.prototype.pop),xn=ae(Array.prototype.push),Mv=ae(Array.prototype.splice),Zt=Array.isArray,En=ae(String.prototype.toLowerCase),Lo=ae(String.prototype.toString),Fc=ae(String.prototype.match),_n=ae(String.prototype.replace),zc=ae(String.prototype.indexOf),Ov=ae(String.prototype.trim),Fv=ae(Number.prototype.toString),zv=ae(Boolean.prototype.toString),$c=typeof BigInt>"u"?null:ae(BigInt.prototype.toString),Uc=typeof Symbol>"u"?null:ae(Symbol.prototype.toString),Se=ae(Object.prototype.hasOwnProperty),kn=ae(Object.prototype.toString),ve=ae(RegExp.prototype.test),St=$v(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 Oo(t,e,r)}}function $v(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Fo(t,n)}}function H(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:En;if(Mc&&Mc(t,null),!Zt(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(Pv(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Uv(t){for(let e=0;e<t.length;e++)Se(t,e)||(t[e]=null);return t}function Re(t){let e=Yt(null);for(let r of Zc(t)){var n=Nv(r,2);let i=n[0],o=n[1];Se(t,i)&&(Zt(o)?e[i]=Uv(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Re(o):e[i]=o)}return e}function Hv(t){switch(typeof t){case"string":return t;case"number":return Fv(t);case"boolean":return zv(t);case"bigint":return $c?$c(t):"0";case"symbol":return Uc?Uc(t):"Symbol()";case"undefined":return kn(t);case"function":case"object":{if(t===null)return kn(t);let e=t,n=ze(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 ze(t,e){for(;t!==null;){let r=Iv(t,e);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}t=Dv(t)}function n(){return null}return n}function Bv(t){try{return ve(t,""),!0}catch{return!1}}var Hc=ce(["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"]),Po=ce(["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"]),Do=ce(["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"]),Wv=ce(["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"]),Io=ce(["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"]),Kv=ce(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bc=ce(["#text"]),Wc=ce(["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"]),Go=ce(["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"]),Kc=ce(["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"]),zr=ce(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vv=pe(/{{[\w\W]*|^[\w\W]*}}/g),jv=pe(/<%[\w\W]*|^[\w\W]*%>/g),qv=pe(/\${[\w\W]*/g),Yv=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Zv=pe(/^aria-[\-\w]+$/),Vc=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xv=pe(/^(?:\w+script|data):/i),Qv=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Jv=pe(/^html$/i),ey=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),jc=pe(/<[/\w!]/g),qc=pe(/<[/\w]/g),ty=pe(/<\/no(script|embed|frames)/i),ny=pe(/\/>/i),Ae={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Qc=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],ry=ce(H({},Qc)),iy=(function(){let t={};return Tt(Qc,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),ce(t)})(),oy=function(){return typeof window>"u"?null:window},ay=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Yc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ct=function(e,n,r,i){return Se(e,n)&&Zt(e[n])?H(i.base?Re(i.base):{},e[n],i.transform):r},Mo=function(e,n,r){let i=Se(e,n)?e[n]:void 0;return i&&typeof i=="object"?Re(i):r()};function Jc(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oy(),e=T=>Jc(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ae.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let d=t.DOMParser,h=t.trustedTypes,c=s.prototype,f=ze(c,"cloneNode"),g=ze(c,"remove"),v=ze(c,"nextSibling"),m=ze(c,"childNodes"),y=ze(c,"parentNode"),b=ze(c,"shadowRoot"),k=ze(c,"attributes"),_=a&&a.prototype?ze(a.prototype,"nodeType"):null,N=a&&a.prototype?ze(a.prototype,"nodeName"):null,D=a&&a.prototype?ze(a.prototype,"ownerDocument"):null,I=function(p){return _?_(p):p.nodeType},z=function(p){return N?N(p):p.nodeName};if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let F,G="",U,j=!1,Q=0,ge=function(){if(Q>0)throw St('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},de=function(p){ge(),Q++;try{return F.createHTML(p)}finally{Q--}},Be=function(p){ge(),Q++;try{return F.createScriptURL(p)}finally{Q--}},Nt=function(){return j||(U=ay(h,i),j=!0),U},De=n,Ie=De.implementation,Ge=De.createNodeIterator,We=De.createDocumentFragment,Jt=De.getElementsByTagName,Ce=r.importNode,q=Yc();e.isSupported=typeof Zc=="function"&&typeof y=="function"&&Ie&&Ie.createHTMLDocument!==void 0;let en=Vv,Eh=jv,Sh=qv,Th=Yv,Ah=Zv,Rh=Xv,la=Qv,Ch=ey,ua=Vc,Z=null,ei=H({},[...Hc,...Po,...Do,...Io,...Bc]),X=null,ti=H({},[...Wc,...Go,...Kc,...zr]),Ke=Object.seal(Yt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),tn=null,ca=null,nt=Object.seal(Yt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),da=!0,ni=!0,ha=!1,fa=!0,rt=!1,ft=!0,pt=!1,ri=!1,Pn=null,Dn=null,ii=!1,Lt=!1,In=!1,Gn=!1,pa=!0,ga=!1,ma="user-content-",oi=!0,ai=!1,Pt={},Dt=null,va=H({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),ya=null,wa=H({},["audio","video","img","source","image","track"]),ba=null,xa=H({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mn="http://www.w3.org/1998/Math/MathML",On="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml",It=Ve,si=!1,li=null,Nh=H({},[Mn,On,Ve],Lo),_a=ce(["mi","mo","mn","ms","mtext"]),ui=H({},_a),ka=ce(["annotation-xml"]),ci=H({},ka),Lh=H({},["title","style","font","a","script"]),nn=null,Ph=["application/xhtml+xml","text/html"],Dh="text/html",te=null,Gt=null,Ih=n.createElement("form"),Ea=function(p){return p instanceof RegExp||p instanceof Function},di=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Gt&&Gt===p)return;(!p||typeof p!="object")&&(p={}),p=Re(p),nn=Ph.indexOf(p.PARSER_MEDIA_TYPE)===-1?Dh:p.PARSER_MEDIA_TYPE,te=nn==="application/xhtml+xml"?Lo:En,Z=ct(p,"ALLOWED_TAGS",ei,{transform:te}),X=ct(p,"ALLOWED_ATTR",ti,{transform:te}),li=ct(p,"ALLOWED_NAMESPACES",Nh,{transform:Lo}),ba=ct(p,"ADD_URI_SAFE_ATTR",xa,{transform:te,base:xa}),ya=ct(p,"ADD_DATA_URI_TAGS",wa,{transform:te,base:wa}),Dt=ct(p,"FORBID_CONTENTS",va,{transform:te}),tn=ct(p,"FORBID_TAGS",Re({}),{transform:te}),ca=ct(p,"FORBID_ATTR",Re({}),{transform:te}),Pt=Se(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Re(p.USE_PROFILES):p.USE_PROFILES:!1,da=p.ALLOW_ARIA_ATTR!==!1,ni=p.ALLOW_DATA_ATTR!==!1,ha=p.ALLOW_UNKNOWN_PROTOCOLS||!1,fa=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,rt=p.SAFE_FOR_TEMPLATES||!1,ft=p.SAFE_FOR_XML!==!1,pt=p.WHOLE_DOCUMENT||!1,Lt=p.RETURN_DOM||!1,In=p.RETURN_DOM_FRAGMENT||!1,Gn=p.RETURN_TRUSTED_TYPE||!1,ii=p.FORCE_BODY||!1,pa=p.SANITIZE_DOM!==!1,ga=p.SANITIZE_NAMED_PROPS||!1,oi=p.KEEP_CONTENT!==!1,ai=p.IN_PLACE||!1,ua=Bv(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:Vc,It=typeof p.NAMESPACE=="string"?p.NAMESPACE:Ve,ui=Mo(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>H({},_a)),ci=Mo(p,"HTML_INTEGRATION_POINTS",()=>H({},ka));let w=Mo(p,"CUSTOM_ELEMENT_HANDLING",()=>Yt(null));if(Ke=Yt(null),Se(w,"tagNameCheck")&&Ea(w.tagNameCheck)&&(Ke.tagNameCheck=w.tagNameCheck),Se(w,"attributeNameCheck")&&Ea(w.attributeNameCheck)&&(Ke.attributeNameCheck=w.attributeNameCheck),Se(w,"allowCustomizedBuiltInElements")&&typeof w.allowCustomizedBuiltInElements=="boolean"&&(Ke.allowCustomizedBuiltInElements=w.allowCustomizedBuiltInElements),pe(Ke),rt&&(ni=!1),In&&(Lt=!0),Pt&&(Z=H({},Bc),X=Yt(null),Pt.html===!0&&(H(Z,Hc),H(X,Wc)),Pt.svg===!0&&(H(Z,Po),H(X,Go),H(X,zr)),Pt.svgFilters===!0&&(H(Z,Do),H(X,Go),H(X,zr)),Pt.mathMl===!0&&(H(Z,Io),H(X,Kc),H(X,zr))),nt.tagCheck=null,nt.attributeCheck=null,Se(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?nt.tagCheck=p.ADD_TAGS:Zt(p.ADD_TAGS)&&(Z===ei&&(Z=Re(Z)),H(Z,p.ADD_TAGS,te))),Se(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?nt.attributeCheck=p.ADD_ATTR:Zt(p.ADD_ATTR)&&(X===ti&&(X=Re(X)),H(X,p.ADD_ATTR,te))),Se(p,"ADD_FORBID_CONTENTS")&&Zt(p.ADD_FORBID_CONTENTS)&&(Dt===va&&(Dt=Re(Dt)),H(Dt,p.ADD_FORBID_CONTENTS,te)),oi&&(Z["#text"]=!0),pt&&H(Z,["html","head","body"]),Z.table&&(H(Z,["tbody"]),delete tn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw St('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw St('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=F;F=p.TRUSTED_TYPES_POLICY;try{G=de("")}catch(R){throw F=E,R}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=Nt()),F&&typeof G=="string"&&(G=de("")));ce&&ce(p),Gt=p},Sa=H({},[...Po,...Do,...Wv]),Ta=H({},[...Io,...Kv]),Gh=function(p,w,E){return w.namespaceURI===Ve?p==="svg":w.namespaceURI===Mn?p==="svg"&&(E==="annotation-xml"||ui[E]):!!Sa[p]},Mh=function(p,w,E){return w.namespaceURI===Ve?p==="math":w.namespaceURI===On?p==="math"&&ci[E]:!!Ta[p]},Oh=function(p,w,E){return w.namespaceURI===On&&!ci[E]||w.namespaceURI===Mn&&!ui[E]?!1:!Ta[p]&&(Lh[p]||!Sa[p])},Fh=function(p){let w=y(p);(!w||!w.tagName)&&(w={namespaceURI:It,tagName:"template"});let E=En(p.tagName),R=En(w.tagName);return li[p.namespaceURI]?p.namespaceURI===On?Gh(E,w,R):p.namespaceURI===Mn?Mh(E,w,R):p.namespaceURI===Ve?Oh(E,w,R):!!(nn==="application/xhtml+xml"&&li[p.namespaceURI]):!1},it=function(p){xn(e.removed,{element:p});try{y(p).removeChild(p)}catch{if(g(p),!y(p))throw St("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Aa=function(p,w,E){try{p.removeAttributeNode(w)}catch{try{p.removeAttribute(E)}catch{}}},Fn=function(p){zn(p);let w=m(p);if(w){let R=[];Tt(w,P=>{xn(R,P)}),Tt(R,P=>{try{g(P)}catch{}})}let E=k(p);if(E)for(let R=E.length-1;R>=0;--R){let P=E[R],O=P&&P.name;typeof O=="string"&&Aa(p,P,O)}},gt=function(p,w,E){if(!E)try{E=w.getAttributeNode(p)}catch{E=null}xn(e.removed,{attribute:E||null,from:w});try{E?w.removeAttributeNode(E):w.removeAttribute(p)}catch{try{w.removeAttribute(p)}catch{}}if(p==="is")if(Lt||In)try{it(w)}catch{}else try{w.setAttribute(p,"")}catch{}},zh=function(p){let w=k(p);if(w)for(let E=w.length-1;E>=0;--E){let R=w[E],P=R&&R.name;typeof P!="string"||X[te(P)]||Aa(p,R,P)}},zn=function(p){let w=[p];for(;w.length>0;){let E=w.pop();I(E)===Ae.element&&zh(E);let P=m(E);if(P)for(let O=P.length-1;O>=0;--O)w.push(P[O])}},Ra=function(p,w){return ft?p==="patchsrc"?!0:p==="for"&&w!=="label"&&w!=="output":!1},$h=function(p){if(!ft)return;let w=[p];for(;w.length>0;){let E=w.pop(),R=I(E);if(R===Ae.processingInstruction||R===Ae.comment&&ve(qc,E.data)){try{g(E)}catch{}continue}if(R===Ae.element){let O=E,Y=te(z(E));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&Ra("for",Y)&&O.removeAttribute("for")}catch{}}let P=m(E);if(P)for(let O=P.length-1;O>=0;--O)w.push(P[O])}},Ca=function(p){let w=null,E=null;if(ii)p="<remove></remove>"+p;else{let O=Fc(p,/^[\r\n\t ]+/);E=O&&O[0]}nn==="application/xhtml+xml"&&It===Ve&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let R=F?de(p):p;if(It===Ve)try{w=new d().parseFromString(R,nn)}catch{}if(!w||!w.documentElement){w=Ie.createDocument(It,"template",null);try{w.documentElement.innerHTML=si?G:R}catch{}}let P=w.body||w.documentElement;return p&&E&&P.insertBefore(n.createTextNode(E),P.childNodes[0]||null),It===Ve?Jt.call(w,pt?"html":"body")[0]:pt?w.documentElement:P},Na=function(p){let w=D?D(p):p.ownerDocument;return Ge.call(w||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},$n=function(p){return p=_n(p,en," "),p=_n(p,Eh," "),p=_n(p,Sh," "),p},hi=function(p){var w;p.normalize();let E=D?D(p):p.ownerDocument,R=Ge.call(E||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),P=R.nextNode();for(;P;)P.data=$n(P.data),P=R.nextNode();let O=(w=p.querySelectorAll)===null||w===void 0?void 0:w.call(p,"template");O&&Tt(O,Y=>{Mt(Y.content)&&hi(Y.content)})},Un=function(p){let w=N?N(p):null;return typeof w!="string"||te(w)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==k(p)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function"||p.nodeType!==_(p)||p.childNodes!==m(p)},Mt=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return _(p)===Ae.documentFragment}catch{return!1}},rn=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return typeof _(p)=="number"}catch{return!1}};function je(T,p,w){T.length!==0&&Tt(T,E=>{E.call(e,p,w,Gt)})}let Uh=function(p,w){return!!(ft&&p.hasChildNodes()&&!rn(p.firstElementChild)&&ve(jc,p.textContent)&&ve(jc,p.innerHTML)||ft&&p.namespaceURI===Ve&&ry[w]&&(rn(p.firstElementChild)||typeof p.textContent=="string"&&ve(iy[w],p.textContent))||p.nodeType===Ae.processingInstruction||ft&&p.nodeType===Ae.comment&&ve(qc,p.data))},Hn=function(p,w){if(p instanceof RegExp)return ve(p,w);if(p instanceof Function){for(var E=arguments.length,R=new Array(E>2?E-2:0),P=2;P<E;P++)R[P-2]=arguments[P];return!!p(w,...R)}return!1},Hh=function(p,w,E){if(!tn[w]&&Ga(w)&&Hn(Ke.tagNameCheck,w))return!1;if(oi&&!Dt[w]){let R=y(p),P=m(p);if(P&&R){let O=P.length;for(let Y=O-1;Y>=0;--Y){let J=p===E?f(P[Y],!0):P[Y];R.insertBefore(J,v(p))}}}return it(p),!0},La=function(p,w,E,R){return p.length===0?w:w===E||w===R?Re(w):w},Pa=function(p,w){return p===w||y(p)!==null?!1:(ai&&zn(p),!0)},Da=function(p,w){if(je(q.beforeSanitizeElements,p,null),Pa(p,w))return!0;if(Un(p))return it(p),!0;let E=te(z(p));if(Z=La(q.uponSanitizeElement,Z,ei,Pn),je(q.uponSanitizeElement,p,{tagName:E,allowedTags:Z}),Pa(p,w))return!0;if(Uh(p,E))return it(p),!0;if(tn[E]||!(nt.tagCheck instanceof Function&&nt.tagCheck(E))&&!Z[E]){let P=Hh(p,E,w);return P===!1&&je(q.afterSanitizeElements,p,null),P}if(I(p)===Ae.element&&!Fh(p)||(E==="noscript"||E==="noembed"||E==="noframes")&&ve(ty,p.innerHTML))return it(p),!0;if(rt&&p.nodeType===Ae.text){let P=$n(p.textContent);p.textContent!==P&&(xn(e.removed,{element:p.cloneNode()}),p.textContent=P)}return je(q.afterSanitizeElements,p,null),!1},Ia=function(p,w,E){if(ca[w]||Ra(w,p)||pa&&(w==="id"||w==="name")&&(E in n||E in Ih))return!1;let R=X[w]||nt.attributeCheck instanceof Function&&nt.attributeCheck(w,p);return ni&&ve(Th,w)||da&&ve(Ah,w)?!0:R?ba[w]||ve(ua,_n(E,la,""))||(w==="src"||w==="xlink:href"||w==="href")&&p!=="script"&&zc(E,"data:")===0&&ya[p]||ha&&!ve(Rh,_n(E,la,""))?!0:!E:Ga(p)&&Hn(Ke.tagNameCheck,p)&&Hn(Ke.attributeNameCheck,w,p)||w==="is"&&Ke.allowCustomizedBuiltInElements&&Hn(Ke.tagNameCheck,E)},Bh=H({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ga=function(p){return!Bh[En(p)]&&ve(Ch,p)},Wh=function(p,w,E,R){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(p,w)){case"TrustedHTML":return de(R);case"TrustedScriptURL":return Be(R)}return R},Kh=function(p,w,E,R){try{E?p.setAttributeNS(E,w,R):p.setAttribute(w,R),Un(p)?it(p):Oc(e.removed)}catch{gt(w,p)}},Ma=function(p){je(q.beforeSanitizeAttributes,p,null);let w=p.attributes;if(!w||Un(p))return;X=La(q.uponSanitizeAttribute,X,ti,Dn);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0},R=w.length,P=te(p.nodeName);for(;R--;){let O=w[R],Y=O.name,J=O.namespaceURI,ke=O.value,Ee=te(Y),pi=ke,we=Y==="value"?pi:Ov(pi);if(E.attrName=Ee,E.attrValue=we,E.keepAttr=!0,E.forceKeepAttr=void 0,je(q.uponSanitizeAttribute,p,E),we=E.attrValue,ga&&(Ee==="id"||Ee==="name")&&zc(we,ma)!==0&&(gt(Y,p,O),we=ma+we),ft&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){gt(Y,p,O);continue}if(Ee==="attributename"&&Fc(we,"href")){gt(Y,p,O);continue}if(!E.forceKeepAttr){if(!E.keepAttr){gt(Y,p,O);continue}if(!fa&&ve(ny,we)){gt(Y,p,O);continue}if(rt&&(we=$n(we)),!Ia(P,Ee,we)){gt(Y,p,O);continue}we=Wh(P,Ee,J,we),we!==pi&&Kh(p,Y,J,we)}}je(q.afterSanitizeAttributes,p,null)},Bn=function(p){let w=null,E=Na(p);for(je(q.beforeSanitizeShadowDOM,p,null);w=E.nextNode();)if(je(q.uponSanitizeShadowNode,w,null),Da(w,p),Ma(w),Mt(w.content)&&Bn(w.content),I(w)===Ae.element){let R=b(w);Mt(R)&&(fi(R),Bn(R))}je(q.afterSanitizeShadowDOM,p,null)},fi=function(p){let w=[{node:p,shadow:null}];for(;w.length>0;){let E=w.pop();if(E.shadow){Bn(E.shadow);continue}let R=E.node,O=I(R)===Ae.element,Y=m(R);if(Y)for(let J=Y.length-1;J>=0;--J)w.push({node:Y[J],shadow:null});if(O){let J=N?N(R):null;if(typeof J=="string"&&te(J)==="template"){let ke=R.content;Mt(ke)&&w.push({node:ke,shadow:null})}}if(O){let J=b(R);Mt(J)&&w.push({node:null,shadow:J},{node:J,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},w=null,E=null,R=null,P=null;if(si=!T,si&&(T="<!-->"),typeof T!="string"&&!rn(T)&&(T=Hv(T),typeof T!="string"))throw St("dirty is not a string, aborting");if(!e.isSupported)return T;ri?(Z=Pn,X=Dn):di(p),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(Z=Re(Z)),q.uponSanitizeAttribute.length>0&&(X=Re(X)),e.removed=[];let O=ai&&typeof T!="string"&&rn(T);if(O){$h(T);let ke=z(T);if(typeof ke=="string"){let Ee=te(ke);if(!Z[Ee]||tn[Ee])throw Fn(T),St("root node is forbidden and cannot be sanitized in-place")}if(Un(T))throw Fn(T),St("root node is clobbered and cannot be sanitized in-place");try{fi(T)}catch(Ee){throw Fn(T),Ee}}else if(rn(T))w=Ca("<!---->"),E=w.ownerDocument.importNode(T,!0),E.nodeType===Ae.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?w=E:w.appendChild(E),fi(E);else{if(!Lt&&!rt&&!pt&&T.indexOf("<")===-1)return F&&Gn?de(T):T;if(w=Ca(T),!w)return Lt?null:Gn?G:""}w&&ii&&it(w.firstChild);let Y=O?T:w;try{let ke=Na(Y);for(;R=ke.nextNode();)Da(R,Y),Ma(R),Mt(R.content)&&Bn(R.content)}catch(ke){throw O&&(Fn(T),Tt(e.removed,Ee=>{Ee.element&&zn(Ee.element)})),ke}if(O)return Tt(e.removed,ke=>{ke.element&&zn(ke.element)}),rt&&hi(T),T;if(Lt){if(rt&&hi(w),In)for(P=We.call(w.ownerDocument);w.firstChild;)P.appendChild(w.firstChild);else P=w;return(X.shadowroot||X.shadowrootmode)&&(P=Ce.call(r,P,!0)),P}let J=pt?w.outerHTML:w.innerHTML;return pt&&Z["!doctype"]&&w.ownerDocument&&w.ownerDocument.doctype&&w.ownerDocument.doctype.name&&ve(Jv,w.ownerDocument.doctype.name)&&(J="<!DOCTYPE "+w.ownerDocument.doctype.name+`>
|
|
334
|
+
`+J),rt&&(J=$n(J)),F&&Gn?de(J):J},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};di(T),ri=!0,Pn=Z,Dn=X},e.clearConfig=function(){Gt=null,ri=!1,Pn=null,Dn=null,F=U,G=""},e.isValidAttribute=function(T,p,w){Gt||di({});let E=te(T),R=te(p);return Ia(E,R,w)},e.addHook=function(T,p){typeof p=="function"&&Se(q,T)&&xn(q[T],p)},e.removeHook=function(T,p){if(Se(q,T)){if(p!==void 0){let w=Gv(q[T],p);return w===-1?void 0:Mv(q[T],w,1)[0]}return Oc(q[T])}},e.removeHooks=function(T){Se(q,T)&&(q[T]=[])},e.removeAllHooks=function(){q=Yc()},e}var ed=Jc();function Ho(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ct=Ho();function ld(t){Ct=t}var At={exec:()=>null};function Xt(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function $(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(ye.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var sy=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ye={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Xt(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Xt(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Xt(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Xt(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Xt(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Xt(t=>new RegExp(`^ {0,${t}}>`))},ly=/^(?:[ \t]*(?:\n|$))+/,uy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,cy=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,An=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Bo=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ud=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cd=$(ud).replace(/bull/g,Bo).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(),hy=$(ud).replace(/bull/g,Bo).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(),Wo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,fy=/^[^\n]+/,Ko=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,py=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ko).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gy=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Bo).getRegex(),Wr="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",Vo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,my=$("^ {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",Vo).replace("tag",Wr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dd=t=>$(Wo).replace("hr",An).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",Wr).getRegex(),vy=dd(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),yy=dd(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),wy=$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",yy).getRegex(),jo={blockquote:wy,code:uy,def:py,fences:cy,heading:dy,hr:An,html:my,lheading:cd,list:gy,newline:ly,paragraph:vy,table:At,text:fy},td=$("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",An).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",Wr).getRegex(),by={...jo,lheading:hy,table:td,paragraph:$(Wo).replace("hr",An).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",td).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",Wr).getRegex()},xy={...jo,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Vo).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:At,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(Wo).replace("hr",An).replace("heading",` *#{1,6} *[^
|
|
335
|
+
]`).replace("lheading",cd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},_y=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ky=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,hd=/^( {2,}|\\)\n(?!\s*$)/,Ey=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tt=/[\p{P}\p{S}]/u,Qt=/[\s\p{P}\p{S}]/u,Rn=/[^\s\p{P}\p{S}]/u,Sy=$(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Qt).getRegex(),Ty=/[\p{Pi}\p{Ps}"']/u,fd=/(?!~)[\p{P}\p{S}]/u,Ay=/(?!~)[\s\p{P}\p{S}]/u,Ry=/(?:[^\s\p{P}\p{S}]|~)/u,Cy=$(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",sy?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),pd=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ny=$(pd,"u").replace(/punct/g,tt).getRegex(),Ly=$(pd,"u").replace(/punct/g,fd).getRegex(),Py=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Dy=$(Py,"u").replace(/openQuote/g,Ty).replace(/punct/g,tt).getRegex(),gd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Iy=$(gd,"gu").replace(/notPunctSpace/g,Rn).replace(/punctSpace/g,Qt).replace(/punct/g,tt).getRegex(),Gy=$(gd,"gu").replace(/notPunctSpace/g,Ry).replace(/punctSpace/g,Ay).replace(/punct/g,fd).getRegex(),My="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Oy=$(My,"gu").replace(/notPunctSpace/g,Rn).replace(/punctSpace/g,Qt).replace(/punct/g,tt).getRegex(),Fy=$("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Rn).replace(/punctSpace/g,Qt).replace(/punct/g,tt).getRegex(),zy="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",$y=$(zy,"gu").replace(/notPunctSpace/g,Rn).replace(/punctSpace/g,Qt).replace(/punct/g,tt).getRegex(),Uy=$(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,tt).getRegex(),Hy="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",By=$(Hy,"gu").replace(/notPunctSpace/g,Rn).replace(/punctSpace/g,Qt).replace(/punct/g,tt).getRegex(),Wy=$(/\\(punct)/,"gu").replace(/punct/g,tt).getRegex(),Ky=$(/^<(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(),Vy=$(Vo).replace("(?:-->|$)","-->").getRegex(),jy=$("^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",Vy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ur=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,qy=$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ur).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),md=$(/^!?\[(label)\]\[(ref)\]/).replace("label",Ur).replace("ref",Ko).getRegex(),vd=$(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ko).getRegex(),Yy=$("reflink|nolink(?!\\()","g").replace("reflink",md).replace("nolink",vd).getRegex(),nd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qo={_backpedal:At,anyPunctuation:Wy,autolink:Ky,blockSkip:Cy,br:hd,code:ky,del:At,delLDelim:At,delRDelim:At,emStrongLDelim:Ny,emStrongRDelimAst:Iy,emStrongRDelimUnd:Fy,escape:_y,link:qy,nolink:vd,punctuation:Sy,reflink:md,reflinkSearch:Yy,tag:jy,text:Ey,url:At},Zy={...qo,emStrongLDelim:Dy,emStrongRDelimAst:Oy,emStrongRDelimUnd:$y,link:$(/^!?\[(label)\]\((.*?)\)/).replace("label",Ur).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ur).getRegex()},zo={...qo,emStrongRDelimAst:Gy,emStrongLDelim:Ly,delLDelim:Uy,delRDelim:By,url:$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nd).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",nd).getRegex()},Xy={...zo,br:$(hd).replace("{2,}","*").getRegex(),text:$(zo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},$r={normal:jo,gfm:by,pedantic:xy},Sn={normal:qo,gfm:zo,breaks:Xy,pedantic:Zy},Qy={"&":"&","<":"<",">":">",'"':""","'":"'"},rd=t=>Qy[t];function qe(t,e){if(e){if(ye.escapeTest.test(t))return t.replace(ye.escapeReplace,rd)}else if(ye.escapeTestNoEncode.test(t))return t.replace(ye.escapeReplaceNoEncode,rd);return t}function id(t){try{t=encodeURI(t).replace(ye.percentDecode,"%")}catch{return null}return t}function od(t,e){let n=t.replace(ye.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(ye.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(ye.slashPipe,"|");return r}function dt(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 ad(t){let e=t.split(`
|
|
336
|
+
`),n=e.length-1;for(;n>=0&&ye.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
337
|
+
`)}function Jy(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 ew(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 sd(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 tw(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
340
338
|
`).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[s]=a;return s.length>=i.length?o.slice(i.length):o}).join(`
|
|
341
|
-
`)}var
|
|
342
|
-
`),depth:
|
|
343
|
-
`)}}blockquote(
|
|
339
|
+
`)}var Hr=class{options;rules;lexer;constructor(t){this.options=t||Ct}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]:ad(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=tw(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=dt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:dt(e[0],`
|
|
340
|
+
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:dt(e[0],`
|
|
341
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=dt(e[0],`
|
|
344
342
|
`).split(`
|
|
345
343
|
`),r="",i="",o=[];for(;n.length>0;){let a=!1,s=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))s.push(n[l]),a=!0;else if(!a)s.push(n[l]);else break;n=n.slice(l);let u=s.join(`
|
|
346
|
-
`),
|
|
344
|
+
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
347
345
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
348
346
|
${u}`:u,i=i?`${i}
|
|
349
|
-
${
|
|
350
|
-
`),
|
|
351
|
-
`+g.replace(this.rules.other.blockquoteSetextReplace2,""),
|
|
352
|
-
${g}`,i=i.substring(0,i.length-f.text.length)+
|
|
347
|
+
${d}`:d;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,o,!0),this.lexer.state.top=h,n.length===0)break;let c=o.at(-1);if(c?.type==="code")break;if(c?.type==="blockquote"){let f=c,g=n.join(`
|
|
348
|
+
`),v=f.raw+`
|
|
349
|
+
`+g.replace(this.rules.other.blockquoteSetextReplace2,""),m=this.blockquote(v);o[o.length-1]=m,r=`${r}
|
|
350
|
+
${g}`,i=i.substring(0,i.length-f.text.length)+m.text;break}else if(c?.type==="list"){let f=c,g=f.raw+`
|
|
353
351
|
`+n.join(`
|
|
354
|
-
`),
|
|
355
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(
|
|
356
|
-
`,1)[0],
|
|
357
|
-
`,1)[0],f=!h.trim(),g=0;if(this.options.pedantic?(g=2,
|
|
358
|
-
`,
|
|
359
|
-
`,1)[0],D;if(
|
|
360
|
-
`+D.slice(g);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||
|
|
361
|
-
`+
|
|
362
|
-
`,
|
|
363
|
-
`),href:r,title:i}}}table(
|
|
364
|
-
`):[],o={type:"table",raw:
|
|
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(
|
|
366
|
-
`),depth:
|
|
367
|
-
`?
|
|
368
|
-
`),this.blockTokens(
|
|
369
|
-
`:n.push(o);continue}if(o=this.tokenizer.code(
|
|
352
|
+
`),v=this.list(g);o[o.length-1]=v,r=r.substring(0,r.length-c.raw.length)+v.raw,i=i.substring(0,i.length-f.raw.length)+v.raw,n=g.substring(o.at(-1).raw.length).split(`
|
|
353
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",d="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=ew(e[2].split(`
|
|
354
|
+
`,1)[0],e[1].length),c=t.split(`
|
|
355
|
+
`,1)[0],f=!h.trim(),g=0;if(this.options.pedantic?(g=2,d=h.trimStart()):f?g=e[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,d=h.slice(g),g+=e[1].length),f&&this.rules.other.blankLine.test(c)&&(u+=c+`
|
|
356
|
+
`,t=t.substring(c.length+1),l=!0),!l){let v=this.rules.other.nextBulletRegex(g),m=this.rules.other.hrRegex(g),y=this.rules.other.fencesBeginRegex(g),b=this.rules.other.headingBeginRegex(g),k=this.rules.other.htmlBeginRegex(g),_=this.rules.other.blockquoteBeginRegex(g);for(;t;){let N=t.split(`
|
|
357
|
+
`,1)[0],D;if(c=N,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),D=c):D=c.replace(this.rules.other.tabCharGlobal," "),y.test(c)||b.test(c)||k.test(c)||_.test(c)||v.test(c)||m.test(c))break;if(D.search(this.rules.other.nonSpaceChar)>=g||!c.trim())d+=`
|
|
358
|
+
`+D.slice(g);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(h)||b.test(h)||m.test(h))break;d+=`
|
|
359
|
+
`+c}f=!c.trim(),u+=N+`
|
|
360
|
+
`,t=t.substring(N.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(d),loose:!1,text:d,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"),d=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=d}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 d=this.rules.other.listTaskCheckbox.exec(l.raw);if(d){let h={type:"checkbox",raw:d[0]+" ",checked:d[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=ad(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:dt(e[0],`
|
|
361
|
+
`),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=od(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
362
|
+
`):[],o={type:"table",raw:dt(e[0],`
|
|
363
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(od(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:dt(e[0],`
|
|
364
|
+
`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
365
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=dt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Jy(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)),sd(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 sd(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],d=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(d)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let c=[...r[0]][0].length,f=t.slice(0,i+r.index+c+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,d=t.slice(0,i+r.index+u+a),h=d.slice(i,-i);return{type:"del",raw:d,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}}}},$e=class $o{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ct,this.options.tokenizer=this.options.tokenizer||new Hr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ye,block:$r.normal,inline:Sn.normal};this.options.pedantic?(n.block=$r.pedantic,n.inline=Sn.pedantic):this.options.gfm&&(n.block=$r.gfm,this.options.breaks?n.inline=Sn.breaks:n.inline=Sn.gfm),this.tokenizer.rules=n}static get rules(){return{block:$r,inline:Sn}}static lex(e,n){return new $o(n).lex(e)}static lexInline(e,n){return new $o(n).inlineTokens(e)}lex(e){e=e.replace(ye.carriageReturn,`
|
|
366
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ye.tabCharGlobal," ").replace(ye.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
|
|
367
|
+
`: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
368
|
`)?"":`
|
|
371
369
|
`)+o.raw,s.text+=`
|
|
372
|
-
`+o.text,this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(o=this.tokenizer.fences(
|
|
370
|
+
`+o.text,this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
373
371
|
`)?"":`
|
|
374
372
|
`)+o.raw,s.text+=`
|
|
375
|
-
`+o.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(
|
|
373
|
+
`+o.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),n.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let s=1/0,l=e.slice(1),u;this.options.extensions.startBlock.forEach(d=>{u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(s=Math.min(s,u))}),s<1/0&&s>=0&&(a=e.substring(0,s+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
|
|
376
374
|
`)?"":`
|
|
377
375
|
`)+o.raw,s.text+=`
|
|
378
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==
|
|
376
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
379
377
|
`)?"":`
|
|
380
378
|
`)+o.raw,s.text+=`
|
|
381
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(
|
|
382
|
-
`;return r?'<pre><code class="language-'+
|
|
383
|
-
`:"<pre><code>"+(n?i:
|
|
384
|
-
`}blockquote({tokens:
|
|
385
|
-
${this.parser.parse(
|
|
386
|
-
`}html({text:
|
|
387
|
-
`}hr(
|
|
388
|
-
`}list(
|
|
379
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let d=u?u.length:0;return s.slice(0,d)+"["+"a".repeat(s.length-d-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,d=e.slice(1),h;this.options.extensions.startInline.forEach(c=>{h=c.call({lexer:this},d),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)}},Br=class{options;parser;constructor(t){this.options=t||Ct}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(ye.notSpaceStart)?.[0],i=t.replace(ye.endingNewline,"")+`
|
|
380
|
+
`;return r?'<pre><code class="language-'+qe(r)+'">'+(n?i:qe(i,!0))+`</code></pre>
|
|
381
|
+
`:"<pre><code>"+(n?i:qe(i,!0))+`</code></pre>
|
|
382
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
383
|
+
${this.parser.parse(t)}</blockquote>
|
|
384
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
385
|
+
`}hr(t){return`<hr>
|
|
386
|
+
`}list(t){let e=t.ordered,n=t.start,r="";for(let a=0;a<t.items.length;a++){let s=t.items[a];r+=this.listitem(s)}let i=e?"ol":"ul",o=e&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
|
|
389
387
|
`+r+"</"+i+`>
|
|
390
|
-
`}listitem(
|
|
391
|
-
`}checkbox({checked:
|
|
392
|
-
`}table(
|
|
388
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
389
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
390
|
+
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let o=t.rows[i];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
393
391
|
<thead>
|
|
394
|
-
`+
|
|
392
|
+
`+e+`</thead>
|
|
395
393
|
`+r+`</table>
|
|
396
|
-
`}tablerow({text:
|
|
397
|
-
${
|
|
398
|
-
`}tablecell(
|
|
399
|
-
`}strong({tokens:
|
|
400
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+at(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},$t=new es;function Y(e,t){return $t.parse(e,t)}Y.options=Y.setOptions=function(e){return $t.setOptions(e),Y.defaults=$t.defaults,pf(Y.defaults),Y};Y.getDefaults=Va;Y.defaults=Ut;function s_(...e){return $t.use(...e),Y.defaults=$t.defaults,pf(Y.defaults),Y}Y.use=s_;Y.walkTokens=function(e,t){return $t.walkTokens(e,t)};Y.parseInline=$t.parseInline;Y.Parser=Xe;Y.parser=Xe.parse;Y.Renderer=Pi;Y.TextRenderer=Ja;Y.Lexer=Ye;Y.lexer=Ye.lex;Y.Tokenizer=Li;Y.Hooks=tr;Y.parse=Y;var mT=Y.options,vT=Y.setOptions,yT=Y.walkTokens,wT=Y.parseInline;var bT=Xe.parse,xT=Ye.lex;var Sf={"&":"&","<":"<",">":">",'"':""","'":"'"},l_=new RegExp(`[${Object.keys(Sf).join("")}]`,"g");function Ze(e){return e.replace(l_,t=>Sf[t])}var u_=["http:","https:","mailto:"],c_=/^[a-z][a-z0-9+.-]*:/i,d_=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Ef(e){let t=e.replace(d_,""),n=c_.exec(t);return n===null?t===""?null:e:u_.includes(n[0].toLowerCase())?e:null}var _t="data-weave-target",Ii="note:",h_={bySpelling:new Map,hasGhosts:!1};function f_(e){if(e.kind!=="note"||!e.id.startsWith(Ii))return null;let t=e.id.slice(Ii.length);return t===""?null:t}function Tf(e,t){if(e===null)return h_;let n=new Map;for(let i of e.model.nodes){let o=f_(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=t!==null&&(e.dangling[t]?.length??0)>0;return{bySpelling:n,hasGhosts:r}}function p_(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function g_(e){return e.hasGhosts}var m_=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function v_(e){let t=e.indexOf("[[");return t===-1?void 0:t}function y_(e){return{name:"wikilink",level:"inline",start:v_,tokenizer(t){return b_(t)},renderer(t){return w_(e,t)}}}function w_(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return x_(e,n,r)}function b_(e){let t=m_.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function x_(e,t,n){let r=Ze((n===""?t:n).trim());if(r==="")return"";let i=p_(e,t);return i!==null?`<a class="weave-wiki" ${_t}="${Ze(i)}" role="link" tabindex="0" title="${Ze(t.trim())}">${r}</a>`:g_(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Ze(t.trim())}">${r}</span>`:r}function __(e){return new es({gfm:!0,async:!1,extensions:[y_(e)],renderer:{html({text:t}){return Ze(t)},link({href:t,title:n,tokens:r}){let i=Ef(t),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:t,title:n,text:r}){let i=Ef(t);if(i===null)return Ze(r);let o=n==null||n===""?"":` title="${Ze(n)}"`;return`<img src="${Ze(i)}" alt="${Ze(r)}"${o}>`}}})}function k_(e,t){return __(t).parse(e,{async:!1})}function ir(e){return Object.freeze(e)}var E_=ir({ALLOWED_TAGS:ir(["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:ir(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",_t]),ADD_URI_SAFE_ATTR:ir([_t]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:ir({html:!0})});function Af(e,t,n){return e.sanitize(k_(t,n),E_)}var Rf=32;function ts(e){let t=e;for(let n=0;t!==null&&n<Rf;n++){let r=t.getAttribute(_t);if(r!==null&&r!=="")return`${Ii}${r}`;t=t.parentElement}return null}function Cf(e){if(!e||e.isCollapsed===!0)return!1;let t=e.toString;return(typeof t=="function"&&t!==Object.prototype.toString?t.call(e):"").length>0}var Nf="edited",Lf="created";function Pf(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:It(e.source),provenanceTitle:rn(e.source),updated:Un(e.updated,t),updatedIso:e.updated,created:Un(e.created,t),createdIso:e.created,tags:e.tags}}function Df(e){return`#${e}`}var S_=200,T_=8,A_="no note",ns="weave-preview";function rs(e){let t=e;for(let n=0;t!==null&&n<Rf;n++){let r=t.getAttribute(_t);if(r!==null&&r!=="")return{slug:r,text:(t.textContent??"").trim()};if((t.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(t.textContent??"").trim()};t=t.parentElement}return null}function R_(e){return e.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(t,n,r)=>r??n).replace(/<[^>]*>/g," ").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s{0,3}([-*_][ \t]?){3,}$/gm," ").replace(/^\s{0,3}[-*+]\s+/gm,"").replace(/^\s{0,3}\d+[.)]\s+/gm,"").replace(/[*_~]{1,3}([^*_~]*)[*_~]{1,3}/g,"$1").replace(/\s+/g," ").trim()}function C_(e,t=S_){let n=R_(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function If(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:A_,text:`no note named “${i}” yet`}}let n=e?.model.nodes.find(i=>i.id===`note:${t.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${rn(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:C_(n.detail.preview??"")}}function Mf(e,t,n,r,i,o,a=T_){let s=e+a,l=t+a;return s+n>i-a&&(s=e-a-n),l+r>o-a&&(l=t-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var Mi={anchor:null,pointerX:0,pointerY:0};function Gf(e,t){switch(t.type){case"show":return t.anchor.slug===null&&t.anchor.text===""?e:{anchor:t.anchor,pointerX:t.x,pointerY:t.y};case"hide":return e.anchor===null?e:Mi;case"dismiss":return Mi}}function Of(e,t){return t!==null?null:e===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":e.startsWith(Ii)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var N_="weave-preview-x",L_="weave-preview-y";function P_({view:e,open:t}){return y("header",{class:"weave-note-head",children:[y("h3",{class:"weave-note-title",children:e.title}),y("p",{class:"weave-note-meta",children:[t===null?null:y("button",{type:"button",class:"weave-note-open",title:Vd,"aria-label":Kd,onClick:t,children:y("span",{class:"weave-note-open-mark","aria-hidden":"true",dangerouslySetInnerHTML:{__html:jd}})}),y("span",{class:`weave-prov weave-prov-${e.provenance}`,title:e.provenanceTitle,children:[e.provenanceGlyph," ",e.provenance]}),y("span",{class:"weave-note-time",title:e.updatedIso,children:[Nf," ",e.updated]}),y("span",{class:"weave-note-time",title:e.createdIso,children:[Lf," ",e.created]})]}),y("p",{class:"weave-note-tags",children:e.tags.map(n=>y("span",{class:"weave-tag",children:Df(n)},n))})]})}function Ff(e){let t=e.note?.note??null,n=Of(e.selectedId,t),r=be(()=>t===null?null:Tf(e.graph,t.slug),[t,e.graph]),i=be(()=>t===null||r===null?"":Af(rf,t.body,r),[t,r]),[o,a]=V(Mi),s=g=>{a(m=>Gf(m,g))},l=ee(null),u=ee(null),c=o.anchor===null?null:If(e.graph,o.anchor);if(At(()=>{s({type:"hide"})},[t===null?null:t.slug]),At(()=>{let g=l.current;if(g!==null){let w=o.anchor?.slug??null;for(let b of g.querySelectorAll(`a[${_t}]`))w!==null&&b.getAttribute(_t)===w?b.setAttribute("aria-describedby",ns):b.removeAttribute("aria-describedby")}let m=u.current;if(m===null||c===null)return;let v=Mf(o.pointerX,o.pointerY,m.offsetWidth,m.offsetHeight,window.innerWidth,window.innerHeight);m.style.setProperty(`--${N_}`,`${v.x}px`),m.style.setProperty(`--${L_}`,`${v.y}px`)},[o,c]),t===null||r===null)return y("p",{class:"weave-note-empty",children:n});let h=e.toolbar,d={draft:e.draft,prompt:e.prompt,send:e.send},f=Pf(t,e.now);return y("article",{class:`weave-note weave-note-${f.provenance}`,children:[y(P_,{view:f,open:h===null?null:()=>e.send({type:"open"})}),h===null?null:y(of,{toolbar:h,...d}),h!==null&&h.editing?y(af,{toolbar:h,...d}):y("div",{ref:l,class:"weave-note-body",tabIndex:-1,onMouseOver:g=>{let m=rs(g.target);s(m!==null?{type:"show",anchor:m,x:g.clientX,y:g.clientY}:{type:"hide"})},onMouseLeave:()=>s({type:"hide"}),onFocus:g=>{let m=rs(g.target);if(m===null)return;let v=g.target.getBoundingClientRect?.();s({type:"show",anchor:m,x:v?.left??0,y:v?.bottom??0})},onBlur:()=>s({type:"hide"}),onClick:g=>{let m=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(Cf(m))return;let v=ts(g.target);if(v!==null){e.onSelect(v);return}e.toolbar!==null&&e.send({type:"toggle"})},onKeyDown:g=>{if(g.key==="Escape"&&o.anchor!==null){g.stopPropagation(),s({type:"dismiss"});return}if(g.key!=="Enter"&&g.key!==" ")return;let m=ts(g.target);m!==null&&(g.preventDefault(),e.onSelect(m))},dangerouslySetInnerHTML:{__html:i}}),c===null?null:y("div",{ref:u,id:ns,role:"tooltip",class:`weave-preview${c.ghost?" weave-preview-ghost":""}`,children:[y("span",{class:"weave-preview-kind",children:c.kind}),y("span",{class:"weave-preview-title",children:c.title}),c.text===""?null:y("p",{class:"weave-preview-text",children:c.text})]})]},t.slug)}var or=["tree","note","graph"],is={tree:180,note:320,graph:260},$f={tree:.22,note:.46,graph:.32},D_=1100,I_=800;function Uf(e){return!Number.isFinite(e)||e<I_?"narrow":e<D_?"medium":"wide"}function Gi(e){return e==="wide"?or:e==="medium"?["tree","note"]:["note"]}function Hf(e,t){return Bf(or,e,t)}function Bf(e,t,n){let r={tree:0,note:0,graph:0};for(let l of e){let u=t[l];r[l]=Number.isFinite(u)&&u>0?u:$f[l]}let i=0;for(let l of e)i+=r[l];for(let l of e)r[l]=r[l]/i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of e){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 e)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function as(e){let t=Number.isFinite(e)&&e>0?e:1,n={tree:is.tree/t,note:is.note/t,graph:is.graph/t},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 Wf(e,t){return{fractions:Hf(e,as(t))}}function zf(e){return Wf($f,e)}function Kf(e,t,n){let r=Gi(n),i=Number.isFinite(t)&&t>0?t:0,o=Bf(r,e.fractions,as(i));return r.map(a=>({id:a,width:o[a]*i}))}var Vf=["tree","note"];function M_(e){return e==="tree"?["tree","note"]:["note","graph"]}function ss(e,t,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return e;let[o,a]=M_(t),s=as(i),l=Math.max(0,e.fractions[o]-s[o]),u=Math.max(0,e.fractions[a]-s[a]),c=Math.max(-l,Math.min(u,n/i));if(c===0)return e;let h={...e.fractions,[o]:e.fractions[o]+c,[a]:e.fractions[a]-c};return{fractions:Hf(h,s)}}var jf="pi-weave.layout.v1";function G_(e){return JSON.stringify({v:1,tree:os(e.fractions.tree),note:os(e.fractions.note),graph:os(e.fractions.graph)})}function os(e){return Math.round(e*1e4)/1e4}function O_(e,t){if(e===null)return null;let n;try{n=JSON.parse(e)}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 o of or){let a=r[o];if(typeof a!="number"||!Number.isFinite(a)||a<=0)return null;i[o]=a}return Wf(i,t)}function qf(e,t){let n;try{n=e.getItem(jf)}catch{return zf(t)}return O_(n,t)??zf(t)}function Yf(e,t){try{return e.setItem(jf,G_(t)),!0}catch{return!1}}function F_(e){return`--weave-col-${e}`}function z_(e){return`${Math.round(e)}px`}function Xf(e){return e.map(t=>[F_(t.id),z_(t.width)])}var $_={k:{type:"openSearch"},e:{type:"toggleEdit"},s:{type:"saveNote"}},Zf={1:"tree",2:"note",3:"graph"},U_=new Set(or.filter(e=>Gi("medium").includes(e)===!1||Gi("narrow").includes(e)===!1));function H_(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function B_(e){return!e.ctrl&&!e.meta&&!e.alt}var W_={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function Qf(e,t){if(t.overlay!==null)return e.key==="Escape"?{type:"closeOverlay"}:null;if(H_(e)){let n=$_[e.key.toLowerCase()];if(n!==void 0)return n;let r=Zf[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection?{type:"clearSelection"}:null:!B_(e)||e.typing?null:W_[e.key]??null}var K_=["INPUT","TEXTAREA","SELECT"];function ls(e,t){return t?!0:e!==null&&K_.includes(e.toUpperCase())}function Jf(e){return{key:e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:ls(e.target?.tagName??null,e.target?.isContentEditable===!0)}}var V_={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},j_=".weave-col-tree .weave-filter";function q_(e){let t=e;return typeof t?.focus=="function"?t:null}function ep(e,t){let n=q_(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function tp(e,t){switch(e.type){case"openSearch":return t.setOverlay("search");case"openHelp":return t.setOverlay("help");case"closeOverlay":return t.setOverlay(null);case"focusColumn":return void t.focusSelector(V_[e.column]);case"filterTree":return void t.focusSelector(j_);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"toggleEdit":return t.toggleEdit();case"saveNote":return t.saveNote();case"cycleTheme":return t.cycleTheme()}}function np(e){return[{title:"Global",entries:[{combo:`${e}K`,what:"Search notes and the repository"},...Object.entries(Zf).map(([t,n])=>({combo:`${e}${t}`,what:`Focus the ${n} column${U_.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Note",entries:[{combo:`${e}E`,what:"Toggle read / edit"},{combo:`${e}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 us="Keyboard shortcuts",rp="esc close";var ip={chevron:{d:["M5.75 4.25 9.5 8l-3.75 3.75"],filled:!1},vault:{d:["M8 2.6 13.4 8 8 13.4 2.6 8Z"],filled:!0},note:{d:["M4.5 2.75h4.75l2.25 2.25v8.25h-7Z","M9.25 2.75V5h2.25"],filled:!1},session:{d:["M3 3.75h10v6.5H6.75L3.75 13v-2.75H3Z"],filled:!1},repository:{d:["M2.75 4.25h10.5v7.5H2.75Z","M2.75 6.75h10.5"],filled:!1},module:{d:["M2.75 4.25h4l1.5 1.75h5v5.75h-10.5Z"],filled:!1},package:{d:["M8 2.5 13.25 5v6L8 13.5 2.75 11V5Z","M2.75 5 8 7.5 13.25 5","M8 7.5v6"],filled:!1},entryPoint:{d:["M5.75 3.75v8.5L12.75 8Z"],filled:!0},gitState:{d:["M8 2.85 13.15 8 8 13.15 2.85 8Z"],filled:!1},external:{d:["M4.5 11.5l7-7","M6.75 4.5h4.75v4.75"],filled:!1},file:{d:["M4.5 2.75h7v10.5h-7Z"],filled:!1}};function ar({name:e,class:t}){let n=ip[e];return y("svg",{class:t,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:n.filled?"currentColor":"none",stroke:n.filled?void 0:"currentColor","stroke-width":n.filled?void 0:n.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n.d.map(r=>y("path",{d:r}))})}function X_({view:e,onSelect:t,onToggle:n,onDelete:r,onDragStart:i,onDragOver:o,onDragLeave:a,onDrop:s,isDragOver:l}){return y("li",{id:e.domId,"data-row-id":e.id,"data-row-label":e.label,"data-row-kind":e.kind,class:`weave-row weave-row-${e.kind}${e.selected?" weave-row-on":""}${e.muted?" weave-row-muted":""}${hn.value.has(e.id)?" weave-row-new":""}${l?" weave-row-droptarget":""}`,role:"treeitem","aria-level":e.level,"aria-posinset":e.posinset,"aria-setsize":e.setsize,"aria-selected":e.selected,"aria-expanded":e.hasKids?e.expanded:void 0,style:Hc(e.depth),onClick:t,draggable:Pc(e.kind,e.id),onDragStart:i,onDragOver:o,onDragLeave:a,onDrop:s,children:[y("span",{class:"weave-twisty","aria-hidden":"true",onClick:u=>{u.stopPropagation(),n()},children:e.hasKids?y(ar,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),y("span",{class:"weave-kind","aria-hidden":"true",children:y(ar,{name:e.kindIcon,class:"weave-icon"})}),y("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),y("span",{class:"weave-label",children:e.label}),y("span",{class:"weave-meta",children:e.meta}),r?y("button",{type:"button",class:"weave-row-del",title:`Delete ${e.label}`,"aria-label":`Delete ${e.label}`,onClick:u=>{u.stopPropagation(),r()},children:"×"}):null]})}function op(e){let[t,n]=V(Tc),[r,i]=V(!1),[o,a]=V(""),[s,l]=V(null),[u,c]=V(null),[h,d]=V(null),[f,g]=V(null),[m,v]=V(null),[w,b]=V(null),E=ee(null),k=Ac(e.graph,t),I=Xc(e.graph,k,t),D=e.fetch??rt;At(()=>{let _=E.current;if(!_||!u)return;let A=Ic(u.x,u.y,_.offsetWidth||170,_.offsetHeight||130,window.innerWidth,window.innerHeight);_.style.setProperty("--weave-menu-x",`${A.x}px`),_.style.setProperty("--weave-menu-y",`${A.y}px`)},[u]);let N=(_,A)=>{let O=ri(_);O&&d({id:_,label:A,isFolder:O.type==="folder"})},z=async _=>{let A=ri(_.id);A&&(A.type==="note"?(await Ll(D,A.slug),e.selectedId===_.id&&e.onSelect("")):(await Pl(D,A.path),e.selectedId&&e.selectedId.startsWith(`note:${A.path}/`)&&e.onSelect("")))},U=async _=>{if(!u)return;let A=u;switch(c(null),_){case"open":e.onSelect(A.rowId);break;case"new-folder":i(!0);break;case"new-subfolder":{let O=A.rowId.slice(8);b({parentPath:O,value:""});break}case"rename":{if(!A.rowId.startsWith("note:"))break;let O=A.rowId.slice(5);g({slug:O,currentName:A.rowLabel,value:A.rowLabel});break}case"rename-folder":{if(!A.rowId.startsWith("vfolder:"))break;let O=A.rowId.slice(8),B=O.split("/").pop()??A.rowLabel;v({oldPath:O,currentName:B,value:B});break}case"delete-note":case"delete-folder":N(A.rowId,A.rowLabel);break;case"collapse-all":n(O=>({...O,expanded:new Set}));break;case"copy-id":typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(A.rowId);break}};return y("div",{class:"weave-tree",onKeyDown:_=>{let A=_.target,O=ls(A?.tagName??null,A?.isContentEditable===!0),B=Fc(k,t,e.selectedId,_.key,O);B.handled&&(_.preventDefault(),n(B.state),B.selectedId!==null&&e.onSelect(B.selectedId))},children:[y("div",{class:"weave-tree-controls",children:[y("input",{type:"search",class:"weave-filter",value:t.query,placeholder:Vc,"aria-label":qc,title:Yc,onInput:_=>n(Mc(t,_.currentTarget.value))}),y("button",{type:"button",class:"weave-chip",title:Bc(t.provFilter),onClick:()=>n(Gc(t)),children:["◧ ",ti(t.provFilter)]}),y("button",{type:"button",class:"weave-chip",title:Kc(t.showInternals),onClick:()=>n(Oc(t)),children:["◧ ",Wc(t.showInternals)]}),y("button",{type:"button",class:"weave-chip",title:Rc,onClick:()=>i(_=>!_),children:"+ folder"})]}),r?y("form",{class:"weave-tree-new-folder",onSubmit:async _=>{_.preventDefault();let A=o.trim();A&&(await xo(D,A),i(!1),a(""))},children:[y("input",{type:"text",class:"weave-filter",placeholder:Cc,value:o,onInput:_=>a(_.currentTarget.value),onKeyDown:_=>{_.key==="Escape"&&(_.stopPropagation(),i(!1),a(""))},autoFocus:!0}),y("button",{type:"submit",class:"weave-chip",children:"Create"}),y("button",{type:"button",class:"weave-chip",onClick:()=>{i(!1),a("")},children:"Cancel"})]}):null,I===null?y("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":jc,onContextMenu:_=>{_.preventDefault();let O=_.target?.closest(".weave-row");if(O){let B=O.getAttribute("data-row-id"),ae=O.getAttribute("data-row-label")??"",ie=O.getAttribute("data-row-kind")??"note";if(B){c({x:_.clientX,y:_.clientY,rowId:B,rowLabel:ae,kind:ie});return}}c({x:_.clientX,y:_.clientY,rowId:"vault",rowLabel:"Vault",kind:"vault"})},"aria-activedescendant":Uc(k,e.selectedId)??void 0,children:$c(k,e.selectedId,e.now).map(_=>y(X_,{view:_,onSelect:()=>{e.onSelect(_.id),(_.hasKids||_.id.startsWith("vfolder:"))&&n(A=>ha(A,_.id))},onToggle:()=>n(ha(t,_.id)),onDelete:ri(_.id)?()=>N(_.id,_.label):void 0,isDragOver:s===_.id,onDragStart:A=>{A.dataTransfer?.setData("text/plain",_.id),A.dataTransfer&&(A.dataTransfer.effectAllowed="move")},onDragOver:A=>{Nc(_.id)&&(A.preventDefault(),A.dataTransfer&&(A.dataTransfer.dropEffect="move"),l(_.id))},onDragLeave:()=>{s===_.id&&l(null)},onDrop:async A=>{A.preventDefault(),l(null);let O=A.dataTransfer?.getData("text/plain");if(!O||!O.startsWith("note:"))return;let B=O.slice(5),ae=Lc(_.id);await Nl(D,B,ae),_.id.startsWith("vfolder:")&&n(ie=>ni(ie,_.id))}},_.id))}):y("p",{class:"weave-tree-empty",children:I}),y("p",{class:"weave-tree-count",children:Zc(k)}),u!==null?y(Ne,{children:[y("div",{class:"weave-menu-backdrop",onClick:()=>c(null),onContextMenu:_=>{_.preventDefault(),c(null)}}),y("div",{ref:E,class:"weave-menu",role:"menu","aria-label":`Context menu for ${u.rowLabel}`,children:Dc(u.rowId,u.kind).map((_,A)=>_.kind==="separator"?y("hr",{class:"weave-menu-sep"},A):y("button",{type:"button",class:`weave-menu-item${_.destructive?" weave-menu-item-bad":""}`,role:"menuitem",onClick:()=>{U(_.id)},children:[_.icon?y("span",{"aria-hidden":"true",children:_.icon}):null,y("span",{children:_.label})]},_.id))})]}):null,h!==null?y("div",{class:"weave-scrim",onClick:()=>d(null),children:y("div",{class:"weave-dialog",role:"alertdialog","aria-modal":"true","aria-label":"Confirm deletion",onClick:_=>_.stopPropagation(),onKeyDown:_=>{_.key==="Escape"&&d(null)},children:[y("h3",{class:"weave-dialog-title",children:["Delete ",h.isFolder?"folder":"note","?"]}),y("p",{class:"weave-dialog-body",children:["Are you sure you want to delete ",y("strong",{children:["“",h.label,"”"]}),"?",h.isFolder?" All notes inside will be permanently deleted.":" This cannot be undone."]}),y("div",{class:"weave-dialog-actions",children:[y("button",{type:"button",class:"weave-chip",onClick:()=>d(null),autoFocus:!0,children:"Cancel"}),y("button",{type:"button",class:"weave-chip weave-chip-bad",onClick:async()=>{let _=h;d(null),await z(_)},children:"Delete"})]})]})}):null,f!==null?y("div",{class:"weave-scrim",onClick:()=>g(null),children:y("div",{class:"weave-dialog",role:"dialog","aria-modal":"true","aria-label":"Rename note",onClick:_=>_.stopPropagation(),children:[y("h3",{class:"weave-dialog-title",children:"Rename note"}),y("form",{onSubmit:async _=>{_.preventDefault();let A=f.value.trim();A&&A!==f.currentName&&await Cl(D,f.slug,A,A),g(null)},children:[y("input",{type:"text",class:"weave-filter weave-dialog-input",value:f.value,onInput:_=>g({...f,value:_.currentTarget.value}),onKeyDown:_=>{_.key==="Escape"&&(_.stopPropagation(),g(null))},autoFocus:!0}),y("div",{class:"weave-dialog-actions",children:[y("button",{type:"button",class:"weave-chip",onClick:()=>g(null),children:"Cancel"}),y("button",{type:"submit",class:"weave-chip",children:"Rename"})]})]})]})}):null,m!==null?y("div",{class:"weave-scrim",onClick:()=>v(null),children:y("div",{class:"weave-dialog",role:"dialog","aria-modal":"true","aria-label":"Rename folder",onClick:_=>_.stopPropagation(),children:[y("h3",{class:"weave-dialog-title",children:"Rename folder"}),y("form",{onSubmit:async _=>{_.preventDefault();let A=m.value.trim();if(A&&A!==m.currentName){let O=m.oldPath.includes("/")?m.oldPath.split("/").slice(0,-1).join("/")+"/":"";await Dl(D,m.oldPath,O+A)}v(null)},children:[y("input",{type:"text",class:"weave-filter weave-dialog-input",value:m.value,onInput:_=>v({...m,value:_.currentTarget.value}),onKeyDown:_=>{_.key==="Escape"&&(_.stopPropagation(),v(null))},autoFocus:!0}),y("div",{class:"weave-dialog-actions",children:[y("button",{type:"button",class:"weave-chip",onClick:()=>v(null),children:"Cancel"}),y("button",{type:"submit",class:"weave-chip",children:"Rename"})]})]})]})}):null,w!==null?y("div",{class:"weave-scrim",onClick:()=>b(null),children:y("div",{class:"weave-dialog",role:"dialog","aria-modal":"true","aria-label":"New subfolder",onClick:_=>_.stopPropagation(),children:[y("h3",{class:"weave-dialog-title",children:["New subfolder under “",w.parentPath,"”"]}),y("form",{onSubmit:async _=>{_.preventDefault();let A=w.value.trim();A&&(await xo(D,`${w.parentPath}/${A}`),n(O=>ni(O,`vfolder:${w.parentPath}`))),b(null)},children:[y("input",{type:"text",class:"weave-filter weave-dialog-input",placeholder:"Subfolder name…",value:w.value,onInput:_=>b({...w,value:_.currentTarget.value}),onKeyDown:_=>{_.key==="Escape"&&(_.stopPropagation(),b(null))},autoFocus:!0}),y("div",{class:"weave-dialog-actions",children:[y("button",{type:"button",class:"weave-chip",onClick:()=>b(null),children:"Cancel"}),y("button",{type:"submit",class:"weave-chip",children:"Create"})]})]})]})}):null]})}function ap(e,t){if(e===null)return 0;for(let[n,r]of t)e.style.setProperty(n,r);return t.length}var sr={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function zi(e,t,n){return{id:e,target:t.id,label:De(t),kind:t.kind,kindIcon:pa(t.id)?"session":fa(t.kind),provenance:t.provenance,provenanceGlyph:It(t.provenance),provenanceTitle:rn(t.provenance),selected:t.id===n}}function Z_(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:zi(e.id,i,n)}function Q_(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var J_=["link:links-to:"];function ek(e){return J_.some(t=>e.id.startsWith(t))}function tk(e){return e.id.startsWith("link:mentions:")}function nk(e,t,n,r){let i=[];for(let[o,a]of Object.entries(e.tags)){if(!a.includes(t))continue;let s=[];for(let l of a){if(l===t)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(zi(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function rk(e,t,n,r){let i=[];for(let o of e.edges){if(o.kind!=="mentions"||o.target!==t)continue;let a=n.get(o.source);a!==void 0&&i.push(zi(`mentioned-by:${o.source}`,a,r))}return i}function ik(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var Fi={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 cs(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function sp(e,t){if(e===null)return cs(Fi.loading);if(t===null)return cs(Fi.noSelection);let n=Dt(e),r=sa(n,t);if(r===null)return cs(Fi.unknown);let i=Q_(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>Z_(d,i,t)).filter(d=>d!==null);a(sr.links,s(r.links.filter(ek)));let l=ua(n.edges).get(t)??[];a(sr.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>zi(`backlink:${h.id}`,h,t))),a(sr.mentions,[...s(r.links.filter(tk)),...rk(n,t,i,t)]);let u=ik(t),c=u===null?[]:nk(e,u,i,t);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:Fi.isolated}:{subject:r.label,groups:o,tags:c,tagsCount:c.length,empty:null}}function lp(){return{open:new Set,closed:new Set}}var ok=8;function up(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>ok}function ak(e){return e.some(t=>t.selected)}function cp(e,t){let n=up(t,e.heading,e.count,ak(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function dp(e,t){let n=up(t,sr.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:sr.tags,count:e.length,collapsed:n,rows:[]}}function hp(e,t,n){let r=new Set(e.open),i=new Set(e.closed);return n?(r.add(t),i.delete(t)):(i.add(t),r.delete(t)),{open:r,closed:i}}function $i(e){return`weave-ctx-panel-${e.toLowerCase()}`}var sk={notes:0,repo:null,nodes:0},lk=["note"];function fp(e){if(e===null)return sk;let t=e.model.nodes;return{notes:t.filter(n=>lk.includes(n.kind)).length,repo:e.model.staleness?.state??null,nodes:t.length}}function uk(e){return e===null||e==="missing"?"unindexed":e}function pp(e){return[`vault:${e.notes}`,`repo:${uk(e.repo)}`,`${e.nodes} nodes`]}var ck={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 — the header's refresh control retries"}};function ds(e){return ck[e]}var dk={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 gp(e){return dk[e]}var hs={title:"Context",body:"Links, backlinks and mentions for whatever is selected.",phase:"P2"},mp="—";function vp(e,t,n,r){return{cwd:e===""?mp:e,selection:t??"nothing selected",connection:ds(n),stamp:r}}function yp(e){return e===null?mp:/T(\d{2}:\d{2}:\d{2})/.exec(e)?.[1]??e}function wp(e){return e.map((t,n)=>({column:t,divider:n<e.length-1&&hk(t.id)?t.id:null}))}function hk(e){return Vf.includes(e)}var bp=["M21 12a9 9 0 1 1-2.64-6.36","M21 3v6h-6"],xp=6e4,_p="Search…";function fs(e){return e?"⌘K":"Ctrl K"}function kp(e){return`Search notes and repository (${e})`}function ps(e){return/mac|iphone|ipad/i.test(e)}function Ep({row:e,onSelect:t}){return y("li",{class:`weave-ctx-row${e.selected?" weave-row-on":""}`,children:y("button",{type:"button",class:"weave-ctx-link",onClick:t,children:[y("span",{class:"weave-kind","aria-hidden":"true",children:y(ar,{name:e.kindIcon,class:"weave-icon"})}),y("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),y("span",{class:"weave-label",children:e.label})]})})}function Sp({view:e,onToggle:t}){return y("h4",{class:"weave-ctx-head",children:y("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!e.collapsed,"aria-controls":$i(e.heading),onClick:t,children:[y("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:y(ar,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,y("span",{class:"weave-ctx-count",children:e.count})]})})}function fk({view:e,onSelect:t,onToggle:n}){return y("section",{class:"weave-ctx-group",children:[y(Sp,{view:e,onToggle:n}),y("ul",{class:"weave-ctx-rows",id:$i(e.heading),hidden:e.collapsed,children:e.rows.map(r=>y(Ep,{row:r,onSelect:()=>t(r.target)},r.id))})]})}function pk({tag:e,onSelect:t}){return y("li",{class:"weave-ctx-tag",children:[y("span",{class:"weave-tag",children:["#",e.tag]}),y("ul",{class:"weave-ctx-rows",children:e.siblings.map(n=>y(Ep,{row:n,onSelect:()=>t(n.target)},n.id))})]})}function Tp(e){let t=sp(e.graph,e.selectedId),[n,r]=V(lp),i=a=>()=>r(hp(n,a.heading,a.collapsed)),o=dp(t.tags,n);return y("div",{class:"weave-rail","aria-label":hs.title,children:[y("h2",{class:"weave-col-title",children:hs.title}),t.empty===null?null:y("p",{class:"weave-ctx-empty",children:t.empty}),t.groups.map(a=>{let s=cp(a,n);return y(fk,{view:s,onSelect:e.onSelect,onToggle:i(s)},a.heading)}),t.tags.length===0?null:y("section",{class:"weave-ctx-group",children:[y(Sp,{view:o,onToggle:i(o)}),y("ul",{class:"weave-ctx-tags",id:$i(o.heading),hidden:o.collapsed,children:t.tags.map(a=>y(pk,{tag:a,onSelect:e.onSelect},a.tag))})]})]})}function Ap(e){return y("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":e.label,tabIndex:0,onPointerDown:t=>{t.currentTarget.setPointerCapture(t.pointerId),e.onDown(t.clientX,t.pointerId)},onPointerMove:t=>e.onMove(t.clientX),onPointerUp:t=>{t.currentTarget.releasePointerCapture(t.pointerId),e.onUp()},onKeyDown:t=>e.onKey(t.key)})}function gk({id:e,props:t}){let n=gp(e);return y("section",{class:`weave-col weave-col-${e}`,"aria-label":n.title,children:[y("h2",{class:"weave-col-title",children:n.title}),e==="tree"?y(op,{graph:t.graph,selectedId:t.selectedId,onSelect:t.onSelect,now:t.now,fetch:t.fetch}):null,e==="note"?y(Ff,{note:t.note,graph:t.graph,selectedId:t.selectedId,onSelect:t.onSelect,now:t.now,toolbar:t.toolbar,prompt:t.prompt,draft:t.draft,send:t.send}):null,e==="graph"?y(Oh,{graph:t.graph,selectedId:t.selectedId,onSelect:t.onSelect,renderer:t.renderer,storage:t.storage,host:t.host,scheme:t.scheme,bootFailed:t.bootFailed,fit:t.fit}):null,e==="graph"?y(Tp,{graph:t.graph,selectedId:t.selectedId,onSelect:t.onSelect}):null]})}function mk({slot:e,props:t}){let n=e.divider;return y(Ne,{children:[y(gk,{id:e.column.id,props:t}),n===null?null:y(Ap,{id:n,label:`Resize ${e.column.id} column`,onDown:(r,i)=>t.onDown(n,r,i),onMove:t.onMove,onUp:t.onUp,onKey:r=>t.onKey(n,r)})]})}function Rp(e){let t=ee(null);return At(()=>{ap(t.current,Xf(e.resolved))},[e.resolved]),y("div",{class:"weave-grid",ref:t,"data-columns":e.resolved.length,children:wp(e.resolved).map(n=>y(mk,{slot:n,props:e},n.column.id))})}function vk(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function Cp(e,t){let n=vk(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function Np(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function yk(e,t,n,r){return{divider:e,origin:t,base:n,pointerId:r}}function wk(e,t,n){return ss(e.base,e.divider,t-e.origin,n)}function bk(e,t){let n=e.base.fractions,r=t.fractions;return n.tree!==r.tree||n.note!==r.note||n.graph!==r.graph}var Lp=24;function xk(e){return e==="ArrowLeft"?-Lp:e==="ArrowRight"?Lp:0}function Pp(e){let t=null;return{onDown(n,r,i){t=yk(n,r,e.layout(),i)},onMove(n){t!==null&&e.setLayout(wk(t,n,e.width()))},onUp(){let n=t;t=null,n!==null&&bk(n,e.layout())&&e.persist(e.layout())},onKey(n,r){let i=ss(e.layout(),n,xk(r),e.width());i!==e.layout()&&(e.setLayout(i),e.persist(i))}}}var Dp="image/png",Ip="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 _k({onRefresh:e}){let[t,n]=V(!1);return y("button",{type:"button",class:"weave-refresh",onClick:()=>{e(),n(!0)},onAnimationEnd:()=>n(!1),title:"Refetch everything","aria-busy":t?"true":void 0,children:y("svg",{class:t?"weave-refresh-glyph weave-refresh-spinning":"weave-refresh-glyph",viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:bp.map(r=>y("path",{d:r},r))})})}function Mp(e){return y("header",{class:"weave-header",children:[y("span",{class:"weave-brand",children:[y("img",{class:"weave-brand-mark",src:`data:${Dp};base64,${Ip}`,alt:"",width:18,height:18}),"pi-weave"]}),y("button",{type:"button",class:"weave-search",title:kp(e.shortcut),onClick:e.onSearch,children:[y("span",{class:"weave-search-text",children:_p}),y("kbd",{children:e.shortcut})]}),y("span",{class:"weave-summary",children:pp(e.summary).map(t=>y("span",{class:"weave-summary-part",children:t},t))}),y("button",{type:"button",class:"weave-theme",onClick:e.onTheme,title:e.theme.hint,"aria-label":e.theme.hint,children:e.theme.glyph}),y(_k,{onRefresh:e.onRefresh}),y("span",{class:`weave-conn weave-conn-${e.connection.tone}`,title:e.connection.hint,children:[y("span",{class:"weave-conn-dot","aria-hidden":"true",children:"●"}),e.connection.label]})]})}function kk({group:e}){return y("div",{children:[y("p",{class:"weave-key-group",children:e.title}),e.entries.map(t=>y("div",{class:"weave-key-row",children:[y("kbd",{class:"weave-key-combo",children:t.combo}),y("span",{class:"weave-key-what",children:t.what})]},t.combo))]})}function Gp(e){let t=_i(),n=e.shortcut.slice(0,-1);return y("div",{class:"weave-scrim",onClick:e.onClose,children:y("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":us,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[y("h2",{class:"weave-help-title",children:us}),y("div",{class:"weave-keys",children:np(n).map(r=>y(kk,{group:r},r.title))}),y("p",{class:"weave-help-foot",children:[y("button",{type:"button",class:"weave-chip",onClick:e.onClose,children:"close"}),y("span",{class:"weave-help-hint",children:rp})]})]})})}function Op(e,t){let n=r=>{let i=Qf(Jf(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function Fp({model:e}){return y("footer",{class:"weave-status",children:[y("span",{class:"weave-status-cwd",title:e.cwd,children:e.cwd}),y("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:e.selection}),y("span",{class:"weave-status-stamp",title:"data as of",children:yp(e.stamp)}),y("span",{class:`weave-conn weave-conn-${e.connection.tone}`,title:e.connection.hint,children:e.connection.label})]})}var gs=["system","light","dark"],zp="pi-weave.theme.v1";function Ek(e){return e==="system"||e==="light"||e==="dark"}function Ui(e){try{let t=e.getItem(zp);return Ek(t)?t:null}catch{return null}}function $p(e,t){try{return e.setItem(zp,t),!0}catch{return!1}}function Hi(e){let t=gs.indexOf(e);return gs[(t+1)%gs.length]??"system"}function Up(e,t){return e==="system"?t:e}function Bi(e){return e==="system"?null:e}var Sk={dark:"●",system:"◐",light:"○"};function Hp(e){return{glyph:Sk[e],hint:`Colour theme: ${e} — click for ${Hi(e)}`}}function Bp(e,t){let n=()=>t(e.innerWidth);return e.addEventListener("resize",n),()=>e.removeEventListener("resize",n)}function Tk(e){e===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=e}function Wp(e){let[t,n]=V(e.initialWidth),[r,i]=V(null),[o,a]=V(()=>qf(localStorage,e.initialWidth)),[s,l]=V(fn),[u,c]=V(()=>Ui(localStorage)??"system"),[h,d]=V(()=>Pr(window)),f=ee(null),g=ee(null),m=ee({layout:o,width:t,overlay:r});m.current={layout:o,width:t,overlay:r};let v=be(()=>Zd({fetch:rt,select:N=>{Ti(rt,N)},onChange:l}),[]);re(()=>{let N=xh({fetch:rt,open:$d});return f.current=N,()=>N.stop()},[]);let w=ee(!1),b=ee(location.hash);re(()=>{w.current&&(mh(localStorage,Ue.value),history.replaceState(null,"",Np(Ue.value)))},[Ue.value]),re(()=>{if(w.current||Le.value===null||(w.current=!0,Ue.value!==null))return;let N=Cp(b.current,Le.value);if(N!==null)Ti(rt,N);else{let z=vh(Le.value,localStorage);z!==null&&Ti(rt,z)}},[Le.value]),re(()=>wh(N=>v.send({type:"loaded",payload:N})),[]),re(()=>Qd(window,()=>Ra(v.state())),[]),re(()=>Bp(window,n),[]);let[E,k]=V(()=>Date.now());re(()=>{let N=setInterval(()=>k(Date.now()),xp);return()=>clearInterval(N)},[]),re(()=>Tk(Bi(u)),[u]),re(()=>{$p(localStorage,u)},[u]),re(()=>Ol(window,d),[]),re(()=>Op(document,{context:()=>({overlay:m.current.overlay,hasSelection:Ue.value!==null}),run:N=>tp(N,{setOverlay:i,focusSelector:z=>ep(document,z),fitGraph:()=>g.current?.(),clearSelection:()=>v.send({type:"navigate",id:null}),toggleEdit:()=>v.send({type:"toggle"}),saveNote:()=>v.send({type:"save"}),cycleTheme:()=>c(z=>Hi(z))})}),[]);let I=be(()=>Kf(o,t,Uf(t)),[o,t]),D=be(()=>Pp({layout:()=>m.current.layout,width:()=>m.current.width,setLayout:a,persist:N=>{Yf(localStorage,N)}}),[]);return y(Ne,{children:[y(Mp,{summary:fp(Le.value),connection:ds(dn.value),shortcut:fs(ps(e.platform)),onRefresh:()=>f.current?.refresh(),onSearch:()=>i("search"),theme:Hp(u),onTheme:()=>c(N=>Hi(N))}),y(Rp,{resolved:I,onDown:D.onDown,onMove:D.onMove,onUp:D.onUp,onKey:D.onKey,scheme:Up(u,h),bootFailed:qn.value,graph:Le.value,note:Yn.value,selectedId:Ue.value,onSelect:N=>v.send({type:"navigate",id:N}),now:E,toolbar:Yd(s),prompt:qd(s),draft:s.draft,send:v.send,renderer:_d,storage:localStorage,host:window,fetch:rt,fit:g}),y(Fp,{model:vp(e.cwd,Ue.value,dn.value,Le.value?.model.generatedAt??null)}),r==="search"?y(ph,{graph:Le.value,onSelect:N=>v.send({type:"navigate",id:N}),onClose:()=>i(null),ports:{fetch:rt,now:Date.now,delay:(N,z)=>{setTimeout(N,z)}}}):null,r==="help"?y(Gp,{shortcut:fs(ps(e.platform)),onClose:()=>i(null)}):null]})}var Kp=`
|
|
394
|
+
`}tablerow({text:t}){return`<tr>
|
|
395
|
+
${t}</tr>
|
|
396
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
397
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${qe(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=id(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+qe(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=id(t);if(i===null)return qe(n);t=i;let o=`<img src="${t}" alt="${qe(n)}"`;return e&&(o+=` title="${qe(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:qe(t.text)}},Yo=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}},Ue=class Uo{options;renderer;textRenderer;constructor(e){this.options=e||Ct,this.options.renderer=this.options.renderer||new Br,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Yo}static parse(e,n){return new Uo(n).parse(e)}static parseInline(e,n){return new Uo(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}},Tn=class{options;block;constructor(t){this.options=t||Ct}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?$e.lex:$e.lexInline}provideParser(t=this.block){return t?Ue.parse:Ue.parseInline}},Zo=class{defaults=Ho();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ue;Renderer=Br;TextRenderer=Yo;Lexer=$e;Tokenizer=Hr;Hooks=Tn;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 Br(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 d=s.apply(i,u);return d===!1&&(d=l.apply(i,u)),d||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Hr(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 d=s.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Tn;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];Tn.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&Tn.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,u);return l.call(i,h)})();let d=s.call(i,u);return l.call(i,d)}: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 d=s.apply(i,u);return d===!1&&(d=l.apply(i,u)),d}}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 $e.lex(t,e??this.defaults)}parser(t,e){return Ue.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?$e.lex:$e.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?Ue.parse:Ue.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?$e.lex:$e.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?Ue.parse:Ue.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
|
|
398
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+qe(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Rt=new Zo;function V(t,e){return Rt.parse(t,e)}V.options=V.setOptions=function(t){return Rt.setOptions(t),V.defaults=Rt.defaults,ld(V.defaults),V};V.getDefaults=Ho;V.defaults=Ct;function nw(...t){return Rt.use(...t),V.defaults=Rt.defaults,ld(V.defaults),V}V.use=nw;V.walkTokens=function(t,e){return Rt.walkTokens(t,e)};V.parseInline=Rt.parseInline;V.Parser=Ue;V.parser=Ue.parse;V.Renderer=Br;V.TextRenderer=Yo;V.Lexer=$e;V.lexer=$e.lex;V.Tokenizer=Hr;V.Hooks=Tn;V.parse=V;var yk=V.options,wk=V.setOptions,bk=V.walkTokens,xk=V.parseInline;var _k=Ue.parse,kk=$e.lex;var wd={"&":"&","<":"<",">":">",'"':""","'":"'"},rw=new RegExp(`[${Object.keys(wd).join("")}]`,"g");function He(t){return t.replace(rw,e=>wd[e])}var iw=["http:","https:","mailto:"],ow=/^[a-z][a-z0-9+.-]*:/i,aw=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function yd(t){let e=t.replace(aw,""),n=ow.exec(e);return n===null?e===""?null:t:iw.includes(n[0].toLowerCase())?t:null}var ht="data-weave-target",Kr="note:",sw={bySpelling:new Map,hasGhosts:!1};function lw(t){if(t.kind!=="note"||!t.id.startsWith(Kr))return null;let e=t.id.slice(Kr.length);return e===""?null:e}function bd(t,e){if(t===null)return sw;let n=new Map;for(let i of t.model.nodes){let o=lw(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 uw(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function cw(t){return t.hasGhosts}var dw=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function hw(t){let e=t.indexOf("[[");return e===-1?void 0:e}function fw(t){return{name:"wikilink",level:"inline",start:hw,tokenizer(e){return gw(e)},renderer(e){return pw(t,e)}}}function pw(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return mw(t,n,r)}function gw(t){let e=dw.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function mw(t,e,n){let r=He((n===""?e:n).trim());if(r==="")return"";let i=uw(t,e);return i!==null?`<a class="weave-wiki" ${ht}="${He(i)}" role="link" tabindex="0" title="${He(e.trim())}">${r}</a>`:cw(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${He(e.trim())}">${r}</span>`:r}function vw(t){return new Zo({gfm:!0,async:!1,extensions:[fw(t)],renderer:{html({text:e}){return He(e)},link({href:e,title:n,tokens:r}){let i=yd(e),o=this.parser.parseInline(r);return`<a${[i===null?"":` href="${He(i)}"`,n==null||n===""?"":` title="${He(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=yd(e);if(i===null)return He(r);let o=n==null||n===""?"":` title="${He(n)}"`;return`<img src="${He(i)}" alt="${He(r)}"${o}>`}}})}function yw(t,e){return vw(e).parse(t,{async:!1})}function Cn(t){return Object.freeze(t)}var ww=Cn({ALLOWED_TAGS:Cn(["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:Cn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",ht]),ADD_URI_SAFE_ATTR:Cn([ht]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Cn({html:!0})});function xd(t,e,n){return t.sanitize(yw(e,n),ww)}var _d=32;function Xo(t){let e=t;for(let n=0;e!==null&&n<_d;n++){let r=e.getAttribute(ht);if(r!==null&&r!=="")return`${Kr}${r}`;e=e.parentElement}return null}function kd(t){if(!t||t.isCollapsed===!0)return!1;let e=t.toString;return(typeof e=="function"&&e!==Object.prototype.toString?e.call(t):"").length>0}var Ed="edited",Sd="created";function Td(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Et(t.source),provenanceTitle:Wt(t.source),updated:vn(t.updated,e),updatedIso:t.updated,created:vn(t.created,e),createdIso:t.created,tags:t.tags}}function Ad(t){return`#${t}`}var bw=200,xw=8,_w="no note",Qo="weave-preview";function Jo(t){let e=t;for(let n=0;e!==null&&n<_d;n++){let r=e.getAttribute(ht);if(r!==null&&r!=="")return{slug:r,text:(e.textContent??"").trim()};if((e.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(e.textContent??"").trim()};e=e.parentElement}return null}function kw(t){return t.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(e,n,r)=>r??n).replace(/<[^>]*>/g," ").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s{0,3}([-*_][ \t]?){3,}$/gm," ").replace(/^\s{0,3}[-*+]\s+/gm,"").replace(/^\s{0,3}\d+[.)]\s+/gm,"").replace(/[*_~]{1,3}([^*_~]*)[*_~]{1,3}/g,"$1").replace(/\s+/g," ").trim()}function Ew(t,e=bw){let n=kw(t);if(n.length<=e)return n;let r=n.lastIndexOf(" ",e);return`${r>0?n.slice(0,r):n.slice(0,e)}…`}function Rd(t,e){if(e.slug===null){let i=e.text===""?"this link":e.text;return{ghost:!0,title:i,kind:_w,text:`no note named “${i}” yet`}}let n=t?.model.nodes.find(i=>i.id===`note:${e.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${Wt(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Ew(n.detail.preview??"")}}function Cd(t,e,n,r,i,o,a=xw){let s=t+a,l=e+a;return s+n>i-a&&(s=t-a-n),l+r>o-a&&(l=e-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var Vr={anchor:null,pointerX:0,pointerY:0};function Nd(t,e){switch(e.type){case"show":return e.anchor.slug===null&&e.anchor.text===""?t:{anchor:e.anchor,pointerX:e.x,pointerY:e.y};case"hide":return t.anchor===null?t:Vr;case"dismiss":return Vr}}function Ld(t,e){return e!==null?null:t===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":t.startsWith(Kr)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var Sw="weave-preview-x",Tw="weave-preview-y";function Aw({view:t,open:e}){return x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:t.title}),x("p",{class:"weave-note-meta",children:[x("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:e,children:x("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),x("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),x("span",{class:"weave-note-time",title:t.updatedIso,children:[Ed," ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:[Sd," ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(n=>x("span",{class:"weave-tag",children:Ad(n)},n))})]})}function Pd(t){let e=t.note?.note??null,n=Ld(t.selectedId,e),r=vt(()=>e===null?null:bd(t.graph,e.slug),[e,t.graph]),i=vt(()=>e===null||r===null?"":xd(ed,e.body,r),[e,r]),[o,a]=he(Vr),s=c=>{a(f=>Nd(f,c))},l=re(null),u=re(null),d=o.anchor===null?null:Rd(t.graph,o.anchor);if(Si(()=>{s({type:"hide"})},[e===null?null:e.slug]),Si(()=>{let c=l.current;if(c!==null){let v=o.anchor?.slug??null;for(let m of c.querySelectorAll(`a[${ht}]`))v!==null&&m.getAttribute(ht)===v?m.setAttribute("aria-describedby",Qo):m.removeAttribute("aria-describedby")}let f=u.current;if(f===null||d===null)return;let g=Cd(o.pointerX,o.pointerY,f.offsetWidth,f.offsetHeight,window.innerWidth,window.innerHeight);f.style.setProperty(`--${Sw}`,`${g.x}px`),f.style.setProperty(`--${Tw}`,`${g.y}px`)},[o,d]),e===null||r===null)return x("p",{class:"weave-note-empty",children:n});let h=Td(e,t.now);return x("article",{class:`weave-note weave-note-${h.provenance}`,children:[x(Aw,{view:h,open:()=>t.onOpen(e.slug)}),x("div",{ref:l,class:"weave-note-body",tabIndex:-1,onMouseOver:c=>{let f=Jo(c.target);s(f!==null?{type:"show",anchor:f,x:c.clientX,y:c.clientY}:{type:"hide"})},onMouseLeave:()=>s({type:"hide"}),onFocus:c=>{let f=Jo(c.target);if(f===null)return;let g=c.target.getBoundingClientRect?.();s({type:"show",anchor:f,x:g?.left??0,y:g?.bottom??0})},onBlur:()=>s({type:"hide"}),onClick:c=>{let f=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(kd(f))return;let g=Xo(c.target);if(g!==null){t.onSelect(g);return}},onKeyDown:c=>{if(c.key==="Escape"&&o.anchor!==null){c.stopPropagation(),s({type:"dismiss"});return}if(c.key!=="Enter"&&c.key!==" ")return;let f=Xo(c.target);f!==null&&(c.preventDefault(),t.onSelect(f))},dangerouslySetInnerHTML:{__html:i}}),d===null?null:x("div",{ref:u,id:Qo,role:"tooltip",class:`weave-preview${d.ghost?" weave-preview-ghost":""}`,children:[x("span",{class:"weave-preview-kind",children:d.kind}),x("span",{class:"weave-preview-title",children:d.title}),d.text===""?null:x("p",{class:"weave-preview-text",children:d.text})]})]},e.slug)}var Rw={notes:0,repo:null,nodes:0},Cw=["note"];function Dd(t){if(t===null)return Rw;let e=t.model.nodes;return{notes:e.filter(n=>Cw.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function Nw(t){return t===null||t==="missing"?"unindexed":t}function Id(t){return[`vault:${t.notes}`,`repo:${Nw(t.repo)}`,`${t.nodes} nodes`]}var Lw={tree:{title:"Tree"},note:{title:"Note"},graph:{title:"Graph"}};function Gd(t){return Lw[t]}var ea={title:"Context"},Md="—";function Od(t,e,n){return{cwd:t===""?Md:t,selection:e??"nothing selected",stamp:n}}function Fd(t){return t===null?Md:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}var zd=["M21 12a9 9 0 1 1-2.64-6.36","M21 3v6h-6"],$d=6e4,Ud="Search…";function ta(t){return t?"⌘K":"Ctrl K"}function Hd(t){return`Search notes and repository (${t})`}function na(t){return/mac|iphone|ipad/i.test(t)}var Pw={k:{type:"openSearch"}},Bd={1:"tree",2:"note",3:"graph"},Dw=new Set(["tree","graph"]);function Iw(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function Gw(t){return!t.ctrl&&!t.meta&&!t.alt}var Mw={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function Wd(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(Iw(t)){let n=Pw[t.key.toLowerCase()];if(n!==void 0)return n;let r=Bd[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!Gw(t)||t.typing?null:Mw[t.key]??null}var Ow=["INPUT","TEXTAREA","SELECT"];function ra(t,e){return e?!0:t!==null&&Ow.includes(t.toUpperCase())}function Kd(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:ra(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Fw={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},zw=".weave-col-tree .weave-filter";function $w(t){let e=t;return typeof e?.focus=="function"?e:null}function Vd(t,e){let n=$w(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function jd(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(Fw[t.column]);case"filterTree":return void e.focusSelector(zw);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"cycleTheme":return e.cycleTheme()}}function qd(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(Bd).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column${Dw.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var ia="Keyboard shortcuts",Yd="esc close";var Zd={chevron:{d:["M5.75 4.25 9.5 8l-3.75 3.75"],filled:!1},vault:{d:["M8 2.6 13.4 8 8 13.4 2.6 8Z"],filled:!0},note:{d:["M4.5 2.75h4.75l2.25 2.25v8.25h-7Z","M9.25 2.75V5h2.25"],filled:!1},repository:{d:["M2.75 4.25h10.5v7.5H2.75Z","M2.75 6.75h10.5"],filled:!1},module:{d:["M2.75 4.25h4l1.5 1.75h5v5.75h-10.5Z"],filled:!1},package:{d:["M8 2.5 13.25 5v6L8 13.5 2.75 11V5Z","M2.75 5 8 7.5 13.25 5","M8 7.5v6"],filled:!1},entryPoint:{d:["M5.75 3.75v8.5L12.75 8Z"],filled:!0},gitState:{d:["M8 2.85 13.15 8 8 13.15 2.85 8Z"],filled:!1},external:{d:["M4.5 11.5l7-7","M6.75 4.5h4.75v4.75"],filled:!1},file:{d:["M4.5 2.75h7v10.5h-7Z"],filled:!1}};function Nn({name:t,class:e}){let n=Zd[t];return x("svg",{class:e,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:n.filled?"currentColor":"none",stroke:n.filled?void 0:"currentColor","stroke-width":n.filled?void 0:n.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n.d.map(r=>x("path",{d:r}))})}function Hw({view:t,recentIds:e,onSelect:n,onToggle:r}){return x("li",{id:t.domId,"data-row-id":t.id,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${e.has(t.id)?" weave-row-new":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:vu(t.depth),onClick:n,children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:i=>{i.stopPropagation(),r()},children:t.hasKids?x(Nn,{name:"chevron",class:t.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),x("span",{class:"weave-kind","aria-hidden":"true",children:x(Nn,{name:t.kindIcon,class:"weave-icon"})}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label}),x("span",{class:"weave-meta",children:t.meta})]})}function Xd(t){let[e,n]=he(lu),r=uu(t.graph,e),i=Su(t.graph,r,e);return x("div",{class:"weave-tree",onKeyDown:o=>{let a=o.target,s=fu(r,e,t.selectedId,o.key,ra(a?.tagName??null,a?.isContentEditable===!0));s.handled&&(o.preventDefault(),n(s.state),s.selectedId!==null&&t.onSelect(s.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:xu,"aria-label":ku,title:Eu,onInput:o=>n(cu(e,o.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:yu(e.provFilter),onClick:()=>n(du(e)),children:["◧ ",Tr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:bu(e.showInternals),onClick:()=>n(hu(e)),children:["◧ ",wu(e.showInternals)]})]}),i===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":_u,"aria-activedescendant":mu(r,t.selectedId)??void 0,children:gu(r,t.selectedId,t.now).map(o=>x(Hw,{view:o,recentIds:t.recentIds,onSelect:()=>{t.onSelect(o.id),o.hasKids&&n(a=>yo(a,o.id))},onToggle:()=>n(yo(e,o.id))},o.id))}):x("p",{class:"weave-tree-empty",children:i}),x("p",{class:"weave-tree-count",children:Tu(r)})]})}var Ln={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function Yr(t,e,n){return{id:t,target:e.id,label:Te(e),kind:e.kind,kindIcon:wo(e.kind),provenance:e.provenance,provenanceGlyph:Et(e.provenance),provenanceTitle:Wt(e.provenance),selected:e.id===n}}function Bw(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:Yr(t.id,i,n)}function Ww(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var Kw=["link:links-to:"];function Vw(t){return Kw.some(e=>t.id.startsWith(e))}function jw(t){return t.id.startsWith("link:mentions:")}function qw(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(Yr(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function Yw(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(Yr(`mentioned-by:${o.source}`,a,r))}return i}function Zw(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var qr={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 oa(t){return{subject:null,groups:[],tags:[],tagsCount:0,empty:t}}function Qd(t,e){if(t===null)return oa(qr.loading);if(e===null)return oa(qr.noSelection);let n=kt(t),r=fo(n,e);if(r===null)return oa(qr.unknown);let i=Ww(n),o=[],a=(h,c)=>{c.length>0&&o.push({heading:h,count:c.length,rows:c})},s=h=>h.map(c=>Bw(c,i,e)).filter(c=>c!==null);a(Ln.links,s(r.links.filter(Vw)));let l=go(n.edges).get(e)??[];a(Ln.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>Yr(`backlink:${h.id}`,h,e))),a(Ln.mentions,[...s(r.links.filter(jw)),...Yw(n,e,i,e)]);let u=Zw(e),d=u===null?[]:qw(t,u,i,e);return o.length===0&&d.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:qr.isolated}:{subject:r.label,groups:o,tags:d,tagsCount:d.length,empty:null}}function Jd(){return{open:new Set,closed:new Set}}var Xw=8;function eh(t,e,n,r){return r?!1:t.closed.has(e)?!0:t.open.has(e)?!1:n>Xw}function Qw(t){return t.some(e=>e.selected)}function th(t,e){let n=eh(e,t.heading,t.count,Qw(t.rows));return{heading:t.heading,count:t.count,collapsed:n,rows:n?[]:t.rows}}function nh(t,e){let n=eh(e,Ln.tags,t.length,t.some(r=>r.siblings.some(i=>i.selected)));return{heading:Ln.tags,count:t.length,collapsed:n,rows:[]}}function rh(t,e,n){let r=new Set(t.open),i=new Set(t.closed);return n?(r.add(e),i.delete(e)):(i.add(e),r.delete(e)),{open:r,closed:i}}function Zr(t){return`weave-ctx-panel-${t.toLowerCase()}`}function ih({row:t,onSelect:e}){return x("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:x("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[x("span",{class:"weave-kind","aria-hidden":"true",children:x(Nn,{name:t.kindIcon,class:"weave-icon"})}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label})]})})}function oh({view:t,onToggle:e}){return x("h4",{class:"weave-ctx-head",children:x("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!t.collapsed,"aria-controls":Zr(t.heading),onClick:e,children:[x("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:x(Nn,{name:"chevron",class:t.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),t.heading,x("span",{class:"weave-ctx-count",children:t.count})]})})}function Jw({view:t,onSelect:e,onToggle:n}){return x("section",{class:"weave-ctx-group",children:[x(oh,{view:t,onToggle:n}),x("ul",{class:"weave-ctx-rows",id:Zr(t.heading),hidden:t.collapsed,children:t.rows.map(r=>x(ih,{row:r,onSelect:()=>e(r.target)},r.id))})]})}function eb({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(ih,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function ah(t){let e=Qd(t.graph,t.selectedId),[n,r]=he(Jd),i=a=>()=>r(rh(n,a.heading,a.collapsed)),o=nh(e.tags,n);return x("div",{class:"weave-rail","aria-label":ea.title,children:[x("h2",{class:"weave-col-title",children:ea.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(a=>{let s=th(a,n);return x(Jw,{view:s,onSelect:t.onSelect,onToggle:i(s)},a.heading)}),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x(oh,{view:o,onToggle:i(o)}),x("ul",{class:"weave-ctx-tags",id:Zr(o.heading),hidden:o.collapsed,children:e.tags.map(a=>x(eb,{tag:a,onSelect:t.onSelect},a.tag))})]})]})}function aa({id:t,props:e}){let n=Gd(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(Xd,{graph:e.graph,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:e.onSelect,now:e.now}):null,t==="note"?x(Pd,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,onOpen:e.onOpen}):null,t==="graph"?x(Ic,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,scheme:e.scheme,bootFailed:e.bootFailed,fit:e.fit}):null,t==="graph"?x(ah,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function sh(t){return x("div",{class:"weave-grid",children:[x(aa,{id:"tree",props:t}),x(aa,{id:"note",props:t}),x(aa,{id:"graph",props:t})]})}function tb(t){if(t===""||t==="#")return null;let e=t.slice(1),n=/^note[/:](.+)$/.exec(e);return n===null?null:`note:${n[1]}`}function lh(t,e){let n=tb(t);return n===null||e===null?null:e.model.nodes.some(r=>r.id===n)?n:null}function uh(t){let e=t===null?null:t.startsWith("note:")?t.slice(5):null;return e===null||e===""?"":`#note/${e}`}var ch="image/png",dh="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 nb({onRefresh:t}){let[e,n]=he(!1);return x("button",{type:"button",class:"weave-refresh",onClick:()=>{t(),n(!0)},onAnimationEnd:()=>n(!1),title:"Refetch everything","aria-busy":e?"true":void 0,children:x("svg",{class:e?"weave-refresh-glyph weave-refresh-spinning":"weave-refresh-glyph",viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:zd.map(r=>x("path",{d:r},r))})})}function hh(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:[x("img",{class:"weave-brand-mark",src:`data:${ch};base64,${dh}`,alt:"",width:18,height:18}),"pi-weave"]}),x("button",{type:"button",class:"weave-search",title:Hd(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:Ud}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:Id(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-theme",onClick:t.onTheme,title:t.theme.hint,"aria-label":t.theme.hint,children:t.theme.glyph}),x(nb,{onRefresh:t.onRefresh})]})}function rb({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 fh(t){let e=Mr(),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":ia,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:ia}),x("div",{class:"weave-keys",children:qd(n).map(r=>x(rb,{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:Yd})]})]})})}function ph(t,e){let n=r=>{let i=Wd(Kd(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function gh({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:Fd(t.stamp)})]})}var sa=["system","light","dark"],mh="pi-weave.theme.v1";function ib(t){return t==="system"||t==="light"||t==="dark"}function Xr(t){try{let e=t.getItem(mh);return ib(e)?e:null}catch{return null}}function vh(t,e){try{return t.setItem(mh,e),!0}catch{return!1}}function Qr(t){let e=sa.indexOf(t);return sa[(e+1)%sa.length]??"system"}function yh(t,e){return t==="system"?e:t}function Jr(t){return t==="system"?null:t}var ob={dark:"●",system:"◐",light:"○"};function wh(t){return{glyph:ob[t],hint:`Colour theme: ${t} — click for ${Qr(t)}`}}function ab(t){t===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=t}function bh(t){let[e,n]=he(gc),[r,i]=he(null),[o,a]=he(()=>Xr(localStorage)??"system"),[s,l]=he(()=>nr(window)),u=re(null),d=re(null),h=re({overlay:r,selectedId:e.selectedId});h.current={overlay:r,selectedId:e.selectedId},ie(()=>{let m=yc({fetch:tr,state:e,setState:n});return u.current=m,()=>m.stop()},[]);let c=re(!1),f=re(location.hash);ie(()=>{c.current&&(fc(localStorage,e.selectedId),history.replaceState(null,"",uh(e.selectedId)))},[e.selectedId]),ie(()=>{if(c.current||e.graph===null||(c.current=!0,e.selectedId!==null))return;let m=lh(f.current,e.graph);if(m!==null)u.current?.select(m);else{let y=pc(e.graph,localStorage);y!==null&&u.current?.select(y)}},[e.graph]);let[g,v]=he(()=>Date.now());return ie(()=>{let m=setInterval(()=>v(Date.now()),$d);return()=>clearInterval(m)},[]),ie(()=>ab(Jr(o)),[o]),ie(()=>{vh(localStorage,o)},[o]),ie(()=>xs(window,l),[]),ie(()=>ph(document,{context:()=>({overlay:h.current.overlay,hasSelection:h.current.selectedId!==null}),run:m=>jd(m,{setOverlay:i,focusSelector:y=>Vd(document,y),fitGraph:()=>d.current?.(),clearSelection:()=>{u.current?.select(null)},cycleTheme:()=>a(y=>Qr(y))})}),[]),x(at,{children:[x(hh,{summary:Dd(e.graph),shortcut:ta(na(t.platform)),onRefresh:()=>u.current?.refresh(),onSearch:()=>i("search"),theme:wh(o),onTheme:()=>a(m=>Qr(m))}),x(sh,{scheme:yh(o,s),bootFailed:e.graphFailed,graph:e.graph,note:e.note,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:m=>{u.current?.select(m)},onOpen:m=>{ws(tr,m)},now:g,renderer:Xu,storage:localStorage,host:window,fit:d}),x(gh,{model:Od(t.cwd,e.selectedId,e.graph?.model.generatedAt??null)}),r==="search"?x(dc,{graph:e.graph,onSelect:m=>{u.current?.select(m)},onClose:()=>i(null),ports:{fetch:tr}}):null,r==="help"?x(fh,{shortcut:ta(na(t.platform)),onClose:()=>i(null)}):null]})}var xh=`
|
|
401
399
|
--weave-bg:#eff1f5;--weave-panel:#e6e9ef;--weave-raise:#ccd0da;--weave-fg:#4c4f69;--weave-dim:#56586a;
|
|
402
400
|
--weave-faint:#606274;--weave-line:#ccd0da;--weave-line-strong:#bcc0cc;
|
|
403
401
|
--weave-accent:#7113ec;--weave-ok:#28641b;--weave-warn:#7c4f10;--weave-bad:#b20d30;
|
|
404
402
|
--weave-new:rgba(113,19,236,.10);
|
|
405
403
|
--weave-page:#dce0e8;
|
|
406
|
-
`,
|
|
404
|
+
`,sb=`
|
|
407
405
|
:root{
|
|
408
406
|
--weave-bg:#24273a;--weave-panel:#1e2030;--weave-raise:#363a4f;--weave-fg:#cad3f5;--weave-dim:#a5adcb;
|
|
409
407
|
--weave-faint:#939ab7;--weave-line:#363a4f;--weave-line-strong:#494d64;
|
|
@@ -437,7 +435,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
437
435
|
ui 11.5 status bar, the note's meta row, small controls
|
|
438
436
|
row 12 list rows, text inputs, inline code
|
|
439
437
|
base 13 body copy, h3-h6, preview-card text
|
|
440
|
-
body 13.5 the note column's prose
|
|
438
|
+
body 13.5 the note column's prose
|
|
441
439
|
subhead 14 palette input, note-body h2, header icon buttons
|
|
442
440
|
title 15 note-body h1
|
|
443
441
|
display 20 the note's page title
|
|
@@ -465,11 +463,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
465
463
|
without a manual "dark" being dragged back into light by the OS. */
|
|
466
464
|
@media (prefers-color-scheme: light){
|
|
467
465
|
:root:not([data-weave-theme="dark"]){
|
|
468
|
-
${
|
|
466
|
+
${xh}
|
|
469
467
|
}
|
|
470
468
|
}
|
|
471
469
|
:root[data-weave-theme="light"]{
|
|
472
|
-
${
|
|
470
|
+
${xh}
|
|
473
471
|
}
|
|
474
472
|
body{font-size:var(--weave-px-base)}
|
|
475
473
|
#app{height:100%;display:grid;grid-template-rows:auto 1fr auto;background:var(--weave-bg)}
|
|
@@ -520,30 +518,21 @@ body{font-size:var(--weave-px-base)}
|
|
|
520
518
|
}
|
|
521
519
|
.weave-theme:hover{color:var(--weave-fg);background:var(--weave-line)}
|
|
522
520
|
|
|
523
|
-
/* connection indicator -------------------------------------------------- */
|
|
524
|
-
.weave-conn{display:inline-flex;align-items:center;gap:5px;font-size:var(--weave-px-ui);white-space:nowrap}
|
|
525
|
-
.weave-conn-dot{font-size:var(--weave-px-prov);line-height:1}
|
|
526
|
-
/* Reconnecting breathes instead of sitting there: the one state whose whole
|
|
527
|
-
message is "hold on, I am still working" is the one that should keep
|
|
528
|
-
saying it. The offline dot stays still — its message needs a decision,
|
|
529
|
-
not patience. The global reduced-motion kill switch restores the static
|
|
530
|
-
dot, the same way it does every animation in this sheet. */
|
|
531
|
-
.weave-conn-ok .weave-conn-dot,.weave-conn-ok{color:var(--weave-ok)}
|
|
532
|
-
.weave-conn-warn .weave-conn-dot,.weave-conn-warn{color:var(--weave-warn)}
|
|
533
|
-
.weave-conn-warn .weave-conn-dot{animation:weave-conn-pulse 1.6s ease-in-out infinite}
|
|
534
|
-
.weave-conn-bad .weave-conn-dot,.weave-conn-bad{color:var(--weave-bad)}
|
|
535
|
-
@keyframes weave-conn-pulse{0%,100%{opacity:1}50%{opacity:.35}}
|
|
536
|
-
|
|
537
521
|
/* the grid -------------------------------------------------------------- */
|
|
538
|
-
/*
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
522
|
+
/* One boring grid. CSS owns the breakpoints; no saved widths, divider state
|
|
523
|
+
or viewport listener can make the shell disagree with the browser. */
|
|
524
|
+
.weave-grid{
|
|
525
|
+
display:grid;min-height:0;overflow:hidden;background:var(--weave-line);
|
|
526
|
+
grid-template-columns:minmax(180px,22fr) minmax(320px,46fr) minmax(260px,32fr);
|
|
527
|
+
}
|
|
528
|
+
@media (max-width:1099px){
|
|
529
|
+
.weave-grid{grid-template-columns:minmax(180px,32fr) minmax(320px,68fr)}
|
|
530
|
+
.weave-col-graph{display:none}
|
|
531
|
+
}
|
|
532
|
+
@media (max-width:799px){
|
|
533
|
+
.weave-grid{grid-template-columns:1fr}
|
|
534
|
+
.weave-col-tree{display:none}
|
|
544
535
|
}
|
|
545
|
-
.weave-grid[data-columns="2"]{grid-template-columns:var(--weave-col-tree,32%) 1px var(--weave-col-note,68%)}
|
|
546
|
-
.weave-grid[data-columns="1"]{grid-template-columns:1fr}
|
|
547
536
|
|
|
548
537
|
.weave-col{
|
|
549
538
|
display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;
|
|
@@ -562,18 +551,8 @@ body{font-size:var(--weave-px-base)}
|
|
|
562
551
|
inside the same region instead of squeezing the graph. */
|
|
563
552
|
.weave-col-graph{display:grid;grid-template-rows:auto minmax(0,1fr) minmax(96px,40%);background:var(--weave-bg)}
|
|
564
553
|
|
|
565
|
-
/* dividers -------------------------------------------------------------- */
|
|
566
|
-
.weave-divider{
|
|
567
|
-
background:var(--weave-line);cursor:col-resize;position:relative;
|
|
568
|
-
touch-action:none;
|
|
569
|
-
}
|
|
570
|
-
/* A 1 px target is unhittable, so the hit area is widened with a pseudo
|
|
571
|
-
element rather than by making the visible rule thicker. */
|
|
572
|
-
.weave-divider::after{content:"";position:absolute;inset:0 -3px;z-index:1}
|
|
573
|
-
.weave-divider:hover,.weave-divider:focus-visible{background:var(--weave-accent);outline:none}
|
|
574
|
-
|
|
575
554
|
/* tree column ----------------------------------------------------------- */
|
|
576
|
-
/* --weave-depth is written per row by \`depthVar\`, through
|
|
555
|
+
/* --weave-depth is written per row by \`depthVar\`, through CSSOM
|
|
577
556
|
path as the column widths, and multiplied by a step this sheet owns — so
|
|
578
557
|
the tree's density stays a CSS decision. */
|
|
579
558
|
.weave-tree{display:flex;flex-direction:column;min-height:0;flex:1}
|
|
@@ -592,8 +571,6 @@ body{font-size:var(--weave-px-base)}
|
|
|
592
571
|
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
|
|
593
572
|
}
|
|
594
573
|
.weave-chip:hover{color:var(--weave-fg);border-color:var(--weave-accent)}
|
|
595
|
-
.weave-chip-bad{color:var(--weave-bad);border-color:var(--weave-bad)}
|
|
596
|
-
.weave-chip-bad:hover{color:var(--weave-fg);background:var(--weave-bad);border-color:var(--weave-bad)}
|
|
597
574
|
.weave-rows{
|
|
598
575
|
flex:1;min-height:0;overflow:auto;margin:0;padding:3px 0;list-style:none;
|
|
599
576
|
}
|
|
@@ -605,45 +582,22 @@ body{font-size:var(--weave-px-base)}
|
|
|
605
582
|
cursor:default;white-space:nowrap;
|
|
606
583
|
}
|
|
607
584
|
.weave-row:hover{background:var(--weave-line)}
|
|
608
|
-
.weave-row.weave-row-droptarget{
|
|
609
|
-
background:var(--weave-new);outline:1px dashed var(--weave-accent);outline-offset:-1px;
|
|
610
|
-
}
|
|
611
|
-
.weave-tree-new-folder{
|
|
612
|
-
display:flex;align-items:center;gap:6px;padding:4px var(--weave-gutter);
|
|
613
|
-
border-bottom:1px solid var(--weave-line);background:var(--weave-panel);
|
|
614
|
-
}
|
|
615
|
-
.weave-row-del{
|
|
616
|
-
display:none;margin-left:auto;padding:0 4px;font:inherit;font-size:var(--weave-px-row);
|
|
617
|
-
line-height:1;color:var(--weave-faint);background:none;border:0;cursor:pointer;
|
|
618
|
-
border-radius:var(--weave-radius);
|
|
619
|
-
}
|
|
620
|
-
.weave-row:hover .weave-row-del{display:inline-flex;align-items:center}
|
|
621
|
-
.weave-row-del:hover{color:var(--weave-bad);background:var(--weave-panel)}
|
|
622
585
|
/* A hover changes two things, in this order: the ground appears under the
|
|
623
586
|
row, then the label steps up to fg. The second half is what stops the
|
|
624
587
|
hover from reading as a stray grey rectangle — the row answers the pointer
|
|
625
588
|
in both channels at once. */
|
|
626
589
|
.weave-row:hover .weave-label{color:var(--weave-fg)}
|
|
627
|
-
/* The session fold (tree.model.ts's isMuted): machine-written memory that
|
|
628
|
-
accrues by the dozens with near-duplicate titles, dropped one notch so the
|
|
629
|
-
rows a human wrote keep the foreground. --weave-dim holds ≥ 4.5 on both
|
|
630
|
-
grounds, so this is quiet, not illegible — and the two states below always
|
|
631
|
-
restore full weight, which is why the model never emits both classes on
|
|
632
|
-
one row. */
|
|
633
|
-
.weave-row-muted .weave-label{color:var(--weave-dim)}
|
|
634
|
-
.weave-row-muted:hover .weave-label{color:var(--weave-fg)}
|
|
635
590
|
/* The selection has one voice. On the tinted ground every quieter token still
|
|
636
591
|
fails contrast — even --weave-dim lands under 4.5 — so a selected row's
|
|
637
592
|
kind, provenance and meta children join its label in --weave-fg. The
|
|
638
593
|
provenance glyph shape carries the distinction the colour swap drops;
|
|
639
594
|
elsewhere the hues are unaffected. The palette's hit rows need the same
|
|
640
595
|
remap: same selected ground, same failure. The label is restated last
|
|
641
|
-
|
|
642
|
-
on. */
|
|
596
|
+
so the selected row is always readable. */
|
|
643
597
|
.weave-row-on .weave-twisty,.weave-row-on .weave-kind,.weave-row-on .weave-prov,
|
|
644
598
|
.weave-row-on .weave-meta,.weave-row-on .weave-label{color:var(--weave-fg)}
|
|
645
599
|
.weave-hit-on .weave-hit-badge,.weave-hit-on .weave-hit-detail{color:var(--weave-fg)}
|
|
646
|
-
/* A newly-arrived node (a file or note added since the last update,
|
|
600
|
+
/* A newly-arrived node (a file or note added since the last update, ):
|
|
647
601
|
one short highlight that fades while the label settles from bold back to
|
|
648
602
|
normal. The class is computed from the frame diff in workspace.ts and
|
|
649
603
|
expires with it, so collapsing and re-expanding later does not replay the
|
|
@@ -670,7 +624,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
670
624
|
|
|
671
625
|
/* icons ------------------------------------------------------------------
|
|
672
626
|
The sprite's only CSS: one colour (the glyph inherits the row's, so a
|
|
673
|
-
|
|
627
|
+
quiet row's icon recedes with it and a selected row's brightens with it)
|
|
674
628
|
and the twisty's rotation, which is the *same* 16px chevron the rail's
|
|
675
629
|
group headings use — right-pointing closed, rotated 90° open. The
|
|
676
630
|
rotation is not in the motion block's transition list, on purpose: that
|
|
@@ -686,8 +640,8 @@ body{font-size:var(--weave-px-base)}
|
|
|
686
640
|
so it lies on --weave-page — one step off the desk and the canvas grounds.
|
|
687
641
|
The 2px rule flush to its left edge is the spine: it takes the note's
|
|
688
642
|
provenance colour (see the --weave-spine map), so the document's origin is
|
|
689
|
-
readable peripherally, before any glyph is. Head
|
|
690
|
-
--weave-note-gutter so
|
|
643
|
+
readable peripherally, before any glyph is. Head and body share the
|
|
644
|
+
--weave-note-gutter so the page has one consistent measure. */
|
|
691
645
|
.weave-note{display:flex;flex-direction:column;min-height:0;flex:1;overflow:auto;background:var(--weave-page)}
|
|
692
646
|
.weave-note-human{--weave-spine:var(--weave-ok)}
|
|
693
647
|
.weave-note-agent{--weave-spine:var(--weave-accent)}
|
|
@@ -699,9 +653,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
699
653
|
alternative, a title that scrolls away, is how a reader ends up annotating
|
|
700
654
|
the wrong file. It carries the page ground rather than a fill or a shadow,
|
|
701
655
|
so the reveal reads as the page continuing under it and not as a bar
|
|
702
|
-
arriving; the hairline is the only seam. The
|
|
703
|
-
sibling in the column flow, so it can never slide underneath — no stacking
|
|
704
|
-
contest exists between them. The head's z-index is only what keeps it above
|
|
656
|
+
arriving; the hairline is the only seam. The head's z-index is only what keeps it above
|
|
705
657
|
the prose (and the wikilinks inside it) as that prose scrolls beneath. */
|
|
706
658
|
.weave-note-head{position:sticky;top:0;z-index:2;padding:14px var(--weave-note-gutter) 9px;background:var(--weave-page);border-bottom:1px solid var(--weave-line)}
|
|
707
659
|
/* The page's largest voice, and the point of the review's headline finding:
|
|
@@ -715,11 +667,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
715
667
|
so the eye can read the whole of it without ever reading it. */
|
|
716
668
|
.weave-note-meta{margin:0;display:flex;align-items:center;gap:8px;font-size:var(--weave-px-ui);color:var(--weave-dim);flex-wrap:wrap}
|
|
717
669
|
.weave-note-time{color:var(--weave-faint)}
|
|
718
|
-
/* \`Open in $EDITOR
|
|
719
|
-
bordered button — the note's loudest control, sitting between its title and
|
|
720
|
-
its prose. Now it is an icon at the end of the meta line: the hint rides
|
|
721
|
-
the \`title\`/\`aria-label\` (\`editor.model.ts\`'s OPEN_HINT/OPEN_LABEL), and
|
|
722
|
-
the control is quiet until the pointer asks for it. */
|
|
670
|
+
/* \`Open in $EDITOR\` is a quiet icon at the end of the meta line. */
|
|
723
671
|
.weave-note-open{
|
|
724
672
|
display:inline-flex;align-items:center;justify-content:center;
|
|
725
673
|
width:22px;height:22px;padding:0;font:inherit;color:var(--weave-faint);
|
|
@@ -736,9 +684,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
736
684
|
withdrawn at the user's call: this is a workspace, and the note shares the
|
|
737
685
|
width the desk gives it. It reads at --weave-px-body on 1.7 rather than the
|
|
738
686
|
chrome's 1.6: the extra leading is what a page of running text needs that a
|
|
739
|
-
status bar does not. Code
|
|
740
|
-
reading prose and reading raw are different postures, and the face switch
|
|
741
|
-
is the toggle. */
|
|
687
|
+
status bar does not. Code stays mono deliberately. */
|
|
742
688
|
.weave-note-body{padding:12px var(--weave-note-gutter) 28px;font-size:var(--weave-px-body);line-height:1.7;color:var(--weave-fg)}
|
|
743
689
|
.weave-note-body>*:first-child{margin-top:0}
|
|
744
690
|
.weave-note-body h1,.weave-note-body h2,.weave-note-body h3,
|
|
@@ -826,53 +772,6 @@ body{font-size:var(--weave-px-base)}
|
|
|
826
772
|
underlines a hover should not land with a thud. */
|
|
827
773
|
@keyframes weave-preview-in{from{opacity:0;transform:translateY(2px)}}
|
|
828
774
|
|
|
829
|
-
/* note editor (§11 P5) ---------------------------------------------------- */
|
|
830
|
-
/* A \`<textarea>\`, not CodeMirror: §0 V10 measured CM6 at 118 KB gzip, more
|
|
831
|
-
than the entire rest of the client. It inherits the body's type so toggling
|
|
832
|
-
\`⌘E\` does not reflow the column into a different shape. */
|
|
833
|
-
.weave-note-bar{
|
|
834
|
-
display:flex;align-items:center;gap:6px;flex-wrap:wrap;
|
|
835
|
-
padding:5px var(--weave-gutter);border-bottom:1px solid var(--weave-line);
|
|
836
|
-
}
|
|
837
|
-
/* \`weave-note-open\` is styled in the note column above (P6.3 moved it into
|
|
838
|
-
the head's meta row as an icon), and no longer shares the bar's bordered
|
|
839
|
-
button voice. */
|
|
840
|
-
.weave-note-toggle,.weave-note-save,.weave-note-action{
|
|
841
|
-
font:inherit;font-size:var(--weave-px-ui);padding:2px 8px;cursor:pointer;
|
|
842
|
-
color:var(--weave-fg);background:var(--weave-raise);
|
|
843
|
-
border:1px solid var(--weave-line);border-radius:var(--weave-radius);
|
|
844
|
-
}
|
|
845
|
-
.weave-note-toggle:hover,.weave-note-save:hover,.weave-note-action:hover{
|
|
846
|
-
border-color:var(--weave-accent);
|
|
847
|
-
}
|
|
848
|
-
.weave-note-toggle[aria-pressed="true"]{border-color:var(--weave-accent);color:var(--weave-accent)}
|
|
849
|
-
.weave-note-save:disabled{opacity:.45;cursor:default;border-color:var(--weave-line)}
|
|
850
|
-
.weave-note-dirty{color:var(--weave-accent);font-size:var(--weave-px-subhead);line-height:1}
|
|
851
|
-
.weave-note-status{font-size:var(--weave-px-ui);color:var(--weave-dim)}
|
|
852
|
-
.weave-note-status-ok{color:var(--weave-ok)}
|
|
853
|
-
.weave-note-status-warn{color:var(--weave-warn)}
|
|
854
|
-
/* The prompt takes the full row rather than sitting inline: reload-or-overwrite
|
|
855
|
-
is a decision about the user's unsaved text, and a decision squeezed between
|
|
856
|
-
two buttons reads as a hint. */
|
|
857
|
-
.weave-note-prompt{
|
|
858
|
-
flex-basis:100%;display:flex;align-items:center;gap:8px;flex-wrap:wrap;
|
|
859
|
-
margin-top:4px;padding:5px 8px;border-radius:var(--weave-radius);
|
|
860
|
-
background:var(--weave-raise);border:1px solid var(--weave-warn);
|
|
861
|
-
}
|
|
862
|
-
.weave-note-prompt-conflict,.weave-note-prompt-collision{border-color:var(--weave-warn)}
|
|
863
|
-
.weave-note-prompt-external,.weave-note-prompt-discard{border-color:var(--weave-line)}
|
|
864
|
-
.weave-note-prompt-text{margin:0;font-size:var(--weave-px-ui);color:var(--weave-fg)}
|
|
865
|
-
.weave-note-prompt-actions{margin:0;display:flex;gap:6px;flex-wrap:wrap}
|
|
866
|
-
.weave-note-editor{
|
|
867
|
-
flex:1;min-height:240px;resize:none;
|
|
868
|
-
padding:10px var(--weave-note-gutter) 24px;
|
|
869
|
-
/* Exactly the prose body's size and leading. The invariant is documented
|
|
870
|
-
and deliberate: ⌘E must not reflow, and reading raw at the same measure
|
|
871
|
-
the prose uses is what makes the toggle a lens rather than a jump. */
|
|
872
|
-
font:inherit;font-family:var(--weave-mono);font-size:var(--weave-px-body);line-height:1.7;
|
|
873
|
-
color:var(--weave-fg);background:var(--weave-page);border:0;outline-offset:-2px;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
775
|
/* graph column ---------------------------------------------------------- */
|
|
877
776
|
/* The canvas is a plain block sigma appends its own <canvas> layers into. It
|
|
878
777
|
must have a definite size before sigma measures it, hence \`min-height\` and
|
|
@@ -983,14 +882,14 @@ body{font-size:var(--weave-px-base)}
|
|
|
983
882
|
/* status bar ------------------------------------------------------------ */
|
|
984
883
|
/* One separator vocabulary, shared with the header summary: every run of
|
|
985
884
|
status items after the first opens with the same mid-dot, in the same
|
|
986
|
-
--weave-faint. cwd · selection
|
|
885
|
+
--weave-faint. cwd · selection · stamp reads as one grammar,
|
|
987
886
|
the same way the header's three-part summary does. */
|
|
988
887
|
.weave-status{
|
|
989
888
|
display:flex;align-items:center;gap:8px;height:22px;padding:0 var(--weave-gutter);
|
|
990
889
|
font-family:var(--weave-mono);font-size:var(--weave-px-ui);color:var(--weave-dim);
|
|
991
890
|
border-top:1px solid var(--weave-line);background:var(--weave-panel);
|
|
992
891
|
}
|
|
993
|
-
.weave-status-sel::before
|
|
892
|
+
.weave-status-sel::before{content:"·";margin-right:8px;color:var(--weave-faint)}
|
|
994
893
|
.weave-status-cwd,.weave-status-sel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
995
894
|
.weave-status-cwd{max-width:38%;color:var(--weave-faint)}
|
|
996
895
|
.weave-status-sel{color:var(--weave-fg)}
|
|
@@ -1013,31 +912,11 @@ body{font-size:var(--weave-px-base)}
|
|
|
1013
912
|
@media (prefers-color-scheme: light){
|
|
1014
913
|
:root:not([data-weave-theme="dark"]) .weave-scrim{background:rgba(76,79,105,.30)}
|
|
1015
914
|
}
|
|
1016
|
-
.weave-palette,.weave-help
|
|
915
|
+
.weave-palette,.weave-help{
|
|
1017
916
|
display:flex;flex-direction:column;width:100%;max-width:560px;max-height:72vh;
|
|
1018
917
|
overflow:hidden;background:var(--weave-panel);color:var(--weave-fg);
|
|
1019
918
|
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);
|
|
1020
919
|
}
|
|
1021
|
-
.weave-dialog{max-width:380px;padding:16px;overflow:visible}
|
|
1022
|
-
.weave-dialog-title{margin:0 0 8px;font-size:var(--weave-px-subhead);font-weight:600;color:var(--weave-fg)}
|
|
1023
|
-
.weave-dialog-body{margin:0 0 16px;font-size:var(--weave-px-row);line-height:1.5;color:var(--weave-dim)}
|
|
1024
|
-
.weave-dialog-input{width:100%;margin-bottom:12px;box-sizing:border-box}
|
|
1025
|
-
.weave-dialog-actions{display:flex;justify-content:flex-end;gap:8px}
|
|
1026
|
-
.weave-menu-backdrop{position:fixed;inset:0;z-index:9}
|
|
1027
|
-
.weave-menu{
|
|
1028
|
-
position:fixed;left:var(--weave-menu-x,0);top:var(--weave-menu-y,0);z-index:10;
|
|
1029
|
-
min-width:160px;padding:4px 0;background:var(--weave-panel);
|
|
1030
|
-
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);
|
|
1031
|
-
}
|
|
1032
|
-
.weave-menu-item{
|
|
1033
|
-
display:flex;align-items:center;gap:8px;width:100%;height:26px;padding:0 10px;
|
|
1034
|
-
font:inherit;font-size:var(--weave-px-row);text-align:left;color:var(--weave-fg);
|
|
1035
|
-
background:none;border:0;cursor:pointer;white-space:nowrap;
|
|
1036
|
-
}
|
|
1037
|
-
.weave-menu-item:hover{background:var(--weave-line)}
|
|
1038
|
-
.weave-menu-item-bad{color:var(--weave-bad)}
|
|
1039
|
-
.weave-menu-item-bad:hover{color:var(--weave-bad);background:var(--weave-line)}
|
|
1040
|
-
.weave-menu-sep{height:1px;margin:4px 0;background:var(--weave-line);border:0}
|
|
1041
920
|
.weave-palette-input{
|
|
1042
921
|
flex:none;height:34px;padding:0 11px;font:inherit;font-size:var(--weave-px-subhead);
|
|
1043
922
|
color:var(--weave-fg);background:transparent;border:0;
|
|
@@ -1079,7 +958,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
1079
958
|
--weave-new tint is exactly an accent at a strength text stays legible in. */
|
|
1080
959
|
::selection{background:var(--weave-new)}
|
|
1081
960
|
/* Every scroller in the workspace (rows, note body, rail, palette results,
|
|
1082
|
-
help sheet
|
|
961
|
+
help sheet) gets the same thin chrome: the default scrollbar is a
|
|
1083
962
|
15 px system object the hairline aesthetic cannot afford, and Firefox and
|
|
1084
963
|
the Blink/WebKit pair cover the whole surface with these five rules. */
|
|
1085
964
|
*{scrollbar-width:thin;scrollbar-color:var(--weave-line-strong) transparent}
|
|
@@ -1099,20 +978,15 @@ body{font-size:var(--weave-px-base)}
|
|
|
1099
978
|
properties only — colour, border, opacity, transform; height and padding
|
|
1100
979
|
snap. */
|
|
1101
980
|
.weave-row,.weave-ctx-link,.weave-chip,.weave-search,.weave-refresh,.weave-theme,
|
|
1102
|
-
.weave-
|
|
1103
|
-
.weave-note-action{
|
|
981
|
+
.weave-hit,.weave-note-open{
|
|
1104
982
|
transition:background-color 120ms ease,border-color 120ms ease,color 120ms ease;
|
|
1105
983
|
}
|
|
1106
984
|
.weave-scrim{animation:weave-fade-in 140ms ease-out both}
|
|
1107
985
|
.weave-palette,.weave-help{animation:weave-overlay-in 160ms ease-out both}
|
|
1108
|
-
/* The conflict prompt mounts once per conflict, so its entrance cannot strobe
|
|
1109
|
-
the way a context-rail flash would — that rail deliberately stays still. */
|
|
1110
|
-
.weave-note-prompt{animation:weave-prompt-in 180ms ease-out both}
|
|
1111
986
|
@keyframes weave-fade-in{from{opacity:0}}
|
|
1112
987
|
@keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
|
|
1113
|
-
@keyframes weave-prompt-in{from{opacity:0;transform:translateY(-2px)}}
|
|
1114
988
|
@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
|
|
1115
|
-
`,
|
|
989
|
+
`,lb=["style[nonce]","style","script[nonce]","script[src]"];function ub(t){for(let e of lb){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function _h(t,e=sb){let n=t.createElement("style"),r=ub(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var kh=document.getElementById("app");if(kh!==null){_h(document),cb();let t=ns(document.getElementById(ts)?.textContent??null);es(x(bh,{cwd:t.cwd,platform:navigator.platform}),kh)}function cb(){let t=Jr(Xr(localStorage)??"system");t!==null&&(document.documentElement.dataset.weaveTheme=t)}})();
|
|
1116
990
|
/*! Bundled license information:
|
|
1117
991
|
|
|
1118
992
|
dompurify/dist/purify.es.mjs:
|