pi-weave 0.3.12 → 0.3.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.
@@ -18,21 +18,21 @@
18
18
  * sigma@3.0.3 — MIT
19
19
  */
20
20
 
21
- "use strict";(()=>{var jm=Object.create;var Ql=Object.defineProperty;var qm=Object.getOwnPropertyDescriptor;var Ym=Object.getOwnPropertyNames;var Zm=Object.getPrototypeOf,Xm=Object.prototype.hasOwnProperty;var Jl=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Qm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ym(t))!Xm.call(e,i)&&i!==n&&Ql(e,i,{get:()=>t[i],enumerable:!(r=qm(t,i))||r.enumerable});return e};var Ir=(e,t,n)=>(n=e!=null?jm(Zm(e)):{},Qm(t||!e||!e.__esModule?Ql(n,"default",{value:e,enumerable:!0}):n,e));var Ra=Jl((sR,ol)=>{"use strict";var hr=typeof Reflect=="object"?Reflect:null,zp=hr&&typeof hr.apply=="function"?hr.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Sa;hr&&typeof hr.ownKeys=="function"?Sa=hr.ownKeys:Object.getOwnPropertySymbols?Sa=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Sa=function(t){return Object.getOwnPropertyNames(t)};function Yx(e){console&&console.warn&&console.warn(e)}var Wp=Number.isNaN||function(t){return t!==t};function de(){de.init.call(this)}ol.exports=de;ol.exports.once=Jx;de.EventEmitter=de;de.prototype._events=void 0;de.prototype._eventsCount=0;de.prototype._maxListeners=void 0;var Hp=10;function Ea(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(de,"defaultMaxListeners",{enumerable:!0,get:function(){return Hp},set:function(e){if(typeof e!="number"||e<0||Wp(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Hp=e}});de.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};de.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Wp(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 Up(e){return e._maxListeners===void 0?de.defaultMaxListeners:e._maxListeners}de.prototype.getMaxListeners=function(){return Up(this)};de.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=a[t];if(l===void 0)return!1;if(typeof l=="function")zp(l,this,n);else for(var c=l.length,u=qp(l,c),r=0;r<c;++r)zp(u[r],this,n);return!0};function Bp(e,t,n,r){var i,a,o;if(Ea(n),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]),o===void 0)o=a[t]=n,++e._eventsCount;else if(typeof o=="function"?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),i=Up(e),i>0&&o.length>i&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,Yx(s)}return e}de.prototype.addListener=function(t,n){return Bp(this,t,n,!1)};de.prototype.on=de.prototype.addListener;de.prototype.prependListener=function(t,n){return Bp(this,t,n,!0)};function Zx(){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 Kp(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=Zx.bind(r);return i.listener=n,r.wrapFn=i,i}de.prototype.once=function(t,n){return Ea(n),this.on(t,Kp(this,t,n)),this};de.prototype.prependOnceListener=function(t,n){return Ea(n),this.prependListener(t,Kp(this,t,n)),this};de.prototype.removeListener=function(t,n){var r,i,a,o,s;if(Ea(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(a=-1,o=r.length-1;o>=0;o--)if(r[o]===n||r[o].listener===n){s=r[o].listener,a=o;break}if(a<0)return this;a===0?r.shift():Xx(r,a),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};de.prototype.off=de.prototype.removeListener;de.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 a=Object.keys(r),o;for(i=0;i<a.length;++i)o=a[i],o!=="removeListener"&&this.removeAllListeners(o);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 Vp(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?Qx(i):qp(i,i.length)}de.prototype.listeners=function(t){return Vp(this,t,!0)};de.prototype.rawListeners=function(t){return Vp(this,t,!1)};de.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):jp.call(e,t)};de.prototype.listenerCount=jp;function jp(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}de.prototype.eventNames=function(){return this._eventsCount>0?Sa(this._events):[]};function qp(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function Xx(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Qx(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Jx(e,t){return new Promise(function(n,r){function i(o){e.removeListener(t,a),r(o)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}Yp(e,t,a,{once:!0}),t!=="error"&&ek(e,i,{once:!0})})}function ek(e,t,n){typeof e.on=="function"&&Yp(e,"error",t,n)}function Yp(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var sl=Jl((uR,Xp)=>{"use strict";Xp.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Fi,le,ic,Jm,an,ec,ac,oc,po,Pi,Mr,sc,mo,fo,go,ev,Mi={},Gi=[],tv=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$i=Array.isArray;function Ht(e,t){for(var n in t)e[n]=t[n];return e}function vo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function nv(e,t,n){var r,i,a,o={};for(a in t)a=="key"?r=t[a]:a=="ref"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Fi.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Di(e,o,r,i,null)}function Di(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ic,__i:-1,__u:0};return i==null&&le.vnode!=null&&le.vnode(a),a}function be(e){return e.children}function Ii(e,t){this.props=e,this.context=t}function kn(e,t){if(t==null)return e.__?kn(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"?kn(e):null}function rv(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ht({},t);a.__v=t.__v+1,le.vnode&&le.vnode(a),wo(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??kn(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,hc(r,a,i),t.__e=t.__=null,a.__e!=n&&lc(a)}}function lc(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}),lc(e)}function tc(e){(!e.__d&&(e.__d=!0)&&an.push(e)&&!Oi.__r++||ec!=le.debounceRendering)&&((ec=le.debounceRendering)||ac)(Oi)}function Oi(){try{for(var e,t=1;an.length;)an.length>t&&an.sort(oc),e=an.shift(),t=an.length,rv(e)}finally{an.length=Oi.__r=0}}function cc(e,t,n,r,i,a,o,s,l,c,u){var d,h,f,g,w,v,y=r&&r.__k||Gi,b=t.length;for(l=iv(n,t,y,l,b),d=0;d<b;d++)(f=n.__k[d])!=null&&(h=f.__i!=-1&&y[f.__i]||Mi,f.__i=d,v=wo(e,f,h,i,a,o,s,l,c,u),g=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&yo(h.ref,null,f),u.push(f.ref,f.__c||g,f)),w==null&&g!=null&&(w=g),4&f.__u?(l=uc(f,l,e),h.__e&&(h.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=w,l}function iv(e,t,n,r,i){var a,o,s,l,c,u=n.length,d=u,h=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=e.__k[a]=Di(null,o,null,null,null):$i(o)?o=e.__k[a]=Di(be,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Di(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,l=a+h,o.__=e,o.__b=e.__b+1,s=null,(c=o.__i=av(o,n,l,d))!=-1&&(d--,(s=n[c])&&(s.__u|=2)),s==null||s.__v==null?(c==-1&&(i>u?h--:i<u&&h++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=kn(s)),fc(s,s));return r}function uc(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=uc(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=kn(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function av(e,t,n,r){var i,a,o,s=e.key,l=e.type,c=t[n],u=c!=null&&(2&c.__u)==0;if(c===null&&s==null||u&&s==c.key&&l==c.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((c=t[o=i>=0?i--:a++])!=null&&(2&c.__u)==0&&s==c.key&&l==c.type)return o}return-1}function nc(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||tv.test(t)?n:n+"px"}function Ni(e,t,n,r,i){var a,o;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||nc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||nc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(sc,"$1")),o=t.toLowerCase(),t=o in e||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[Mr]=r[Mr]:(n[Mr]=mo,e.addEventListener(t,a?go:fo,a)):e.removeEventListener(t,a?go:fo,a);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 rc(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Pi]==null)t[Pi]=mo++;else if(t[Pi]<n[Mr])return;return n(le.event?le.event(t):t)}}}function wo(e,t,n,r,i,a,o,s,l,c){var u,d,h,f,g,w,v,y,b,_,x,C,O,N,j,P,R=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=le.__b)&&u(t);e:if(typeof R=="function"){d=o.length;try{if(b=t.props,_=R.prototype&&R.prototype.render,x=(u=R.contextType)&&r[u.__c],C=u?x?x.props.value:u.__:r,n.__c?y=(h=t.__c=n.__c).__=h.__E:(_?t.__c=h=new R(b,C):(t.__c=h=new Ii(b,C),h.constructor=R,h.render=sv),x&&x.sub(h),h.state||(h.state={}),h.__n=r,f=h.__d=!0,h.__h=[],h._sb=[]),_&&h.__s==null&&(h.__s=h.state),_&&R.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Ht({},h.__s)),Ht(h.__s,R.getDerivedStateFromProps(b,h.__s))),g=h.props,w=h.state,h.__v=t,f)_&&R.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),_&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(_&&R.getDerivedStateFromProps==null&&b!==g&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(b,C),t.__v==n.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(b,h.__s,C)===!1){t.__v!=n.__v&&(h.props=b,h.state=h.__s,h.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(H){H&&(H.__=t)}),Gi.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h),s=kn(n);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(b,h.__s,C),_&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(g,w,v)})}if(h.context=C,h.props=b,h.__P=e,h.__e=!1,O=le.__r,N=0,_)h.state=h.__s,h.__d=!1,O&&O(t),u=h.render(h.props,h.state,h.context),Gi.push.apply(h.__h,h._sb),h._sb=[];else do h.__d=!1,O&&O(t),u=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++N<25);h.state=h.__s,h.getChildContext!=null&&(r=Ht(Ht({},r),h.getChildContext())),_&&!f&&h.getSnapshotBeforeUpdate!=null&&(v=h.getSnapshotBeforeUpdate(g,w)),j=u!=null&&u.type===be&&u.key==null?pc(u.props.children):u,s=cc(e,$i(j)?j:[j],t,n,r,i,a,o,s,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),y&&(h.__E=h.__=null)}catch(H){if(o.length=d,t.__v=null,l||a!=null){if(H.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(P=a.length;P--;)vo(a[P])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),H.then||dc(t),le.__e(H,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=ov(n.__e,t,n,r,i,a,o,l,c);return(u=le.diffed)&&u(t),128&t.__u?void 0:s}function dc(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(dc))}function hc(e,t,n){for(var r=0;r<n.length;r++)yo(n[r],n[++r],n[++r]);le.__c&&le.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){le.__e(a,i.__v)}})}function pc(e){return typeof e!="object"||e==null||e.__b>0?e:$i(e)?e.map(pc):e.constructor!==void 0?null:Ht({},e)}function ov(e,t,n,r,i,a,o,s,l){var c,u,d,h,f,g,w,v=n.props||Mi,y=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"),a!=null){for(c=0;c<a.length;c++)if((f=a[c])&&"setAttribute"in f==!!b&&(b?f.localName==b:f.nodeType==3)){e=f,a[c]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&(le.__m&&le.__m(t,a),s=!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a=b=="textarea"&&y.defaultValue!=null?null:a&&Fi.call(e.childNodes),!s&&a!=null)for(v={},c=0;c<e.attributes.length;c++)v[(f=e.attributes[c]).name]=f.value;for(c in v)f=v[c],c=="dangerouslySetInnerHTML"?d=f:c=="children"||c in y||c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y||Ni(e,c,null,f,i);for(c in y)f=y[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?u=f:c=="value"?g=f:c=="checked"?w=f:s&&typeof f!="function"||v[c]===f||Ni(e,c,f,v[c],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),cc(t.type=="template"?e.content:e,$i(h)?h:[h],t,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,o,a?a[0]:n.__k&&kn(n,0),s,l),a!=null)for(c=a.length;c--;)vo(a[c]);s&&b!="textarea"||(c="value",b=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[c]||b=="progress"&&!g||b=="option"&&g!=v[c])&&Ni(e,c,g,v[c],i),c="checked",w!=null&&w!=e[c]&&Ni(e,c,w,v[c],i))}return e}function yo(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){le.__e(i,n)}}function fc(e,t,n){var r,i;if(le.unmount&&le.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||yo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){le.__e(a,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&fc(r[i],t,n||typeof e.type!="function");n||vo(e.__e),e.__c=e.__=e.__e=void 0}function sv(e,t,n){return this.constructor(e,n)}function gc(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),le.__&&le.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,a=[],o=[],wo(t,e=(!r&&n||t).__k=nv(be,null,[e]),i||Mi,Mi,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Fi.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),hc(a,e,o),e.props.children=null}Fi=Gi.slice,le={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},ic=0,Jm=function(e){return e!=null&&e.constructor===void 0},Ii.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ht({},this.state),typeof e=="function"&&(e=e(Ht({},n),this.props)),e&&Ht(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),tc(this))},Ii.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),tc(this))},Ii.prototype.render=be,an=[],ac=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,oc=function(e,t){return e.__v.__b-t.__v.__b},Oi.__r=0,po=Math.random().toString(8),Pi="__d"+po,Mr="__a"+po,sc=/(PointerCapture)$|Capture$/i,mo=0,fo=rc(!1),go=rc(!0),ev=0;var mc="weave-bootstrap";var bo={cwd:""};function lv(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function vc(e){if(e===null||e.trim()==="")return bo;let t;try{t=JSON.parse(e)}catch{return bo}return lv(t)?t:bo}var _n,ke,xo,wc,Gr=0,Ec=[],Re=le,yc=Re.__b,bc=Re.__r,xc=Re.diffed,kc=Re.__c,_c=Re.unmount,Tc=Re.__;function Or(e,t){Re.__h&&Re.__h(ke,e,Gr||t),Gr=0;var n=ke.__H||(ke.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function K(e){return Gr=1,cv(Ac,e)}function cv(e,t,n){var r=Or(_n++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ac(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,s);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=ke,!ke.__f)){var i=function(s,l,c){if(!r.__c.__H)return!0;var u=!1,d=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){u=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(d=!0)}}),a){var h=a.call(this,s,l,c);return u?h||d:h}return!u||d};ke.__f=!0;var a=ke.shouldComponentUpdate,o=ke.componentWillUpdate;ke.componentWillUpdate=function(s,l,c){if(this.__e){var u=a;a=void 0,i(s,l,c),a=u}o&&o.call(this,s,l,c)},ke.shouldComponentUpdate=i}return r.__N||r.__}function ne(e,t){var n=Or(_n++,3);!Re.__s&&To(n.__H,t)&&(n.__=e,n.u=t,ke.__H.__h.push(n))}function ze(e,t){var n=Or(_n++,4);!Re.__s&&To(n.__H,t)&&(n.__=e,n.u=t,ke.__h.push(n))}function V(e){return Gr=5,De(function(){return{current:e}},[])}function De(e,t){var n=Or(_n++,7);return To(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function _o(e,t){return Gr=8,De(function(){return e},t)}function Rc(){var e=Or(_n++,11);if(!e.__){for(var t=ke.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function uv(){for(var e;e=Ec.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(zi),t.__h.some(ko),t.__h=[]}catch(n){t.__h=[],Re.__e(n,e.__v)}}}Re.__b=function(e){ke=null,yc&&yc(e)},Re.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Tc&&Tc(e,t)},Re.__r=function(e){bc&&bc(e),_n=0;var t=(ke=e.__c).__H;t&&(xo===ke?(t.__h=[],ke.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(zi),t.__h.some(ko),t.__h=[],_n=0)),xo=ke},Re.diffed=function(e){xc&&xc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ec.push(t)!==1&&wc===Re.requestAnimationFrame||((wc=Re.requestAnimationFrame)||dv)(uv)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),xo=ke=null},Re.__c=function(e,t){t.some(function(n){try{n.__h.some(zi),n.__h=n.__h.filter(function(r){return!r.__||ko(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Re.__e(r,n.__v)}}),kc&&kc(e,t)},Re.unmount=function(e){_c&&_c(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{zi(r)}catch(i){t=i}}),n.__H=void 0,t&&Re.__e(t,n.__v))};var Sc=typeof requestAnimationFrame=="function";function dv(e){var t,n=function(){clearTimeout(r),Sc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Sc&&(t=requestAnimationFrame(n))}function zi(e){var t=ke,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ke=t}function ko(e){var t=ke;e.__c=e.__(),ke=t}function To(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Ac(e,t){return typeof t=="function"?t(e):t}var Cc={bg:"#eff1f5",panel:"#e6e9ef",page:"#ffffff",raise:"#ccd0da",fg:"#4c4f69",dim:"#56586a",faint:"#606274",line:"#ccd0da","line-strong":"#bcc0cc",accent:"#7113ec",ok:"#28641b",warn:"#7c4f10",bad:"#b20d30"},Lc={bg:"#24273a",panel:"#1e2030",page:"#181926",raise:"#363a4f",fg:"#cad3f5",dim:"#a5adcb",faint:"#939ab7",line:"#363a4f","line-strong":"#494d64",accent:"#c6a0f6",ok:"#a6da95",warn:"#eed49f",bad:"#ed8796"},ve={light:{name:"Catppuccin Latte · Mauve",scheme:"light",colors:Cc},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...Cc,accent:"#1750bf"}},"frappe-teal":{name:"Catppuccin Frappé · Teal",scheme:"dark",colors:{bg:"#303446",panel:"#292c3c",page:"#232634",raise:"#414559",fg:"#c6d0f5",dim:"#b5bfe2",faint:"#a5adce",line:"#414559","line-strong":"#51576d",accent:"#81c8be",ok:"#a6d189",warn:"#e5c890",bad:"#f4a4a6"}},dark:{name:"Catppuccin Macchiato · Mauve",scheme:"dark",colors:Lc},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...Lc,accent:"#f5a97f"}},"mocha-lavender":{name:"Catppuccin Mocha · Lavender",scheme:"dark",colors:{bg:"#1e1e2e",panel:"#181825",page:"#11111b",raise:"#313244",fg:"#cdd6f4",dim:"#a6adc8",faint:"#9399b2",line:"#313244","line-strong":"#45475a",accent:"#b4befe",ok:"#a6e3a1",warn:"#f9e2af",bad:"#f38ba8"}},"paper-blue":{name:"Paper · Blue",scheme:"light",colors:{bg:"#f4f6f8",panel:"#e9edf2",page:"#ffffff",raise:"#dce3eb",fg:"#182334",dim:"#42536a",faint:"#526176",line:"#dce3eb","line-strong":"#bac6d4",accent:"#174ea6",ok:"#21623b",warn:"#805300",bad:"#a3223c"}},"ink-blue":{name:"Ink · Blue",scheme:"dark",colors:{bg:"#1b2430",panel:"#141c27",page:"#101720",raise:"#2b3748",fg:"#edf2f8",dim:"#becadc",faint:"#a5b5cb",line:"#2b3748","line-strong":"#46566d",accent:"#8bbcff",ok:"#91d5a5",warn:"#edc47b",bad:"#ff9fae"}},"sand-amber":{name:"Sand · Amber",scheme:"light",colors:{bg:"#f7f3ec",panel:"#ede6da",page:"#fffdf8",raise:"#e2d8c8",fg:"#30291f",dim:"#5b4e3f",faint:"#675847",line:"#e2d8c8","line-strong":"#c7b8a2",accent:"#814500",ok:"#365c2a",warn:"#795000",bad:"#a12c32"}},"ember-amber":{name:"Ember · Amber",scheme:"dark",colors:{bg:"#29231f",panel:"#211c19",page:"#191512",raise:"#3c322b",fg:"#f3e9dc",dim:"#d0bfab",faint:"#bfa991",line:"#3c322b","line-strong":"#5c4d40",accent:"#edb96b",ok:"#b5cf8a",warn:"#efc57a",bad:"#f69a91"}},"mist-teal":{name:"Mist · Teal",scheme:"light",colors:{bg:"#eff5f3",panel:"#e1ece8",page:"#fafffd",raise:"#d2e2dc",fg:"#18342e",dim:"#3c5b52",faint:"#48655b",line:"#d2e2dc","line-strong":"#acc5bc",accent:"#006457",ok:"#2a5e35",warn:"#795300",bad:"#a52a43"}},"forest-teal":{name:"Forest · Teal",scheme:"dark",colors:{bg:"#1c2b27",panel:"#16221e",page:"#101b17",raise:"#2b4038",fg:"#e6f2ec",dim:"#b8d0c4",faint:"#a2bfb0",line:"#2b4038","line-strong":"#456255",accent:"#7cd8bb",ok:"#a5d6a0",warn:"#e6c582",bad:"#f5a2ac"}}},Nc=["system",...Object.keys(ve)];function Xn(e){return typeof e=="string"&&Nc.includes(e)}var Tn={mauve:{name:"Mauve",light:"#7113ec",dark:"#cba9f8"},blue:{name:"Blue",light:"#1750bf",dark:"#8bbcff"},teal:{name:"Teal",light:"#006457",dark:"#7cd8bb"},peach:{name:"Peach",light:"#814500",dark:"#f5a97f"},rose:{name:"Rose",light:"#a52a43",dark:"#f4a4a6"},green:{name:"Green",light:"#28641b",dark:"#a6da95"},amber:{name:"Amber",light:"#775000",dark:"#edb96b"},lavender:{name:"Lavender",light:"#445198",dark:"#b4befe"}};function Hi(e){return typeof e=="string"?e:e.theme}function Pc(e,t){return t==="theme"?ve[e].colors.accent:Tn[t][ve[e].scheme]}var at={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},on={...at};function So(e){Object.assign(at,e)}var Qn=[{key:"containsStrength",label:"Group cohesion",hint:"how hard a parent holds its children — group cohesion",min:0,max:1,step:.01},{key:"containsRest",label:"Group radius",hint:"how far children sit from their parent — rosette radius",min:10,max:300,step:5},{key:"relationStrength",label:"Link strength",hint:"pull of links-to / mentions across groups",min:0,max:1,step:.01},{key:"relationDistance",label:"Link distance",hint:"how long those cross-group springs are",min:20,max:600,step:10},{key:"charge",label:"Repulsion",hint:"node-to-node repulsion — more negative pushes harder",min:-1200,max:0,step:10},{key:"chargeMax",label:"Repulsion range",hint:"distance past which repulsion stops — caps overall spread",min:100,max:4e3,step:50},{key:"center",label:"Center gravity",hint:"pull toward the origin — too much makes one blob",min:0,max:.3,step:.005}],sn={lightTheme:"light",darkTheme:"dark",accent:"theme",fontSize:14,readable:!0,spellcheck:!0,defaultEdit:!1,startup:"restore",focusNewTabs:!0,groupColors:!0,forces:{...on}};function Dc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ic(e){if(!Dc(e))return null;let n=!Object.hasOwn(e,"lightTheme")&&!Object.hasOwn(e,"darkTheme")?{...e,lightTheme:"light",darkTheme:"dark"}:e;if(Object.keys(n).length!==Object.keys(sn).length)return null;for(let i of["light","dark"]){let a=n[`${i}Theme`];if(!Xn(a)||a==="system"||ve[a].scheme!==i)return null}if(n.accent!=="theme"&&(typeof n.accent!="string"||!Object.hasOwn(Tn,n.accent))||typeof n.fontSize!="number"||!Number.isInteger(n.fontSize)||n.fontSize<12||n.fontSize>22)return null;for(let i of["readable","spellcheck","defaultEdit","focusNewTabs","groupColors"])if(typeof n[i]!="boolean")return null;if(n.startup!=="restore"&&n.startup!=="empty")return null;let r=n.forces;if(!Dc(r)||Object.keys(r).length!==Qn.length)return null;for(let{key:i,min:a,max:o}of Qn){let s=r[i];if(typeof s!="number"||!Number.isFinite(s)||s<a||s>o)return null}return n}var Co=40,Mc=100,hv=1e9,Fr=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function Lo(){return{version:1,panes:[{id:"pane-1",tabs:[Fr("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,contextPinned:!1,treeWidth:240,contextWidth:240,contextGraphHeight:260,contextTagsHeight:180,theme:"system",preferences:sn}}function Sn(e){return e.panes.find(t=>t.id===e.activePane)}function En(e){let t=Sn(e);return t.tabs.find(n=>n.id===t.activeTab)}function Mt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function er(e,t){let n=new Set(e.panes.flatMap(i=>[i.id,...i.tabs.map(a=>a.id)])),r=1;for(;n.has(`${t}-${r}`);)r++;return`${t}-${r}`}function Rn(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?Ui({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function No(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function Ui(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??No(e);return r?{...n,lastDocumentTab:r.id}:n}function Bi(e){if(En(e).kind==="document")return e;let t=Sn(e),n=No(t);return n?Rn(e,t,n):ln(e,null,{newTab:!0})}function Ki(e,t,n){let r=e.panes.find(a=>a.id===t),i=r?.tabs.find(a=>a.id===n);return r&&i?{pane:r,tab:i}:null}function Ao(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=Co?e:Rn(e,{...t,tabs:[...t.tabs,n]},n)}function Eo(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>Mc&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function ln(e,t,n={}){let r=e.panes.find(s=>s.id===(n.paneId??e.activePane));if(!r)return e;let i=r.activeTab,a=r.tabs.find(s=>s.id===i);if(a?.kind==="graph"&&(a=No(r),a?r={...r,activeTab:a.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!a)return Ao(e,r,Eo(Fr(er(e,"tab")),t));let o=Eo(a,t);return o===a&&r.id===e.activePane&&i===a.id?e:Rn(e,r,o)}function Po(e){let t=e.panes.flatMap(r=>r.tabs.filter(i=>i.kind==="graph").map(i=>({pane:r,tab:i})))[0];if(t)return t.pane.id===e.activePane&&t.pane.activeTab===t.tab.id?e:Rn(e,t.pane,t.tab);let n=Sn(e);return Ao(e,n,{id:er(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function Do(e,t,n){let r=Ki(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:Rn(e,r.pane,r.tab)}function Io(e,t,n){let r=Ki(e,t,n);if(!r)return e;let{pane:i}=r;if(i.tabs.length===1){let c=e.panes.find(d=>d.id!==t);if(c)return{...e,panes:[c],activePane:c.id};let u=Fr(er(e,"tab"));return Rn(e,{...i,tabs:[u]},u)}let a=i.tabs.filter(c=>c.id!==n),o=i.activeTab===n,s=a[Math.max(0,i.tabs.findIndex(c=>c.id===n)-1)],l=Ui({...i,tabs:a,activeTab:o?s.id:i.activeTab});return{...e,activePane:o?t:e.activePane,panes:e.panes.map(c=>c.id===t?l:c)}}function Mo(e,t,n){let r=e.panes.find(o=>o.id===t),i=r?.tabs.find(o=>o.id===r.activeTab);if(!r||!i||i.kind!=="document")return e;let a=i.cursor+n;return a<0||a>=i.history.length?e:Rn(e,r,{...i,cursor:a,scroll:0})}function Go(e,t){if(e.panes.length===2)return e.split===t?e:{...e,split:t};let n=tr(e,e.activePane,En(e).id);return n===e?e:{...n,split:t}}function Gc(e,t){if(e.panes.length!==2||!e.panes.some(i=>i.id===t))return e;let n=e.panes.find(i=>i.id===t),r=e.panes.find(i=>i.id!==t);return{...e,panes:[{...r,tabs:[...r.tabs,...n.tabs]}],activePane:r.id}}function Oo(e,t,n,r){let i=Ki(e,t,n);if(!i||r===n||r!==null&&!i.pane.tabs.some(o=>o.id===r))return e;let a=i.pane.tabs.filter(o=>o.id!==n);return a.splice(r===null?a.length:a.findIndex(o=>o.id===r),0,i.tab),a.every((o,s)=>o===i.pane.tabs[s])?e:{...e,panes:e.panes.map(o=>o.id===t?{...o,tabs:a}:o)}}function Vi(e,t,n){return e.panes.some(r=>r.id===t)?e.panes.find(r=>r.id!==t&&r.tabs.some(i=>i.id===n))?.id??null:null}function tr(e,t,n){let r=Ki(e,t,n);if(!r)return e;let i=e.panes.find(u=>u.id!==t)??{id:er(e,"pane"),tabs:[],activeTab:""},a=r.pane.tabs.filter(u=>u.id!==n),o=Ui({...i,tabs:[...i.tabs,r.tab],activeTab:r.tab.id});if(!a.length&&e.panes.length===2)return{...e,panes:[o],activePane:i.id};if(!a.length&&e.panes.reduce((u,d)=>u+d.tabs.length,0)>=Co)return e;let s=a.length?null:Fr(er(e,"tab")),l=a.length?a:[s],c=Ui({...r.pane,tabs:l,activeTab:r.pane.activeTab===n?l[Math.max(0,r.pane.tabs.findIndex(u=>u.id===n)-1)].id:r.pane.activeTab});return{...e,activePane:i.id,panes:e.panes.length===1?[c,o]:e.panes.map(u=>u.id===c.id?c:o)}}function Ro(e,t){return Object.keys(e).length===t.length&&t.every(n=>Object.hasOwn(e,n))}function Wi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jn(e,t){return typeof e=="string"&&e.length<=2048&&(t===void 0?e.length>0&&!/[\u0000-\u001f\u007f]/.test(e):new RegExp(`^${t}-[1-9][0-9]{0,8}$`).test(e))}function Oc(e){if(!Wi(e)||!Ro(e,["version","panes","activePane","split","ratio","treeVisible","contextVisible","treeWidth","contextWidth","theme",...["preferences","contextGraphHeight","contextTagsHeight","contextPinned"].filter(u=>Object.hasOwn(e,u))])||e.version!==1||!Array.isArray(e.panes)||e.panes.length<1||e.panes.length>2||!Jn(e.activePane,"pane")||e.split!=="right"&&e.split!=="down"||typeof e.ratio!="number"||!Number.isFinite(e.ratio)||e.ratio<.1||e.ratio>.9||typeof e.treeVisible!="boolean"||typeof e.contextVisible!="boolean")return null;let t=Object.hasOwn(e,"contextPinned")?e.contextPinned:!1;if(typeof t!="boolean"||typeof e.treeWidth!="number"||!Number.isFinite(e.treeWidth)||e.treeWidth<120||e.treeWidth>800||typeof e.contextWidth!="number"||!Number.isFinite(e.contextWidth)||e.contextWidth<120||e.contextWidth>800)return null;let n=Object.hasOwn(e,"contextGraphHeight")?e.contextGraphHeight:260,r=Object.hasOwn(e,"contextTagsHeight")?e.contextTagsHeight:180;if(typeof n!="number"||!Number.isFinite(n)||n<120||n>800||typeof r!="number"||!Number.isFinite(r)||r<60||r>600||!Xn(e.theme))return null;let i=Object.hasOwn(e,"preferences")?Ic(e.preferences):sn;if(i===null)return null;let a=e.preferences;e.theme!=="system"&&(!Wi(a)||!Object.hasOwn(a,"lightTheme"))&&(i={...i,[`${ve[e.theme].scheme}Theme`]:e.theme});let o=new Set,s=0,l=0,c=[];for(let u of e.panes){if(!Wi(u)||!Ro(u,Object.hasOwn(u,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!Jn(u.id,"pane")||!Array.isArray(u.tabs)||u.tabs.length<1||!Jn(u.activeTab,"tab")||o.has(u.id))return null;o.add(u.id);let d=[],h=!1;for(let g of u.tabs){if(!Wi(g)||!Ro(g,["id","kind","history","cursor","scroll"])||!Jn(g.id,"tab")||o.has(g.id)||(o.add(g.id),g.kind!=="document"&&g.kind!=="graph"))return null;let w=g.kind;if(!Array.isArray(g.history)||g.history.length<1||g.history.length>Mc||!Number.isInteger(g.cursor)||g.cursor<0||g.cursor>=g.history.length||g.history.some(v=>v!==null&&!Jn(v))||typeof g.scroll!="number"||!Number.isFinite(g.scroll)||g.scroll<0||g.scroll>hv)return null;w==="graph"&&l++,s++,g.id===u.activeTab&&(h=!0),d.push({id:g.id,kind:w,history:g.history,cursor:g.cursor,scroll:g.scroll})}if(!h)return null;let f=u.lastDocumentTab;if(Object.hasOwn(u,"lastDocumentTab")&&(!Jn(f,"tab")||!d.some(g=>g.id===f&&g.kind==="document")))return null;c.push({id:u.id,tabs:d,activeTab:u.activeTab,...typeof f=="string"?{lastDocumentTab:f}:{}})}return s>Co||l>1||!c.some(u=>u.id===e.activePane)?null:{version:1,panes:c,activePane:e.activePane,split:e.split,ratio:e.ratio,treeVisible:e.treeVisible,contextVisible:e.contextVisible,contextPinned:t,treeWidth:e.treeWidth,contextWidth:e.contextWidth,contextGraphHeight:n,contextTagsHeight:r,theme:e.theme,preferences:i}}function Fc(e){if(e.preferences.startup==="restore")return e;let t=Lo();return{...e,panes:t.panes,activePane:t.activePane}}function $c(e,t,n={}){let r=ln(e,t,n);return!n.newTab||e.preferences.focusNewTabs?r:{...r,activePane:e.activePane,panes:r.panes.map(i=>{let a=e.panes.find(l=>l.id===i.id),{lastDocumentTab:o,...s}=i;return{...s,activeTab:a.activeTab,...a.lastDocumentTab?{lastDocumentTab:a.lastDocumentTab}:{}}})}}var _e=(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},...t?.signal===void 0?{}:{signal:t.signal},credentials:"same-origin"});function ji(e,t=!1){return{ok:!0,data:e,cached:t}}function Gt(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function zc(e){return e===403?"auth":e===404?"missing":"server"}function Hc(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(o){return Gt("network",0,o instanceof Error?o.message:"network request failed")}if(!i.ok)return Gt(zc(i.status),i.status,Hc(i.status));let a;try{a=await i.json()}catch{return Gt("malformed",i.status,"response was not valid JSON")}return n(a)?ji(a):Gt("malformed",i.status,"response did not match the expected shape")}function ot(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wc(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function pv(e){if(!ot(e)||typeof e.stamp!="string")return!1;let t=e.model;return!ot(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:ot(e.tags)&&ot(e.dangling)}function fv(e){if(!ot(e)||typeof e.stamp!="string"||typeof e.turn!="number")return!1;let t=e.events;return Array.isArray(t)&&t.every(n=>ot(n)&&typeof n.seq=="number"&&typeof n.turn=="number"&&typeof n.at=="string"&&(n.kind==="searched"||n.kind==="read"||n.kind==="wrote")&&typeof n.action=="string"&&Wc(n.slugs)&&(n.query===void 0||typeof n.query=="string"))}function gv(e){if(!ot(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return Wc(e.tags)}function Uc(e){return ot(e)&&gv(e.note)}function mv(e){return ot(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function vv(e){return ot(e)&&typeof e.opened=="boolean"}var wv=new Set(["human","agent","outside","system"]),yv=e=>Number.isInteger(e)&&e>=0;function bv(e){if(!ot(e)||typeof e.slug!="string"||typeof e.enabled!="boolean"||typeof e.trimmed!="boolean")return!1;let t=e.revisions;return Array.isArray(t)&&t.every(n=>{if(!ot(n)||typeof n.at!="string"||!wv.has(n.by)||typeof n.op!="string")return!1;if(typeof n.full=="string")return!0;let r=n.keep;return Array.isArray(r)&&r.length===2&&r.every(yv)&&typeof n.text=="string"})}function xv(e){let t=[],n=null;for(let{at:r,by:i,op:a,full:o,keep:s,text:l}of e.revisions){if(o!==void 0)n=o;else{let[c,u]=s;if(n===null||c+u>n.length)return null;n=n.slice(0,c)+l+n.slice(n.length-u)}t.push({at:r,by:i,op:a,body:n})}return{slug:e.slug,enabled:e.enabled,trimmed:e.trimmed,revisions:t}}function kv(e){return ot(e)&&typeof e.enabled=="boolean"}function _v(e){return ot(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}function qi(e,t=null){return Kc(e,"/api/graph",t,pv)}function Bc(e,t=null){return Kc(e,"/api/trail",t,fv)}async function Kc(e,t,n,r){let i=n===null?void 0:{"if-none-match":`"${n.stamp}"`},a;try{a=await e(t,i===void 0?{}:{headers:i})}catch(s){return Gt("network",0,s instanceof Error?s.message:"network request failed")}if(a.status===304)return n===null?Gt("malformed",304,"server sent 304 for an unconditional request"):ji(n,!0);if(!a.ok)return Gt(zc(a.status),a.status,Hc(a.status));let o;try{o=await a.json()}catch{return Gt("malformed",a.status,"response was not valid JSON")}return r(o)?ji(o):Gt("malformed",a.status,"response did not match the expected shape")}function Fo(e,t){return An(e,`/api/note/${encodeURIComponent(t)}`,Uc)}function Vc(e,t,n){return An(e,`/api/search?q=${encodeURIComponent(t)}`,mv,n===void 0?void 0:{signal:n})}function jc(e,t){return An(e,"/api/open",vv,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function qc(e,t){return An(e,"/api/notes",Uc,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})}function Cn(e,t,n,r){return An(e,t,_v,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var Yi=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,$o=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,Yc=(e,t,n,r=!1)=>Cn(e,Yi(t),"POST",r?{body:n,raw:!0}:{body:n}),Zc=(e,t,n)=>Cn(e,Yi(t,"/rename"),"POST",{name:n}),Xc=(e,t,n)=>Cn(e,Yi(t,"/move"),"POST",{folder:n}),Qc=(e,t)=>Cn(e,Yi(t),"DELETE"),Jc=(e,t)=>Cn(e,$o(t),"POST"),eu=(e,t,n)=>Cn(e,$o(t,"/rename"),"POST",{name:n}),tu=(e,t)=>Cn(e,$o(t),"DELETE");async function nu(e,t){let n=await An(e,`/api/history/${encodeURIComponent(t)}`,bv);if(!n.ok)return n;let r=xv(n.data);return r===null?Gt("malformed",200,"history did not fit together"):ji(r,n.cached)}function zo(e,t){return An(e,"/api/history-settings",kv,t===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:t})})}function pt(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 Tv(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 c=n.get(l.source);c?c.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let c=r.get(l.source);c?c.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let a=l=>{if(!l.detail.path)return null;let c=l.detail.path,u=null,d=0,h=n.get("repository")??[];for(let f of h){let g=t.get(f);if(g&&g.kind==="module"&&g.detail.path){let w=g.detail.path;c.startsWith(w+"/")&&w.length>d&&(u=f,d=w.length)}}return u},o=new Map;for(let l of e.nodes){if(l.kind!=="entryPoint")continue;let c=a(l);if(c){let u=o.get(c);u?u.push(l.id):o.set(c,[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:o,roots:s}}function au(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 Sv(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function ru(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function Ev(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),a=t.get(r),o=ru(i),s=ru(a);if(o!==s)return o?-1:1;let l=pt(i),c=pt(a);return l.localeCompare(c)})}function iu(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 Rv(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?iu(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?iu(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 Ho(e,t){let n=Tv(e),{byId:r,tree:i,moduleEntries:a,roots:o}=n,s=g=>{let y=(i.get(g)??[]).filter(b=>{let _=r.get(b);if(!_||_.kind!=="entryPoint")return!0;for(let[,x]of a)if(x.includes(b))return!1;return!0}).concat(a.get(g)??[]);return y=y.filter(b=>r.has(b)),t.showInternals||(y=y.filter(b=>{let _=r.get(b);return!(_&&Sv(_.kind))})),Ev(y,r)},l=t.provFilter!==null||t.query.length>0,c=g=>!(t.provFilter!==null&&g.provenance!==t.provFilter||t.query.length>0&&!pt(g).toLowerCase().includes(t.query.toLowerCase())),u=new Set,d=g=>{let w=r.get(g),v=!1;for(let b of s(g))d(b)&&(v=!0);let y=c(w)||v;return y&&u.add(g),y};for(let g of o)d(g);let h=[],f=(g,w)=>{if(!u.has(g))return;let v=r.get(g),y=s(g),b=y.filter(x=>u.has(x)),_=l?b.length>0:t.expanded.has(g);if(h.push({id:g,depth:w,hasKids:y.length>0,expanded:_,label:pt(v),kind:v.kind,provenance:v.provenance,meta:Rv(v)}),_)for(let x of b)f(x,w+1)};for(let g of o)f(g,0);return h}function Wo(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 Wt(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 a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);if(o<30)return`${o}d ago`;let s=Math.floor(o/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var Av=7;function Uo(e,t){if(e===null)return"";switch(e.kind){case"relTime":return Wt(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,Av);case"text":return e.text}}var Cv="## Raw",Lv=/^[ \t]*(`{3,}|~{3,})(.*)$/gm,Nv=new RegExp(`^${Cv}[ \\t]*\\r?$`,"m");function ou(e){let t=[],n=null;for(let r of e.matchAll(Lv)){let i=r[1],a=r[2];n===null?n={at:r.index,marker:i[0],length:i.length}:i[0]===n.marker&&i.length>=n.length&&a.trim()===""&&(t.push([n.at,r.index+r[0].length]),n=null)}return n!==null&&t.push([n.at,e.length]),t}function su(e,t){let n=0;for(;;){let r=e.slice(n),i=Nv.exec(r);if(i===null)return e.length;let a=n+i.index,o=t.find(([s,l])=>a>=s&&a<l);if(o===void 0)return a;n=o[1]}}var Pv=/(?:^|\n)-{3,}[ \t]*\r?\n\s*$/;function Dv(e){let t=su(e,ou(e));if(t===e.length)return t;let n=Pv.exec(e.slice(0,t));return n===null?t:n.index===0&&!e.startsWith(`
22
- `)?0:n.index+1}function nr(e){let t=Dv(e);return{head:e.slice(0,t).trimEnd(),tail:e.slice(t).trimEnd()}}function Bo(e,t){return t===""?e:e===""?t:`${e}
21
+ "use strict";(()=>{var Qm=Object.create;var ec=Object.defineProperty;var Jm=Object.getOwnPropertyDescriptor;var ev=Object.getOwnPropertyNames;var tv=Object.getPrototypeOf,nv=Object.prototype.hasOwnProperty;var tc=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var rv=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ev(t))!nv.call(e,i)&&i!==n&&ec(e,i,{get:()=>t[i],enumerable:!(r=Jm(t,i))||r.enumerable});return e};var Ir=(e,t,n)=>(n=e!=null?Qm(tv(e)):{},rv(t||!e||!e.__esModule?ec(n,"default",{value:e,enumerable:!0}):n,e));var Ra=tc((hR,ll)=>{"use strict";var hr=typeof Reflect=="object"?Reflect:null,Kp=hr&&typeof hr.apply=="function"?hr.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Sa;hr&&typeof hr.ownKeys=="function"?Sa=hr.ownKeys:Object.getOwnPropertySymbols?Sa=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Sa=function(t){return Object.getOwnPropertyNames(t)};function ek(e){console&&console.warn&&console.warn(e)}var jp=Number.isNaN||function(t){return t!==t};function de(){de.init.call(this)}ll.exports=de;ll.exports.once=ik;de.EventEmitter=de;de.prototype._events=void 0;de.prototype._eventsCount=0;de.prototype._maxListeners=void 0;var Vp=10;function Ea(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(de,"defaultMaxListeners",{enumerable:!0,get:function(){return Vp},set:function(e){if(typeof e!="number"||e<0||jp(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Vp=e}});de.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};de.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||jp(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 qp(e){return e._maxListeners===void 0?de.defaultMaxListeners:e._maxListeners}de.prototype.getMaxListeners=function(){return qp(this)};de.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=a[t];if(l===void 0)return!1;if(typeof l=="function")Kp(l,this,n);else for(var c=l.length,u=Jp(l,c),r=0;r<c;++r)Kp(u[r],this,n);return!0};function Yp(e,t,n,r){var i,a,o;if(Ea(n),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]),o===void 0)o=a[t]=n,++e._eventsCount;else if(typeof o=="function"?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),i=qp(e),i>0&&o.length>i&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=o.length,ek(s)}return e}de.prototype.addListener=function(t,n){return Yp(this,t,n,!1)};de.prototype.on=de.prototype.addListener;de.prototype.prependListener=function(t,n){return Yp(this,t,n,!0)};function tk(){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 Zp(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=tk.bind(r);return i.listener=n,r.wrapFn=i,i}de.prototype.once=function(t,n){return Ea(n),this.on(t,Zp(this,t,n)),this};de.prototype.prependOnceListener=function(t,n){return Ea(n),this.prependListener(t,Zp(this,t,n)),this};de.prototype.removeListener=function(t,n){var r,i,a,o,s;if(Ea(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(a=-1,o=r.length-1;o>=0;o--)if(r[o]===n||r[o].listener===n){s=r[o].listener,a=o;break}if(a<0)return this;a===0?r.shift():nk(r,a),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};de.prototype.off=de.prototype.removeListener;de.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 a=Object.keys(r),o;for(i=0;i<a.length;++i)o=a[i],o!=="removeListener"&&this.removeAllListeners(o);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 Xp(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?rk(i):Jp(i,i.length)}de.prototype.listeners=function(t){return Xp(this,t,!0)};de.prototype.rawListeners=function(t){return Xp(this,t,!1)};de.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Qp.call(e,t)};de.prototype.listenerCount=Qp;function Qp(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}de.prototype.eventNames=function(){return this._eventsCount>0?Sa(this._events):[]};function Jp(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function nk(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function rk(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function ik(e,t){return new Promise(function(n,r){function i(o){e.removeListener(t,a),r(o)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}ef(e,t,a,{once:!0}),t!=="error"&&ak(e,i,{once:!0})})}function ak(e,t,n){typeof e.on=="function"&&ef(e,"error",t,n)}function ef(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var cl=tc((gR,nf)=>{"use strict";nf.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Fi,le,oc,iv,on,nc,sc,lc,po,Pi,Mr,cc,mo,fo,go,av,Mi={},Gi=[],ov=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,$i=Array.isArray;function Wt(e,t){for(var n in t)e[n]=t[n];return e}function vo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function sv(e,t,n){var r,i,a,o={};for(a in t)a=="key"?r=t[a]:a=="ref"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Fi.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Di(e,o,r,i,null)}function Di(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++oc,__i:-1,__u:0};return i==null&&le.vnode!=null&&le.vnode(a),a}function xe(e){return e.children}function Ii(e,t){this.props=e,this.context=t}function _n(e,t){if(t==null)return e.__?_n(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"?_n(e):null}function lv(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Wt({},t);a.__v=t.__v+1,le.vnode&&le.vnode(a),wo(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??_n(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,fc(r,a,i),t.__e=t.__=null,a.__e!=n&&uc(a)}}function uc(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}),uc(e)}function rc(e){(!e.__d&&(e.__d=!0)&&on.push(e)&&!Oi.__r++||nc!=le.debounceRendering)&&((nc=le.debounceRendering)||sc)(Oi)}function Oi(){try{for(var e,t=1;on.length;)on.length>t&&on.sort(lc),e=on.shift(),t=on.length,lv(e)}finally{on.length=Oi.__r=0}}function dc(e,t,n,r,i,a,o,s,l,c,u){var d,h,f,g,w,v,y=r&&r.__k||Gi,b=t.length;for(l=cv(n,t,y,l,b),d=0;d<b;d++)(f=n.__k[d])!=null&&(h=f.__i!=-1&&y[f.__i]||Mi,f.__i=d,v=wo(e,f,h,i,a,o,s,l,c,u),g=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&yo(h.ref,null,f),u.push(f.ref,f.__c||g,f)),w==null&&g!=null&&(w=g),4&f.__u?(l=hc(f,l,e),h.__e&&(h.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=w,l}function cv(e,t,n,r,i){var a,o,s,l,c,u=n.length,d=u,h=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=e.__k[a]=Di(null,o,null,null,null):$i(o)?o=e.__k[a]=Di(xe,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Di(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,l=a+h,o.__=e,o.__b=e.__b+1,s=null,(c=o.__i=uv(o,n,l,d))!=-1&&(d--,(s=n[c])&&(s.__u|=2)),s==null||s.__v==null?(c==-1&&(i>u?h--:i<u&&h++),typeof o.type!="function"&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=_n(s)),mc(s,s));return r}function hc(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=hc(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=_n(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function uv(e,t,n,r){var i,a,o,s=e.key,l=e.type,c=t[n],u=c!=null&&(2&c.__u)==0;if(c===null&&s==null||u&&s==c.key&&l==c.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((c=t[o=i>=0?i--:a++])!=null&&(2&c.__u)==0&&s==c.key&&l==c.type)return o}return-1}function ic(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||ov.test(t)?n:n+"px"}function Ni(e,t,n,r,i){var a,o;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||ic(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||ic(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(cc,"$1")),o=t.toLowerCase(),t=o in e||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n[Mr]=r[Mr]:(n[Mr]=mo,e.addEventListener(t,a?go:fo,a)):e.removeEventListener(t,a?go:fo,a);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 ac(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Pi]==null)t[Pi]=mo++;else if(t[Pi]<n[Mr])return;return n(le.event?le.event(t):t)}}}function wo(e,t,n,r,i,a,o,s,l,c){var u,d,h,f,g,w,v,y,b,_,x,R,O,N,j,P,A=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=le.__b)&&u(t);e:if(typeof A=="function"){d=o.length;try{if(b=t.props,_=A.prototype&&A.prototype.render,x=(u=A.contextType)&&r[u.__c],R=u?x?x.props.value:u.__:r,n.__c?y=(h=t.__c=n.__c).__=h.__E:(_?t.__c=h=new A(b,R):(t.__c=h=new Ii(b,R),h.constructor=A,h.render=hv),x&&x.sub(h),h.state||(h.state={}),h.__n=r,f=h.__d=!0,h.__h=[],h._sb=[]),_&&h.__s==null&&(h.__s=h.state),_&&A.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Wt({},h.__s)),Wt(h.__s,A.getDerivedStateFromProps(b,h.__s))),g=h.props,w=h.state,h.__v=t,f)_&&A.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),_&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(_&&A.getDerivedStateFromProps==null&&b!==g&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(b,R),t.__v==n.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(b,h.__s,R)===!1){t.__v!=n.__v&&(h.props=b,h.state=h.__s,h.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(H){H&&(H.__=t)}),Gi.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h),s=_n(n);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(b,h.__s,R),_&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(g,w,v)})}if(h.context=R,h.props=b,h.__P=e,h.__e=!1,O=le.__r,N=0,_)h.state=h.__s,h.__d=!1,O&&O(t),u=h.render(h.props,h.state,h.context),Gi.push.apply(h.__h,h._sb),h._sb=[];else do h.__d=!1,O&&O(t),u=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++N<25);h.state=h.__s,h.getChildContext!=null&&(r=Wt(Wt({},r),h.getChildContext())),_&&!f&&h.getSnapshotBeforeUpdate!=null&&(v=h.getSnapshotBeforeUpdate(g,w)),j=u!=null&&u.type===xe&&u.key==null?gc(u.props.children):u,s=dc(e,$i(j)?j:[j],t,n,r,i,a,o,s,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),y&&(h.__E=h.__=null)}catch(H){if(o.length=d,t.__v=null,l||a!=null){if(H.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(P=a.length;P--;)vo(a[P])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),H.then||pc(t),le.__e(H,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=dv(n.__e,t,n,r,i,a,o,l,c);return(u=le.diffed)&&u(t),128&t.__u?void 0:s}function pc(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(pc))}function fc(e,t,n){for(var r=0;r<n.length;r++)yo(n[r],n[++r],n[++r]);le.__c&&le.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){le.__e(a,i.__v)}})}function gc(e){return typeof e!="object"||e==null||e.__b>0?e:$i(e)?e.map(gc):e.constructor!==void 0?null:Wt({},e)}function dv(e,t,n,r,i,a,o,s,l){var c,u,d,h,f,g,w,v=n.props||Mi,y=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"),a!=null){for(c=0;c<a.length;c++)if((f=a[c])&&"setAttribute"in f==!!b&&(b?f.localName==b:f.nodeType==3)){e=f,a[c]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&(le.__m&&le.__m(t,a),s=!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a=b=="textarea"&&y.defaultValue!=null?null:a&&Fi.call(e.childNodes),!s&&a!=null)for(v={},c=0;c<e.attributes.length;c++)v[(f=e.attributes[c]).name]=f.value;for(c in v)f=v[c],c=="dangerouslySetInnerHTML"?d=f:c=="children"||c in y||c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y||Ni(e,c,null,f,i);for(c in y)f=y[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?u=f:c=="value"?g=f:c=="checked"?w=f:s&&typeof f!="function"||v[c]===f||Ni(e,c,f,v[c],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),dc(t.type=="template"?e.content:e,$i(h)?h:[h],t,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,o,a?a[0]:n.__k&&_n(n,0),s,l),a!=null)for(c=a.length;c--;)vo(a[c]);s&&b!="textarea"||(c="value",b=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[c]||b=="progress"&&!g||b=="option"&&g!=v[c])&&Ni(e,c,g,v[c],i),c="checked",w!=null&&w!=e[c]&&Ni(e,c,w,v[c],i))}return e}function yo(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){le.__e(i,n)}}function mc(e,t,n){var r,i;if(le.unmount&&le.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||yo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){le.__e(a,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&mc(r[i],t,n||typeof e.type!="function");n||vo(e.__e),e.__c=e.__=e.__e=void 0}function hv(e,t,n){return this.constructor(e,n)}function vc(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),le.__&&le.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,a=[],o=[],wo(t,e=(!r&&n||t).__k=sv(xe,null,[e]),i||Mi,Mi,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Fi.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),fc(a,e,o),e.props.children=null}Fi=Gi.slice,le={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},oc=0,iv=function(e){return e!=null&&e.constructor===void 0},Ii.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Wt({},this.state),typeof e=="function"&&(e=e(Wt({},n),this.props)),e&&Wt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),rc(this))},Ii.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),rc(this))},Ii.prototype.render=xe,on=[],sc=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,lc=function(e,t){return e.__v.__b-t.__v.__b},Oi.__r=0,po=Math.random().toString(8),Pi="__d"+po,Mr="__a"+po,cc=/(PointerCapture)$|Capture$/i,mo=0,fo=ac(!1),go=ac(!0),av=0;var wc="weave-bootstrap";var bo={cwd:""};function pv(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function yc(e){if(e===null||e.trim()==="")return bo;let t;try{t=JSON.parse(e)}catch{return bo}return pv(t)?t:bo}var Tn,_e,xo,bc,Gr=0,Ac=[],Re=le,xc=Re.__b,kc=Re.__r,_c=Re.diffed,Tc=Re.__c,Sc=Re.unmount,Ec=Re.__;function Or(e,t){Re.__h&&Re.__h(_e,e,Gr||t),Gr=0;var n=_e.__H||(_e.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function K(e){return Gr=1,fv(Lc,e)}function fv(e,t,n){var r=Or(Tn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Lc(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,s);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=_e,!_e.__f)){var i=function(s,l,c){if(!r.__c.__H)return!0;var u=!1,d=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){u=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(d=!0)}}),a){var h=a.call(this,s,l,c);return u?h||d:h}return!u||d};_e.__f=!0;var a=_e.shouldComponentUpdate,o=_e.componentWillUpdate;_e.componentWillUpdate=function(s,l,c){if(this.__e){var u=a;a=void 0,i(s,l,c),a=u}o&&o.call(this,s,l,c)},_e.shouldComponentUpdate=i}return r.__N||r.__}function ne(e,t){var n=Or(Tn++,3);!Re.__s&&To(n.__H,t)&&(n.__=e,n.u=t,_e.__H.__h.push(n))}function ze(e,t){var n=Or(Tn++,4);!Re.__s&&To(n.__H,t)&&(n.__=e,n.u=t,_e.__h.push(n))}function V(e){return Gr=5,De(function(){return{current:e}},[])}function De(e,t){var n=Or(Tn++,7);return To(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function _o(e,t){return Gr=8,De(function(){return e},t)}function Cc(){var e=Or(Tn++,11);if(!e.__){for(var t=_e.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function gv(){for(var e;e=Ac.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(zi),t.__h.some(ko),t.__h=[]}catch(n){t.__h=[],Re.__e(n,e.__v)}}}Re.__b=function(e){_e=null,xc&&xc(e)},Re.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ec&&Ec(e,t)},Re.__r=function(e){kc&&kc(e),Tn=0;var t=(_e=e.__c).__H;t&&(xo===_e?(t.__h=[],_e.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(zi),t.__h.some(ko),t.__h=[],Tn=0)),xo=_e},Re.diffed=function(e){_c&&_c(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ac.push(t)!==1&&bc===Re.requestAnimationFrame||((bc=Re.requestAnimationFrame)||mv)(gv)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),xo=_e=null},Re.__c=function(e,t){t.some(function(n){try{n.__h.some(zi),n.__h=n.__h.filter(function(r){return!r.__||ko(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Re.__e(r,n.__v)}}),Tc&&Tc(e,t)},Re.unmount=function(e){Sc&&Sc(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{zi(r)}catch(i){t=i}}),n.__H=void 0,t&&Re.__e(t,n.__v))};var Rc=typeof requestAnimationFrame=="function";function mv(e){var t,n=function(){clearTimeout(r),Rc&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Rc&&(t=requestAnimationFrame(n))}function zi(e){var t=_e,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),_e=t}function ko(e){var t=_e;e.__c=e.__(),_e=t}function To(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Lc(e,t){return typeof t=="function"?t(e):t}var Nc={bg:"#eff1f5",panel:"#e6e9ef",page:"#ffffff",raise:"#ccd0da",fg:"#4c4f69",dim:"#56586a",faint:"#606274",line:"#ccd0da","line-strong":"#bcc0cc",accent:"#7113ec",ok:"#28641b",warn:"#7c4f10",bad:"#b20d30"},Pc={bg:"#24273a",panel:"#1e2030",page:"#181926",raise:"#363a4f",fg:"#cad3f5",dim:"#a5adcb",faint:"#939ab7",line:"#363a4f","line-strong":"#494d64",accent:"#c6a0f6",ok:"#a6da95",warn:"#eed49f",bad:"#ed8796"},ve={light:{name:"Catppuccin Latte · Mauve",scheme:"light",colors:Nc},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...Nc,accent:"#1750bf"}},"frappe-teal":{name:"Catppuccin Frappé · Teal",scheme:"dark",colors:{bg:"#303446",panel:"#292c3c",page:"#232634",raise:"#414559",fg:"#c6d0f5",dim:"#b5bfe2",faint:"#a5adce",line:"#414559","line-strong":"#51576d",accent:"#81c8be",ok:"#a6d189",warn:"#e5c890",bad:"#f4a4a6"}},dark:{name:"Catppuccin Macchiato · Mauve",scheme:"dark",colors:Pc},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...Pc,accent:"#f5a97f"}},"mocha-lavender":{name:"Catppuccin Mocha · Lavender",scheme:"dark",colors:{bg:"#1e1e2e",panel:"#181825",page:"#11111b",raise:"#313244",fg:"#cdd6f4",dim:"#a6adc8",faint:"#9399b2",line:"#313244","line-strong":"#45475a",accent:"#b4befe",ok:"#a6e3a1",warn:"#f9e2af",bad:"#f38ba8"}},"paper-blue":{name:"Paper · Blue",scheme:"light",colors:{bg:"#f4f6f8",panel:"#e9edf2",page:"#ffffff",raise:"#dce3eb",fg:"#182334",dim:"#42536a",faint:"#526176",line:"#dce3eb","line-strong":"#bac6d4",accent:"#174ea6",ok:"#21623b",warn:"#805300",bad:"#a3223c"}},"ink-blue":{name:"Ink · Blue",scheme:"dark",colors:{bg:"#1b2430",panel:"#141c27",page:"#101720",raise:"#2b3748",fg:"#edf2f8",dim:"#becadc",faint:"#a5b5cb",line:"#2b3748","line-strong":"#46566d",accent:"#8bbcff",ok:"#91d5a5",warn:"#edc47b",bad:"#ff9fae"}},"sand-amber":{name:"Sand · Amber",scheme:"light",colors:{bg:"#f7f3ec",panel:"#ede6da",page:"#fffdf8",raise:"#e2d8c8",fg:"#30291f",dim:"#5b4e3f",faint:"#675847",line:"#e2d8c8","line-strong":"#c7b8a2",accent:"#814500",ok:"#365c2a",warn:"#795000",bad:"#a12c32"}},"ember-amber":{name:"Ember · Amber",scheme:"dark",colors:{bg:"#29231f",panel:"#211c19",page:"#191512",raise:"#3c322b",fg:"#f3e9dc",dim:"#d0bfab",faint:"#bfa991",line:"#3c322b","line-strong":"#5c4d40",accent:"#edb96b",ok:"#b5cf8a",warn:"#efc57a",bad:"#f69a91"}},"mist-teal":{name:"Mist · Teal",scheme:"light",colors:{bg:"#eff5f3",panel:"#e1ece8",page:"#fafffd",raise:"#d2e2dc",fg:"#18342e",dim:"#3c5b52",faint:"#48655b",line:"#d2e2dc","line-strong":"#acc5bc",accent:"#006457",ok:"#2a5e35",warn:"#795300",bad:"#a52a43"}},"forest-teal":{name:"Forest · Teal",scheme:"dark",colors:{bg:"#1c2b27",panel:"#16221e",page:"#101b17",raise:"#2b4038",fg:"#e6f2ec",dim:"#b8d0c4",faint:"#a2bfb0",line:"#2b4038","line-strong":"#456255",accent:"#7cd8bb",ok:"#a5d6a0",warn:"#e6c582",bad:"#f5a2ac"}}},Dc=["system",...Object.keys(ve)];function Xn(e){return typeof e=="string"&&Dc.includes(e)}var Sn={mauve:{name:"Mauve",light:"#7113ec",dark:"#cba9f8"},blue:{name:"Blue",light:"#1750bf",dark:"#8bbcff"},teal:{name:"Teal",light:"#006457",dark:"#7cd8bb"},peach:{name:"Peach",light:"#814500",dark:"#f5a97f"},rose:{name:"Rose",light:"#a52a43",dark:"#f4a4a6"},green:{name:"Green",light:"#28641b",dark:"#a6da95"},amber:{name:"Amber",light:"#775000",dark:"#edb96b"},lavender:{name:"Lavender",light:"#445198",dark:"#b4befe"}};function Hi(e){return typeof e=="string"?e:e.theme}function Ic(e,t){return t==="theme"?ve[e].colors.accent:Sn[t][ve[e].scheme]}var at={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},sn={...at};function So(e){Object.assign(at,e)}var Qn=[{key:"containsStrength",label:"Group cohesion",hint:"how hard a parent holds its children — group cohesion",min:0,max:1,step:.01},{key:"containsRest",label:"Group radius",hint:"how far children sit from their parent — rosette radius",min:10,max:300,step:5},{key:"relationStrength",label:"Link strength",hint:"pull of links-to / mentions across groups",min:0,max:1,step:.01},{key:"relationDistance",label:"Link distance",hint:"how long those cross-group springs are",min:20,max:600,step:10},{key:"charge",label:"Repulsion",hint:"node-to-node repulsion — more negative pushes harder",min:-1200,max:0,step:10},{key:"chargeMax",label:"Repulsion range",hint:"distance past which repulsion stops — caps overall spread",min:100,max:4e3,step:50},{key:"center",label:"Center gravity",hint:"pull toward the origin — too much makes one blob",min:0,max:.3,step:.005}],ln={lightTheme:"light",darkTheme:"dark",accent:"theme",fontSize:14,readable:!0,spellcheck:!0,defaultEdit:!1,startup:"restore",focusNewTabs:!0,groupColors:!0,forces:{...sn}};function Mc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gc(e){if(!Mc(e))return null;let n=!Object.hasOwn(e,"lightTheme")&&!Object.hasOwn(e,"darkTheme")?{...e,lightTheme:"light",darkTheme:"dark"}:e;if(Object.keys(n).length!==Object.keys(ln).length)return null;for(let i of["light","dark"]){let a=n[`${i}Theme`];if(!Xn(a)||a==="system"||ve[a].scheme!==i)return null}if(n.accent!=="theme"&&(typeof n.accent!="string"||!Object.hasOwn(Sn,n.accent))||typeof n.fontSize!="number"||!Number.isInteger(n.fontSize)||n.fontSize<12||n.fontSize>22)return null;for(let i of["readable","spellcheck","defaultEdit","focusNewTabs","groupColors"])if(typeof n[i]!="boolean")return null;if(n.startup!=="restore"&&n.startup!=="empty")return null;let r=n.forces;if(!Mc(r)||Object.keys(r).length!==Qn.length)return null;for(let{key:i,min:a,max:o}of Qn){let s=r[i];if(typeof s!="number"||!Number.isFinite(s)||s<a||s>o)return null}return n}var Co=40,Oc=100,vv=1e9,Fr=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function Lo(){return{version:1,panes:[{id:"pane-1",tabs:[Fr("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,contextPinned:!1,treeWidth:240,contextWidth:240,contextGraphHeight:260,contextTagsHeight:180,theme:"system",preferences:ln}}function En(e){return e.panes.find(t=>t.id===e.activePane)}function Rn(e){let t=En(e);return t.tabs.find(n=>n.id===t.activeTab)}function Mt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function er(e,t){let n=new Set(e.panes.flatMap(i=>[i.id,...i.tabs.map(a=>a.id)])),r=1;for(;n.has(`${t}-${r}`);)r++;return`${t}-${r}`}function An(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?Ui({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function No(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function Ui(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??No(e);return r?{...n,lastDocumentTab:r.id}:n}function Bi(e){if(Rn(e).kind==="document")return e;let t=En(e),n=No(t);return n?An(e,t,n):cn(e,null,{newTab:!0})}function Ki(e,t,n){let r=e.panes.find(a=>a.id===t),i=r?.tabs.find(a=>a.id===n);return r&&i?{pane:r,tab:i}:null}function Ao(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=Co?e:An(e,{...t,tabs:[...t.tabs,n]},n)}function Eo(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>Oc&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function cn(e,t,n={}){let r=e.panes.find(s=>s.id===(n.paneId??e.activePane));if(!r)return e;let i=r.activeTab,a=r.tabs.find(s=>s.id===i);if(a?.kind==="graph"&&(a=No(r),a?r={...r,activeTab:a.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!a)return Ao(e,r,Eo(Fr(er(e,"tab")),t));let o=Eo(a,t);return o===a&&r.id===e.activePane&&i===a.id?e:An(e,r,o)}function Po(e){let t=e.panes.flatMap(r=>r.tabs.filter(i=>i.kind==="graph").map(i=>({pane:r,tab:i})))[0];if(t)return t.pane.id===e.activePane&&t.pane.activeTab===t.tab.id?e:An(e,t.pane,t.tab);let n=En(e);return Ao(e,n,{id:er(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function Do(e,t,n){let r=Ki(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:An(e,r.pane,r.tab)}function Io(e,t,n){let r=Ki(e,t,n);if(!r)return e;let{pane:i}=r;if(i.tabs.length===1){let c=e.panes.find(d=>d.id!==t);if(c)return{...e,panes:[c],activePane:c.id};let u=Fr(er(e,"tab"));return An(e,{...i,tabs:[u]},u)}let a=i.tabs.filter(c=>c.id!==n),o=i.activeTab===n,s=a[Math.max(0,i.tabs.findIndex(c=>c.id===n)-1)],l=Ui({...i,tabs:a,activeTab:o?s.id:i.activeTab});return{...e,activePane:o?t:e.activePane,panes:e.panes.map(c=>c.id===t?l:c)}}function Mo(e,t,n){let r=e.panes.find(o=>o.id===t),i=r?.tabs.find(o=>o.id===r.activeTab);if(!r||!i||i.kind!=="document")return e;let a=i.cursor+n;return a<0||a>=i.history.length?e:An(e,r,{...i,cursor:a,scroll:0})}function Go(e,t){if(e.panes.length===2)return e.split===t?e:{...e,split:t};let n=tr(e,e.activePane,Rn(e).id);return n===e?e:{...n,split:t}}function Fc(e,t){if(e.panes.length!==2||!e.panes.some(i=>i.id===t))return e;let n=e.panes.find(i=>i.id===t),r=e.panes.find(i=>i.id!==t);return{...e,panes:[{...r,tabs:[...r.tabs,...n.tabs]}],activePane:r.id}}function Oo(e,t,n,r){let i=Ki(e,t,n);if(!i||r===n||r!==null&&!i.pane.tabs.some(o=>o.id===r))return e;let a=i.pane.tabs.filter(o=>o.id!==n);return a.splice(r===null?a.length:a.findIndex(o=>o.id===r),0,i.tab),a.every((o,s)=>o===i.pane.tabs[s])?e:{...e,panes:e.panes.map(o=>o.id===t?{...o,tabs:a}:o)}}function Vi(e,t,n){return e.panes.some(r=>r.id===t)?e.panes.find(r=>r.id!==t&&r.tabs.some(i=>i.id===n))?.id??null:null}function tr(e,t,n){let r=Ki(e,t,n);if(!r)return e;let i=e.panes.find(u=>u.id!==t)??{id:er(e,"pane"),tabs:[],activeTab:""},a=r.pane.tabs.filter(u=>u.id!==n),o=Ui({...i,tabs:[...i.tabs,r.tab],activeTab:r.tab.id});if(!a.length&&e.panes.length===2)return{...e,panes:[o],activePane:i.id};if(!a.length&&e.panes.reduce((u,d)=>u+d.tabs.length,0)>=Co)return e;let s=a.length?null:Fr(er(e,"tab")),l=a.length?a:[s],c=Ui({...r.pane,tabs:l,activeTab:r.pane.activeTab===n?l[Math.max(0,r.pane.tabs.findIndex(u=>u.id===n)-1)].id:r.pane.activeTab});return{...e,activePane:i.id,panes:e.panes.length===1?[c,o]:e.panes.map(u=>u.id===c.id?c:o)}}function Ro(e,t){return Object.keys(e).length===t.length&&t.every(n=>Object.hasOwn(e,n))}function Wi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jn(e,t){return typeof e=="string"&&e.length<=2048&&(t===void 0?e.length>0&&!/[\u0000-\u001f\u007f]/.test(e):new RegExp(`^${t}-[1-9][0-9]{0,8}$`).test(e))}function $c(e){if(!Wi(e)||!Ro(e,["version","panes","activePane","split","ratio","treeVisible","contextVisible","treeWidth","contextWidth","theme",...["preferences","contextGraphHeight","contextTagsHeight","contextPinned"].filter(u=>Object.hasOwn(e,u))])||e.version!==1||!Array.isArray(e.panes)||e.panes.length<1||e.panes.length>2||!Jn(e.activePane,"pane")||e.split!=="right"&&e.split!=="down"||typeof e.ratio!="number"||!Number.isFinite(e.ratio)||e.ratio<.1||e.ratio>.9||typeof e.treeVisible!="boolean"||typeof e.contextVisible!="boolean")return null;let t=Object.hasOwn(e,"contextPinned")?e.contextPinned:!1;if(typeof t!="boolean"||typeof e.treeWidth!="number"||!Number.isFinite(e.treeWidth)||e.treeWidth<120||e.treeWidth>800||typeof e.contextWidth!="number"||!Number.isFinite(e.contextWidth)||e.contextWidth<120||e.contextWidth>800)return null;let n=Object.hasOwn(e,"contextGraphHeight")?e.contextGraphHeight:260,r=Object.hasOwn(e,"contextTagsHeight")?e.contextTagsHeight:180;if(typeof n!="number"||!Number.isFinite(n)||n<120||n>800||typeof r!="number"||!Number.isFinite(r)||r<60||r>600||!Xn(e.theme))return null;let i=Object.hasOwn(e,"preferences")?Gc(e.preferences):ln;if(i===null)return null;let a=e.preferences;e.theme!=="system"&&(!Wi(a)||!Object.hasOwn(a,"lightTheme"))&&(i={...i,[`${ve[e.theme].scheme}Theme`]:e.theme});let o=new Set,s=0,l=0,c=[];for(let u of e.panes){if(!Wi(u)||!Ro(u,Object.hasOwn(u,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!Jn(u.id,"pane")||!Array.isArray(u.tabs)||u.tabs.length<1||!Jn(u.activeTab,"tab")||o.has(u.id))return null;o.add(u.id);let d=[],h=!1;for(let g of u.tabs){if(!Wi(g)||!Ro(g,["id","kind","history","cursor","scroll"])||!Jn(g.id,"tab")||o.has(g.id)||(o.add(g.id),g.kind!=="document"&&g.kind!=="graph"))return null;let w=g.kind;if(!Array.isArray(g.history)||g.history.length<1||g.history.length>Oc||!Number.isInteger(g.cursor)||g.cursor<0||g.cursor>=g.history.length||g.history.some(v=>v!==null&&!Jn(v))||typeof g.scroll!="number"||!Number.isFinite(g.scroll)||g.scroll<0||g.scroll>vv)return null;w==="graph"&&l++,s++,g.id===u.activeTab&&(h=!0),d.push({id:g.id,kind:w,history:g.history,cursor:g.cursor,scroll:g.scroll})}if(!h)return null;let f=u.lastDocumentTab;if(Object.hasOwn(u,"lastDocumentTab")&&(!Jn(f,"tab")||!d.some(g=>g.id===f&&g.kind==="document")))return null;c.push({id:u.id,tabs:d,activeTab:u.activeTab,...typeof f=="string"?{lastDocumentTab:f}:{}})}return s>Co||l>1||!c.some(u=>u.id===e.activePane)?null:{version:1,panes:c,activePane:e.activePane,split:e.split,ratio:e.ratio,treeVisible:e.treeVisible,contextVisible:e.contextVisible,contextPinned:t,treeWidth:e.treeWidth,contextWidth:e.contextWidth,contextGraphHeight:n,contextTagsHeight:r,theme:e.theme,preferences:i}}function zc(e){if(e.preferences.startup==="restore")return e;let t=Lo();return{...e,panes:t.panes,activePane:t.activePane}}function Hc(e,t,n={}){let r=cn(e,t,n);return!n.newTab||e.preferences.focusNewTabs?r:{...r,activePane:e.activePane,panes:r.panes.map(i=>{let a=e.panes.find(l=>l.id===i.id),{lastDocumentTab:o,...s}=i;return{...s,activeTab:a.activeTab,...a.lastDocumentTab?{lastDocumentTab:a.lastDocumentTab}:{}}})}}var we=(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},...t?.signal===void 0?{}:{signal:t.signal},credentials:"same-origin"});function ji(e,t=!1){return{ok:!0,data:e,cached:t}}function Gt(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function Wc(e){return e===403?"auth":e===404?"missing":"server"}function Uc(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function Cn(e,t,n,r){let i;try{i=await e(t,r)}catch(o){return Gt("network",0,o instanceof Error?o.message:"network request failed")}if(!i.ok)return Gt(Wc(i.status),i.status,Uc(i.status));let a;try{a=await i.json()}catch{return Gt("malformed",i.status,"response was not valid JSON")}return n(a)?ji(a):Gt("malformed",i.status,"response did not match the expected shape")}function ot(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Bc(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function wv(e){if(!ot(e)||typeof e.stamp!="string")return!1;let t=e.model;return!ot(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:ot(e.tags)&&ot(e.dangling)}function yv(e){if(!ot(e)||typeof e.stamp!="string"||typeof e.turn!="number")return!1;let t=e.events;return Array.isArray(t)&&t.every(n=>ot(n)&&typeof n.seq=="number"&&typeof n.turn=="number"&&typeof n.at=="string"&&(n.kind==="searched"||n.kind==="read"||n.kind==="wrote")&&typeof n.action=="string"&&Bc(n.slugs)&&(n.query===void 0||typeof n.query=="string"))}function bv(e){if(!ot(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return Bc(e.tags)}function Kc(e){return ot(e)&&bv(e.note)}function xv(e){return ot(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function kv(e){return ot(e)&&typeof e.opened=="boolean"}var _v=new Set(["human","agent","outside","system"]),Tv=e=>Number.isInteger(e)&&e>=0;function Sv(e){if(!ot(e)||typeof e.slug!="string"||typeof e.enabled!="boolean"||typeof e.trimmed!="boolean")return!1;let t=e.revisions;return Array.isArray(t)&&t.every(n=>{if(!ot(n)||typeof n.at!="string"||!_v.has(n.by)||typeof n.op!="string")return!1;if(typeof n.full=="string")return!0;let r=n.keep;return Array.isArray(r)&&r.length===2&&r.every(Tv)&&typeof n.text=="string"})}function Ev(e){let t=[],n=null;for(let{at:r,by:i,op:a,full:o,keep:s,text:l}of e.revisions){if(o!==void 0)n=o;else{let[c,u]=s;if(n===null||c+u>n.length)return null;n=n.slice(0,c)+l+n.slice(n.length-u)}t.push({at:r,by:i,op:a,body:n})}return{slug:e.slug,enabled:e.enabled,trimmed:e.trimmed,revisions:t}}function Rv(e){return ot(e)&&typeof e.enabled=="boolean"}function Av(e){return ot(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}function qi(e,t=null){return jc(e,"/api/graph",t,wv)}function Vc(e,t=null){return jc(e,"/api/trail",t,yv)}async function jc(e,t,n,r){let i=n===null?void 0:{"if-none-match":`"${n.stamp}"`},a;try{a=await e(t,i===void 0?{}:{headers:i})}catch(s){return Gt("network",0,s instanceof Error?s.message:"network request failed")}if(a.status===304)return n===null?Gt("malformed",304,"server sent 304 for an unconditional request"):ji(n,!0);if(!a.ok)return Gt(Wc(a.status),a.status,Uc(a.status));let o;try{o=await a.json()}catch{return Gt("malformed",a.status,"response was not valid JSON")}return r(o)?ji(o):Gt("malformed",a.status,"response did not match the expected shape")}function Fo(e,t){return Cn(e,`/api/note/${encodeURIComponent(t)}`,Kc)}function qc(e,t,n){return Cn(e,`/api/search?q=${encodeURIComponent(t)}`,xv,n===void 0?void 0:{signal:n})}function Yc(e,t){return Cn(e,"/api/open",kv,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function Zc(e,t){return Cn(e,"/api/notes",Kc,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})}function Ot(e,t,n,r){return Cn(e,t,Av,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var Yi=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,$o=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,zo=(e,t="")=>`/api/artifact/${e.split("/").map(encodeURIComponent).join("/")}${t}`,Xc=(e,t,n,r=!1)=>Ot(e,Yi(t),"POST",r?{body:n,raw:!0}:{body:n}),Qc=(e,t,n)=>Ot(e,Yi(t,"/rename"),"POST",{name:n}),Jc=(e,t,n)=>Ot(e,Yi(t,"/move"),"POST",{folder:n}),eu=(e,t,n)=>Ot(e,zo(t,"/move"),"POST",{folder:n}),tu=(e,t,n)=>Ot(e,zo(t,"/rename"),"POST",{name:n}),nu=(e,t)=>Ot(e,zo(t),"DELETE"),ru=(e,t)=>Ot(e,Yi(t),"DELETE"),iu=(e,t)=>Ot(e,$o(t),"POST"),au=(e,t,n)=>Ot(e,$o(t,"/rename"),"POST",{name:n}),ou=(e,t)=>Ot(e,$o(t),"DELETE");async function su(e,t){let n=await Cn(e,`/api/history/${encodeURIComponent(t)}`,Sv);if(!n.ok)return n;let r=Ev(n.data);return r===null?Gt("malformed",200,"history did not fit together"):ji(r,n.cached)}function Ho(e,t){return Cn(e,"/api/history-settings",Rv,t===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:t})})}function pt(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 Cv(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 c=n.get(l.source);c?c.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let c=r.get(l.source);c?c.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let a=l=>{if(!l.detail.path)return null;let c=l.detail.path,u=null,d=0,h=n.get("repository")??[];for(let f of h){let g=t.get(f);if(g&&g.kind==="module"&&g.detail.path){let w=g.detail.path;c.startsWith(w+"/")&&w.length>d&&(u=f,d=w.length)}}return u},o=new Map;for(let l of e.nodes){if(l.kind!=="entryPoint")continue;let c=a(l);if(c){let u=o.get(c);u?u.push(l.id):o.set(c,[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:o,roots:s}}function uu(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 lu(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function Nv(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),a=t.get(r),o=lu(i),s=lu(a);if(o!==s)return o?-1:1;let l=pt(i),c=pt(a);return l.localeCompare(c)})}function cu(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 Pv(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?cu(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?cu(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 Wo(e,t){let n=Cv(e),{byId:r,tree:i,moduleEntries:a,roots:o}=n,s=g=>{let y=(i.get(g)??[]).filter(b=>{let _=r.get(b);if(!_||_.kind!=="entryPoint")return!0;for(let[,x]of a)if(x.includes(b))return!1;return!0}).concat(a.get(g)??[]);return y=y.filter(b=>r.has(b)),t.showInternals||(y=y.filter(b=>{let _=r.get(b);return!(_&&Lv(_.kind))})),Nv(y,r)},l=t.provFilter!==null||t.query.length>0,c=g=>!(t.provFilter!==null&&g.provenance!==t.provFilter||t.query.length>0&&!pt(g).toLowerCase().includes(t.query.toLowerCase())),u=new Set,d=g=>{let w=r.get(g),v=!1;for(let b of s(g))d(b)&&(v=!0);let y=c(w)||v;return y&&u.add(g),y};for(let g of o)d(g);let h=[],f=(g,w)=>{if(!u.has(g))return;let v=r.get(g),y=s(g),b=y.filter(x=>u.has(x)),_=l?b.length>0:t.expanded.has(g);if(h.push({id:g,depth:w,hasKids:y.length>0,expanded:_,label:pt(v),kind:v.kind,provenance:v.provenance,meta:Pv(v)}),_)for(let x of b)f(x,w+1)};for(let g of o)f(g,0);return h}function Uo(e){if(!e.nodes.find(i=>i.kind==="vault"))return null;let n=e.nodes.some(i=>i.kind==="note"||i.id.startsWith("artifact:")||i.id.startsWith("vfolder:")),r=e.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function Ut(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 a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);if(o<30)return`${o}d ago`;let s=Math.floor(o/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var Dv=7;function Bo(e,t){if(e===null)return"";switch(e.kind){case"relTime":return Ut(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,Dv);case"text":return e.text}}var Iv="## Raw",Mv=/^[ \t]*(`{3,}|~{3,})(.*)$/gm,Gv=new RegExp(`^${Iv}[ \\t]*\\r?$`,"m");function du(e){let t=[],n=null;for(let r of e.matchAll(Mv)){let i=r[1],a=r[2];n===null?n={at:r.index,marker:i[0],length:i.length}:i[0]===n.marker&&i.length>=n.length&&a.trim()===""&&(t.push([n.at,r.index+r[0].length]),n=null)}return n!==null&&t.push([n.at,e.length]),t}function hu(e,t){let n=0;for(;;){let r=e.slice(n),i=Gv.exec(r);if(i===null)return e.length;let a=n+i.index,o=t.find(([s,l])=>a>=s&&a<l);if(o===void 0)return a;n=o[1]}}var Ov=/(?:^|\n)-{3,}[ \t]*\r?\n\s*$/;function Fv(e){let t=hu(e,du(e));if(t===e.length)return t;let n=Ov.exec(e.slice(0,t));return n===null?t:n.index===0&&!e.startsWith(`
22
+ `)?0:n.index+1}function nr(e){let t=Fv(e);return{head:e.slice(0,t).trimEnd(),tail:e.slice(t).trimEnd()}}function Ko(e,t){return t===""?e:e===""?t:`${e}
23
23
 
24
- ${t}`}var Iv=/^<!--(?! appended\b).*-->[ \t]*\r?$/;function $r(e){let t=su(e,ou(e));if(t===e.length)return{opening:e,entries:""};let n=e.indexOf(`
24
+ ${t}`}var $v=/^<!--(?! appended\b).*-->[ \t]*\r?$/;function $r(e){let t=hu(e,du(e));if(t===e.length)return{opening:e,entries:""};let n=e.indexOf(`
25
25
  `,t);if(n!==-1){let r=e.indexOf(`
26
- `,n+1),i=e.slice(n+1,r===-1?e.length:r);Iv.test(i)&&(n=r)}return n===-1?{opening:e.trimEnd(),entries:""}:{opening:e.slice(0,n).trimEnd(),entries:e.slice(n).replace(/^\s*\n/,"").trimEnd()}}function Ko(e,t){return t.trim()===""?"":`${e}
26
+ `,n+1),i=e.slice(n+1,r===-1?e.length:r);$v.test(i)&&(n=r)}return n===-1?{opening:e.trimEnd(),entries:""}:{opening:e.slice(0,n).trimEnd(),entries:e.slice(n).replace(/^\s*\n/,"").trimEnd()}}function Vo(e,t){return t.trim()===""?"":`${e}
27
27
 
28
- ${t.replace(/^\s*\n/,"").trimEnd()}`}var Mv=["title","description","path","size","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","link references","warning","stale","preview","root","notes","state"];function Vo(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 a=[];for(let s of e.edges){if(s.source!==t)continue;let l=n.get(s.target);l&&a.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${pt(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let o=[];for(let s of e.edges){if(s.kind!=="links-to"||s.target!==t)continue;let l=n.get(s.source);l&&o.push({id:`backlink:${s.source}`,target:s.source,label:`← ${pt(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:pt(r),kind:r.kind,provenance:r.provenance,meta:i,links:a,backlinks:o}}function Zi(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 Xi(e,t){let n=new Map;for(let h of e.nodes)n.set(h.id,h);let r=Fv(e,n),i=au(e),a=new Set,o=h=>{if(!a.has(h)&&(a.add(h),!!t.has(h)))for(let f of r.get(h)??[])o(f)};for(let h of i)o(h);let s=new Map;for(let h of r.keys())s.set(h,$v(h,r));let l=new Map;for(let h of e.nodes)if(!(!a.has(h.id)||t.has(h.id)))for(let f of s.get(h.id)??[])!a.has(f)&&!l.has(f)&&l.set(f,h.id);for(let h of e.nodes)!a.has(h.id)&&!l.has(h.id)&&a.add(h.id);let c=new Map;for(let[h,f]of r){let g=s.get(h);c.set(h,{children:f,descendants:g,members:g.filter(w=>l.get(w)===h),provenance:zv(g,n),expanded:t.has(h)})}let u=new Set,d=[];for(let h of e.nodes)a.has(h.id)?d.push(h):u.add(h.id);return{nodes:d,edges:Hv(e.edges,a,l),clusters:c,hidden:u,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 $v(e,t){let n=[],r=new Set([e]),i=a=>{for(let o of t.get(a)??[])r.has(o)||(r.add(o),n.push(o),i(o))};return i(e),n}function zv(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 Hv(e,t,n){let r=o=>t.has(o)?o:n.get(o),i=[],a=new Set;for(let o of e){let s=r(o.source),l=r(o.target);if(s===void 0||l===void 0||s===l)continue;let c=`${s}\0${l}\0${o.kind}`;a.has(c)||(a.add(c),i.push({source:s,target:l,kind:o.kind}))}return i}function jo(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 rr=[null,"human","agent","generated"];function lu(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function Zo(e,t){let n=new Set(e.expanded).add("vault"),r="";for(let i of t?t.split("/"):[])r=r?`${r}/${i}`:i,n.add(`vfolder:${r}`);return{...e,expanded:n,query:"",provFilter:null}}function Ln(e){return{...e.model,danglingLinks:e.dangling}}function cu(e,t){return e===null?[]:Ho(Ln(e),t)}var ir="vfolder:\0draft";function uu(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function du(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function hu(e,t){if(t===null)return[...e];let n={id:ir,depth:t===""?1:t.split("/").length+1,hasKids:!1,expanded:!1,label:"",kind:"module",provenance:null,meta:null};if(t==="")return[...e,n];let r=e.findIndex(a=>a.id===`vfolder:${t}`);if(r===-1)return[...e,n];let i=r+1;for(;i<e.length&&e[i].depth>e[r].depth;)i++;return[...e.slice(0,i),n,...e.slice(i)]}function Xo(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Wv(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return n.add(t),{...e,expanded:n}}function Uv(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function Qo(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function Nn(e){return e==="vault"?{type:"vault",path:""}:e.startsWith("note:")?{type:"note",path:e.slice(5)}:e.startsWith("vfolder:")?{type:"folder",path:e.slice(8)}:null}function Ji(e,t){if(t.type==="note")return[t.path];if(t.type!=="folder"||e===null)return[];let n=`note:${t.path}/`;return e.model.nodes.filter(r=>r.kind==="note"&&r.id.startsWith(n)).map(r=>r.id.slice(5))}function pu(e,t){return e===null?!1:t.type==="note"?e===`note:${t.path}`:t.type==="folder"?e===`vfolder:${t.path}`||e.startsWith(`vfolder:${t.path}/`)||e.startsWith(`note:${t.path}/`):!1}function Jo(e){return e.type==="folder"}function fu(e,t,n){return Jo(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function gu(e,t){return e.query===t?e:{...e,query:t}}function mu(e){let t=rr.indexOf(e.provFilter),n=rr[(t+1)%rr.length]??null;return{...e,provFilter:n}}function vu(e){return{...e,showInternals:!e.showInternals}}function ea(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function Yo(e,t){return e[t]?.id??null}function qo(e,t,n){if(e.length===0)return null;let r=ea(e,t),i=r===-1?n>0?-1:e.length:r;return Yo(e,Math.min(e.length-1,Math.max(0,i+n)))}function Bv(e,t){let n=ea(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 wu(e,t,n,r,i=!1){let a={state:t,selectedId:n,handled:!1};if(i)return a;let o=d=>({state:t,selectedId:d,handled:!0}),s=Vv(r);if(s==="ArrowDown")return o(qo(e,n,1));if(s==="ArrowUp")return o(qo(e,n,-1));if(s==="Home")return o(Yo(e,0));if(s==="End")return o(Yo(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return a;let l=ea(e,n),c=l===-1?void 0:e[l];if(c===void 0||n===null)return a;if(s==="ArrowRight")return c.hasKids?c.expanded?o(qo(e,n,1)):{state:Wv(t,n),selectedId:n,handled:!0}:a;if(c.hasKids&&c.expanded)return{state:Uv(t,n),selectedId:n,handled:!0};let u=Bv(e,n);return u===null?a:o(u)}var jv={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Pn(e){return jv[e]}var qv={human:"●",agent:"◐",generated:"○"};function Ut(e){return e===null?"":qv[e]}function cn(e){return e===null?"":`${e}-authored`}function yu(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Yv(e){let t=e.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let a of n.splice(i+1))for(let[o,s]of a.entries())t[s]={posinset:o+1,setsize:a.length}};for(let[i,a]of e.entries()){r(a.depth);let o=n[a.depth];if(o===void 0){for(o=[];n.length<a.depth;)n.push([]);n.push(o)}o.push(i)}return r(-1),t}function Zv(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:yu(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:Pn(e.kind),provenance:e.provenance,provenanceGlyph:Ut(e.provenance),provenanceTitle:cn(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:Uo(e.meta,n),level:e.depth+1}}function bu(e,t,n){let r=Yv(e);return e.map((i,a)=>Zv(i,t,n,r[a]))}function xu(e,t){return ea(e,t)===-1?null:yu(t)}function ku(e){return{"--weave-depth":String(Math.max(0,e))}}function Qi(e){return e===null?"all":e}function _u(e){let t=rr.indexOf(e),n=rr[(t+1)%rr.length]??null;return`provenance filter: ${Qi(e)} — click for ${Qi(n)}`}function Tu(e){return e?"internals":"knowledge"}function Su(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 Eu="filter…",Ru="Vault and repository",Au="Filter the tree",Cu="Filter the tree (/)";function Lu(e,t,n){if(e===null)return"loading…";let r=Wo(Ln(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 Nu(e){return e.length===1?"1 row":`${e.length} rows`}function Pu(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Du(this.cover(t,n),t,n,e)}function Du(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,l=e._y0,c=e._x1,u=e._y1,d,h,f,g,w,v,y,b;if(!a)return e._root=o,e;for(;a.length;)if((w=t>=(d=(s+c)/2))?s=d:c=d,(v=n>=(h=(l+u)/2))?l=h:u=h,i=a,!(a=a[y=v<<1|w]))return i[y]=o,e;if(f=+e._x.call(null,a.data),g=+e._y.call(null,a.data),t===f&&n===g)return o.next=a,i?i[y]=o:e._root=o,e;do i=i?i[y]=new Array(4):e._root=new Array(4),(w=t>=(d=(s+c)/2))?s=d:c=d,(v=n>=(h=(l+u)/2))?l=h:u=h;while((y=v<<1|w)===(b=(g>=h)<<1|f>=d));return i[b]=a,i[y]=o,e}function Iu(e){var t,n,r=e.length,i,a,o=new Array(r),s=new Array(r),l=1/0,c=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<l&&(l=i),i>u&&(u=i),a<c&&(c=a),a>d&&(d=a));if(l>u||c>d)return this;for(this.cover(l,c).cover(u,d),n=0;n<r;++n)Du(this,o[n],s[n],e[n]);return this}function Mu(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,l,c;n>e||e>=i||r>t||t>=a;)switch(c=(t<r)<<1|e<n,l=new Array(4),l[c]=s,s=l,o*=2,c){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function Gu(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Ou(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 He(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Fu(e,t,n){var r,i=this._x0,a=this._y0,o,s,l,c,u=this._x1,d=this._y1,h=[],f=this._root,g,w;for(f&&h.push(new He(f,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);g=h.pop();)if(!(!(f=g.node)||(o=g.x0)>u||(s=g.y0)>d||(l=g.x1)<i||(c=g.y1)<a))if(f.length){var v=(o+l)/2,y=(s+c)/2;h.push(new He(f[3],v,y,l,c),new He(f[2],o,y,v,c),new He(f[1],v,s,l,y),new He(f[0],o,s,v,y)),(w=(t>=y)<<1|e>=v)&&(g=h[h.length-1],h[h.length-1]=h[h.length-1-w],h[h.length-1-w]=g)}else{var b=e-+this._x.call(null,f.data),_=t-+this._y.call(null,f.data),x=b*b+_*_;if(x<n){var C=Math.sqrt(n=x);i=e-C,a=t-C,u=e+C,d=t+C,r=f.data}}return r}function $u(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,l=this._x1,c=this._y1,u,d,h,f,g,w,v,y;if(!n)return this;if(n.length)for(;;){if((g=u>=(h=(o+l)/2))?o=h:l=h,(w=d>=(f=(s+c)/2))?s=f:c=f,t=n,!(n=n[v=w<<1|g]))return this;if(!n.length)break;(t[v+1&3]||t[v+2&3]||t[v+3&3])&&(r=t,y=v)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[v]=a: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[y]=n:this._root=n),this):(this._root=a,this)}function zu(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Hu(){return this._root}function Wu(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Uu(e){var t=[],n,r=this._root,i,a,o,s,l;for(r&&t.push(new He(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,l=n.y1)&&r.length){var c=(a+s)/2,u=(o+l)/2;(i=r[3])&&t.push(new He(i,c,u,s,l)),(i=r[2])&&t.push(new He(i,a,u,c,l)),(i=r[1])&&t.push(new He(i,c,o,s,u)),(i=r[0])&&t.push(new He(i,a,o,c,u))}return this}function Bu(e){var t=[],n=[],r;for(this._root&&t.push(new He(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,l=r.x1,c=r.y1,u=(o+l)/2,d=(s+c)/2;(a=i[0])&&t.push(new He(a,o,s,u,d)),(a=i[1])&&t.push(new He(a,u,s,l,d)),(a=i[2])&&t.push(new He(a,o,d,u,c)),(a=i[3])&&t.push(new He(a,u,d,l,c))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Ku(e){return e[0]}function Vu(e){return arguments.length?(this._x=e,this):this._x}function ju(e){return e[1]}function qu(e){return arguments.length?(this._y=e,this):this._y}function Dn(e,t,n){var r=new es(t??Ku,n??ju,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function es(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function Yu(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Xe=Dn.prototype=es.prototype;Xe.copy=function(){var e=new es(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=Yu(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]=Yu(r));return e};Xe.add=Pu;Xe.addAll=Iu;Xe.cover=Mu;Xe.data=Gu;Xe.extent=Ou;Xe.find=Fu;Xe.remove=$u;Xe.removeAll=zu;Xe.root=Hu;Xe.size=Wu;Xe.visit=Uu;Xe.visitAfter=Bu;Xe.x=Vu;Xe.y=qu;function Le(e){return function(){return e}}function Et(e){return(e()-.5)*1e-6}function Xv(e){return e.x+e.vx}function Qv(e){return e.y+e.vy}function ts(e){var t,n,r,i=1,a=1;typeof e!="function"&&(e=Le(e==null?1:+e));function o(){for(var c,u=t.length,d,h,f,g,w,v,y=0;y<a;++y)for(d=Dn(t,Xv,Qv).visitAfter(s),c=0;c<u;++c)h=t[c],w=n[h.index],v=w*w,f=h.x+h.vx,g=h.y+h.vy,d.visit(b);function b(_,x,C,O,N){var j=_.data,P=_.r,R=w+P;if(j){if(j.index>h.index){var H=f-j.x-j.vx,Z=g-j.y-j.vy,G=H*H+Z*Z;G<R*R&&(H===0&&(H=Et(r),G+=H*H),Z===0&&(Z=Et(r),G+=Z*Z),G=(R-(G=Math.sqrt(G)))/G*i,h.vx+=(H*=G)*(R=(P*=P)/(v+P)),h.vy+=(Z*=G)*R,j.vx-=H*(R=1-R),j.vy-=Z*R)}return}return x>f+R||O<f-R||C>g+R||N<g-R}}function s(c){if(c.data)return c.r=n[c.data.index];for(var u=c.r=0;u<4;++u)c[u]&&c[u].r>c.r&&(c.r=c[u].r)}function l(){if(t){var c,u=t.length,d;for(n=new Array(u),c=0;c<u;++c)d=t[c],n[d.index]=+e(d,c,t)}}return o.initialize=function(c,u){t=c,r=u,l()},o.iterations=function(c){return arguments.length?(a=+c,o):a},o.strength=function(c){return arguments.length?(i=+c,o):i},o.radius=function(c){return arguments.length?(e=typeof c=="function"?c:Le(+c),l(),o):e},o}function Jv(e){return e.index}function Zu(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function ns(e){var t=Jv,n=d,r,i=Le(30),a,o,s,l,c,u=1;e==null&&(e=[]);function d(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function h(v){for(var y=0,b=e.length;y<u;++y)for(var _=0,x,C,O,N,j,P,R;_<b;++_)x=e[_],C=x.source,O=x.target,N=O.x+O.vx-C.x-C.vx||Et(c),j=O.y+O.vy-C.y-C.vy||Et(c),P=Math.sqrt(N*N+j*j),P=(P-a[_])/P*v*r[_],N*=P,j*=P,O.vx-=N*(R=l[_]),O.vy-=j*R,C.vx+=N*(R=1-R),C.vy+=j*R}function f(){if(o){var v,y=o.length,b=e.length,_=new Map(o.map((C,O)=>[t(C,O,o),C])),x;for(v=0,s=new Array(y);v<b;++v)x=e[v],x.index=v,typeof x.source!="object"&&(x.source=Zu(_,x.source)),typeof x.target!="object"&&(x.target=Zu(_,x.target)),s[x.source.index]=(s[x.source.index]||0)+1,s[x.target.index]=(s[x.target.index]||0)+1;for(v=0,l=new Array(b);v<b;++v)x=e[v],l[v]=s[x.source.index]/(s[x.source.index]+s[x.target.index]);r=new Array(b),g(),a=new Array(b),w()}}function g(){if(o)for(var v=0,y=e.length;v<y;++v)r[v]=+n(e[v],v,e)}function w(){if(o)for(var v=0,y=e.length;v<y;++v)a[v]=+i(e[v],v,e)}return h.initialize=function(v,y){o=v,c=y,f()},h.links=function(v){return arguments.length?(e=v,f(),h):e},h.id=function(v){return arguments.length?(t=v,h):t},h.iterations=function(v){return arguments.length?(u=+v,h):u},h.strength=function(v){return arguments.length?(n=typeof v=="function"?v:Le(+v),g(),h):n},h.distance=function(v){return arguments.length?(i=typeof v=="function"?v:Le(+v),w(),h):i},h}var ew={value:()=>{}};function Qu(){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 ta(n)}function ta(e){this._=e}function tw(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}})}ta.prototype=Qu.prototype={constructor:ta,on:function(e,t){var n=this._,r=tw(e+"",n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=nw(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Xu(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Xu(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 ta(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[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,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function nw(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Xu(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=ew,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var rs=Qu;var ar=0,Hr=0,zr=0,ed=1e3,na,Wr,ra=0,In=0,ia=0,Ur=typeof performance=="object"&&performance.now?performance:Date,td=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function os(){return In||(td(rw),In=Ur.now()+ia)}function rw(){In=0}function is(){this._call=this._time=this._next=null}is.prototype=aa.prototype={constructor:is,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?os():+n)+(t==null?0:+t),!this._next&&Wr!==this&&(Wr?Wr._next=this:na=this,Wr=this),this._call=e,this._time=n,as()},stop:function(){this._call&&(this._call=null,this._time=1/0,as())}};function aa(e,t,n){var r=new is;return r.restart(e,t,n),r}function nd(){os(),++ar;for(var e=na,t;e;)(t=In-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ar}function Ju(){In=(ra=Ur.now())+ia,ar=Hr=0;try{nd()}finally{ar=0,aw(),In=0}}function iw(){var e=Ur.now(),t=e-ra;t>ed&&(ia-=t,ra=e)}function aw(){for(var e,t=na,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:na=n);Wr=e,as(r)}function as(e){if(!ar){Hr&&(Hr=clearTimeout(Hr));var t=e-In;t>24?(e<1/0&&(Hr=setTimeout(Ju,e-Ur.now()-ia)),zr&&(zr=clearInterval(zr))):(zr||(ra=Ur.now(),zr=setInterval(iw,ed)),ar=1,td(Ju))}}function rd(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function id(e){return e.x}function ad(e){return e.y}var ow=10,sw=Math.PI*(3-Math.sqrt(5));function ss(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),a=0,o=.6,s=new Map,l=aa(d),c=rs("tick","end"),u=rd();e==null&&(e=[]);function d(){h(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function h(w){var v,y=e.length,b;w===void 0&&(w=1);for(var _=0;_<w;++_)for(n+=(a-n)*i,s.forEach(function(x){x(n)}),v=0;v<y;++v)b=e[v],b.fx==null?b.x+=b.vx*=o:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=o:(b.y=b.fy,b.vy=0);return t}function f(){for(var w=0,v=e.length,y;w<v;++w){if(y=e[w],y.index=w,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var b=ow*Math.sqrt(.5+w),_=w*sw;y.x=b*Math.cos(_),y.y=b*Math.sin(_)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function g(w){return w.initialize&&w.initialize(e,u),w}return f(),t={tick:h,restart:function(){return l.restart(d),t},stop:function(){return l.stop(),t},nodes:function(w){return arguments.length?(e=w,f(),s.forEach(g),t):e},alpha:function(w){return arguments.length?(n=+w,t):n},alphaMin:function(w){return arguments.length?(r=+w,t):r},alphaDecay:function(w){return arguments.length?(i=+w,t):+i},alphaTarget:function(w){return arguments.length?(a=+w,t):a},velocityDecay:function(w){return arguments.length?(o=1-w,t):1-o},randomSource:function(w){return arguments.length?(u=w,s.forEach(g),t):u},force:function(w,v){return arguments.length>1?(v==null?s.delete(w):s.set(w,g(v)),t):s.get(w)},find:function(w,v,y){var b=0,_=e.length,x,C,O,N,j;for(y==null?y=1/0:y*=y,b=0;b<_;++b)N=e[b],x=w-N.x,C=v-N.y,O=x*x+C*C,O<y&&(j=N,y=O);return j},on:function(w,v){return arguments.length>1?(c.on(w,v),t):c.on(w)}}}function ls(){var e,t,n,r,i=Le(-30),a,o=1,s=1/0,l=.81;function c(f){var g,w=e.length,v=Dn(e,id,ad).visitAfter(d);for(r=f,g=0;g<w;++g)t=e[g],v.visit(h)}function u(){if(e){var f,g=e.length,w;for(a=new Array(g),f=0;f<g;++f)w=e[f],a[w.index]=+i(w,f,e)}}function d(f){var g=0,w,v,y=0,b,_,x;if(f.length){for(b=_=x=0;x<4;++x)(w=f[x])&&(v=Math.abs(w.value))&&(g+=w.value,y+=v,b+=v*w.x,_+=v*w.y);f.x=b/y,f.y=_/y}else{w=f,w.x=w.data.x,w.y=w.data.y;do g+=a[w.data.index];while(w=w.next)}f.value=g}function h(f,g,w,v){if(!f.value)return!0;var y=f.x-t.x,b=f.y-t.y,_=v-g,x=y*y+b*b;if(_*_/l<x)return x<s&&(y===0&&(y=Et(n),x+=y*y),b===0&&(b=Et(n),x+=b*b),x<o&&(x=Math.sqrt(o*x)),t.vx+=y*f.value*r/x,t.vy+=b*f.value*r/x),!0;if(f.length||x>=s)return;(f.data!==t||f.next)&&(y===0&&(y=Et(n),x+=y*y),b===0&&(b=Et(n),x+=b*b),x<o&&(x=Math.sqrt(o*x)));do f.data!==t&&(_=a[f.data.index]*r/x,t.vx+=y*_,t.vy+=b*_);while(f=f.next)}return c.initialize=function(f,g){e=f,n=g,u()},c.strength=function(f){return arguments.length?(i=typeof f=="function"?f:Le(+f),u(),c):i},c.distanceMin=function(f){return arguments.length?(o=f*f,c):Math.sqrt(o)},c.distanceMax=function(f){return arguments.length?(s=f*f,c):Math.sqrt(s)},c.theta=function(f){return arguments.length?(l=f*f,c):Math.sqrt(l)},c}function cs(e){var t=Le(.1),n,r,i;typeof e!="function"&&(e=Le(e==null?0:+e));function a(s){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vx+=(i[l]-u.x)*r[l]*s}function o(){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 a.initialize=function(s){n=s,o()},a.strength=function(s){return arguments.length?(t=typeof s=="function"?s:Le(+s),o(),a):t},a.x=function(s){return arguments.length?(e=typeof s=="function"?s:Le(+s),o(),a):e},a}function us(e){var t=Le(.1),n,r,i;typeof e!="function"&&(e=Le(e==null?0:+e));function a(s){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vy+=(i[l]-u.y)*r[l]*s}function o(){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 a.initialize=function(s){n=s,o()},a.strength=function(s){return arguments.length?(t=typeof s=="function"?s:Le(+s),o(),a):t},a.y=function(s){return arguments.length?(e=typeof s=="function"?s:Le(+s),o(),a):e},a}var lw=9,oa=6,Br=18,cw=32,ld=9,or=lw+ld;function ds(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+cw));return oa+(Br-oa)*n}function hs(e){return e+ld}var uw=300,cd=1,od=.001;function sd(e){return e==="contains"||e==="anchored-at"}function dw(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function hw(e){let t=[],n=new Set;for(let a of e.nodes)n.has(a.id)||(n.add(a.id),t.push(a.id));let r=[],i=new Set;for(let a of e.edges){if(a.source===a.target||!n.has(a.source)||!n.has(a.target))continue;let o=`${a.source}\0${a.target}\0${a.kind}`;i.has(o)||(i.add(o),r.push(a))}return{ids:t,edges:r}}function ps(e){let t=ns(e.links).id(n=>n.id).distance(n=>sd(n.kind)?at.containsRest:at.relationDistance).strength(n=>sd(n.kind)?at.containsStrength:at.relationStrength).iterations(2);return ss(e.nodes).randomSource(dw(e.seed??cd)).force("charge",ls().strength(at.charge).distanceMax(at.chargeMax)).force("link",t).force("collide",ts(n=>n.r??or).strength(1)).force("x",cs(0).strength(at.center)).force("y",us(0).strength(at.center)).stop()}function pw(e,t,n){let r=ps({nodes:e,links:t.map(({source:i,target:a,kind:o})=>({source:i,target:a,kind:o})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(od).alphaDecay(n.ticks>0?1-Math.pow(od,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function ud(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??uw)),{ids:r,edges:i}=hw(e),a=r.map(l=>{let c=t.initial?.get(l),u={id:l,vx:0,vy:0};return c!==void 0&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&(u.x=c.x,u.y=c.y,t.pinWarm===!0&&(u.fx=c.x,u.fy=c.y)),u}),o=new Map;for(let l of i)o.set(l.source,(o.get(l.source)??0)+1),o.set(l.target,(o.get(l.target)??0)+1);for(let l of a)l.r=hs(ds(o.get(l.id)??0));a.length>1&&pw(a,i,{ticks:n,seed:t.seed??cd,warm:t.initial!==void 0});let s=new Map;for(let l of a)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}var fw=Object.fromEntries(Object.entries(ve).map(([e,{colors:t}])=>[e,{accent:t.accent,success:t.ok,warning:t.warn,dim:t.dim,text:t.fg,muted:t.faint,line:t["line-strong"],ground:t.bg}]));function Ot(e){let t=fw[Hi(e)];return typeof e=="string"?t:{...t,accent:Pc(e.theme,e.accent)}}var gw={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},mw={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function vw(e,t){return Ot(t)[gw[e]]}function dd(e,t){return Ot(t)[mw[e]]}function ww(e,t){return yw(e)?Kr(dd(e,t),t,bw):dd(e,t)}function yw(e){return e==="contains"||e==="anchored-at"}var gs=.85,bw=.3;function Mn(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),a=r(t);if(i===null||a===null)return e;let o=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,c)=>Math.round(l+(c-l)*o).toString(16).padStart(2,"0");return`#${s(i[0],a[0])}${s(i[1],a[1])}${s(i[2],a[2])}`}function Kr(e,t,n=gs){return Mn(e,Ot(t).ground,n)}var xw={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},fs=1.6,hd=32,kw=hd/2;function _w(e,t=hd){if(t<=0)return e.length>0?"…":e;if(e.length<=t)return e;let n=t-1,i=e.slice(0,n).lastIndexOf(" "),a=i>=kw?i:n;return`${e.slice(0,a).trimEnd()}…`}function Tw(e){let t=Ut(e.provenance),n=pt(e);return _w(t===""?n:`${t} ${n}`)}var Sw=6,Ew=6;function Rw(e){return(t,n,r)=>{if(n.label===null||n.label===""||n.forceLabel===!0)return;let i=Ot(e);t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=Ew,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+Sw),t.restore()}}function ms(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=0;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(a++,s.x<t&&(t=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>i&&(i=s.y));if(a===0)return null;let o=Math.max(Br,(or*4-Math.max(r-t,i-n))/2);return{x:[t-o,r+o],y:[n-o,i+o]}}var Aw=1.2,Cw=or*10;function pd(e,t){let n=ms(t);if(e===null||n===null)return null;let r=Math.max(e.x[1]-e.x[0],e.y[1]-e.y[0]),i=r>0&&Number.isFinite(r)?r:1,a=Math.max(n.x[1]-n.x[0],n.y[1]-n.y[0],Cw),o=s=>(s[0]+s[1])/2;return{x:.5+(o(n.x)-o(e.x))/i,y:.5+(o(n.y)-o(e.y))/i,ratio:Math.min(1,a*Aw/i)}}var fd={nodes:[],edges:[]};function gd(e){return`${e.source}\0${e.target}\0${e.kind}`}function Lw(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 a=gd(i);r.has(a)||(r.add(a),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function md(e,t,n,r,i){let a=new Map;for(let d of e){if(a.has(d.id))continue;let h=n.get(d.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||a.set(d.id,d)}let o=new Set(a.keys()),s=Lw(t,o),l=[];for(let[d,h]of a){let f=n.get(d),g=ds(s.get(d)??0);l.push({id:d,x:f.x,y:f.y,size:g,label:Tw(h),color:i?.get(d)??vw(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(g),type:"circle"})}let c=[],u=new Set;for(let d of t){if(d.source===d.target||!o.has(d.source)||!o.has(d.target))continue;let h=gd(d);u.has(h)||(u.add(h),c.push({key:h,source:d.source,target:d.target,size:xw[d.kind],color:ww(d.kind,r),kind:d.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function vd(e,t,n=1,r="neighbourhood"){return(i,a,o)=>e===null||n<=0?{}:r==="spotlight"?Gw(e,t??null,n,i,a,o):i===t&&e.has(i)?{zIndex:a.zIndex+Vr*2,size:a.size*Bt($w,n)}:e.has(i)?{zIndex:a.zIndex+Vr,size:a.size*Bt(zw,n)}:{color:Kr(a.color,o,gs*n),label:n>=bd?null:a.label,zIndex:0}}var wd=.92,Nw=1.4,Pw=1.7,Dw=.75,Iw=40,Mw="warning";function Gw(e,t,n,r,i,a){let o=n>=bd;return r===t?{zIndex:i.zIndex+Vr*2,size:i.size*Bt(Pw,n),forceLabel:o}:e.has(r)?{zIndex:i.zIndex+Vr,size:i.size*Bt(Nw,n),forceLabel:o&&e.size<=Iw}:{color:Kr(i.color,a,wd*n),label:o?null:i.label,size:i.size*Bt(Dw,n),zIndex:0}}var Ow=60,Fw=.004;function yd(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/Ow);return Math.abs(t-i)<Fw?t:i}function Bt(e,t){return 1+(e-1)*t}var bd=.5,$w=1.45,zw=1.15,Vr=Br+1;function xd(e,t,n=1,r="neighbourhood"){return(i,a,o)=>e===null||n<=0?{}:r==="spotlight"?!e.has(a.source)||!e.has(a.target)?{color:Kr(a.color,o,wd*n)}:{zIndex:2,size:a.size*Bt(fs*1.35,n),color:Mn(a.color,Ot(o)[Mw],n)}:!e.has(a.source)||!e.has(a.target)?{color:Kr(a.color,o,gs*n)}:t!=null&&(a.source===t||a.target===t)?{zIndex:2,size:a.size*Bt(fs*1.35,n),color:Mn(a.color,Ot(o).accent,n)}:{zIndex:1,size:a.size*Bt(fs,n)}}var Hw={searched:{slot:"warning",blend:.35,growth:1.08},read:{slot:"success",blend:.85,growth:1.3},wrote:{slot:"accent",blend:1,growth:1.5}};function kd(e,t,n,r){if(e===void 0||!(e.strength>0))return{};let i=Hw[e.kind],a=Math.min(1,e.strength);return{color:Mn(t.color,Ot(n)[i.slot],i.blend*a),size:t.size*Bt(i.growth,a),zIndex:t.zIndex+Vr*3,label:r}}var _d=(oa+Br)/2,Ww=30;function vs(e){return e<Ww?0:_d}var Uw=or*4,Bw=1;function Td(e){let t=Ot(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Bw,labelGridCellSize:Uw,labelRenderedSizeThreshold:_d,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:or,defaultDrawNodeHover:Rw(e),allowInvalidContainer:!0}}function Sd(e){return e==="contains"||e==="anchored-at"}function Kw(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)Sd(i.kind)&&i.source!==i.target&&(!n.has(i.source)||!n.has(i.target)||r.has(i.target)||r.set(i.target,i.source));return r}function Vw(e,t){let n=Kw(e,t),r=new Map;for(let i of e){let a=i.id,o=i.id,s=0,l=new Set([a]);for(;;){let c=n.get(a);if(c===void 0||l.has(c))break;l.add(c),o=a,a=c,s++}r.set(i.id,{key:o,depth:Math.max(0,s-1)})}return r}function jw(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var qw={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},Yw=3;function Zw(e,t){let n=qw[ve[Hi(t)].scheme],i=[...jw(e).entries()].sort((o,s)=>s[1]-o[1]||(o[0]<s[0]?-1:o[0]>s[0]?1:0)),a=new Map;return i.forEach(([o],s)=>a.set(o,n[s*Yw%n.length])),a}var Xw=.11,Qw=.34;function Jw(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return Mn(e,Ot(n).ground,Math.min(Qw,r*Xw))}var ey=.26,ty=.55;function ny(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let a of t){let o=Math.min(ey,ty-i);if(o<=0)break;i+=o,r=Mn(r,a,o)}return r}function Ed(e,t,n){let r=Vw(e,t),i=new Map;for(let[u,d]of r)i.set(u,d.key);let a=Zw(i,n),o=new Set(e.map(u=>u.id)),s=new Map,l=(u,d)=>{let h=r.get(u)?.key,f=r.get(d)?.key;if(h===void 0||f===void 0||h===f)return;let g=s.get(u);g===void 0?s.set(u,new Set([f])):g.add(f)};for(let u of t)Sd(u.kind)||u.source!==u.target&&(!o.has(u.source)||!o.has(u.target)||(l(u.source,u.target),l(u.target,u.source)));let c=new Map;for(let u of e){let d=r.get(u.id);if(d===void 0)continue;let h=a.get(d.key);if(h===void 0)continue;let f=Jw(h,d.depth,n),g=[...s.get(u.id)??[]].sort().map(w=>a.get(w)).filter(w=>w!==void 0);c.set(u.id,ny(f,g,n))}return c}function ws(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 ry=300,iy=1;function ay(e,t,n){let r=new Map(n??[]);if(r.size>0)for(let a of t){if(a.kind!=="contains"&&a.kind!=="anchored-at"||r.has(a.target))continue;let o=r.get(a.source);o!==void 0&&r.set(a.target,{x:o.x,y:o.y})}let i={ticks:ry,seed:iy,pinWarm:!0};return r.size>0&&(i.initial=r),ud({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function oy(e,t){let n=0,r=0;for(let a of e){let o=ws(a.id);n^=o,r=r+o>>>0}for(let a of t){let o=ws(`${a.source}\0${a.target}\0${a.kind}`);n^=o,r=r+o>>>0}return[...[e.length,t.length,n>>>0,r].map(a=>a.toString(16)),ws(JSON.stringify(at)).toString(16)].join("-")}var Ad="pi-weave.graph.positions.v4";function Rd(e){return Math.round(e*10)/10}function sy(e,t){let n={};for(let[r,i]of t)n[r]=[Rd(i.x),Rd(i.y)];return JSON.stringify({v:4,key:e,at:n})}function ly(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!==4||r.key!==t)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let a=new Map;for(let[o,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,c]=s;if(typeof l!="number"||typeof c!="number"||!Number.isFinite(l)||!Number.isFinite(c))return null;a.set(o,{x:l,y:c})}return a.size===0?null:a}function cy(e,t){let n;try{n=e.getItem(Ad)}catch{return null}return ly(n,t)}function uy(e,t,n){try{return e.setItem(Ad,sy(t,n)),!0}catch{return!1}}function Cd(e,t,n){let r=oy(t,n),i=cy(e,r);if(i!==null&&t.every(o=>i.has(o.id)))return{key:r,positions:i,cached:!0};let a=ay(t,n);return uy(e,r,a),{key:r,positions:a,cached:!1}}function sa(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(i=>i.id===t);if(n===void 0)return null;let r=t.startsWith("artifact:")?"HTML artifact":t.startsWith("vfolder:")?"Folder":n.kind;return{id:t,title:n.label,kind:r,icon:Pn(n.kind)}}function dy(e){return{expanded:new Set(Xi(e,new Set).clusters.keys())}}function Nd(e,t){return t!==null?t:e===null?{expanded:new Set}:dy(Ln(e))}function hy(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function py(e,t){return t===null?null:Zi(t,e)}function fy(e,t,n){return t===null?n:Zi(t,e)}function Pd(e,t,n){return n===null?{highlight:e,selectedId:t,style:"neighbourhood"}:{highlight:n,selectedId:t,style:"spotlight"}}function Dd(e,t,n){return n.style==="spotlight"?t===null?n:{...n,selectedId:t}:{highlight:fy(e,t,n.highlight),selectedId:t??n.selectedId,style:"neighbourhood"}}var Id="fit",Md="frame the whole graph",la={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Gd(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function gy(e,t){return e===null?"Loading…":e.model.nodes.length===0?"Nothing here yet — add a note to get started.":t===0?"Nothing to draw at this expansion.":null}var my="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",Ld={graph:fd,highlight:null,key:"",cached:!1,clusters:new Map,representative:new Map,visible:0,total:0,empty:"Loading…"};function Od(e,t,n,r,i,a=!1,o=!0){if(e===null)return a?{...Ld,empty:my}:Ld;let s=Ln(e),l=Xi(s,n.expanded),u=n.expanded.has("vault")?l.edges.filter(g=>g.source!=="vault"&&g.target!=="vault"):l.edges,d=Cd(r,l.nodes,u),h=o?Ed(l.nodes,u,i):void 0;return{graph:md(l.nodes,u,d.positions,i,h),highlight:py(u,t),key:d.key,cached:d.cached,clusters:l.clusters,representative:l.representative,visible:l.nodes.length,total:s.nodes.length,empty:gy(e,l.nodes.length)}}function Fd(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:hy(e,n),selectedId:n}}function ks(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Fn=ks();function Vd(e){Fn=e}var Gn={exec:()=>null};function sr(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function re(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(je.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,t)};return r}var vy=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),je={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:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:sr(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:sr(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:sr(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:sr(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:sr(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:sr(e=>new RegExp(`^ {0,${e}}>`))},wy=/^(?:[ \t]*(?:\n|$))+/,yy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,by=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,xy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_s=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,jd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qd=re(jd).replace(/bull/g,_s).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(),ky=re(jd).replace(/bull/g,_s).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(),Ts=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,_y=/^[^\n]+/,Ss=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ty=re(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ss).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Sy=re(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,_s).getRegex(),pa="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",Es=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ey=re("^ {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",Es).replace("tag",pa).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Yd=e=>re(Ts).replace("hr",Yr).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",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",pa).getRegex(),Ry=Yd(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Ay=Yd(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Cy=re(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ay).getRegex(),Rs={blockquote:Cy,code:yy,def:Ty,fences:by,heading:xy,hr:Yr,html:Ey,lheading:qd,list:Sy,newline:wy,paragraph:Ry,table:Gn,text:_y},$d=re("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yr).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",pa).getRegex(),Ly={...Rs,lheading:ky,table:$d,paragraph:re(Ts).replace("hr",Yr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",$d).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",pa).getRegex()},Ny={...Rs,html:re(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Es).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:Gn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:re(Ts).replace("hr",Yr).replace("heading",` *#{1,6} *[^
29
- ]`).replace("lheading",qd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Py=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Dy=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Zd=/^( {2,}|\\)\n(?!\s*$)/,Iy=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kt=/[\p{P}\p{S}]/u,lr=/[\s\p{P}\p{S}]/u,Zr=/[^\s\p{P}\p{S}]/u,My=re(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lr).getRegex(),Gy=/[\p{Pi}\p{Ps}"']/u,Xd=/(?!~)[\p{P}\p{S}]/u,Oy=/(?!~)[\s\p{P}\p{S}]/u,Fy=/(?:[^\s\p{P}\p{S}]|~)/u,$y=re(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",vy?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Qd=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,zy=re(Qd,"u").replace(/punct/g,Kt).getRegex(),Hy=re(Qd,"u").replace(/punct/g,Xd).getRegex(),Wy=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Uy=re(Wy,"u").replace(/openQuote/g,Gy).replace(/punct/g,Kt).getRegex(),Jd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",By=re(Jd,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Kt).getRegex(),Ky=re(Jd,"gu").replace(/notPunctSpace/g,Fy).replace(/punctSpace/g,Oy).replace(/punct/g,Xd).getRegex(),Vy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",jy=re(Vy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Kt).getRegex(),qy=re("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Kt).getRegex(),Yy="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Zy=re(Yy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Kt).getRegex(),Xy=re(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Kt).getRegex(),Qy="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Jy=re(Qy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Kt).getRegex(),eb=re(/\\(punct)/,"gu").replace(/punct/g,Kt).getRegex(),tb=re(/^<(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(),nb=re(Es).replace("(?:-->|$)","-->").getRegex(),rb=re("^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",nb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ua=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ib=re(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ua).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),eh=re(/^!?\[(label)\]\[(ref)\]/).replace("label",ua).replace("ref",Ss).getRegex(),th=re(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ss).getRegex(),ab=re("reflink|nolink(?!\\()","g").replace("reflink",eh).replace("nolink",th).getRegex(),zd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,As={_backpedal:Gn,anyPunctuation:eb,autolink:tb,blockSkip:$y,br:Zd,code:Dy,del:Gn,delLDelim:Gn,delRDelim:Gn,emStrongLDelim:zy,emStrongRDelimAst:By,emStrongRDelimUnd:qy,escape:Py,link:ib,nolink:th,punctuation:My,reflink:eh,reflinkSearch:ab,tag:rb,text:Iy,url:Gn},ob={...As,emStrongLDelim:Uy,emStrongRDelimAst:jy,emStrongRDelimUnd:Zy,link:re(/^!?\[(label)\]\((.*?)\)/).replace("label",ua).getRegex(),reflink:re(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ua).getRegex()},ys={...As,emStrongRDelimAst:Ky,emStrongLDelim:Hy,delLDelim:Xy,delRDelim:Jy,url:re(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",zd).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:re(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",zd).getRegex()},sb={...ys,br:re(Zd).replace("{2,}","*").getRegex(),text:re(ys.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ca={normal:Rs,gfm:Ly,pedantic:Ny},jr={normal:As,gfm:ys,breaks:sb,pedantic:ob},lb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Hd=e=>lb[e];function Ft(e,t){if(t){if(je.escapeTest.test(e))return e.replace(je.escapeReplace,Hd)}else if(je.escapeTestNoEncode.test(e))return e.replace(je.escapeReplaceNoEncode,Hd);return e}function Wd(e){try{e=encodeURI(e).replace(je.percentDecode,"%")}catch{return null}return e}function Ud(e,t){let n=e.replace(je.findPipe,(a,o,s)=>{let l=!1,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(je.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(je.slashPipe,"|");return r}function un(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Bd(e){let t=e.split(`
28
+ ${t.replace(/^\s*\n/,"").trimEnd()}`}var zv=["title","description","path","size","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","link references","warning","stale","preview","root","notes","state"];function jo(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 zv){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let a=[];for(let s of e.edges){if(s.source!==t)continue;let l=n.get(s.target);l&&a.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${pt(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let o=[];for(let s of e.edges){if(s.kind!=="links-to"||s.target!==t)continue;let l=n.get(s.source);l&&o.push({id:`backlink:${s.source}`,target:s.source,label:`← ${pt(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:pt(r),kind:r.kind,provenance:r.provenance,meta:i,links:a,backlinks:o}}function Zi(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 Hv=["contains","anchored-at"];function Wv(e){return Hv.includes(e)}function Xi(e,t){let n=new Map;for(let h of e.nodes)n.set(h.id,h);let r=Uv(e,n),i=uu(e),a=new Set,o=h=>{if(!a.has(h)&&(a.add(h),!!t.has(h)))for(let f of r.get(h)??[])o(f)};for(let h of i)o(h);let s=new Map;for(let h of r.keys())s.set(h,Bv(h,r));let l=new Map;for(let h of e.nodes)if(!(!a.has(h.id)||t.has(h.id)))for(let f of s.get(h.id)??[])!a.has(f)&&!l.has(f)&&l.set(f,h.id);for(let h of e.nodes)!a.has(h.id)&&!l.has(h.id)&&a.add(h.id);let c=new Map;for(let[h,f]of r){let g=s.get(h);c.set(h,{children:f,descendants:g,members:g.filter(w=>l.get(w)===h),provenance:Kv(g,n),expanded:t.has(h)})}let u=new Set,d=[];for(let h of e.nodes)a.has(h.id)?d.push(h):u.add(h.id);return{nodes:d,edges:Vv(e.edges,a,l),clusters:c,hidden:u,representative:l,roots:i}}function Uv(e,t){let n=new Map;for(let r of e.edges){if(!Wv(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 Bv(e,t){let n=[],r=new Set([e]),i=a=>{for(let o of t.get(a)??[])r.has(o)||(r.add(o),n.push(o),i(o))};return i(e),n}function Kv(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 Vv(e,t,n){let r=o=>t.has(o)?o:n.get(o),i=[],a=new Set;for(let o of e){let s=r(o.source),l=r(o.target);if(s===void 0||l===void 0||s===l)continue;let c=`${s}\0${l}\0${o.kind}`;a.has(c)||(a.add(c),i.push({source:s,target:l,kind:o.kind}))}return i}function qo(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 rr=[null,"human","agent","generated"];function pu(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function Xo(e,t){let n=new Set(e.expanded).add("vault"),r="";for(let i of t?t.split("/"):[])r=r?`${r}/${i}`:i,n.add(`vfolder:${r}`);return{...e,expanded:n,query:"",provFilter:null}}function Ln(e){return{...e.model,danglingLinks:e.dangling}}function fu(e,t){return e===null?[]:Wo(Ln(e),t)}var ir="vfolder:\0draft";function gu(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function mu(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function vu(e,t){if(t===null)return[...e];let n={id:ir,depth:t===""?1:t.split("/").length+1,hasKids:!1,expanded:!1,label:"",kind:"module",provenance:null,meta:null};if(t==="")return[...e,n];let r=e.findIndex(a=>a.id===`vfolder:${t}`);if(r===-1)return[...e,n];let i=r+1;for(;i<e.length&&e[i].depth>e[r].depth;)i++;return[...e.slice(0,i),n,...e.slice(i)]}function Qo(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function jv(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return n.add(t),{...e,expanded:n}}function qv(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function Jo(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function es(e){return e.startsWith("note:")?{type:"note",slug:e.slice(5)}:e.startsWith("artifact:")?{type:"artifact",slug:e.slice(9)}:null}function Nn(e){return e==="vault"?{type:"vault",path:""}:e.startsWith("note:")?{type:"note",path:e.slice(5)}:e.startsWith("artifact:")?{type:"artifact",path:e.slice(9)}:e.startsWith("vfolder:")?{type:"folder",path:e.slice(8)}:null}function Ji(e,t){if(t.type==="note")return[t.path];if(t.type!=="folder"||e===null)return[];let n=`note:${t.path}/`;return e.model.nodes.filter(r=>r.kind==="note"&&r.id.startsWith(n)).map(r=>r.id.slice(5))}function wu(e,t){return e===null?!1:t.type==="note"?e===`note:${t.path}`:t.type==="artifact"?e===`artifact:${t.path}`:t.type==="folder"?e===`vfolder:${t.path}`||["vfolder:","note:","artifact:"].some(n=>e.startsWith(`${n}${t.path}/`)):!1}function ts(e){return e.type==="folder"}function yu(e,t,n){return ts(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function bu(e,t){return e.query===t?e:{...e,query:t}}function xu(e){let t=rr.indexOf(e.provFilter),n=rr[(t+1)%rr.length]??null;return{...e,provFilter:n}}function ku(e){return{...e,showInternals:!e.showInternals}}function ea(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function Zo(e,t){return e[t]?.id??null}function Yo(e,t,n){if(e.length===0)return null;let r=ea(e,t),i=r===-1?n>0?-1:e.length:r;return Zo(e,Math.min(e.length-1,Math.max(0,i+n)))}function Yv(e,t){let n=ea(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 Zv={j:"ArrowDown",k:"ArrowUp"};function Xv(e){return Zv[e]??e}function _u(e,t,n,r,i=!1){let a={state:t,selectedId:n,handled:!1};if(i)return a;let o=d=>({state:t,selectedId:d,handled:!0}),s=Xv(r);if(s==="ArrowDown")return o(Yo(e,n,1));if(s==="ArrowUp")return o(Yo(e,n,-1));if(s==="Home")return o(Zo(e,0));if(s==="End")return o(Zo(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return a;let l=ea(e,n),c=l===-1?void 0:e[l];if(c===void 0||n===null)return a;if(s==="ArrowRight")return c.hasKids?c.expanded?o(Yo(e,n,1)):{state:jv(t,n),selectedId:n,handled:!0}:a;if(c.hasKids&&c.expanded)return{state:qv(t,n),selectedId:n,handled:!0};let u=Yv(e,n);return u===null?a:o(u)}var Qv={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Pn(e){return Qv[e]}var Jv={human:"●",agent:"◐",generated:"○"};function Bt(e){return e===null?"":Jv[e]}function un(e){return e===null?"":`${e}-authored`}function Tu(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function ew(e){let t=e.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let a of n.splice(i+1))for(let[o,s]of a.entries())t[s]={posinset:o+1,setsize:a.length}};for(let[i,a]of e.entries()){r(a.depth);let o=n[a.depth];if(o===void 0){for(o=[];n.length<a.depth;)n.push([]);n.push(o)}o.push(i)}return r(-1),t}function tw(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:Tu(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:Pn(e.kind),provenance:e.provenance,provenanceGlyph:Bt(e.provenance),provenanceTitle:un(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:Bo(e.meta,n),level:e.depth+1}}function Su(e,t,n){let r=ew(e);return e.map((i,a)=>tw(i,t,n,r[a]))}function Eu(e,t){return ea(e,t)===-1?null:Tu(t)}function Ru(e){return{"--weave-depth":String(Math.max(0,e))}}function Qi(e){return e===null?"all":e}function Au(e){let t=rr.indexOf(e),n=rr[(t+1)%rr.length]??null;return`provenance filter: ${Qi(e)} — click for ${Qi(n)}`}function Cu(e){return e?"internals":"knowledge"}function Lu(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 Nu="filter…",Pu="Vault and repository",Du="Filter the tree",Iu="Filter the tree (/)";function Mu(e,t,n){if(e===null)return"loading…";let r=Uo(Ln(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 Gu(e){return e.length===1?"1 row":`${e.length} rows`}function Ou(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Fu(this.cover(t,n),t,n,e)}function Fu(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,l=e._y0,c=e._x1,u=e._y1,d,h,f,g,w,v,y,b;if(!a)return e._root=o,e;for(;a.length;)if((w=t>=(d=(s+c)/2))?s=d:c=d,(v=n>=(h=(l+u)/2))?l=h:u=h,i=a,!(a=a[y=v<<1|w]))return i[y]=o,e;if(f=+e._x.call(null,a.data),g=+e._y.call(null,a.data),t===f&&n===g)return o.next=a,i?i[y]=o:e._root=o,e;do i=i?i[y]=new Array(4):e._root=new Array(4),(w=t>=(d=(s+c)/2))?s=d:c=d,(v=n>=(h=(l+u)/2))?l=h:u=h;while((y=v<<1|w)===(b=(g>=h)<<1|f>=d));return i[b]=a,i[y]=o,e}function $u(e){var t,n,r=e.length,i,a,o=new Array(r),s=new Array(r),l=1/0,c=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<l&&(l=i),i>u&&(u=i),a<c&&(c=a),a>d&&(d=a));if(l>u||c>d)return this;for(this.cover(l,c).cover(u,d),n=0;n<r;++n)Fu(this,o[n],s[n],e[n]);return this}function zu(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,l,c;n>e||e>=i||r>t||t>=a;)switch(c=(t<r)<<1|e<n,l=new Array(4),l[c]=s,s=l,o*=2,c){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function Hu(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Wu(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 He(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Uu(e,t,n){var r,i=this._x0,a=this._y0,o,s,l,c,u=this._x1,d=this._y1,h=[],f=this._root,g,w;for(f&&h.push(new He(f,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);g=h.pop();)if(!(!(f=g.node)||(o=g.x0)>u||(s=g.y0)>d||(l=g.x1)<i||(c=g.y1)<a))if(f.length){var v=(o+l)/2,y=(s+c)/2;h.push(new He(f[3],v,y,l,c),new He(f[2],o,y,v,c),new He(f[1],v,s,l,y),new He(f[0],o,s,v,y)),(w=(t>=y)<<1|e>=v)&&(g=h[h.length-1],h[h.length-1]=h[h.length-1-w],h[h.length-1-w]=g)}else{var b=e-+this._x.call(null,f.data),_=t-+this._y.call(null,f.data),x=b*b+_*_;if(x<n){var R=Math.sqrt(n=x);i=e-R,a=t-R,u=e+R,d=t+R,r=f.data}}return r}function Bu(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,l=this._x1,c=this._y1,u,d,h,f,g,w,v,y;if(!n)return this;if(n.length)for(;;){if((g=u>=(h=(o+l)/2))?o=h:l=h,(w=d>=(f=(s+c)/2))?s=f:c=f,t=n,!(n=n[v=w<<1|g]))return this;if(!n.length)break;(t[v+1&3]||t[v+2&3]||t[v+3&3])&&(r=t,y=v)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[v]=a: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[y]=n:this._root=n),this):(this._root=a,this)}function Ku(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Vu(){return this._root}function ju(){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,a,o,s,l;for(r&&t.push(new He(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,l=n.y1)&&r.length){var c=(a+s)/2,u=(o+l)/2;(i=r[3])&&t.push(new He(i,c,u,s,l)),(i=r[2])&&t.push(new He(i,a,u,c,l)),(i=r[1])&&t.push(new He(i,c,o,s,u)),(i=r[0])&&t.push(new He(i,a,o,c,u))}return this}function Yu(e){var t=[],n=[],r;for(this._root&&t.push(new He(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,l=r.x1,c=r.y1,u=(o+l)/2,d=(s+c)/2;(a=i[0])&&t.push(new He(a,o,s,u,d)),(a=i[1])&&t.push(new He(a,u,s,l,d)),(a=i[2])&&t.push(new He(a,o,d,u,c)),(a=i[3])&&t.push(new He(a,u,d,l,c))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Zu(e){return e[0]}function Xu(e){return arguments.length?(this._x=e,this):this._x}function Qu(e){return e[1]}function Ju(e){return arguments.length?(this._y=e,this):this._y}function Dn(e,t,n){var r=new ns(t??Zu,n??Qu,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function ns(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function ed(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Xe=Dn.prototype=ns.prototype;Xe.copy=function(){var e=new ns(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=ed(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]=ed(r));return e};Xe.add=Ou;Xe.addAll=$u;Xe.cover=zu;Xe.data=Hu;Xe.extent=Wu;Xe.find=Uu;Xe.remove=Bu;Xe.removeAll=Ku;Xe.root=Vu;Xe.size=ju;Xe.visit=qu;Xe.visitAfter=Yu;Xe.x=Xu;Xe.y=Ju;function Le(e){return function(){return e}}function Et(e){return(e()-.5)*1e-6}function nw(e){return e.x+e.vx}function rw(e){return e.y+e.vy}function rs(e){var t,n,r,i=1,a=1;typeof e!="function"&&(e=Le(e==null?1:+e));function o(){for(var c,u=t.length,d,h,f,g,w,v,y=0;y<a;++y)for(d=Dn(t,nw,rw).visitAfter(s),c=0;c<u;++c)h=t[c],w=n[h.index],v=w*w,f=h.x+h.vx,g=h.y+h.vy,d.visit(b);function b(_,x,R,O,N){var j=_.data,P=_.r,A=w+P;if(j){if(j.index>h.index){var H=f-j.x-j.vx,Z=g-j.y-j.vy,G=H*H+Z*Z;G<A*A&&(H===0&&(H=Et(r),G+=H*H),Z===0&&(Z=Et(r),G+=Z*Z),G=(A-(G=Math.sqrt(G)))/G*i,h.vx+=(H*=G)*(A=(P*=P)/(v+P)),h.vy+=(Z*=G)*A,j.vx-=H*(A=1-A),j.vy-=Z*A)}return}return x>f+A||O<f-A||R>g+A||N<g-A}}function s(c){if(c.data)return c.r=n[c.data.index];for(var u=c.r=0;u<4;++u)c[u]&&c[u].r>c.r&&(c.r=c[u].r)}function l(){if(t){var c,u=t.length,d;for(n=new Array(u),c=0;c<u;++c)d=t[c],n[d.index]=+e(d,c,t)}}return o.initialize=function(c,u){t=c,r=u,l()},o.iterations=function(c){return arguments.length?(a=+c,o):a},o.strength=function(c){return arguments.length?(i=+c,o):i},o.radius=function(c){return arguments.length?(e=typeof c=="function"?c:Le(+c),l(),o):e},o}function iw(e){return e.index}function td(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function is(e){var t=iw,n=d,r,i=Le(30),a,o,s,l,c,u=1;e==null&&(e=[]);function d(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function h(v){for(var y=0,b=e.length;y<u;++y)for(var _=0,x,R,O,N,j,P,A;_<b;++_)x=e[_],R=x.source,O=x.target,N=O.x+O.vx-R.x-R.vx||Et(c),j=O.y+O.vy-R.y-R.vy||Et(c),P=Math.sqrt(N*N+j*j),P=(P-a[_])/P*v*r[_],N*=P,j*=P,O.vx-=N*(A=l[_]),O.vy-=j*A,R.vx+=N*(A=1-A),R.vy+=j*A}function f(){if(o){var v,y=o.length,b=e.length,_=new Map(o.map((R,O)=>[t(R,O,o),R])),x;for(v=0,s=new Array(y);v<b;++v)x=e[v],x.index=v,typeof x.source!="object"&&(x.source=td(_,x.source)),typeof x.target!="object"&&(x.target=td(_,x.target)),s[x.source.index]=(s[x.source.index]||0)+1,s[x.target.index]=(s[x.target.index]||0)+1;for(v=0,l=new Array(b);v<b;++v)x=e[v],l[v]=s[x.source.index]/(s[x.source.index]+s[x.target.index]);r=new Array(b),g(),a=new Array(b),w()}}function g(){if(o)for(var v=0,y=e.length;v<y;++v)r[v]=+n(e[v],v,e)}function w(){if(o)for(var v=0,y=e.length;v<y;++v)a[v]=+i(e[v],v,e)}return h.initialize=function(v,y){o=v,c=y,f()},h.links=function(v){return arguments.length?(e=v,f(),h):e},h.id=function(v){return arguments.length?(t=v,h):t},h.iterations=function(v){return arguments.length?(u=+v,h):u},h.strength=function(v){return arguments.length?(n=typeof v=="function"?v:Le(+v),g(),h):n},h.distance=function(v){return arguments.length?(i=typeof v=="function"?v:Le(+v),w(),h):i},h}var aw={value:()=>{}};function rd(){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 ta(n)}function ta(e){this._=e}function ow(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}})}ta.prototype=rd.prototype={constructor:ta,on:function(e,t){var n=this._,r=ow(e+"",n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=sw(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=nd(n[i],e.name,t);else if(t==null)for(i in n)n[i]=nd(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 ta(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[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,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function sw(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function nd(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=aw,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var as=rd;var ar=0,Hr=0,zr=0,ad=1e3,na,Wr,ra=0,In=0,ia=0,Ur=typeof performance=="object"&&performance.now?performance:Date,od=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ls(){return In||(od(lw),In=Ur.now()+ia)}function lw(){In=0}function os(){this._call=this._time=this._next=null}os.prototype=aa.prototype={constructor:os,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ls():+n)+(t==null?0:+t),!this._next&&Wr!==this&&(Wr?Wr._next=this:na=this,Wr=this),this._call=e,this._time=n,ss()},stop:function(){this._call&&(this._call=null,this._time=1/0,ss())}};function aa(e,t,n){var r=new os;return r.restart(e,t,n),r}function sd(){ls(),++ar;for(var e=na,t;e;)(t=In-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ar}function id(){In=(ra=Ur.now())+ia,ar=Hr=0;try{sd()}finally{ar=0,uw(),In=0}}function cw(){var e=Ur.now(),t=e-ra;t>ad&&(ia-=t,ra=e)}function uw(){for(var e,t=na,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:na=n);Wr=e,ss(r)}function ss(e){if(!ar){Hr&&(Hr=clearTimeout(Hr));var t=e-In;t>24?(e<1/0&&(Hr=setTimeout(id,e-Ur.now()-ia)),zr&&(zr=clearInterval(zr))):(zr||(ra=Ur.now(),zr=setInterval(cw,ad)),ar=1,od(id))}}function ld(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function cd(e){return e.x}function ud(e){return e.y}var dw=10,hw=Math.PI*(3-Math.sqrt(5));function cs(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),a=0,o=.6,s=new Map,l=aa(d),c=as("tick","end"),u=ld();e==null&&(e=[]);function d(){h(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function h(w){var v,y=e.length,b;w===void 0&&(w=1);for(var _=0;_<w;++_)for(n+=(a-n)*i,s.forEach(function(x){x(n)}),v=0;v<y;++v)b=e[v],b.fx==null?b.x+=b.vx*=o:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=o:(b.y=b.fy,b.vy=0);return t}function f(){for(var w=0,v=e.length,y;w<v;++w){if(y=e[w],y.index=w,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var b=dw*Math.sqrt(.5+w),_=w*hw;y.x=b*Math.cos(_),y.y=b*Math.sin(_)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function g(w){return w.initialize&&w.initialize(e,u),w}return f(),t={tick:h,restart:function(){return l.restart(d),t},stop:function(){return l.stop(),t},nodes:function(w){return arguments.length?(e=w,f(),s.forEach(g),t):e},alpha:function(w){return arguments.length?(n=+w,t):n},alphaMin:function(w){return arguments.length?(r=+w,t):r},alphaDecay:function(w){return arguments.length?(i=+w,t):+i},alphaTarget:function(w){return arguments.length?(a=+w,t):a},velocityDecay:function(w){return arguments.length?(o=1-w,t):1-o},randomSource:function(w){return arguments.length?(u=w,s.forEach(g),t):u},force:function(w,v){return arguments.length>1?(v==null?s.delete(w):s.set(w,g(v)),t):s.get(w)},find:function(w,v,y){var b=0,_=e.length,x,R,O,N,j;for(y==null?y=1/0:y*=y,b=0;b<_;++b)N=e[b],x=w-N.x,R=v-N.y,O=x*x+R*R,O<y&&(j=N,y=O);return j},on:function(w,v){return arguments.length>1?(c.on(w,v),t):c.on(w)}}}function us(){var e,t,n,r,i=Le(-30),a,o=1,s=1/0,l=.81;function c(f){var g,w=e.length,v=Dn(e,cd,ud).visitAfter(d);for(r=f,g=0;g<w;++g)t=e[g],v.visit(h)}function u(){if(e){var f,g=e.length,w;for(a=new Array(g),f=0;f<g;++f)w=e[f],a[w.index]=+i(w,f,e)}}function d(f){var g=0,w,v,y=0,b,_,x;if(f.length){for(b=_=x=0;x<4;++x)(w=f[x])&&(v=Math.abs(w.value))&&(g+=w.value,y+=v,b+=v*w.x,_+=v*w.y);f.x=b/y,f.y=_/y}else{w=f,w.x=w.data.x,w.y=w.data.y;do g+=a[w.data.index];while(w=w.next)}f.value=g}function h(f,g,w,v){if(!f.value)return!0;var y=f.x-t.x,b=f.y-t.y,_=v-g,x=y*y+b*b;if(_*_/l<x)return x<s&&(y===0&&(y=Et(n),x+=y*y),b===0&&(b=Et(n),x+=b*b),x<o&&(x=Math.sqrt(o*x)),t.vx+=y*f.value*r/x,t.vy+=b*f.value*r/x),!0;if(f.length||x>=s)return;(f.data!==t||f.next)&&(y===0&&(y=Et(n),x+=y*y),b===0&&(b=Et(n),x+=b*b),x<o&&(x=Math.sqrt(o*x)));do f.data!==t&&(_=a[f.data.index]*r/x,t.vx+=y*_,t.vy+=b*_);while(f=f.next)}return c.initialize=function(f,g){e=f,n=g,u()},c.strength=function(f){return arguments.length?(i=typeof f=="function"?f:Le(+f),u(),c):i},c.distanceMin=function(f){return arguments.length?(o=f*f,c):Math.sqrt(o)},c.distanceMax=function(f){return arguments.length?(s=f*f,c):Math.sqrt(s)},c.theta=function(f){return arguments.length?(l=f*f,c):Math.sqrt(l)},c}function ds(e){var t=Le(.1),n,r,i;typeof e!="function"&&(e=Le(e==null?0:+e));function a(s){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vx+=(i[l]-u.x)*r[l]*s}function o(){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 a.initialize=function(s){n=s,o()},a.strength=function(s){return arguments.length?(t=typeof s=="function"?s:Le(+s),o(),a):t},a.x=function(s){return arguments.length?(e=typeof s=="function"?s:Le(+s),o(),a):e},a}function hs(e){var t=Le(.1),n,r,i;typeof e!="function"&&(e=Le(e==null?0:+e));function a(s){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vy+=(i[l]-u.y)*r[l]*s}function o(){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 a.initialize=function(s){n=s,o()},a.strength=function(s){return arguments.length?(t=typeof s=="function"?s:Le(+s),o(),a):t},a.y=function(s){return arguments.length?(e=typeof s=="function"?s:Le(+s),o(),a):e},a}var pw=9,oa=6,Br=18,fw=32,pd=9,or=pw+pd;function ps(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+fw));return oa+(Br-oa)*n}function fs(e){return e+pd}var gw=300,fd=1,dd=.001;function hd(e){return e==="contains"||e==="anchored-at"}function mw(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function vw(e){let t=[],n=new Set;for(let a of e.nodes)n.has(a.id)||(n.add(a.id),t.push(a.id));let r=[],i=new Set;for(let a of e.edges){if(a.source===a.target||!n.has(a.source)||!n.has(a.target))continue;let o=`${a.source}\0${a.target}\0${a.kind}`;i.has(o)||(i.add(o),r.push(a))}return{ids:t,edges:r}}function gs(e){let t=is(e.links).id(n=>n.id).distance(n=>hd(n.kind)?at.containsRest:at.relationDistance).strength(n=>hd(n.kind)?at.containsStrength:at.relationStrength).iterations(2);return cs(e.nodes).randomSource(mw(e.seed??fd)).force("charge",us().strength(at.charge).distanceMax(at.chargeMax)).force("link",t).force("collide",rs(n=>n.r??or).strength(1)).force("x",ds(0).strength(at.center)).force("y",hs(0).strength(at.center)).stop()}function ww(e,t,n){let r=gs({nodes:e,links:t.map(({source:i,target:a,kind:o})=>({source:i,target:a,kind:o})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(dd).alphaDecay(n.ticks>0?1-Math.pow(dd,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function gd(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??gw)),{ids:r,edges:i}=vw(e),a=r.map(l=>{let c=t.initial?.get(l),u={id:l,vx:0,vy:0};return c!==void 0&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&(u.x=c.x,u.y=c.y,t.pinWarm===!0&&(u.fx=c.x,u.fy=c.y)),u}),o=new Map;for(let l of i)o.set(l.source,(o.get(l.source)??0)+1),o.set(l.target,(o.get(l.target)??0)+1);for(let l of a)l.r=fs(ps(o.get(l.id)??0));a.length>1&&ww(a,i,{ticks:n,seed:t.seed??fd,warm:t.initial!==void 0});let s=new Map;for(let l of a)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}var yw=Object.fromEntries(Object.entries(ve).map(([e,{colors:t}])=>[e,{accent:t.accent,success:t.ok,warning:t.warn,dim:t.dim,text:t.fg,muted:t.faint,line:t["line-strong"],ground:t.bg}]));function Ft(e){let t=yw[Hi(e)];return typeof e=="string"?t:{...t,accent:Ic(e.theme,e.accent)}}var bw={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},xw={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function kw(e,t){return Ft(t)[bw[e]]}function md(e,t){return Ft(t)[xw[e]]}function _w(e,t){return Tw(e)?Kr(md(e,t),t,Sw):md(e,t)}function Tw(e){return e==="contains"||e==="anchored-at"}var vs=.85,Sw=.3;function Mn(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),a=r(t);if(i===null||a===null)return e;let o=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,c)=>Math.round(l+(c-l)*o).toString(16).padStart(2,"0");return`#${s(i[0],a[0])}${s(i[1],a[1])}${s(i[2],a[2])}`}function Kr(e,t,n=vs){return Mn(e,Ft(t).ground,n)}var Ew={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},ms=1.6,vd=32,Rw=vd/2;function Aw(e,t=vd){if(t<=0)return e.length>0?"…":e;if(e.length<=t)return e;let n=t-1,i=e.slice(0,n).lastIndexOf(" "),a=i>=Rw?i:n;return`${e.slice(0,a).trimEnd()}…`}function Cw(e){let t=Bt(e.provenance),n=pt(e);return Aw(t===""?n:`${t} ${n}`)}var Lw=6,Nw=6;function Pw(e){return(t,n,r)=>{if(n.label===null||n.label===""||n.forceLabel===!0)return;let i=Ft(e);t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=Nw,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+Lw),t.restore()}}function ws(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=0;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(a++,s.x<t&&(t=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>i&&(i=s.y));if(a===0)return null;let o=Math.max(Br,(or*4-Math.max(r-t,i-n))/2);return{x:[t-o,r+o],y:[n-o,i+o]}}var Dw=1.2,Iw=or*10;function wd(e,t){let n=ws(t);if(e===null||n===null)return null;let r=Math.max(e.x[1]-e.x[0],e.y[1]-e.y[0]),i=r>0&&Number.isFinite(r)?r:1,a=Math.max(n.x[1]-n.x[0],n.y[1]-n.y[0],Iw),o=s=>(s[0]+s[1])/2;return{x:.5+(o(n.x)-o(e.x))/i,y:.5+(o(n.y)-o(e.y))/i,ratio:Math.min(1,a*Dw/i)}}var yd={nodes:[],edges:[]};function bd(e){return`${e.source}\0${e.target}\0${e.kind}`}function Mw(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 a=bd(i);r.has(a)||(r.add(a),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function xd(e,t,n,r,i){let a=new Map;for(let d of e){if(a.has(d.id))continue;let h=n.get(d.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||a.set(d.id,d)}let o=new Set(a.keys()),s=Mw(t,o),l=[];for(let[d,h]of a){let f=n.get(d),g=ps(s.get(d)??0);l.push({id:d,x:f.x,y:f.y,size:g,label:Cw(h),color:i?.get(d)??kw(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(g),type:"circle"})}let c=[],u=new Set;for(let d of t){if(d.source===d.target||!o.has(d.source)||!o.has(d.target))continue;let h=bd(d);u.has(h)||(u.add(h),c.push({key:h,source:d.source,target:d.target,size:Ew[d.kind],color:_w(d.kind,r),kind:d.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function kd(e,t,n=1,r="neighbourhood"){return(i,a,o)=>e===null||n<=0?{}:r==="spotlight"?Hw(e,t??null,n,i,a,o):i===t&&e.has(i)?{zIndex:a.zIndex+Vr*2,size:a.size*Kt(Bw,n)}:e.has(i)?{zIndex:a.zIndex+Vr,size:a.size*Kt(Kw,n)}:{color:Kr(a.color,o,vs*n),label:n>=Sd?null:a.label,zIndex:0}}var _d=.92,Gw=1.4,Ow=1.7,Fw=.75,$w=40,zw="warning";function Hw(e,t,n,r,i,a){let o=n>=Sd;return r===t?{zIndex:i.zIndex+Vr*2,size:i.size*Kt(Ow,n),forceLabel:o}:e.has(r)?{zIndex:i.zIndex+Vr,size:i.size*Kt(Gw,n),forceLabel:o&&e.size<=$w}:{color:Kr(i.color,a,_d*n),label:o?null:i.label,size:i.size*Kt(Fw,n),zIndex:0}}var Ww=60,Uw=.004;function Td(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/Ww);return Math.abs(t-i)<Uw?t:i}function Kt(e,t){return 1+(e-1)*t}var Sd=.5,Bw=1.45,Kw=1.15,Vr=Br+1;function Ed(e,t,n=1,r="neighbourhood"){return(i,a,o)=>e===null||n<=0?{}:r==="spotlight"?!e.has(a.source)||!e.has(a.target)?{color:Kr(a.color,o,_d*n)}:{zIndex:2,size:a.size*Kt(ms*1.35,n),color:Mn(a.color,Ft(o)[zw],n)}:!e.has(a.source)||!e.has(a.target)?{color:Kr(a.color,o,vs*n)}:t!=null&&(a.source===t||a.target===t)?{zIndex:2,size:a.size*Kt(ms*1.35,n),color:Mn(a.color,Ft(o).accent,n)}:{zIndex:1,size:a.size*Kt(ms,n)}}var Vw={searched:{slot:"warning",blend:.35,growth:1.08},read:{slot:"success",blend:.85,growth:1.3},wrote:{slot:"accent",blend:1,growth:1.5}};function Rd(e,t,n,r){if(e===void 0||!(e.strength>0))return{};let i=Vw[e.kind],a=Math.min(1,e.strength);return{color:Mn(t.color,Ft(n)[i.slot],i.blend*a),size:t.size*Kt(i.growth,a),zIndex:t.zIndex+Vr*3,label:r}}var Ad=(oa+Br)/2,jw=30;function ys(e){return e<jw?0:Ad}var qw=or*4,Yw=1;function Cd(e){let t=Ft(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Yw,labelGridCellSize:qw,labelRenderedSizeThreshold:Ad,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:or,defaultDrawNodeHover:Pw(e),allowInvalidContainer:!0}}function Ld(e){return e==="contains"||e==="anchored-at"}function Zw(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)Ld(i.kind)&&i.source!==i.target&&(!n.has(i.source)||!n.has(i.target)||r.has(i.target)||r.set(i.target,i.source));return r}function Xw(e,t){let n=Zw(e,t),r=new Map;for(let i of e){let a=i.id,o=i.id,s=0,l=new Set([a]);for(;;){let c=n.get(a);if(c===void 0||l.has(c))break;l.add(c),o=a,a=c,s++}r.set(i.id,{key:o,depth:Math.max(0,s-1)})}return r}function Qw(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var Jw={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},ey=3;function ty(e,t){let n=Jw[ve[Hi(t)].scheme],i=[...Qw(e).entries()].sort((o,s)=>s[1]-o[1]||(o[0]<s[0]?-1:o[0]>s[0]?1:0)),a=new Map;return i.forEach(([o],s)=>a.set(o,n[s*ey%n.length])),a}var ny=.11,ry=.34;function iy(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return Mn(e,Ft(n).ground,Math.min(ry,r*ny))}var ay=.26,oy=.55;function sy(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let a of t){let o=Math.min(ay,oy-i);if(o<=0)break;i+=o,r=Mn(r,a,o)}return r}function Nd(e,t,n){let r=Xw(e,t),i=new Map;for(let[u,d]of r)i.set(u,d.key);let a=ty(i,n),o=new Set(e.map(u=>u.id)),s=new Map,l=(u,d)=>{let h=r.get(u)?.key,f=r.get(d)?.key;if(h===void 0||f===void 0||h===f)return;let g=s.get(u);g===void 0?s.set(u,new Set([f])):g.add(f)};for(let u of t)Ld(u.kind)||u.source!==u.target&&(!o.has(u.source)||!o.has(u.target)||(l(u.source,u.target),l(u.target,u.source)));let c=new Map;for(let u of e){let d=r.get(u.id);if(d===void 0)continue;let h=a.get(d.key);if(h===void 0)continue;let f=iy(h,d.depth,n),g=[...s.get(u.id)??[]].sort().map(w=>a.get(w)).filter(w=>w!==void 0);c.set(u.id,sy(f,g,n))}return c}function bs(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 ly=300,cy=1;function uy(e,t,n){let r=new Map(n??[]);if(r.size>0)for(let a of t){if(a.kind!=="contains"&&a.kind!=="anchored-at"||r.has(a.target))continue;let o=r.get(a.source);o!==void 0&&r.set(a.target,{x:o.x,y:o.y})}let i={ticks:ly,seed:cy,pinWarm:!0};return r.size>0&&(i.initial=r),gd({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function dy(e,t){let n=0,r=0;for(let a of e){let o=bs(a.id);n^=o,r=r+o>>>0}for(let a of t){let o=bs(`${a.source}\0${a.target}\0${a.kind}`);n^=o,r=r+o>>>0}return[...[e.length,t.length,n>>>0,r].map(a=>a.toString(16)),bs(JSON.stringify(at)).toString(16)].join("-")}var Dd="pi-weave.graph.positions.v4";function Pd(e){return Math.round(e*10)/10}function hy(e,t){let n={};for(let[r,i]of t)n[r]=[Pd(i.x),Pd(i.y)];return JSON.stringify({v:4,key:e,at:n})}function py(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!==4||r.key!==t)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let a=new Map;for(let[o,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,c]=s;if(typeof l!="number"||typeof c!="number"||!Number.isFinite(l)||!Number.isFinite(c))return null;a.set(o,{x:l,y:c})}return a.size===0?null:a}function fy(e,t){let n;try{n=e.getItem(Dd)}catch{return null}return py(n,t)}function gy(e,t,n){try{return e.setItem(Dd,hy(t,n)),!0}catch{return!1}}function Id(e,t,n){let r=dy(t,n),i=fy(e,r);if(i!==null&&t.every(o=>i.has(o.id)))return{key:r,positions:i,cached:!0};let a=uy(t,n);return gy(e,r,a),{key:r,positions:a,cached:!1}}function sa(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(i=>i.id===t);if(n===void 0)return null;let r=t.startsWith("artifact:")?"HTML artifact":t.startsWith("vfolder:")?"Folder":n.kind;return{id:t,title:n.label,kind:r,icon:Pn(n.kind)}}function my(e){return{expanded:new Set(Xi(e,new Set).clusters.keys())}}function Gd(e,t){return t!==null?t:e===null?{expanded:new Set}:my(Ln(e))}function vy(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function wy(e,t){return t===null?null:Zi(t,e)}function yy(e,t,n){return t===null?n:Zi(t,e)}function Od(e,t,n){return n===null?{highlight:e,selectedId:t,style:"neighbourhood"}:{highlight:n,selectedId:t,style:"spotlight"}}function Fd(e,t,n){return n.style==="spotlight"?t===null?n:{...n,selectedId:t}:{highlight:yy(e,t,n.highlight),selectedId:t??n.selectedId,style:"neighbourhood"}}var $d="fit",zd="frame the whole graph",la={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Hd(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function by(e,t){return e===null?"Loading…":e.model.nodes.length===0?"Nothing here yet — add a note to get started.":t===0?"Nothing to draw at this expansion.":null}var xy="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",Md={graph:yd,highlight:null,key:"",cached:!1,clusters:new Map,representative:new Map,visible:0,total:0,empty:"Loading…"};function Wd(e,t,n,r,i,a=!1,o=!0){if(e===null)return a?{...Md,empty:xy}:Md;let s=Ln(e),l=Xi(s,n.expanded),u=n.expanded.has("vault")?l.edges.filter(g=>g.source!=="vault"&&g.target!=="vault"):l.edges,d=Id(r,l.nodes,u),h=o?Nd(l.nodes,u,i):void 0;return{graph:xd(l.nodes,u,d.positions,i,h),highlight:wy(u,t),key:d.key,cached:d.cached,clusters:l.clusters,representative:l.representative,visible:l.nodes.length,total:s.nodes.length,empty:by(e,l.nodes.length)}}function Ud(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:vy(e,n),selectedId:n}}function Ts(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Fn=Ts();function Xd(e){Fn=e}var Gn={exec:()=>null};function sr(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function re(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(je.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,t)};return r}var ky=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),je={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:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:sr(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:sr(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:sr(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:sr(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:sr(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:sr(e=>new RegExp(`^ {0,${e}}>`))},_y=/^(?:[ \t]*(?:\n|$))+/,Ty=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Sy=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ey=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ss=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jd=re(Qd).replace(/bull/g,Ss).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(),Ry=re(Qd).replace(/bull/g,Ss).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(),Es=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ay=/^[^\n]+/,Rs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Cy=re(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ly=re(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ss).getRegex(),pa="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",As=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ny=re("^ {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",As).replace("tag",pa).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),eh=e=>re(Es).replace("hr",Yr).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",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",pa).getRegex(),Py=eh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Dy=eh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Iy=re(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Dy).getRegex(),Cs={blockquote:Iy,code:Ty,def:Cy,fences:Sy,heading:Ey,hr:Yr,html:Ny,lheading:Jd,list:Ly,newline:_y,paragraph:Py,table:Gn,text:Ay},Bd=re("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yr).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",pa).getRegex(),My={...Cs,lheading:Ry,table:Bd,paragraph:re(Es).replace("hr",Yr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Bd).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",pa).getRegex()},Gy={...Cs,html:re(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",As).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:Gn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:re(Es).replace("hr",Yr).replace("heading",` *#{1,6} *[^
29
+ ]`).replace("lheading",Jd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Oy=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Fy=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,th=/^( {2,}|\\)\n(?!\s*$)/,$y=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Vt=/[\p{P}\p{S}]/u,lr=/[\s\p{P}\p{S}]/u,Zr=/[^\s\p{P}\p{S}]/u,zy=re(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lr).getRegex(),Hy=/[\p{Pi}\p{Ps}"']/u,nh=/(?!~)[\p{P}\p{S}]/u,Wy=/(?!~)[\s\p{P}\p{S}]/u,Uy=/(?:[^\s\p{P}\p{S}]|~)/u,By=re(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ky?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),rh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ky=re(rh,"u").replace(/punct/g,Vt).getRegex(),Vy=re(rh,"u").replace(/punct/g,nh).getRegex(),jy=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,qy=re(jy,"u").replace(/openQuote/g,Hy).replace(/punct/g,Vt).getRegex(),ih="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Yy=re(ih,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Vt).getRegex(),Zy=re(ih,"gu").replace(/notPunctSpace/g,Uy).replace(/punctSpace/g,Wy).replace(/punct/g,nh).getRegex(),Xy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Qy=re(Xy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Vt).getRegex(),Jy=re("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Vt).getRegex(),eb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",tb=re(eb,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Vt).getRegex(),nb=re(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Vt).getRegex(),rb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ib=re(rb,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,lr).replace(/punct/g,Vt).getRegex(),ab=re(/\\(punct)/,"gu").replace(/punct/g,Vt).getRegex(),ob=re(/^<(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(),sb=re(As).replace("(?:-->|$)","-->").getRegex(),lb=re("^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",sb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ua=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,cb=re(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ua).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ah=re(/^!?\[(label)\]\[(ref)\]/).replace("label",ua).replace("ref",Rs).getRegex(),oh=re(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rs).getRegex(),ub=re("reflink|nolink(?!\\()","g").replace("reflink",ah).replace("nolink",oh).getRegex(),Kd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ls={_backpedal:Gn,anyPunctuation:ab,autolink:ob,blockSkip:By,br:th,code:Fy,del:Gn,delLDelim:Gn,delRDelim:Gn,emStrongLDelim:Ky,emStrongRDelimAst:Yy,emStrongRDelimUnd:Jy,escape:Oy,link:cb,nolink:oh,punctuation:zy,reflink:ah,reflinkSearch:ub,tag:lb,text:$y,url:Gn},db={...Ls,emStrongLDelim:qy,emStrongRDelimAst:Qy,emStrongRDelimUnd:tb,link:re(/^!?\[(label)\]\((.*?)\)/).replace("label",ua).getRegex(),reflink:re(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ua).getRegex()},xs={...Ls,emStrongRDelimAst:Zy,emStrongLDelim:Vy,delLDelim:nb,delRDelim:ib,url:re(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Kd).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:re(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Kd).getRegex()},hb={...xs,br:re(th).replace("{2,}","*").getRegex(),text:re(xs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ca={normal:Cs,gfm:My,pedantic:Gy},jr={normal:Ls,gfm:xs,breaks:hb,pedantic:db},pb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Vd=e=>pb[e];function $t(e,t){if(t){if(je.escapeTest.test(e))return e.replace(je.escapeReplace,Vd)}else if(je.escapeTestNoEncode.test(e))return e.replace(je.escapeReplaceNoEncode,Vd);return e}function jd(e){try{e=encodeURI(e).replace(je.percentDecode,"%")}catch{return null}return e}function qd(e,t){let n=e.replace(je.findPipe,(a,o,s)=>{let l=!1,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(je.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(je.slashPipe,"|");return r}function dn(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Yd(e){let t=e.split(`
30
30
  `),n=t.length-1;for(;n>=0&&je.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
31
- `)}function cb(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function ub(e,t=0){let n=t,r="";for(let i of e)if(i===" "){let a=4-n%4;r+=" ".repeat(a),n+=a}else r+=i,n++;return r}function Kd(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function db(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
31
+ `)}function fb(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function gb(e,t=0){let n=t,r="";for(let i of e)if(i===" "){let a=4-n%4;r+=" ".repeat(a),n+=a}else r+=i,n++;return r}function Zd(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function mb(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
32
32
  `).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[s]=o;return s.length>=i.length?a.slice(i.length):a}).join(`
33
- `)}var da=class{options;rules;lexer;constructor(e){this.options=e||Fn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Bd(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=db(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=un(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:un(t[0],`
34
- `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:un(t[0],`
35
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=un(t[0],`
33
+ `)}var da=class{options;rules;lexer;constructor(e){this.options=e||Fn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Yd(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=mb(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=dn(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:dn(t[0],`
34
+ `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:dn(t[0],`
35
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=dn(t[0],`
36
36
  `).split(`
37
37
  `),r="",i="",a=[];for(;n.length>0;){let o=!1,s=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))s.push(n[l]),o=!0;else if(!o)s.push(n[l]);else break;n=n.slice(l);let c=s.join(`
38
38
  `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
@@ -44,19 +44,19 @@ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
44
44
  ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(h?.type==="list"){let f=h,g=f.raw+`
45
45
  `+n.join(`
46
46
  `),w=this.list(g);a[a.length-1]=w,r=r.substring(0,r.length-h.raw.length)+w.raw,i=i.substring(0,i.length-f.raw.length)+w.raw,n=g.substring(a.at(-1).raw.length).split(`
47
- `);continue}}return{type:"blockquote",raw:r,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[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 a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,c="",u="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let d=ub(t[2].split(`
47
+ `);continue}}return{type:"blockquote",raw:r,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[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 a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,c="",u="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let d=gb(t[2].split(`
48
48
  `,1)[0],t[1].length),h=e.split(`
49
49
  `,1)[0],f=!d.trim(),g=0;if(this.options.pedantic?(g=2,u=d.trimStart()):f?g=t[1].length+1:(g=d.search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=d.slice(g),g+=t[1].length),f&&this.rules.other.blankLine.test(h)&&(c+=h+`
50
- `,e=e.substring(h.length+1),l=!0),!l){let w=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),y=this.rules.other.fencesBeginRegex(g),b=this.rules.other.headingBeginRegex(g),_=this.rules.other.htmlBeginRegex(g),x=this.rules.other.blockquoteBeginRegex(g);for(;e;){let C=e.split(`
51
- `,1)[0],O;if(h=C,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),O=h):O=h.replace(this.rules.other.tabCharGlobal," "),y.test(h)||b.test(h)||_.test(h)||x.test(h)||w.test(h)||v.test(h))break;if(O.search(this.rules.other.nonSpaceChar)>=g||!h.trim())u+=`
50
+ `,e=e.substring(h.length+1),l=!0),!l){let w=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),y=this.rules.other.fencesBeginRegex(g),b=this.rules.other.headingBeginRegex(g),_=this.rules.other.htmlBeginRegex(g),x=this.rules.other.blockquoteBeginRegex(g);for(;e;){let R=e.split(`
51
+ `,1)[0],O;if(h=R,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),O=h):O=h.replace(this.rules.other.tabCharGlobal," "),y.test(h)||b.test(h)||_.test(h)||x.test(h)||w.test(h)||v.test(h))break;if(O.search(this.rules.other.nonSpaceChar)>=g||!h.trim())u+=`
52
52
  `+O.slice(g);else{if(f||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(d)||b.test(d)||v.test(d))break;u+=`
53
- `+h}f=!h.trim(),c+=C+`
54
- `,e=e.substring(C.length+1),d=O.slice(g)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}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 c=l.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=u}for(let l of i.items){let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=d.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=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Bd(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:un(t[0],`
55
- `),href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ud(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
56
- `):[],a={type:"table",raw:un(t[0],`
57
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(Ud(o,a.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[l]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:un(t[0],`
53
+ `+h}f=!h.trim(),c+=R+`
54
+ `,e=e.substring(R.length+1),d=O.slice(g)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}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 c=l.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=u}for(let l of i.items){let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=d.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=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Yd(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:dn(t[0],`
55
+ `),href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=qd(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
56
+ `):[],a={type:"table",raw:dn(t[0],`
57
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(qd(o,a.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[l]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:dn(t[0],`
58
58
  `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
59
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let a=un(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=cb(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(r);a&&(r=a[1],i=a[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Kd(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Kd(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);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,a,o,s=i,l=0,c=r[0][0],u=n===c,d=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}else if(r[5]||r[6]){if(i%3&&!((i+o)%3)){l+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+l);let h=[...r[0]][0].length,f=e.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let w=f.slice(1,-1);return{type:"em",raw:f,text:w,tokens:this.lexer.inlineTokens(w)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[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:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+i);(r=l.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(o=[...a].length,o!==i))continue;if(r[3]||r[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let c=[...r[0]][0].length,u=e.slice(0,i+r.index+c+o),d=u.slice(i,-i);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},st=class bs{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Fn,this.options.tokenizer=this.options.tokenizer||new da,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:je,block:ca.normal,inline:jr.normal};this.options.pedantic?(n.block=ca.pedantic,n.inline=jr.pedantic):this.options.gfm&&(n.block=ca.gfm,this.options.breaks?n.inline=jr.breaks:n.inline=jr.gfm),this.tokenizer.rules=n}static get rules(){return{block:ca,inline:jr}}static lex(t,n){return new bs(n).lex(t)}static lexInline(t,n){return new bs(n).inlineTokens(t)}lex(t){t=t.replace(je.carriageReturn,`
59
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let a=dn(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=fb(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(r);a&&(r=a[1],i=a[3])}else i=t[3]?t[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)),Zd(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Zd(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);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,a,o,s=i,l=0,c=r[0][0],u=n===c,d=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}else if(r[5]||r[6]){if(i%3&&!((i+o)%3)){l+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+l);let h=[...r[0]][0].length,f=e.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let w=f.slice(1,-1);return{type:"em",raw:f,text:w,tokens:this.lexer.inlineTokens(w)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[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:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+i);(r=l.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(o=[...a].length,o!==i))continue;if(r[3]||r[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let c=[...r[0]][0].length,u=e.slice(0,i+r.index+c+o),d=u.slice(i,-i);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},st=class ks{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Fn,this.options.tokenizer=this.options.tokenizer||new da,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:je,block:ca.normal,inline:jr.normal};this.options.pedantic?(n.block=ca.pedantic,n.inline=jr.pedantic):this.options.gfm&&(n.block=ca.gfm,this.options.breaks?n.inline=jr.breaks:n.inline=jr.gfm),this.tokenizer.rules=n}static get rules(){return{block:ca,inline:jr}}static lex(t,n){return new ks(n).lex(t)}static lexInline(t,n){return new ks(n).inlineTokens(t)}lex(t){t=t.replace(je.carriageReturn,`
60
60
  `),this.blockTokens(t,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(t,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(je.tabCharGlobal," ").replace(je.spaceLine,""));let i=1/0;for(;t;){if(t.length<i)i=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let a;if(this.options.extensions?.block?.some(s=>(a=s.call({lexer:this},t,n))?(t=t.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(t)){t=t.substring(a.raw.length);let s=n.at(-1);a.raw.length===1&&s!==void 0?s.raw+=`
61
61
  `:n.push(a);continue}if(a=this.tokenizer.code(t)){t=t.substring(a.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
62
62
  `)?"":`
@@ -71,8 +71,8 @@ ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(h?.type==="li
71
71
  `)?"":`
72
72
  `)+a.raw,s.text+=`
73
73
  `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(a);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let r=t;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,c)=>{let u=c?c.length:0;return s.slice(0,u)+"["+"a".repeat(s.length-u-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,a="",o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(a=""),i=!1;let s;if(this.options.extensions?.inline?.some(c=>(s=c.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(s.raw.length);let c=n.at(-1);s.type==="text"&&c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(t,r,a)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(t,r,a)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),n.push(s);continue}let l=t;if(this.options.extensions?.startInline){let c=1/0,u=t.slice(1),d;this.options.extensions.startInline.forEach(h=>{d=h.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(s=this.tokenizer.inlineText(l)){t=t.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),i=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):n.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},ha=class{options;parser;constructor(e){this.options=e||Fn}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(je.notSpaceStart)?.[0],i=e.replace(je.endingNewline,"")+`
74
- `;return r?'<pre><code class="language-'+Ft(r)+'">'+(n?i:Ft(i,!0))+`</code></pre>
75
- `:"<pre><code>"+(n?i:Ft(i,!0))+`</code></pre>
74
+ `;return r?'<pre><code class="language-'+$t(r)+'">'+(n?i:$t(i,!0))+`</code></pre>
75
+ `:"<pre><code>"+(n?i:$t(i,!0))+`</code></pre>
76
76
  `}blockquote({tokens:e}){return`<blockquote>
77
77
  ${this.parser.parse(e)}</blockquote>
78
78
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -88,18 +88,18 @@ ${this.parser.parse(e)}</blockquote>
88
88
  `}tablerow({text:e}){return`<tr>
89
89
  ${e}</tr>
90
90
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
91
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ft(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Wd(e);if(i===null)return r;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+Ft(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Wd(e);if(i===null)return Ft(n);e=i;let a=`<img src="${e}" alt="${Ft(n)}"`;return t&&(a+=` title="${Ft(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ft(e.text)}},Cs=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Rt=class xs{options;renderer;textRenderer;constructor(t){this.options=t||Fn,this.options.renderer=this.options.renderer||new ha,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Cs}static parse(t,n){return new xs(n).parse(t)}static parseInline(t,n){return new xs(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){n+=s||"";continue}}let a=i;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){r+=s||"";continue}}let o=a;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},qr=class{options;block;constructor(e){this.options=e||Fn}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?st.lex:st.lexInline}provideParser(e=this.block){return e?Rt.parse:Rt.parseInline}},fa=class{defaults=ks();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Rt;Renderer=ha;TextRenderer=Cs;Lexer=st;Tokenizer=da;Hooks=qr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let a of i.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let o of a)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let o=i[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.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 a=t.renderers[i.name];a?t.renderers[i.name]=function(...o){let s=i.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:t.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 a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new ha(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=n.renderer[o],l=i[o];i[o]=(...c)=>{let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new da(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new qr;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=n.hooks[o],l=i[o];qr.passThroughHooks.has(a)?i[o]=c=>{if(this.defaults.async&&qr.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(i,c);return l.call(i,d)})();let u=s.call(i,c);return l.call(i,u)}:i[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(i,c);return d===!1&&(d=await l.apply(i,c)),d})();let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;r.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),i&&(s=s.concat(i.call(this,o))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return st.lex(e,t??this.defaults)}parser(e,t){return Rt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,s=await(i.hooks?await i.hooks.provideLexer(e):e?st.lex:st.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser(e):e?Rt.parse:Rt.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer(e):e?st.lex:st.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(e):e?Rt.parse:Rt.parseInline)(o,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
92
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Ft(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},On=new fa;function fe(e,t){return On.parse(e,t)}fe.options=fe.setOptions=function(e){return On.setOptions(e),fe.defaults=On.defaults,Vd(fe.defaults),fe};fe.getDefaults=ks;fe.defaults=Fn;function hb(...e){return On.use(...e),fe.defaults=On.defaults,Vd(fe.defaults),fe}fe.use=hb;fe.walkTokens=function(e,t){return On.walkTokens(e,t)};fe.parseInline=On.parseInline;fe.Parser=Rt;fe.parser=Rt.parse;fe.Renderer=ha;fe.TextRenderer=Cs;fe.Lexer=st;fe.lexer=st.lex;fe.Tokenizer=da;fe.Hooks=qr;fe.parse=fe;var i1=fe.options,a1=fe.setOptions,o1=fe.walkTokens,s1=fe.parseInline;var l1=Rt.parse,c1=st.lex;var rh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},pb=new RegExp(`[${Object.keys(rh).join("")}]`,"g");function ft(e){return e.replace(pb,t=>rh[t])}var fb=["http:","https:","mailto:"],ih=/^[a-z][a-z0-9+.-]*:/i,ah=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function nh(e){let t=e.replace(ah,""),n=ih.exec(t);return n===null?t===""?null:e:fb.includes(n[0].toLowerCase())?e:null}var Vt="data-weave-target",$n="data-weave-task";function wa(e){return e?"Mark task incomplete":"Mark task complete"}var ma="note:",gb={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function mb(e){if(e.kind!=="note"||!e.id.startsWith(ma))return null;let t=e.id.slice(ma.length);return t===""?null:t}function oh(e){if(e.kind!=="file"||!e.id.startsWith("artifact:"))return null;let t=e.detail.path;return t!==void 0&&/\.html?$/i.test(t)?t:null}function sh(e){let t=oh(e);return t===null?null:`${t}:${e.detail.updated??""}`}function lh(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:oh(n)}function ch(e,t){if(e===null)return gb;let n=new Map;for(let i of e.model.nodes){let a=mb(i);if(a!==null)for(let o of[a,i.label])n.set(o,a),n.set(o.toLowerCase(),a)}let r=t!==null&&(e.dangling[t]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:t}}function uh(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function vb(e,t){if(e.currentSlug===null||ih.test(t.replace(ah,"")))return null;try{let n=new URL(t,`https://weave.invalid/${e.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:uh(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function wb(e){return e.hasGhosts}var yb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function bb(e){let t=e.indexOf("[[");return t===-1?void 0:t}function xb(e){return{name:"wikilink",level:"inline",start:bb,tokenizer(t){return _b(t)},renderer(t){return kb(e,t)}}}function kb(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return Tb(e,n,r)}function _b(e){let t=yb.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function Tb(e,t,n){let r=ft((n===""?t:n).trim());if(r==="")return"";let i=uh(e,t);return i!==null?`<a class="weave-wiki" ${Vt}="${ft(i)}" role="link" tabindex="0" title="${ft(t.trim())}">${r}</a>`:wb(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${ft(t.trim())}">${r}</span>`:r}function Sb(e){let t=0;return new fa({gfm:!0,async:!1,extensions:[xb(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${$n}="${t++}" aria-label="${wa(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":ft(n)},link({href:n,title:r,tokens:i}){let a=nh(n),o=this.parser.parseInline(i),s=a===null?null:vb(e,a);if(s!==null){let c=r==null||r===""?"":` title="${ft(r)}"`;return`<a class="weave-wiki" ${Vt}="${ft(s)}" role="link" tabindex="0"${c}>${o}</a>`}return`<a${[a===null?"":` href="${ft(a)}"`,r==null||r===""?"":` title="${ft(r)}"`,a===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:n,title:r,text:i}){let a=nh(n);if(a===null)return ft(i);let o=r==null||r===""?"":` title="${ft(r)}"`;return`<img src="${ft(a)}" alt="${ft(i)}"${o}>`}}})}function Eb(e,t){return Sb(t).parse(e,{async:!1})}function ga(e){return Object.freeze(e)}var Rb=ga({ALLOWED_TAGS:ga(["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:ga(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",Vt,$n]),ADD_URI_SAFE_ATTR:ga([Vt,$n]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function Ns(e,t,n){return Cb(e.sanitize(Eb(t,n),Rb))}var Ab=/^(\s*<h1>[\s\S]*?<\/h1>)?\s*<p><strong>TL;?DR[ \t]*:?<\/strong>[ \t]*:?[ \t\n]*/i,Ls=/<(\/?)(?:ul|ol)\b[^>]*>/g;function Cb(e){let t=Ab.exec(e);if(t===null)return e;let n=e.indexOf("</p>",t[0].length);if(n===-1)return e;let r=t[1]??"",i=e.slice(t[0].length,n),a=n+4;if(/^\s*<(?:ul|ol)\b/.exec(e.slice(a))!==null){Ls.lastIndex=a;let l=0;for(let c=Ls.exec(e);c!==null;c=Ls.exec(e))if(l+=c[1]==="/"?-1:1,l===0){a=c.index+c[0].length;break}if(l!==0)return e}let s=e.slice(n+4,a);return`${r}
91
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${$t(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=jd(e);if(i===null)return r;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+$t(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=jd(e);if(i===null)return $t(n);e=i;let a=`<img src="${e}" alt="${$t(n)}"`;return t&&(a+=` title="${$t(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:$t(e.text)}},Ns=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Rt=class _s{options;renderer;textRenderer;constructor(t){this.options=t||Fn,this.options.renderer=this.options.renderer||new ha,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ns}static parse(t,n){return new _s(n).parse(t)}static parseInline(t,n){return new _s(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){n+=s||"";continue}}let a=i;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){r+=s||"";continue}}let o=a;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},qr=class{options;block;constructor(e){this.options=e||Fn}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?st.lex:st.lexInline}provideParser(e=this.block){return e?Rt.parse:Rt.parseInline}},fa=class{defaults=Ts();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Rt;Renderer=ha;TextRenderer=Ns;Lexer=st;Tokenizer=da;Hooks=qr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let a of i.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let o of a)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let o=i[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.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 a=t.renderers[i.name];a?t.renderers[i.name]=function(...o){let s=i.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:t.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 a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new ha(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=n.renderer[o],l=i[o];i[o]=(...c)=>{let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new da(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new qr;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=n.hooks[o],l=i[o];qr.passThroughHooks.has(a)?i[o]=c=>{if(this.defaults.async&&qr.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(i,c);return l.call(i,d)})();let u=s.call(i,c);return l.call(i,u)}:i[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(i,c);return d===!1&&(d=await l.apply(i,c)),d})();let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;r.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),i&&(s=s.concat(i.call(this,o))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return st.lex(e,t??this.defaults)}parser(e,t){return Rt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,s=await(i.hooks?await i.hooks.provideLexer(e):e?st.lex:st.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser(e):e?Rt.parse:Rt.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer(e):e?st.lex:st.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(e):e?Rt.parse:Rt.parseInline)(o,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
92
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+$t(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},On=new fa;function fe(e,t){return On.parse(e,t)}fe.options=fe.setOptions=function(e){return On.setOptions(e),fe.defaults=On.defaults,Xd(fe.defaults),fe};fe.getDefaults=Ts;fe.defaults=Fn;function vb(...e){return On.use(...e),fe.defaults=On.defaults,Xd(fe.defaults),fe}fe.use=vb;fe.walkTokens=function(e,t){return On.walkTokens(e,t)};fe.parseInline=On.parseInline;fe.Parser=Rt;fe.parser=Rt.parse;fe.Renderer=ha;fe.TextRenderer=Ns;fe.Lexer=st;fe.lexer=st.lex;fe.Tokenizer=da;fe.Hooks=qr;fe.parse=fe;var c1=fe.options,u1=fe.setOptions,d1=fe.walkTokens,h1=fe.parseInline;var p1=Rt.parse,f1=st.lex;var lh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},wb=new RegExp(`[${Object.keys(lh).join("")}]`,"g");function ft(e){return e.replace(wb,t=>lh[t])}var yb=["http:","https:","mailto:"],ch=/^[a-z][a-z0-9+.-]*:/i,uh=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function sh(e){let t=e.replace(uh,""),n=ch.exec(t);return n===null?t===""?null:e:yb.includes(n[0].toLowerCase())?e:null}var jt="data-weave-target",$n="data-weave-task";function wa(e){return e?"Mark task incomplete":"Mark task complete"}var ma="note:",bb={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function xb(e){if(e.kind!=="note"||!e.id.startsWith(ma))return null;let t=e.id.slice(ma.length);return t===""?null:t}function dh(e){if(e.kind!=="file"||!e.id.startsWith("artifact:"))return null;let t=e.detail.path;return t!==void 0&&/\.html?$/i.test(t)?t:null}function hh(e){let t=dh(e);return t===null?null:`${t}:${e.detail.updated??""}`}function ph(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:dh(n)}function fh(e,t){if(e===null)return bb;let n=new Map;for(let i of e.model.nodes){let a=xb(i);if(a!==null)for(let o of[a,i.label])n.set(o,a),n.set(o.toLowerCase(),a)}let r=t!==null&&(e.dangling[t]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:t}}function gh(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function kb(e,t){if(e.currentSlug===null||ch.test(t.replace(uh,"")))return null;try{let n=new URL(t,`https://weave.invalid/${e.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:gh(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function _b(e){return e.hasGhosts}var Tb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Sb(e){let t=e.indexOf("[[");return t===-1?void 0:t}function Eb(e){return{name:"wikilink",level:"inline",start:Sb,tokenizer(t){return Ab(t)},renderer(t){return Rb(e,t)}}}function Rb(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return Cb(e,n,r)}function Ab(e){let t=Tb.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function Cb(e,t,n){let r=ft((n===""?t:n).trim());if(r==="")return"";let i=gh(e,t);return i!==null?`<a class="weave-wiki" ${jt}="${ft(i)}" role="link" tabindex="0" title="${ft(t.trim())}">${r}</a>`:_b(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${ft(t.trim())}">${r}</span>`:r}function Lb(e){let t=0;return new fa({gfm:!0,async:!1,extensions:[Eb(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${$n}="${t++}" aria-label="${wa(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":ft(n)},link({href:n,title:r,tokens:i}){let a=sh(n),o=this.parser.parseInline(i),s=a===null?null:kb(e,a);if(s!==null){let c=r==null||r===""?"":` title="${ft(r)}"`;return`<a class="weave-wiki" ${jt}="${ft(s)}" role="link" tabindex="0"${c}>${o}</a>`}return`<a${[a===null?"":` href="${ft(a)}"`,r==null||r===""?"":` title="${ft(r)}"`,a===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:n,title:r,text:i}){let a=sh(n);if(a===null)return ft(i);let o=r==null||r===""?"":` title="${ft(r)}"`;return`<img src="${ft(a)}" alt="${ft(i)}"${o}>`}}})}function Nb(e,t){return Lb(t).parse(e,{async:!1})}function ga(e){return Object.freeze(e)}var Pb=ga({ALLOWED_TAGS:ga(["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:ga(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",jt,$n]),ADD_URI_SAFE_ATTR:ga([jt,$n]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function Ds(e,t,n){return Ib(e.sanitize(Nb(t,n),Pb))}var Db=/^(\s*<h1>[\s\S]*?<\/h1>)?\s*<p><strong>TL;?DR[ \t]*:?<\/strong>[ \t]*:?[ \t\n]*/i,Ps=/<(\/?)(?:ul|ol)\b[^>]*>/g;function Ib(e){let t=Db.exec(e);if(t===null)return e;let n=e.indexOf("</p>",t[0].length);if(n===-1)return e;let r=t[1]??"",i=e.slice(t[0].length,n),a=n+4;if(/^\s*<(?:ul|ol)\b/.exec(e.slice(a))!==null){Ps.lastIndex=a;let l=0;for(let c=Ps.exec(e);c!==null;c=Ps.exec(e))if(l+=c[1]==="/"?-1:1,l===0){a=c.index+c[0].length;break}if(l!==0)return e}let s=e.slice(n+4,a);return`${r}
93
93
  <div class="weave-tldr"><p><span class="weave-tldr-label">TLDR</span>${i}</p>${s}
94
- </div>${e.slice(a)}`}var Lb=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function Nb(e){let t=[],n=e.replace(/\r\n?/g,`
94
+ </div>${e.slice(a)}`}var Mb=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function Gb(e){let t=[],n=e.replace(/\r\n?/g,`
95
95
  `),r=0;for(let l of st.lex(n,{gfm:!0})){let c=n.indexOf(l.raw,r);if(c===-1||(r=c+l.raw.length,l.type!=="list"&&l.type!=="blockquote"))continue;let u=0;for(;u<l.raw.length;){let d=l.raw.indexOf(`
96
- `,u),h=d===-1?l.raw.length:d,f=l.raw.slice(u,h).replace(/\r$/,""),g=Lb.exec(f);g!==null&&t.push(c+u+g[1].length),u=d===-1?l.raw.length:d+1}}let i=new fa,a=l=>{let c=[];return i.walkTokens(st.lex(l,{gfm:!0}),u=>{u.type==="checkbox"&&c.push(u.checked)}),c},o=a(n),s=o.map(()=>null);for(let l of t){let c=`${n.slice(0,l)}${n[l]===" "?"x":" "}${n.slice(l+1)}`,u=a(c);if(u.length!==o.length)continue;let d=-1;for(let h=0;h<o.length;h+=1)if(u[h]!==o[h]){if(d!==-1){d=-1;break}d=h}d!==-1&&(s[d]=l)}return s.map(l=>{if(l===null)return null;let c=0,u=0;for(;u<l;)c+=e[c]==="\r"&&e[c+1]===`
97
- `?2:1,u+=1;return c})}function dh(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=Nb(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function hh(e){let t=e?.getAttribute($n);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var ph=32;function Ps(e){let t=e;for(let n=0;t!==null&&n<ph;n++){let r=t.getAttribute(Vt);if(r!==null&&r!=="")return`${ma}${r}`;t=t.parentElement}return null}function fh(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 gh="edited",mh="created",vh="Edit",wh="Done";var yh="Note body",bh="Start writing…",xh="Raw notes",kh="Raw notes text",_h="Raw";function Th(e,t){if(t)return"Your words as captured. Edits here are saved with the note.";let n=e.match(/^<!-- appended\b/gm)?.length??0;if(n>0)return`${n} ${n===1?"entry":"entries"} captured`;let r=e===""?0:e.split(`
98
- `).length;return`${r} ${r===1?"line":"lines"}`}var ya="Discard unsaved changes to this note?";function Pb(e){return e==="human"?"You wrote this":e==="agent"?"Agent wrote this":"Generated by pi-weave"}var Db="Vault";function Ib(e){return[Db,...e.split("/").slice(0,-1)].join(" / ")}function Sh(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:Ut(e.source),provenanceTitle:cn(e.source),updated:Wt(e.updated,t),updatedIso:e.updated,created:Wt(e.created,t),createdIso:e.created,tags:e.tags,byline:Pb(e.source),folder:Ib(e.slug)}}function Eh(e){return`#${e}`}var Mb=200,Gb=8,Ob="no note";function Ds(e){let t=e;for(let n=0;t!==null&&n<ph;n++){let r=t.getAttribute(Vt);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 Is(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 Xr(e,t=Mb){let n=Is(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function Rh(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:Ob,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} · ${cn(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Xr(n.detail.preview??"")}}function Ah(e,t,n,r,i,a,o=Gb){let s=e+o,l=t+o;return s+n>i-o&&(s=e-o-n),l+r>a-o&&(l=t-o-r),s=Math.min(Math.max(s,o),Math.max(o,i-o-n)),l=Math.min(Math.max(l,o),Math.max(o,a-o-r)),{x:s,y:l}}var va={anchor:null,pointerX:0,pointerY:0};function Ch(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:va;case"dismiss":return va}}function Lh(e,t,n=!1){return t!==null?null:e===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":n?"Couldn’t load this note — retrying…":e.startsWith(ma)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var Ph="Light up notes, tags or code",Dh="Light up in graph",Ih="Esc",Fs="Clear the spotlight (Esc)",Mh="agent",Gh="Your agent searched for this. Type to light up something else.",$s={lit:"lit",dimmed:"not lit"},Fb="search match";function Oh(e){return e===0?"no matches":`${e} lit`}function $b(e){let t=[];for(let n of e.toLowerCase().split(/\s+/)){let r=n.startsWith("#"),i=r?n.replace(/^#+/,""):n;i!==""&&t.push({text:i,tagOnly:r})}return t}function zb(e){let t=e.detail.path??e.detail.slug;if(typeof t=="string"&&t!=="")return t;let n=e.id.indexOf(":");return n===-1?"":e.id.slice(n+1)}function Hb(e){let t=new Map;for(let[n,r]of Object.entries(e.tags))for(let i of r){let a=`note:${i}`,o=t.get(a);o===void 0?t.set(a,[n]):o.includes(n)||o.push(n)}return t}function Wb(e,t,n){let r=e.label.toLowerCase(),i=zb(e).toLowerCase(),a=!1,o=!1,s=[];for(let c of n){let u=!c.tagOnly&&r.includes(c.text),d=t.filter(f=>f.toLowerCase().includes(c.text)),h=!c.tagOnly&&!u&&d.length===0&&i.includes(c.text);if(!u&&d.length===0&&!h)return null;a||=u,o||=h;for(let f of d)s.includes(f)||s.push(f)}let l=t.filter(c=>s.includes(c));return[...a?["title"]:[],...l.map(c=>`tag #${c}`),...o?["path"]:[]]}function Fh(e,t,n=[]){let r=$b(t);if(r.length===0)return null;let i=new Set,a=new Map;if(e!==null){let o=Hb(e);for(let l of e.model.nodes){if(i.has(l.id))continue;let c=Wb(l,o.get(l.id)??[],r);c!==null&&(i.add(l.id),a.set(l.id,c))}let s=new Set(n);for(let l of e.model.nodes)i.has(l.id)||!s.has(l.id)||(i.add(l.id),a.set(l.id,[Fb]))}return{terms:r,lit:i,reasons:a,count:i.size}}function $h(e,t){if(e===null)return null;let n=new Set;for(let r of e.lit)n.add(t.get(r)??r);return n}function Ub(e,t){let n=e?.reasons.get(t);return n===void 0||n.length===0?null:n.join(", ")}function zh(e,t,n){return e!==""&&(t||!n)}function Ms(e,t){let n=[...new Set(t.map(s=>s.text))].sort((s,l)=>l.length-s.length),r=e.toLowerCase(),i=[],a=0,o="";for(;a<e.length;){let s=n.find(l=>r.startsWith(l,a));if(s===void 0){o+=e[a],a+=1;continue}o!==""&&i.push({text:o,hit:!1}),o="",i.push({text:e.slice(a,a+s.length),hit:!0}),a+=s.length}return o!==""&&i.push({text:o,hit:!1}),i}var Bb=6,zs="Connected";function Hh(e,t){return t>e?`+${t-e} more`:null}var Wh="Graph node details",Hs="Close details",Uh="Open",Bh="Open in split",Kh="Lit because:",Kb={human:"You",agent:"Agent",generated:"Generated"},Os=new Set(["contains","anchored-at"]);function Vb(e){let t=new Map;for(let n of e)Os.has(n.kind)&&!t.has(n.target)&&n.source!==n.target&&t.set(n.target,n.source);return t}var Nh=3;function jb(e,t){let n=Vb(e.model.edges),r=new Map(e.model.nodes.map(c=>[c.id,c.label])),i=[],a=new Set([t]),o=n.get(t);for(;o!==void 0&&!a.has(o);)a.add(o),i.unshift(r.get(o)??o),o=n.get(o);let s=i.length>1?i.slice(1):i;return(s.length>Nh?["…",...s.slice(-Nh)]:s).join(" / ")}function qb(e){let t=/\*\*TL;?DR:?\*\*:?|(?:^|\s)TL;?DR:/i.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=n.search(/(?:^|\s)#{1,6}\s|\*\*[^*]+:\*\*/);r>=0&&(n=n.slice(0,r));let i=Is(n.replace(/(?:^|\s)[-*+]\s+\[[xX]\]\s*/g," ☑ ").replace(/(?:^|\s)[-*+]\s+\[ \]\s*/g," ☐ ").replace(/(?:^|\s)[-*+]\s+/g," · ")).replace(/\s+/g," ").replace(/^\s*·\s*/,"").trim();return i===""?null:i}var Gs=200;function Yb(e,t){let n=e.detail.preview??"",r=qb(n);if(r!==null)return{heading:"TLDR",parts:Ms(Xr(r,Gs),t)};let i=e.detail.summary??e.detail.description??"";if(i.trim()!=="")return{heading:"Summary",parts:Ms(Xr(i,Gs),t)};let a=Xr(n,Gs);return a===""?null:{heading:"Preview",parts:Ms(a,t)}}function Zb(e,t,n){let r=new Map(e.model.nodes.map(l=>[l.id,l])),i=l=>{let c=[];for(let u of e.model.edges){let d=l(u);d!==null&&d!==t&&r.has(d)&&!c.includes(d)&&c.push(d)}return c},a=i(l=>Os.has(l.kind)?null:l.source===t?l.target:l.target===t?l.source:null);return(a.length>0?a:i(l=>Os.has(l.kind)&&l.source===t?l.target:null)).map(l=>{let c=r.get(l),u=n?.lit.has(l)??!1;return{id:l,label:c.label,lit:u,ariaLabel:u?`${c.label} (lit)`:c.label}}).sort((l,c)=>Number(c.lit)-Number(l.lit)||l.label.localeCompare(c.label)||l.id.localeCompare(c.id))}function Vh(e,t,n,r){let i=sa(e,t);if(i===null||e===null)return null;let a=e.model.nodes.find(s=>s.id===i.id),o=Zb(e,i.id,n);return{id:i.id,title:i.title,kind:i.kind,icon:i.icon,crumb:jb(e,i.id),who:a.provenance===null?null:{provenance:a.provenance,glyph:Ut(a.provenance),word:Kb[a.provenance],title:cn(a.provenance)},when:Wt(a.detail.updated,r),text:Yb(a,n?.terms??[]),litBecause:Ub(n,i.id),connected:o.slice(0,Bb),connectedTotal:o.length}}var jh="(prefers-color-scheme: light)";function Qr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(jh).matches?"light":"dark"}function qh(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(jh);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}var Xb=.06,Qb=.2,Ws=.001,Yh=.5;function Zh(e,t){if(e.nodes.length===0)return null;let n=e.nodes.map(s=>{let l=t?.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:hs(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,a=[];for(let s of e.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),a.push({source:s.source,target:s.target,kind:s.kind}))}let o=ps({nodes:n,links:a,seed:1}).alpha(Xb).alphaMin(Ws);return{tick(){o.tick()},awake(){return o.alphaTarget()>Ws||o.alpha()>Ws},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let c=r.get(s);if(!c)return;let u=c.fx!=null&&c.fy!=null&&Math.abs(c.fx-l.x)<Yh&&Math.abs(c.fy-l.y)<Yh;c.fx=l.x,c.fy=l.y,o.alphaTarget(u?0:Qb)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,o.alphaTarget(0))}}}var Jr="application/x-weave-note";function Xh(e,t){return t.startsWith("note:")&&e?.model.nodes.some(n=>n.id===t&&n.kind==="note")?t:null}function Us(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function Qh(e,t){return t!==null&&t===e}function Jh(e,t,n){let r=e.panes.find(s=>s.id===n)??Sn(e),i=e.panes.find(s=>s.id!==r.id),a=ln(e,t,{newTab:!0,paneId:i?.id??r.id});if(a===e)return e;let o=a;if(i===void 0){let{lastDocumentTab:s,...l}=a.panes[0],c=l.tabs.at(-1),u={...a,panes:[{...l,activeTab:r.activeTab,...r.lastDocumentTab===void 0?{}:{lastDocumentTab:r.lastDocumentTab}}]};o=tr(u,r.id,c.id)}return e.preferences.focusNewTabs?o:{...o,activePane:r.id}}function ep(e,t,n){return e.map(r=>{let i=t?.model.nodes.find(o=>o.id===r),a=i?.kind??(r.startsWith("vfolder:")?"module":r.startsWith("artifact:")?"file":"note");return{id:r,label:i?.label??r.replace(/^[^:]+:/,""),icon:Pn(a),selected:r===n}})}var tp={title:"Context"},Jb="—";function np(e,t,n=""){return{cwd:e===""?Jb:e,selection:ex(t),hint:n===""?"":`${n} search`}}function ex(e){return e===null?"nothing selected":e.startsWith("note:")&&e.length>5?`${e.slice(5)}.md`:e}var rp=6e4;function ei(e){return e?"⌘K":"Ctrl K"}function ip(e){return`Search notes and repository (${e})`}function ti(e){return/mac|iphone|ipad/i.test(e)}var tx={k:{type:"openSearch"},",":{type:"openSettings"}},ap={1:"tree",2:"note",3:"graph"};function nx(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function rx(e){return!e.ctrl&&!e.meta&&!e.alt}var ix={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"},"]":{type:"toggleContext"}};function op(e,t){if(t.overlay!==null)return e.key==="Escape"?{type:"closeOverlay"}:null;if(e.alt&&!e.meta&&!e.ctrl&&!e.shift&&e.key.toLowerCase()==="w")return{type:"closeTab"};if(nx(e)){let n=tx[e.key.toLowerCase()];if(n!==void 0)return n;let r=ap[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection&&e.navigating?{type:"clearSelection"}:null:!rx(e)||e.typing?null:ix[e.key]??null}var ax=["INPUT","TEXTAREA","SELECT"];function Bs(e,t){return t?!0:e!==null&&ax.includes(e.toUpperCase())}var ox=".weave-sidebar-notes, .weave-graph-host";function sp(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:Bs(e.target?.tagName??null,e.target?.isContentEditable===!0),navigating:(e.target?.closest?.(ox)??null)!==null}}var cr={tree:".weave-sidebar-notes .weave-rows",note:".weave-pane-active .weave-note-body",graph:".weave-graph-host .weave-graph-canvas"},Ks=".weave-sidebar-notes .weave-filter";function sx(e){let t=e;return typeof t?.focus=="function"?t:null}function ba(e,t){let n=sx(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function lp(e,t){switch(e.type){case"openSearch":return t.setOverlay("search");case"openSettings":return t.setOverlay("settings");case"openHelp":return t.setOverlay("help");case"closeOverlay":return t.setOverlay(null);case"focusColumn":return void t.focusSelector(cr[e.column]);case"filterTree":return void t.focusSelector(Ks);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"closeTab":return t.closeTab();case"toggleTheme":return t.toggleTheme();case"toggleContext":return t.toggleContext()}}function xa(e){return[{title:"Global",entries:[{combo:"⌥W / Alt W",what:"Close the active tab"},{combo:`${e},`,what:"Open settings"},{combo:`${e}K`,what:"Search notes and the repository"},...Object.entries(ap).map(([t,n])=>({combo:`${e}${t}`,what:n==="tree"?"Open and focus the notes sidebar":n==="graph"?"Open and focus Graph view":"Focus the note"})),{combo:"?",what:"This help"},{combo:"t",what:"Switch between selected light and dark themes"},{combo:"]",what:"Fold or unfold Context"},{combo:"Esc",what:"Clear the selection from the tree or graph, 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:"Tabs and panes",entries:[{combo:"Alt ← / →",what:"Reorder the focused tab"},{combo:"← / → / Home / End",what:"Select a tab when the tab strip is focused"},{combo:`${e}click`,what:"Open a note or search result in a new tab"},{combo:"Pane options (···)",what:"Split right or down, move a tab, or close a pane"}]},{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:`${e}↵`,what:"Open the highlighted result in a new tab"},{combo:"Tab / ⇧Tab",what:"Switch between All, Notes, Code and Tags"},{combo:"⇧↵",what:"Light up the matches in the graph"},{combo:"Esc",what:"Close the palette"}]}]}var Vs="Keyboard shortcuts",cp="esc close";var ka={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},sidebar:{d:["M2.75 3.25h10.5v9.5H2.75Z","M6.25 3.25v9.5"],filled:!1},graph:{d:["M5.5 4a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z","M13.5 5a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z","M8.5 12a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z","M5.5 4.3 10.5 4.8M4.6 5.4l1.9 5.2M11.3 6.3 8.3 10.8"],filled:!1},noteGraph:{d:["M3.25 2.75h9.5v10.5h-9.5Z","M10.5 8a2.5 2.5 0 1 1-5 0a2.5 2.5 0 1 1 5 0Z"],filled:!1},search:{d:["M11 7a4 4 0 1 1-8 0a4 4 0 1 1 8 0Z","m10 10 3.5 3.5"],filled:!1},context:{d:["M2.75 3.25h10.5v9.5H2.75Z","M9.75 3.25v9.5"],filled:!1},refresh:{d:["M13 8a5 5 0 1 1-1.5-3.55","M13 2.75V5.5h-2.75"],filled:!1},settings:{d:["M6.50 3.65L6.89 1.70L9.11 1.70L9.50 3.65A4.6 4.6 0 0 1 11.02 4.53L12.90 3.89L14.01 5.81L12.52 7.12A4.6 4.6 0 0 1 12.52 8.88L14.01 10.19L12.90 12.11L11.02 11.47A4.6 4.6 0 0 1 9.50 12.35L9.11 14.30L6.89 14.30L6.50 12.35A4.6 4.6 0 0 1 4.98 11.47L3.10 12.11L1.99 10.19L3.48 8.88A4.6 4.6 0 0 1 3.48 7.12L1.99 5.81L3.10 3.89L4.98 4.53A4.6 4.6 0 0 1 6.50 3.65Z","M10 8a2 2 0 1 1-4 0a2 2 0 1 1 4 0Z"],filled:!1},sun:{d:["M10.5 8a2.5 2.5 0 1 1-5 0a2.5 2.5 0 1 1 5 0Z","M8 1.75V3M8 13v1.25M1.75 8H3M13 8h1.25M3.6 3.6l.9.9M11.5 11.5l.9.9M3.6 12.4l.9-.9M11.5 4.5l.9-.9"],filled:!1},moon:{d:["M13 9.75A5.25 5.25 0 0 1 6.25 3a5.25 5.25 0 1 0 6.75 6.75Z"],filled:!1},system:{d:["M13.25 8a5.25 5.25 0 1 1-10.5 0a5.25 5.25 0 1 1 10.5 0Z","M8 2.75v10.5"],filled:!1},history:{d:["M13.25 8a5.25 5.25 0 1 1-10.5 0a5.25 5.25 0 1 1 10.5 0Z","M8 5v3l2 1.5"],filled:!1},edit:{d:["M10.75 2.75 13.25 5.25 6 12.5H3.5V10Z","M9.25 4.25l2.5 2.5"],filled:!1},check:{d:["m3.25 8.5 3 3 6.5-6.75"],filled:!1},heading:{d:["M4 3v10M12 3v10M4 8h8"],filled:!1},bold:{d:["M4.5 3h4a2.5 2.5 0 0 1 0 5h-4Z","M4.5 8h4.75a2.5 2.5 0 0 1 0 5H4.5Z"],filled:!1},italic:{d:["M7 3h5M4 13h5M10 3 6 13"],filled:!1},link:{d:["M6.75 9.25l2.5-2.5","M7.25 4.75 8.5 3.5a2.5 2.5 0 0 1 3.5 3.5l-1.25 1.25","M8.75 11.25 7.5 12.5a2.5 2.5 0 0 1-3.5-3.5l1.25-1.25"],filled:!1},wikilink:{d:["M5.5 3H3.5v10h2","M10.5 3h2v10h-2"],filled:!1},task:{d:["M3 3h10v10H3Z","m5.5 8 1.75 1.75L10.75 6.25"],filled:!1},pin:{d:["M6 2.75h4l-.5 4 2 2v1h-7v-1l2-2Z","M8 9.75v3.5"],filled:!1},close:{d:["m4.25 4.25 7.5 7.5M11.75 4.25l-7.5 7.5"],filled:!1},folder:{d:["M2.75 4.25h3.5l1.25 1.5h5.75v6.5H2.75Z"],filled:!1}};var lx=0;function p(e,t,n,r,i,a){t||(t={});var o,s,l=t;if("ref"in l)for(s in l={},t)s=="ref"?o=t[s]:l[s]=t[s];var c={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--lx,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(o=e.defaultProps))for(s in o)l[s]===void 0&&(l[s]=o[s]);return le.vnode&&le.vnode(c),c}function ce({name:e,class:t}){let n=ka[e];return p("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=>p("path",{d:r}))})}function cx({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:a,onToggle:o,onMenu:s,onDrop:l}){let c=Qo(e.id);return p("li",{id:e.domId,"data-row-id":e.id,class:`weave-row weave-row-${e.kind}${e.selected?" weave-row-on":""}${t.has(e.id)?" weave-row-new":""}`,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:ku(e.depth),onClick:u=>a(u.metaKey||u.ctrlKey),draggable:e.id.startsWith("note:"),"aria-label":e.id===ir?"New folder":void 0,onDragStart:u=>{u.dataTransfer?.setData("text/plain",e.id),u.dataTransfer?.setData(Jr,e.id),u.dataTransfer&&(u.dataTransfer.effectAllowed="copyMove")},onDragOver:c===void 0?void 0:u=>u.preventDefault(),onDrop:c===void 0?void 0:u=>{u.preventDefault(),l(u.dataTransfer?.getData("text/plain")??"")},onContextMenu:u=>{u.preventDefault(),u.stopPropagation(),s(u.clientX,u.clientY)},children:[p("span",{class:"weave-twisty","aria-hidden":"true",onClick:u=>{u.stopPropagation(),o()},children:e.hasKids?p(ce,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),p("span",{class:"weave-kind","aria-hidden":"true",children:p(ce,{name:e.kindIcon,class:"weave-icon"})}),p("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),n===null?p("span",{class:"weave-label",children:e.label}):p(ux,{value:n,draft:e.id===ir,onEdit:r,onCommit:i}),p("span",{class:"weave-meta",children:e.meta})]})}function ux({value:e,draft:t,onEdit:n,onCommit:r}){let i=V(null);return ze(()=>{let a=i.current;a!==null&&(a.focus(),a.select())},[]),p("input",{ref:i,class:"weave-tree-rename",value:e,placeholder:t?"New folder name…":void 0,onClick:a=>a.stopPropagation(),onInput:a=>n(a.currentTarget.value),onBlur:a=>r(a.currentTarget.value),onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"?a.currentTarget.blur():a.key==="Escape"&&r(null)}})}function dp(e){let[t,n]=K(lu),[r,i]=K(null),a=V(null);ze(()=>{r!==null&&a.current?.querySelector(".weave-menu button")?.focus()},[r?.id]);let o=()=>{i(null),a.current?.querySelector(".weave-tree-actions")?.focus()},[s,l]=K(null),[c,u]=K(null),d=hu(cu(e.graph,t),c),h=Lu(e.graph,d,t),f=async(y,b)=>{let _=await y;if(!_.ok)window.alert(_.message);else{let x=_.data.id??b;x!==void 0&&e.onSelect(x),e.onRefresh()}},g=async y=>{if(r===null)return;let b=Nn(r.id);if(i(null),b!==null){if(y==="newFolder"){let _=uu(b);n(x=>Zo(x,_)),u(_),l({id:ir,label:"",value:""})}else if(y==="rename")n(_=>Zo(_,b.path.split("/").slice(0,-1).join("/"))),l({id:r.id,label:r.label,value:r.label});else if(b.type!=="vault"){if(!e.onMutate(Ji(e.graph,b)))return;await f(b.type==="note"?Qc(_e,b.path):tu(_e,b.path),pu(e.selectedId,b)?"vault":void 0)}}},w=y=>{if(r!==null){if(Jo(y)&&r.armed!==!0){i({...r,armed:!0});return}g("delete")}},v=y=>{let b=s,_=c;if(l(null),u(null),b===null)return;let x=y?.trim();if(b.id===ir){let O=_===null||!x?null:du(_,x);O!==null&&f(Jc(_e,O));return}let C=Nn(b.id);if(C!==null&&x&&x!==b.label){if(!e.onMutate(Ji(e.graph,C)))return;f(C.type==="note"?Zc(_e,C.path,x):eu(_e,C.path,x))}};return p("div",{class:"weave-tree",ref:a,onKeyDown:y=>{if(r!==null&&y.key==="Escape"){y.preventDefault(),y.stopPropagation(),o();return}let b=y.target,_=wu(d,t,e.selectedId,y.key,Bs(b?.tagName??null,b?.isContentEditable===!0));_.handled&&(y.preventDefault(),n(_.state),_.selectedId!==null&&e.onSelect(_.selectedId,!1,!0))},children:[p("div",{class:"weave-tree-controls",children:[p("input",{type:"search",class:"weave-filter",value:t.query,placeholder:Eu,"aria-label":Au,title:Cu,onInput:y=>n(gu(t,y.currentTarget.value))}),p("button",{type:"button",class:"weave-chip",title:_u(t.provFilter),onClick:()=>n(mu(t)),children:["◧ ",Qi(t.provFilter)]}),p("button",{type:"button",class:"weave-chip",title:Su(t.showInternals),onClick:()=>n(vu(t)),children:["◧ ",Tu(t.showInternals)]}),p("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:y=>{let b=e.selectedId!==null&&Nn(e.selectedId)!==null?e.selectedId:"vault",_=y.currentTarget.getBoundingClientRect();i({id:b,label:e.graph?.model.nodes.find(x=>x.id===b)?.label??"Vault",x:_.left,y:_.bottom})},children:"···"})]}),h===null?p("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Ru,"aria-activedescendant":xu(d,e.selectedId)??void 0,onContextMenu:y=>{y.preventDefault(),i({id:"vault",label:"Vault",x:y.clientX,y:y.clientY})},children:bu(d,e.selectedId,e.now).map(y=>p(cx,{view:y,recentIds:e.recentIds,edit:s?.id===y.id?s.value:null,onEdit:b=>l(_=>_===null?null:{..._,value:b}),onRename:v,onSelect:b=>{e.onSelect(y.id,b),y.hasKids&&n(_=>Xo(_,y.id))},onToggle:()=>n(Xo(t,y.id)),onMenu:(b,_)=>i({id:y.id,label:y.label,x:b,y:_}),onDrop:b=>{let _=Qo(y.id);if(b.startsWith("note:")&&_!==void 0){let x=Nn(b);if(x!==null&&!e.onMutate(Ji(e.graph,x)))return;f(Xc(_e,b.slice(5),_))}}},y.id))}):p("p",{class:"weave-tree-empty",children:h}),p("p",{class:"weave-tree-count",children:Nu(d)}),r!==null&&Nn(r.id)!==null?(()=>{let y=Nn(r.id);return p(be,{children:[p("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:o}),p("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},onKeyDown:b=>{if(b.key==="Escape")b.preventDefault(),o();else if(["ArrowDown","ArrowUp","Home","End"].includes(b.key)){b.preventDefault();let _=[...b.currentTarget.querySelectorAll("button")],x=_.indexOf(document.activeElement),C=b.key==="Home"?0:b.key==="End"?_.length-1:(x+(b.key==="ArrowDown"?1:-1)+_.length)%_.length;_[C]?.focus()}b.stopPropagation()},children:[p("button",{type:"button",role:"menuitem",onClick:()=>{g("newFolder")},children:"New folder…"}),y.type!=="vault"?p(be,{children:[p("button",{type:"button",role:"menuitem",onClick:()=>{g("rename")},children:"Rename…"}),p("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>w(y),children:fu(y,r.label,r.armed===!0)})]}):null]})]})})():null]})}var hp=new Map;function pp(e){let t=V(null),n=V(null),r=V(null),i=V(null),a=V(!1),o=V(!1),s=_o(()=>{let{full:G,model:J}=R.current;G?n.current?.fit():n.current?.focus(J.highlight)},[]),l=_o(()=>{if(i.current!==null)return;let G=()=>{i.current=null;let J=r.current;if(J!==null){if(J.tick(),!J.awake()){(!a.current||o.current)&&(a.current=!0,o.current=!1,s());return}n.current?.setPositions(J.positions()),i.current=requestAnimationFrame(G)}};i.current=requestAnimationFrame(G)},[]),[c,u]=K(null),d=De(()=>(So(e.forces),JSON.stringify(e.forces)),[e.forces]),h=e.groupColors,f=e.scheme??Qr(e.host),g=Nd(e.graph,c),w=De(()=>Od(e.graph,e.selectedId,g,e.storage,f,e.bootFailed,h),[e.graph,e.selectedId,g,e.storage,f,e.bootFailed,d,h]),v=e.onQuery!==void 0,y=v?e.query??"":"",b=De(()=>Fh(e.graph,y,e.found),[e.graph,y,e.found]),_=De(()=>$h(b,w.representative),[b,w.representative]),x=De(()=>Pd(w.highlight,e.selectedId,_),[w.highlight,e.selectedId,_]),C=v?null:sa(e.graph,e.previewId),O=e.now??Date.now(),N=De(()=>v?Vh(e.graph,e.previewId,b,O):null,[v,e.graph,e.previewId,b,O]),j=V(null),P=V(hp);P.current=e.trail??hp;let R=V({view:g,model:w,picture:x,full:v,onSelect:e.onSelect,selectedId:e.selectedId});R.current={view:g,model:w,picture:x,full:v,onSelect:e.onSelect,selectedId:e.selectedId},ne(()=>{let G=e.renderer(f);G.onSelect(X=>{let se=Fd(R.current.view,R.current.model.clusters,X);u(se.state),R.current.onSelect(se.selectedId)}),G.onHover(X=>{let{model:se,picture:Ye}=R.current,Ae=Dd(se.graph.edges,X,Ye);G.setHighlight(Ae.highlight,Ae.selectedId,Ae.style)}),G.onDragStart(X=>{let se=n.current?.positions().get(X);se&&(r.current?.pin(X,se),l())}),G.onDragMove((X,se)=>{r.current?.pin(X,se)}),G.onDragEnd(X=>{r.current?.release(X)}),G.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=G,G.setGraph(R.current.model.graph);let J=R.current.picture;return G.setHighlight(J.highlight,J.selectedId,J.style),G.setTrail(P.current),e.fit.current=()=>G.fit(),()=>{G.destroy(),n.current=null,e.fit.current=null}},[e.renderer,f]),ne(()=>{n.current?.setGraph(w.graph)},[w.key,d,h]),ne(()=>{let G=Zh(w.graph,n.current?.positions());return r.current=G,G!==null&&l(),()=>{r.current=null}},[w.key,l,d]),ne(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),ne(()=>{n.current?.setHighlight(x.highlight,x.selectedId,x.style)},[x]),ne(()=>{a.current&&(i.current!==null?o.current=!0:s())},[v,v?null:e.selectedId]),ne(()=>{n.current?.setTrail(P.current)},[e.trail]);let H=G=>{G.key!=="Escape"||!zh(y,G.target===j.current,N!==null)||(G.preventDefault(),e.onQuery?.(""))},Z=N===null?null:Hh(N.connected.length,N.connectedTotal);return p("div",{class:"weave-graph",onKeyDown:H,children:[w.empty===null?null:p("p",{class:"weave-graph-empty",children:w.empty}),p("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),v?p("div",{class:`weave-spotlight${b===null?"":" weave-spotlight-on"}`,role:"search",children:[p("svg",{class:"weave-spotlight-icon",viewBox:"0 0 20 20",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":1.8,"aria-hidden":"true",children:[p("circle",{cx:"8.5",cy:"8.5",r:"5.5"}),p("path",{d:"m13 13 4 4"})]}),p("input",{ref:j,class:"weave-spotlight-input",type:"search",value:y,placeholder:Ph,"aria-label":Dh,spellcheck:!1,autoComplete:"off",onInput:G=>e.onQuery?.(G.currentTarget.value)}),b===null?null:p(be,{children:[e.byAgent===!0?p("span",{class:"weave-spotlight-by",title:Gh,children:Mh}):null,p("span",{class:`weave-spotlight-count${b.count===0?" weave-spotlight-none":""}`,role:"status",children:Oh(b.count)}),p("button",{type:"button",class:"weave-spotlight-clear",title:Fs,"aria-label":Fs,onClick:()=>{e.onQuery?.(""),j.current?.focus()},children:Ih})]})]}):null,N===null?null:p("aside",{class:"weave-sheet","aria-label":Wh,children:[p("button",{type:"button",class:"weave-sheet-close","aria-label":Hs,title:Hs,onClick:()=>e.onSelect(null),children:"×"}),p("p",{class:"weave-sheet-crumb",children:[p(ce,{name:N.crumb===""?N.icon:"module",class:"weave-icon"}),p("span",{children:N.crumb===""?N.kind:N.crumb})]}),p("h2",{class:"weave-sheet-title",children:N.title}),p("p",{class:"weave-sheet-meta",children:[N.who===null?null:p("span",{class:`weave-prov weave-prov-${N.who.provenance}`,title:N.who.title,"aria-hidden":"true",children:N.who.glyph}),p("span",{children:N.who===null?N.kind:N.who.word}),N.when===""?null:p("span",{class:"weave-sheet-when",children:["· ",N.when]})]}),N.text===null?null:p("div",{class:"weave-sheet-text",children:[p("span",{class:"weave-sheet-text-head",children:N.text.heading}),N.text.parts.map(G=>G.hit?p("mark",{class:"weave-sheet-mark",children:G.text}):G.text)]}),N.litBecause===null?null:p("p",{class:"weave-sheet-why",children:[p("span",{"aria-hidden":"true",children:"✳"}),Kh," ",N.litBecause]}),N.connectedTotal===0?null:p("section",{class:"weave-sheet-section","aria-label":zs,children:[p("h3",{class:"weave-sheet-heading",children:[zs,p("span",{class:"weave-sheet-count",children:N.connectedTotal})]}),p("ul",{class:"weave-sheet-rows",children:N.connected.map(G=>p("li",{children:p("button",{type:"button",class:"weave-sheet-row",title:G.label,"aria-label":G.ariaLabel,onClick:()=>e.onSelect(G.id),children:[p("span",{class:`weave-sheet-dot${G.lit?" weave-sheet-dot-lit":""}`,"aria-hidden":"true"}),p("span",{class:"weave-sheet-row-label",children:G.label})]})},G.id))}),Z===null?null:p("p",{class:"weave-sheet-more",children:Z})]}),p("div",{class:"weave-sheet-actions",children:[p("button",{type:"button",class:"weave-sheet-open",onClick:()=>e.onOpen(N.id),children:Uh}),e.onOpenSplit===void 0?null:p("button",{type:"button",class:"weave-sheet-split",onClick:()=>e.onOpenSplit?.(N.id),children:Bh})]})]}),C===null?null:p("aside",{class:"weave-graph-preview","aria-label":"Selected graph node",children:[p("div",{class:"weave-graph-preview-info",children:[p("span",{class:"weave-kind","aria-hidden":"true",children:p(ce,{name:C.icon,class:"weave-icon"})}),p("div",{class:"weave-graph-preview-copy",children:[p("span",{class:"weave-graph-preview-kind",children:C.kind}),p("strong",{class:"weave-graph-preview-title",title:C.title,children:C.title})]})]}),p("button",{type:"button",class:"weave-graph-preview-close","aria-label":"Clear graph selection",onClick:()=>e.onSelect(null),children:"×"}),p("button",{type:"button",class:"weave-chip",onClick:()=>e.onOpen(C.id),children:"Open in new tab"})]}),p("div",{class:"weave-graph-controls",children:[p("button",{type:"button",class:"weave-chip",title:Md,onClick:()=>n.current?.fit(),children:Id}),p("span",{class:"weave-graph-legend",children:[p("span",{class:"weave-legend-on",children:["◉ ",la.selected]}),b===null?p("span",{class:"weave-legend-near",children:["● ",la.neighborhood]}):p("span",{class:"weave-legend-lit",children:["● ",$s.lit]}),p("span",{class:"weave-legend-dim",children:["· ",b===null?la.dimmed:$s.dimmed]})]})]}),p("p",{class:"weave-graph-count",children:Gd(w.visible,w.total)})]})}function dx(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 Hn(e){var t=dx(e,"string");return typeof t=="symbol"?t:t+""}function Ie(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function fp(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,Hn(r.key),r)}}function Me(e,t,n){return t&&fp(e.prototype,t),n&&fp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function zn(e){return zn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},zn(e)}function gp(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(gp=function(){return!!e})()}function hx(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function px(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 hx(e)}function Qe(e,t,n){return t=zn(t),px(e,gp()?Reflect.construct(t,n||[],zn(e).constructor):t.apply(e,n))}function js(e,t){return js=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},js(e,t)}function Je(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&&js(e,t)}function fx(e){if(Array.isArray(e))return e}function gx(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}function _a(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 Xs(e,t){if(e){if(typeof e=="string")return _a(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)?_a(e,t):void 0}}function mx(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
99
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hn(e,t){return fx(e)||gx(e,t)||Xs(e,t)||mx()}var qs={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 mp=new Int8Array(4),Ys=new Int32Array(mp.buffer,0,1),vx=new Float32Array(mp.buffer,0,1),wx=/^\s*rgba?\s*\(/,yx=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function bx(e){var t=0,n=0,r=0,i=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(wx.test(e)){var a=e.match(yx);a&&(t=+a[1],n=+a[2],r=+a[3],a[4]&&(i=+a[4]))}return{r:t,g:n,b:r,a:i}}var ur={};for(ni in qs)ur[ni]=dr(qs[ni]),ur[qs[ni]]=ur[ni];var ni;function vp(e,t,n,r,i){return Ys[0]=r<<24|n<<16|t<<8|e,i&&(Ys[0]=Ys[0]&4278190079),vx[0]}function dr(e){if(e=e.toLowerCase(),typeof ur[e]<"u")return ur[e];var t=bx(e),n=t.r,r=t.g,i=t.b,a=t.a;a=a*255|0;var o=vp(n,r,i,a,!0);return ur[e]=o,o}var Zs={};function Qs(e){if(typeof Zs[e]<"u")return Zs[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,a=vp(t,n,r,i,!0);return Zs[e]=a,a}function Js(e,t,n,r){return n+(t<<8)+(e<<16)}function el(e,t,n,r,i,a){var o=Math.floor(n/a*i),s=Math.floor(e.drawingBufferHeight/a-r/a*i),l=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(o,s,1,1,e.RGBA,e.UNSIGNED_BYTE,l);var c=hn(l,4),u=c[0],d=c[1],h=c[2],f=c[3];return[u,d,h,f]}function A(e,t,n){return(t=Hn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?wp(Object(n),!0).forEach(function(r){A(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function xx(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=zn(e))!==null;);return e}function rl(){return rl=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=xx(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},rl.apply(null,arguments)}function Sp(e,t,n,r){var i=rl(zn(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(a){return i.apply(n,a)}:i}function kx(e){return e.normalized?1:e.size}function tl(e){var t=0;return e.forEach(function(n){return t+=kx(n)}),t}function Ep(e,t,n){var r=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(i,n),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var o=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`loadShader: error while compiling the shader:
96
+ `,u),h=d===-1?l.raw.length:d,f=l.raw.slice(u,h).replace(/\r$/,""),g=Mb.exec(f);g!==null&&t.push(c+u+g[1].length),u=d===-1?l.raw.length:d+1}}let i=new fa,a=l=>{let c=[];return i.walkTokens(st.lex(l,{gfm:!0}),u=>{u.type==="checkbox"&&c.push(u.checked)}),c},o=a(n),s=o.map(()=>null);for(let l of t){let c=`${n.slice(0,l)}${n[l]===" "?"x":" "}${n.slice(l+1)}`,u=a(c);if(u.length!==o.length)continue;let d=-1;for(let h=0;h<o.length;h+=1)if(u[h]!==o[h]){if(d!==-1){d=-1;break}d=h}d!==-1&&(s[d]=l)}return s.map(l=>{if(l===null)return null;let c=0,u=0;for(;u<l;)c+=e[c]==="\r"&&e[c+1]===`
97
+ `?2:1,u+=1;return c})}function mh(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=Gb(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function vh(e){let t=e?.getAttribute($n);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var wh=32;function Is(e){let t=e;for(let n=0;t!==null&&n<wh;n++){let r=t.getAttribute(jt);if(r!==null&&r!=="")return`${ma}${r}`;t=t.parentElement}return null}function yh(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 bh="edited",xh="created",kh="Edit",_h="Done";var Th="Note body",Sh="Start writing…",Eh="Raw notes",Rh="Raw notes text",Ah="Raw";function Ch(e,t){if(t)return"Your words as captured. Edits here are saved with the note.";let n=e.match(/^<!-- appended\b/gm)?.length??0;if(n>0)return`${n} ${n===1?"entry":"entries"} captured`;let r=e===""?0:e.split(`
98
+ `).length;return`${r} ${r===1?"line":"lines"}`}var ya="Discard unsaved changes to this note?";function Ob(e){return e==="human"?"You wrote this":e==="agent"?"Agent wrote this":"Generated by pi-weave"}var Fb="Vault";function $b(e){return[Fb,...e.split("/").slice(0,-1)].join(" / ")}function Lh(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:Bt(e.source),provenanceTitle:un(e.source),updated:Ut(e.updated,t),updatedIso:e.updated,created:Ut(e.created,t),createdIso:e.created,tags:e.tags,byline:Ob(e.source),folder:$b(e.slug)}}function Nh(e){return`#${e}`}var zb=200,Hb=8,Wb="no note";function Ms(e){let t=e;for(let n=0;t!==null&&n<wh;n++){let r=t.getAttribute(jt);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 Gs(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 Xr(e,t=zb){let n=Gs(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function Ph(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:Wb,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} · ${un(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Xr(n.detail.preview??"")}}function Dh(e,t,n,r,i,a,o=Hb){let s=e+o,l=t+o;return s+n>i-o&&(s=e-o-n),l+r>a-o&&(l=t-o-r),s=Math.min(Math.max(s,o),Math.max(o,i-o-n)),l=Math.min(Math.max(l,o),Math.max(o,a-o-r)),{x:s,y:l}}var va={anchor:null,pointerX:0,pointerY:0};function Ih(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:va;case"dismiss":return va}}function Mh(e,t,n=!1){return t!==null?null:e===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":n?"Couldn’t load this note — retrying…":e.startsWith(ma)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var Oh="Light up notes, tags or code",Fh="Light up in graph",$h="Esc",zs="Clear the spotlight (Esc)",zh="agent",Hh="Your agent searched for this. Type to light up something else.",Hs={lit:"lit",dimmed:"not lit"},Ub="search match";function Wh(e){return e===0?"no matches":`${e} lit`}function Bb(e){let t=[];for(let n of e.toLowerCase().split(/\s+/)){let r=n.startsWith("#"),i=r?n.replace(/^#+/,""):n;i!==""&&t.push({text:i,tagOnly:r})}return t}function Kb(e){let t=e.detail.path??e.detail.slug;if(typeof t=="string"&&t!=="")return t;let n=e.id.indexOf(":");return n===-1?"":e.id.slice(n+1)}function Vb(e){let t=new Map;for(let[n,r]of Object.entries(e.tags))for(let i of r){let a=`note:${i}`,o=t.get(a);o===void 0?t.set(a,[n]):o.includes(n)||o.push(n)}return t}function jb(e,t,n){let r=e.label.toLowerCase(),i=Kb(e).toLowerCase(),a=!1,o=!1,s=[];for(let c of n){let u=!c.tagOnly&&r.includes(c.text),d=t.filter(f=>f.toLowerCase().includes(c.text)),h=!c.tagOnly&&!u&&d.length===0&&i.includes(c.text);if(!u&&d.length===0&&!h)return null;a||=u,o||=h;for(let f of d)s.includes(f)||s.push(f)}let l=t.filter(c=>s.includes(c));return[...a?["title"]:[],...l.map(c=>`tag #${c}`),...o?["path"]:[]]}function Uh(e,t,n=[]){let r=Bb(t);if(r.length===0)return null;let i=new Set,a=new Map;if(e!==null){let o=Vb(e);for(let l of e.model.nodes){if(i.has(l.id))continue;let c=jb(l,o.get(l.id)??[],r);c!==null&&(i.add(l.id),a.set(l.id,c))}let s=new Set(n);for(let l of e.model.nodes)i.has(l.id)||!s.has(l.id)||(i.add(l.id),a.set(l.id,[Ub]))}return{terms:r,lit:i,reasons:a,count:i.size}}function Bh(e,t){if(e===null)return null;let n=new Set;for(let r of e.lit)n.add(t.get(r)??r);return n}function qb(e,t){let n=e?.reasons.get(t);return n===void 0||n.length===0?null:n.join(", ")}function Kh(e,t,n){return e!==""&&(t||!n)}function Os(e,t){let n=[...new Set(t.map(s=>s.text))].sort((s,l)=>l.length-s.length),r=e.toLowerCase(),i=[],a=0,o="";for(;a<e.length;){let s=n.find(l=>r.startsWith(l,a));if(s===void 0){o+=e[a],a+=1;continue}o!==""&&i.push({text:o,hit:!1}),o="",i.push({text:e.slice(a,a+s.length),hit:!0}),a+=s.length}return o!==""&&i.push({text:o,hit:!1}),i}var Yb=6,Ws="Connected";function Vh(e,t){return t>e?`+${t-e} more`:null}var jh="Graph node details",Us="Close details",qh="Open",Yh="Open in split",Zh="Lit because:",Zb={human:"You",agent:"Agent",generated:"Generated"},$s=new Set(["contains","anchored-at"]);function Xb(e){let t=new Map;for(let n of e)$s.has(n.kind)&&!t.has(n.target)&&n.source!==n.target&&t.set(n.target,n.source);return t}var Gh=3;function Qb(e,t){let n=Xb(e.model.edges),r=new Map(e.model.nodes.map(c=>[c.id,c.label])),i=[],a=new Set([t]),o=n.get(t);for(;o!==void 0&&!a.has(o);)a.add(o),i.unshift(r.get(o)??o),o=n.get(o);let s=i.length>1?i.slice(1):i;return(s.length>Gh?["…",...s.slice(-Gh)]:s).join(" / ")}function Jb(e){let t=/\*\*TL;?DR:?\*\*:?|(?:^|\s)TL;?DR:/i.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=n.search(/(?:^|\s)#{1,6}\s|\*\*[^*]+:\*\*/);r>=0&&(n=n.slice(0,r));let i=Gs(n.replace(/(?:^|\s)[-*+]\s+\[[xX]\]\s*/g," ☑ ").replace(/(?:^|\s)[-*+]\s+\[ \]\s*/g," ☐ ").replace(/(?:^|\s)[-*+]\s+/g," · ")).replace(/\s+/g," ").replace(/^\s*·\s*/,"").trim();return i===""?null:i}var Fs=200;function ex(e,t){let n=e.detail.preview??"",r=Jb(n);if(r!==null)return{heading:"TLDR",parts:Os(Xr(r,Fs),t)};let i=e.detail.summary??e.detail.description??"";if(i.trim()!=="")return{heading:"Summary",parts:Os(Xr(i,Fs),t)};let a=Xr(n,Fs);return a===""?null:{heading:"Preview",parts:Os(a,t)}}function tx(e,t,n){let r=new Map(e.model.nodes.map(l=>[l.id,l])),i=l=>{let c=[];for(let u of e.model.edges){let d=l(u);d!==null&&d!==t&&r.has(d)&&!c.includes(d)&&c.push(d)}return c},a=i(l=>$s.has(l.kind)?null:l.source===t?l.target:l.target===t?l.source:null);return(a.length>0?a:i(l=>$s.has(l.kind)&&l.source===t?l.target:null)).map(l=>{let c=r.get(l),u=n?.lit.has(l)??!1;return{id:l,label:c.label,lit:u,ariaLabel:u?`${c.label} (lit)`:c.label}}).sort((l,c)=>Number(c.lit)-Number(l.lit)||l.label.localeCompare(c.label)||l.id.localeCompare(c.id))}function Xh(e,t,n,r){let i=sa(e,t);if(i===null||e===null)return null;let a=e.model.nodes.find(s=>s.id===i.id),o=tx(e,i.id,n);return{id:i.id,title:i.title,kind:i.kind,icon:i.icon,crumb:Qb(e,i.id),who:a.provenance===null?null:{provenance:a.provenance,glyph:Bt(a.provenance),word:Zb[a.provenance],title:un(a.provenance)},when:Ut(a.detail.updated,r),text:ex(a,n?.terms??[]),litBecause:qb(n,i.id),connected:o.slice(0,Yb),connectedTotal:o.length}}var Qh="(prefers-color-scheme: light)";function Qr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(Qh).matches?"light":"dark"}function Jh(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(Qh);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}var nx=.06,rx=.2,Bs=.001,ep=.5;function tp(e,t){if(e.nodes.length===0)return null;let n=e.nodes.map(s=>{let l=t?.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:fs(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,a=[];for(let s of e.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),a.push({source:s.source,target:s.target,kind:s.kind}))}let o=gs({nodes:n,links:a,seed:1}).alpha(nx).alphaMin(Bs);return{tick(){o.tick()},awake(){return o.alphaTarget()>Bs||o.alpha()>Bs},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let c=r.get(s);if(!c)return;let u=c.fx!=null&&c.fy!=null&&Math.abs(c.fx-l.x)<ep&&Math.abs(c.fy-l.y)<ep;c.fx=l.x,c.fy=l.y,o.alphaTarget(u?0:rx)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,o.alphaTarget(0))}}}var Jr="application/x-weave-note";function np(e,t){let n=t.startsWith("note:")?"note":t.startsWith("artifact:")?"file":null;return n!==null&&e?.model.nodes.some(r=>r.id===t&&r.kind===n)?t:null}function Ks(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function rp(e,t){return t!==null&&t===e}function ip(e,t,n){let r=e.panes.find(s=>s.id===n)??En(e),i=e.panes.find(s=>s.id!==r.id),a=cn(e,t,{newTab:!0,paneId:i?.id??r.id});if(a===e)return e;let o=a;if(i===void 0){let{lastDocumentTab:s,...l}=a.panes[0],c=l.tabs.at(-1),u={...a,panes:[{...l,activeTab:r.activeTab,...r.lastDocumentTab===void 0?{}:{lastDocumentTab:r.lastDocumentTab}}]};o=tr(u,r.id,c.id)}return e.preferences.focusNewTabs?o:{...o,activePane:r.id}}function ap(e,t,n){return e.map(r=>{let i=t?.model.nodes.find(o=>o.id===r),a=i?.kind??(r.startsWith("vfolder:")?"module":r.startsWith("artifact:")?"file":"note");return{id:r,label:i?.label??r.replace(/^[^:]+:/,""),icon:Pn(a),selected:r===n}})}var op={title:"Context"},ix="—";function sp(e,t,n=""){return{cwd:e===""?ix:e,selection:ax(t),hint:n===""?"":`${n} search`}}function ax(e){return e===null?"nothing selected":e.startsWith("note:")&&e.length>5?`${e.slice(5)}.md`:e}var lp=6e4;function ei(e){return e?"⌘K":"Ctrl K"}function cp(e){return`Search notes and repository (${e})`}function ti(e){return/mac|iphone|ipad/i.test(e)}var ox={k:{type:"openSearch"},",":{type:"openSettings"}},up={1:"tree",2:"note",3:"graph"};function sx(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function lx(e){return!e.ctrl&&!e.meta&&!e.alt}var cx={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"},"]":{type:"toggleContext"}};function dp(e,t){if(t.overlay!==null)return e.key==="Escape"?{type:"closeOverlay"}:null;if(e.alt&&!e.meta&&!e.ctrl&&!e.shift&&e.key.toLowerCase()==="w")return{type:"closeTab"};if(sx(e)){let n=ox[e.key.toLowerCase()];if(n!==void 0)return n;let r=up[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection&&e.navigating?{type:"clearSelection"}:null:!lx(e)||e.typing?null:cx[e.key]??null}var ux=["INPUT","TEXTAREA","SELECT"];function Vs(e,t){return t?!0:e!==null&&ux.includes(e.toUpperCase())}var dx=".weave-sidebar-notes, .weave-graph-host";function hp(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:Vs(e.target?.tagName??null,e.target?.isContentEditable===!0),navigating:(e.target?.closest?.(dx)??null)!==null}}var cr={tree:".weave-sidebar-notes .weave-rows",note:".weave-pane-active .weave-note-body",graph:".weave-graph-host .weave-graph-canvas"},js=".weave-sidebar-notes .weave-filter";function hx(e){let t=e;return typeof t?.focus=="function"?t:null}function ba(e,t){let n=hx(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function pp(e,t){switch(e.type){case"openSearch":return t.setOverlay("search");case"openSettings":return t.setOverlay("settings");case"openHelp":return t.setOverlay("help");case"closeOverlay":return t.setOverlay(null);case"focusColumn":return void t.focusSelector(cr[e.column]);case"filterTree":return void t.focusSelector(js);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"closeTab":return t.closeTab();case"toggleTheme":return t.toggleTheme();case"toggleContext":return t.toggleContext()}}function xa(e){return[{title:"Global",entries:[{combo:"⌥W / Alt W",what:"Close the active tab"},{combo:`${e},`,what:"Open settings"},{combo:`${e}K`,what:"Search notes and the repository"},...Object.entries(up).map(([t,n])=>({combo:`${e}${t}`,what:n==="tree"?"Open and focus the notes sidebar":n==="graph"?"Open and focus Graph view":"Focus the note"})),{combo:"?",what:"This help"},{combo:"t",what:"Switch between selected light and dark themes"},{combo:"]",what:"Fold or unfold Context"},{combo:"Esc",what:"Clear the selection from the tree or graph, 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:"Tabs and panes",entries:[{combo:"Alt ← / →",what:"Reorder the focused tab"},{combo:"← / → / Home / End",what:"Select a tab when the tab strip is focused"},{combo:`${e}click`,what:"Open a note or search result in a new tab"},{combo:"Pane options (···)",what:"Split right or down, move a tab, or close a pane"}]},{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:`${e}↵`,what:"Open the highlighted result in a new tab"},{combo:"Tab / ⇧Tab",what:"Switch between All, Notes, Code and Tags"},{combo:"⇧↵",what:"Light up the matches in the graph"},{combo:"Esc",what:"Close the palette"}]}]}var qs="Keyboard shortcuts",fp="esc close";var ka={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},sidebar:{d:["M2.75 3.25h10.5v9.5H2.75Z","M6.25 3.25v9.5"],filled:!1},graph:{d:["M5.5 4a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z","M13.5 5a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z","M8.5 12a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z","M5.5 4.3 10.5 4.8M4.6 5.4l1.9 5.2M11.3 6.3 8.3 10.8"],filled:!1},noteGraph:{d:["M3.25 2.75h9.5v10.5h-9.5Z","M10.5 8a2.5 2.5 0 1 1-5 0a2.5 2.5 0 1 1 5 0Z"],filled:!1},search:{d:["M11 7a4 4 0 1 1-8 0a4 4 0 1 1 8 0Z","m10 10 3.5 3.5"],filled:!1},context:{d:["M2.75 3.25h10.5v9.5H2.75Z","M9.75 3.25v9.5"],filled:!1},refresh:{d:["M13 8a5 5 0 1 1-1.5-3.55","M13 2.75V5.5h-2.75"],filled:!1},settings:{d:["M6.50 3.65L6.89 1.70L9.11 1.70L9.50 3.65A4.6 4.6 0 0 1 11.02 4.53L12.90 3.89L14.01 5.81L12.52 7.12A4.6 4.6 0 0 1 12.52 8.88L14.01 10.19L12.90 12.11L11.02 11.47A4.6 4.6 0 0 1 9.50 12.35L9.11 14.30L6.89 14.30L6.50 12.35A4.6 4.6 0 0 1 4.98 11.47L3.10 12.11L1.99 10.19L3.48 8.88A4.6 4.6 0 0 1 3.48 7.12L1.99 5.81L3.10 3.89L4.98 4.53A4.6 4.6 0 0 1 6.50 3.65Z","M10 8a2 2 0 1 1-4 0a2 2 0 1 1 4 0Z"],filled:!1},sun:{d:["M10.5 8a2.5 2.5 0 1 1-5 0a2.5 2.5 0 1 1 5 0Z","M8 1.75V3M8 13v1.25M1.75 8H3M13 8h1.25M3.6 3.6l.9.9M11.5 11.5l.9.9M3.6 12.4l.9-.9M11.5 4.5l.9-.9"],filled:!1},moon:{d:["M13 9.75A5.25 5.25 0 0 1 6.25 3a5.25 5.25 0 1 0 6.75 6.75Z"],filled:!1},system:{d:["M13.25 8a5.25 5.25 0 1 1-10.5 0a5.25 5.25 0 1 1 10.5 0Z","M8 2.75v10.5"],filled:!1},history:{d:["M13.25 8a5.25 5.25 0 1 1-10.5 0a5.25 5.25 0 1 1 10.5 0Z","M8 5v3l2 1.5"],filled:!1},edit:{d:["M10.75 2.75 13.25 5.25 6 12.5H3.5V10Z","M9.25 4.25l2.5 2.5"],filled:!1},check:{d:["m3.25 8.5 3 3 6.5-6.75"],filled:!1},heading:{d:["M4 3v10M12 3v10M4 8h8"],filled:!1},bold:{d:["M4.5 3h4a2.5 2.5 0 0 1 0 5h-4Z","M4.5 8h4.75a2.5 2.5 0 0 1 0 5H4.5Z"],filled:!1},italic:{d:["M7 3h5M4 13h5M10 3 6 13"],filled:!1},link:{d:["M6.75 9.25l2.5-2.5","M7.25 4.75 8.5 3.5a2.5 2.5 0 0 1 3.5 3.5l-1.25 1.25","M8.75 11.25 7.5 12.5a2.5 2.5 0 0 1-3.5-3.5l1.25-1.25"],filled:!1},wikilink:{d:["M5.5 3H3.5v10h2","M10.5 3h2v10h-2"],filled:!1},task:{d:["M3 3h10v10H3Z","m5.5 8 1.75 1.75L10.75 6.25"],filled:!1},pin:{d:["M6 2.75h4l-.5 4 2 2v1h-7v-1l2-2Z","M8 9.75v3.5"],filled:!1},close:{d:["m4.25 4.25 7.5 7.5M11.75 4.25l-7.5 7.5"],filled:!1},folder:{d:["M2.75 4.25h3.5l1.25 1.5h5.75v6.5H2.75Z"],filled:!1}};var px=0;function p(e,t,n,r,i,a){t||(t={});var o,s,l=t;if("ref"in l)for(s in l={},t)s=="ref"?o=t[s]:l[s]=t[s];var c={type:e,props:l,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--px,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(o=e.defaultProps))for(s in o)l[s]===void 0&&(l[s]=o[s]);return le.vnode&&le.vnode(c),c}function ce({name:e,class:t}){let n=ka[e];return p("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=>p("path",{d:r}))})}function fx({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:a,onToggle:o,onMenu:s,onDrop:l}){let c=Jo(e.id);return p("li",{id:e.domId,"data-row-id":e.id,class:`weave-row weave-row-${e.kind}${e.selected?" weave-row-on":""}${t.has(e.id)?" weave-row-new":""}`,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:Ru(e.depth),onClick:u=>a(u.metaKey||u.ctrlKey),draggable:es(e.id)!==null,"aria-label":e.id===ir?"New folder":void 0,onDragStart:u=>{u.dataTransfer?.setData("text/plain",e.id),u.dataTransfer?.setData(Jr,e.id),u.dataTransfer&&(u.dataTransfer.effectAllowed="copyMove")},onDragOver:c===void 0?void 0:u=>u.preventDefault(),onDrop:c===void 0?void 0:u=>{u.preventDefault(),l(u.dataTransfer?.getData("text/plain")??"")},onContextMenu:u=>{u.preventDefault(),u.stopPropagation(),s(u.clientX,u.clientY)},children:[p("span",{class:"weave-twisty","aria-hidden":"true",onClick:u=>{u.stopPropagation(),o()},children:e.hasKids?p(ce,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),p("span",{class:"weave-kind","aria-hidden":"true",children:p(ce,{name:e.kindIcon,class:"weave-icon"})}),p("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),n===null?p("span",{class:"weave-label",children:e.label}):p(gx,{value:n,draft:e.id===ir,onEdit:r,onCommit:i}),p("span",{class:"weave-meta",children:e.meta})]})}function gx({value:e,draft:t,onEdit:n,onCommit:r}){let i=V(null);return ze(()=>{let a=i.current;a!==null&&(a.focus(),a.select())},[]),p("input",{ref:i,class:"weave-tree-rename",value:e,placeholder:t?"New folder name…":void 0,onClick:a=>a.stopPropagation(),onInput:a=>n(a.currentTarget.value),onBlur:a=>r(a.currentTarget.value),onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"?a.currentTarget.blur():a.key==="Escape"&&r(null)}})}function mp(e){let[t,n]=K(pu),[r,i]=K(null),a=V(null);ze(()=>{r!==null&&a.current?.querySelector(".weave-menu button")?.focus()},[r?.id]);let o=()=>{i(null),a.current?.querySelector(".weave-tree-actions")?.focus()},[s,l]=K(null),[c,u]=K(null),d=vu(fu(e.graph,t),c),h=Mu(e.graph,d,t),f=async(y,b)=>{let _=await y;if(!_.ok)window.alert(_.message);else{let x=_.data.id??b;x!==void 0&&e.onSelect(x),e.onRefresh()}},g=async y=>{if(r===null)return;let b=Nn(r.id);if(i(null),b!==null){if(y==="newFolder"){let _=gu(b);n(x=>Xo(x,_)),u(_),l({id:ir,label:"",value:""})}else if(y==="rename")n(_=>Xo(_,b.path.split("/").slice(0,-1).join("/"))),l({id:r.id,label:r.label,value:r.label});else if(b.type!=="vault"){if(!e.onMutate(Ji(e.graph,b)))return;await f(b.type==="note"?ru(we,b.path):b.type==="artifact"?nu(we,b.path):ou(we,b.path),wu(e.selectedId,b)?"vault":void 0)}}},w=y=>{if(r!==null){if(ts(y)&&r.armed!==!0){i({...r,armed:!0});return}g("delete")}},v=y=>{let b=s,_=c;if(l(null),u(null),b===null)return;let x=y?.trim();if(b.id===ir){let O=_===null||!x?null:mu(_,x);O!==null&&f(iu(we,O));return}let R=Nn(b.id);if(R!==null&&x&&x!==b.label){if(!e.onMutate(Ji(e.graph,R)))return;f(R.type==="note"?Qc(we,R.path,x):R.type==="artifact"?tu(we,R.path,x):au(we,R.path,x))}};return p("div",{class:"weave-tree",ref:a,onKeyDown:y=>{if(r!==null&&y.key==="Escape"){y.preventDefault(),y.stopPropagation(),o();return}let b=y.target,_=_u(d,t,e.selectedId,y.key,Vs(b?.tagName??null,b?.isContentEditable===!0));_.handled&&(y.preventDefault(),n(_.state),_.selectedId!==null&&e.onSelect(_.selectedId,!1,!0))},children:[p("div",{class:"weave-tree-controls",children:[p("input",{type:"search",class:"weave-filter",value:t.query,placeholder:Nu,"aria-label":Du,title:Iu,onInput:y=>n(bu(t,y.currentTarget.value))}),p("button",{type:"button",class:"weave-chip",title:Au(t.provFilter),onClick:()=>n(xu(t)),children:["◧ ",Qi(t.provFilter)]}),p("button",{type:"button",class:"weave-chip",title:Lu(t.showInternals),onClick:()=>n(ku(t)),children:["◧ ",Cu(t.showInternals)]}),p("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:y=>{let b=e.selectedId!==null&&Nn(e.selectedId)!==null?e.selectedId:"vault",_=y.currentTarget.getBoundingClientRect();i({id:b,label:e.graph?.model.nodes.find(x=>x.id===b)?.label??"Vault",x:_.left,y:_.bottom})},children:"···"})]}),h===null?p("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Pu,"aria-activedescendant":Eu(d,e.selectedId)??void 0,onContextMenu:y=>{y.preventDefault(),i({id:"vault",label:"Vault",x:y.clientX,y:y.clientY})},children:Su(d,e.selectedId,e.now).map(y=>p(fx,{view:y,recentIds:e.recentIds,edit:s?.id===y.id?s.value:null,onEdit:b=>l(_=>_===null?null:{..._,value:b}),onRename:v,onSelect:b=>{e.onSelect(y.id,b),y.hasKids&&n(_=>Qo(_,y.id))},onToggle:()=>n(Qo(t,y.id)),onMenu:(b,_)=>i({id:y.id,label:y.label,x:b,y:_}),onDrop:b=>{let _=Jo(y.id),x=es(b);if(x===null||_===void 0)return;if(x.type==="artifact"){f(eu(we,x.slug,_));return}let R=Nn(b);R!==null&&!e.onMutate(Ji(e.graph,R))||f(Jc(we,x.slug,_))}},y.id))}):p("p",{class:"weave-tree-empty",children:h}),p("p",{class:"weave-tree-count",children:Gu(d)}),r!==null&&Nn(r.id)!==null?(()=>{let y=Nn(r.id);return p(xe,{children:[p("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:o}),p("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},onKeyDown:b=>{if(b.key==="Escape")b.preventDefault(),o();else if(["ArrowDown","ArrowUp","Home","End"].includes(b.key)){b.preventDefault();let _=[...b.currentTarget.querySelectorAll("button")],x=_.indexOf(document.activeElement),R=b.key==="Home"?0:b.key==="End"?_.length-1:(x+(b.key==="ArrowDown"?1:-1)+_.length)%_.length;_[R]?.focus()}b.stopPropagation()},children:[p("button",{type:"button",role:"menuitem",onClick:()=>{g("newFolder")},children:"New folder…"}),y.type!=="vault"?p(xe,{children:[p("button",{type:"button",role:"menuitem",onClick:()=>{g("rename")},children:"Rename…"}),p("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>w(y),children:yu(y,r.label,r.armed===!0)})]}):null]})]})})():null]})}var vp=new Map;function wp(e){let t=V(null),n=V(null),r=V(null),i=V(null),a=V(!1),o=V(!1),s=_o(()=>{let{full:G,model:J}=A.current;G?n.current?.fit():n.current?.focus(J.highlight)},[]),l=_o(()=>{if(i.current!==null)return;let G=()=>{i.current=null;let J=r.current;if(J!==null){if(J.tick(),!J.awake()){(!a.current||o.current)&&(a.current=!0,o.current=!1,s());return}n.current?.setPositions(J.positions()),i.current=requestAnimationFrame(G)}};i.current=requestAnimationFrame(G)},[]),[c,u]=K(null),d=De(()=>(So(e.forces),JSON.stringify(e.forces)),[e.forces]),h=e.groupColors,f=e.scheme??Qr(e.host),g=Gd(e.graph,c),w=De(()=>Wd(e.graph,e.selectedId,g,e.storage,f,e.bootFailed,h),[e.graph,e.selectedId,g,e.storage,f,e.bootFailed,d,h]),v=e.onQuery!==void 0,y=v?e.query??"":"",b=De(()=>Uh(e.graph,y,e.found),[e.graph,y,e.found]),_=De(()=>Bh(b,w.representative),[b,w.representative]),x=De(()=>Od(w.highlight,e.selectedId,_),[w.highlight,e.selectedId,_]),R=v?null:sa(e.graph,e.previewId),O=e.now??Date.now(),N=De(()=>v?Xh(e.graph,e.previewId,b,O):null,[v,e.graph,e.previewId,b,O]),j=V(null),P=V(vp);P.current=e.trail??vp;let A=V({view:g,model:w,picture:x,full:v,onSelect:e.onSelect,selectedId:e.selectedId});A.current={view:g,model:w,picture:x,full:v,onSelect:e.onSelect,selectedId:e.selectedId},ne(()=>{let G=e.renderer(f);G.onSelect(X=>{let se=Ud(A.current.view,A.current.model.clusters,X);u(se.state),A.current.onSelect(se.selectedId)}),G.onHover(X=>{let{model:se,picture:Ye}=A.current,Ae=Fd(se.graph.edges,X,Ye);G.setHighlight(Ae.highlight,Ae.selectedId,Ae.style)}),G.onDragStart(X=>{let se=n.current?.positions().get(X);se&&(r.current?.pin(X,se),l())}),G.onDragMove((X,se)=>{r.current?.pin(X,se)}),G.onDragEnd(X=>{r.current?.release(X)}),G.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=G,G.setGraph(A.current.model.graph);let J=A.current.picture;return G.setHighlight(J.highlight,J.selectedId,J.style),G.setTrail(P.current),e.fit.current=()=>G.fit(),()=>{G.destroy(),n.current=null,e.fit.current=null}},[e.renderer,f]),ne(()=>{n.current?.setGraph(w.graph)},[w.key,d,h]),ne(()=>{let G=tp(w.graph,n.current?.positions());return r.current=G,G!==null&&l(),()=>{r.current=null}},[w.key,l,d]),ne(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),ne(()=>{n.current?.setHighlight(x.highlight,x.selectedId,x.style)},[x]),ne(()=>{a.current&&(i.current!==null?o.current=!0:s())},[v,v?null:e.selectedId]),ne(()=>{n.current?.setTrail(P.current)},[e.trail]);let H=G=>{G.key!=="Escape"||!Kh(y,G.target===j.current,N!==null)||(G.preventDefault(),e.onQuery?.(""))},Z=N===null?null:Vh(N.connected.length,N.connectedTotal);return p("div",{class:"weave-graph",onKeyDown:H,children:[w.empty===null?null:p("p",{class:"weave-graph-empty",children:w.empty}),p("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),v?p("div",{class:`weave-spotlight${b===null?"":" weave-spotlight-on"}`,role:"search",children:[p("svg",{class:"weave-spotlight-icon",viewBox:"0 0 20 20",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":1.8,"aria-hidden":"true",children:[p("circle",{cx:"8.5",cy:"8.5",r:"5.5"}),p("path",{d:"m13 13 4 4"})]}),p("input",{ref:j,class:"weave-spotlight-input",type:"search",value:y,placeholder:Oh,"aria-label":Fh,spellcheck:!1,autoComplete:"off",onInput:G=>e.onQuery?.(G.currentTarget.value)}),b===null?null:p(xe,{children:[e.byAgent===!0?p("span",{class:"weave-spotlight-by",title:Hh,children:zh}):null,p("span",{class:`weave-spotlight-count${b.count===0?" weave-spotlight-none":""}`,role:"status",children:Wh(b.count)}),p("button",{type:"button",class:"weave-spotlight-clear",title:zs,"aria-label":zs,onClick:()=>{e.onQuery?.(""),j.current?.focus()},children:$h})]})]}):null,N===null?null:p("aside",{class:"weave-sheet","aria-label":jh,children:[p("button",{type:"button",class:"weave-sheet-close","aria-label":Us,title:Us,onClick:()=>e.onSelect(null),children:"×"}),p("p",{class:"weave-sheet-crumb",children:[p(ce,{name:N.crumb===""?N.icon:"module",class:"weave-icon"}),p("span",{children:N.crumb===""?N.kind:N.crumb})]}),p("h2",{class:"weave-sheet-title",children:N.title}),p("p",{class:"weave-sheet-meta",children:[N.who===null?null:p("span",{class:`weave-prov weave-prov-${N.who.provenance}`,title:N.who.title,"aria-hidden":"true",children:N.who.glyph}),p("span",{children:N.who===null?N.kind:N.who.word}),N.when===""?null:p("span",{class:"weave-sheet-when",children:["· ",N.when]})]}),N.text===null?null:p("div",{class:"weave-sheet-text",children:[p("span",{class:"weave-sheet-text-head",children:N.text.heading}),N.text.parts.map(G=>G.hit?p("mark",{class:"weave-sheet-mark",children:G.text}):G.text)]}),N.litBecause===null?null:p("p",{class:"weave-sheet-why",children:[p("span",{"aria-hidden":"true",children:"✳"}),Zh," ",N.litBecause]}),N.connectedTotal===0?null:p("section",{class:"weave-sheet-section","aria-label":Ws,children:[p("h3",{class:"weave-sheet-heading",children:[Ws,p("span",{class:"weave-sheet-count",children:N.connectedTotal})]}),p("ul",{class:"weave-sheet-rows",children:N.connected.map(G=>p("li",{children:p("button",{type:"button",class:"weave-sheet-row",title:G.label,"aria-label":G.ariaLabel,onClick:()=>e.onSelect(G.id),children:[p("span",{class:`weave-sheet-dot${G.lit?" weave-sheet-dot-lit":""}`,"aria-hidden":"true"}),p("span",{class:"weave-sheet-row-label",children:G.label})]})},G.id))}),Z===null?null:p("p",{class:"weave-sheet-more",children:Z})]}),p("div",{class:"weave-sheet-actions",children:[p("button",{type:"button",class:"weave-sheet-open",onClick:()=>e.onOpen(N.id),children:qh}),e.onOpenSplit===void 0?null:p("button",{type:"button",class:"weave-sheet-split",onClick:()=>e.onOpenSplit?.(N.id),children:Yh})]})]}),R===null?null:p("aside",{class:"weave-graph-preview","aria-label":"Selected graph node",children:[p("div",{class:"weave-graph-preview-info",children:[p("span",{class:"weave-kind","aria-hidden":"true",children:p(ce,{name:R.icon,class:"weave-icon"})}),p("div",{class:"weave-graph-preview-copy",children:[p("span",{class:"weave-graph-preview-kind",children:R.kind}),p("strong",{class:"weave-graph-preview-title",title:R.title,children:R.title})]})]}),p("button",{type:"button",class:"weave-graph-preview-close","aria-label":"Clear graph selection",onClick:()=>e.onSelect(null),children:"×"}),p("button",{type:"button",class:"weave-chip",onClick:()=>e.onOpen(R.id),children:"Open in new tab"})]}),p("div",{class:"weave-graph-controls",children:[p("button",{type:"button",class:"weave-chip",title:zd,onClick:()=>n.current?.fit(),children:$d}),p("span",{class:"weave-graph-legend",children:[p("span",{class:"weave-legend-on",children:["◉ ",la.selected]}),b===null?p("span",{class:"weave-legend-near",children:["● ",la.neighborhood]}):p("span",{class:"weave-legend-lit",children:["● ",Hs.lit]}),p("span",{class:"weave-legend-dim",children:["· ",b===null?la.dimmed:Hs.dimmed]})]})]}),p("p",{class:"weave-graph-count",children:Hd(w.visible,w.total)})]})}function mx(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 Hn(e){var t=mx(e,"string");return typeof t=="symbol"?t:t+""}function Ie(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yp(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,Hn(r.key),r)}}function Me(e,t,n){return t&&yp(e.prototype,t),n&&yp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function zn(e){return zn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},zn(e)}function bp(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bp=function(){return!!e})()}function vx(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function wx(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 vx(e)}function Qe(e,t,n){return t=zn(t),wx(e,bp()?Reflect.construct(t,n||[],zn(e).constructor):t.apply(e,n))}function Ys(e,t){return Ys=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Ys(e,t)}function Je(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&&Ys(e,t)}function yx(e){if(Array.isArray(e))return e}function bx(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}function _a(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 Js(e,t){if(e){if(typeof e=="string")return _a(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)?_a(e,t):void 0}}function xx(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
99
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pn(e,t){return yx(e)||bx(e,t)||Js(e,t)||xx()}var Zs={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 xp=new Int8Array(4),Xs=new Int32Array(xp.buffer,0,1),kx=new Float32Array(xp.buffer,0,1),_x=/^\s*rgba?\s*\(/,Tx=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Sx(e){var t=0,n=0,r=0,i=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(_x.test(e)){var a=e.match(Tx);a&&(t=+a[1],n=+a[2],r=+a[3],a[4]&&(i=+a[4]))}return{r:t,g:n,b:r,a:i}}var ur={};for(ni in Zs)ur[ni]=dr(Zs[ni]),ur[Zs[ni]]=ur[ni];var ni;function kp(e,t,n,r,i){return Xs[0]=r<<24|n<<16|t<<8|e,i&&(Xs[0]=Xs[0]&4278190079),kx[0]}function dr(e){if(e=e.toLowerCase(),typeof ur[e]<"u")return ur[e];var t=Sx(e),n=t.r,r=t.g,i=t.b,a=t.a;a=a*255|0;var o=kp(n,r,i,a,!0);return ur[e]=o,o}var Qs={};function el(e){if(typeof Qs[e]<"u")return Qs[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,a=kp(t,n,r,i,!0);return Qs[e]=a,a}function tl(e,t,n,r){return n+(t<<8)+(e<<16)}function nl(e,t,n,r,i,a){var o=Math.floor(n/a*i),s=Math.floor(e.drawingBufferHeight/a-r/a*i),l=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(o,s,1,1,e.RGBA,e.UNSIGNED_BYTE,l);var c=pn(l,4),u=c[0],d=c[1],h=c[2],f=c[3];return[u,d,h,f]}function C(e,t,n){return(t=Hn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?_p(Object(n),!0).forEach(function(r){C(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_p(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ex(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=zn(e))!==null;);return e}function al(){return al=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=Ex(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},al.apply(null,arguments)}function Lp(e,t,n,r){var i=al(zn(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(a){return i.apply(n,a)}:i}function Rx(e){return e.normalized?1:e.size}function rl(e){var t=0;return e.forEach(function(n){return t+=Rx(n)}),t}function Np(e,t,n){var r=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(i,n),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var o=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`loadShader: error while compiling the shader:
100
100
  `.concat(o,`
101
- `).concat(n))}return i}function _x(e,t){return Ep("VERTEX",e,t)}function Tx(e,t){return Ep("FRAGMENT",e,t)}function Sx(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var a=e.getProgramParameter(n,e.LINK_STATUS);if(!a){var o=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(o))}return n}function yp(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,a=e.fragmentShader;t.deleteShader(i),t.deleteShader(a),t.deleteProgram(r),t.deleteBuffer(n)}var bp=`#define PICKING_MODE
102
- `,Ex=A(A(A(A(A(A(A(A({},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 Rp=(function(){function e(t,n,r){Ie(this,e),A(this,"array",new Float32Array),A(this,"constantArray",new Float32Array),A(this,"capacity",0),A(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=tl(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,bp+i.VERTEX_SHADER_SOURCE,bp+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var a=tl(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*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(a,")"));for(var l=0;l<s.length;l++)this.constantArray[o*a+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return Me(e,[{key:"kill",value:function(){yp(this.normalProgram),this.pickProgram&&(yp(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,a,o){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var c=_x(r,i),u=Tx(r,a),d=Sx(r,[c,u]),h={};s.UNIFORMS.forEach(function(w){var v=r.getUniformLocation(d,w);v&&(h[w]=v)});var f={};s.ATTRIBUTES.forEach(function(w){f[w.name]=r.getAttribLocation(d,w.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){f[w.name]=r.getAttribLocation(d,w.name)}),g=r.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:d,gl:r,frameBuffer:o,buffer:l,constantBuffer:g||{},uniformLocations:h,attributeLocations:f,isPicking:n==="pick",vertexShader:c,fragmentShader:u}}},{key:"bindProgram",value:function(n){var r=this,i=0,a=n.gl,o=n.buffer;this.isInstanced?(a.bindBuffer(a.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),a.bufferData(a.ARRAY_BUFFER,this.constantArray,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)):(a.bindBuffer(a.ARRAY_BUFFER,o),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)),a.bindBuffer(a.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,a){var o=Ex[n.type];if(typeof o!="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 c=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:tl(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,c,i),this.isInstanced&&a)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var u=l.getExtension("ANGLE_instanced_arrays");u&&u.vertexAttribDivisorANGLE(s,1)}}return n.size*o}},{key:"unbindAttribute",value:function(n,r,i){var a=r.attributeLocations[n.name],o=r.gl;if(a!==-1&&(o.disableVertexAttribArray(a),this.isInstanced&&i))if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(a,0);else{var s=o.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(a,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,a=r.program;i.enable(i.BLEND),i.useProgram(a),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(z(z({},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,a=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,a),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var o=i.getExtension("ANGLE_instanced_arrays");o&&o.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})();var Rx=(function(e){function t(){return Ie(this,t),Qe(this,t,arguments)}return Je(t,e),Me(t,[{key:"kill",value:function(){Sp(t,"kill",this,3)([])}},{key:"process",value:function(r,i,a){var o=i*this.STRIDE;if(a.hidden){for(var s=o+this.STRIDE;o<s;o++)this.array[o]=0;return}return this.processVisibleItem(Qs(r),o,a)}}])})(Rp);var il=(function(e){function t(){var n;Ie(this,t);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n=Qe(this,t,[].concat(i)),A(n,"drawLabel",void 0),n}return Je(t,e),Me(t,[{key:"kill",value:function(){Sp(t,"kill",this,3)([])}},{key:"process",value:function(r,i,a,o,s){var l=i*this.STRIDE;if(s.hidden||a.hidden||o.hidden){for(var c=l+this.STRIDE;l<c;l++)this.array[l]=0;return}return this.processVisibleItem(Qs(r),l,a,o,s)}}])})(Rp);function Ax(e,t){return(function(){function n(r,i,a){Ie(this,n),A(this,"drawLabel",t),this.programs=e.map(function(o){return new o(r,i,a)})}return Me(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(a){return a.reallocate(i)})}},{key:"process",value:function(i,a,o,s,l){this.programs.forEach(function(c){return c.process(i,a,o,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(a){return a.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function Ap(e,t,n,r,i){var a=i.edgeLabelSize,o=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,c=t.label;if(c){e.fillStyle=l,e.font="".concat(s," ").concat(a,"px ").concat(o);var u=n.size,d=r.size,h=n.x,f=n.y,g=r.x,w=r.y,v=(h+g)/2,y=(f+w)/2,b=g-h,_=w-f,x=Math.sqrt(b*b+_*_);if(!(x<u+d)){h+=b*u/x,f+=_*u/x,g-=b*d/x,w-=_*d/x,v=(h+g)/2,y=(f+w)/2,b=g-h,_=w-f,x=Math.sqrt(b*b+_*_);var C=e.measureText(c).width;if(C>x){var O="…";for(c=c+O,C=e.measureText(c).width;C>x&&c.length>1;)c=c.slice(0,-2)+O,C=e.measureText(c).width;if(c.length<4)return}var N;b>0?_>0?N=Math.acos(b/x):N=Math.asin(_/x):_>0?N=Math.acos(b/x)+Math.PI:N=Math.asin(b/x)+Math.PI/2,e.save(),e.translate(v,y),e.rotate(N),e.fillText(c,-C/2,t.size/2+a),e.restore()}}}function al(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,a=n.labelWeight,o=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=o,e.font="".concat(a," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function Cp(e,t,n){var r=n.labelSize,i=n.labelFont,a=n.labelWeight;e.font="".concat(a," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var o=2;if(typeof t.label=="string"){var s=e.measureText(t.label).width,l=Math.round(s+5),c=Math.round(r+2*o),u=Math.max(t.size,r/2)+o,d=Math.asin(c/2/u),h=Math.sqrt(Math.abs(Math.pow(u,2)-Math.pow(c/2,2)));e.beginPath(),e.moveTo(t.x+h,t.y+c/2),e.lineTo(t.x+u+l,t.y+c/2),e.lineTo(t.x+u+l,t.y-c/2),e.lineTo(t.x+h,t.y-c/2),e.arc(t.x,t.y,u,d,-d),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+o,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,al(e,t,n)}var Cx=`
101
+ `).concat(n))}return i}function Ax(e,t){return Np("VERTEX",e,t)}function Cx(e,t){return Np("FRAGMENT",e,t)}function Lx(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var a=e.getProgramParameter(n,e.LINK_STATUS);if(!a){var o=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(o))}return n}function Tp(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,a=e.fragmentShader;t.deleteShader(i),t.deleteShader(a),t.deleteProgram(r),t.deleteBuffer(n)}var Sp=`#define PICKING_MODE
102
+ `,Nx=C(C(C(C(C(C(C(C({},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 Pp=(function(){function e(t,n,r){Ie(this,e),C(this,"array",new Float32Array),C(this,"constantArray",new Float32Array),C(this,"capacity",0),C(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=rl(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,Sp+i.VERTEX_SHADER_SOURCE,Sp+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var a=rl(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*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(a,")"));for(var l=0;l<s.length;l++)this.constantArray[o*a+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return Me(e,[{key:"kill",value:function(){Tp(this.normalProgram),this.pickProgram&&(Tp(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,a,o){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var c=Ax(r,i),u=Cx(r,a),d=Lx(r,[c,u]),h={};s.UNIFORMS.forEach(function(w){var v=r.getUniformLocation(d,w);v&&(h[w]=v)});var f={};s.ATTRIBUTES.forEach(function(w){f[w.name]=r.getAttribLocation(d,w.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){f[w.name]=r.getAttribLocation(d,w.name)}),g=r.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:d,gl:r,frameBuffer:o,buffer:l,constantBuffer:g||{},uniformLocations:h,attributeLocations:f,isPicking:n==="pick",vertexShader:c,fragmentShader:u}}},{key:"bindProgram",value:function(n){var r=this,i=0,a=n.gl,o=n.buffer;this.isInstanced?(a.bindBuffer(a.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),a.bufferData(a.ARRAY_BUFFER,this.constantArray,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)):(a.bindBuffer(a.ARRAY_BUFFER,o),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),a.bufferData(a.ARRAY_BUFFER,this.array,a.DYNAMIC_DRAW)),a.bindBuffer(a.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,a){var o=Nx[n.type];if(typeof o!="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 c=this.isInstanced?(a?this.ATTRIBUTES_ITEMS_COUNT:rl(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,c,i),this.isInstanced&&a)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var u=l.getExtension("ANGLE_instanced_arrays");u&&u.vertexAttribDivisorANGLE(s,1)}}return n.size*o}},{key:"unbindAttribute",value:function(n,r,i){var a=r.attributeLocations[n.name],o=r.gl;if(a!==-1&&(o.disableVertexAttribArray(a),this.isInstanced&&i))if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(a,0);else{var s=o.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(a,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,a=r.program;i.enable(i.BLEND),i.useProgram(a),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(z(z({},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,a=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,a),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var o=i.getExtension("ANGLE_instanced_arrays");o&&o.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})();var Px=(function(e){function t(){return Ie(this,t),Qe(this,t,arguments)}return Je(t,e),Me(t,[{key:"kill",value:function(){Lp(t,"kill",this,3)([])}},{key:"process",value:function(r,i,a){var o=i*this.STRIDE;if(a.hidden){for(var s=o+this.STRIDE;o<s;o++)this.array[o]=0;return}return this.processVisibleItem(el(r),o,a)}}])})(Pp);var ol=(function(e){function t(){var n;Ie(this,t);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n=Qe(this,t,[].concat(i)),C(n,"drawLabel",void 0),n}return Je(t,e),Me(t,[{key:"kill",value:function(){Lp(t,"kill",this,3)([])}},{key:"process",value:function(r,i,a,o,s){var l=i*this.STRIDE;if(s.hidden||a.hidden||o.hidden){for(var c=l+this.STRIDE;l<c;l++)this.array[l]=0;return}return this.processVisibleItem(el(r),l,a,o,s)}}])})(Pp);function Dx(e,t){return(function(){function n(r,i,a){Ie(this,n),C(this,"drawLabel",t),this.programs=e.map(function(o){return new o(r,i,a)})}return Me(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(a){return a.reallocate(i)})}},{key:"process",value:function(i,a,o,s,l){this.programs.forEach(function(c){return c.process(i,a,o,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(a){return a.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function Dp(e,t,n,r,i){var a=i.edgeLabelSize,o=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,c=t.label;if(c){e.fillStyle=l,e.font="".concat(s," ").concat(a,"px ").concat(o);var u=n.size,d=r.size,h=n.x,f=n.y,g=r.x,w=r.y,v=(h+g)/2,y=(f+w)/2,b=g-h,_=w-f,x=Math.sqrt(b*b+_*_);if(!(x<u+d)){h+=b*u/x,f+=_*u/x,g-=b*d/x,w-=_*d/x,v=(h+g)/2,y=(f+w)/2,b=g-h,_=w-f,x=Math.sqrt(b*b+_*_);var R=e.measureText(c).width;if(R>x){var O="…";for(c=c+O,R=e.measureText(c).width;R>x&&c.length>1;)c=c.slice(0,-2)+O,R=e.measureText(c).width;if(c.length<4)return}var N;b>0?_>0?N=Math.acos(b/x):N=Math.asin(_/x):_>0?N=Math.acos(b/x)+Math.PI:N=Math.asin(b/x)+Math.PI/2,e.save(),e.translate(v,y),e.rotate(N),e.fillText(c,-R/2,t.size/2+a),e.restore()}}}function sl(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,a=n.labelWeight,o=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=o,e.font="".concat(a," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function Ip(e,t,n){var r=n.labelSize,i=n.labelFont,a=n.labelWeight;e.font="".concat(a," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var o=2;if(typeof t.label=="string"){var s=e.measureText(t.label).width,l=Math.round(s+5),c=Math.round(r+2*o),u=Math.max(t.size,r/2)+o,d=Math.asin(c/2/u),h=Math.sqrt(Math.abs(Math.pow(u,2)-Math.pow(c/2,2)));e.beginPath(),e.moveTo(t.x+h,t.y+c/2),e.lineTo(t.x+u+l,t.y+c/2),e.lineTo(t.x+u+l,t.y-c/2),e.lineTo(t.x+h,t.y-c/2),e.arc(t.x,t.y,u,d,-d),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+o,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,sl(e,t,n)}var Ix=`
103
103
  precision highp float;
104
104
 
105
105
  varying vec4 v_color;
@@ -131,7 +131,7 @@ void main(void) {
131
131
  gl_FragColor = mix(v_color, transparent, t);
132
132
  #endif
133
133
  }
134
- `,Lx=Cx,Nx=`
134
+ `,Mx=Ix,Gx=`
135
135
  attribute vec4 a_id;
136
136
  attribute vec4 a_color;
137
137
  attribute vec2 a_position;
@@ -172,7 +172,7 @@ void main() {
172
172
 
173
173
  v_color.a *= bias;
174
174
  }
175
- `,Px=Nx,Lp=WebGLRenderingContext,xp=Lp.UNSIGNED_BYTE,nl=Lp.FLOAT,Dx=["u_sizeRatio","u_correctionRatio","u_matrix"],ii=(function(e){function t(){return Ie(this,t),Qe(this,t,arguments)}return Je(t,e),Me(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Px,FRAGMENT_SHADER_SOURCE:Lx,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Dx,ATTRIBUTES:[{name:"a_position",size:2,type:nl},{name:"a_size",size:1,type:nl},{name:"a_color",size:4,type:xp,normalized:!0},{name:"a_id",size:4,type:xp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:nl}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,a){var o=this.array,s=dr(a.color);o[i++]=a.x,o[i++]=a.y,o[i++]=a.size,o[i++]=s,o[i++]=r}},{key:"setUniforms",value:function(r,i){var a=i.gl,o=i.uniformLocations,s=o.u_sizeRatio,l=o.u_correctionRatio,c=o.u_matrix;a.uniform1f(l,r.correctionRatio),a.uniform1f(s,r.sizeRatio),a.uniformMatrix3fv(c,!1,r.matrix)}}])})(Rx);A(ii,"ANGLE_1",0);A(ii,"ANGLE_2",2*Math.PI/3);A(ii,"ANGLE_3",4*Math.PI/3);var Ix=`
175
+ `,Ox=Gx,Mp=WebGLRenderingContext,Ep=Mp.UNSIGNED_BYTE,il=Mp.FLOAT,Fx=["u_sizeRatio","u_correctionRatio","u_matrix"],ii=(function(e){function t(){return Ie(this,t),Qe(this,t,arguments)}return Je(t,e),Me(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ox,FRAGMENT_SHADER_SOURCE:Mx,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Fx,ATTRIBUTES:[{name:"a_position",size:2,type:il},{name:"a_size",size:1,type:il},{name:"a_color",size:4,type:Ep,normalized:!0},{name:"a_id",size:4,type:Ep,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:il}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,a){var o=this.array,s=dr(a.color);o[i++]=a.x,o[i++]=a.y,o[i++]=a.size,o[i++]=s,o[i++]=r}},{key:"setUniforms",value:function(r,i){var a=i.gl,o=i.uniformLocations,s=o.u_sizeRatio,l=o.u_correctionRatio,c=o.u_matrix;a.uniform1f(l,r.correctionRatio),a.uniform1f(s,r.sizeRatio),a.uniformMatrix3fv(c,!1,r.matrix)}}])})(Px);C(ii,"ANGLE_1",0);C(ii,"ANGLE_2",2*Math.PI/3);C(ii,"ANGLE_3",4*Math.PI/3);var $x=`
176
176
  precision mediump float;
177
177
 
178
178
  varying vec4 v_color;
@@ -180,7 +180,7 @@ varying vec4 v_color;
180
180
  void main(void) {
181
181
  gl_FragColor = v_color;
182
182
  }
183
- `,Mx=Ix,Gx=`
183
+ `,zx=$x,Hx=`
184
184
  attribute vec2 a_position;
185
185
  attribute vec2 a_normal;
186
186
  attribute float a_radius;
@@ -246,7 +246,7 @@ void main() {
246
246
 
247
247
  v_color.a *= bias;
248
248
  }
249
- `,Ox=Gx,Np=WebGLRenderingContext,kp=Np.UNSIGNED_BYTE,Ta=Np.FLOAT,Fx=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Pp={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Dp(e){var t=z(z({},Pp),e||{});return(function(n){function r(){return Ie(this,r),Qe(this,r,arguments)}return Je(r,n),Me(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ox,FRAGMENT_SHADER_SOURCE:Mx,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Fx,ATTRIBUTES:[{name:"a_position",size:2,type:Ta},{name:"a_normal",size:2,type:Ta},{name:"a_radius",size:1,type:Ta},{name:"a_color",size:4,type:kp,normalized:!0},{name:"a_id",size:4,type:kp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Ta}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,l,c){if(t.extremity==="source"){var u=[l,s];s=u[0],l=u[1]}var d=c.size||1,h=l.size||1,f=s.x,g=s.y,w=l.x,v=l.y,y=dr(c.color),b=w-f,_=v-g,x=b*b+_*_,C=0,O=0;x&&(x=1/Math.sqrt(x),C=-_*x*d,O=b*x*d);var N=this.array;N[o++]=w,N[o++]=v,N[o++]=-C,N[o++]=-O,N[o++]=h,N[o++]=y,N[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,l=o.uniformLocations,c=l.u_matrix,u=l.u_sizeRatio,d=l.u_correctionRatio,h=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,g=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(c,!1,a.matrix),s.uniform1f(u,a.sizeRatio),s.uniform1f(d,a.correctionRatio),s.uniform1f(h,a.minEdgeThickness),s.uniform1f(f,t.lengthToThicknessRatio),s.uniform1f(g,t.widenessToThicknessRatio)}}])})(il)}var iR=Dp();var $x=`
249
+ `,Wx=Hx,Gp=WebGLRenderingContext,Rp=Gp.UNSIGNED_BYTE,Ta=Gp.FLOAT,Ux=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Op={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Fp(e){var t=z(z({},Op),e||{});return(function(n){function r(){return Ie(this,r),Qe(this,r,arguments)}return Je(r,n),Me(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Wx,FRAGMENT_SHADER_SOURCE:zx,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ux,ATTRIBUTES:[{name:"a_position",size:2,type:Ta},{name:"a_normal",size:2,type:Ta},{name:"a_radius",size:1,type:Ta},{name:"a_color",size:4,type:Rp,normalized:!0},{name:"a_id",size:4,type:Rp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Ta}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(a,o,s,l,c){if(t.extremity==="source"){var u=[l,s];s=u[0],l=u[1]}var d=c.size||1,h=l.size||1,f=s.x,g=s.y,w=l.x,v=l.y,y=dr(c.color),b=w-f,_=v-g,x=b*b+_*_,R=0,O=0;x&&(x=1/Math.sqrt(x),R=-_*x*d,O=b*x*d);var N=this.array;N[o++]=w,N[o++]=v,N[o++]=-R,N[o++]=-O,N[o++]=h,N[o++]=y,N[o++]=a}},{key:"setUniforms",value:function(a,o){var s=o.gl,l=o.uniformLocations,c=l.u_matrix,u=l.u_sizeRatio,d=l.u_correctionRatio,h=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,g=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(c,!1,a.matrix),s.uniform1f(u,a.sizeRatio),s.uniform1f(d,a.correctionRatio),s.uniform1f(h,a.minEdgeThickness),s.uniform1f(f,t.lengthToThicknessRatio),s.uniform1f(g,t.widenessToThicknessRatio)}}])})(ol)}var cR=Fp();var Bx=`
250
250
  precision mediump float;
251
251
 
252
252
  varying vec4 v_color;
@@ -272,7 +272,7 @@ void main(void) {
272
272
  gl_FragColor = mix(v_color, transparent, t);
273
273
  #endif
274
274
  }
275
- `,Ip=$x,zx=`
275
+ `,$p=Bx,Kx=`
276
276
  attribute vec4 a_id;
277
277
  attribute vec4 a_color;
278
278
  attribute vec2 a_normal;
@@ -340,7 +340,7 @@ void main() {
340
340
 
341
341
  v_color.a *= bias;
342
342
  }
343
- `,Hx=zx,Mp=WebGLRenderingContext,_p=Mp.UNSIGNED_BYTE,Wn=Mp.FLOAT,Wx=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Ux={lengthToThicknessRatio:Pp.lengthToThicknessRatio};function Gp(e){var t=z(z({},Ux),e||{});return(function(n){function r(){return Ie(this,r),Qe(this,r,arguments)}return Je(r,n),Me(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Hx,FRAGMENT_SHADER_SOURCE:Ip,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Wx,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Wn},{name:"a_positionEnd",size:2,type:Wn},{name:"a_normal",size:2,type:Wn},{name:"a_color",size:4,type:_p,normalized:!0},{name:"a_id",size:4,type:_p,normalized:!0},{name:"a_radius",size:1,type:Wn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Wn},{name:"a_normalCoef",size:1,type:Wn},{name:"a_radiusCoef",size:1,type:Wn}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(a,o,s,l,c){var u=c.size||1,d=s.x,h=s.y,f=l.x,g=l.y,w=dr(c.color),v=f-d,y=g-h,b=l.size||1,_=v*v+y*y,x=0,C=0;_&&(_=1/Math.sqrt(_),x=-y*_*u,C=v*_*u);var O=this.array;O[o++]=d,O[o++]=h,O[o++]=f,O[o++]=g,O[o++]=x,O[o++]=C,O[o++]=w,O[o++]=a,O[o++]=b}},{key:"setUniforms",value:function(a,o){var s=o.gl,l=o.uniformLocations,c=l.u_matrix,u=l.u_zoomRatio,d=l.u_feather,h=l.u_pixelRatio,f=l.u_correctionRatio,g=l.u_sizeRatio,w=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(c,!1,a.matrix),s.uniform1f(u,a.zoomRatio),s.uniform1f(g,a.sizeRatio),s.uniform1f(f,a.correctionRatio),s.uniform1f(h,a.pixelRatio),s.uniform1f(d,a.antiAliasingFeather),s.uniform1f(w,a.minEdgeThickness),s.uniform1f(v,t.lengthToThicknessRatio)}}])})(il)}var aR=Gp();function Bx(e){return Ax([Gp(e),Dp(e)])}var Kx=Bx(),Op=Kx,Vx=`
343
+ `,Vx=Kx,zp=WebGLRenderingContext,Ap=zp.UNSIGNED_BYTE,Wn=zp.FLOAT,jx=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],qx={lengthToThicknessRatio:Op.lengthToThicknessRatio};function Hp(e){var t=z(z({},qx),e||{});return(function(n){function r(){return Ie(this,r),Qe(this,r,arguments)}return Je(r,n),Me(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Vx,FRAGMENT_SHADER_SOURCE:$p,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:jx,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Wn},{name:"a_positionEnd",size:2,type:Wn},{name:"a_normal",size:2,type:Wn},{name:"a_color",size:4,type:Ap,normalized:!0},{name:"a_id",size:4,type:Ap,normalized:!0},{name:"a_radius",size:1,type:Wn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Wn},{name:"a_normalCoef",size:1,type:Wn},{name:"a_radiusCoef",size:1,type:Wn}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(a,o,s,l,c){var u=c.size||1,d=s.x,h=s.y,f=l.x,g=l.y,w=dr(c.color),v=f-d,y=g-h,b=l.size||1,_=v*v+y*y,x=0,R=0;_&&(_=1/Math.sqrt(_),x=-y*_*u,R=v*_*u);var O=this.array;O[o++]=d,O[o++]=h,O[o++]=f,O[o++]=g,O[o++]=x,O[o++]=R,O[o++]=w,O[o++]=a,O[o++]=b}},{key:"setUniforms",value:function(a,o){var s=o.gl,l=o.uniformLocations,c=l.u_matrix,u=l.u_zoomRatio,d=l.u_feather,h=l.u_pixelRatio,f=l.u_correctionRatio,g=l.u_sizeRatio,w=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(c,!1,a.matrix),s.uniform1f(u,a.zoomRatio),s.uniform1f(g,a.sizeRatio),s.uniform1f(f,a.correctionRatio),s.uniform1f(h,a.pixelRatio),s.uniform1f(d,a.antiAliasingFeather),s.uniform1f(w,a.minEdgeThickness),s.uniform1f(v,t.lengthToThicknessRatio)}}])})(ol)}var uR=Hp();function Yx(e){return Dx([Hp(e),Fp(e)])}var Zx=Yx(),Wp=Zx,Xx=`
344
344
  attribute vec4 a_id;
345
345
  attribute vec4 a_color;
346
346
  attribute vec2 a_normal;
@@ -405,17 +405,17 @@ void main() {
405
405
 
406
406
  v_color.a *= bias;
407
407
  }
408
- `,jx=Vx,Fp=WebGLRenderingContext,Tp=Fp.UNSIGNED_BYTE,ri=Fp.FLOAT,qx=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],$p=(function(e){function t(){return Ie(this,t),Qe(this,t,arguments)}return Je(t,e),Me(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:jx,FRAGMENT_SHADER_SOURCE:Ip,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:qx,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ri},{name:"a_positionEnd",size:2,type:ri},{name:"a_normal",size:2,type:ri},{name:"a_color",size:4,type:Tp,normalized:!0},{name:"a_id",size:4,type:Tp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ri},{name:"a_normalCoef",size:1,type:ri}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,a,o,s){var l=s.size||1,c=a.x,u=a.y,d=o.x,h=o.y,f=dr(s.color),g=d-c,w=h-u,v=g*g+w*w,y=0,b=0;v&&(v=1/Math.sqrt(v),y=-w*v*l,b=g*v*l);var _=this.array;_[i++]=c,_[i++]=u,_[i++]=d,_[i++]=h,_[i++]=y,_[i++]=b,_[i++]=f,_[i++]=r}},{key:"setUniforms",value:function(r,i){var a=i.gl,o=i.uniformLocations,s=o.u_matrix,l=o.u_zoomRatio,c=o.u_feather,u=o.u_pixelRatio,d=o.u_correctionRatio,h=o.u_sizeRatio,f=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,r.matrix),a.uniform1f(l,r.zoomRatio),a.uniform1f(h,r.sizeRatio),a.uniform1f(d,r.correctionRatio),a.uniform1f(u,r.pixelRatio),a.uniform1f(c,r.antiAliasingFeather),a.uniform1f(f,r.minEdgeThickness)}}])})(il);var Zp=Ir(Ra()),Aa=(function(e){function t(){var n;return Ie(this,t),n=Qe(this,t),n.rawEmitter=n,n}return Je(t,e),Me(t)})(Zp.EventEmitter);var ef=Ir(sl());var tk=function(t){return t},nk=function(t){return t*t},rk=function(t){return t*(2-t)},ik=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},ak=function(t){return t*t*t},ok=function(t){return--t*t*t+1},sk=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},tf={linear:tk,quadraticIn:nk,quadraticOut:rk,quadraticInOut:ik,cubicIn:ak,cubicOut:ok,cubicInOut:sk},nf={easing:"quadraticInOut",duration:150};function bt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ca(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Qp(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 Jp(e,t,n){return e[6]=t,e[7]=n,e}function pn(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],d=t[0],h=t[1],f=t[2],g=t[3],w=t[4],v=t[5],y=t[6],b=t[7],_=t[8];return e[0]=d*n+h*a+f*l,e[1]=d*r+h*o+f*c,e[2]=d*i+h*s+f*u,e[3]=g*n+w*a+v*l,e[4]=g*r+w*o+v*c,e[5]=g*i+w*s+v*u,e[6]=y*n+b*a+_*l,e[7]=y*r+b*o+_*c,e[8]=y*i+b*s+_*u,e}function La(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],a=e[3],o=e[4],s=e[6],l=e[7],c=t.x,u=t.y;return{x:c*r+u*a+s*n,y:c*i+u*o+l*n}}function lk(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 pr(e,t,n,r,i){var a=e.angle,o=e.ratio,s=e.x,l=e.y,c=t.width,u=t.height,d=bt(),h=Math.min(c,u)-2*r,f=lk(t,n);return i?(pn(d,Jp(bt(),s,l)),pn(d,Ca(bt(),o)),pn(d,Qp(bt(),a)),pn(d,Ca(bt(),c/h/2/f,u/h/2/f))):(pn(d,Ca(bt(),2*(h/c)*f,2*(h/u)*f)),pn(d,Qp(bt(),-a)),pn(d,Ca(bt(),1/o)),pn(d,Jp(bt(),-s,-l))),d}function rf(e,t,n){var r=La(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,a=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(a,2))/n.width}function af(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(a,o){var s=o.x,l=o.y;s<t&&(t=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[t,n],y:[r,i]}}function of(e){if(!(0,ef.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 sf(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var a in n)r.setAttribute(a,n[a]);return r}function ll(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function cl(e,t,n){return n.sort(function(r,i){var a=t(r)||0,o=t(i)||0;return a<o?-1:a>o?1:0})}function ul(e){var t=hn(e.x,2),n=t[0],r=t[1],i=hn(e.y,2),a=i[0],o=i[1],s=Math.max(r-n,o-a),l=(r+n)/2,c=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(c)&&(c=0);var u=function(h){return{x:.5+(h.x-l)/s,y:.5+(h.y-c)/s}};return u.applyTo=function(d){d.x=.5+(d.x-l)/s,d.y=.5+(d.y-c)/s},u.inverse=function(d){return{x:l+s*(d.x-.5),y:c+s*(d.y-.5)}},u.ratio=s,u}function Na(e){"@babel/helpers - typeof";return Na=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},Na(e)}function dl(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(a){e[r+i]=a,i++})}}function Pa(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 Da={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:Ap,defaultDrawNodeLabel:al,defaultDrawNodeHover:Cp,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:{}},ck={circle:ii},uk={arrow:Op,line:$p};function Ia(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 lf(e){var t=Pa({},Da,e);return t.nodeProgramClasses=Pa({},ck,t.nodeProgramClasses),t.edgeProgramClasses=Pa({},uk,t.edgeProgramClasses),t}var TR=Ir(Ra()),SR=Ir(sl()),Ma=1.5,cf=(function(e){function t(){var n;return Ie(this,t),n=Qe(this,t),A(n,"x",.5),A(n,"y",.5),A(n,"angle",0),A(n,"ratio",1),A(n,"minRatio",null),A(n,"maxRatio",null),A(n,"enabledZooming",!0),A(n,"enabledPanning",!0),A(n,"enabledRotation",!0),A(n,"clean",null),A(n,"nextFrame",null),A(n,"previousState",null),A(n,"enabled",!0),n.previousState=n.getState(),n}return Je(t,e),Me(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(z(z({},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,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(!o)return new Promise(function(f){return i.animate(r,a,f)});if(this.enabled){var s=z(z({},nf),a),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:tf[s.easing],u=Date.now(),d=this.getState(),h=function(){var g=(Date.now()-u)/s.duration;if(g>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=c(g),v={};typeof l.x=="number"&&(v.x=d.x+(l.x-d.x)*w),typeof l.y=="number"&&(v.y=d.y+(l.y-d.y)*w),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=d.angle+(l.angle-d.angle)*w),typeof l.ratio=="number"&&(v.ratio=d.ratio+(l.ratio-d.ratio)*w),i.setState(v),i.nextFrame=requestAnimationFrame(h)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(h)):h(),this.animationCallback=o}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Ma)},r):this.animate({ratio:this.ratio/Ma})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Ma)},r):this.animate({ratio:this.ratio*Ma})}},{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)}}])})(Aa);function At(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function jt(e,t){var n=z(z({},At(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function ai(e){var t="x"in e?e:z(z({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function dk(e,t){return z(z({},jt(e,t)),{},{delta:gf(e)})}var hk=2;function Ga(e){for(var t=[],n=0,r=Math.min(e.length,hk);n<r;n++)t.push(e[n]);return t}function oi(e,t,n){var r={touches:Ga(e.touches).map(function(i){return At(i,n)}),previousTouches:t.map(function(i){return At(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function gf(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 mf=(function(e){function t(n,r){var i;return Ie(this,t),i=Qe(this,t),i.container=n,i.renderer=r,i}return Je(t,e),Me(t)})(Aa),pk=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],fk=pk.reduce(function(e,t){return z(z({},e),{},A({},t,Da[t]))},{}),gk=(function(e){function t(n,r){var i;return Ie(this,t),i=Qe(this,t,[n,r]),A(i,"enabled",!0),A(i,"draggedEvents",0),A(i,"downStartTime",null),A(i,"lastMouseX",null),A(i,"lastMouseY",null),A(i,"isMouseDown",!1),A(i,"isMoving",!1),A(i,"movingTimeout",null),A(i,"startCameraState",null),A(i,"clicks",0),A(i,"doubleClickTimeout",null),A(i,"currentWheelDirection",0),A(i,"settings",fk),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 Je(t,e),Me(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",jt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",jt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=jt(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var a=this.renderer.getCamera(),o=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(At(r,this.container),o),{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=At(r,this.container),a=i.x,o=i.y;this.lastMouseX=a,this.lastMouseY=o,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",jt(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var a=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var o=At(r,this.container),s=o.x,l=o.y,c=a.getState(),u=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:c.x+this.settings.inertiaRatio*(c.x-u.x),y:c.y+this.settings.inertiaRatio*(c.y-u.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&a.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",jt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var a=jt(r,this.container);if(this.emit("mousemovebody",a),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",a),!a.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 o=this.renderer.getCamera(),s=At(r,this.container),l=s.x,c=s.y,u=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:l,y:c}),h=u.x-d.x,f=u.y-d.y,g=o.getState(),w=g.x+h,v=g.y+f;o.setState({x:w,y:v}),this.lastMouseX=l,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",jt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",jt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var o=gf(r);if(o){var s=dk(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=a.getState().ratio,c=o>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,u=a.getBoundedRatio(l*c),d=o>0?1:-1,h=Date.now();l!==u&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&h-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(At(r,this.container),u),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=h))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(mf),mk=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],vk=mk.reduce(function(e,t){return z(z({},e),{},A({},t,Da[t]))},{}),wk=(function(e){function t(n,r){var i;return Ie(this,t),i=Qe(this,t,[n,r]),A(i,"enabled",!0),A(i,"isMoving",!1),A(i,"hasMoved",!1),A(i,"touchMode",0),A(i,"startTouchesPositions",[]),A(i,"lastTouches",[]),A(i,"lastTap",null),A(i,"settings",vk),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 Je(t,e),Me(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 a=Ga(r.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(f){return At(f,i.container)}),this.touchMode===2){var o=hn(this.startTouchesPositions,2),s=o[0],l=s.x,c=s.y,u=o[1],d=u.x,h=u.y;this.startTouchesAngle=Math.atan2(h-c,d-l),this.startTouchesDistance=Math.sqrt(Math.pow(d-l,2)+Math.pow(h-c,2))}this.emit("touchdown",oi(r,this.lastTouches,this.container)),this.lastTouches=a,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(),a=i.getState(),o=i.getPreviousState()||{x:0,y:0};i.animate({x:a.x+this.settings.inertiaRatio*(a.x-o.x),y:a.y+this.settings.inertiaRatio*(a.y-o.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",oi(r,this.lastTouches,this.container)),!r.touches.length){var s=At(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],c=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var u=oi(r,this.lastTouches,this.container);if(this.emit("doubletap",u),this.lastTap=null,!u.sigmaDefaultPrevented){var d=this.renderer.getCamera(),h=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,h),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=oi(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Ga(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var a=Ga(r.touches),o=a.map(function(Te){return At(Te,i.container)}),s=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=o;var l=oi(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=o.some(function(Te,ct){var Pe=i.startTouchesPositions[ct];return Pe&&(Te.x!==Pe.x||Te.y!==Pe.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),u=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var h=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=h.x,g=h.y,w=this.renderer.viewportToFramedGraph(o[0]),v=w.x,y=w.y;c.setState({x:u.x+f-v,y:u.y+g-y});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},_=o[0],x=_.x,C=_.y,O=o[1],N=O.x,j=O.y,P=Math.atan2(j-C,N-x)-this.startTouchesAngle,R=Math.hypot(j-C,N-x)/this.startTouchesDistance,H=c.getBoundedRatio(u.ratio/R);b.ratio=H,b.angle=u.angle+P;var Z=this.getDimensions(),G=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),J=Math.min(Z.width,Z.height)-2*d,X=J/Z.width,se=J/Z.height,Ye=H/J,Ae=x-J/2/X,we=C-J/2/se,ue=[Ae*Math.cos(-b.angle)-we*Math.sin(-b.angle),we*Math.cos(-b.angle)+Ae*Math.sin(-b.angle)];Ae=ue[0],we=ue[1],b.x=G.x-Ae*Ye,b.y=G.y+we*Ye,c.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(mf);function yk(e){if(Array.isArray(e))return _a(e)}function bk(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function xk(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
409
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uf(e){return yk(e)||bk(e)||Xs(e)||xk()}function kk(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 hl(e,t){if(e==null)return{};var n,r,i=kk(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var df=(function(){function e(t,n){Ie(this,e),this.key=t,this.size=n}return Me(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),hf=(function(){function e(){Ie(this,e),A(this,"width",0),A(this,"height",0),A(this,"cellSize",0),A(this,"columns",0),A(this,"rows",0),A(this,"cells",{})}return Me(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 a=new df(n,r),o=this.getIndex(i),s=this.cells[o];s||(s=[],this.cells[o]=s),s.push(a)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(df.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,a=i/n/n,o=a*r/i,s=Math.ceil(o),l=[];for(var c in this.cells)for(var u=this.cells[c],d=0;d<Math.min(s,u.length);d++)l.push(u[d].key);return l}}])})();function _k(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,a=[];return t.forEachEdge(function(o,s,l,c){(l===n||c===n||r.has(l)||r.has(c)||i.has(l)&&i.has(c))&&a.push(o)}),a}var pf=150,ff=50,qt=Object.prototype.hasOwnProperty;function Tk(e,t,n){if(!qt.call(n,"x")||!qt.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),qt.call(n,"hidden")||(n.hidden=!1),qt.call(n,"highlighted")||(n.highlighted=!1),qt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Sk(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),qt.call(n,"hidden")||(n.hidden=!1),qt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Ek=(function(e){function t(n,r){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Ie(this,t),i=Qe(this,t),A(i,"elements",{}),A(i,"canvasContexts",{}),A(i,"webGLContexts",{}),A(i,"pickingLayers",new Set),A(i,"textures",{}),A(i,"frameBuffers",{}),A(i,"activeListeners",{}),A(i,"labelGrid",new hf),A(i,"nodeDataCache",{}),A(i,"edgeDataCache",{}),A(i,"nodeProgramIndex",{}),A(i,"edgeProgramIndex",{}),A(i,"nodesWithForcedLabels",new Set),A(i,"edgesWithForcedLabels",new Set),A(i,"nodeExtent",{x:[0,1],y:[0,1]}),A(i,"nodeZExtent",[1/0,-1/0]),A(i,"edgeZExtent",[1/0,-1/0]),A(i,"matrix",bt()),A(i,"invMatrix",bt()),A(i,"correctionRatio",1),A(i,"customBBox",null),A(i,"normalizationFunction",ul({x:[0,1],y:[0,1]})),A(i,"graphToViewportRatio",1),A(i,"itemIDsIndex",{}),A(i,"nodeIndices",{}),A(i,"edgeIndices",{}),A(i,"width",0),A(i,"height",0),A(i,"pixelRatio",ll()),A(i,"pickingDownSizingRatio",2*i.pixelRatio),A(i,"displayedNodeLabels",new Set),A(i,"displayedEdgeLabels",new Set),A(i,"highlightedNodes",new Set),A(i,"hoveredNode",null),A(i,"hoveredEdge",null),A(i,"renderFrame",null),A(i,"renderHighlightedNodesFrame",null),A(i,"needToProcess",!1),A(i,"checkEdgesEventsFrame",null),A(i,"nodePrograms",{}),A(i,"nodeHoverPrograms",{}),A(i,"edgePrograms",{}),i.settings=lf(a),Ia(i.settings),of(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:a.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 o in i.settings.nodeProgramClasses)i.registerNodeProgram(o,i.settings.nodeProgramClasses[o],i.settings.nodeHoverProgramClasses[o]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new cf,i.bindCameraHandlers(),i.mouseCaptor=new gk(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new wk(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Je(t,e),Me(t,[{key:"registerNodeProgram",value:function(r,i,a){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(a||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,a=i[r],o=hl(i,[r].map(Hn));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=hl(s,[r].map(Hn));l.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,a=i[r],o=hl(i,[r].map(Hn));a.kill(),this.edgePrograms=o}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],a=this.frameBuffers[r],o=this.textures[r];o&&i.deleteTexture(o);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),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,a=r.y,o=el(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),s=Js.apply(void 0,uf(o)),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(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}},l=r.getNodeAtPosition(o);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",z(z({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",z(z({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(o)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",z(z({},s),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var u=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);u!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",z(z({},s),{},{edge:r.hoveredEdge})),u&&r.emit("enterEdge",z(z({},s),{},{edge:u})),r.hoveredEdge=u)}},this.activeListeners.handleMoveBody=function(a){var o=ai(a);r.emit("moveBody",{event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",z(z({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",z(z({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",z({},s))},this.activeListeners.handleEnter=function(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};r.emit("enterStage",z({},s))};var i=function(o){return function(s){var l=ai(s),c={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},u=r.getNodeAtPosition(l);if(u)return r.emit("".concat(o,"Node"),z(z({},c),{},{node:u}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(l.x,l.y);if(d)return r.emit("".concat(o,"Edge"),z(z({},c),{},{edge:d}))}return r.emit("".concat(o,"Stage"),c)}};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,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(o){var s,l=(s=o.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(u){return r.updateNode(u)});var c=!l||l.some(function(u){return a.has(u)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(o){var s,l=(s=o.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(u){return r.updateEdge(u)});var c=l&&["zIndex","type"].some(function(u){return l?.includes(u)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(o){var s=o.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(o){var s=o.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(o){var s=o.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(o){var s=o.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(o){var s=o.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(o){var s=o.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 a=el(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),o=Js.apply(void 0,uf(a)),s=this.itemIDsIndex[o];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,o=this.getDimensions();if(this.nodeExtent=af(this.graph),!this.settings.autoRescale){var s=o.width,l=o.height,c=this.nodeExtent,u=c.x,d=c.y;this.nodeExtent={x:[(u[0]+u[1])/2-s/2,(u[0]+u[1])/2+s/2],y:[(d[0]+d[1])/2-l/2,(d[0]+d[1])/2+l/2]}}this.normalizationFunction=ul(this.customBBox||this.nodeExtent);var h=new cf,f=pr(h.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var g={},w={},v={},y={},b=1,_=i.nodes(),x=0,C=_.length;x<C;x++){var O=_[x],N=this.nodeDataCache[O],j=i.getNodeAttributes(O);N.x=j.x,N.y=j.y,this.normalizationFunction.applyTo(N),typeof N.label=="string"&&!N.hidden&&this.labelGrid.add(O,N.size,this.framedGraphToViewport(N,{matrix:f})),g[N.type]=(g[N.type]||0)+1}this.labelGrid.organize();for(var P in this.nodePrograms){if(!qt.call(this.nodePrograms,P))throw new Error('Sigma: could not find a suitable program for node type "'.concat(P,'"!'));this.nodePrograms[P].reallocate(g[P]||0),g[P]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=cl(this.nodeZExtent,function(Se){return r.nodeDataCache[Se].zIndex},_));for(var R=0,H=_.length;R<H;R++){var Z=_[R];w[Z]=b,y[w[Z]]={type:"node",id:Z},b++;var G=this.nodeDataCache[Z];this.addNodeToProgram(Z,w[Z],g[G.type]++)}for(var J={},X=i.edges(),se=0,Ye=X.length;se<Ye;se++){var Ae=X[se],we=this.edgeDataCache[Ae];J[we.type]=(J[we.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(X=cl(this.edgeZExtent,function(Se){return r.edgeDataCache[Se].zIndex},X));for(var ue in this.edgePrograms){if(!qt.call(this.edgePrograms,ue))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ue,'"!'));this.edgePrograms[ue].reallocate(J[ue]||0),J[ue]=0}for(var Te=0,ct=X.length;Te<ct;Te++){var Pe=X[Te];v[Pe]=b,y[v[Pe]]={type:"edge",id:Pe},b++;var oe=this.edgeDataCache[Pe];this.addEdgeToProgram(Pe,v[Pe],J[oe.type]++)}return this.itemIDsIndex=y,this.nodeIndices=w,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(u){return i.cleanCameraState(u,a.cameraPanBoundaries&&Na(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==a.edgeProgramClasses){for(var o in a.edgeProgramClasses)a.edgeProgramClasses[o]!==r.edgeProgramClasses[o]&&this.registerEdgeProgram(o,a.edgeProgramClasses[o]);for(var s in r.edgeProgramClasses)a.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==a.nodeProgramClasses||r.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var l in a.nodeProgramClasses)(a.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||a.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,a.nodeProgramClasses[l],a.nodeHoverProgramClasses[l]);for(var c in r.nodeProgramClasses)a.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}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]:{},a=i.tolerance,o=a===void 0?0:a,s=i.boundaries,l=z({},r),c=s||this.nodeExtent,u=hn(c.x,2),d=u[0],h=u[1],f=hn(c.y,2),g=f[0],w=f[1],v=[this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:w},{cameraState:r}),this.graphToViewport({x:h,y:w},{cameraState:r})],y=1/0,b=-1/0,_=1/0,x=-1/0;v.forEach(function(J){var X=J.x,se=J.y;y=Math.min(y,X),b=Math.max(b,X),_=Math.min(_,se),x=Math.max(x,se)});var C=b-y,O=x-_,N=this.getDimensions(),j=N.width,P=N.height,R=0,H=0;if(C>=j?b<j-o?R=b-(j-o):y>o&&(R=y-o):b>j+o?R=b-(j+o):y<-o&&(R=y+o),O>=P?x<P-o?H=x-(P-o):_>o&&(H=_-o):x>P+o?H=x-(P+o):_<-o&&(H=_+o),R||H){var Z=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),G=this.viewportToFramedGraph({x:R,y:H},{cameraState:r});R=G.x-Z.x,H=G.y-Z.y,l.x+=R,l.y+=H}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);dl(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,o=0,s=i.length;o<s;o++){var l=i[o],c=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!c.hidden){var u=this.framedGraphToViewport(c),d=u.x,h=u.y,f=this.scaleSize(c.size);if(!(!c.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-pf||d>this.width+pf||h<-ff||h>this.height+ff)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[c.type],v=w?.drawLabel||g;v(a,z(z({key:l},c),{},{size:f,x:d,y:h}),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=_k({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});dl(i,this.edgesWithForcedLabels);for(var a=new Set,o=0,s=i.length;o<s;o++){var l=i[o],c=this.graph.extremities(l),u=this.nodeDataCache[c[0]],d=this.nodeDataCache[c[1]],h=this.edgeDataCache[l];if(!a.has(l)&&!(h.hidden||u.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[h.type],w=g?.drawLabel||f;w(r,z(z({key:l},h),{},{size:this.scaleSize(h.size)}),z(z(z({key:c[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),z(z(z({key:c[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),a.add(l)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(f){var g=r.nodeDataCache[f],w=r.framedGraphToViewport(g),v=w.x,y=w.y,b=r.scaleSize(g.size),_=r.settings.defaultDrawNodeHover,x=r.nodePrograms[g.type],C=x?.drawHover||_;C(i,z(z({key:f},g),{},{size:b,x:v,y}),r.settings)},o=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&o.push(this.hoveredNode),this.highlightedNodes.forEach(function(h){h!==r.hoveredNode&&o.push(h)}),o.forEach(function(h){return a(h)});var s={};o.forEach(function(h){var f=r.nodeDataCache[h].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;o.forEach(function(h){var f=r.nodeDataCache[h];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var u in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[u];d.render(c)}}},{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 a=this.mouseCaptor,o=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),c=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=pr(s,l,c,u),this.invMatrix=pr(s,l,c,u,!0),this.correctionRatio=rf(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var h in this.nodePrograms){var f=this.nodePrograms[h];f.render(d)}if(!this.settings.hideEdgesOnMove||!o)for(var g in this.edgePrograms){var w=this.edgePrograms[g];w.render(d)}return this.settings.hideLabelsOnMove&&o||(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 a=Tk(this.settings,r,i);this.nodeDataCache[r]=a,this.nodesWithForcedLabels.delete(r),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),a.highlighted&&!a.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.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 a=Sk(this.settings,r,i);this.edgeDataCache[r]=a,this.edgesWithForcedLabels.delete(r),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.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 hf,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,a){var o=this.nodeDataCache[r],s=this.nodePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(o.type,'"!'));s.process(i,a,o),this.nodeProgramIndex[r]=a}},{key:"addEdgeToProgram",value:function(r,i,a){var o=this.edgeDataCache[r],s=this.edgePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(o.type,'"!'));var l=this.graph.extremities(r),c=this.nodeDataCache[l[0]],u=this.nodeDataCache[l[1]];s.process(i,a,c,u,o),this.edgeProgramIndex[r]=a}},{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,a=r.autoRescale;return a&&i||0}},{key:"createLayer",value:function(r,i){var a=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 o=sf(i,{position:"absolute"},{class:"sigma-".concat(r)});return a.style&&Object.assign(o.style,a.style),this.elements[r]=o,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(o):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(o):this.container.appendChild(o),o}},{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]:{},a=this.createCanvas(r,i),o={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=a.getContext("2d",o),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i?.canvas||this.createCanvas(r,i);i.hidden&&a.remove();var o=z({preserveDrawingBuffer:!1,antialias:!1},i),s;s=a.getContext("webgl2",o),s||(s=a.getContext("webgl",o)),s||(s=a.getContext("experimental-webgl",o));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var c=l.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}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 a,o=this.webGLContexts[r];(a=o.getExtension("WEBGL_lose_context"))===null||a===void 0||a.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 z({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var a=z({},this.settings);return this.settings[r]=i,Ia(this.settings),this.handleSettingsUpdate(a),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=z({},this.settings);return this.settings=z(z({},this.settings),r),Ia(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=ll(),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&&a===this.height)return this;for(var o in this.elements){var s=this.elements[o];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 c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var u=this.webGLContexts[c];if(u.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var d=this.textures[c];d&&u.deleteTexture(d)}}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,a=r?.skipIndexation!==void 0?r?.skipIndexation:!1,o=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(x){return i.addNode(x)}),this.graph.forEachEdge(function(x){return i.addEdge(x)});else{for(var l,c,u=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],d=0,h=u?.length||0;d<h;d++){var f=u[d];if(this.updateNode(f),a){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 w=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],v=0,y=w.length;v<y;v++){var b=w[v];if(this.updateEdge(b),a){var _=this.edgeProgramIndex[b];if(_===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],_)}}}return(s||!a)&&(this.needToProcess=!0),o?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(z(z({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var a=this.camera.getState(),o=a.ratio,s=a.angle,l=a.x,c=a.y,u=this.settings,d=u.minCameraRatio,h=u.maxCameraRatio;typeof h=="number"&&(i=Math.min(i,h)),typeof d=="number"&&(i=Math.max(i,d));var f=i/o,g={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(w.x-v.x)*(1-f)+l,y:(w.y-v.y)*(1-f)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,o=i.matrix?i.matrix:a?pr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=La(o,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]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,o=i.matrix?i.matrix:a?pr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=La(o,{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},a=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),o=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));return l/a}},{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 a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var o in this.edgePrograms)this.edgePrograms[o].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}}])})(Aa),vf=Ek;var xf=Ir(Ra(),1);function Rk(){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 Ge=Rk;typeof Object.assign=="function"&&(Ge=Object.assign);function kt(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(r==="mixed"?a=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?a=i.out&&i.out[n]:a=i.undirected&&i.undirected[n]),a}function Be(e){return typeof e=="object"&&e!==null}function kf(e){let t;for(t in e)return!1;return!0}function xt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Ct(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 wf(e){return!(!Be(e)||e.attributes&&!Array.isArray(e.attributes))}function Ak(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Yt(){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 gr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var ci=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},$=class e extends ci{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},M=class e extends ci{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},q=class e extends ci{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function _f(e,t){this.key=e,this.attributes=t,this.clear()}_f.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 Tf(e,t){this.key=e,this.attributes=t,this.clear()}Tf.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Sf(e,t){this.key=e,this.attributes=t,this.clear()}Sf.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function mr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}mr.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)};mr.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");let i=this.source[e],a=i[r];if(typeof a>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this};mr.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]};mr.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 Ef=0,Rf=1,Ck=2,Af=3;function Zt(e,t,n,r,i,a,o){let s,l,c,u;if(r=""+r,n===Ef){if(s=e._nodes.get(r),!s)throw new M(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,u=a}else if(n===Af){if(i=""+i,l=e._edges.get(i),!l)throw new M(`Graph.${t}: could not find the "${i}" edge in the graph.`);let d=l.source.key,h=l.target.key;if(r===d)s=l.target;else if(r===h)s=l.source;else throw new M(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${d}, ${h}).`);c=a,u=o}else{if(l=e._edges.get(r),!l)throw new M(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Rf?s=l.source:s=l.target,c=i,u=a}return[s,c,u]}function Lk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);return o.attributes[s]}}function Nk(e,t,n){e.prototype[t]=function(r,i){let[a]=Zt(this,t,n,r,i);return a.attributes}}function Pk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);return o.attributes.hasOwnProperty(s)}}function Dk(e,t,n){e.prototype[t]=function(r,i,a,o){let[s,l,c]=Zt(this,t,n,r,i,a,o);return s.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Ik(e,t,n){e.prototype[t]=function(r,i,a,o){let[s,l,c]=Zt(this,t,n,r,i,a,o);if(typeof c!="function")throw new $(`Graph.${t}: updater should be a function.`);let u=s.attributes,d=c(u[l]);return u[l]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Mk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function Gk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);if(!Be(s))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ok(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);if(!Be(s))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return Ge(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Fk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);if(typeof s!="function")throw new $(`Graph.${t}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var $k=[{name:e=>`get${e}Attribute`,attacher:Lk},{name:e=>`get${e}Attributes`,attacher:Nk},{name:e=>`has${e}Attribute`,attacher:Pk},{name:e=>`set${e}Attribute`,attacher:Dk},{name:e=>`update${e}Attribute`,attacher:Ik},{name:e=>`remove${e}Attribute`,attacher:Mk},{name:e=>`replace${e}Attributes`,attacher:Gk},{name:e=>`merge${e}Attributes`,attacher:Ok},{name:e=>`update${e}Attributes`,attacher:Fk}];function zk(e){$k.forEach(function({name:t,attacher:n}){n(e,t("Node"),Ef),n(e,t("Source"),Rf),n(e,t("Target"),Ck),n(e,t("Opposite"),Af)})}function Hk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]}}function Wk(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new q(`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,o=""+arguments[1];if(i=kt(this,a,o,n),!i)throw new M(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function Uk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function Bk(e,t,n){e.prototype[t]=function(r,i,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new q(`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],a=arguments[3],o=kt(this,s,l,n),!o)throw new M(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function Kk(e,t,n){e.prototype[t]=function(r,i,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new q(`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],a=arguments[3],o=kt(this,s,l,n),!o)throw new M(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof a!="function")throw new $(`Graph.${t}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function Vk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function jk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Be(i))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function qk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Be(i))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return Ge(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function Yk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new $(`Graph.${t}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var Zk=[{name:e=>`get${e}Attribute`,attacher:Hk},{name:e=>`get${e}Attributes`,attacher:Wk},{name:e=>`has${e}Attribute`,attacher:Uk},{name:e=>`set${e}Attribute`,attacher:Bk},{name:e=>`update${e}Attribute`,attacher:Kk},{name:e=>`remove${e}Attribute`,attacher:Vk},{name:e=>`replace${e}Attributes`,attacher:jk},{name:e=>`merge${e}Attributes`,attacher:qk},{name:e=>`update${e}Attributes`,attacher:Yk}];function Xk(e){Zk.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var Qk=[{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 Jk(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function e0(e,t,n,r){let i,a,o,s=!1;for(let l in t)if(l!==r){i=t[l];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function pl(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function t0(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function n0(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function fl(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 r0(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",a=e._edges.values(),o=0,s,l;for(;s=a.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[o++]=l.key);return r}function Cf(e,t,n,r){if(t.size===0)return;let i=n!=="mixed"&&n!==t.type,a=n==="undirected",o,s,l=!1,c=t._edges.values();for(;o=c.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:u,attributes:d,source:h,target:f}=s;if(l=r(u,d,h.key,f.key,h.attributes,f.attributes,s.undirected),e&&l)return u}}function i0(e,t){if(e.size===0)return gr();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(n&&o.undirected!==r))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function gl(e,t,n,r,i,a){let o=t?e0:Jk,s;if(n!=="undirected"&&(r!=="out"&&(s=o(e,i.in,a),e&&s)||r!=="in"&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!=="directed"&&(s=o(e,i.undirected,a),e&&s))return s}function a0(e,t,n,r){let i=[];return gl(!1,e,t,n,r,function(a){i.push(a)}),i}function o0(e,t,n){let r=gr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Yt(r,pl(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Yt(r,pl(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Yt(r,pl(n.undirected))),r}function ml(e,t,n,r,i,a,o){let s=n?n0:t0,l;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(e,i.in,a,o),e&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==a)&&(l=s(e,i.out,a,o),e&&l))||t!=="directed"&&typeof i.undirected<"u"&&(l=s(e,i.undirected,a,o),e&&l))return l}function s0(e,t,n,r,i){let a=[];return ml(!1,e,t,n,r,i,function(o){a.push(o)}),a}function l0(e,t,n,r){let i=gr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=Yt(i,fl(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=Yt(i,fl(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=Yt(i,fl(n.undirected,r))),i}function c0(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(a,o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return r0(this,r);if(arguments.length===1){a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new M(`Graph.${n}: could not find the "${a}" node in the graph.`);return a0(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){a=""+a,o=""+o;let s=this._nodes.get(a);if(!s)throw new M(`Graph.${n}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new M(`Graph.${n}: could not find the "${o}" target node in the graph.`);return s0(r,this.multi,i,s,o)}throw new $(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function u0(e,t){let{name:n,type:r,direction:i}=t,a="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(c,u,d){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return d=c,Cf(!1,this,r,d);if(arguments.length===2){c=""+c,d=u;let h=this._nodes.get(c);if(typeof h>"u")throw new M(`Graph.${a}: could not find the "${c}" node in the graph.`);return gl(!1,this.multi,r==="mixed"?this.type:r,i,h,d)}if(arguments.length===3){c=""+c,u=""+u;let h=this._nodes.get(c);if(!h)throw new M(`Graph.${a}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new M(`Graph.${a}: could not find the "${u}" target node in the graph.`);return ml(!1,r,this.multi,i,h,u,d)}throw new $(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o="map"+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),d;if(c.length===0){let h=0;r!=="directed"&&(h+=this.undirectedSize),r!=="undirected"&&(h+=this.directedSize),d=new Array(h);let f=0;c.push((g,w,v,y,b,_,x)=>{d[f++]=u(g,w,v,y,b,_,x)})}else d=[],c.push((h,f,g,w,v,y,b)=>{d.push(u(h,f,g,w,v,y,b))});return this[a].apply(this,c),d};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),d=[];return c.push((h,f,g,w,v,y,b)=>{u(h,f,g,w,v,y,b)&&d.push(h)}),this[a].apply(this,c),d};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new $(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new $(`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 u,d;c.length===2?(u=c[0],d=c[1],c=[]):c.length===3?(u=c[1],d=c[2],c=[c[0]]):c.length===4&&(u=c[2],d=c[3],c=[c[0],c[1]]);let h=d;return c.push((f,g,w,v,y,b,_)=>{h=u(h,f,g,w,v,y,b,_)}),this[a].apply(this,c),h}}function d0(e,t){let{name:n,type:r,direction:i}=t,a="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(l,c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return u=l,Cf(!0,this,r,u);if(arguments.length===2){l=""+l,u=c;let d=this._nodes.get(l);if(typeof d>"u")throw new M(`Graph.${a}: could not find the "${l}" node in the graph.`);return gl(!0,this.multi,r==="mixed"?this.type:r,i,d,u)}if(arguments.length===3){l=""+l,c=""+c;let d=this._nodes.get(l);if(!d)throw new M(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new M(`Graph.${a}: could not find the "${c}" target node in the graph.`);return ml(!0,r,this.multi,i,d,c,u)}throw new $(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((d,h,f,g,w,v,y)=>c(d,h,f,g,w,v,y)),!!this[a].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((d,h,f,g,w,v,y)=>!c(d,h,f,g,w,v,y)),!this[a].apply(this,l)}}function h0(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+"Entries";e.prototype[a]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return gr();if(!arguments.length)return i0(this,r);if(arguments.length===1){o=""+o;let l=this._nodes.get(o);if(!l)throw new M(`Graph.${a}: could not find the "${o}" node in the graph.`);return o0(r,i,l)}if(arguments.length===2){o=""+o,s=""+s;let l=this._nodes.get(o);if(!l)throw new M(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new M(`Graph.${a}: could not find the "${s}" target node in the graph.`);return l0(r,i,l,s)}throw new $(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function p0(e){Qk.forEach(t=>{c0(e,t),u0(e,t),d0(e,t),h0(e,t)})}var f0=[{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 Ua(){this.A=null,this.B=null}Ua.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};Ua.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function si(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,l=o.target,c=s===n?l:s;if(t&&t.has(c.key))continue;let u=i(c.key,c.attributes);if(e&&u)return c.key}}function vl(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return si(e,null,r,r.undirected,i);if(typeof n=="string")return si(e,null,r,r[n],i)}let a=new Ua,o;if(t!=="undirected"){if(n!=="out"){if(o=si(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!=="in"){if(o=si(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!=="directed"&&(o=si(e,a,r,r.undirected,i),e&&o))return o}function g0(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 vl(!1,e,t,n,function(i){r.push(i)}),r}function li(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],l=s.source,c=s.target;if(o=l===t?c:l,e&&e.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function m0(e,t,n){if(e!=="mixed"){if(e==="undirected")return li(null,n,n.undirected);if(typeof t=="string")return li(null,n,n[t])}let r=gr(),i=new Ua;return e!=="undirected"&&(t!=="out"&&(r=Yt(r,li(i,n,n.in))),t!=="in"&&(r=Yt(r,li(i,n,n.out)))),e!=="directed"&&(r=Yt(r,li(i,n,n.undirected))),r}function v0(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];a=""+a;let o=this._nodes.get(a);if(typeof o>"u")throw new M(`Graph.${n}: could not find the "${a}" node in the graph.`);return g0(r==="mixed"?this.type:r,i,o)}}function w0(e,t){let{name:n,type:r,direction:i}=t,a="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let d=this._nodes.get(c);if(typeof d>"u")throw new M(`Graph.${a}: could not find the "${c}" node in the graph.`);vl(!1,r==="mixed"?this.type:r,i,d,u)};let o="map"+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(c,u){let d=[];return this[a](c,(h,f)=>{d.push(u(h,f))}),d};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,u){let d=[];return this[a](c,(h,f)=>{u(h,f)&&d.push(h)}),d};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(c,u,d){if(arguments.length<3)throw new $(`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 h=d;return this[a](c,(f,g)=>{h=u(h,f,g)}),h}}function y0(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o="find"+a;e.prototype[o]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let d=this._nodes.get(c);if(typeof d>"u")throw new M(`Graph.${o}: could not find the "${c}" node in the graph.`);return vl(!0,r==="mixed"?this.type:r,i,d,u)};let s="some"+a;e.prototype[s]=function(c,u){return!!this[o](c,u)};let l="every"+a;e.prototype[l]=function(c,u){return!this[o](c,(h,f)=>!u(h,f))}}function b0(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+"Entries";e.prototype[a]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return gr();o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new M(`Graph.${a}: could not find the "${o}" node in the graph.`);return m0(r==="mixed"?this.type:r,i,s)}}function x0(e){f0.forEach(t=>{v0(e,t),w0(e,t),y0(e,t),b0(e,t)})}function Oa(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,l,c,u,d,h,f;for(;s=a.next(),s.done!==!0;){let g=!1;if(l=s.value,o!=="undirected"){u=l.out;for(c in u){d=u[c];do{if(h=d.target,g=!0,f=i(l.key,h.key,l.attributes,h.attributes,d.key,d.attributes,d.undirected),e&&f)return d;d=d.next}while(d)}}if(o!=="directed"){u=l.undirected;for(c in u)if(!(t&&l.key>c)){d=u[c];do{if(h=d.target,h.key!==c&&(h=d.source),g=!0,f=i(l.key,h.key,l.attributes,h.attributes,d.key,d.attributes,d.undirected),e&&f)return d;d=d.next}while(d)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),e&&f))return null}}function k0(e,t){let n={key:e};return kf(t.attributes)||(n.attributes=Ge({},t.attributes)),n}function _0(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return kf(n.attributes)||(r.attributes=Ge({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function T0(e){if(!Be(e))throw new $('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 $("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!Be(e.attributes)||e.attributes===null))throw new $("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function S0(e){if(!Be(e))throw new $('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 $("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new $("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!Be(e.attributes)||e.attributes===null))throw new $("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new $("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var E0=Ak(),R0=new Set(["directed","undirected","mixed"]),yf=new Set(["domain","_events","_eventsCount","_maxListeners"]),A0=[{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"}],C0={allowSelfLoops:!0,multi:!1,type:"mixed"};function L0(e,t,n){if(n&&!Be(n))throw new $(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new q(`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 bf(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 Lf(e,t,n,r,i,a,o,s){if(!r&&e.type==="undirected")throw new q(`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 q(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Be(s))throw new $(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!e.allowSelfLoops&&a===o)throw new q(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(a),c=e._nodes.get(o);if(!l)throw new M(`Graph.${t}: source node "${a}" not found.`);if(!c)throw new M(`Graph.${t}: target node "${o}" not found.`);let u={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new q(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof l.undirected[o]<"u":typeof l.out[o]<"u"))throw new q(`Graph.${t}: an edge linking "${a}" to "${o}" 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 d=new mr(r,i,l,c,s);e._edges.set(i,d);let h=a===o;return r?(l.undirectedDegree++,c.undirectedDegree++,h&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,c.inDegree++,h&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,u.key=i,e.emit("edgeAdded",u),i}function N0(e,t,n,r,i,a,o,s,l){if(!r&&e.type==="undirected")throw new q(`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 q(`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 $(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!Be(s))throw new $(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let c;if(l&&(c=s,s=void 0),!e.allowSelfLoops&&a===o)throw new q(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=e._nodes.get(a),d=e._nodes.get(o),h,f;if(!n&&(h=e._edges.get(i),h)){if((h.source.key!==a||h.target.key!==o)&&(!r||h.source.key!==o||h.target.key!==a))throw new q(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${h.source.key}", "${h.target.key}").`);f=h}if(!f&&!e.multi&&u&&(f=r?u.undirected[o]:u.out[o]),f){let b=[f.key,!1,!1,!1];if(l?!c:!s)return b;if(l){let _=f.attributes;f.attributes=c(_),e.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else Ge(f.attributes,s),e.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return b}s=s||{},l&&c&&(s=c(s));let g={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new q(`Graph.${t}: the "${i}" edge already exists in the graph.`);let w=!1,v=!1;u||(u=bf(e,a,{}),w=!0,a===o&&(d=u,v=!0)),d||(d=bf(e,o,{}),v=!0),h=new mr(r,i,u,d,s),e._edges.set(i,h);let y=a===o;return r?(u.undirectedDegree++,d.undirectedDegree++,y&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,d.inDegree++,y&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,g.key=i,e.emit("edgeAdded",g),[i,!0,w,v]}function fr(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var he=class e extends xf.EventEmitter{constructor(t){if(super(),t=Ge({},C0,t),typeof t.multi!="boolean")throw new $(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!R0.has(t.type))throw new $(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new $(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);let n=t.type==="mixed"?_f:t.type==="directed"?Tf:Sf;xt(this,"NodeDataClass",n);let r="geid_"+E0()+"_",i=0,a=()=>{let o;do o=r+i++;while(this._edges.has(o));return o};xt(this,"_attributes",{}),xt(this,"_nodes",new Map),xt(this,"_edges",new Map),xt(this,"_directedSize",0),xt(this,"_undirectedSize",0),xt(this,"_directedSelfLoopCount",0),xt(this,"_undirectedSelfLoopCount",0),xt(this,"_edgeKeyGenerator",a),xt(this,"_options",t),yf.forEach(o=>xt(this,o,this[o])),Ct(this,"order",()=>this._nodes.size),Ct(this,"size",()=>this._edges.size),Ct(this,"directedSize",()=>this._directedSize),Ct(this,"undirectedSize",()=>this._undirectedSize),Ct(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Ct(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Ct(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Ct(this,"multi",this._options.multi),Ct(this,"type",this._options.type),Ct(this,"allowSelfLoops",this._options.allowSelfLoops),Ct(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 $(`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 $(`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 $(`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 q("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 M(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new M(`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 q("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 M(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new M(`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 q("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 M(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,a=r.target.key;if(t===i)return a;if(t===a)return i;throw new M(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${a}).`)}hasExtremity(t,n){t=""+t,n=""+n;let r=this._edges.get(t);if(!r)throw new M(`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 M(`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 M(`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 M(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return L0(this,t,n).key}mergeNode(t,n){if(n&&!Be(n))throw new $(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ge(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 $(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){let a=r.attributes;r.attributes=n(a),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 M(`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 fr(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do fr(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do fr(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=kt(this,r,i,this.type),!n)throw new M(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new M(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return fr(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new q("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 q("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=kt(this,t,n,"directed");if(!r)throw new M(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return fr(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new q("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 q("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=kt(this,t,n,"undirected");if(!r)throw new M(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return fr(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 $("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(!Be(t))throw new $("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(!Be(t))throw new $("Graph.mergeAttributes: provided attributes are not a plain object.");return Ge(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new $("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 $("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!wf(n))throw new $("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,a.attributes=t(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new $("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!wf(n))throw new $("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,a,o,s;for(;i=r.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=t(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new $("Graph.forEachAdjacencyEntry: expecting a callback.");Oa(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new $("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Oa(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new $("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Oa(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new $("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Oa(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new $("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 $("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 $("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,a=new Array(this.order),o=0;for(;r=n.next(),r.done!==!0;)i=r.value,a[o++]=t(i.key,i.attributes);return a}someNode(t){if(typeof t!="function")throw new $("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 $("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 $("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,a=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(t,n){if(typeof t!="function")throw new $("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new $("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(),a,o;for(;a=i.next(),a.done!==!0;)o=a.value,r=t(r,o.key,o.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,a)=>{t[n++]=k0(a,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,a)=>{r[n++]=_0(this.type,a,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,c)=>{n?this.mergeNode(l,c):this.addNode(l,c)}),t.forEachEdge((l,c,u,d,h,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,u,d,c):this.mergeDirectedEdgeWithKey(l,u,d,c):g?this.addUndirectedEdgeWithKey(l,u,d,c):this.addDirectedEdgeWithKey(l,u,d,c)}),this;if(!Be(t))throw new $("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Be(t.attributes))throw new $("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,a,o,s;if(t.nodes){if(a=t.nodes,!Array.isArray(a))throw new $("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=a.length;r<i;r++){o=a[r],T0(o);let{key:l,attributes:c}=o;n?this.mergeNode(l,c):this.addNode(l,c)}}if(t.edges){let l=!1;if(this.type==="undirected"&&(l=!0),a=t.edges,!Array.isArray(a))throw new $("Graph.import: invalid edges. Expecting an array.");for(r=0,i=a.length;r<i;r++){s=a[r],S0(s);let{source:c,target:u,attributes:d,undirected:h=l}=s,f;"key"in s?(f=n?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,c,u,d)):(f=n?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,c,u,d))}}return this}nullCopy(t){let n=new e(Ge({},this._options,t));return n.replaceAttributes(Ge({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let a=Ge({},r.attributes);r=new n.NodeDataClass(i,a),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new q(`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 q("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 q("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,a;for(;i=r.next(),i.done!==!0;)a=i.value,Lf(n,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,Ge({},a.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let t={};this._nodes.forEach((a,o)=>{t[o]=a.attributes});let n={},r={};this._edges.forEach((a,o)=>{let s=a.undirected?"--":"->",l="",c=a.source.key,u=a.target.key,d;a.undirected&&c>u&&(d=c,c=u,u=d);let h=`(${c})${s}(${u})`;o.startsWith("geid_")?this.multi&&(typeof r[h]>"u"?r[h]=0:r[h]++,l+=`${r[h]}. `):l+=`[${o}]: `,l+=h,n[l]=a.attributes});let i={};for(let a in this)this.hasOwnProperty(a)&&!yf.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,xt(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(he.prototype[Symbol.for("nodejs.util.inspect.custom")]=he.prototype.inspect);A0.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?Lf:N0;e.generateKey?he.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,a,o,t==="update")}:he.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,a,o,s,t==="update")}})});zk(he);Xk(he);p0(he);x0(he);var Fa=class extends he{constructor(t){let n=Ge({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new $("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new $('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},$a=class extends he{constructor(t){let n=Ge({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new $("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new $('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},za=class extends he{constructor(t){let n=Ge({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new $("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Ha=class extends he{constructor(t){let n=Ge({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new $("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new $('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Wa=class extends he{constructor(t){let n=Ge({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new $("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new $('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function vr(e){e.from=function(t,n){let r=Ge({},t.options,n),i=new e(r);return i.import(t),i}}vr(he);vr(Fa);vr($a);vr(za);vr(Ha);vr(Wa);he.Graph=he;he.DirectedGraph=Fa;he.UndirectedGraph=$a;he.MultiGraph=za;he.MultiDirectedGraph=Ha;he.MultiUndirectedGraph=Wa;he.InvalidArgumentsGraphError=$;he.NotFoundGraphError=M;he.UsageGraphError=q;function P0(){return new he({multi:!0,type:"directed"})}function wl(e){let t=P0();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:a,...o}=n;t.addDirectedEdgeWithKey(r,i,a,{source:i,target:a,...o})}return t}function Nf(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 Ba(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var Pf=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function Df(e,t,n){let r=null,i=wl({nodes:[],edges:[]}),a=null,o=null,s="neighbourhood",l=new Map,c=0,u=0,d=null,h=0,f=()=>{},g=()=>{},w=()=>{},v=()=>{},y=()=>{},b=null,_=!1,x=P=>{if(b===null)return;let R=b;b=null,r?.setSetting("enableCameraPanning",!0),(P===null||P===R)&&y(R)},C=()=>ms([...Ba(i).values()]),O=(P,R)=>{R.then(()=>{r===P&&P.refresh()},()=>{})},N=P=>{let R=vd(a,o,c,s),H=xd(a,o,c,s),Z=l;P.setSetting("nodeReducer",(G,J)=>{let X={...J,...R(G,J,t)};return{...X,...kd(Z.get(G),X,t,J.label)}}),P.setSetting("edgeReducer",(G,J)=>({...J,...H(G,J,t)}))},j=()=>{if(n===void 0||d!==null)return;h=n.now();let P=()=>{d=null;let R=n.now();if(c=yd(c,u,R-h),h=R,r!==null&&N(r),c===u){c===0&&(a=null);return}d=n.request(P)};d=n.request(P)};return{mount(P){if(r!==null)return;let R=e(i,P,Td(t));R.on("clickNode",({node:H})=>{_||f(H)}),R.on("doubleClickNode",({node:H,preventSigmaDefault:Z})=>{Z(),_||f(H)}),R.on("clickStage",()=>f(null)),R.on("downNode",({node:H})=>{b=H,_=!1,r?.setSetting("enableCameraPanning",!1),w(H)}),R.on("moveBody",H=>{b!==null&&(_=!0,H.preventSigmaDefault(),v(b,R.viewportToGraph({x:H.event.x,y:H.event.y})))}),R.on("enterNode",({node:H})=>g(H)),R.on("leaveNode",()=>g(null)),R.on("upNode",()=>x(b)),R.on("upStage",()=>x(null)),N(R),R.setSetting("labelRenderedSizeThreshold",vs(i.order)),R.setCustomBBox(C()),r=R},setGraph(P){i=wl(P),r?.setGraph(i),r?.setSetting("labelRenderedSizeThreshold",vs(i.order)),r?.setCustomBBox(C())},setPositions(P){Nf(i,P),r?.refresh()},setHighlight(P,R=null,H="neighbourhood"){if(n===void 0){a=P,o=R,s=H,c=P===null?0:1,u=c,r!==null&&N(r);return}if(P===null){if(u=0,a===null)return}else a=P,o=R,s=H,u=1;r!==null&&N(r),c!==u&&j()},setTrail(P){l=P,r!==null&&N(r)},onSelect(P){f=P},onHover(P){g=P},onDragStart(P){w=P},onDragMove(P){v=P},onDragEnd(P){y=P},fit(){let P=r;P!==null&&(P.setCustomBBox(C()),O(P,P.getCamera().animatedReset()))},focus(P){let R=r;if(R===null)return;let H=C(),Z=Ba(i),G=[...P??[]].flatMap(X=>Z.get(X)??[]),J=pd(H,G);R.setCustomBBox(H),O(R,J===null?R.getCamera().animatedReset():R.getCamera().animate(J))},positions(){return Ba(i)},destroy(){d!==null&&(n?.cancel(d),d=null),r?.kill(),r=null}}}var If=e=>Df((t,n,r)=>new vf(t,n,r),e,Pf(window));function Mf(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 D0(e){if(Array.isArray(e))return e}function I0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}function M0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
410
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function G0(e,t){return D0(e)||I0(e,t)||O0(e,t)||M0()}function O0(e,t){if(e){if(typeof e=="string")return Mf(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)?Mf(e,t):void 0}}var Zf=Object.entries,Gf=Object.setPrototypeOf,F0=Object.isFrozen,$0=Object.getPrototypeOf,z0=Object.getOwnPropertyDescriptor,Oe=Object.freeze,We=Object.seal,wr=Object.create,Xf=typeof Reflect<"u"&&Reflect,Sl=Xf.apply,El=Xf.construct;Oe||(Oe=function(t){return t});We||(We=function(t){return t});Sl||(Sl=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];return t.apply(n,i)});El||(El=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 Bn=Ne(Array.prototype.forEach),H0=Ne(Array.prototype.lastIndexOf),Of=Ne(Array.prototype.pop),ui=Ne(Array.prototype.push),W0=Ne(Array.prototype.splice),yr=Array.isArray,pi=Ne(String.prototype.toLowerCase),yl=Ne(String.prototype.toString),Ff=Ne(String.prototype.match),di=Ne(String.prototype.replace),$f=Ne(String.prototype.indexOf),U0=Ne(String.prototype.trim),B0=Ne(Number.prototype.toString),K0=Ne(Boolean.prototype.toString),zf=typeof BigInt>"u"?null:Ne(BigInt.prototype.toString),Hf=typeof Symbol>"u"?null:Ne(Symbol.prototype.toString),lt=Ne(Object.prototype.hasOwnProperty),hi=Ne(Object.prototype.toString),qe=Ne(RegExp.prototype.test),Un=V0(TypeError);function Ne(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 Sl(e,t,r)}}function V0(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return El(e,n)}}function ae(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pi;if(Gf&&Gf(e,null),!yr(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let a=n(i);a!==i&&(F0(t)||(t[r]=a),i=a)}e[i]=!0}return e}function j0(e){for(let t=0;t<e.length;t++)lt(e,t)||(e[t]=null);return e}function mt(e){let t=wr(null);for(let r of Zf(e)){var n=G0(r,2);let i=n[0],a=n[1];lt(e,i)&&(yr(a)?t[i]=j0(a):a&&typeof a=="object"&&a.constructor===Object?t[i]=mt(a):t[i]=a)}return t}function q0(e){switch(typeof e){case"string":return e;case"number":return B0(e);case"boolean":return K0(e);case"bigint":return zf?zf(e):"0";case"symbol":return Hf?Hf(e):"Symbol()";case"undefined":return hi(e);case"function":case"object":{if(e===null)return hi(e);let t=e,n=Lt(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:hi(r)}return hi(e)}default:return hi(e)}}function Lt(e,t){for(;e!==null;){let r=z0(e,t);if(r){if(r.get)return Ne(r.get);if(typeof r.value=="function")return Ne(r.value)}e=$0(e)}function n(){return null}return n}function Y0(e){try{return qe(e,""),!0}catch{return!1}}var Wf=Oe(["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"]),bl=Oe(["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"]),xl=Oe(["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"]),Z0=Oe(["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"]),kl=Oe(["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"]),X0=Oe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Uf=Oe(["#text"]),Bf=Oe(["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"]),_l=Oe(["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"]),Kf=Oe(["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"]),Ka=Oe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Q0=We(/{{[\w\W]*|^[\w\W]*}}/g),J0=We(/<%[\w\W]*|^[\w\W]*%>/g),e_=We(/\${[\w\W]*/g),t_=We(/^data-[\-\w.\u00B7-\uFFFF]+$/),n_=We(/^aria-[\-\w]+$/),Vf=We(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),r_=We(/^(?:\w+script|data):/i),i_=We(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),a_=We(/^html$/i),o_=We(/^[a-z][.\w]*(-[.\w]+)+$/i),jf=We(/<[/\w!]/g),qf=We(/<[/\w]/g),s_=We(/<\/no(script|embed|frames)/i),l_=We(/\/>/i),gt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Qf=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],c_=Oe(ae({},Qf)),u_=(function(){let e={};return Bn(Qf,t=>{e[t]=We(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Oe(e)})(),d_=function(){return typeof window>"u"?null:window},h_=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 a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Yf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},fn=function(t,n,r,i){return lt(t,n)&&yr(t[n])?ae(i.base?mt(i.base):{},t[n],i.transform):r},Tl=function(t,n,r){let i=lt(t,n)?t[n]:void 0;return i&&typeof i=="object"?mt(i):r()};function Jf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:d_(),t=D=>Jf(D);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==gt.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,l=e.NodeFilter,c=e.NamedNodeMap;c===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let u=e.DOMParser,d=e.trustedTypes,h=s.prototype,f=Lt(h,"cloneNode"),g=Lt(h,"remove"),w=Lt(h,"nextSibling"),v=Lt(h,"childNodes"),y=Lt(h,"parentNode"),b=Lt(h,"shadowRoot"),_=Lt(h,"attributes"),x=o&&o.prototype?Lt(o.prototype,"nodeType"):null,C=o&&o.prototype?Lt(o.prototype,"nodeName"):null,O=o&&o.prototype?Lt(o.prototype,"ownerDocument"):null,N=function(m){return x?x(m):m.nodeType},j=function(m){return C?C(m):m.nodeName};if(typeof a=="function"){let D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let P,R="",H,Z=!1,G=0,J=function(){if(G>0)throw Un('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.')},X=function(m){J(),G++;try{return P.createHTML(m)}finally{G--}},se=function(m){J(),G++;try{return P.createScriptURL(m)}finally{G--}},Ye=function(){return Z||(H=h_(d,i),Z=!0),H},Ae=n,we=Ae.implementation,ue=Ae.createNodeIterator,Te=Ae.createDocumentFragment,ct=Ae.getElementsByTagName,Pe=r.importNode,oe=Yf();t.isSupported=typeof Zf=="function"&&typeof y=="function"&&we&&we.createHTMLDocument!==void 0;let Se=Q0,ut=J0,Nt=e_,L=t_,W=n_,te=r_,ge=i_,Fe=o_,wt=Vf,pe=null,_t=ae({},[...Wf,...bl,...xl,...kl,...Uf]),ie=null,Tt=ae({},[...Bf,..._l,...Kf,...Ka]),Ke=Object.seal(wr(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}})),gn=null,xr=null,Ve=Object.seal(wr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),kr=!0,mn=!0,_r=!1,Tr=!0,Pt=!1,$t=!0,et=!1,vn=!1,Dt=null,Vn=null,yt=!1,Ee=!1,$e=!1,wn=!1,Ce=!0,zt=!1,Xt="user-content-",yn=!0,Sr=!1,Qt={},tt=null,vi=ae({},["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"]),nt=null,Jt=ae({},["audio","video","img","source","image","track"]),St=null,dt=ae({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jn="http://www.w3.org/1998/Math/MathML",en="http://www.w3.org/2000/svg",ht="http://www.w3.org/1999/xhtml",tn=ht,Er=!1,Rr=null,so=ae({},[jn,en,ht],yl),wi=Oe(["mi","mo","mn","ms","mtext"]),Ar=ae({},wi),yi=Oe(["annotation-xml"]),qn=ae({},yi),bi=ae({},["title","style","font","a","script"]),bn=null,xi=["application/xhtml+xml","text/html"],ki="text/html",ye=null,nn=null,_i=n.createElement("form"),xn=function(m){return m instanceof RegExp||m instanceof Function},Cr=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(nn&&nn===m)return;(!m||typeof m!="object")&&(m={}),m=mt(m),bn=xi.indexOf(m.PARSER_MEDIA_TYPE)===-1?ki:m.PARSER_MEDIA_TYPE,ye=bn==="application/xhtml+xml"?yl:pi,pe=fn(m,"ALLOWED_TAGS",_t,{transform:ye}),ie=fn(m,"ALLOWED_ATTR",Tt,{transform:ye}),Rr=fn(m,"ALLOWED_NAMESPACES",so,{transform:yl}),St=fn(m,"ADD_URI_SAFE_ATTR",dt,{transform:ye,base:dt}),nt=fn(m,"ADD_DATA_URI_TAGS",Jt,{transform:ye,base:Jt}),tt=fn(m,"FORBID_CONTENTS",vi,{transform:ye}),gn=fn(m,"FORBID_TAGS",mt({}),{transform:ye}),xr=fn(m,"FORBID_ATTR",mt({}),{transform:ye}),Qt=lt(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?mt(m.USE_PROFILES):m.USE_PROFILES:!1,kr=m.ALLOW_ARIA_ATTR!==!1,mn=m.ALLOW_DATA_ATTR!==!1,_r=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Tr=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pt=m.SAFE_FOR_TEMPLATES||!1,$t=m.SAFE_FOR_XML!==!1,et=m.WHOLE_DOCUMENT||!1,Ee=m.RETURN_DOM||!1,$e=m.RETURN_DOM_FRAGMENT||!1,wn=m.RETURN_TRUSTED_TYPE||!1,yt=m.FORCE_BODY||!1,Ce=m.SANITIZE_DOM!==!1,zt=m.SANITIZE_NAMED_PROPS||!1,yn=m.KEEP_CONTENT!==!1,Sr=m.IN_PLACE||!1,wt=Y0(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:Vf,tn=typeof m.NAMESPACE=="string"?m.NAMESPACE:ht,Ar=Tl(m,"MATHML_TEXT_INTEGRATION_POINTS",()=>ae({},wi)),qn=Tl(m,"HTML_INTEGRATION_POINTS",()=>ae({},yi));let T=Tl(m,"CUSTOM_ELEMENT_HANDLING",()=>wr(null));if(Ke=wr(null),lt(T,"tagNameCheck")&&xn(T.tagNameCheck)&&(Ke.tagNameCheck=T.tagNameCheck),lt(T,"attributeNameCheck")&&xn(T.attributeNameCheck)&&(Ke.attributeNameCheck=T.attributeNameCheck),lt(T,"allowCustomizedBuiltInElements")&&typeof T.allowCustomizedBuiltInElements=="boolean"&&(Ke.allowCustomizedBuiltInElements=T.allowCustomizedBuiltInElements),We(Ke),Pt&&(mn=!1),$e&&(Ee=!0),Qt&&(pe=ae({},Uf),ie=wr(null),Qt.html===!0&&(ae(pe,Wf),ae(ie,Bf)),Qt.svg===!0&&(ae(pe,bl),ae(ie,_l),ae(ie,Ka)),Qt.svgFilters===!0&&(ae(pe,xl),ae(ie,_l),ae(ie,Ka)),Qt.mathMl===!0&&(ae(pe,kl),ae(ie,Kf),ae(ie,Ka))),Ve.tagCheck=null,Ve.attributeCheck=null,lt(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Ve.tagCheck=m.ADD_TAGS:yr(m.ADD_TAGS)&&(pe===_t&&(pe=mt(pe)),ae(pe,m.ADD_TAGS,ye))),lt(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Ve.attributeCheck=m.ADD_ATTR:yr(m.ADD_ATTR)&&(ie===Tt&&(ie=mt(ie)),ae(ie,m.ADD_ATTR,ye))),lt(m,"ADD_FORBID_CONTENTS")&&yr(m.ADD_FORBID_CONTENTS)&&(tt===vi&&(tt=mt(tt)),ae(tt,m.ADD_FORBID_CONTENTS,ye)),yn&&(pe["#text"]=!0),et&&ae(pe,["html","head","body"]),pe.table&&(ae(pe,["tbody"]),delete gn.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Un('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Un('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=P;P=m.TRUSTED_TYPES_POLICY;try{R=X("")}catch(F){throw P=E,F}}else m.TRUSTED_TYPES_POLICY===null?(P=void 0,R=""):(P===void 0&&(P=Ye()),P&&typeof R=="string"&&(R=X("")));Oe&&Oe(m),nn=m},Ti=ae({},[...bl,...xl,...Z0]),Lr=ae({},[...kl,...X0]),Si=function(m,T,E){return T.namespaceURI===ht?m==="svg":T.namespaceURI===jn?m==="svg"&&(E==="annotation-xml"||Ar[E]):!!Ti[m]},Ei=function(m,T,E){return T.namespaceURI===ht?m==="math":T.namespaceURI===en?m==="math"&&qn[E]:!!Lr[m]},Ri=function(m,T,E){return T.namespaceURI===en&&!qn[E]||T.namespaceURI===jn&&!Ar[E]?!1:!Lr[m]&&(bi[m]||!Ti[m])},lo=function(m){let T=y(m);(!T||!T.tagName)&&(T={namespaceURI:tn,tagName:"template"});let E=pi(m.tagName),F=pi(T.tagName);return Rr[m.namespaceURI]?m.namespaceURI===en?Si(E,T,F):m.namespaceURI===jn?Ei(E,T,F):m.namespaceURI===ht?Ri(E,T,F):!!(bn==="application/xhtml+xml"&&Rr[m.namespaceURI]):!1},k=function(m){ui(t.removed,{element:m});try{y(m).removeChild(m)}catch{if(g(m),!y(m))throw Un("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},S=function(m,T,E){try{m.removeAttributeNode(T)}catch{try{m.removeAttribute(E)}catch{}}},B=function(m){ee(m);let T=v(m);if(T){let F=[];Bn(T,U=>{ui(F,U)}),Bn(F,U=>{try{g(U)}catch{}})}let E=_(m);if(E)for(let F=E.length-1;F>=0;--F){let U=E[F],Y=U&&U.name;typeof Y=="string"&&S(m,U,Y)}},Q=function(m,T,E){if(!E)try{E=T.getAttributeNode(m)}catch{E=null}ui(t.removed,{attribute:E||null,from:T});try{E?T.removeAttributeNode(E):T.removeAttribute(m)}catch{try{T.removeAttribute(m)}catch{}}if(m==="is")if(Ee||$e)try{k(T)}catch{}else try{T.setAttribute(m,"")}catch{}},I=function(m){let T=_(m);if(T)for(let E=T.length-1;E>=0;--E){let F=T[E],U=F&&F.name;typeof U!="string"||ie[ye(U)]||S(m,F,U)}},ee=function(m){let T=[m];for(;T.length>0;){let E=T.pop();N(E)===gt.element&&I(E);let U=v(E);if(U)for(let Y=U.length-1;Y>=0;--Y)T.push(U[Y])}},Ue=function(m,T){return $t?m==="patchsrc"?!0:m==="for"&&T!=="label"&&T!=="output":!1},rn=function(m){if(!$t)return;let T=[m];for(;T.length>0;){let E=T.pop(),F=N(E);if(F===gt.processingInstruction||F===gt.comment&&qe(qf,E.data)){try{g(E)}catch{}continue}if(F===gt.element){let Y=E,me=ye(j(E));try{Y.hasAttribute&&Y.hasAttribute("patchsrc")&&Y.removeAttribute("patchsrc"),Y.hasAttribute&&Y.hasAttribute("for")&&Ue("for",me)&&Y.removeAttribute("for")}catch{}}let U=v(E);if(U)for(let Y=U.length-1;Y>=0;--Y)T.push(U[Y])}},Nr=function(m){let T=null,E=null;if(yt)m="<remove></remove>"+m;else{let Y=Ff(m,/^[\r\n\t ]+/);E=Y&&Y[0]}bn==="application/xhtml+xml"&&tn===ht&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");let F=P?X(m):m;if(tn===ht)try{T=new u().parseFromString(F,bn)}catch{}if(!T||!T.documentElement){T=we.createDocument(tn,"template",null);try{T.documentElement.innerHTML=Er?R:F}catch{}}let U=T.body||T.documentElement;return m&&E&&U.insertBefore(n.createTextNode(E),U.childNodes[0]||null),tn===ht?ct.call(T,et?"html":"body")[0]:et?T.documentElement:U},Pr=function(m){let T=O?O(m):m.ownerDocument;return ue.call(T||m,m,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Yn=function(m){return m=di(m,Se," "),m=di(m,ut," "),m=di(m,Nt," "),m},co=function(m){var T;m.normalize();let E=O?O(m):m.ownerDocument,F=ue.call(E||m,m,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),U=F.nextNode();for(;U;)U.data=Yn(U.data),U=F.nextNode();let Y=(T=m.querySelectorAll)===null||T===void 0?void 0:T.call(m,"template");Y&&Bn(Y,me=>{Zn(me.content)&&co(me.content)})},Ai=function(m){let T=C?C(m):null;return typeof T!="string"||ye(T)!=="form"?!1:typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||m.attributes!==_(m)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function"||m.nodeType!==x(m)||m.childNodes!==v(m)},Zn=function(m){if(!x||typeof m!="object"||m===null)return!1;try{return x(m)===gt.documentFragment}catch{return!1}},Dr=function(m){if(!x||typeof m!="object"||m===null)return!1;try{return typeof x(m)=="number"}catch{return!1}};function It(D,m,T){D.length!==0&&Bn(D,E=>{E.call(t,m,T,nn)})}let Wm=function(m,T){return!!($t&&m.hasChildNodes()&&!Dr(m.firstElementChild)&&qe(jf,m.textContent)&&qe(jf,m.innerHTML)||$t&&m.namespaceURI===ht&&c_[T]&&(Dr(m.firstElementChild)||typeof m.textContent=="string"&&qe(u_[T],m.textContent))||m.nodeType===gt.processingInstruction||$t&&m.nodeType===gt.comment&&qe(qf,m.data))},Ci=function(m,T){if(m instanceof RegExp)return qe(m,T);if(m instanceof Function){for(var E=arguments.length,F=new Array(E>2?E-2:0),U=2;U<E;U++)F[U-2]=arguments[U];return!!m(T,...F)}return!1},Um=function(m,T,E){if(!gn[T]&&Zl(T)&&Ci(Ke.tagNameCheck,T))return!1;if(yn&&!tt[T]){let F=y(m),U=v(m);if(U&&F){let Y=U.length;for(let me=Y-1;me>=0;--me){let xe=m===E?f(U[me],!0):U[me];F.insertBefore(xe,w(m))}}}return k(m),!0},Vl=function(m,T,E,F){return m.length===0?T:T===E||T===F?mt(T):T},jl=function(m,T){return m===T||y(m)!==null?!1:(Sr&&ee(m),!0)},ql=function(m,T){if(It(oe.beforeSanitizeElements,m,null),jl(m,T))return!0;if(Ai(m))return k(m),!0;let E=ye(j(m));if(pe=Vl(oe.uponSanitizeElement,pe,_t,Dt),It(oe.uponSanitizeElement,m,{tagName:E,allowedTags:pe}),jl(m,T))return!0;if(Wm(m,E))return k(m),!0;if(gn[E]||!(Ve.tagCheck instanceof Function&&Ve.tagCheck(E))&&!pe[E]){let U=Um(m,E,T);return U===!1&&It(oe.afterSanitizeElements,m,null),U}if(N(m)===gt.element&&!lo(m)||(E==="noscript"||E==="noembed"||E==="noframes")&&qe(s_,m.innerHTML))return k(m),!0;if(Pt&&m.nodeType===gt.text){let U=Yn(m.textContent);m.textContent!==U&&(ui(t.removed,{element:m.cloneNode()}),m.textContent=U)}return It(oe.afterSanitizeElements,m,null),!1},Yl=function(m,T,E){if(xr[T]||Ue(T,m)||Ce&&(T==="id"||T==="name")&&(E in n||E in _i))return!1;let F=ie[T]||Ve.attributeCheck instanceof Function&&Ve.attributeCheck(T,m);return mn&&qe(L,T)||kr&&qe(W,T)?!0:F?St[T]||qe(wt,di(E,ge,""))||(T==="src"||T==="xlink:href"||T==="href")&&m!=="script"&&$f(E,"data:")===0&&nt[m]||_r&&!qe(te,di(E,ge,""))?!0:!E:Zl(m)&&Ci(Ke.tagNameCheck,m)&&Ci(Ke.attributeNameCheck,T,m)||T==="is"&&Ke.allowCustomizedBuiltInElements&&Ci(Ke.tagNameCheck,E)},Bm=ae({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zl=function(m){return!Bm[pi(m)]&&qe(Fe,m)},Km=function(m,T,E,F){if(P&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!E)switch(d.getAttributeType(m,T)){case"TrustedHTML":return X(F);case"TrustedScriptURL":return se(F)}return F},Vm=function(m,T,E,F){try{E?m.setAttributeNS(E,T,F):m.setAttribute(T,F),Ai(m)?k(m):Of(t.removed)}catch{Q(T,m)}},Xl=function(m){It(oe.beforeSanitizeAttributes,m,null);let T=m.attributes;if(!T||Ai(m))return;ie=Vl(oe.uponSanitizeAttribute,ie,Tt,Vn);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ie,forceKeepAttr:void 0},F=T.length,U=ye(m.nodeName);for(;F--;){let Y=T[F],me=Y.name,xe=Y.namespaceURI,rt=Y.value,it=ye(me),ho=rt,Ze=me==="value"?ho:U0(ho);if(E.attrName=it,E.attrValue=Ze,E.keepAttr=!0,E.forceKeepAttr=void 0,It(oe.uponSanitizeAttribute,m,E),Ze=E.attrValue,zt&&(it==="id"||it==="name")&&$f(Ze,Xt)!==0&&(Q(me,m,Y),Ze=Xt+Ze),$t&&qe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ze)){Q(me,m,Y);continue}if(it==="attributename"&&Ff(Ze,"href")){Q(me,m,Y);continue}if(!E.forceKeepAttr){if(!E.keepAttr){Q(me,m,Y);continue}if(!Tr&&qe(l_,Ze)){Q(me,m,Y);continue}if(Pt&&(Ze=Yn(Ze)),!Yl(U,it,Ze)){Q(me,m,Y);continue}Ze=Km(U,it,xe,Ze),Ze!==ho&&Vm(m,me,xe,Ze)}}It(oe.afterSanitizeAttributes,m,null)},Li=function(m){let T=null,E=Pr(m);for(It(oe.beforeSanitizeShadowDOM,m,null);T=E.nextNode();)if(It(oe.uponSanitizeShadowNode,T,null),ql(T,m),Xl(T),Zn(T.content)&&Li(T.content),N(T)===gt.element){let F=b(T);Zn(F)&&(uo(F),Li(F))}It(oe.afterSanitizeShadowDOM,m,null)},uo=function(m){let T=[{node:m,shadow:null}];for(;T.length>0;){let E=T.pop();if(E.shadow){Li(E.shadow);continue}let F=E.node,Y=N(F)===gt.element,me=v(F);if(me)for(let xe=me.length-1;xe>=0;--xe)T.push({node:me[xe],shadow:null});if(Y){let xe=C?C(F):null;if(typeof xe=="string"&&ye(xe)==="template"){let rt=F.content;Zn(rt)&&T.push({node:rt,shadow:null})}}if(Y){let xe=b(F);Zn(xe)&&T.push({node:null,shadow:xe},{node:xe,shadow:null})}}};return t.sanitize=function(D){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,E=null,F=null,U=null;if(Er=!D,Er&&(D="<!-->"),typeof D!="string"&&!Dr(D)&&(D=q0(D),typeof D!="string"))throw Un("dirty is not a string, aborting");if(!t.isSupported)return D;vn?(pe=Dt,ie=Vn):Cr(m),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(pe=mt(pe)),oe.uponSanitizeAttribute.length>0&&(ie=mt(ie)),t.removed=[];let Y=Sr&&typeof D!="string"&&Dr(D);if(Y){rn(D);let rt=j(D);if(typeof rt=="string"){let it=ye(rt);if(!pe[it]||gn[it])throw B(D),Un("root node is forbidden and cannot be sanitized in-place")}if(Ai(D))throw B(D),Un("root node is clobbered and cannot be sanitized in-place");try{uo(D)}catch(it){throw B(D),it}}else if(Dr(D))T=Nr("<!---->"),E=T.ownerDocument.importNode(D,!0),E.nodeType===gt.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?T=E:T.appendChild(E),uo(E);else{if(!Ee&&!Pt&&!et&&D.indexOf("<")===-1)return P&&wn?X(D):D;if(T=Nr(D),!T)return Ee?null:wn?R:""}T&&yt&&k(T.firstChild);let me=Y?D:T;try{let rt=Pr(me);for(;F=rt.nextNode();)ql(F,me),Xl(F),Zn(F.content)&&Li(F.content)}catch(rt){throw Y&&(B(D),Bn(t.removed,it=>{it.element&&ee(it.element)})),rt}if(Y)return Bn(t.removed,rt=>{rt.element&&ee(rt.element)}),Pt&&co(D),D;if(Ee){if(Pt&&co(T),$e)for(U=Te.call(T.ownerDocument);T.firstChild;)U.appendChild(T.firstChild);else U=T;return(ie.shadowroot||ie.shadowrootmode)&&(U=Pe.call(r,U,!0)),U}let xe=et?T.outerHTML:T.innerHTML;return et&&pe["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&qe(a_,T.ownerDocument.doctype.name)&&(xe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
411
- `+xe),Pt&&(xe=Yn(xe)),P&&wn?X(xe):xe},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cr(D),vn=!0,Dt=pe,Vn=ie},t.clearConfig=function(){nn=null,vn=!1,Dt=null,Vn=null,P=H,R=""},t.isValidAttribute=function(D,m,T){nn||Cr({});let E=ye(D),F=ye(m);return Yl(E,F,T)},t.addHook=function(D,m){typeof m=="function"&&lt(oe,D)&&ui(oe[D],m)},t.removeHook=function(D,m){if(lt(oe,D)){if(m!==void 0){let T=H0(oe[D],m);return T===-1?void 0:W0(oe[D],T,1)[0]}return Of(oe[D])}},t.removeHooks=function(D){lt(oe,D)&&(oe[D]=[])},t.removeAllHooks=function(){oe=Yf()},t}var Rl=Jf();function Va(e=Date.now){let t=new Map,n=new Map,r=new Set,i=0,a=()=>r.forEach(s=>s()),o=s=>s.body!==s.baseline||s.raw!==s.rawBaseline;return{get:s=>t.get(s)??null,subscribe(s){return r.add(s),()=>r.delete(s)},open(s,l){if(t.has(s))return;let{head:c,tail:u}=nr(l),{entries:d}=$r(u);t.set(s,{body:c,baseline:c,tail:u,raw:d,rawBaseline:d,saving:!1,original:c,originalRaw:d,savedAt:null,failed:!1}),a()},edit(s,l){let c=t.get(s);c===void 0||c.body===l||(c.body=l,c.failed=!1,a())},editRaw(s,l){let c=t.get(s);c===void 0||c.raw===l||(c.raw=l,c.failed=!1,a())},syncTail(s,l){let c=t.get(s);if(c===void 0||c.saving||c.raw!==c.rawBaseline)return;let{tail:u}=nr(l);if(u===c.tail)return;let{entries:d}=$r(u);c.originalRaw===c.rawBaseline?c.originalRaw=d:d.startsWith(c.rawBaseline)&&(c.originalRaw+=d.slice(c.rawBaseline.length)),c.tail=u,c.raw=d,c.rawBaseline=d,a()},discard(s){t.delete(s)&&a()},isDirty(s){let l=t.get(s);return l!==void 0&&o(l)},dirtySlugs(){return[...t].filter(([,s])=>o(s)).map(([s])=>s)},revert(s){let l=t.get(s);return l===void 0?!1:(l.body=l.original,l.raw=l.originalRaw,a(),o(l))},async save(s,l,c){let u=t.get(s);if(u===void 0||u.saving||n.get(s)?.saving)return;let d=u.body,h=u.raw,f=h!==u.rawBaseline,g=f?Ko($r(u.tail).opening,h):u.tail,w=Bo(d,g);u.saving=!0,a();let v=!1;try{let y={...f?{raw:!0}:{},...c?.keepOpen?{quiet:!0}:{}};v=await l(s,w,Object.keys(y).length===0?void 0:y)}finally{if(t.get(s)===u){let y=n.get(s);v&&y!==void 0&&(y.body=w,y.version=++i,delete y.pending),v&&!c?.keepOpen&&u.body===d&&u.raw===h?t.delete(s):(v&&(u.baseline=d,u.rawBaseline=h,u.tail=g,u.savedAt=e()),u.failed=!v,u.saving=!1),a()}}},nextLoadVersion(){return++i},getTaskBody(s,l){return n.get(s)?.body??l},taskBody(s,l,c){let u=n.get(s),d=!1;return u===void 0?(u={body:l,version:c,saving:!1},n.set(s,u)):c>u.version&&(u.saving?(u.pending===void 0||c>u.pending.version)&&(u.pending={body:l,version:c}):(d=u.body!==l,u.body=l,u.version=c)),d&&a(),u.body},isTaskSaving:s=>n.get(s)?.saving??!1,async saveTask(s,l,c){let u=n.get(s);if(u===void 0||u.saving||t.get(s)?.saving)return!1;u.saving=!0,a();let d=!1;try{return d=await c(s,l),d}finally{n.get(s)===u&&(d?(u.body=l,u.version=++i):u.pending!==void 0&&u.pending.version>u.version&&(u.body=u.pending.body,u.version=u.pending.version),delete u.pending,u.saving=!1,a())}},clearTaskSources(s){let l=!1;for(let c of s)l=n.delete(c)||l;l&&a()}}}function eg(e,t,n,r){let i=new Set(t.panes.flatMap(s=>s.tabs.map(Mt))),a=new Set(n.panes.flatMap(s=>s.tabs.map(Mt))),o=[...i].filter(s=>s!==null&&s.startsWith("note:")&&!a.has(s)).map(s=>s.slice(5));return o.some(s=>e.isDirty(s))&&!r()?!1:(o.forEach(s=>e.discard(s)),e.clearTaskSources(o),!0)}function tg(e,t,n){let r=new Set(t);return e.dirtySlugs().filter(a=>r.has(a)).length>0&&!n()?!1:(r.forEach(a=>e.discard(a)),e.clearTaskSources([...r]),!0)}var fi="",ja="",ng=900;function Cl(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;let i=0;for(;i<n-r&&e.charCodeAt(e.length-1-i)===t.charCodeAt(t.length-1-i);)i++;return{start:r,end:t.length-i,removed:e.length-i-r}}var p_=/^[ \t]*(?:#{1,6}[ \t]+|>[ \t]?|(?:[*+-]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)*/,f_=/^[ \t]*(?:`{3,}|~{3,}|<!--|(?:[-*_][ \t]*){3,}$)/,g_=/!?\[\[[^\]\n]*\]\]|!?\[[^\]\n]*\]\([^)\n]*\)|<[a-z][a-z0-9+.-]*:[^>\s]*>/gi;function m_(e,t){let{start:n,end:r}=Cl(e??"",t);if(n>=r)return t;let i=[],a=t.lastIndexOf(`
408
+ `,Qx=Xx,Up=WebGLRenderingContext,Cp=Up.UNSIGNED_BYTE,ri=Up.FLOAT,Jx=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Bp=(function(e){function t(){return Ie(this,t),Qe(this,t,arguments)}return Je(t,e),Me(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Qx,FRAGMENT_SHADER_SOURCE:$p,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Jx,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ri},{name:"a_positionEnd",size:2,type:ri},{name:"a_normal",size:2,type:ri},{name:"a_color",size:4,type:Cp,normalized:!0},{name:"a_id",size:4,type:Cp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ri},{name:"a_normalCoef",size:1,type:ri}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,a,o,s){var l=s.size||1,c=a.x,u=a.y,d=o.x,h=o.y,f=dr(s.color),g=d-c,w=h-u,v=g*g+w*w,y=0,b=0;v&&(v=1/Math.sqrt(v),y=-w*v*l,b=g*v*l);var _=this.array;_[i++]=c,_[i++]=u,_[i++]=d,_[i++]=h,_[i++]=y,_[i++]=b,_[i++]=f,_[i++]=r}},{key:"setUniforms",value:function(r,i){var a=i.gl,o=i.uniformLocations,s=o.u_matrix,l=o.u_zoomRatio,c=o.u_feather,u=o.u_pixelRatio,d=o.u_correctionRatio,h=o.u_sizeRatio,f=o.u_minEdgeThickness;a.uniformMatrix3fv(s,!1,r.matrix),a.uniform1f(l,r.zoomRatio),a.uniform1f(h,r.sizeRatio),a.uniform1f(d,r.correctionRatio),a.uniform1f(u,r.pixelRatio),a.uniform1f(c,r.antiAliasingFeather),a.uniform1f(f,r.minEdgeThickness)}}])})(ol);var tf=Ir(Ra()),Aa=(function(e){function t(){var n;return Ie(this,t),n=Qe(this,t),n.rawEmitter=n,n}return Je(t,e),Me(t)})(tf.EventEmitter);var of=Ir(cl());var ok=function(t){return t},sk=function(t){return t*t},lk=function(t){return t*(2-t)},ck=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},uk=function(t){return t*t*t},dk=function(t){return--t*t*t+1},hk=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},sf={linear:ok,quadraticIn:sk,quadraticOut:lk,quadraticInOut:ck,cubicIn:uk,cubicOut:dk,cubicInOut:hk},lf={easing:"quadraticInOut",duration:150};function bt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ca(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function rf(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 af(e,t,n){return e[6]=t,e[7]=n,e}function fn(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],d=t[0],h=t[1],f=t[2],g=t[3],w=t[4],v=t[5],y=t[6],b=t[7],_=t[8];return e[0]=d*n+h*a+f*l,e[1]=d*r+h*o+f*c,e[2]=d*i+h*s+f*u,e[3]=g*n+w*a+v*l,e[4]=g*r+w*o+v*c,e[5]=g*i+w*s+v*u,e[6]=y*n+b*a+_*l,e[7]=y*r+b*o+_*c,e[8]=y*i+b*s+_*u,e}function La(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],a=e[3],o=e[4],s=e[6],l=e[7],c=t.x,u=t.y;return{x:c*r+u*a+s*n,y:c*i+u*o+l*n}}function pk(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 pr(e,t,n,r,i){var a=e.angle,o=e.ratio,s=e.x,l=e.y,c=t.width,u=t.height,d=bt(),h=Math.min(c,u)-2*r,f=pk(t,n);return i?(fn(d,af(bt(),s,l)),fn(d,Ca(bt(),o)),fn(d,rf(bt(),a)),fn(d,Ca(bt(),c/h/2/f,u/h/2/f))):(fn(d,Ca(bt(),2*(h/c)*f,2*(h/u)*f)),fn(d,rf(bt(),-a)),fn(d,Ca(bt(),1/o)),fn(d,af(bt(),-s,-l))),d}function cf(e,t,n){var r=La(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,a=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(a,2))/n.width}function uf(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(a,o){var s=o.x,l=o.y;s<t&&(t=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[t,n],y:[r,i]}}function df(e){if(!(0,of.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 hf(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var a in n)r.setAttribute(a,n[a]);return r}function ul(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function dl(e,t,n){return n.sort(function(r,i){var a=t(r)||0,o=t(i)||0;return a<o?-1:a>o?1:0})}function hl(e){var t=pn(e.x,2),n=t[0],r=t[1],i=pn(e.y,2),a=i[0],o=i[1],s=Math.max(r-n,o-a),l=(r+n)/2,c=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(c)&&(c=0);var u=function(h){return{x:.5+(h.x-l)/s,y:.5+(h.y-c)/s}};return u.applyTo=function(d){d.x=.5+(d.x-l)/s,d.y=.5+(d.y-c)/s},u.inverse=function(d){return{x:l+s*(d.x-.5),y:c+s*(d.y-.5)}},u.ratio=s,u}function Na(e){"@babel/helpers - typeof";return Na=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},Na(e)}function pl(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(a){e[r+i]=a,i++})}}function Pa(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 Da={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:Dp,defaultDrawNodeLabel:sl,defaultDrawNodeHover:Ip,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:{}},fk={circle:ii},gk={arrow:Wp,line:Bp};function Ia(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 pf(e){var t=Pa({},Da,e);return t.nodeProgramClasses=Pa({},fk,t.nodeProgramClasses),t.edgeProgramClasses=Pa({},gk,t.edgeProgramClasses),t}var CR=Ir(Ra()),LR=Ir(cl()),Ma=1.5,ff=(function(e){function t(){var n;return Ie(this,t),n=Qe(this,t),C(n,"x",.5),C(n,"y",.5),C(n,"angle",0),C(n,"ratio",1),C(n,"minRatio",null),C(n,"maxRatio",null),C(n,"enabledZooming",!0),C(n,"enabledPanning",!0),C(n,"enabledRotation",!0),C(n,"clean",null),C(n,"nextFrame",null),C(n,"previousState",null),C(n,"enabled",!0),n.previousState=n.getState(),n}return Je(t,e),Me(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(z(z({},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,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(!o)return new Promise(function(f){return i.animate(r,a,f)});if(this.enabled){var s=z(z({},lf),a),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:sf[s.easing],u=Date.now(),d=this.getState(),h=function(){var g=(Date.now()-u)/s.duration;if(g>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=c(g),v={};typeof l.x=="number"&&(v.x=d.x+(l.x-d.x)*w),typeof l.y=="number"&&(v.y=d.y+(l.y-d.y)*w),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=d.angle+(l.angle-d.angle)*w),typeof l.ratio=="number"&&(v.ratio=d.ratio+(l.ratio-d.ratio)*w),i.setState(v),i.nextFrame=requestAnimationFrame(h)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(h)):h(),this.animationCallback=o}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Ma)},r):this.animate({ratio:this.ratio/Ma})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Ma)},r):this.animate({ratio:this.ratio*Ma})}},{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)}}])})(Aa);function At(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function qt(e,t){var n=z(z({},At(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function ai(e){var t="x"in e?e:z(z({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function mk(e,t){return z(z({},qt(e,t)),{},{delta:bf(e)})}var vk=2;function Ga(e){for(var t=[],n=0,r=Math.min(e.length,vk);n<r;n++)t.push(e[n]);return t}function oi(e,t,n){var r={touches:Ga(e.touches).map(function(i){return At(i,n)}),previousTouches:t.map(function(i){return At(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function bf(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 xf=(function(e){function t(n,r){var i;return Ie(this,t),i=Qe(this,t),i.container=n,i.renderer=r,i}return Je(t,e),Me(t)})(Aa),wk=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],yk=wk.reduce(function(e,t){return z(z({},e),{},C({},t,Da[t]))},{}),bk=(function(e){function t(n,r){var i;return Ie(this,t),i=Qe(this,t,[n,r]),C(i,"enabled",!0),C(i,"draggedEvents",0),C(i,"downStartTime",null),C(i,"lastMouseX",null),C(i,"lastMouseY",null),C(i,"isMouseDown",!1),C(i,"isMoving",!1),C(i,"movingTimeout",null),C(i,"startCameraState",null),C(i,"clicks",0),C(i,"doubleClickTimeout",null),C(i,"currentWheelDirection",0),C(i,"settings",yk),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 Je(t,e),Me(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",qt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",qt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=qt(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var a=this.renderer.getCamera(),o=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(At(r,this.container),o),{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=At(r,this.container),a=i.x,o=i.y;this.lastMouseX=a,this.lastMouseY=o,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",qt(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var a=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var o=At(r,this.container),s=o.x,l=o.y,c=a.getState(),u=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:c.x+this.settings.inertiaRatio*(c.x-u.x),y:c.y+this.settings.inertiaRatio*(c.y-u.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&a.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",qt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var a=qt(r,this.container);if(this.emit("mousemovebody",a),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",a),!a.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 o=this.renderer.getCamera(),s=At(r,this.container),l=s.x,c=s.y,u=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:l,y:c}),h=u.x-d.x,f=u.y-d.y,g=o.getState(),w=g.x+h,v=g.y+f;o.setState({x:w,y:v}),this.lastMouseX=l,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",qt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",qt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var o=bf(r);if(o){var s=mk(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=a.getState().ratio,c=o>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,u=a.getBoundedRatio(l*c),d=o>0?1:-1,h=Date.now();l!==u&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&h-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(At(r,this.container),u),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=h))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(xf),xk=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],kk=xk.reduce(function(e,t){return z(z({},e),{},C({},t,Da[t]))},{}),_k=(function(e){function t(n,r){var i;return Ie(this,t),i=Qe(this,t,[n,r]),C(i,"enabled",!0),C(i,"isMoving",!1),C(i,"hasMoved",!1),C(i,"touchMode",0),C(i,"startTouchesPositions",[]),C(i,"lastTouches",[]),C(i,"lastTap",null),C(i,"settings",kk),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 Je(t,e),Me(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 a=Ga(r.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(f){return At(f,i.container)}),this.touchMode===2){var o=pn(this.startTouchesPositions,2),s=o[0],l=s.x,c=s.y,u=o[1],d=u.x,h=u.y;this.startTouchesAngle=Math.atan2(h-c,d-l),this.startTouchesDistance=Math.sqrt(Math.pow(d-l,2)+Math.pow(h-c,2))}this.emit("touchdown",oi(r,this.lastTouches,this.container)),this.lastTouches=a,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(),a=i.getState(),o=i.getPreviousState()||{x:0,y:0};i.animate({x:a.x+this.settings.inertiaRatio*(a.x-o.x),y:a.y+this.settings.inertiaRatio*(a.y-o.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",oi(r,this.lastTouches,this.container)),!r.touches.length){var s=At(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],c=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var u=oi(r,this.lastTouches,this.container);if(this.emit("doubletap",u),this.lastTap=null,!u.sigmaDefaultPrevented){var d=this.renderer.getCamera(),h=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(s,h),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=oi(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Ga(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var a=Ga(r.touches),o=a.map(function(Te){return At(Te,i.container)}),s=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=o;var l=oi(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=o.some(function(Te,ct){var Pe=i.startTouchesPositions[ct];return Pe&&(Te.x!==Pe.x||Te.y!==Pe.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),u=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var h=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=h.x,g=h.y,w=this.renderer.viewportToFramedGraph(o[0]),v=w.x,y=w.y;c.setState({x:u.x+f-v,y:u.y+g-y});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},_=o[0],x=_.x,R=_.y,O=o[1],N=O.x,j=O.y,P=Math.atan2(j-R,N-x)-this.startTouchesAngle,A=Math.hypot(j-R,N-x)/this.startTouchesDistance,H=c.getBoundedRatio(u.ratio/A);b.ratio=H,b.angle=u.angle+P;var Z=this.getDimensions(),G=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),J=Math.min(Z.width,Z.height)-2*d,X=J/Z.width,se=J/Z.height,Ye=H/J,Ae=x-J/2/X,ye=R-J/2/se,ue=[Ae*Math.cos(-b.angle)-ye*Math.sin(-b.angle),ye*Math.cos(-b.angle)+Ae*Math.sin(-b.angle)];Ae=ue[0],ye=ue[1],b.x=G.x-Ae*Ye,b.y=G.y+ye*Ye,c.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(xf);function Tk(e){if(Array.isArray(e))return _a(e)}function Sk(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Ek(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
409
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gf(e){return Tk(e)||Sk(e)||Js(e)||Ek()}function Rk(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 fl(e,t){if(e==null)return{};var n,r,i=Rk(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var mf=(function(){function e(t,n){Ie(this,e),this.key=t,this.size=n}return Me(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),vf=(function(){function e(){Ie(this,e),C(this,"width",0),C(this,"height",0),C(this,"cellSize",0),C(this,"columns",0),C(this,"rows",0),C(this,"cells",{})}return Me(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 a=new mf(n,r),o=this.getIndex(i),s=this.cells[o];s||(s=[],this.cells[o]=s),s.push(a)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(mf.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,a=i/n/n,o=a*r/i,s=Math.ceil(o),l=[];for(var c in this.cells)for(var u=this.cells[c],d=0;d<Math.min(s,u.length);d++)l.push(u[d].key);return l}}])})();function Ak(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,a=[];return t.forEachEdge(function(o,s,l,c){(l===n||c===n||r.has(l)||r.has(c)||i.has(l)&&i.has(c))&&a.push(o)}),a}var wf=150,yf=50,Yt=Object.prototype.hasOwnProperty;function Ck(e,t,n){if(!Yt.call(n,"x")||!Yt.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),Yt.call(n,"hidden")||(n.hidden=!1),Yt.call(n,"highlighted")||(n.highlighted=!1),Yt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Lk(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Yt.call(n,"hidden")||(n.hidden=!1),Yt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Nk=(function(e){function t(n,r){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Ie(this,t),i=Qe(this,t),C(i,"elements",{}),C(i,"canvasContexts",{}),C(i,"webGLContexts",{}),C(i,"pickingLayers",new Set),C(i,"textures",{}),C(i,"frameBuffers",{}),C(i,"activeListeners",{}),C(i,"labelGrid",new vf),C(i,"nodeDataCache",{}),C(i,"edgeDataCache",{}),C(i,"nodeProgramIndex",{}),C(i,"edgeProgramIndex",{}),C(i,"nodesWithForcedLabels",new Set),C(i,"edgesWithForcedLabels",new Set),C(i,"nodeExtent",{x:[0,1],y:[0,1]}),C(i,"nodeZExtent",[1/0,-1/0]),C(i,"edgeZExtent",[1/0,-1/0]),C(i,"matrix",bt()),C(i,"invMatrix",bt()),C(i,"correctionRatio",1),C(i,"customBBox",null),C(i,"normalizationFunction",hl({x:[0,1],y:[0,1]})),C(i,"graphToViewportRatio",1),C(i,"itemIDsIndex",{}),C(i,"nodeIndices",{}),C(i,"edgeIndices",{}),C(i,"width",0),C(i,"height",0),C(i,"pixelRatio",ul()),C(i,"pickingDownSizingRatio",2*i.pixelRatio),C(i,"displayedNodeLabels",new Set),C(i,"displayedEdgeLabels",new Set),C(i,"highlightedNodes",new Set),C(i,"hoveredNode",null),C(i,"hoveredEdge",null),C(i,"renderFrame",null),C(i,"renderHighlightedNodesFrame",null),C(i,"needToProcess",!1),C(i,"checkEdgesEventsFrame",null),C(i,"nodePrograms",{}),C(i,"nodeHoverPrograms",{}),C(i,"edgePrograms",{}),i.settings=pf(a),Ia(i.settings),df(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:a.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 o in i.settings.nodeProgramClasses)i.registerNodeProgram(o,i.settings.nodeProgramClasses[o],i.settings.nodeHoverProgramClasses[o]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new ff,i.bindCameraHandlers(),i.mouseCaptor=new bk(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new _k(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Je(t,e),Me(t,[{key:"registerNodeProgram",value:function(r,i,a){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(a||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,a=i[r],o=fl(i,[r].map(Hn));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=fl(s,[r].map(Hn));l.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,a=i[r],o=fl(i,[r].map(Hn));a.kill(),this.edgePrograms=o}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],a=this.frameBuffers[r],o=this.textures[r];o&&i.deleteTexture(o);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),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,a=r.y,o=nl(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),s=tl.apply(void 0,gf(o)),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(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}},l=r.getNodeAtPosition(o);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",z(z({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",z(z({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(o)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",z(z({},s),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var u=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);u!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",z(z({},s),{},{edge:r.hoveredEdge})),u&&r.emit("enterEdge",z(z({},s),{},{edge:u})),r.hoveredEdge=u)}},this.activeListeners.handleMoveBody=function(a){var o=ai(a);r.emit("moveBody",{event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",z(z({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",z(z({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",z({},s))},this.activeListeners.handleEnter=function(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};r.emit("enterStage",z({},s))};var i=function(o){return function(s){var l=ai(s),c={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},u=r.getNodeAtPosition(l);if(u)return r.emit("".concat(o,"Node"),z(z({},c),{},{node:u}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(l.x,l.y);if(d)return r.emit("".concat(o,"Edge"),z(z({},c),{},{edge:d}))}return r.emit("".concat(o,"Stage"),c)}};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,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(o){var s,l=(s=o.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(u){return r.updateNode(u)});var c=!l||l.some(function(u){return a.has(u)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(o){var s,l=(s=o.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(u){return r.updateEdge(u)});var c=l&&["zIndex","type"].some(function(u){return l?.includes(u)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(o){var s=o.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(o){var s=o.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(o){var s=o.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(o){var s=o.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(o){var s=o.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(o){var s=o.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 a=nl(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),o=tl.apply(void 0,gf(a)),s=this.itemIDsIndex[o];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,o=this.getDimensions();if(this.nodeExtent=uf(this.graph),!this.settings.autoRescale){var s=o.width,l=o.height,c=this.nodeExtent,u=c.x,d=c.y;this.nodeExtent={x:[(u[0]+u[1])/2-s/2,(u[0]+u[1])/2+s/2],y:[(d[0]+d[1])/2-l/2,(d[0]+d[1])/2+l/2]}}this.normalizationFunction=hl(this.customBBox||this.nodeExtent);var h=new ff,f=pr(h.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var g={},w={},v={},y={},b=1,_=i.nodes(),x=0,R=_.length;x<R;x++){var O=_[x],N=this.nodeDataCache[O],j=i.getNodeAttributes(O);N.x=j.x,N.y=j.y,this.normalizationFunction.applyTo(N),typeof N.label=="string"&&!N.hidden&&this.labelGrid.add(O,N.size,this.framedGraphToViewport(N,{matrix:f})),g[N.type]=(g[N.type]||0)+1}this.labelGrid.organize();for(var P in this.nodePrograms){if(!Yt.call(this.nodePrograms,P))throw new Error('Sigma: could not find a suitable program for node type "'.concat(P,'"!'));this.nodePrograms[P].reallocate(g[P]||0),g[P]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=dl(this.nodeZExtent,function(Se){return r.nodeDataCache[Se].zIndex},_));for(var A=0,H=_.length;A<H;A++){var Z=_[A];w[Z]=b,y[w[Z]]={type:"node",id:Z},b++;var G=this.nodeDataCache[Z];this.addNodeToProgram(Z,w[Z],g[G.type]++)}for(var J={},X=i.edges(),se=0,Ye=X.length;se<Ye;se++){var Ae=X[se],ye=this.edgeDataCache[Ae];J[ye.type]=(J[ye.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(X=dl(this.edgeZExtent,function(Se){return r.edgeDataCache[Se].zIndex},X));for(var ue in this.edgePrograms){if(!Yt.call(this.edgePrograms,ue))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ue,'"!'));this.edgePrograms[ue].reallocate(J[ue]||0),J[ue]=0}for(var Te=0,ct=X.length;Te<ct;Te++){var Pe=X[Te];v[Pe]=b,y[v[Pe]]={type:"edge",id:Pe},b++;var oe=this.edgeDataCache[Pe];this.addEdgeToProgram(Pe,v[Pe],J[oe.type]++)}return this.itemIDsIndex=y,this.nodeIndices=w,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(u){return i.cleanCameraState(u,a.cameraPanBoundaries&&Na(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==a.edgeProgramClasses){for(var o in a.edgeProgramClasses)a.edgeProgramClasses[o]!==r.edgeProgramClasses[o]&&this.registerEdgeProgram(o,a.edgeProgramClasses[o]);for(var s in r.edgeProgramClasses)a.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==a.nodeProgramClasses||r.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var l in a.nodeProgramClasses)(a.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||a.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,a.nodeProgramClasses[l],a.nodeHoverProgramClasses[l]);for(var c in r.nodeProgramClasses)a.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}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]:{},a=i.tolerance,o=a===void 0?0:a,s=i.boundaries,l=z({},r),c=s||this.nodeExtent,u=pn(c.x,2),d=u[0],h=u[1],f=pn(c.y,2),g=f[0],w=f[1],v=[this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:w},{cameraState:r}),this.graphToViewport({x:h,y:w},{cameraState:r})],y=1/0,b=-1/0,_=1/0,x=-1/0;v.forEach(function(J){var X=J.x,se=J.y;y=Math.min(y,X),b=Math.max(b,X),_=Math.min(_,se),x=Math.max(x,se)});var R=b-y,O=x-_,N=this.getDimensions(),j=N.width,P=N.height,A=0,H=0;if(R>=j?b<j-o?A=b-(j-o):y>o&&(A=y-o):b>j+o?A=b-(j+o):y<-o&&(A=y+o),O>=P?x<P-o?H=x-(P-o):_>o&&(H=_-o):x>P+o?H=x-(P+o):_<-o&&(H=_+o),A||H){var Z=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),G=this.viewportToFramedGraph({x:A,y:H},{cameraState:r});A=G.x-Z.x,H=G.y-Z.y,l.x+=A,l.y+=H}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);pl(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,o=0,s=i.length;o<s;o++){var l=i[o],c=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!c.hidden){var u=this.framedGraphToViewport(c),d=u.x,h=u.y,f=this.scaleSize(c.size);if(!(!c.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-wf||d>this.width+wf||h<-yf||h>this.height+yf)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[c.type],v=w?.drawLabel||g;v(a,z(z({key:l},c),{},{size:f,x:d,y:h}),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=Ak({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});pl(i,this.edgesWithForcedLabels);for(var a=new Set,o=0,s=i.length;o<s;o++){var l=i[o],c=this.graph.extremities(l),u=this.nodeDataCache[c[0]],d=this.nodeDataCache[c[1]],h=this.edgeDataCache[l];if(!a.has(l)&&!(h.hidden||u.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[h.type],w=g?.drawLabel||f;w(r,z(z({key:l},h),{},{size:this.scaleSize(h.size)}),z(z(z({key:c[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),z(z(z({key:c[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),a.add(l)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(f){var g=r.nodeDataCache[f],w=r.framedGraphToViewport(g),v=w.x,y=w.y,b=r.scaleSize(g.size),_=r.settings.defaultDrawNodeHover,x=r.nodePrograms[g.type],R=x?.drawHover||_;R(i,z(z({key:f},g),{},{size:b,x:v,y}),r.settings)},o=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&o.push(this.hoveredNode),this.highlightedNodes.forEach(function(h){h!==r.hoveredNode&&o.push(h)}),o.forEach(function(h){return a(h)});var s={};o.forEach(function(h){var f=r.nodeDataCache[h].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;o.forEach(function(h){var f=r.nodeDataCache[h];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var u in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[u];d.render(c)}}},{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 a=this.mouseCaptor,o=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),c=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=pr(s,l,c,u),this.invMatrix=pr(s,l,c,u,!0),this.correctionRatio=cf(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var h in this.nodePrograms){var f=this.nodePrograms[h];f.render(d)}if(!this.settings.hideEdgesOnMove||!o)for(var g in this.edgePrograms){var w=this.edgePrograms[g];w.render(d)}return this.settings.hideLabelsOnMove&&o||(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 a=Ck(this.settings,r,i);this.nodeDataCache[r]=a,this.nodesWithForcedLabels.delete(r),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),a.highlighted&&!a.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.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 a=Lk(this.settings,r,i);this.edgeDataCache[r]=a,this.edgesWithForcedLabels.delete(r),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.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 vf,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,a){var o=this.nodeDataCache[r],s=this.nodePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(o.type,'"!'));s.process(i,a,o),this.nodeProgramIndex[r]=a}},{key:"addEdgeToProgram",value:function(r,i,a){var o=this.edgeDataCache[r],s=this.edgePrograms[o.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(o.type,'"!'));var l=this.graph.extremities(r),c=this.nodeDataCache[l[0]],u=this.nodeDataCache[l[1]];s.process(i,a,c,u,o),this.edgeProgramIndex[r]=a}},{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,a=r.autoRescale;return a&&i||0}},{key:"createLayer",value:function(r,i){var a=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 o=hf(i,{position:"absolute"},{class:"sigma-".concat(r)});return a.style&&Object.assign(o.style,a.style),this.elements[r]=o,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(o):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(o):this.container.appendChild(o),o}},{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]:{},a=this.createCanvas(r,i),o={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=a.getContext("2d",o),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i?.canvas||this.createCanvas(r,i);i.hidden&&a.remove();var o=z({preserveDrawingBuffer:!1,antialias:!1},i),s;s=a.getContext("webgl2",o),s||(s=a.getContext("webgl",o)),s||(s=a.getContext("experimental-webgl",o));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var c=l.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}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 a,o=this.webGLContexts[r];(a=o.getExtension("WEBGL_lose_context"))===null||a===void 0||a.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 z({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var a=z({},this.settings);return this.settings[r]=i,Ia(this.settings),this.handleSettingsUpdate(a),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=z({},this.settings);return this.settings=z(z({},this.settings),r),Ia(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=ul(),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&&a===this.height)return this;for(var o in this.elements){var s=this.elements[o];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 c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var u=this.webGLContexts[c];if(u.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var d=this.textures[c];d&&u.deleteTexture(d)}}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,a=r?.skipIndexation!==void 0?r?.skipIndexation:!1,o=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(x){return i.addNode(x)}),this.graph.forEachEdge(function(x){return i.addEdge(x)});else{for(var l,c,u=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],d=0,h=u?.length||0;d<h;d++){var f=u[d];if(this.updateNode(f),a){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 w=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],v=0,y=w.length;v<y;v++){var b=w[v];if(this.updateEdge(b),a){var _=this.edgeProgramIndex[b];if(_===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],_)}}}return(s||!a)&&(this.needToProcess=!0),o?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(z(z({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var a=this.camera.getState(),o=a.ratio,s=a.angle,l=a.x,c=a.y,u=this.settings,d=u.minCameraRatio,h=u.maxCameraRatio;typeof h=="number"&&(i=Math.min(i,h)),typeof d=="number"&&(i=Math.max(i,d));var f=i/o,g={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(w.x-v.x)*(1-f)+l,y:(w.y-v.y)*(1-f)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,o=i.matrix?i.matrix:a?pr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=La(o,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]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,o=i.matrix?i.matrix:a?pr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=La(o,{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},a=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),o=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2));return l/a}},{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 a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var o in this.edgePrograms)this.edgePrograms[o].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}}])})(Aa),kf=Nk;var Ef=Ir(Ra(),1);function Pk(){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 Ge=Pk;typeof Object.assign=="function"&&(Ge=Object.assign);function kt(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(r==="mixed"?a=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?a=i.out&&i.out[n]:a=i.undirected&&i.undirected[n]),a}function Be(e){return typeof e=="object"&&e!==null}function Rf(e){let t;for(t in e)return!1;return!0}function xt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Ct(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 _f(e){return!(!Be(e)||e.attributes&&!Array.isArray(e.attributes))}function Dk(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Zt(){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 gr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var ci=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},$=class e extends ci{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},M=class e extends ci{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},q=class e extends ci{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function Af(e,t){this.key=e,this.attributes=t,this.clear()}Af.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 Cf(e,t){this.key=e,this.attributes=t,this.clear()}Cf.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Lf(e,t){this.key=e,this.attributes=t,this.clear()}Lf.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function mr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}mr.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)};mr.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");let i=this.source[e],a=i[r];if(typeof a>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this};mr.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]};mr.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 Nf=0,Pf=1,Ik=2,Df=3;function Xt(e,t,n,r,i,a,o){let s,l,c,u;if(r=""+r,n===Nf){if(s=e._nodes.get(r),!s)throw new M(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,u=a}else if(n===Df){if(i=""+i,l=e._edges.get(i),!l)throw new M(`Graph.${t}: could not find the "${i}" edge in the graph.`);let d=l.source.key,h=l.target.key;if(r===d)s=l.target;else if(r===h)s=l.source;else throw new M(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${d}, ${h}).`);c=a,u=o}else{if(l=e._edges.get(r),!l)throw new M(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Pf?s=l.source:s=l.target,c=i,u=a}return[s,c,u]}function Mk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Xt(this,t,n,r,i,a);return o.attributes[s]}}function Gk(e,t,n){e.prototype[t]=function(r,i){let[a]=Xt(this,t,n,r,i);return a.attributes}}function Ok(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Xt(this,t,n,r,i,a);return o.attributes.hasOwnProperty(s)}}function Fk(e,t,n){e.prototype[t]=function(r,i,a,o){let[s,l,c]=Xt(this,t,n,r,i,a,o);return s.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function $k(e,t,n){e.prototype[t]=function(r,i,a,o){let[s,l,c]=Xt(this,t,n,r,i,a,o);if(typeof c!="function")throw new $(`Graph.${t}: updater should be a function.`);let u=s.attributes,d=c(u[l]);return u[l]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function zk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Xt(this,t,n,r,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function Hk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Xt(this,t,n,r,i,a);if(!Be(s))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Wk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Xt(this,t,n,r,i,a);if(!Be(s))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return Ge(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Uk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Xt(this,t,n,r,i,a);if(typeof s!="function")throw new $(`Graph.${t}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var Bk=[{name:e=>`get${e}Attribute`,attacher:Mk},{name:e=>`get${e}Attributes`,attacher:Gk},{name:e=>`has${e}Attribute`,attacher:Ok},{name:e=>`set${e}Attribute`,attacher:Fk},{name:e=>`update${e}Attribute`,attacher:$k},{name:e=>`remove${e}Attribute`,attacher:zk},{name:e=>`replace${e}Attributes`,attacher:Hk},{name:e=>`merge${e}Attributes`,attacher:Wk},{name:e=>`update${e}Attributes`,attacher:Uk}];function Kk(e){Bk.forEach(function({name:t,attacher:n}){n(e,t("Node"),Nf),n(e,t("Source"),Pf),n(e,t("Target"),Ik),n(e,t("Opposite"),Df)})}function Vk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]}}function jk(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new q(`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,o=""+arguments[1];if(i=kt(this,a,o,n),!i)throw new M(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function qk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function Yk(e,t,n){e.prototype[t]=function(r,i,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new q(`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],a=arguments[3],o=kt(this,s,l,n),!o)throw new M(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function Zk(e,t,n){e.prototype[t]=function(r,i,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new q(`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],a=arguments[3],o=kt(this,s,l,n),!o)throw new M(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof a!="function")throw new $(`Graph.${t}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function Xk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function Qk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Be(i))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Jk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Be(i))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return Ge(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function e0(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new q(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new q(`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,s=""+i;if(i=arguments[2],a=kt(this,o,s,n),!a)throw new M(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new q(`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 M(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new $(`Graph.${t}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var t0=[{name:e=>`get${e}Attribute`,attacher:Vk},{name:e=>`get${e}Attributes`,attacher:jk},{name:e=>`has${e}Attribute`,attacher:qk},{name:e=>`set${e}Attribute`,attacher:Yk},{name:e=>`update${e}Attribute`,attacher:Zk},{name:e=>`remove${e}Attribute`,attacher:Xk},{name:e=>`replace${e}Attributes`,attacher:Qk},{name:e=>`merge${e}Attributes`,attacher:Jk},{name:e=>`update${e}Attributes`,attacher:e0}];function n0(e){t0.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var r0=[{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 i0(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function a0(e,t,n,r){let i,a,o,s=!1;for(let l in t)if(l!==r){i=t[l];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function gl(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function o0(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function s0(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function ml(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 l0(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",a=e._edges.values(),o=0,s,l;for(;s=a.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[o++]=l.key);return r}function If(e,t,n,r){if(t.size===0)return;let i=n!=="mixed"&&n!==t.type,a=n==="undirected",o,s,l=!1,c=t._edges.values();for(;o=c.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:u,attributes:d,source:h,target:f}=s;if(l=r(u,d,h.key,f.key,h.attributes,f.attributes,s.undirected),e&&l)return u}}function c0(e,t){if(e.size===0)return gr();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(n&&o.undirected!==r))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function vl(e,t,n,r,i,a){let o=t?a0:i0,s;if(n!=="undirected"&&(r!=="out"&&(s=o(e,i.in,a),e&&s)||r!=="in"&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!=="directed"&&(s=o(e,i.undirected,a),e&&s))return s}function u0(e,t,n,r){let i=[];return vl(!1,e,t,n,r,function(a){i.push(a)}),i}function d0(e,t,n){let r=gr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Zt(r,gl(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Zt(r,gl(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Zt(r,gl(n.undirected))),r}function wl(e,t,n,r,i,a,o){let s=n?s0:o0,l;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(e,i.in,a,o),e&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==a)&&(l=s(e,i.out,a,o),e&&l))||t!=="directed"&&typeof i.undirected<"u"&&(l=s(e,i.undirected,a,o),e&&l))return l}function h0(e,t,n,r,i){let a=[];return wl(!1,e,t,n,r,i,function(o){a.push(o)}),a}function p0(e,t,n,r){let i=gr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=Zt(i,ml(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=Zt(i,ml(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=Zt(i,ml(n.undirected,r))),i}function f0(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(a,o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return l0(this,r);if(arguments.length===1){a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new M(`Graph.${n}: could not find the "${a}" node in the graph.`);return u0(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){a=""+a,o=""+o;let s=this._nodes.get(a);if(!s)throw new M(`Graph.${n}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new M(`Graph.${n}: could not find the "${o}" target node in the graph.`);return h0(r,this.multi,i,s,o)}throw new $(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function g0(e,t){let{name:n,type:r,direction:i}=t,a="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(c,u,d){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return d=c,If(!1,this,r,d);if(arguments.length===2){c=""+c,d=u;let h=this._nodes.get(c);if(typeof h>"u")throw new M(`Graph.${a}: could not find the "${c}" node in the graph.`);return vl(!1,this.multi,r==="mixed"?this.type:r,i,h,d)}if(arguments.length===3){c=""+c,u=""+u;let h=this._nodes.get(c);if(!h)throw new M(`Graph.${a}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new M(`Graph.${a}: could not find the "${u}" target node in the graph.`);return wl(!1,r,this.multi,i,h,u,d)}throw new $(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o="map"+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),d;if(c.length===0){let h=0;r!=="directed"&&(h+=this.undirectedSize),r!=="undirected"&&(h+=this.directedSize),d=new Array(h);let f=0;c.push((g,w,v,y,b,_,x)=>{d[f++]=u(g,w,v,y,b,_,x)})}else d=[],c.push((h,f,g,w,v,y,b)=>{d.push(u(h,f,g,w,v,y,b))});return this[a].apply(this,c),d};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),d=[];return c.push((h,f,g,w,v,y,b)=>{u(h,f,g,w,v,y,b)&&d.push(h)}),this[a].apply(this,c),d};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new $(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new $(`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 u,d;c.length===2?(u=c[0],d=c[1],c=[]):c.length===3?(u=c[1],d=c[2],c=[c[0]]):c.length===4&&(u=c[2],d=c[3],c=[c[0],c[1]]);let h=d;return c.push((f,g,w,v,y,b,_)=>{h=u(h,f,g,w,v,y,b,_)}),this[a].apply(this,c),h}}function m0(e,t){let{name:n,type:r,direction:i}=t,a="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(l,c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return u=l,If(!0,this,r,u);if(arguments.length===2){l=""+l,u=c;let d=this._nodes.get(l);if(typeof d>"u")throw new M(`Graph.${a}: could not find the "${l}" node in the graph.`);return vl(!0,this.multi,r==="mixed"?this.type:r,i,d,u)}if(arguments.length===3){l=""+l,c=""+c;let d=this._nodes.get(l);if(!d)throw new M(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new M(`Graph.${a}: could not find the "${c}" target node in the graph.`);return wl(!0,r,this.multi,i,d,c,u)}throw new $(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((d,h,f,g,w,v,y)=>c(d,h,f,g,w,v,y)),!!this[a].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((d,h,f,g,w,v,y)=>!c(d,h,f,g,w,v,y)),!this[a].apply(this,l)}}function v0(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+"Entries";e.prototype[a]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return gr();if(!arguments.length)return c0(this,r);if(arguments.length===1){o=""+o;let l=this._nodes.get(o);if(!l)throw new M(`Graph.${a}: could not find the "${o}" node in the graph.`);return d0(r,i,l)}if(arguments.length===2){o=""+o,s=""+s;let l=this._nodes.get(o);if(!l)throw new M(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new M(`Graph.${a}: could not find the "${s}" target node in the graph.`);return p0(r,i,l,s)}throw new $(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function w0(e){r0.forEach(t=>{f0(e,t),g0(e,t),m0(e,t),v0(e,t)})}var y0=[{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 Ua(){this.A=null,this.B=null}Ua.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};Ua.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function si(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,l=o.target,c=s===n?l:s;if(t&&t.has(c.key))continue;let u=i(c.key,c.attributes);if(e&&u)return c.key}}function yl(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return si(e,null,r,r.undirected,i);if(typeof n=="string")return si(e,null,r,r[n],i)}let a=new Ua,o;if(t!=="undirected"){if(n!=="out"){if(o=si(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!=="in"){if(o=si(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!=="directed"&&(o=si(e,a,r,r.undirected,i),e&&o))return o}function b0(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 yl(!1,e,t,n,function(i){r.push(i)}),r}function li(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],l=s.source,c=s.target;if(o=l===t?c:l,e&&e.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function x0(e,t,n){if(e!=="mixed"){if(e==="undirected")return li(null,n,n.undirected);if(typeof t=="string")return li(null,n,n[t])}let r=gr(),i=new Ua;return e!=="undirected"&&(t!=="out"&&(r=Zt(r,li(i,n,n.in))),t!=="in"&&(r=Zt(r,li(i,n,n.out)))),e!=="directed"&&(r=Zt(r,li(i,n,n.undirected))),r}function k0(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];a=""+a;let o=this._nodes.get(a);if(typeof o>"u")throw new M(`Graph.${n}: could not find the "${a}" node in the graph.`);return b0(r==="mixed"?this.type:r,i,o)}}function _0(e,t){let{name:n,type:r,direction:i}=t,a="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let d=this._nodes.get(c);if(typeof d>"u")throw new M(`Graph.${a}: could not find the "${c}" node in the graph.`);yl(!1,r==="mixed"?this.type:r,i,d,u)};let o="map"+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(c,u){let d=[];return this[a](c,(h,f)=>{d.push(u(h,f))}),d};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,u){let d=[];return this[a](c,(h,f)=>{u(h,f)&&d.push(h)}),d};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(c,u,d){if(arguments.length<3)throw new $(`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 h=d;return this[a](c,(f,g)=>{h=u(h,f,g)}),h}}function T0(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o="find"+a;e.prototype[o]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let d=this._nodes.get(c);if(typeof d>"u")throw new M(`Graph.${o}: could not find the "${c}" node in the graph.`);return yl(!0,r==="mixed"?this.type:r,i,d,u)};let s="some"+a;e.prototype[s]=function(c,u){return!!this[o](c,u)};let l="every"+a;e.prototype[l]=function(c,u){return!this[o](c,(h,f)=>!u(h,f))}}function S0(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+"Entries";e.prototype[a]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return gr();o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new M(`Graph.${a}: could not find the "${o}" node in the graph.`);return x0(r==="mixed"?this.type:r,i,s)}}function E0(e){y0.forEach(t=>{k0(e,t),_0(e,t),T0(e,t),S0(e,t)})}function Oa(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,l,c,u,d,h,f;for(;s=a.next(),s.done!==!0;){let g=!1;if(l=s.value,o!=="undirected"){u=l.out;for(c in u){d=u[c];do{if(h=d.target,g=!0,f=i(l.key,h.key,l.attributes,h.attributes,d.key,d.attributes,d.undirected),e&&f)return d;d=d.next}while(d)}}if(o!=="directed"){u=l.undirected;for(c in u)if(!(t&&l.key>c)){d=u[c];do{if(h=d.target,h.key!==c&&(h=d.source),g=!0,f=i(l.key,h.key,l.attributes,h.attributes,d.key,d.attributes,d.undirected),e&&f)return d;d=d.next}while(d)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),e&&f))return null}}function R0(e,t){let n={key:e};return Rf(t.attributes)||(n.attributes=Ge({},t.attributes)),n}function A0(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return Rf(n.attributes)||(r.attributes=Ge({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function C0(e){if(!Be(e))throw new $('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 $("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!Be(e.attributes)||e.attributes===null))throw new $("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function L0(e){if(!Be(e))throw new $('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 $("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new $("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!Be(e.attributes)||e.attributes===null))throw new $("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new $("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var N0=Dk(),P0=new Set(["directed","undirected","mixed"]),Tf=new Set(["domain","_events","_eventsCount","_maxListeners"]),D0=[{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"}],I0={allowSelfLoops:!0,multi:!1,type:"mixed"};function M0(e,t,n){if(n&&!Be(n))throw new $(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new q(`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 Sf(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 Mf(e,t,n,r,i,a,o,s){if(!r&&e.type==="undirected")throw new q(`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 q(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Be(s))throw new $(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!e.allowSelfLoops&&a===o)throw new q(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(a),c=e._nodes.get(o);if(!l)throw new M(`Graph.${t}: source node "${a}" not found.`);if(!c)throw new M(`Graph.${t}: target node "${o}" not found.`);let u={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new q(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof l.undirected[o]<"u":typeof l.out[o]<"u"))throw new q(`Graph.${t}: an edge linking "${a}" to "${o}" 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 d=new mr(r,i,l,c,s);e._edges.set(i,d);let h=a===o;return r?(l.undirectedDegree++,c.undirectedDegree++,h&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,c.inDegree++,h&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,u.key=i,e.emit("edgeAdded",u),i}function G0(e,t,n,r,i,a,o,s,l){if(!r&&e.type==="undirected")throw new q(`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 q(`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 $(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!Be(s))throw new $(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let c;if(l&&(c=s,s=void 0),!e.allowSelfLoops&&a===o)throw new q(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=e._nodes.get(a),d=e._nodes.get(o),h,f;if(!n&&(h=e._edges.get(i),h)){if((h.source.key!==a||h.target.key!==o)&&(!r||h.source.key!==o||h.target.key!==a))throw new q(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${h.source.key}", "${h.target.key}").`);f=h}if(!f&&!e.multi&&u&&(f=r?u.undirected[o]:u.out[o]),f){let b=[f.key,!1,!1,!1];if(l?!c:!s)return b;if(l){let _=f.attributes;f.attributes=c(_),e.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else Ge(f.attributes,s),e.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return b}s=s||{},l&&c&&(s=c(s));let g={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new q(`Graph.${t}: the "${i}" edge already exists in the graph.`);let w=!1,v=!1;u||(u=Sf(e,a,{}),w=!0,a===o&&(d=u,v=!0)),d||(d=Sf(e,o,{}),v=!0),h=new mr(r,i,u,d,s),e._edges.set(i,h);let y=a===o;return r?(u.undirectedDegree++,d.undirectedDegree++,y&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,d.inDegree++,y&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,g.key=i,e.emit("edgeAdded",g),[i,!0,w,v]}function fr(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var he=class e extends Ef.EventEmitter{constructor(t){if(super(),t=Ge({},I0,t),typeof t.multi!="boolean")throw new $(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!P0.has(t.type))throw new $(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new $(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);let n=t.type==="mixed"?Af:t.type==="directed"?Cf:Lf;xt(this,"NodeDataClass",n);let r="geid_"+N0()+"_",i=0,a=()=>{let o;do o=r+i++;while(this._edges.has(o));return o};xt(this,"_attributes",{}),xt(this,"_nodes",new Map),xt(this,"_edges",new Map),xt(this,"_directedSize",0),xt(this,"_undirectedSize",0),xt(this,"_directedSelfLoopCount",0),xt(this,"_undirectedSelfLoopCount",0),xt(this,"_edgeKeyGenerator",a),xt(this,"_options",t),Tf.forEach(o=>xt(this,o,this[o])),Ct(this,"order",()=>this._nodes.size),Ct(this,"size",()=>this._edges.size),Ct(this,"directedSize",()=>this._directedSize),Ct(this,"undirectedSize",()=>this._undirectedSize),Ct(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Ct(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Ct(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Ct(this,"multi",this._options.multi),Ct(this,"type",this._options.type),Ct(this,"allowSelfLoops",this._options.allowSelfLoops),Ct(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 $(`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 $(`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 $(`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 q("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 M(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new M(`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 q("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 M(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new M(`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 q("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 M(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`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 M(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,a=r.target.key;if(t===i)return a;if(t===a)return i;throw new M(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${a}).`)}hasExtremity(t,n){t=""+t,n=""+n;let r=this._edges.get(t);if(!r)throw new M(`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 M(`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 M(`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 M(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return M0(this,t,n).key}mergeNode(t,n){if(n&&!Be(n))throw new $(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ge(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 $(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){let a=r.attributes;r.attributes=n(a),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 M(`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 fr(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do fr(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do fr(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=kt(this,r,i,this.type),!n)throw new M(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new M(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return fr(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new q("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 q("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=kt(this,t,n,"directed");if(!r)throw new M(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return fr(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new q("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 q("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=kt(this,t,n,"undirected");if(!r)throw new M(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return fr(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 $("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(!Be(t))throw new $("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(!Be(t))throw new $("Graph.mergeAttributes: provided attributes are not a plain object.");return Ge(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new $("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 $("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!_f(n))throw new $("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,a.attributes=t(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new $("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!_f(n))throw new $("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,a,o,s;for(;i=r.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=t(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new $("Graph.forEachAdjacencyEntry: expecting a callback.");Oa(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new $("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Oa(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new $("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Oa(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new $("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Oa(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new $("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 $("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 $("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,a=new Array(this.order),o=0;for(;r=n.next(),r.done!==!0;)i=r.value,a[o++]=t(i.key,i.attributes);return a}someNode(t){if(typeof t!="function")throw new $("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 $("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 $("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,a=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(t,n){if(typeof t!="function")throw new $("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new $("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(),a,o;for(;a=i.next(),a.done!==!0;)o=a.value,r=t(r,o.key,o.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,a)=>{t[n++]=R0(a,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,a)=>{r[n++]=A0(this.type,a,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,c)=>{n?this.mergeNode(l,c):this.addNode(l,c)}),t.forEachEdge((l,c,u,d,h,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,u,d,c):this.mergeDirectedEdgeWithKey(l,u,d,c):g?this.addUndirectedEdgeWithKey(l,u,d,c):this.addDirectedEdgeWithKey(l,u,d,c)}),this;if(!Be(t))throw new $("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Be(t.attributes))throw new $("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,a,o,s;if(t.nodes){if(a=t.nodes,!Array.isArray(a))throw new $("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=a.length;r<i;r++){o=a[r],C0(o);let{key:l,attributes:c}=o;n?this.mergeNode(l,c):this.addNode(l,c)}}if(t.edges){let l=!1;if(this.type==="undirected"&&(l=!0),a=t.edges,!Array.isArray(a))throw new $("Graph.import: invalid edges. Expecting an array.");for(r=0,i=a.length;r<i;r++){s=a[r],L0(s);let{source:c,target:u,attributes:d,undirected:h=l}=s,f;"key"in s?(f=n?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,c,u,d)):(f=n?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,c,u,d))}}return this}nullCopy(t){let n=new e(Ge({},this._options,t));return n.replaceAttributes(Ge({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let a=Ge({},r.attributes);r=new n.NodeDataClass(i,a),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new q(`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 q("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 q("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,a;for(;i=r.next(),i.done!==!0;)a=i.value,Mf(n,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,Ge({},a.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let t={};this._nodes.forEach((a,o)=>{t[o]=a.attributes});let n={},r={};this._edges.forEach((a,o)=>{let s=a.undirected?"--":"->",l="",c=a.source.key,u=a.target.key,d;a.undirected&&c>u&&(d=c,c=u,u=d);let h=`(${c})${s}(${u})`;o.startsWith("geid_")?this.multi&&(typeof r[h]>"u"?r[h]=0:r[h]++,l+=`${r[h]}. `):l+=`[${o}]: `,l+=h,n[l]=a.attributes});let i={};for(let a in this)this.hasOwnProperty(a)&&!Tf.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,xt(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(he.prototype[Symbol.for("nodejs.util.inspect.custom")]=he.prototype.inspect);D0.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?Mf:G0;e.generateKey?he.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,a,o,t==="update")}:he.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,a,o,s,t==="update")}})});Kk(he);n0(he);w0(he);E0(he);var Fa=class extends he{constructor(t){let n=Ge({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new $("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new $('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},$a=class extends he{constructor(t){let n=Ge({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new $("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new $('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},za=class extends he{constructor(t){let n=Ge({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new $("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Ha=class extends he{constructor(t){let n=Ge({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new $("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new $('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Wa=class extends he{constructor(t){let n=Ge({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new $("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new $('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function vr(e){e.from=function(t,n){let r=Ge({},t.options,n),i=new e(r);return i.import(t),i}}vr(he);vr(Fa);vr($a);vr(za);vr(Ha);vr(Wa);he.Graph=he;he.DirectedGraph=Fa;he.UndirectedGraph=$a;he.MultiGraph=za;he.MultiDirectedGraph=Ha;he.MultiUndirectedGraph=Wa;he.InvalidArgumentsGraphError=$;he.NotFoundGraphError=M;he.UsageGraphError=q;function O0(){return new he({multi:!0,type:"directed"})}function bl(e){let t=O0();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:a,...o}=n;t.addDirectedEdgeWithKey(r,i,a,{source:i,target:a,...o})}return t}function Gf(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 Ba(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var Of=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function Ff(e,t,n){let r=null,i=bl({nodes:[],edges:[]}),a=null,o=null,s="neighbourhood",l=new Map,c=0,u=0,d=null,h=0,f=()=>{},g=()=>{},w=()=>{},v=()=>{},y=()=>{},b=null,_=!1,x=P=>{if(b===null)return;let A=b;b=null,r?.setSetting("enableCameraPanning",!0),(P===null||P===A)&&y(A)},R=()=>ws([...Ba(i).values()]),O=(P,A)=>{A.then(()=>{r===P&&P.refresh()},()=>{})},N=P=>{let A=kd(a,o,c,s),H=Ed(a,o,c,s),Z=l;P.setSetting("nodeReducer",(G,J)=>{let X={...J,...A(G,J,t)};return{...X,...Rd(Z.get(G),X,t,J.label)}}),P.setSetting("edgeReducer",(G,J)=>({...J,...H(G,J,t)}))},j=()=>{if(n===void 0||d!==null)return;h=n.now();let P=()=>{d=null;let A=n.now();if(c=Td(c,u,A-h),h=A,r!==null&&N(r),c===u){c===0&&(a=null);return}d=n.request(P)};d=n.request(P)};return{mount(P){if(r!==null)return;let A=e(i,P,Cd(t));A.on("clickNode",({node:H})=>{_||f(H)}),A.on("doubleClickNode",({node:H,preventSigmaDefault:Z})=>{Z(),_||f(H)}),A.on("clickStage",()=>f(null)),A.on("downNode",({node:H})=>{b=H,_=!1,r?.setSetting("enableCameraPanning",!1),w(H)}),A.on("moveBody",H=>{b!==null&&(_=!0,H.preventSigmaDefault(),v(b,A.viewportToGraph({x:H.event.x,y:H.event.y})))}),A.on("enterNode",({node:H})=>g(H)),A.on("leaveNode",()=>g(null)),A.on("upNode",()=>x(b)),A.on("upStage",()=>x(null)),N(A),A.setSetting("labelRenderedSizeThreshold",ys(i.order)),A.setCustomBBox(R()),r=A},setGraph(P){i=bl(P),r?.setGraph(i),r?.setSetting("labelRenderedSizeThreshold",ys(i.order)),r?.setCustomBBox(R())},setPositions(P){Gf(i,P),r?.refresh()},setHighlight(P,A=null,H="neighbourhood"){if(n===void 0){a=P,o=A,s=H,c=P===null?0:1,u=c,r!==null&&N(r);return}if(P===null){if(u=0,a===null)return}else a=P,o=A,s=H,u=1;r!==null&&N(r),c!==u&&j()},setTrail(P){l=P,r!==null&&N(r)},onSelect(P){f=P},onHover(P){g=P},onDragStart(P){w=P},onDragMove(P){v=P},onDragEnd(P){y=P},fit(){let P=r;P!==null&&(P.setCustomBBox(R()),O(P,P.getCamera().animatedReset()))},focus(P){let A=r;if(A===null)return;let H=R(),Z=Ba(i),G=[...P??[]].flatMap(X=>Z.get(X)??[]),J=wd(H,G);A.setCustomBBox(H),O(A,J===null?A.getCamera().animatedReset():A.getCamera().animate(J))},positions(){return Ba(i)},destroy(){d!==null&&(n?.cancel(d),d=null),r?.kill(),r=null}}}var $f=e=>Ff((t,n,r)=>new kf(t,n,r),e,Of(window));function zf(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 F0(e){if(Array.isArray(e))return e}function $0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],l=!0,c=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}function z0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
410
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H0(e,t){return F0(e)||$0(e,t)||W0(e,t)||z0()}function W0(e,t){if(e){if(typeof e=="string")return zf(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)?zf(e,t):void 0}}var tg=Object.entries,Hf=Object.setPrototypeOf,U0=Object.isFrozen,B0=Object.getPrototypeOf,K0=Object.getOwnPropertyDescriptor,Oe=Object.freeze,We=Object.seal,wr=Object.create,ng=typeof Reflect<"u"&&Reflect,Rl=ng.apply,Al=ng.construct;Oe||(Oe=function(t){return t});We||(We=function(t){return t});Rl||(Rl=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];return t.apply(n,i)});Al||(Al=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 Bn=Ne(Array.prototype.forEach),V0=Ne(Array.prototype.lastIndexOf),Wf=Ne(Array.prototype.pop),ui=Ne(Array.prototype.push),j0=Ne(Array.prototype.splice),yr=Array.isArray,pi=Ne(String.prototype.toLowerCase),xl=Ne(String.prototype.toString),Uf=Ne(String.prototype.match),di=Ne(String.prototype.replace),Bf=Ne(String.prototype.indexOf),q0=Ne(String.prototype.trim),Y0=Ne(Number.prototype.toString),Z0=Ne(Boolean.prototype.toString),Kf=typeof BigInt>"u"?null:Ne(BigInt.prototype.toString),Vf=typeof Symbol>"u"?null:Ne(Symbol.prototype.toString),lt=Ne(Object.prototype.hasOwnProperty),hi=Ne(Object.prototype.toString),qe=Ne(RegExp.prototype.test),Un=X0(TypeError);function Ne(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 Rl(e,t,r)}}function X0(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Al(e,n)}}function ae(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pi;if(Hf&&Hf(e,null),!yr(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let a=n(i);a!==i&&(U0(t)||(t[r]=a),i=a)}e[i]=!0}return e}function Q0(e){for(let t=0;t<e.length;t++)lt(e,t)||(e[t]=null);return e}function mt(e){let t=wr(null);for(let r of tg(e)){var n=H0(r,2);let i=n[0],a=n[1];lt(e,i)&&(yr(a)?t[i]=Q0(a):a&&typeof a=="object"&&a.constructor===Object?t[i]=mt(a):t[i]=a)}return t}function J0(e){switch(typeof e){case"string":return e;case"number":return Y0(e);case"boolean":return Z0(e);case"bigint":return Kf?Kf(e):"0";case"symbol":return Vf?Vf(e):"Symbol()";case"undefined":return hi(e);case"function":case"object":{if(e===null)return hi(e);let t=e,n=Lt(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:hi(r)}return hi(e)}default:return hi(e)}}function Lt(e,t){for(;e!==null;){let r=K0(e,t);if(r){if(r.get)return Ne(r.get);if(typeof r.value=="function")return Ne(r.value)}e=B0(e)}function n(){return null}return n}function e_(e){try{return qe(e,""),!0}catch{return!1}}var jf=Oe(["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"]),kl=Oe(["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"]),_l=Oe(["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"]),t_=Oe(["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"]),Tl=Oe(["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"]),n_=Oe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qf=Oe(["#text"]),Yf=Oe(["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"]),Sl=Oe(["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"]),Zf=Oe(["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"]),Ka=Oe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),r_=We(/{{[\w\W]*|^[\w\W]*}}/g),i_=We(/<%[\w\W]*|^[\w\W]*%>/g),a_=We(/\${[\w\W]*/g),o_=We(/^data-[\-\w.\u00B7-\uFFFF]+$/),s_=We(/^aria-[\-\w]+$/),Xf=We(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),l_=We(/^(?:\w+script|data):/i),c_=We(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),u_=We(/^html$/i),d_=We(/^[a-z][.\w]*(-[.\w]+)+$/i),Qf=We(/<[/\w!]/g),Jf=We(/<[/\w]/g),h_=We(/<\/no(script|embed|frames)/i),p_=We(/\/>/i),gt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},rg=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],f_=Oe(ae({},rg)),g_=(function(){let e={};return Bn(rg,t=>{e[t]=We(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Oe(e)})(),m_=function(){return typeof window>"u"?null:window},v_=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 a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},eg=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},gn=function(t,n,r,i){return lt(t,n)&&yr(t[n])?ae(i.base?mt(i.base):{},t[n],i.transform):r},El=function(t,n,r){let i=lt(t,n)?t[n]:void 0;return i&&typeof i=="object"?mt(i):r()};function ig(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:m_(),t=D=>ig(D);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==gt.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,l=e.NodeFilter,c=e.NamedNodeMap;c===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let u=e.DOMParser,d=e.trustedTypes,h=s.prototype,f=Lt(h,"cloneNode"),g=Lt(h,"remove"),w=Lt(h,"nextSibling"),v=Lt(h,"childNodes"),y=Lt(h,"parentNode"),b=Lt(h,"shadowRoot"),_=Lt(h,"attributes"),x=o&&o.prototype?Lt(o.prototype,"nodeType"):null,R=o&&o.prototype?Lt(o.prototype,"nodeName"):null,O=o&&o.prototype?Lt(o.prototype,"ownerDocument"):null,N=function(m){return x?x(m):m.nodeType},j=function(m){return R?R(m):m.nodeName};if(typeof a=="function"){let D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let P,A="",H,Z=!1,G=0,J=function(){if(G>0)throw Un('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.')},X=function(m){J(),G++;try{return P.createHTML(m)}finally{G--}},se=function(m){J(),G++;try{return P.createScriptURL(m)}finally{G--}},Ye=function(){return Z||(H=v_(d,i),Z=!0),H},Ae=n,ye=Ae.implementation,ue=Ae.createNodeIterator,Te=Ae.createDocumentFragment,ct=Ae.getElementsByTagName,Pe=r.importNode,oe=eg();t.isSupported=typeof tg=="function"&&typeof y=="function"&&ye&&ye.createHTMLDocument!==void 0;let Se=r_,ut=i_,Nt=a_,L=o_,W=s_,te=l_,ge=c_,Fe=d_,wt=Xf,pe=null,_t=ae({},[...jf,...kl,..._l,...Tl,...qf]),ie=null,Tt=ae({},[...Yf,...Sl,...Zf,...Ka]),Ke=Object.seal(wr(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}})),mn=null,xr=null,Ve=Object.seal(wr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),kr=!0,vn=!0,_r=!1,Tr=!0,Pt=!1,zt=!0,et=!1,wn=!1,Dt=null,Vn=null,yt=!1,Ee=!1,$e=!1,yn=!1,Ce=!0,Ht=!1,Qt="user-content-",bn=!0,Sr=!1,Jt={},tt=null,vi=ae({},["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"]),nt=null,en=ae({},["audio","video","img","source","image","track"]),St=null,dt=ae({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jn="http://www.w3.org/1998/Math/MathML",tn="http://www.w3.org/2000/svg",ht="http://www.w3.org/1999/xhtml",nn=ht,Er=!1,Rr=null,so=ae({},[jn,tn,ht],xl),wi=Oe(["mi","mo","mn","ms","mtext"]),Ar=ae({},wi),yi=Oe(["annotation-xml"]),qn=ae({},yi),bi=ae({},["title","style","font","a","script"]),xn=null,xi=["application/xhtml+xml","text/html"],ki="text/html",be=null,rn=null,_i=n.createElement("form"),kn=function(m){return m instanceof RegExp||m instanceof Function},Cr=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(rn&&rn===m)return;(!m||typeof m!="object")&&(m={}),m=mt(m),xn=xi.indexOf(m.PARSER_MEDIA_TYPE)===-1?ki:m.PARSER_MEDIA_TYPE,be=xn==="application/xhtml+xml"?xl:pi,pe=gn(m,"ALLOWED_TAGS",_t,{transform:be}),ie=gn(m,"ALLOWED_ATTR",Tt,{transform:be}),Rr=gn(m,"ALLOWED_NAMESPACES",so,{transform:xl}),St=gn(m,"ADD_URI_SAFE_ATTR",dt,{transform:be,base:dt}),nt=gn(m,"ADD_DATA_URI_TAGS",en,{transform:be,base:en}),tt=gn(m,"FORBID_CONTENTS",vi,{transform:be}),mn=gn(m,"FORBID_TAGS",mt({}),{transform:be}),xr=gn(m,"FORBID_ATTR",mt({}),{transform:be}),Jt=lt(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?mt(m.USE_PROFILES):m.USE_PROFILES:!1,kr=m.ALLOW_ARIA_ATTR!==!1,vn=m.ALLOW_DATA_ATTR!==!1,_r=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Tr=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pt=m.SAFE_FOR_TEMPLATES||!1,zt=m.SAFE_FOR_XML!==!1,et=m.WHOLE_DOCUMENT||!1,Ee=m.RETURN_DOM||!1,$e=m.RETURN_DOM_FRAGMENT||!1,yn=m.RETURN_TRUSTED_TYPE||!1,yt=m.FORCE_BODY||!1,Ce=m.SANITIZE_DOM!==!1,Ht=m.SANITIZE_NAMED_PROPS||!1,bn=m.KEEP_CONTENT!==!1,Sr=m.IN_PLACE||!1,wt=e_(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:Xf,nn=typeof m.NAMESPACE=="string"?m.NAMESPACE:ht,Ar=El(m,"MATHML_TEXT_INTEGRATION_POINTS",()=>ae({},wi)),qn=El(m,"HTML_INTEGRATION_POINTS",()=>ae({},yi));let T=El(m,"CUSTOM_ELEMENT_HANDLING",()=>wr(null));if(Ke=wr(null),lt(T,"tagNameCheck")&&kn(T.tagNameCheck)&&(Ke.tagNameCheck=T.tagNameCheck),lt(T,"attributeNameCheck")&&kn(T.attributeNameCheck)&&(Ke.attributeNameCheck=T.attributeNameCheck),lt(T,"allowCustomizedBuiltInElements")&&typeof T.allowCustomizedBuiltInElements=="boolean"&&(Ke.allowCustomizedBuiltInElements=T.allowCustomizedBuiltInElements),We(Ke),Pt&&(vn=!1),$e&&(Ee=!0),Jt&&(pe=ae({},qf),ie=wr(null),Jt.html===!0&&(ae(pe,jf),ae(ie,Yf)),Jt.svg===!0&&(ae(pe,kl),ae(ie,Sl),ae(ie,Ka)),Jt.svgFilters===!0&&(ae(pe,_l),ae(ie,Sl),ae(ie,Ka)),Jt.mathMl===!0&&(ae(pe,Tl),ae(ie,Zf),ae(ie,Ka))),Ve.tagCheck=null,Ve.attributeCheck=null,lt(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Ve.tagCheck=m.ADD_TAGS:yr(m.ADD_TAGS)&&(pe===_t&&(pe=mt(pe)),ae(pe,m.ADD_TAGS,be))),lt(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Ve.attributeCheck=m.ADD_ATTR:yr(m.ADD_ATTR)&&(ie===Tt&&(ie=mt(ie)),ae(ie,m.ADD_ATTR,be))),lt(m,"ADD_FORBID_CONTENTS")&&yr(m.ADD_FORBID_CONTENTS)&&(tt===vi&&(tt=mt(tt)),ae(tt,m.ADD_FORBID_CONTENTS,be)),bn&&(pe["#text"]=!0),et&&ae(pe,["html","head","body"]),pe.table&&(ae(pe,["tbody"]),delete mn.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Un('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Un('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=P;P=m.TRUSTED_TYPES_POLICY;try{A=X("")}catch(F){throw P=E,F}}else m.TRUSTED_TYPES_POLICY===null?(P=void 0,A=""):(P===void 0&&(P=Ye()),P&&typeof A=="string"&&(A=X("")));Oe&&Oe(m),rn=m},Ti=ae({},[...kl,..._l,...t_]),Lr=ae({},[...Tl,...n_]),Si=function(m,T,E){return T.namespaceURI===ht?m==="svg":T.namespaceURI===jn?m==="svg"&&(E==="annotation-xml"||Ar[E]):!!Ti[m]},Ei=function(m,T,E){return T.namespaceURI===ht?m==="math":T.namespaceURI===tn?m==="math"&&qn[E]:!!Lr[m]},Ri=function(m,T,E){return T.namespaceURI===tn&&!qn[E]||T.namespaceURI===jn&&!Ar[E]?!1:!Lr[m]&&(bi[m]||!Ti[m])},lo=function(m){let T=y(m);(!T||!T.tagName)&&(T={namespaceURI:nn,tagName:"template"});let E=pi(m.tagName),F=pi(T.tagName);return Rr[m.namespaceURI]?m.namespaceURI===tn?Si(E,T,F):m.namespaceURI===jn?Ei(E,T,F):m.namespaceURI===ht?Ri(E,T,F):!!(xn==="application/xhtml+xml"&&Rr[m.namespaceURI]):!1},k=function(m){ui(t.removed,{element:m});try{y(m).removeChild(m)}catch{if(g(m),!y(m))throw Un("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},S=function(m,T,E){try{m.removeAttributeNode(T)}catch{try{m.removeAttribute(E)}catch{}}},B=function(m){ee(m);let T=v(m);if(T){let F=[];Bn(T,U=>{ui(F,U)}),Bn(F,U=>{try{g(U)}catch{}})}let E=_(m);if(E)for(let F=E.length-1;F>=0;--F){let U=E[F],Y=U&&U.name;typeof Y=="string"&&S(m,U,Y)}},Q=function(m,T,E){if(!E)try{E=T.getAttributeNode(m)}catch{E=null}ui(t.removed,{attribute:E||null,from:T});try{E?T.removeAttributeNode(E):T.removeAttribute(m)}catch{try{T.removeAttribute(m)}catch{}}if(m==="is")if(Ee||$e)try{k(T)}catch{}else try{T.setAttribute(m,"")}catch{}},I=function(m){let T=_(m);if(T)for(let E=T.length-1;E>=0;--E){let F=T[E],U=F&&F.name;typeof U!="string"||ie[be(U)]||S(m,F,U)}},ee=function(m){let T=[m];for(;T.length>0;){let E=T.pop();N(E)===gt.element&&I(E);let U=v(E);if(U)for(let Y=U.length-1;Y>=0;--Y)T.push(U[Y])}},Ue=function(m,T){return zt?m==="patchsrc"?!0:m==="for"&&T!=="label"&&T!=="output":!1},an=function(m){if(!zt)return;let T=[m];for(;T.length>0;){let E=T.pop(),F=N(E);if(F===gt.processingInstruction||F===gt.comment&&qe(Jf,E.data)){try{g(E)}catch{}continue}if(F===gt.element){let Y=E,me=be(j(E));try{Y.hasAttribute&&Y.hasAttribute("patchsrc")&&Y.removeAttribute("patchsrc"),Y.hasAttribute&&Y.hasAttribute("for")&&Ue("for",me)&&Y.removeAttribute("for")}catch{}}let U=v(E);if(U)for(let Y=U.length-1;Y>=0;--Y)T.push(U[Y])}},Nr=function(m){let T=null,E=null;if(yt)m="<remove></remove>"+m;else{let Y=Uf(m,/^[\r\n\t ]+/);E=Y&&Y[0]}xn==="application/xhtml+xml"&&nn===ht&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");let F=P?X(m):m;if(nn===ht)try{T=new u().parseFromString(F,xn)}catch{}if(!T||!T.documentElement){T=ye.createDocument(nn,"template",null);try{T.documentElement.innerHTML=Er?A:F}catch{}}let U=T.body||T.documentElement;return m&&E&&U.insertBefore(n.createTextNode(E),U.childNodes[0]||null),nn===ht?ct.call(T,et?"html":"body")[0]:et?T.documentElement:U},Pr=function(m){let T=O?O(m):m.ownerDocument;return ue.call(T||m,m,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Yn=function(m){return m=di(m,Se," "),m=di(m,ut," "),m=di(m,Nt," "),m},co=function(m){var T;m.normalize();let E=O?O(m):m.ownerDocument,F=ue.call(E||m,m,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),U=F.nextNode();for(;U;)U.data=Yn(U.data),U=F.nextNode();let Y=(T=m.querySelectorAll)===null||T===void 0?void 0:T.call(m,"template");Y&&Bn(Y,me=>{Zn(me.content)&&co(me.content)})},Ai=function(m){let T=R?R(m):null;return typeof T!="string"||be(T)!=="form"?!1:typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||m.attributes!==_(m)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function"||m.nodeType!==x(m)||m.childNodes!==v(m)},Zn=function(m){if(!x||typeof m!="object"||m===null)return!1;try{return x(m)===gt.documentFragment}catch{return!1}},Dr=function(m){if(!x||typeof m!="object"||m===null)return!1;try{return typeof x(m)=="number"}catch{return!1}};function It(D,m,T){D.length!==0&&Bn(D,E=>{E.call(t,m,T,rn)})}let jm=function(m,T){return!!(zt&&m.hasChildNodes()&&!Dr(m.firstElementChild)&&qe(Qf,m.textContent)&&qe(Qf,m.innerHTML)||zt&&m.namespaceURI===ht&&f_[T]&&(Dr(m.firstElementChild)||typeof m.textContent=="string"&&qe(g_[T],m.textContent))||m.nodeType===gt.processingInstruction||zt&&m.nodeType===gt.comment&&qe(Jf,m.data))},Ci=function(m,T){if(m instanceof RegExp)return qe(m,T);if(m instanceof Function){for(var E=arguments.length,F=new Array(E>2?E-2:0),U=2;U<E;U++)F[U-2]=arguments[U];return!!m(T,...F)}return!1},qm=function(m,T,E){if(!mn[T]&&Ql(T)&&Ci(Ke.tagNameCheck,T))return!1;if(bn&&!tt[T]){let F=y(m),U=v(m);if(U&&F){let Y=U.length;for(let me=Y-1;me>=0;--me){let ke=m===E?f(U[me],!0):U[me];F.insertBefore(ke,w(m))}}}return k(m),!0},ql=function(m,T,E,F){return m.length===0?T:T===E||T===F?mt(T):T},Yl=function(m,T){return m===T||y(m)!==null?!1:(Sr&&ee(m),!0)},Zl=function(m,T){if(It(oe.beforeSanitizeElements,m,null),Yl(m,T))return!0;if(Ai(m))return k(m),!0;let E=be(j(m));if(pe=ql(oe.uponSanitizeElement,pe,_t,Dt),It(oe.uponSanitizeElement,m,{tagName:E,allowedTags:pe}),Yl(m,T))return!0;if(jm(m,E))return k(m),!0;if(mn[E]||!(Ve.tagCheck instanceof Function&&Ve.tagCheck(E))&&!pe[E]){let U=qm(m,E,T);return U===!1&&It(oe.afterSanitizeElements,m,null),U}if(N(m)===gt.element&&!lo(m)||(E==="noscript"||E==="noembed"||E==="noframes")&&qe(h_,m.innerHTML))return k(m),!0;if(Pt&&m.nodeType===gt.text){let U=Yn(m.textContent);m.textContent!==U&&(ui(t.removed,{element:m.cloneNode()}),m.textContent=U)}return It(oe.afterSanitizeElements,m,null),!1},Xl=function(m,T,E){if(xr[T]||Ue(T,m)||Ce&&(T==="id"||T==="name")&&(E in n||E in _i))return!1;let F=ie[T]||Ve.attributeCheck instanceof Function&&Ve.attributeCheck(T,m);return vn&&qe(L,T)||kr&&qe(W,T)?!0:F?St[T]||qe(wt,di(E,ge,""))||(T==="src"||T==="xlink:href"||T==="href")&&m!=="script"&&Bf(E,"data:")===0&&nt[m]||_r&&!qe(te,di(E,ge,""))?!0:!E:Ql(m)&&Ci(Ke.tagNameCheck,m)&&Ci(Ke.attributeNameCheck,T,m)||T==="is"&&Ke.allowCustomizedBuiltInElements&&Ci(Ke.tagNameCheck,E)},Ym=ae({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ql=function(m){return!Ym[pi(m)]&&qe(Fe,m)},Zm=function(m,T,E,F){if(P&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!E)switch(d.getAttributeType(m,T)){case"TrustedHTML":return X(F);case"TrustedScriptURL":return se(F)}return F},Xm=function(m,T,E,F){try{E?m.setAttributeNS(E,T,F):m.setAttribute(T,F),Ai(m)?k(m):Wf(t.removed)}catch{Q(T,m)}},Jl=function(m){It(oe.beforeSanitizeAttributes,m,null);let T=m.attributes;if(!T||Ai(m))return;ie=ql(oe.uponSanitizeAttribute,ie,Tt,Vn);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ie,forceKeepAttr:void 0},F=T.length,U=be(m.nodeName);for(;F--;){let Y=T[F],me=Y.name,ke=Y.namespaceURI,rt=Y.value,it=be(me),ho=rt,Ze=me==="value"?ho:q0(ho);if(E.attrName=it,E.attrValue=Ze,E.keepAttr=!0,E.forceKeepAttr=void 0,It(oe.uponSanitizeAttribute,m,E),Ze=E.attrValue,Ht&&(it==="id"||it==="name")&&Bf(Ze,Qt)!==0&&(Q(me,m,Y),Ze=Qt+Ze),zt&&qe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ze)){Q(me,m,Y);continue}if(it==="attributename"&&Uf(Ze,"href")){Q(me,m,Y);continue}if(!E.forceKeepAttr){if(!E.keepAttr){Q(me,m,Y);continue}if(!Tr&&qe(p_,Ze)){Q(me,m,Y);continue}if(Pt&&(Ze=Yn(Ze)),!Xl(U,it,Ze)){Q(me,m,Y);continue}Ze=Zm(U,it,ke,Ze),Ze!==ho&&Xm(m,me,ke,Ze)}}It(oe.afterSanitizeAttributes,m,null)},Li=function(m){let T=null,E=Pr(m);for(It(oe.beforeSanitizeShadowDOM,m,null);T=E.nextNode();)if(It(oe.uponSanitizeShadowNode,T,null),Zl(T,m),Jl(T),Zn(T.content)&&Li(T.content),N(T)===gt.element){let F=b(T);Zn(F)&&(uo(F),Li(F))}It(oe.afterSanitizeShadowDOM,m,null)},uo=function(m){let T=[{node:m,shadow:null}];for(;T.length>0;){let E=T.pop();if(E.shadow){Li(E.shadow);continue}let F=E.node,Y=N(F)===gt.element,me=v(F);if(me)for(let ke=me.length-1;ke>=0;--ke)T.push({node:me[ke],shadow:null});if(Y){let ke=R?R(F):null;if(typeof ke=="string"&&be(ke)==="template"){let rt=F.content;Zn(rt)&&T.push({node:rt,shadow:null})}}if(Y){let ke=b(F);Zn(ke)&&T.push({node:null,shadow:ke},{node:ke,shadow:null})}}};return t.sanitize=function(D){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,E=null,F=null,U=null;if(Er=!D,Er&&(D="<!-->"),typeof D!="string"&&!Dr(D)&&(D=J0(D),typeof D!="string"))throw Un("dirty is not a string, aborting");if(!t.isSupported)return D;wn?(pe=Dt,ie=Vn):Cr(m),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(pe=mt(pe)),oe.uponSanitizeAttribute.length>0&&(ie=mt(ie)),t.removed=[];let Y=Sr&&typeof D!="string"&&Dr(D);if(Y){an(D);let rt=j(D);if(typeof rt=="string"){let it=be(rt);if(!pe[it]||mn[it])throw B(D),Un("root node is forbidden and cannot be sanitized in-place")}if(Ai(D))throw B(D),Un("root node is clobbered and cannot be sanitized in-place");try{uo(D)}catch(it){throw B(D),it}}else if(Dr(D))T=Nr("<!---->"),E=T.ownerDocument.importNode(D,!0),E.nodeType===gt.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?T=E:T.appendChild(E),uo(E);else{if(!Ee&&!Pt&&!et&&D.indexOf("<")===-1)return P&&yn?X(D):D;if(T=Nr(D),!T)return Ee?null:yn?A:""}T&&yt&&k(T.firstChild);let me=Y?D:T;try{let rt=Pr(me);for(;F=rt.nextNode();)Zl(F,me),Jl(F),Zn(F.content)&&Li(F.content)}catch(rt){throw Y&&(B(D),Bn(t.removed,it=>{it.element&&ee(it.element)})),rt}if(Y)return Bn(t.removed,rt=>{rt.element&&ee(rt.element)}),Pt&&co(D),D;if(Ee){if(Pt&&co(T),$e)for(U=Te.call(T.ownerDocument);T.firstChild;)U.appendChild(T.firstChild);else U=T;return(ie.shadowroot||ie.shadowrootmode)&&(U=Pe.call(r,U,!0)),U}let ke=et?T.outerHTML:T.innerHTML;return et&&pe["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&qe(u_,T.ownerDocument.doctype.name)&&(ke="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
411
+ `+ke),Pt&&(ke=Yn(ke)),P&&yn?X(ke):ke},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Cr(D),wn=!0,Dt=pe,Vn=ie},t.clearConfig=function(){rn=null,wn=!1,Dt=null,Vn=null,P=H,A=""},t.isValidAttribute=function(D,m,T){rn||Cr({});let E=be(D),F=be(m);return Xl(E,F,T)},t.addHook=function(D,m){typeof m=="function"&&lt(oe,D)&&ui(oe[D],m)},t.removeHook=function(D,m){if(lt(oe,D)){if(m!==void 0){let T=V0(oe[D],m);return T===-1?void 0:j0(oe[D],T,1)[0]}return Wf(oe[D])}},t.removeHooks=function(D){lt(oe,D)&&(oe[D]=[])},t.removeAllHooks=function(){oe=eg()},t}var Cl=ig();function Va(e=Date.now){let t=new Map,n=new Map,r=new Set,i=0,a=()=>r.forEach(s=>s()),o=s=>s.body!==s.baseline||s.raw!==s.rawBaseline;return{get:s=>t.get(s)??null,subscribe(s){return r.add(s),()=>r.delete(s)},open(s,l){if(t.has(s))return;let{head:c,tail:u}=nr(l),{entries:d}=$r(u);t.set(s,{body:c,baseline:c,tail:u,raw:d,rawBaseline:d,saving:!1,original:c,originalRaw:d,savedAt:null,failed:!1}),a()},edit(s,l){let c=t.get(s);c===void 0||c.body===l||(c.body=l,c.failed=!1,a())},editRaw(s,l){let c=t.get(s);c===void 0||c.raw===l||(c.raw=l,c.failed=!1,a())},syncTail(s,l){let c=t.get(s);if(c===void 0||c.saving||c.raw!==c.rawBaseline)return;let{tail:u}=nr(l);if(u===c.tail)return;let{entries:d}=$r(u);c.originalRaw===c.rawBaseline?c.originalRaw=d:d.startsWith(c.rawBaseline)&&(c.originalRaw+=d.slice(c.rawBaseline.length)),c.tail=u,c.raw=d,c.rawBaseline=d,a()},discard(s){t.delete(s)&&a()},isDirty(s){let l=t.get(s);return l!==void 0&&o(l)},dirtySlugs(){return[...t].filter(([,s])=>o(s)).map(([s])=>s)},revert(s){let l=t.get(s);return l===void 0?!1:(l.body=l.original,l.raw=l.originalRaw,a(),o(l))},async save(s,l,c){let u=t.get(s);if(u===void 0||u.saving||n.get(s)?.saving)return;let d=u.body,h=u.raw,f=h!==u.rawBaseline,g=f?Vo($r(u.tail).opening,h):u.tail,w=Ko(d,g);u.saving=!0,a();let v=!1;try{let y={...f?{raw:!0}:{},...c?.keepOpen?{quiet:!0}:{}};v=await l(s,w,Object.keys(y).length===0?void 0:y)}finally{if(t.get(s)===u){let y=n.get(s);v&&y!==void 0&&(y.body=w,y.version=++i,delete y.pending),v&&!c?.keepOpen&&u.body===d&&u.raw===h?t.delete(s):(v&&(u.baseline=d,u.rawBaseline=h,u.tail=g,u.savedAt=e()),u.failed=!v,u.saving=!1),a()}}},nextLoadVersion(){return++i},getTaskBody(s,l){return n.get(s)?.body??l},taskBody(s,l,c){let u=n.get(s),d=!1;return u===void 0?(u={body:l,version:c,saving:!1},n.set(s,u)):c>u.version&&(u.saving?(u.pending===void 0||c>u.pending.version)&&(u.pending={body:l,version:c}):(d=u.body!==l,u.body=l,u.version=c)),d&&a(),u.body},isTaskSaving:s=>n.get(s)?.saving??!1,async saveTask(s,l,c){let u=n.get(s);if(u===void 0||u.saving||t.get(s)?.saving)return!1;u.saving=!0,a();let d=!1;try{return d=await c(s,l),d}finally{n.get(s)===u&&(d?(u.body=l,u.version=++i):u.pending!==void 0&&u.pending.version>u.version&&(u.body=u.pending.body,u.version=u.pending.version),delete u.pending,u.saving=!1,a())}},clearTaskSources(s){let l=!1;for(let c of s)l=n.delete(c)||l;l&&a()}}}function ag(e,t,n,r){let i=new Set(t.panes.flatMap(s=>s.tabs.map(Mt))),a=new Set(n.panes.flatMap(s=>s.tabs.map(Mt))),o=[...i].filter(s=>s!==null&&s.startsWith("note:")&&!a.has(s)).map(s=>s.slice(5));return o.some(s=>e.isDirty(s))&&!r()?!1:(o.forEach(s=>e.discard(s)),e.clearTaskSources(o),!0)}function og(e,t,n){let r=new Set(t);return e.dirtySlugs().filter(a=>r.has(a)).length>0&&!n()?!1:(r.forEach(a=>e.discard(a)),e.clearTaskSources([...r]),!0)}var fi="",ja="",sg=900;function Nl(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;let i=0;for(;i<n-r&&e.charCodeAt(e.length-1-i)===t.charCodeAt(t.length-1-i);)i++;return{start:r,end:t.length-i,removed:e.length-i-r}}var w_=/^[ \t]*(?:#{1,6}[ \t]+|>[ \t]?|(?:[*+-]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)*/,y_=/^[ \t]*(?:`{3,}|~{3,}|<!--|(?:[-*_][ \t]*){3,}$)/,b_=/!?\[\[[^\]\n]*\]\]|!?\[[^\]\n]*\]\([^)\n]*\)|<[a-z][a-z0-9+.-]*:[^>\s]*>/gi;function x_(e,t){let{start:n,end:r}=Nl(e??"",t);if(n>=r)return t;let i=[],a=t.lastIndexOf(`
412
412
  `,n-1)+1;for(;a<r;){let s=t.indexOf(`
413
- `,a),l=s===-1?t.length:s,c=t.slice(a,l);if(!f_.test(c)){let u=p_.exec(c)[0].length,d=Math.max(n-a,u),h=Math.min(r,l)-a;for(let f of c.matchAll(g_)){let g=f.index+f[0].length;d>f.index&&d<g&&(d=f.index),h>f.index&&h<g&&(h=g)}c.slice(d,h).trim()!==""&&i.push([a+d,a+h])}a=l+1}let o=t;for(let[s,l]of i.reverse())o=o.slice(0,s)+fi+o.slice(s,l)+ja+o.slice(l);return o}function rg(e,t){let n=[],r="",i=t;for(let a of e)a===fi||a===ja?(r!==""&&n.push({text:r,marked:i}),r="",i=a===fi):r+=a;return r!==""&&n.push({text:r,marked:i}),{parts:n,inside:i}}var v_={human:"You",agent:"Agent",outside:"Outside edit",system:"pi-weave"},w_={create:"created the note",edit:"edited",append:"added to the note",raw:"added words to Raw",finalize:"rewrote the summary",generate:"generated the note",repair:"fixed links",outside:"changed outside pi-weave",baseline:"earliest saved version"};function y_(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let r=n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return t!==null&&new Date(t).toDateString()===n.toDateString()?r:`${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${r}`}function b_(e,t){let{head:n,tail:r}=nr(e);return r!==""&&t>=n.length}function qa(e,t){if(e.length===0)return null;let n=Math.max(0,Math.min(e.length-1,t)),r=e[n],i=n===0?null:e[n-1],a=Cl(i?.body??"",r.body),o=a.end-a.start,s=[o>0?`+${o}`:"",a.removed>0?`−${a.removed}`:""].filter(Boolean).join(" "),l=w_[r.op]??r.op;return{position:`${n+1} of ${e.length}`,action:r.op==="baseline"?l[0].toUpperCase()+l.slice(1):`${v_[r.by]} ${l}`,at:y_(r.at,i?.at??null),atIso:r.at,change:s,marked:m_(i?.body??null,r.body),by:r.by,follow:!b_(r.body,a.start)}}var Al=.14;function ig(e){let t=e.map((r,i)=>{let a=Cl(i===0?"":e[i-1].body,r.body);return a.end-a.start+a.removed}),n=Math.log1p(Math.max(0,...t));return e.map((r,i)=>({height:n===0?Al:Al+(1-Al)*(Math.log1p(t[i])/n),by:r.by}))}function ag(e,t){let n=new Date(t),r=new Date(t-864e5),i=Math.max(1,e.length-1),a=[],o="";return e.forEach((s,l)=>{let c=new Date(s.at);if(Number.isNaN(c.getTime()))return;let u=c.toDateString();if(u===o)return;o=u;let d=u===n.toDateString()?"Today":u===r.toDateString()?"Yesterday":c.toLocaleDateString(void 0,{month:"short",day:"numeric"});a.push({at:e.length===1?0:l/i,label:d})}),a}function og(e,t){return e+1<t?e+1:null}var sg="History",lg="Close history",Ll="History is off, so new changes are not being saved. Turn it on in Settings → Editor.",cg="Older versions were trimmed",ug="No saved versions yet. Changes are saved from now on.";function dg(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let a=t.nextNode();a!==null;a=t.nextNode())n.push(a);let r=!1,i=null;for(let a of n){let o=a.data;if(!r&&!o.includes(fi)&&!o.includes(ja))continue;let s=rg(o,r);r=s.inside;let l=e.ownerDocument.createDocumentFragment();for(let c of s.parts){let u=e.ownerDocument.createTextNode(c.text);if(!c.marked){l.append(u);continue}let d=e.ownerDocument.createElement("mark");d.className="weave-replay-mark",d.append(u),l.append(d),i??=d}a.replaceWith(l)}return i}var x_=160,gi=e=>p("svg",{width:"14",height:"14",viewBox:"0 0 18 18","aria-hidden":"true",fill:e.fill?"currentColor":"none",stroke:e.fill?"none":"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",children:p("path",{d:e.d})});function hg(e){let{revisions:t,index:n,playing:r,enabled:i,trimmed:a,error:o}=e.state,s=V(null),l=t===null?0:t.length-1;if(ze(()=>{s.current?.style.setProperty("--weave-replay-at",`${l===0?100:n/l*100}%`)},[n,l]),o!==null)return p("div",{class:"weave-replay weave-replay-note",role:"status",children:o});if(t===null)return p("div",{class:"weave-replay weave-replay-note",role:"status",children:"Loading history…"});let c=qa(t,n);return c===null?p("div",{class:"weave-replay weave-replay-note",role:"status",children:i?ug:Ll}):p("div",{class:"weave-replay",role:"group","aria-label":"Note history",children:[p("p",{class:"weave-replay-caption","aria-live":"polite",children:[p("span",{class:"weave-replay-clock",children:p(gi,{d:"M9 3a6 6 0 1 0 0 12A6 6 0 0 0 9 3zM9 5.5V9l2.5 1.5"})}),p("span",{class:"weave-replay-position",children:["Version ",c.position]}),p("span",{class:`weave-replay-who weave-replay-${c.by}`,children:c.action}),p("span",{class:"weave-replay-time",title:c.atIso,children:c.at}),c.change===""?null:p("span",{class:"weave-replay-change",children:c.change}),a&&n===0?p("span",{class:"weave-replay-time",children:cg}):null]}),p("div",{class:"weave-replay-controls",children:[p("button",{type:"button","aria-label":"Previous version",disabled:n<=0,onClick:()=>e.onIndex(n-1),children:p(gi,{d:"m11 4-5 5 5 5"})}),p("button",{type:"button",class:"weave-replay-play","aria-label":r?"Pause replay":"Play replay",disabled:l===0,onClick:e.onPlay,children:r?p(gi,{d:"M5 4h3v10H5zM10 4h3v10h-3z",fill:!0}):p(gi,{d:"M6 4v10l8-5z",fill:!0})}),p("button",{type:"button","aria-label":"Next version",disabled:n>=l,onClick:()=>e.onIndex(n+1),children:p(gi,{d:"m7 4 5 5-5 5"})}),p("div",{class:"weave-replay-track",ref:s,children:[t.length>x_||l===0?null:p("span",{class:"weave-replay-bars","aria-hidden":"true",style:{"--weave-bars":`${t.length}`},children:ig(t).map((u,d)=>p("span",{style:{"--weave-bar":`${Math.round(u.height*100)}%`,"--weave-bar-at":`${d/l*100}%`},class:`weave-replay-bar weave-replay-${u.by}${d>n?" weave-replay-ahead":""}${d===n?" weave-replay-current":""}`},d))}),l===0?null:p("span",{class:"weave-replay-days","aria-hidden":"true",children:ag(t,e.now).map(u=>p("span",{class:"weave-replay-day",style:{"--weave-day-at":`${u.at*100}%`},children:u.label},u.at))}),p("input",{class:"weave-replay-slider",type:"range","aria-label":"Version","aria-valuetext":`${c.position}: ${c.action}`,min:0,max:l,step:1,value:n,disabled:l===0,onInput:u=>e.onIndex(Number(u.currentTarget.value))})]})]}),i?null:p("p",{class:"weave-replay-hint",children:Ll})]})}var Nl="Editing",vg="Discard changes",wg="Retry",yg="Put this note back the way it was when you started editing?";function k_(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function bg(e){return e.saving?{kind:"saving",label:"Saving…"}:e.failed?{kind:"failed",label:"Not saved"}:e.dirty?{kind:"pending",label:"Unsaved changes"}:e.savedAt!==null?{kind:"saved",label:`Saved ${k_(e.savedAt)}`}:{kind:"clean",label:"No changes yet"}}var Pl=[{kind:"heading",icon:"heading",label:"Heading",key:null},{kind:"bold",icon:"bold",label:"Bold",key:"b"},{kind:"italic",icon:"italic",label:"Italic",key:"i"},{kind:"link",icon:"link",label:"Link",key:null},{kind:"wikilink",icon:"wikilink",label:"Link to a note",key:null},{kind:"task",icon:"task",label:"Task",key:null}];function xg(e){return Pl.find(t=>t.key===e.toLowerCase())?.kind??null}function Ya(e,t,n,r){let i=e.value.slice(e.start,e.end),a=i===""?r:i;return{value:e.value.slice(0,e.start)+t+a+n+e.value.slice(e.end),start:e.start+t.length,end:e.start+t.length+a.length}}function pg(e,t){let n=e.value.lastIndexOf(`
413
+ `,a),l=s===-1?t.length:s,c=t.slice(a,l);if(!y_.test(c)){let u=w_.exec(c)[0].length,d=Math.max(n-a,u),h=Math.min(r,l)-a;for(let f of c.matchAll(b_)){let g=f.index+f[0].length;d>f.index&&d<g&&(d=f.index),h>f.index&&h<g&&(h=g)}c.slice(d,h).trim()!==""&&i.push([a+d,a+h])}a=l+1}let o=t;for(let[s,l]of i.reverse())o=o.slice(0,s)+fi+o.slice(s,l)+ja+o.slice(l);return o}function lg(e,t){let n=[],r="",i=t;for(let a of e)a===fi||a===ja?(r!==""&&n.push({text:r,marked:i}),r="",i=a===fi):r+=a;return r!==""&&n.push({text:r,marked:i}),{parts:n,inside:i}}var k_={human:"You",agent:"Agent",outside:"Outside edit",system:"pi-weave"},__={create:"created the note",edit:"edited",append:"added to the note",raw:"added words to Raw",finalize:"rewrote the summary",generate:"generated the note",repair:"fixed links",outside:"changed outside pi-weave",baseline:"earliest saved version"};function T_(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;let r=n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return t!==null&&new Date(t).toDateString()===n.toDateString()?r:`${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${r}`}function S_(e,t){let{head:n,tail:r}=nr(e);return r!==""&&t>=n.length}function qa(e,t){if(e.length===0)return null;let n=Math.max(0,Math.min(e.length-1,t)),r=e[n],i=n===0?null:e[n-1],a=Nl(i?.body??"",r.body),o=a.end-a.start,s=[o>0?`+${o}`:"",a.removed>0?`−${a.removed}`:""].filter(Boolean).join(" "),l=__[r.op]??r.op;return{position:`${n+1} of ${e.length}`,action:r.op==="baseline"?l[0].toUpperCase()+l.slice(1):`${k_[r.by]} ${l}`,at:T_(r.at,i?.at??null),atIso:r.at,change:s,marked:x_(i?.body??null,r.body),by:r.by,follow:!S_(r.body,a.start)}}var Ll=.14;function cg(e){let t=e.map((r,i)=>{let a=Nl(i===0?"":e[i-1].body,r.body);return a.end-a.start+a.removed}),n=Math.log1p(Math.max(0,...t));return e.map((r,i)=>({height:n===0?Ll:Ll+(1-Ll)*(Math.log1p(t[i])/n),by:r.by}))}function ug(e,t){let n=new Date(t),r=new Date(t-864e5),i=Math.max(1,e.length-1),a=[],o="";return e.forEach((s,l)=>{let c=new Date(s.at);if(Number.isNaN(c.getTime()))return;let u=c.toDateString();if(u===o)return;o=u;let d=u===n.toDateString()?"Today":u===r.toDateString()?"Yesterday":c.toLocaleDateString(void 0,{month:"short",day:"numeric"});a.push({at:e.length===1?0:l/i,label:d})}),a}function dg(e,t){return e+1<t?e+1:null}var hg="History",pg="Close history",Pl="History is off, so new changes are not being saved. Turn it on in Settings → Editor.",fg="Older versions were trimmed",gg="No saved versions yet. Changes are saved from now on.";function mg(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let a=t.nextNode();a!==null;a=t.nextNode())n.push(a);let r=!1,i=null;for(let a of n){let o=a.data;if(!r&&!o.includes(fi)&&!o.includes(ja))continue;let s=lg(o,r);r=s.inside;let l=e.ownerDocument.createDocumentFragment();for(let c of s.parts){let u=e.ownerDocument.createTextNode(c.text);if(!c.marked){l.append(u);continue}let d=e.ownerDocument.createElement("mark");d.className="weave-replay-mark",d.append(u),l.append(d),i??=d}a.replaceWith(l)}return i}var E_=160,gi=e=>p("svg",{width:"14",height:"14",viewBox:"0 0 18 18","aria-hidden":"true",fill:e.fill?"currentColor":"none",stroke:e.fill?"none":"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round",children:p("path",{d:e.d})});function vg(e){let{revisions:t,index:n,playing:r,enabled:i,trimmed:a,error:o}=e.state,s=V(null),l=t===null?0:t.length-1;if(ze(()=>{s.current?.style.setProperty("--weave-replay-at",`${l===0?100:n/l*100}%`)},[n,l]),o!==null)return p("div",{class:"weave-replay weave-replay-note",role:"status",children:o});if(t===null)return p("div",{class:"weave-replay weave-replay-note",role:"status",children:"Loading history…"});let c=qa(t,n);return c===null?p("div",{class:"weave-replay weave-replay-note",role:"status",children:i?gg:Pl}):p("div",{class:"weave-replay",role:"group","aria-label":"Note history",children:[p("p",{class:"weave-replay-caption","aria-live":"polite",children:[p("span",{class:"weave-replay-clock",children:p(gi,{d:"M9 3a6 6 0 1 0 0 12A6 6 0 0 0 9 3zM9 5.5V9l2.5 1.5"})}),p("span",{class:"weave-replay-position",children:["Version ",c.position]}),p("span",{class:`weave-replay-who weave-replay-${c.by}`,children:c.action}),p("span",{class:"weave-replay-time",title:c.atIso,children:c.at}),c.change===""?null:p("span",{class:"weave-replay-change",children:c.change}),a&&n===0?p("span",{class:"weave-replay-time",children:fg}):null]}),p("div",{class:"weave-replay-controls",children:[p("button",{type:"button","aria-label":"Previous version",disabled:n<=0,onClick:()=>e.onIndex(n-1),children:p(gi,{d:"m11 4-5 5 5 5"})}),p("button",{type:"button",class:"weave-replay-play","aria-label":r?"Pause replay":"Play replay",disabled:l===0,onClick:e.onPlay,children:r?p(gi,{d:"M5 4h3v10H5zM10 4h3v10h-3z",fill:!0}):p(gi,{d:"M6 4v10l8-5z",fill:!0})}),p("button",{type:"button","aria-label":"Next version",disabled:n>=l,onClick:()=>e.onIndex(n+1),children:p(gi,{d:"m7 4 5 5-5 5"})}),p("div",{class:"weave-replay-track",ref:s,children:[t.length>E_||l===0?null:p("span",{class:"weave-replay-bars","aria-hidden":"true",style:{"--weave-bars":`${t.length}`},children:cg(t).map((u,d)=>p("span",{style:{"--weave-bar":`${Math.round(u.height*100)}%`,"--weave-bar-at":`${d/l*100}%`},class:`weave-replay-bar weave-replay-${u.by}${d>n?" weave-replay-ahead":""}${d===n?" weave-replay-current":""}`},d))}),l===0?null:p("span",{class:"weave-replay-days","aria-hidden":"true",children:ug(t,e.now).map(u=>p("span",{class:"weave-replay-day",style:{"--weave-day-at":`${u.at*100}%`},children:u.label},u.at))}),p("input",{class:"weave-replay-slider",type:"range","aria-label":"Version","aria-valuetext":`${c.position}: ${c.action}`,min:0,max:l,step:1,value:n,disabled:l===0,onInput:u=>e.onIndex(Number(u.currentTarget.value))})]})]}),i?null:p("p",{class:"weave-replay-hint",children:Pl})]})}var Dl="Editing",kg="Discard changes",_g="Retry",Tg="Put this note back the way it was when you started editing?";function R_(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function Sg(e){return e.saving?{kind:"saving",label:"Saving…"}:e.failed?{kind:"failed",label:"Not saved"}:e.dirty?{kind:"pending",label:"Unsaved changes"}:e.savedAt!==null?{kind:"saved",label:`Saved ${R_(e.savedAt)}`}:{kind:"clean",label:"No changes yet"}}var Il=[{kind:"heading",icon:"heading",label:"Heading",key:null},{kind:"bold",icon:"bold",label:"Bold",key:"b"},{kind:"italic",icon:"italic",label:"Italic",key:"i"},{kind:"link",icon:"link",label:"Link",key:null},{kind:"wikilink",icon:"wikilink",label:"Link to a note",key:null},{kind:"task",icon:"task",label:"Task",key:null}];function Eg(e){return Il.find(t=>t.key===e.toLowerCase())?.kind??null}function Ya(e,t,n,r){let i=e.value.slice(e.start,e.end),a=i===""?r:i;return{value:e.value.slice(0,e.start)+t+a+n+e.value.slice(e.end),start:e.start+t.length,end:e.start+t.length+a.length}}function wg(e,t){let n=e.value.lastIndexOf(`
414
414
  `,e.start-1)+1,r=e.end>e.start&&e.value[e.end-1]===`
415
415
  `?e.end-1:e.end,i=e.value.indexOf(`
416
416
  `,r),a=i===-1?e.value.length:i,o=e.value.slice(n,a).split(`
417
417
  `).map(t).join(`
418
- `);return{value:e.value.slice(0,n)+o+e.value.slice(a),start:n,end:n+o.length}}var fg=/^#{1,6}[ \t]+/,gg=/^([ \t]*)[-*+][ \t]+\[[ xX]\][ \t]+/,mg=/^([ \t]*)[-*+][ \t]+/;function kg(e,t){switch(t){case"bold":return Ya(e,"**","**","bold text");case"italic":return Ya(e,"_","_","italic text");case"wikilink":return Ya(e,"[[","]]","note title");case"link":{let n=e.value.slice(e.start,e.end);if(n==="")return Ya(e,"[","](https://)","link text");let r=`${e.value.slice(0,e.start)}[${n}](https://)${e.value.slice(e.end)}`,i=e.start+n.length+3;return{value:r,start:i,end:i+8}}case"heading":return pg(e,n=>fg.test(n)?n.replace(fg,""):`## ${n}`);case"task":return pg(e,n=>gg.test(n)?n.replace(gg,"$1"):mg.test(n)?n.replace(mg,"$1- [ ] "):`- [ ] ${n}`)}}function _g(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;let i=0;for(;i<n-r&&e.charCodeAt(e.length-1-i)===t.charCodeAt(t.length-1-i);)i++;return{start:r,end:e.length-i,text:t.slice(r,t.length-i)}}var T_="weave-preview-x",S_="weave-preview-y";function E_({view:e,open:t,editing:n,taskSaving:r,onEdit:i,replaying:a,onHistory:o}){return p("header",{class:"weave-note-head",children:[p("p",{class:"weave-note-crumb",children:[p(ce,{name:"folder",class:"weave-icon"}),e.folder]}),p("h3",{class:"weave-note-title",children:e.title}),n?null:p("p",{class:"weave-note-meta",children:[p("span",{class:`weave-prov weave-prov-${e.provenance}`,title:e.provenanceTitle,children:[p("span",{class:"weave-prov-dot","aria-hidden":"true"}),e.byline]}),p("span",{class:"weave-note-time",title:`${mh} ${e.created} · ${e.createdIso}`,children:[gh," ",e.updated]}),p("span",{class:"weave-note-actions",children:[o===null?null:p("button",{type:"button",class:"weave-note-action weave-note-history","aria-pressed":a,onClick:o,children:[p(ce,{name:"history",class:"weave-icon"}),a?lg:sg]}),a?null:p("button",{type:"button",class:"weave-note-action weave-note-edit",disabled:r,onClick:i,children:[p(ce,{name:"edit",class:"weave-icon"}),vh]}),p("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:t,children:p("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})})]})]}),e.tags.length===0?null:p("p",{class:"weave-note-tags",children:e.tags.map(s=>p("span",{class:"weave-tag",children:Eh(s)},s))})]})}function R_({status:e,busy:t,onFormat:n,onRetry:r,onDiscard:i,onDone:a}){return p("div",{class:"weave-editbar",role:"toolbar","aria-label":Nl,children:[p("span",{class:"weave-editbar-badge",children:[p(ce,{name:"edit",class:"weave-icon"}),Nl]}),p("span",{class:"weave-editbar-tools",children:Pl.map(o=>p("button",{type:"button",class:"weave-editbar-tool",title:o.key===null?o.label:`${o.label} (⌘${o.key.toUpperCase()})`,"aria-label":o.label,onMouseDown:s=>s.preventDefault(),onClick:()=>n(o.kind),children:p(ce,{name:o.icon,class:"weave-icon"})},o.kind))}),p("span",{class:`weave-editbar-status weave-editbar-${e.kind}`,role:"status",children:[e.kind==="saved"?p(ce,{name:"check",class:"weave-icon"}):null,e.label,e.kind==="failed"?p("button",{type:"button",class:"weave-editbar-retry",onClick:r,children:wg}):null]}),p("button",{type:"button",class:"weave-editbar-discard",disabled:t||e.kind==="saving",onClick:i,children:vg}),p("button",{type:"button",class:"weave-editbar-done",disabled:t,onClick:a,children:wh})]})}function Tg(e){let t=V(Va()),n=e.drafts??t.current,r=Rc(),i=`${e.idPrefix??r}-weave-preview`,[a,o]=K(0);ne(()=>n.subscribe(()=>o(L=>L+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),c=lh(e.graph,e.selectedId),u=Lh(e.selectedId,s,e.loadFailed),d=De(()=>s===null?null:ch(e.graph,s.slug),[s,e.graph]),h=De(()=>s===null||d===null?"":Ns(Rl,l,d),[s,l,d]),[f,g]=K(va),w=L=>{g(W=>Ch(W,L))},v=V(null),y=V(null),b=V(null),_=V(!1),x=s===null?null:n.get(s.slug),[C,O]=K(!1),N=s!==null&&n.isTaskSaving(s.slug),j=()=>{s!==null&&!n.isTaskSaving(s.slug)&&n.save(s.slug,e.onSave,{keepOpen:!0})},P=async(L,W)=>{let te=()=>{L.checked=!L.checked,L.setAttribute("aria-label",wa(L.checked))};if(s===null||n.isTaskSaving(s.slug)){te();return}let ge=dh(n.getTaskBody(s.slug,s.body),W);if(ge===null){te();return}let Fe=[...v.current?.querySelectorAll(`input[${$n}]`)??[]];L.setAttribute("aria-label",wa(L.checked));for(let wt of Fe)wt.disabled=!0;try{await n.saveTask(s.slug,ge,e.onSave)||te()}catch(wt){throw te(),wt}finally{for(let wt of Fe)wt.disabled=n.isTaskSaving(s.slug)}},R=V(null);ne(()=>{s!==null&&R.current!==s.slug&&(R.current=s.slug,e.defaultEdit&&n.get(s.slug)===null&&(_.current=!0,n.open(s.slug,l)))},[s?.slug,e.defaultEdit]);let H=()=>{s===null||n.isTaskSaving(s.slug)||n.get(s.slug)!==null||(_.current=!0,n.open(s.slug,l))},Z=V(!1),G=()=>{if(!(s===null||x===null||n.isTaskSaving(s.slug))){if(x.saving){Z.current=!0;return}Z.current=!1,n.isDirty(s.slug)?n.save(s.slug,e.onSave):n.discard(s.slug)}},J=()=>{if(s===null||x===null||x.saving)return;if(Z.current=!1,x.baseline!==x.original||x.rawBaseline!==x.originalRaw){if(!window.confirm(yg))return;n.revert(s.slug)?n.save(s.slug,e.onSave):n.discard(s.slug)}else(!n.isDirty(s.slug)||window.confirm(ya))&&n.discard(s.slug)},X=V(null),se=V("body"),Ye=L=>{if(s===null)return;let W=se.current==="raw"&&X.current!==null,te=W?X.current:b.current;if(te===null)return;let ge=kg({value:te.value,start:te.selectionStart,end:te.selectionEnd},L),Fe=_g(te.value,ge.value);te.focus(),te.setSelectionRange(Fe.start,Fe.end),(!(typeof document.execCommand=="function"&&document.execCommand(Fe.text===""?"delete":"insertText",!1,Fe.text))||te.value!==ge.value)&&(te.value=ge.value),W?n.editRaw(s.slug,ge.value):n.edit(s.slug,ge.value),te.setSelectionRange(ge.start,ge.end)},Ae=L=>{if(L.key==="Escape"){L.stopPropagation(),G();return}if(!(L.metaKey||L.ctrlKey)||L.altKey)return;if(L.key.toLowerCase()==="s"){L.preventDefault(),s!==null&&n.isDirty(s.slug)&&j();return}let W=xg(L.key);W===null||L.shiftKey||(L.preventDefault(),Ye(W))};ne(()=>{if(s===null||x===null||x.saving||x.failed||!n.isDirty(s.slug))return;let L=window.setTimeout(j,2500);return()=>window.clearTimeout(L)},[s?.slug,x,x?.body,x?.raw,x?.saving,x?.failed]),ne(()=>{Z.current&&x!==null&&!x.saving&&G()},[x?.saving]);let we=f.anchor===null?null:Rh(e.graph,f.anchor);ze(()=>{let L=b.current;L===null||!_.current||(_.current=!1,L.focus(),L.setSelectionRange(L.value.length,L.value.length))},[x!==null]);let[ue,Te]=K(null),ct=V(null),Pe=e.onHistory,oe=()=>{if(s===null||Pe===void 0)return;if(ue!==null){ct.current=null,Te(null);return}let L=s.slug;ct.current=L,Te({revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:null}),Pe(L).then(W=>{ct.current===L&&Te(W.ok?{revisions:W.data.revisions,enabled:W.data.enabled,trimmed:W.data.trimmed,index:Math.max(0,W.data.revisions.length-1),playing:!1,error:null}:{revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:`Could not load history: ${W.message}`})})},Se=ue?.revisions==null?null:qa(ue.revisions,ue.index),ut=De(()=>Se===null||d===null?null:Ns(Rl,Se.marked,d),[Se?.marked,d]);if(ze(()=>{ct.current=null,Te(null),O(!1)},[s===null?null:s.slug]),ze(()=>{if(ut===null||v.current===null)return;let L=dg(v.current);Se?.follow&&L?.scrollIntoView?.({block:"nearest"})},[ut]),ne(()=>{if(ue===null||!ue.playing||ue.revisions===null)return;let L=ue.revisions.length,W=window.setTimeout(()=>{Te(te=>{if(te===null)return te;let ge=og(te.index,L);return ge===null?{...te,playing:!1}:{...te,index:ge}})},ng);return()=>window.clearTimeout(W)},[ue]),ze(()=>{s!==null&&(n.taskBody(s.slug,s.body,e.loadVersion),n.syncTail(s.slug,s.body))},[n,s===null?null:s.slug,s?.body,e.loadVersion]),ze(()=>{w({type:"hide"})},[s===null?null:s.slug]),ze(()=>{if(s===null)return;let L=n.isTaskSaving(s.slug);for(let W of v.current?.querySelectorAll(`input[${$n}]`)??[])W.disabled=L},[s===null?null:s.slug,a,h]),ze(()=>{let L=v.current;if(L!==null){let ge=f.anchor?.slug??null;for(let Fe of L.querySelectorAll(`a[${Vt}]`))ge!==null&&Fe.getAttribute(Vt)===ge?Fe.setAttribute("aria-describedby",i):Fe.removeAttribute("aria-describedby")}let W=y.current;if(W===null||we===null)return;let te=Ah(f.pointerX,f.pointerY,W.offsetWidth,W.offsetHeight,window.innerWidth,window.innerHeight);W.style.setProperty(`--${T_}`,`${te.x}px`),W.style.setProperty(`--${S_}`,`${te.y}px`)},[f,we,i]),c!==null){let L=e.graph?.model.nodes.find(ge=>ge.id===e.selectedId),W=L?.label??c,te=L===void 0?c:sh(L)??c;return p("article",{class:"weave-note weave-note-artifact",children:[p("header",{class:"weave-note-head",children:[p("h3",{class:"weave-note-title",children:W}),p("p",{class:"weave-note-meta",children:p("span",{class:"weave-note-time",children:c})})]}),p("iframe",{class:"weave-artifact-frame",title:W,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(c)}`},te)]},te)}if(s===null||d===null)return p("p",{class:"weave-note-empty",children:u});let Nt=Sh(s,e.now);return p("article",{class:`weave-note weave-note-${Nt.provenance}`,children:[x===null?null:p(R_,{status:bg({saving:x.saving,failed:x.failed,dirty:n.isDirty(s.slug),savedAt:x.savedAt}),busy:N,onFormat:Ye,onRetry:j,onDiscard:J,onDone:G}),p(E_,{view:Nt,open:()=>e.onOpen(s.slug),editing:x!==null,taskSaving:N,onEdit:H,replaying:ue!==null,onHistory:Pe===void 0?null:oe}),ue===null?null:p(hg,{state:ue,now:e.now,onIndex:L=>Te(W=>W===null?W:{...W,index:L,playing:!1}),onPlay:()=>Te(L=>{if(L===null||L.revisions===null)return L;if(L.playing)return{...L,playing:!1};let W=L.index>=L.revisions.length-1;return{...L,index:W?0:L.index,playing:!0}})}),x!==null?p(be,{children:[p("textarea",{ref:b,class:"weave-note-editor","aria-label":yh,placeholder:bh,spellcheck:e.spellcheck??!0,value:x.body,onInput:L=>n.edit(s.slug,L.target.value),onFocus:()=>{se.current="body"},onKeyDown:Ae}),x.tail===""?null:p("section",{class:"weave-raw","aria-label":xh,"data-open":C?"":void 0,children:[p("div",{class:"weave-raw-head",children:[p("button",{type:"button",class:"weave-raw-toggle","aria-expanded":C,"aria-controls":`${e.idPrefix??r}-weave-raw`,onClick:()=>O(L=>!L),children:[p("svg",{class:"weave-raw-chevron",width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:p("path",{d:"M4.5 2.5 8 6l-3.5 3.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})}),_h]}),p("span",{class:"weave-raw-hint",children:Th(x.raw,C)})]}),C?p("textarea",{id:`${e.idPrefix??r}-weave-raw`,class:"weave-raw-editor","aria-label":kh,spellcheck:e.spellcheck??!0,value:x.raw,ref:X,onInput:L=>n.editRaw(s.slug,L.target.value),onFocus:()=>{se.current="raw"},onKeyDown:Ae}):null]})]}):p("div",{ref:v,class:"weave-note-body",tabIndex:-1,onMouseOver:L=>{let W=Ds(L.target);w(W!==null?{type:"show",anchor:W,x:L.clientX,y:L.clientY}:{type:"hide"})},onMouseLeave:()=>w({type:"hide"}),onFocus:L=>{let W=Ds(L.target);if(W===null)return;let te=L.target.getBoundingClientRect?.();w({type:"show",anchor:W,x:te?.left??0,y:te?.bottom??0})},onBlur:()=>w({type:"hide"}),onClick:L=>{let W=L.target,te=hh(W);if(te!==null&&ut!==null){L.preventDefault();return}if(te!==null){P(W,te);return}let ge=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(fh(ge))return;let Fe=Ps(L.target);Fe!==null&&e.onSelect(Fe,L.metaKey||L.ctrlKey||L.shiftKey)},onKeyDown:L=>{if(L.key==="Escape"&&f.anchor!==null){L.stopPropagation(),w({type:"dismiss"});return}if(L.key!=="Enter"&&L.key!==" ")return;let W=Ps(L.target);W!==null&&(L.preventDefault(),e.onSelect(W,L.metaKey||L.ctrlKey||L.shiftKey))},dangerouslySetInnerHTML:{__html:ut??h}}),we===null?null:p("div",{ref:y,id:i,role:"tooltip",class:`weave-preview${we.ghost?" weave-preview-ghost":""}`,children:[p("span",{class:"weave-preview-kind",children:we.kind}),p("span",{class:"weave-preview-title",children:we.title}),we.text===""?null:p("p",{class:"weave-preview-text",children:we.text})]})]},s.slug)}var Sg=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Eg(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 Rg(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Ag(e){return e===null?!1:(e.focus(),!0)}function br(){let e=V(null);return ne(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Ag(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Rg(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Sg)??[]],r=Eg(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}var Cg=20,A_=10,Pg=140,Dg=["notes","code","tags"],C_=["all",...Dg],Lg={all:"All",notes:"Notes",code:"Code",tags:"Tags"},L_=["note:","vfolder:","artifact:"];function Xa(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.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 N_(e){return Math.min(Math.max(e,0),A_)*2}function P_(e){return`note:${e}`}function D_(e,t){return Xa(e.summary.title,t)+N_(e.score)}function I_(e,t){return Xa(e.label,t)}var M_=["path","manifest","url","slug"];function G_(e){for(let t of M_){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}var O_=["preview","summary","description"];function F_(e){for(let n of O_){let r=e.detail[n];if(typeof r=="string"&&r)return r}let t=G_(e);return t===e.label?"":t}var $_={entryPoint:"entry point",gitState:"git",external:"remote"};function z_(e){return e.id.startsWith("vfolder:")?"folder":e.id.startsWith("artifact:")?"artifact":$_[e.kind]??e.kind}function H_(e){return e.kind==="vault"||L_.some(t=>e.id.startsWith(t))?"notes":"code"}function Ig(e){return e.id.startsWith("note:")?e.id.slice(5):e.id.startsWith("artifact:")?e.id.slice(9):""}function W_(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 Gl(e){let t=e.trim();return t.startsWith("#")?t.slice(1).trim():null}function Ol(e){return Gl(e)===null?e.trim():""}function U_(e){return e===1?"1 note":`${e} notes`}function B_(e,t){let n=Gl(t),r=[];for(let[i,a]of Object.entries(e)){let o=n===""?1:Xa(i,n??t);o&&r.push({id:`tag:${i}`,kind:"tag",group:"tags",icon:"tag",label:`#${i}`,detail:U_(a.length),badge:"tag",score:o,path:"",updated:""})}return r.sort((i,a)=>a.score-i.score)}function K_(e,t){let n=new Map;for(let[r,i]of Object.entries(e)){let a=Xa(r,t);if(a)for(let o of i)n.set(o,Math.max(a,n.get(o)??0))}return n}function V_(e,t){let{slug:n,title:r,updated:i}=e.summary;return{id:P_(n),kind:"note",group:"notes",icon:"note",label:r,detail:e.snippet,badge:"note",score:D_(e,t),path:n,updated:i}}function j_(e,t){return{id:e.id,kind:"node",group:H_(e),icon:e.kind,label:e.label,detail:F_(e),badge:z_(e),score:t,path:Ig(e),updated:e.detail.updated??""}}function Mg(e,t,n,r,i={}){let a=Gl(r),o=a?K_(i,a):new Map,s=new Map;for(let u of e){let d=V_(u,t);s.set(d.id,d)}for(let u of n){if(s.has(u.id))continue;let d=a===null?I_(u,r):u.kind==="note"?o.get(Ig(u))??0:0;d&&s.set(u.id,j_(u,d))}let l=[...s.values()].sort(W_),c=u=>l.filter(d=>d.group===u).slice(0,Cg);return[...c("notes"),...c("code"),...B_(i,r).slice(0,Cg)]}var q_=/(?:\*\*|__)TL;?DR[ \t]*:?[ \t]*(?:\*\*|__)[ \t]*:?|\bTL;?DR[ \t]*:/i;function Y_(e){let t=q_.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=n.search(/\n[ \t]*\n|(?:^|\s)#{1,6}\s/),i=(r<0?n:n.slice(0,r)).trim();return i===""?null:i}var Za="\0";function Z_(e){let t=[];return e.replace(/`{3,}[^\s`]*/g," ").replace(/`([^`\n]*)`/g,(n,r)=>`${Za}${t.push(r)-1}${Za}`).replace(/!?\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/g,(n,r,i)=>(i||r).trim()).replace(/^(…?)(?:[^[\]|]*\|)?([^[\]]*)\]\]/,"$1$2").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?$/,(n,r,i)=>i||r).replace(/\[\[|\]\]/g,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/<\/?[a-z][^>]*>/gi," ").replace(/(^|\s)#{1,6}(?=\s)/g,"$1").replace(/(^|\n)[ \t]*>[ \t]?/g,"$1").replace(/(^|\s)([-*_])(?:[ \t]?\2){2,}(?=\s|$)/g,"$1").replace(/(^|\s)[-*+][ \t]+\[[ xX]\][ \t]*/g,"$1").replace(/(^|\n)[ \t]*(?:[-*+]|\d+[.)])[ \t]+/g,"$1").replace(/(\s)\*(?=\s)/g,"$1").replace(/(\*\*|~~)(?=\S)([\s\S]*?\S)\1/g,"$2").replace(/(^|[^\w])__(?=\S)([\s\S]*?\S)__(?!\w)/g,"$1$2").replace(/(^|[^\w*])\*(?=\S)([^*\n]*?\S)\*(?![\w*])/g,"$1$2").replace(/(^|[^\w])_(?=\S)([^_\n]*?\S)_(?!\w)/g,"$1$2").replace(/\*{2,}|~~/g,"").replace(/\\([\\`*_#[\]|])/g,"$1").replace(new RegExp(`${Za}(\\d+)${Za}`,"g"),(n,r)=>t[Number(r)]).replace(/\s+/g," ").trim()}function X_(e){return Z_(Y_(e)??e)}var Q_=2;function J_(e){let t=e.trim().replace(/^#/,"").trim();return t?[...new Set([t,...t.split(/\s+/).filter(n=>n.length>=Q_)])]:[]}function eT(e,t){let n=[];for(let i of J_(t)){let a=new RegExp(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi");for(let o of e.matchAll(a))n.push([o.index,o.index+o[0].length])}n.sort((i,a)=>i[0]-a[0]||i[1]-a[1]);let r=[];for(let i of n){let a=r[r.length-1];a!==void 0&&i[0]<=a[1]?a[1]=Math.max(a[1],i[1]):r.push(i)}return r}var tT=40,nT=16;function Ng(e,t){let n=[],r=0;for(let[i,a]of t)i>r&&n.push({text:e.slice(r,i),mark:!1}),n.push({text:e.slice(i,a),mark:!0}),r=a;return r<e.length&&n.push({text:e.slice(r),mark:!1}),n}function rT(e,t){let n=X_(e),r=eT(n,t),i=r[0];if(i===void 0||i[0]<=tT)return Ng(n,r);let a=i[0]-nT,o=n.indexOf(" ",a),s=o>=0&&o<i[0]?o+1:a,l=s-1;return Ng(`…${n.slice(s)}`,r.map(([c,u])=>[c-l,u-l]))}function iT(e){return e.split("/").slice(0,-1).join("/")}function aT(e,t){return Wt(e,t).replace(/ ago$/,"")}function oT(e,t){return e.kind==="tag"?"":e.updated?[iT(e.path),aT(e.updated,t)].filter(n=>n!=="").join(" · "):e.badge}var Gg={d:["M11.25 7a4.25 4.25 0 1 1-8.5 0 4.25 4.25 0 0 1 8.5 0Z","M10.25 10.25 13.5 13.5"],filled:!1},sT={d:["M2.75 2.75h5l5.5 5.5-5 5-5.5-5.5Z","M5.5 5.5h.01"],filled:!1};function lT(e){return e==="tag"?sT:ka[e]}function Og(){return{query:"",answered:"",hits:[],cursor:0,scope:"all",loading:!1,failed:!1}}function Dl(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Il(e,t,n){return n<=0?0:((e+t)%n+n)%n}function cT(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Dl(e,n);return t==="ArrowDown"?{...r,cursor:Il(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Il(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Dl(n-1,n),handled:!0}:t==="Escape"?{...r,dismiss:!0,handled:!0}:t!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}function uT(e){let t=n=>e.filter(r=>r.group===n).length;return{all:e.length,notes:t("notes"),code:t("code"),tags:t("tags")}}function Fg(e){return C_.filter(t=>t==="all"||e[t]>0)}function dT(e,t){return Fg(t).includes(e)?e:"all"}function hT(e,t,n){return e[Il(Math.max(e.indexOf(t),0),n?-1:1,e.length)]??"all"}var Qa="Search the workspace",$g="Search notes and repository…",zg="↑↓ move · ↵ open · ⌘↵ open in new tab · Tab scope",Hg="Search scope",Wg="⇧↵";function Ug(e){return`Light up ${e} in the graph`}function pT(e,t){return e.query.trim()?t>0?null:e.failed?"search failed — the workspace server may be gone":e.loading?"searching…":`no matches for “${e.query.trim()}”`:"Type to search notes and code. Start with # to find tags."}function Bg(e){return`weave-search-row-${e}`}function fT(e){return`weave-search-group-${e}`}function gT(e,t,n,r,i){return{id:e.id,kind:e.kind,group:e.group,label:e.label,icon:lT(e.icon),mono:e.group==="code",parts:rT(e.detail,r),meta:oT(e,i),active:t===n,domId:Bg(t),index:t}}function mT(e,t,n){return(e.answered===Ol(e.query)?n:Mg([],"",t?.model.nodes??[],e.query,t?.tags??{})).filter(i=>i.kind!=="tag").map(i=>i.id)}function Kg(e,t,n){let r=e.query.trim(),i=Mg(e.hits,e.answered,t?.model.nodes??[],e.query,t?.tags??{}),a=uT(i),o=dT(e.scope,a),s=o==="all"?i:i.filter(h=>h.group===o),l=Dl(e.cursor,s.length),c=s.map((h,f)=>gT(h,f,l,e.query,n)),u=Dg.flatMap(h=>{let f=c.filter(g=>g.group===h);return f.length?[{group:h,heading:`${Lg[h]} · ${f.length}`,domId:fT(h),rows:f}]:[]}),d=r?Fg(a).map(h=>({scope:h,label:Lg[h],count:a[h],active:h===o})):[];return{groups:u,rows:c,scopes:d,scope:o,status:pT(e,s.length),count:s.length,cursor:l,activeDomId:c.length?Bg(l):null,query:r,lightUp:mT(e,t,i)}}var Ml={type:"none"};function Fl(e,t){return e.kind==="tag"?{type:"tag",query:`#${e.id.slice(4)}`}:{type:"open",id:e.id,newTab:t}}function $l(e){return e.query&&e.lightUp.length>0?{type:"lightUp",query:e.query,ids:e.lightUp}:Ml}function Vg(e,t,n){if(t.key==="Tab")return!t.inInput||t.mod||e.scopes.length<2?Ml:{type:"scope",scope:hT(e.scopes.map(i=>i.scope),e.scope,t.shift)};if(t.key==="Enter"&&t.shift&&n)return $l(e);let r=cT(e.cursor,t.key,e.count);return r.handled?r.activate!==null?Fl(e.rows[r.activate],t.mod):r.dismiss?{type:"close"}:{type:"move",cursor:r.cursor}:Ml}function jg(e,t){return t.type==="move"?t.cursor===e.cursor?e:{...e,cursor:t.cursor}:t.type==="scope"?{...e,scope:t.scope,cursor:0}:t.type==="tag"?{...e,query:t.query,scope:"notes",cursor:0}:e}function qg(e){return e.type==="open"||e.type==="lightUp"||e.type==="close"}function Yg({def:e,class:t}){return p("svg",{class:t,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:e.filled?"currentColor":"none",stroke:e.filled?void 0:"currentColor","stroke-width":e.filled?void 0:e.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:e.d.map(n=>p("path",{d:n}))})}function vT({row:e,onPick:t,onHover:n}){return p("li",{id:e.domId,role:"option","aria-selected":e.active,class:`weave-hit weave-hit-${e.group}${e.active?" weave-hit-on":""}`,onMouseMove:n,onClick:r=>t(r.metaKey||r.ctrlKey),children:[p(Yg,{def:e.icon,class:"weave-icon weave-hit-icon"}),p("span",{class:e.mono?"weave-hit-label weave-hit-mono":"weave-hit-label",children:e.label}),p("span",{class:"weave-hit-detail",children:e.parts.map(r=>r.mark?p("mark",{class:"weave-hit-mark",children:r.text}):r.text)}),e.meta?p("span",{class:"weave-hit-meta",children:e.meta}):null]})}function Zg(e){let[t,n]=K(Og),r=V(0),i=V(null),a=br(),o=V(null);ne(()=>{o.current?.focus()},[]),ne(()=>{let c=Ol(t.query),u=!0;if(!c)return i.current?.abort(),n(h=>({...h,hits:[],answered:"",loading:!1,failed:!1})),()=>{u=!1};let d=window.setTimeout(async()=>{let h=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(w=>({...w,loading:!0,failed:!1}));let g=await Vc(e.ports.fetch,c,f.signal);!u||f.signal.aborted||h!==r.current||n(w=>g.ok?{...w,hits:g.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...w,loading:!1,failed:!0})},Pg);return()=>{u=!1,window.clearTimeout(d),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Kg(t,e.graph,Date.now()),l=c=>{c.type==="open"&&e.onSelect(c.id,c.newTab),c.type==="lightUp"&&e.onLightUp?.(c.query,c.ids),qg(c)?e.onClose():n(u=>jg(u,c)),(c.type==="scope"||c.type==="tag")&&o.current?.focus()};return p("div",{class:"weave-scrim",onClick:()=>l({type:"close"}),children:p("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Qa,tabIndex:-1,ref:a.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{let u=Vg(s,{key:c.key,shift:c.shiftKey,mod:c.metaKey||c.ctrlKey,inInput:c.target===o.current},e.onLightUp!==void 0);if(u.type==="none"){a.onKeyDown(c);return}c.preventDefault(),l(u)},children:[p("div",{class:"weave-palette-bar",children:[p(Yg,{def:Gg,class:"weave-icon weave-palette-glyph"}),p("input",{type:"search",class:"weave-palette-input",ref:o,value:t.query,placeholder:$g,role:"combobox","aria-label":Qa,"aria-expanded":s.count>0,"aria-autocomplete":"list","aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:c=>n(u=>({...u,query:c.currentTarget.value,cursor:0}))}),p("kbd",{class:"weave-palette-kbd","aria-hidden":"true",children:"Esc"})]}),s.scopes.length?p("div",{class:"weave-palette-scopes",role:"group","aria-label":Hg,children:s.scopes.map(c=>p("button",{type:"button",class:"weave-palette-scope","aria-pressed":c.active,onClick:()=>l({type:"scope",scope:c.scope}),children:[c.label," ",p("span",{class:"weave-palette-scope-count",children:c.count})]},c.scope))}):null,s.status===null?p("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Qa,children:s.groups.map(c=>p("li",{role:"presentation",class:"weave-hit-section",children:[p("div",{id:c.domId,role:"presentation",class:"weave-hit-group",children:c.heading}),p("ul",{role:"group","aria-labelledby":c.domId,class:"weave-hit-rows",children:c.rows.map(u=>p(vT,{row:u,onPick:d=>l(Fl(u,d)),onHover:()=>l({type:"move",cursor:u.index})},u.id))})]},c.group))}):p("p",{class:"weave-palette-status",role:"status",children:s.status}),p("p",{class:"weave-palette-foot",children:[p("span",{children:zg}),e.onLightUp&&s.lightUp.length>0?p("button",{type:"button",class:"weave-palette-light",onClick:()=>l($l(s)),children:[Ug(s.lightUp.length)," ",p("kbd",{class:"weave-palette-kbd",children:Wg})]}):null]})]})})}function zl(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Ja=2e3,wT=3e3,Qg=new Set;function yT(e,t){if(e===null)return Qg;let n=new Set(e.model.nodes.map(r=>r.id));return new Set(t.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function Xg(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function Jg(e){let t=e.state,n=!1,r=!1,i=null,a=h=>{Object.entries(h).every(([f,g])=>t[f]===g)||(t={...t,...h},e.setState(t))},o=e.defer??((h,f)=>{let g=setTimeout(h,f);return()=>clearTimeout(g)}),s=async()=>{let h=Xg(t.selectedId);if(h===null){a({note:null,noteFailed:!1});return}let f=await Fo(e.fetch,h);f.ok?a({note:f.data,noteFailed:!1}):a({note:null,noteFailed:!0})},l=async()=>{let h=t.graph,f=await qi(e.fetch,t.graph);if(!f.ok)return t.graph===null&&a({graphFailed:!0}),f;if(!f.cached){let g=yT(h,f.data);a({graph:f.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=o(()=>{i=null,a({recentIds:Qg})},wT))}return f},c=async()=>{if(!(n||r)){r=!0;try{let h=await l();Xg(t.selectedId)!==null&&(t.note===null||h.ok&&!h.cached)&&await s()}finally{r=!1}}},d=(e.repeat??((h,f)=>{let g=setInterval(h,f);return()=>clearInterval(g)}))(()=>{c()},Ja);return c(),{refresh:()=>{c()},select:async h=>{a({selectedId:h}),await s()},syncNote:s,stop:()=>{n||(n=!0,d(),i?.(),i=null)}}}function em(e,t,n,r=(i,a)=>{let o=setTimeout(i,a);return()=>clearTimeout(o)}){let i=!1,a=null,o=async()=>{if(i)return;let s=await Fo(e,t);i||(n(s),s.ok||(a=r(()=>{o()},Ja)))};return o(),()=>{i=!0,a?.()}}var mi={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function to(e,t,n){return{id:e,target:t.id,label:pt(t),kind:t.kind,kindIcon:Pn(t.kind),provenance:t.provenance,provenanceGlyph:Ut(t.provenance),provenanceTitle:cn(t.provenance),selected:t.id===n}}function bT(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:to(e.id,i,n)}function xT(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var kT=["link:links-to:"];function _T(e){return kT.some(t=>e.id.startsWith(t))}function TT(e){return e.id.startsWith("link:mentions:")}function ST(e,t,n,r){let i=[];for(let[a,o]of Object.entries(e.tags)){if(!o.includes(t))continue;let s=[];for(let l of o){if(l===t)continue;let c=n.get(`note:${l}`);c!==void 0&&s.push(to(`tag:${a}:${l}`,c,r))}i.push({tag:a,count:o.length,siblings:s})}return i}function ET(e,t,n,r){let i=[];for(let a of e.edges){if(a.kind!=="mentions"||a.target!==t)continue;let o=n.get(a.source);o!==void 0&&i.push(to(`mentioned-by:${a.source}`,o,r))}return i}function RT(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var eo={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 Hl(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function tm(e){return e.groups.reduce((t,n)=>t+n.count,0)+e.tagsCount}function no(e,t){if(e===null)return Hl(eo.loading);if(t===null)return Hl(eo.noSelection);let n=Ln(e),r=Vo(n,t);if(r===null)return Hl(eo.unknown);let i=xT(n),a=[],o=(d,h)=>{h.length>0&&a.push({heading:d,count:h.length,rows:h})},s=d=>d.map(h=>bT(h,i,t)).filter(h=>h!==null);o(mi.links,s(r.links.filter(_T)));let l=jo(n.edges).get(t)??[];o(mi.backlinks,l.map(d=>i.get(d)).filter(d=>d!==void 0).map(d=>to(`backlink:${d.id}`,d,t))),o(mi.mentions,[...s(r.links.filter(TT)),...ET(n,t,i,t)]);let c=RT(t),u=c===null?[]:ST(e,c,i,t);return a.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:eo.isolated}:{subject:r.label,groups:a,tags:u,tagsCount:u.length,empty:null}}function nm(){return{open:new Set,closed:new Set}}var AT=8;function rm(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>AT}function CT(e){return e.some(t=>t.selected)}function im(e,t){let n=rm(t,e.heading,e.count,CT(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function am(e,t){let n=rm(t,mi.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:mi.tags,count:e.length,collapsed:n,rows:[]}}function om(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 ro(e){return`weave-ctx-panel-${e.toLowerCase()}`}function Kn(e){let t=V(null);return p("div",{class:"weave-workspace-divider",role:"separator",tabIndex:0,"aria-label":e.label,"aria-orientation":e.horizontal?"horizontal":"vertical","aria-valuenow":Math.round(e.value),"aria-valuemin":e.min,"aria-valuemax":e.max,onPointerDown:n=>{t.current=e.horizontal?n.clientY:n.clientX,n.currentTarget.setPointerCapture(n.pointerId)},onPointerMove:n=>{if(t.current===null)return;let r=e.horizontal?n.clientY:n.clientX;e.onChange(r-t.current),t.current=r},onPointerUp:n=>{t.current=null,n.currentTarget.releasePointerCapture(n.pointerId)},onPointerCancel:()=>{t.current=null},onKeyDown:n=>{["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(n.key)&&(n.preventDefault(),e.onChange(n.key==="ArrowLeft"||n.key==="ArrowUp"?-20:20))}})}var sm={searched:0,read:1,wrote:2},lm=new Map;function um(e,t){return t===null?e.events.map(n=>({event:n,at:Date.parse(n.at)})):e.events.filter(n=>n.turn===t.turn).map((n,r)=>({event:n,at:t.startedAt+r*700}))}function dm(e,t,n=null){if(e===null)return lm;let r=new Map,i=new Map;for(let{event:a,at:o}of um(e,n)){let s=t-o;if(n!==null&&s<0)continue;let l=Math.min(1,1-s/6e4);if(l>0)for(let c of a.slugs){let u=`note:${c}`,d=i.get(u)===a.turn?r.get(u):void 0,h=d===void 0||sm[a.kind]>sm[d.kind]?a.kind:d.kind;r.set(u,{kind:h,strength:Math.max(l,d?.strength??0)}),i.set(u,a.turn)}}return r.size===0?lm:r}function hm(e,t,n=null){return e===null?!1:um(e,n).some(({at:r})=>t-r<6e4)}var LT={add:"created",append:"appended",finalize:"finalized",links:"fixed links in"};function NT(e,t){let n=e.slugs.map(r=>({id:`note:${r}`,label:t.get(`note:${r}`)??r}));if(e.kind==="searched"){let r=e.slugs.length;return{key:`${e.seq}:s`,kind:"searched",verb:e.query===void 0?"searched":`searched "${e.query}"`,notes:[],detail:r===0?"no hits":`${r} hit${r===1?"":"s"}`}}return{key:`${e.seq}:${e.kind}`,kind:e.kind,verb:e.kind==="read"?"read":LT[e.action]??"wrote",notes:n,detail:null}}function cm(e,t=!1){let n=new Date(e);return Number.isNaN(n.getTime())?"":[n.getHours(),n.getMinutes(),...t?[n.getSeconds()]:[]].map(i=>String(i).padStart(2,"0")).join(":")}function pm(e,t){if(e===null||e.events.length===0)return[];let n=new Map((t?.model.nodes??[]).map(s=>[s.id,s.label])),r=new Map;for(let s of e.events){let l=r.get(s.turn);l===void 0?r.set(s.turn,[s]):l.push(s)}let i=[...r.entries()].sort(([s],[l])=>l-s),a=i.map(([,s])=>cm(s[0].at)),o=i.map(([s,l],c)=>{let u=new Set(l.filter(h=>h.kind!=="searched").flatMap(h=>h.slugs)),d=a.filter(h=>h===a[c]).length>1;return{turn:s,time:cm(l[0].at,d),steps:l.map(h=>NT(h,n)),used:u.size}});return e.turn>o[0].turn&&o.unshift({turn:e.turn,time:"",steps:[],used:0}),o.slice(0,5)}var fm="Nothing recalled yet.";function Wl(e,t){return t?"This turn":e.time===""?`Turn ${e.turn}`:e.time}function gm(e){if(e===null)return null;for(let t=e.events.length-1;t>=0;t--){let n=e.events[t];if(n.turn!==e.turn)return null;if(!(n.kind!=="searched"||n.query===void 0||n.query.trim()===""))return{seq:n.seq,query:n.query,ids:n.slugs.map(r=>`note:${r}`)}}return null}function mm(e,t,n){return t===null?e===null?null:{query:"",ids:[],agent:null}:t.seq===e||n&&e===null?null:{query:t.query,ids:t.ids,agent:t.seq}}function vm(e){let t=e.turns[0];if(t===void 0)return null;let n=e.turns.find(r=>r.turn===e.shownTurn)??t;return p("section",{class:"weave-ctx-group weave-trail","aria-label":"What your agent recalled",children:[p("h4",{class:"weave-ctx-head weave-trail-head",children:[p("span",{class:"weave-trail-title",children:Wl(n,n===t)}),p("span",{class:"weave-ctx-count",title:"Notes read or written",children:n.used})]}),n.steps.length===0?p("p",{class:"weave-trail-empty",children:fm}):null,p("ol",{class:"weave-trail-steps",children:n.steps.map(r=>p("li",{class:`weave-trail-step weave-trail-${r.kind}`,children:[p("span",{class:"weave-trail-verb",children:r.verb}),r.notes.map(i=>p("button",{type:"button",class:"weave-trail-note",onClick:a=>e.onSelect(i.id,a.metaKey||a.ctrlKey),children:i.label},i.id)),r.detail===null?null:p("span",{class:"weave-trail-detail",children:r.detail})]},r.key))}),e.turns.length<2?null:p("div",{class:"weave-trail-turns",role:"group","aria-label":"Earlier turns",children:e.turns.map((r,i)=>p("button",{type:"button",class:`weave-trail-turn${r.turn===n.turn?" weave-trail-turn-on":""}`,"aria-pressed":r.turn===n.turn,onClick:()=>e.onReplay(r.turn),children:Wl(r,i===0)},r.turn))})]})}function wm({row:e,onSelect:t}){return p("li",{class:`weave-ctx-row${e.selected?" weave-row-on":""}`,children:p("button",{type:"button",class:"weave-ctx-link",onClick:n=>t(n.metaKey||n.ctrlKey),children:[p("span",{class:"weave-kind","aria-hidden":"true",children:p(ce,{name:e.kindIcon,class:"weave-icon"})}),p("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),p("span",{class:"weave-label",children:e.label})]})})}function ym({view:e,onToggle:t}){return p("h4",{class:"weave-ctx-head",children:p("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!e.collapsed,"aria-controls":ro(e.heading),onClick:t,children:[p("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:p(ce,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,p("span",{class:"weave-ctx-count",children:e.count})]})})}function PT({view:e,onSelect:t,onToggle:n}){return p("section",{class:"weave-ctx-group",children:[p(ym,{view:e,onToggle:n}),p("ul",{class:"weave-ctx-rows",id:ro(e.heading),hidden:e.collapsed,children:e.rows.map(r=>p(wm,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function DT({tag:e,onSelect:t}){return p("li",{class:"weave-ctx-tag",children:[p("span",{class:"weave-tag",children:["#",e.tag]}),p("ul",{class:"weave-ctx-rows",children:e.siblings.map(n=>p(wm,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function bm(e){let t=V(null),n=no(e.graph,e.selectedId),[r,i]=K(nm),a=s=>()=>i(om(r,s.heading,s.collapsed)),o=am(n.tags,r);return p("div",{class:"weave-rail","aria-label":tp.title,children:[e.trail===void 0?null:p(vm,{turns:e.trail,shownTurn:e.trailTurn??null,onSelect:e.onSelect,onReplay:s=>e.onReplay?.(s)}),n.empty===null?null:p("p",{class:"weave-ctx-empty",children:n.empty}),n.groups.map(s=>{let l=im(s,r);return p(PT,{view:l,onSelect:e.onSelect,onToggle:a(l)},s.heading)}),n.tags.length===0?null:p("section",{class:"weave-ctx-group",children:[p(ym,{view:o,onToggle:a(o)}),p("ul",{class:"weave-ctx-tags weave-context-tags",ref:t,style:{height:e.tagHeight},id:ro(o.heading),hidden:o.collapsed,children:n.tags.map(s=>p(DT,{tag:s,onSelect:e.onSelect},s.tag))}),o.collapsed?null:p(Kn,{label:"Resize tags section",horizontal:!0,min:60,max:600,value:e.tagHeight,onChange:s=>e.onTagResize(Math.max(60,Math.min(600,(t.current?.clientHeight??e.tagHeight)+s)))})]})]})}function xm(e){let t=null,n=!1,r=!1,i=async()=>{if(!(n||r)){r=!0;try{let s=await Bc(e.fetch,t);if(n||!s.ok||s.cached)return;t=s.data,e.onTrail(s.data)}finally{r=!1}}},o=(e.repeat??((s,l)=>{let c=setInterval(s,l);return()=>clearInterval(c)}))(()=>{i()},Ja);return i(),()=>{n=!0,o()}}function IT(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function km(e,t){let n=IT(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function _m(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function Tm(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function Sm(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):on[e.key]}function Em(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function Rm(e){return Qn.every(t=>Object.is(e[t.key],on[t.key]))}function Am(e){return p("div",{class:"weave-settings-forces",children:[Qn.map(t=>p("label",{class:"weave-setting-row",children:[p("span",{children:[p("strong",{children:t.label}),p("small",{children:t.hint})]}),p("span",{class:"weave-setting-range",children:[p("input",{"aria-label":t.label,type:"range",min:t.min,max:t.max,step:t.step,value:Tm(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:Sm(t,n.currentTarget.value)})}),p("output",{children:Em(e.forces[t.key])})]})]},t.key)),p("button",{type:"button",disabled:Rm(e.forces),onClick:()=>e.onChange({...on}),children:"Reset graph layout"})]})}var Cm=["General","Appearance","Interface","Editor","Files","Backup"];function vt(e){return p("label",{class:"weave-setting-row",children:[p("span",{children:[p("strong",{children:e.name}),p("small",{children:e.hint})]}),e.children]})}function Lm(e){let[t,n]=K("General"),[r,i]=K(0),a=br(),[o,s]=K(null),[l,c]=K(!1);ne(()=>{zo(_e).then(f=>{f.ok&&s(f.data.enabled)})},[]);let u=f=>{s(f),c(!0),zo(_e,f).then(g=>{s(g.ok?g.data.enabled:!f),c(!1)})},d=e.layout.preferences,h=f=>e.onChange({...e.layout,preferences:{...d,...f}});return p("div",{class:"weave-scrim weave-settings-scrim",onClick:e.onClose,children:p("div",{class:"weave-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",tabIndex:-1,ref:a.ref,onClick:f=>f.stopPropagation(),onKeyDown:f=>{a.onKeyDown(f)},children:[p("header",{children:[p("h2",{children:"Settings"}),p("button",{type:"button","aria-label":"Close settings",onClick:e.onClose,children:"×"})]}),p("nav",{"aria-label":"Settings categories",children:e.compact?p("select",{class:"weave-settings-category","aria-label":"Settings category",value:t,onChange:f=>n(f.currentTarget.value),children:Cm.map(f=>p("option",{value:f,children:f},f))}):Cm.map(f=>p("button",{type:"button","aria-current":t===f?"page":void 0,onClick:()=>n(f),children:f},f))}),p("section",{"aria-label":`${t} settings`,children:[p("h3",{children:t}),t==="General"?p(be,{children:[p("p",{children:["Pi Weave ",e.info.version]}),p("dl",{class:"weave-settings-locations",children:[p("dt",{children:"Vault"}),p("dd",{children:p("code",{children:e.info.vaultRoot||"Loading…"})}),p("dt",{children:"Repository"}),p("dd",{children:p("code",{children:e.cwd})})]}),p("div",{class:"weave-settings-actions",children:[p("button",{type:"button",onClick:()=>{i(f=>f+1),e.onRefresh()},children:[p("span",{class:r?"weave-refresh-spin":"","aria-hidden":"true",children:"↻"},r)," Refresh workspace"]}),p("a",{href:"https://github.com/EranYonai/pi-weave#readme",target:"_blank",rel:"noreferrer",children:"Documentation ↗"})]}),p("details",{children:[p("summary",{tabIndex:0,children:"Keyboard shortcuts"}),xa(e.shortcut.slice(0,-1)).map(f=>p("div",{children:[p("h4",{children:f.title}),f.entries.map(g=>p("div",{class:"weave-key-row",children:[p("kbd",{children:g.combo}),p("span",{children:g.what})]},g.combo))]},f.title))]})]}):null,t==="Appearance"?p(be,{children:[p(vt,{name:"Color scheme",hint:"System follows your device and uses your chosen light and dark themes.",children:p("select",{"aria-label":"Color scheme",value:e.layout.theme==="system"?"system":ve[e.layout.theme].scheme,onChange:f=>e.onChange({...e.layout,theme:f.currentTarget.value==="system"?"system":f.currentTarget.value==="light"?d.lightTheme:d.darkTheme}),children:[p("option",{value:"system",children:"System"}),p("option",{value:"light",children:"Light"}),p("option",{value:"dark",children:"Dark"})]})}),["light","dark"].map(f=>p(vt,{name:`${f==="light"?"Light":"Dark"} theme`,hint:`Used in ${f} mode and by the ribbon theme button.`,children:p("select",{"aria-label":`${f==="light"?"Light":"Dark"} theme`,value:d[`${f}Theme`],onChange:g=>{let w=g.currentTarget.value;e.onChange({...e.layout,preferences:{...d,[`${f}Theme`]:w},theme:e.layout.theme!=="system"&&ve[e.layout.theme].scheme===f?w:e.layout.theme})},children:Object.entries(ve).filter(([,g])=>g.scheme===f).map(([g,w])=>p("option",{value:g,children:w.name},g))})},f)),p(vt,{name:"Accent color",hint:"Choose independently of the theme. Shades adapt to light and dark backgrounds.",children:p("select",{"aria-label":"Accent color",value:d.accent,onChange:f=>h({accent:f.currentTarget.value}),children:[p("option",{value:"theme",children:"Theme default"}),Object.entries(Tn).map(([f,g])=>p("option",{value:f,children:g.name},f))]})}),p(vt,{name:"Note font size",hint:"Applies to reading and editing notes.",children:p("span",{class:"weave-setting-range",children:[p("input",{"aria-label":"Note font size",type:"range",min:12,max:22,step:1,value:d.fontSize,onInput:f=>h({fontSize:Number(f.currentTarget.value)})}),p("output",{children:[d.fontSize,"px"]})]})})]}):null,t==="Interface"?p(be,{children:[p(vt,{name:"Notes sidebar",hint:"Show files and recent notes.",children:p("input",{type:"checkbox",checked:e.layout.treeVisible,onChange:f=>e.onChange({...e.layout,treeVisible:f.currentTarget.checked})})}),p(vt,{name:"Context sidebar",hint:"Show links, backlinks, and related items.",children:p("input",{type:"checkbox",checked:e.layout.contextVisible,onChange:f=>e.onChange({...e.layout,contextVisible:f.currentTarget.checked})})}),p(vt,{name:"Color graph by group",hint:"Give each containment group its own color.",children:p("input",{type:"checkbox",checked:d.groupColors,onChange:f=>h({groupColors:f.currentTarget.checked})})}),p("h4",{children:"Graph layout"}),p("p",{class:"weave-settings-hint",children:"Adjust the graph live. Your choices are saved for this workspace."}),p(Am,{forces:d.forces,onChange:f=>h({forces:f})})]}):null,t==="Editor"?p(be,{children:[p(vt,{name:"Spellcheck",hint:"Use your browser or device’s spellchecker while editing.",children:p("input",{type:"checkbox",checked:d.spellcheck,onChange:f=>h({spellcheck:f.currentTarget.checked})})}),p(vt,{name:"Readable line length",hint:"Keep note text in a comfortable reading column.",children:p("input",{type:"checkbox",checked:d.readable,onChange:f=>h({readable:f.currentTarget.checked})})}),p(vt,{name:"Open notes in editing mode",hint:"Newly opened notes start in the editor. Existing drafts are preserved.",children:p("input",{type:"checkbox",checked:d.defaultEdit,onChange:f=>h({defaultEdit:f.currentTarget.checked})})}),p(vt,{name:"Note history",hint:"Save a copy of a note after every change, by you or your agent, so History can replay how it was written. Turning it off keeps what is already saved.",children:p("input",{type:"checkbox",disabled:o===null||l,checked:o??!1,onChange:f=>u(f.currentTarget.checked)})})]}):null,t==="Files"?p(be,{children:[p(vt,{name:"On startup",hint:"Choose which tabs appear when you reopen this workspace.",children:p("select",{"aria-label":"On startup",value:d.startup,onChange:f=>h({startup:f.currentTarget.value}),children:[p("option",{value:"restore",children:"Restore open tabs"}),p("option",{value:"empty",children:"Start with an empty tab"})]})}),p(vt,{name:"Focus new tabs",hint:"Switch to notes opened in a new tab, including from the graph.",children:p("input",{type:"checkbox",checked:d.focusNewTabs,onChange:f=>h({focusNewTabs:f.currentTarget.checked})})}),p("h4",{children:"Deleting files"}),p("p",{children:"Deleting a note or folder removes it from the vault after confirmation. Download a backup before deleting anything you may need again."})]}):null,t==="Backup"?p(be,{children:[p("h4",{children:"Download your vault"}),p("p",{children:"Save a ZIP containing the vault’s files and folders, including notes, metadata, and attachments. Linked files and folders are included as files."}),p("p",{children:"Save any unsaved edits first. The download contains files saved on disk. Backups are manual; store the ZIP somewhere safe."}),p("a",{class:"weave-settings-download",href:"/api/backup",download:!0,children:"Download vault ZIP"})]}):null]})]})})}function MT({group:e}){return p("div",{children:[p("p",{class:"weave-key-group",children:e.title}),e.entries.map(t=>p("div",{class:"weave-key-row",children:[p("kbd",{class:"weave-key-combo",children:t.combo}),p("span",{class:"weave-key-what",children:t.what})]},t.combo))]})}function Nm(e){let t=br(),n=e.shortcut.slice(0,-1);return p("div",{class:"weave-scrim",onClick:e.onClose,children:p("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":Vs,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[p("h2",{class:"weave-help-title",children:Vs}),p("div",{class:"weave-keys",children:xa(n).map(r=>p(MT,{group:r},r.title))}),p("p",{class:"weave-help-foot",children:[p("button",{type:"button",class:"weave-chip",onClick:e.onClose,children:"close"}),p("span",{class:"weave-help-hint",children:cp})]})]})})}function Pm(e,t){let n=r=>{if(r.defaultPrevented)return;let i=op(sp(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function Dm({model:e}){return p("footer",{class:"weave-status",children:[p("span",{class:"weave-status-cwd",title:e.cwd,children:e.cwd}),p("span",{class:"weave-status-sel",title:"Current item",children:e.selection}),e.hint===""?null:p("span",{class:"weave-status-hint",children:e.hint})]})}var Im="pi-weave.theme.v1";function io(e){try{let t=e.getItem(Im);return Xn(t)?t:null}catch{return null}}function Mm(e,t){try{return e.setItem(Im,t),!0}catch{return!1}}function ao(e,t,n=sn){return ve[Bl(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function Bl(e,t,n=sn){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function Gm(e){return e==="system"?null:e}function Ul(e){return e==="system"?"System":ve[e].name}function Om(e,t="dark",n=sn){return{glyph:e==="system"?"◐":ve[e].scheme==="light"?"○":"●",icon:e==="system"?"system":ve[e].scheme==="light"?"sun":"moon",label:Ul(e),hint:`Colour theme: ${Ul(e)} — click for ${Ul(ao(e,t,n))}`}}function oo(e,t){if(e.kind==="graph")return"Graph view";let n=Mt(e);return n===null?"New tab":t?.model.nodes.find(r=>r.id===n)?.label??n.replace(/^[^:]+:/,"")}function OT(e){let[t]=K(e.visits);return p("div",{class:"weave-recents",children:ep(t,e.graph,e.selectedId).map(n=>p("button",{type:"button","aria-current":n.selected?"page":void 0,title:n.label,onClick:r=>e.onSelect(n.id,r.metaKey||r.ctrlKey),children:[p("span",{class:"weave-kind",children:p(ce,{name:n.icon,class:"weave-icon"})}),p("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function FT(e){let t=Mt(e.tab),n=t?.startsWith("note:")?t.slice(5):null,[r,i]=K(null),a=V(null),o=V(e.tab.scroll),[s,l]=K(!1),[c,u]=K(""),[d,h]=K(!1),f=V(null);ze(()=>{s&&f.current?.focus()},[s]),ne(()=>{if(n===null)return;let v=e.drafts.nextLoadVersion();return em(_e,n,y=>{i({slug:n,note:y.ok?y.data:null,failed:!y.ok,version:v})})},[n,e.graph?.stamp,e.revision]);let g=r?.slug===n?r:null;if(ze(()=>{let v=a.current?.querySelector(".weave-note");v!=null&&(v.scrollTop=o.current),n!==null&&e.drafts.get(n)!==null&&a.current?.querySelector(".weave-note-editor")?.focus()},[t,g?.note?.note.slug]),t===null)return p("div",{class:"weave-welcome",children:[p("span",{class:"weave-welcome-mark","aria-hidden":"true",children:"✳"}),p("h1",{children:"Your knowledge, connected."}),p("p",{children:"Ask your agent to write, organize, and connect your notes. Browse that knowledge here, or start a note yourself."}),p("div",{children:[p("button",{type:"button",onClick:e.onSearch,children:["Search workspace ",p("kbd",{children:"⌘K"})]}),p("button",{type:"button",onClick:e.onGraph,children:"Explore graph"}),p("button",{type:"button",onClick:()=>l(!0),children:"New note"})]}),s?p("form",{class:"weave-new-note",onSubmit:v=>{v.preventDefault(),!(d||!c.trim())&&(h(!0),e.onCreate(c.trim()).finally(()=>h(!1)))},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),d||l(!1))},children:[p("label",{for:`new-note-${e.tab.id}`,children:"Note title"}),p("input",{id:`new-note-${e.tab.id}`,ref:f,required:!0,value:c,disabled:d,onInput:v=>u(v.currentTarget.value)}),p("div",{children:[p("button",{type:"submit",disabled:d||!c.trim(),children:d?"Creating…":"Create note"}),p("button",{type:"button",disabled:d,onClick:()=>l(!1),children:"Cancel"})]})]}):null]});let w=e.graph!==null&&!e.graph.model.nodes.some(v=>v.id===t);if(w||g?.failed&&e.drafts.isDirty(n??"")){let v=n===null?null:e.drafts.get(n);return v!==null&&n!==null&&e.drafts.isDirty(n)?p("div",{class:"weave-welcome",children:[p("h2",{children:w?"This item is no longer here":"This note could not be loaded"}),p("p",{children:["Your unsaved draft is preserved below. Select and copy it before closing this workspace. ",w?"Saving cannot restore or recreate the missing note.":"Reopen this tab to retry loading the note."]}),p("label",{class:"weave-note-meta",for:`missing-draft-${e.tab.id}`,children:"Unsaved draft (read-only)"}),p("textarea",{id:`missing-draft-${e.tab.id}`,class:"weave-note-editor","aria-label":"Unsaved draft for missing note",rows:16,readOnly:!0,value:v.body}),p("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]}):p("div",{class:"weave-welcome",children:[p("h2",{children:"This item is no longer here"}),p("p",{children:"It may have been moved or deleted. Your other tabs are still available."}),p("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]})}return p("div",{class:"weave-document",ref:a,onScrollCapture:v=>{let y=v.target;y.classList.contains("weave-note")&&(o.current=y.scrollTop,e.onScroll(y.scrollTop))},children:p(Tg,{spellcheck:e.preferences.spellcheck,defaultEdit:e.preferences.defaultEdit,note:g?.note??null,loadFailed:g?.failed??!1,loadVersion:g?.version??0,graph:e.graph,selectedId:t,onSelect:e.onSelect,onOpen:v=>{jc(_e,v).then(y=>{y.ok?y.data.opened||window.alert("Could not open the note in an editor."):window.alert(y.message)})},onSave:e.onSave,onHistory:v=>nu(_e,v),drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function Fm(e){let[t,n]=K(zl),[r,i]=K(()=>({...Lo(),theme:io(localStorage)??"system"})),[a,o]=K(null),[s,l]=K(!1),[c,u]=K(Date.now),[d,h]=K(null),[f,g]=K(Date.now),[w,v]=K(null),[y,b]=K(e.initialWidth),[_,x]=K(()=>Qr(window)),[C,O]=K(!1),[N,j]=K({version:"",vaultRoot:""}),[P,R]=K(!1),[H,Z]=K(0),[,G]=K(0),[J,X]=K(null),se=V(null),[Ye,Ae]=K(null),[we,ue]=K(""),[Te,ct]=K(null),[Pe,oe]=K(null),Se=V(null),[ut,Nt]=K(null),[L,W]=K(null),[te,ge]=K(!1),[Fe,wt]=K([]),[pe,_t]=K(!1),[ie]=K(Va),Tt=V(null),Ke=V(null),gn=V(location.hash),xr=V(!1),Ve=V(null),kr=V(null),mn=V(null),_r=V(null),[Tr,Pt]=K({left:0,top:0,width:600,height:500}),$t=Sn(r),et=En(r),vn=Om(r.theme,_,r.preferences),Dt=Bl(r.theme,_,r.preferences),Vn=De(()=>({theme:Dt,accent:r.preferences.accent}),[Dt,r.preferences.accent]),yt=Mt(et),Ee=et.kind==="graph"?J:yt,$e=r.panes.find(k=>k.tabs.some(S=>S.id===k.activeTab&&S.kind==="graph")),wn=$e!==void 0&&(y>=850||$e.id===r.activePane),Ce=s&&et.kind==="document"&&!wn,zt=y<1050?pe:r.contextVisible,Xt=!r.contextPinned,yn=De(()=>tm(no(t.graph,Ee)),[t.graph,Ee]),Sr=Math.max(240,Math.min(320,r.contextWidth)),Qt=()=>{y<1050?_t(!0):i({...r,contextVisible:!0})},tt=wn||Ce&&zt&&yt!==null,vi=r.panes.some(k=>k.tabs.some(S=>S.kind==="graph")),nt=V({layout:r,overlay:a,selectedId:Ee,graphPreviewId:Ye,select:k=>{}}),Jt=k=>{nt.current.graphPreviewId=k,Ae(k)};ne(()=>{Jt(null)},[tt,Ce,yt]),ne(()=>{yt!==null?(se.current=yt,X(yt)):et.kind==="graph"&&X(se.current)},[et.id,et.kind,yt]);let St=k=>{eg(ie,nt.current.layout,k,()=>window.confirm(ya))&&i(k)},dt=(k,S=!1,B=r.activePane,Q=!1)=>{let I=(k===null?ln:$c)(r,k,{newTab:S,paneId:B});St(y<850&&!Q?{...I,treeVisible:!1}:I),s||_t(!1)},jn=()=>{let k=!(Ce&&zt);l(k),k&&(i(S=>({...Bi(S),contextVisible:!0})),_t(!0))},en=()=>i(k=>({...Po(k),...y<850?{treeVisible:!1}:{}})),ht=k=>{if(Jt(null),Ce){dt(k,!0);return}let S=r.panes.find(B=>B.id!==$e?.id);dt(k,!0,S?.id??$e?.id??r.activePane)},tn=k=>{Ce||X(k),Qh(nt.current.graphPreviewId,k)?ht(k):Jt(k)},Er=k=>{Jt(null),St(Jh(r,k,$e?.id))},Rr=(k,S=[])=>{ue(k),ct({query:k,ids:S}),oe(null),en()},so=k=>{ue(k),oe(null)};nt.current={layout:r,overlay:a,selectedId:Ee,graphPreviewId:Ye,select:dt};let wi=k=>tg(ie,k,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),Ar=async(k,S,B)=>{let Q=await Yc(_e,k,S,B?.raw===!0);return Q.ok?(Z(I=>I+1),Tt.current?.refresh(),!0):(B?.quiet!==!0&&window.alert(Q.message),!1)},yi=async(k,S)=>{let B=await qc(_e,k);if(!B.ok)return window.alert(B.message),!1;let Q=await qi(_e);return n(I=>({...I,graph:Q.ok?Q.data:null,graphFailed:!Q.ok})),ie.open(B.data.note.slug,B.data.note.body),St(ln(nt.current.layout,`note:${B.data.note.slug}`,{paneId:S})),Tt.current?.refresh(),!0};ne(()=>ie.subscribe(()=>G(k=>k+1)),[ie]),ne(()=>(Tt.current=Jg({fetch:_e,state:zl(),setState:n}),()=>Tt.current?.stop()),[]),ne(()=>{let k=!0;return(async()=>{try{let S=await _e("/api/workspace-state"),B=await S.json();if(!k)return;if(S.ok&&typeof B.viewId=="string"){Ke.current=B.viewId,B.info&&j(B.info);let Q=Oc(B.layout);if(Q){let I=Fc(Q);i(I),se.current=Mt(En(Bi(I))),X(se.current),wt(Q.panes.flatMap(ee=>ee.tabs.flatMap(Ue=>Ue.history)).reduce(Us,[]))}}else R(!0)}catch{k&&R(!0)}finally{k&&O(!0)}})(),()=>{k=!1}},[]),ne(()=>{if(!C||t.graph===null||xr.current)return;xr.current=!0;let k=km(gn.current,t.graph);k!==null&&i(S=>ln(S,k))},[C,t.graph]),ne(()=>{C&&wt(k=>Us(k,Ee))},[C,Ee]),ne(()=>{C&&(history.replaceState(null,"",_m(Ee)),document.documentElement.dataset.weaveTheme=Dt,document.documentElement.dataset.weaveScheme=ve[Dt].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,Mm(localStorage,r.theme))},[C,Ee,r.theme,Dt,r.preferences.accent]);let qn=V(Promise.resolve());ne(()=>{if(!C||!Ke.current)return;let k=Ke.current,S=window.setTimeout(()=>{qn.current=qn.current.then(async()=>{try{let B=await _e("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:k,layout:r})});R(!B.ok)}catch{R(!0)}})},350);return()=>window.clearTimeout(S)},[r,C]),ne(()=>xm({fetch:_e,onTrail:k=>{h(k),v(null),g(Date.now())}}),[]);let bi=hm(d,f,w);ne(()=>{if(!bi){w!==null&&v(null);return}let k=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(k)},[bi]);let bn=De(()=>dm(d,f,w),[d,f,w]),xi=De(()=>pm(d,t.graph),[d,t.graph]),ki=De(()=>gm(d),[d]);ne(()=>{let k=we.trim()!==""&&document.activeElement?.classList.contains("weave-spotlight-input")===!0,S=mm(Pe,ki,k);S!==null&&(ue(S.query),ct({query:S.query,ids:S.ids}),oe(S.agent))},[ki?.seq]);let ye=r.split==="down"?r.panes[0]:r.panes.at(-1),nn=ye?.tabs.find(k=>k.id===ye.activeTab)?.kind==="graph",_i=Xt&&(nn||Ee===null&&xi.length===0),xn=zt&&!_i,Cr=k=>{let S=Date.now();g(S),v({turn:k,startedAt:S})};ne(()=>{let k=window.setInterval(()=>u(Date.now()),rp),S=()=>b(window.innerWidth);window.addEventListener("resize",S);let B=qh(window,x),Q=Ue=>{for(let rn of document.querySelectorAll(".weave-pane-menu[open]"))rn.contains(Ue.target)||(rn.open=!1)};document.addEventListener("pointerdown",Q);let I=Ue=>{ie.dirtySlugs().length&&(Ue.preventDefault(),Ue.returnValue="")},ee=()=>{Ke.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:Ke.current,layout:nt.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",ee),window.addEventListener("beforeunload",I),()=>{window.clearInterval(k),window.removeEventListener("resize",S),window.removeEventListener("beforeunload",I),window.removeEventListener("pagehide",ee),document.removeEventListener("pointerdown",Q),B()}},[]),ne(()=>Pm(document,{context:()=>({overlay:nt.current.overlay,hasSelection:nt.current.selectedId!==null}),run:k=>lp(k,{setOverlay:o,fitGraph:()=>_r.current?.(),clearSelection:()=>{En(nt.current.layout).kind==="graph"?(X(null),Jt(null)):nt.current.select(null)},closeTab:()=>{let S=nt.current.layout;St(Io(S,S.activePane,En(S).id))},toggleTheme:()=>i(S=>({...S,theme:ao(S.theme,Qr(window),S.preferences)})),toggleContext:()=>{window.innerWidth<1050?_t(S=>!S):i(S=>({...S,contextVisible:!S.contextVisible}))},focusSelector:S=>(S===cr.graph?i(B=>({...Po(B),...window.innerWidth<850?{treeVisible:!1}:{}})):S===cr.tree||S===Ks?i(B=>({...B,treeVisible:!0})):i(Bi),requestAnimationFrame(()=>{S===cr.note&&ba(document,".weave-pane-active .weave-note-editor")||!ba(document,S)&&S===cr.note&&ba(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),ze(()=>{for(let k of r.panes)document.getElementById(`tab-${k.activeTab}`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[r.panes.map(k=>k.activeTab).join(","),r.activePane,y,C,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),ze(()=>{let k=Ce?mn.current:kr.current,S=Ve.current;if(!tt||!k||!S)return;let B=()=>{let I=k.getBoundingClientRect(),ee=S.getBoundingClientRect();Pt({left:I.left-ee.left,top:I.top-ee.top,width:I.width,height:I.height})};B();let Q=new ResizeObserver(B);return Q.observe(k),Q.observe(S),()=>Q.disconnect()},[Ce,tt,r,y]);let Ti=(k,S)=>i(B=>({...B,panes:B.panes.map(Q=>({...Q,tabs:Q.tabs.map(I=>I.id===k?{...I,scroll:S}:I)}))})),Lr=(k,S)=>{Vi(r,k,Se.current)===null&&!S.dataTransfer?.types.includes(Jr)||(S.preventDefault(),S.dataTransfer&&(S.dataTransfer.dropEffect=Se.current===null?"copy":"move"),Nt(null),W(k))},Si=(k,S)=>{let B=Xh(t.graph,S.dataTransfer?.getData(Jr)??"");if(B!==null){S.preventDefault(),dt(B,!0,k),W(null);return}let Q=Se.current;Vi(r,k,Q)!==null&&(S.preventDefault(),i(I=>{let ee=Vi(I,k,Q);return ee===null?I:tr(I,ee,Q)}),Se.current=null,W(null),Nt(null))},Ei=(k,S,B)=>{k.tabs.some(Q=>Q.id===Se.current)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect="move",W(null),Nt({paneId:k.id,before:S}))},Ri=(k,S)=>{let B=Se.current;B===null||!k.tabs.some(Q=>Q.id===B)||(S.preventDefault(),S.stopPropagation(),i(Q=>Oo(Q,k.id,B,ut?.paneId===k.id?ut.before:null)),Se.current=null,Nt(null),W(null))},lo=k=>{let S=k.tabs.find(I=>I.id===k.activeTab),B=k.id===r.activePane,Q=Xt&&xn&&(r.split==="down"||k===r.panes.at(-1));return p("section",{class:`weave-pane${B?" weave-pane-active":""}${L===k.id?" weave-pane-drop":""}${Q?" weave-pane-under-card":""}`,"data-drop-label":Se.current===null?"Open note here":"Move tab here","aria-label":`Workspace pane ${r.panes.indexOf(k)+1}`,onDragOver:I=>Lr(k.id,I),onDrop:I=>Si(k.id,I),onDragLeave:I=>{I.currentTarget.contains(I.relatedTarget)||W(null)},hidden:y<850&&!B,onFocusCapture:()=>{B||i(I=>({...I,activePane:k.id}))},onPointerDown:()=>{B||i(I=>({...I,activePane:k.id}))},children:[p("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:I=>Ei(k,null,I),onDrop:I=>Ri(k,I),children:[k.tabs.map(I=>p("div",{class:`weave-tab${I.id===S.id?" weave-tab-active":""}${ut?.paneId===k.id&&ut.before===I.id?" weave-tab-drop-before":""}${ut?.paneId===k.id&&ut.before===null&&I===k.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:ee=>{let Ue=ee.currentTarget.getBoundingClientRect(),rn=ee.clientX<Ue.left+Ue.width/2?I.id:k.tabs[k.tabs.indexOf(I)+1]?.id??null;Ei(k,rn,ee)},onDrop:ee=>Ri(k,ee),children:[p("button",{type:"button",role:"tab",title:oo(I,t.graph),id:`tab-${I.id}`,"aria-selected":I.id===S.id,"aria-controls":`panel-${k.id}`,tabIndex:I.id===S.id?0:-1,draggable:!0,onDragStart:ee=>{Se.current=I.id,ee.dataTransfer.effectAllowed="move",ee.dataTransfer.setData("application/x-weave-tab",I.id)},onClick:()=>i(Do(r,k.id,I.id)),onKeyDown:ee=>{let Ue=ee.key==="ArrowRight"?1:ee.key==="ArrowLeft"?-1:0;if(Ue&&ee.altKey&&!ee.ctrlKey&&!ee.metaKey){ee.preventDefault(),ee.stopPropagation();let Pr=k.tabs.indexOf(I),Yn=Ue<0?k.tabs[Math.max(0,Pr-1)].id:k.tabs[Pr+2]?.id??null;i(Oo(r,k.id,I.id,Yn)),requestAnimationFrame(()=>document.getElementById(`tab-${I.id}`)?.focus());return}if(!Ue&&ee.key!=="Home"&&ee.key!=="End")return;ee.preventDefault();let rn=ee.key==="Home"?0:ee.key==="End"?k.tabs.length-1:(k.tabs.indexOf(I)+Ue+k.tabs.length)%k.tabs.length,Nr=k.tabs[rn];i(Do(r,k.id,Nr.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Nr.id}`)?.focus())},children:[p("span",{"aria-hidden":"true",children:p(ce,{name:I.kind==="graph"?"graph":"note",class:"weave-icon"})}),p("span",{children:oo(I,t.graph)}),ie.isDirty((Mt(I)??"").slice(5))?p("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),p("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${oo(I,t.graph)}`,onClick:()=>St(Io(r,k.id,I.id)),children:"×"})]},I.id)),p("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>dt(null,!0,k.id),children:"+"})]}),p("div",{class:"weave-pane-toolbar",children:[p("button",{type:"button","aria-label":"Navigate back",disabled:S.kind==="graph"||S.cursor===0,onClick:()=>St(Mo({...r,activePane:k.id},k.id,-1)),children:"←"}),p("button",{type:"button","aria-label":"Navigate forward",disabled:S.kind==="graph"||S.cursor>=S.history.length-1,onClick:()=>St(Mo({...r,activePane:k.id},k.id,1)),children:"→"}),p("span",{class:"weave-breadcrumb",children:oo(S,t.graph)}),p("details",{class:"weave-pane-menu",onKeyDown:I=>{I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),I.currentTarget.open=!1,I.currentTarget.querySelector("summary")?.focus())},children:[p("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),p("div",{onClick:I=>{let ee=I.currentTarget.closest("details");ee&&(ee.open=!1)},children:[p("button",{type:"button",onClick:()=>i(Go({...r,activePane:k.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),p("button",{type:"button",onClick:()=>i(Go({...r,activePane:k.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?p(be,{children:[p("button",{type:"button",onClick:()=>i(tr(r,k.id,S.id)),children:"Move tab to other pane"}),p("button",{type:"button",title:"Move all tabs to the other pane and close this pane",onClick:()=>i(Gc(r,k.id)),children:"Close pane"})]}):null]})]})]}),p("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${k.id}`,"aria-labelledby":`tab-${S.id}`,...S.kind==="graph"?{ref:kr}:{},children:S.kind==="document"?p(FT,{preferences:r.preferences,tab:S,graph:t.graph,drafts:ie,revision:H,now:c,onSelect:(I,ee)=>dt(I,ee,k.id),onSave:Ar,onScroll:I=>Ti(S.id,I),onSearch:()=>o("search"),onGraph:en,onCreate:I=>yi(I,k.id)},`${S.id}:${S.cursor}:${Mt(S)}`):null})]},k.id)};return p(be,{children:[p("div",{class:"weave-workbench",style:{"--weave-note-size":`${r.preferences.fontSize}px`,"--weave-reading-width":r.preferences.readable?"760px":"100%","--weave-card-width":`${Sr}px`},ref:Ve,onDragEnd:()=>{Se.current=null,W(null),Nt(null)},children:[p("nav",{class:"weave-ribbon","aria-label":"Workspace tools",children:[p("button",{type:"button","aria-label":"Toggle notes sidebar","aria-pressed":r.treeVisible,title:"Notes",onClick:()=>i({...r,treeVisible:!r.treeVisible}),children:p(ce,{name:"sidebar",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Open graph view",title:"Graph view",onClick:en,children:p(ce,{name:"graph",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Toggle note graph",title:"Note graph","aria-pressed":Ce&&zt,onClick:jn,children:p(ce,{name:"noteGraph",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Search notes and repository",title:ip(ei(ti(e.platform))),onClick:()=>o("search"),children:p(ce,{name:"search",class:"weave-icon"})}),p("span",{class:"weave-ribbon-space"}),p("button",{type:"button","aria-label":"Toggle context sidebar","aria-pressed":zt,title:"Context",onClick:()=>y<1050?_t(!pe):i({...r,contextVisible:!r.contextVisible}),children:p(ce,{name:"context",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{Tt.current?.refresh(),Z(k=>k+1)},children:p(ce,{name:"refresh",class:"weave-icon"})}),p("button",{type:"button","aria-label":vn.hint,title:vn.hint,onClick:()=>i({...r,theme:ao(r.theme,_,r.preferences)}),children:p(ce,{name:vn.icon,class:"weave-icon"})}),p("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>o("settings"),children:p(ce,{name:"settings",class:"weave-icon"})})]}),p("div",{class:"weave-sidebar-dock weave-notes-dock","data-open":r.treeVisible,inert:!r.treeVisible,"aria-hidden":!r.treeVisible,style:{"--weave-sidebar-width":`${Math.min(r.treeWidth,y-90)}px`},children:[p("aside",{class:"weave-sidebar weave-sidebar-notes","aria-label":"Notes sidebar",children:[p("div",{class:"weave-sidebar-heading",children:[p("button",{type:"button","aria-pressed":!te,onClick:()=>ge(!1),children:"Files"}),p("button",{type:"button","aria-pressed":te,onClick:()=>ge(!0),children:"Recent"}),p("button",{type:"button","aria-label":"Hide notes sidebar",onClick:()=>{Ve.current?.querySelector('[aria-label="Toggle notes sidebar"]')?.focus(),i({...r,treeVisible:!1})},children:"«"})]}),te?p(OT,{visits:Fe,graph:t.graph,selectedId:Ee,onSelect:dt}):p(dp,{graph:t.graph,selectedId:Ee,recentIds:t.recentIds,onSelect:(k,S,B)=>dt(k,S,r.activePane,B),onMutate:wi,onRefresh:()=>Tt.current?.refresh(),now:c}),p("div",{class:"weave-vault-label",children:[p("span",{children:"Workspace"}),p("strong",{title:e.cwd,children:e.cwd.split(/[\\/]/).filter(Boolean).pop()??"Weave"})]})]}),p(Kn,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:k=>i(S=>({...S,treeWidth:Math.max(180,Math.min(420,S.treeWidth+k))}))})]}),p("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&y>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:C?r.panes.map((k,S)=>p(be,{children:[S>0&&y>=850?p(Kn,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:B=>{let Q=r.split==="right"?Ve.current?.querySelector("main")?.clientWidth:Ve.current?.querySelector("main")?.clientHeight;i(I=>({...I,ratio:Math.max(.2,Math.min(.8,I.ratio+B/(Q??800)))}))}}):null,lo(k)]})):p("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),p("div",{class:`weave-sidebar-dock weave-context-dock${Xt?" weave-context-float":""}`,"data-open":xn,inert:!xn,"aria-hidden":!xn,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[p(Kn,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:k=>i(S=>({...S,contextWidth:Math.max(180,Math.min(400,S.contextWidth-k))}))}),p("aside",{class:"weave-sidebar weave-sidebar-context","aria-label":"Context sidebar",children:[p("div",{class:"weave-sidebar-heading weave-context-heading",children:[p("strong",{children:"Context"}),p("span",{class:"weave-context-count",children:yn}),p("button",{type:"button",class:"weave-context-pin","aria-pressed":r.contextPinned,"aria-label":r.contextPinned?"Float context over the page":"Dock context as a column",title:r.contextPinned?"Float over the page":"Dock as a column",onClick:()=>i({...r,contextPinned:!r.contextPinned}),children:p(ce,{name:"pin",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Hide context sidebar",title:"Fold (])",onClick:()=>{Ve.current?.querySelector('[aria-label="Toggle context sidebar"]')?.focus(),_t(!1),i({...r,contextVisible:!1})},children:Xt?p(ce,{name:"chevron",class:"weave-icon weave-icon-open"}):"»"})]}),Ce?p("section",{class:"weave-context-graph-section","aria-label":"Note connections",children:[p("div",{class:"weave-context-graph-heading",children:[p("strong",{children:"Note graph"}),p("button",{type:"button","aria-label":"Hide note graph",onClick:()=>{Ve.current?.querySelector('[aria-label="Toggle note graph"]')?.focus(),l(!1)},children:"×"})]}),p("div",{class:"weave-context-graph-slot",ref:mn,style:{height:r.contextGraphHeight},children:yt===null?p("p",{children:"Select a note to see its connections."}):null}),p(Kn,{label:"Resize note graph",horizontal:!0,min:120,max:800,value:Tr.height,onChange:k=>i(S=>({...S,contextGraphHeight:Math.max(120,Math.min(800,(mn.current?.clientHeight??S.contextGraphHeight)+k))}))})]}):null,p(bm,{graph:t.graph,selectedId:Ee,onSelect:dt,trail:xi,trailTurn:w?.turn??null,onReplay:Cr,tagHeight:r.contextTagsHeight,onTagResize:k=>i(S=>({...S,contextTagsHeight:k}))})]})]}),Xt&&!zt&&!_i?p("button",{type:"button",class:"weave-context-pill","aria-label":`Show context, ${yn} items`,title:"Show context (])",onClick:Qt,children:[p(ce,{name:"context",class:"weave-icon"}),"Context",p("span",{class:"weave-context-count",children:yn})]}):null,vi||s?p("div",{class:`weave-graph-host${Ce?" weave-context-graph-host":""}`,onDragOver:k=>{!Ce&&$e&&Lr($e.id,k)},onDrop:k=>{!Ce&&$e&&Si($e.id,k)},onDragLeave:k=>{k.currentTarget.contains(k.relatedTarget)||W(null)},onPointerDown:()=>{!Ce&&$e&&i(k=>({...k,activePane:$e.id}))},onFocusCapture:()=>{!Ce&&$e&&i(k=>({...k,activePane:$e.id}))},"aria-hidden":!tt,inert:!tt,role:Ce?"region":void 0,"aria-label":Ce?"Note graph":void 0,style:{...Tr,visibility:tt?"visible":"hidden",pointerEvents:tt?"auto":"none"},children:p(pp,{graph:t.graph,selectedId:Ee,previewId:Ye,onSelect:tn,onOpen:ht,renderer:If,storage:localStorage,host:window,scheme:Vn,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:_r,trail:bn,...Ce?{}:{query:we,...Te?.query===we?{found:Te.ids}:{},byAgent:Pe!==null,onQuery:so,onOpenSplit:Er},now:c})}):null]}),p("div",{class:"weave-footer",children:[p(Dm,{model:np(e.cwd,Ee,ei(ti(e.platform)))}),P?p("span",{role:"status",children:"Workspace restoration unavailable"}):null,ie.dirtySlugs().length?p("span",{children:[ie.dirtySlugs().length," unsaved"]}):null,y<850&&r.panes.length>1?p("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(k=>k.id!==$t.id).id}),children:"Switch pane"}):null]}),a==="search"?p(Zg,{graph:t.graph,onSelect:dt,onLightUp:Rr,onClose:()=>o(null),ports:{fetch:_e}}):null,a==="settings"?p(Lm,{compact:y<=650,layout:r,info:N,cwd:e.cwd,shortcut:ei(ti(e.platform)),onChange:k=>{St(k),_t(k.contextVisible)},onRefresh:()=>{Tt.current?.refresh(),Z(k=>k+1)},onClose:()=>o(null)}):null,a==="help"?p(Nm,{shortcut:ei(ti(e.platform)),onClose:()=>o(null)}):null]})}var $m=`
418
+ `);return{value:e.value.slice(0,n)+o+e.value.slice(a),start:n,end:n+o.length}}var yg=/^#{1,6}[ \t]+/,bg=/^([ \t]*)[-*+][ \t]+\[[ xX]\][ \t]+/,xg=/^([ \t]*)[-*+][ \t]+/;function Rg(e,t){switch(t){case"bold":return Ya(e,"**","**","bold text");case"italic":return Ya(e,"_","_","italic text");case"wikilink":return Ya(e,"[[","]]","note title");case"link":{let n=e.value.slice(e.start,e.end);if(n==="")return Ya(e,"[","](https://)","link text");let r=`${e.value.slice(0,e.start)}[${n}](https://)${e.value.slice(e.end)}`,i=e.start+n.length+3;return{value:r,start:i,end:i+8}}case"heading":return wg(e,n=>yg.test(n)?n.replace(yg,""):`## ${n}`);case"task":return wg(e,n=>bg.test(n)?n.replace(bg,"$1"):xg.test(n)?n.replace(xg,"$1- [ ] "):`- [ ] ${n}`)}}function Ag(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;let i=0;for(;i<n-r&&e.charCodeAt(e.length-1-i)===t.charCodeAt(t.length-1-i);)i++;return{start:r,end:e.length-i,text:t.slice(r,t.length-i)}}var C_="weave-preview-x",L_="weave-preview-y";function N_({view:e,open:t,editing:n,taskSaving:r,onEdit:i,replaying:a,onHistory:o}){return p("header",{class:"weave-note-head",children:[p("p",{class:"weave-note-crumb",children:[p(ce,{name:"folder",class:"weave-icon"}),e.folder]}),p("h3",{class:"weave-note-title",children:e.title}),n?null:p("p",{class:"weave-note-meta",children:[p("span",{class:`weave-prov weave-prov-${e.provenance}`,title:e.provenanceTitle,children:[p("span",{class:"weave-prov-dot","aria-hidden":"true"}),e.byline]}),p("span",{class:"weave-note-time",title:`${xh} ${e.created} · ${e.createdIso}`,children:[bh," ",e.updated]}),p("span",{class:"weave-note-actions",children:[o===null?null:p("button",{type:"button",class:"weave-note-action weave-note-history","aria-pressed":a,onClick:o,children:[p(ce,{name:"history",class:"weave-icon"}),a?pg:hg]}),a?null:p("button",{type:"button",class:"weave-note-action weave-note-edit",disabled:r,onClick:i,children:[p(ce,{name:"edit",class:"weave-icon"}),kh]}),p("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:t,children:p("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})})]})]}),e.tags.length===0?null:p("p",{class:"weave-note-tags",children:e.tags.map(s=>p("span",{class:"weave-tag",children:Nh(s)},s))})]})}function P_({status:e,busy:t,onFormat:n,onRetry:r,onDiscard:i,onDone:a}){return p("div",{class:"weave-editbar",role:"toolbar","aria-label":Dl,children:[p("span",{class:"weave-editbar-badge",children:[p(ce,{name:"edit",class:"weave-icon"}),Dl]}),p("span",{class:"weave-editbar-tools",children:Il.map(o=>p("button",{type:"button",class:"weave-editbar-tool",title:o.key===null?o.label:`${o.label} (⌘${o.key.toUpperCase()})`,"aria-label":o.label,onMouseDown:s=>s.preventDefault(),onClick:()=>n(o.kind),children:p(ce,{name:o.icon,class:"weave-icon"})},o.kind))}),p("span",{class:`weave-editbar-status weave-editbar-${e.kind}`,role:"status",children:[e.kind==="saved"?p(ce,{name:"check",class:"weave-icon"}):null,e.label,e.kind==="failed"?p("button",{type:"button",class:"weave-editbar-retry",onClick:r,children:_g}):null]}),p("button",{type:"button",class:"weave-editbar-discard",disabled:t||e.kind==="saving",onClick:i,children:kg}),p("button",{type:"button",class:"weave-editbar-done",disabled:t,onClick:a,children:_h})]})}function Cg(e){let t=V(Va()),n=e.drafts??t.current,r=Cc(),i=`${e.idPrefix??r}-weave-preview`,[a,o]=K(0);ne(()=>n.subscribe(()=>o(L=>L+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),c=ph(e.graph,e.selectedId),u=Mh(e.selectedId,s,e.loadFailed),d=De(()=>s===null?null:fh(e.graph,s.slug),[s,e.graph]),h=De(()=>s===null||d===null?"":Ds(Cl,l,d),[s,l,d]),[f,g]=K(va),w=L=>{g(W=>Ih(W,L))},v=V(null),y=V(null),b=V(null),_=V(!1),x=s===null?null:n.get(s.slug),[R,O]=K(!1),N=s!==null&&n.isTaskSaving(s.slug),j=()=>{s!==null&&!n.isTaskSaving(s.slug)&&n.save(s.slug,e.onSave,{keepOpen:!0})},P=async(L,W)=>{let te=()=>{L.checked=!L.checked,L.setAttribute("aria-label",wa(L.checked))};if(s===null||n.isTaskSaving(s.slug)){te();return}let ge=mh(n.getTaskBody(s.slug,s.body),W);if(ge===null){te();return}let Fe=[...v.current?.querySelectorAll(`input[${$n}]`)??[]];L.setAttribute("aria-label",wa(L.checked));for(let wt of Fe)wt.disabled=!0;try{await n.saveTask(s.slug,ge,e.onSave)||te()}catch(wt){throw te(),wt}finally{for(let wt of Fe)wt.disabled=n.isTaskSaving(s.slug)}},A=V(null);ne(()=>{s!==null&&A.current!==s.slug&&(A.current=s.slug,e.defaultEdit&&n.get(s.slug)===null&&(_.current=!0,n.open(s.slug,l)))},[s?.slug,e.defaultEdit]);let H=()=>{s===null||n.isTaskSaving(s.slug)||n.get(s.slug)!==null||(_.current=!0,n.open(s.slug,l))},Z=V(!1),G=()=>{if(!(s===null||x===null||n.isTaskSaving(s.slug))){if(x.saving){Z.current=!0;return}Z.current=!1,n.isDirty(s.slug)?n.save(s.slug,e.onSave):n.discard(s.slug)}},J=()=>{if(s===null||x===null||x.saving)return;if(Z.current=!1,x.baseline!==x.original||x.rawBaseline!==x.originalRaw){if(!window.confirm(Tg))return;n.revert(s.slug)?n.save(s.slug,e.onSave):n.discard(s.slug)}else(!n.isDirty(s.slug)||window.confirm(ya))&&n.discard(s.slug)},X=V(null),se=V("body"),Ye=L=>{if(s===null)return;let W=se.current==="raw"&&X.current!==null,te=W?X.current:b.current;if(te===null)return;let ge=Rg({value:te.value,start:te.selectionStart,end:te.selectionEnd},L),Fe=Ag(te.value,ge.value);te.focus(),te.setSelectionRange(Fe.start,Fe.end),(!(typeof document.execCommand=="function"&&document.execCommand(Fe.text===""?"delete":"insertText",!1,Fe.text))||te.value!==ge.value)&&(te.value=ge.value),W?n.editRaw(s.slug,ge.value):n.edit(s.slug,ge.value),te.setSelectionRange(ge.start,ge.end)},Ae=L=>{if(L.key==="Escape"){L.stopPropagation(),G();return}if(!(L.metaKey||L.ctrlKey)||L.altKey)return;if(L.key.toLowerCase()==="s"){L.preventDefault(),s!==null&&n.isDirty(s.slug)&&j();return}let W=Eg(L.key);W===null||L.shiftKey||(L.preventDefault(),Ye(W))};ne(()=>{if(s===null||x===null||x.saving||x.failed||!n.isDirty(s.slug))return;let L=window.setTimeout(j,2500);return()=>window.clearTimeout(L)},[s?.slug,x,x?.body,x?.raw,x?.saving,x?.failed]),ne(()=>{Z.current&&x!==null&&!x.saving&&G()},[x?.saving]);let ye=f.anchor===null?null:Ph(e.graph,f.anchor);ze(()=>{let L=b.current;L===null||!_.current||(_.current=!1,L.focus(),L.setSelectionRange(L.value.length,L.value.length))},[x!==null]);let[ue,Te]=K(null),ct=V(null),Pe=e.onHistory,oe=()=>{if(s===null||Pe===void 0)return;if(ue!==null){ct.current=null,Te(null);return}let L=s.slug;ct.current=L,Te({revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:null}),Pe(L).then(W=>{ct.current===L&&Te(W.ok?{revisions:W.data.revisions,enabled:W.data.enabled,trimmed:W.data.trimmed,index:Math.max(0,W.data.revisions.length-1),playing:!1,error:null}:{revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:`Could not load history: ${W.message}`})})},Se=ue?.revisions==null?null:qa(ue.revisions,ue.index),ut=De(()=>Se===null||d===null?null:Ds(Cl,Se.marked,d),[Se?.marked,d]);if(ze(()=>{ct.current=null,Te(null),O(!1)},[s===null?null:s.slug]),ze(()=>{if(ut===null||v.current===null)return;let L=mg(v.current);Se?.follow&&L?.scrollIntoView?.({block:"nearest"})},[ut]),ne(()=>{if(ue===null||!ue.playing||ue.revisions===null)return;let L=ue.revisions.length,W=window.setTimeout(()=>{Te(te=>{if(te===null)return te;let ge=dg(te.index,L);return ge===null?{...te,playing:!1}:{...te,index:ge}})},sg);return()=>window.clearTimeout(W)},[ue]),ze(()=>{s!==null&&(n.taskBody(s.slug,s.body,e.loadVersion),n.syncTail(s.slug,s.body))},[n,s===null?null:s.slug,s?.body,e.loadVersion]),ze(()=>{w({type:"hide"})},[s===null?null:s.slug]),ze(()=>{if(s===null)return;let L=n.isTaskSaving(s.slug);for(let W of v.current?.querySelectorAll(`input[${$n}]`)??[])W.disabled=L},[s===null?null:s.slug,a,h]),ze(()=>{let L=v.current;if(L!==null){let ge=f.anchor?.slug??null;for(let Fe of L.querySelectorAll(`a[${jt}]`))ge!==null&&Fe.getAttribute(jt)===ge?Fe.setAttribute("aria-describedby",i):Fe.removeAttribute("aria-describedby")}let W=y.current;if(W===null||ye===null)return;let te=Dh(f.pointerX,f.pointerY,W.offsetWidth,W.offsetHeight,window.innerWidth,window.innerHeight);W.style.setProperty(`--${C_}`,`${te.x}px`),W.style.setProperty(`--${L_}`,`${te.y}px`)},[f,ye,i]),c!==null){let L=e.graph?.model.nodes.find(ge=>ge.id===e.selectedId),W=L?.label??c,te=L===void 0?c:hh(L)??c;return p("article",{class:"weave-note weave-note-artifact",children:[p("header",{class:"weave-note-head",children:[p("h3",{class:"weave-note-title",children:W}),p("p",{class:"weave-note-meta",children:p("span",{class:"weave-note-time",children:c})})]}),p("iframe",{class:"weave-artifact-frame",title:W,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(c)}`},te)]},te)}if(s===null||d===null)return p("p",{class:"weave-note-empty",children:u});let Nt=Lh(s,e.now);return p("article",{class:`weave-note weave-note-${Nt.provenance}`,children:[x===null?null:p(P_,{status:Sg({saving:x.saving,failed:x.failed,dirty:n.isDirty(s.slug),savedAt:x.savedAt}),busy:N,onFormat:Ye,onRetry:j,onDiscard:J,onDone:G}),p(N_,{view:Nt,open:()=>e.onOpen(s.slug),editing:x!==null,taskSaving:N,onEdit:H,replaying:ue!==null,onHistory:Pe===void 0?null:oe}),ue===null?null:p(vg,{state:ue,now:e.now,onIndex:L=>Te(W=>W===null?W:{...W,index:L,playing:!1}),onPlay:()=>Te(L=>{if(L===null||L.revisions===null)return L;if(L.playing)return{...L,playing:!1};let W=L.index>=L.revisions.length-1;return{...L,index:W?0:L.index,playing:!0}})}),x!==null?p(xe,{children:[p("textarea",{ref:b,class:"weave-note-editor","aria-label":Th,placeholder:Sh,spellcheck:e.spellcheck??!0,value:x.body,onInput:L=>n.edit(s.slug,L.target.value),onFocus:()=>{se.current="body"},onKeyDown:Ae}),x.tail===""?null:p("section",{class:"weave-raw","aria-label":Eh,"data-open":R?"":void 0,children:[p("div",{class:"weave-raw-head",children:[p("button",{type:"button",class:"weave-raw-toggle","aria-expanded":R,"aria-controls":`${e.idPrefix??r}-weave-raw`,onClick:()=>O(L=>!L),children:[p("svg",{class:"weave-raw-chevron",width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:p("path",{d:"M4.5 2.5 8 6l-3.5 3.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})}),Ah]}),p("span",{class:"weave-raw-hint",children:Ch(x.raw,R)})]}),R?p("textarea",{id:`${e.idPrefix??r}-weave-raw`,class:"weave-raw-editor","aria-label":Rh,spellcheck:e.spellcheck??!0,value:x.raw,ref:X,onInput:L=>n.editRaw(s.slug,L.target.value),onFocus:()=>{se.current="raw"},onKeyDown:Ae}):null]})]}):p("div",{ref:v,class:"weave-note-body",tabIndex:-1,onMouseOver:L=>{let W=Ms(L.target);w(W!==null?{type:"show",anchor:W,x:L.clientX,y:L.clientY}:{type:"hide"})},onMouseLeave:()=>w({type:"hide"}),onFocus:L=>{let W=Ms(L.target);if(W===null)return;let te=L.target.getBoundingClientRect?.();w({type:"show",anchor:W,x:te?.left??0,y:te?.bottom??0})},onBlur:()=>w({type:"hide"}),onClick:L=>{let W=L.target,te=vh(W);if(te!==null&&ut!==null){L.preventDefault();return}if(te!==null){P(W,te);return}let ge=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(yh(ge))return;let Fe=Is(L.target);Fe!==null&&e.onSelect(Fe,L.metaKey||L.ctrlKey||L.shiftKey)},onKeyDown:L=>{if(L.key==="Escape"&&f.anchor!==null){L.stopPropagation(),w({type:"dismiss"});return}if(L.key!=="Enter"&&L.key!==" ")return;let W=Is(L.target);W!==null&&(L.preventDefault(),e.onSelect(W,L.metaKey||L.ctrlKey||L.shiftKey))},dangerouslySetInnerHTML:{__html:ut??h}}),ye===null?null:p("div",{ref:y,id:i,role:"tooltip",class:`weave-preview${ye.ghost?" weave-preview-ghost":""}`,children:[p("span",{class:"weave-preview-kind",children:ye.kind}),p("span",{class:"weave-preview-title",children:ye.title}),ye.text===""?null:p("p",{class:"weave-preview-text",children:ye.text})]})]},s.slug)}var Lg=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Ng(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 Pg(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Dg(e){return e===null?!1:(e.focus(),!0)}function br(){let e=V(null);return ne(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Dg(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Pg(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Lg)??[]],r=Ng(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}var Ig=20,D_=10,Og=140,Fg=["notes","code","tags"],I_=["all",...Fg],Mg={all:"All",notes:"Notes",code:"Code",tags:"Tags"},M_=["note:","vfolder:","artifact:"];function Xa(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.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 G_(e){return Math.min(Math.max(e,0),D_)*2}function O_(e){return`note:${e}`}function F_(e,t){return Xa(e.summary.title,t)+G_(e.score)}function $_(e,t){return Xa(e.label,t)}var z_=["path","manifest","url","slug"];function H_(e){for(let t of z_){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}var W_=["preview","summary","description"];function U_(e){for(let n of W_){let r=e.detail[n];if(typeof r=="string"&&r)return r}let t=H_(e);return t===e.label?"":t}var B_={entryPoint:"entry point",gitState:"git",external:"remote"};function K_(e){return e.id.startsWith("vfolder:")?"folder":e.id.startsWith("artifact:")?"artifact":B_[e.kind]??e.kind}function V_(e){return e.kind==="vault"||M_.some(t=>e.id.startsWith(t))?"notes":"code"}function $g(e){return e.id.startsWith("note:")?e.id.slice(5):e.id.startsWith("artifact:")?e.id.slice(9):""}function j_(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 Fl(e){let t=e.trim();return t.startsWith("#")?t.slice(1).trim():null}function $l(e){return Fl(e)===null?e.trim():""}function q_(e){return e===1?"1 note":`${e} notes`}function Y_(e,t){let n=Fl(t),r=[];for(let[i,a]of Object.entries(e)){let o=n===""?1:Xa(i,n??t);o&&r.push({id:`tag:${i}`,kind:"tag",group:"tags",icon:"tag",label:`#${i}`,detail:q_(a.length),badge:"tag",score:o,path:"",updated:""})}return r.sort((i,a)=>a.score-i.score)}function Z_(e,t){let n=new Map;for(let[r,i]of Object.entries(e)){let a=Xa(r,t);if(a)for(let o of i)n.set(o,Math.max(a,n.get(o)??0))}return n}function X_(e,t){let{slug:n,title:r,updated:i}=e.summary;return{id:O_(n),kind:"note",group:"notes",icon:"note",label:r,detail:e.snippet,badge:"note",score:F_(e,t),path:n,updated:i}}function Q_(e,t){return{id:e.id,kind:"node",group:V_(e),icon:e.kind,label:e.label,detail:U_(e),badge:K_(e),score:t,path:$g(e),updated:e.detail.updated??""}}function zg(e,t,n,r,i={}){let a=Fl(r),o=a?Z_(i,a):new Map,s=new Map;for(let u of e){let d=X_(u,t);s.set(d.id,d)}for(let u of n){if(s.has(u.id))continue;let d=a===null?$_(u,r):u.kind==="note"?o.get($g(u))??0:0;d&&s.set(u.id,Q_(u,d))}let l=[...s.values()].sort(j_),c=u=>l.filter(d=>d.group===u).slice(0,Ig);return[...c("notes"),...c("code"),...Y_(i,r).slice(0,Ig)]}var J_=/(?:\*\*|__)TL;?DR[ \t]*:?[ \t]*(?:\*\*|__)[ \t]*:?|\bTL;?DR[ \t]*:/i;function eT(e){let t=J_.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=n.search(/\n[ \t]*\n|(?:^|\s)#{1,6}\s/),i=(r<0?n:n.slice(0,r)).trim();return i===""?null:i}var Za="\0";function tT(e){let t=[];return e.replace(/`{3,}[^\s`]*/g," ").replace(/`([^`\n]*)`/g,(n,r)=>`${Za}${t.push(r)-1}${Za}`).replace(/!?\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/g,(n,r,i)=>(i||r).trim()).replace(/^(…?)(?:[^[\]|]*\|)?([^[\]]*)\]\]/,"$1$2").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?$/,(n,r,i)=>i||r).replace(/\[\[|\]\]/g,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/<\/?[a-z][^>]*>/gi," ").replace(/(^|\s)#{1,6}(?=\s)/g,"$1").replace(/(^|\n)[ \t]*>[ \t]?/g,"$1").replace(/(^|\s)([-*_])(?:[ \t]?\2){2,}(?=\s|$)/g,"$1").replace(/(^|\s)[-*+][ \t]+\[[ xX]\][ \t]*/g,"$1").replace(/(^|\n)[ \t]*(?:[-*+]|\d+[.)])[ \t]+/g,"$1").replace(/(\s)\*(?=\s)/g,"$1").replace(/(\*\*|~~)(?=\S)([\s\S]*?\S)\1/g,"$2").replace(/(^|[^\w])__(?=\S)([\s\S]*?\S)__(?!\w)/g,"$1$2").replace(/(^|[^\w*])\*(?=\S)([^*\n]*?\S)\*(?![\w*])/g,"$1$2").replace(/(^|[^\w])_(?=\S)([^_\n]*?\S)_(?!\w)/g,"$1$2").replace(/\*{2,}|~~/g,"").replace(/\\([\\`*_#[\]|])/g,"$1").replace(new RegExp(`${Za}(\\d+)${Za}`,"g"),(n,r)=>t[Number(r)]).replace(/\s+/g," ").trim()}function nT(e){return tT(eT(e)??e)}var rT=2;function iT(e){let t=e.trim().replace(/^#/,"").trim();return t?[...new Set([t,...t.split(/\s+/).filter(n=>n.length>=rT)])]:[]}function aT(e,t){let n=[];for(let i of iT(t)){let a=new RegExp(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi");for(let o of e.matchAll(a))n.push([o.index,o.index+o[0].length])}n.sort((i,a)=>i[0]-a[0]||i[1]-a[1]);let r=[];for(let i of n){let a=r[r.length-1];a!==void 0&&i[0]<=a[1]?a[1]=Math.max(a[1],i[1]):r.push(i)}return r}var oT=40,sT=16;function Gg(e,t){let n=[],r=0;for(let[i,a]of t)i>r&&n.push({text:e.slice(r,i),mark:!1}),n.push({text:e.slice(i,a),mark:!0}),r=a;return r<e.length&&n.push({text:e.slice(r),mark:!1}),n}function lT(e,t){let n=nT(e),r=aT(n,t),i=r[0];if(i===void 0||i[0]<=oT)return Gg(n,r);let a=i[0]-sT,o=n.indexOf(" ",a),s=o>=0&&o<i[0]?o+1:a,l=s-1;return Gg(`…${n.slice(s)}`,r.map(([c,u])=>[c-l,u-l]))}function cT(e){return e.split("/").slice(0,-1).join("/")}function uT(e,t){return Ut(e,t).replace(/ ago$/,"")}function dT(e,t){return e.kind==="tag"?"":e.updated?[cT(e.path),uT(e.updated,t)].filter(n=>n!=="").join(" · "):e.badge}var Hg={d:["M11.25 7a4.25 4.25 0 1 1-8.5 0 4.25 4.25 0 0 1 8.5 0Z","M10.25 10.25 13.5 13.5"],filled:!1},hT={d:["M2.75 2.75h5l5.5 5.5-5 5-5.5-5.5Z","M5.5 5.5h.01"],filled:!1};function pT(e){return e==="tag"?hT:ka[e]}function Wg(){return{query:"",answered:"",hits:[],cursor:0,scope:"all",loading:!1,failed:!1}}function Ml(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Gl(e,t,n){return n<=0?0:((e+t)%n+n)%n}function fT(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Ml(e,n);return t==="ArrowDown"?{...r,cursor:Gl(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Gl(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Ml(n-1,n),handled:!0}:t==="Escape"?{...r,dismiss:!0,handled:!0}:t!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}function gT(e){let t=n=>e.filter(r=>r.group===n).length;return{all:e.length,notes:t("notes"),code:t("code"),tags:t("tags")}}function Ug(e){return I_.filter(t=>t==="all"||e[t]>0)}function mT(e,t){return Ug(t).includes(e)?e:"all"}function vT(e,t,n){return e[Gl(Math.max(e.indexOf(t),0),n?-1:1,e.length)]??"all"}var Qa="Search the workspace",Bg="Search notes and repository…",Kg="↑↓ move · ↵ open · ⌘↵ open in new tab · Tab scope",Vg="Search scope",jg="⇧↵";function qg(e){return`Light up ${e} in the graph`}function wT(e,t){return e.query.trim()?t>0?null:e.failed?"search failed — the workspace server may be gone":e.loading?"searching…":`no matches for “${e.query.trim()}”`:"Type to search notes and code. Start with # to find tags."}function Yg(e){return`weave-search-row-${e}`}function yT(e){return`weave-search-group-${e}`}function bT(e,t,n,r,i){return{id:e.id,kind:e.kind,group:e.group,label:e.label,icon:pT(e.icon),mono:e.group==="code",parts:lT(e.detail,r),meta:dT(e,i),active:t===n,domId:Yg(t),index:t}}function xT(e,t,n){return(e.answered===$l(e.query)?n:zg([],"",t?.model.nodes??[],e.query,t?.tags??{})).filter(i=>i.kind!=="tag").map(i=>i.id)}function Zg(e,t,n){let r=e.query.trim(),i=zg(e.hits,e.answered,t?.model.nodes??[],e.query,t?.tags??{}),a=gT(i),o=mT(e.scope,a),s=o==="all"?i:i.filter(h=>h.group===o),l=Ml(e.cursor,s.length),c=s.map((h,f)=>bT(h,f,l,e.query,n)),u=Fg.flatMap(h=>{let f=c.filter(g=>g.group===h);return f.length?[{group:h,heading:`${Mg[h]} · ${f.length}`,domId:yT(h),rows:f}]:[]}),d=r?Ug(a).map(h=>({scope:h,label:Mg[h],count:a[h],active:h===o})):[];return{groups:u,rows:c,scopes:d,scope:o,status:wT(e,s.length),count:s.length,cursor:l,activeDomId:c.length?Yg(l):null,query:r,lightUp:xT(e,t,i)}}var Ol={type:"none"};function zl(e,t){return e.kind==="tag"?{type:"tag",query:`#${e.id.slice(4)}`}:{type:"open",id:e.id,newTab:t}}function Hl(e){return e.query&&e.lightUp.length>0?{type:"lightUp",query:e.query,ids:e.lightUp}:Ol}function Xg(e,t,n){if(t.key==="Tab")return!t.inInput||t.mod||e.scopes.length<2?Ol:{type:"scope",scope:vT(e.scopes.map(i=>i.scope),e.scope,t.shift)};if(t.key==="Enter"&&t.shift&&n)return Hl(e);let r=fT(e.cursor,t.key,e.count);return r.handled?r.activate!==null?zl(e.rows[r.activate],t.mod):r.dismiss?{type:"close"}:{type:"move",cursor:r.cursor}:Ol}function Qg(e,t){return t.type==="move"?t.cursor===e.cursor?e:{...e,cursor:t.cursor}:t.type==="scope"?{...e,scope:t.scope,cursor:0}:t.type==="tag"?{...e,query:t.query,scope:"notes",cursor:0}:e}function Jg(e){return e.type==="open"||e.type==="lightUp"||e.type==="close"}function em({def:e,class:t}){return p("svg",{class:t,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:e.filled?"currentColor":"none",stroke:e.filled?void 0:"currentColor","stroke-width":e.filled?void 0:e.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:e.d.map(n=>p("path",{d:n}))})}function kT({row:e,onPick:t,onHover:n}){return p("li",{id:e.domId,role:"option","aria-selected":e.active,class:`weave-hit weave-hit-${e.group}${e.active?" weave-hit-on":""}`,onMouseMove:n,onClick:r=>t(r.metaKey||r.ctrlKey),children:[p(em,{def:e.icon,class:"weave-icon weave-hit-icon"}),p("span",{class:e.mono?"weave-hit-label weave-hit-mono":"weave-hit-label",children:e.label}),p("span",{class:"weave-hit-detail",children:e.parts.map(r=>r.mark?p("mark",{class:"weave-hit-mark",children:r.text}):r.text)}),e.meta?p("span",{class:"weave-hit-meta",children:e.meta}):null]})}function tm(e){let[t,n]=K(Wg),r=V(0),i=V(null),a=br(),o=V(null);ne(()=>{o.current?.focus()},[]),ne(()=>{let c=$l(t.query),u=!0;if(!c)return i.current?.abort(),n(h=>({...h,hits:[],answered:"",loading:!1,failed:!1})),()=>{u=!1};let d=window.setTimeout(async()=>{let h=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(w=>({...w,loading:!0,failed:!1}));let g=await qc(e.ports.fetch,c,f.signal);!u||f.signal.aborted||h!==r.current||n(w=>g.ok?{...w,hits:g.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...w,loading:!1,failed:!0})},Og);return()=>{u=!1,window.clearTimeout(d),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Zg(t,e.graph,Date.now()),l=c=>{c.type==="open"&&e.onSelect(c.id,c.newTab),c.type==="lightUp"&&e.onLightUp?.(c.query,c.ids),Jg(c)?e.onClose():n(u=>Qg(u,c)),(c.type==="scope"||c.type==="tag")&&o.current?.focus()};return p("div",{class:"weave-scrim",onClick:()=>l({type:"close"}),children:p("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Qa,tabIndex:-1,ref:a.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{let u=Xg(s,{key:c.key,shift:c.shiftKey,mod:c.metaKey||c.ctrlKey,inInput:c.target===o.current},e.onLightUp!==void 0);if(u.type==="none"){a.onKeyDown(c);return}c.preventDefault(),l(u)},children:[p("div",{class:"weave-palette-bar",children:[p(em,{def:Hg,class:"weave-icon weave-palette-glyph"}),p("input",{type:"search",class:"weave-palette-input",ref:o,value:t.query,placeholder:Bg,role:"combobox","aria-label":Qa,"aria-expanded":s.count>0,"aria-autocomplete":"list","aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:c=>n(u=>({...u,query:c.currentTarget.value,cursor:0}))}),p("kbd",{class:"weave-palette-kbd","aria-hidden":"true",children:"Esc"})]}),s.scopes.length?p("div",{class:"weave-palette-scopes",role:"group","aria-label":Vg,children:s.scopes.map(c=>p("button",{type:"button",class:"weave-palette-scope","aria-pressed":c.active,onClick:()=>l({type:"scope",scope:c.scope}),children:[c.label," ",p("span",{class:"weave-palette-scope-count",children:c.count})]},c.scope))}):null,s.status===null?p("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Qa,children:s.groups.map(c=>p("li",{role:"presentation",class:"weave-hit-section",children:[p("div",{id:c.domId,role:"presentation",class:"weave-hit-group",children:c.heading}),p("ul",{role:"group","aria-labelledby":c.domId,class:"weave-hit-rows",children:c.rows.map(u=>p(kT,{row:u,onPick:d=>l(zl(u,d)),onHover:()=>l({type:"move",cursor:u.index})},u.id))})]},c.group))}):p("p",{class:"weave-palette-status",role:"status",children:s.status}),p("p",{class:"weave-palette-foot",children:[p("span",{children:Kg}),e.onLightUp&&s.lightUp.length>0?p("button",{type:"button",class:"weave-palette-light",onClick:()=>l(Hl(s)),children:[qg(s.lightUp.length)," ",p("kbd",{class:"weave-palette-kbd",children:jg})]}):null]})]})})}function Wl(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Ja=2e3,_T=3e3,rm=new Set;function TT(e,t){if(e===null)return rm;let n=new Set(e.model.nodes.map(r=>r.id));return new Set(t.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function nm(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function im(e){let t=e.state,n=!1,r=!1,i=null,a=h=>{Object.entries(h).every(([f,g])=>t[f]===g)||(t={...t,...h},e.setState(t))},o=e.defer??((h,f)=>{let g=setTimeout(h,f);return()=>clearTimeout(g)}),s=async()=>{let h=nm(t.selectedId);if(h===null){a({note:null,noteFailed:!1});return}let f=await Fo(e.fetch,h);f.ok?a({note:f.data,noteFailed:!1}):a({note:null,noteFailed:!0})},l=async()=>{let h=t.graph,f=await qi(e.fetch,t.graph);if(!f.ok)return t.graph===null&&a({graphFailed:!0}),f;if(!f.cached){let g=TT(h,f.data);a({graph:f.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=o(()=>{i=null,a({recentIds:rm})},_T))}return f},c=async()=>{if(!(n||r)){r=!0;try{let h=await l();nm(t.selectedId)!==null&&(t.note===null||h.ok&&!h.cached)&&await s()}finally{r=!1}}},d=(e.repeat??((h,f)=>{let g=setInterval(h,f);return()=>clearInterval(g)}))(()=>{c()},Ja);return c(),{refresh:()=>{c()},select:async h=>{a({selectedId:h}),await s()},syncNote:s,stop:()=>{n||(n=!0,d(),i?.(),i=null)}}}function am(e,t,n,r=(i,a)=>{let o=setTimeout(i,a);return()=>clearTimeout(o)}){let i=!1,a=null,o=async()=>{if(i)return;let s=await Fo(e,t);i||(n(s),s.ok||(a=r(()=>{o()},Ja)))};return o(),()=>{i=!0,a?.()}}var mi={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function to(e,t,n){return{id:e,target:t.id,label:pt(t),kind:t.kind,kindIcon:Pn(t.kind),provenance:t.provenance,provenanceGlyph:Bt(t.provenance),provenanceTitle:un(t.provenance),selected:t.id===n}}function ST(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:to(e.id,i,n)}function ET(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var RT=["link:links-to:"];function AT(e){return RT.some(t=>e.id.startsWith(t))}function CT(e){return e.id.startsWith("link:mentions:")}function LT(e,t,n,r){let i=[];for(let[a,o]of Object.entries(e.tags)){if(!o.includes(t))continue;let s=[];for(let l of o){if(l===t)continue;let c=n.get(`note:${l}`);c!==void 0&&s.push(to(`tag:${a}:${l}`,c,r))}i.push({tag:a,count:o.length,siblings:s})}return i}function NT(e,t,n,r){let i=[];for(let a of e.edges){if(a.kind!=="mentions"||a.target!==t)continue;let o=n.get(a.source);o!==void 0&&i.push(to(`mentioned-by:${a.source}`,o,r))}return i}function PT(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var eo={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 Ul(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function om(e){return e.groups.reduce((t,n)=>t+n.count,0)+e.tagsCount}function no(e,t){if(e===null)return Ul(eo.loading);if(t===null)return Ul(eo.noSelection);let n=Ln(e),r=jo(n,t);if(r===null)return Ul(eo.unknown);let i=ET(n),a=[],o=(d,h)=>{h.length>0&&a.push({heading:d,count:h.length,rows:h})},s=d=>d.map(h=>ST(h,i,t)).filter(h=>h!==null);o(mi.links,s(r.links.filter(AT)));let l=qo(n.edges).get(t)??[];o(mi.backlinks,l.map(d=>i.get(d)).filter(d=>d!==void 0).map(d=>to(`backlink:${d.id}`,d,t))),o(mi.mentions,[...s(r.links.filter(CT)),...NT(n,t,i,t)]);let c=PT(t),u=c===null?[]:LT(e,c,i,t);return a.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:eo.isolated}:{subject:r.label,groups:a,tags:u,tagsCount:u.length,empty:null}}function sm(){return{open:new Set,closed:new Set}}var DT=8;function lm(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>DT}function IT(e){return e.some(t=>t.selected)}function cm(e,t){let n=lm(t,e.heading,e.count,IT(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function um(e,t){let n=lm(t,mi.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:mi.tags,count:e.length,collapsed:n,rows:[]}}function dm(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 ro(e){return`weave-ctx-panel-${e.toLowerCase()}`}function Kn(e){let t=V(null);return p("div",{class:"weave-workspace-divider",role:"separator",tabIndex:0,"aria-label":e.label,"aria-orientation":e.horizontal?"horizontal":"vertical","aria-valuenow":Math.round(e.value),"aria-valuemin":e.min,"aria-valuemax":e.max,onPointerDown:n=>{t.current=e.horizontal?n.clientY:n.clientX,n.currentTarget.setPointerCapture(n.pointerId)},onPointerMove:n=>{if(t.current===null)return;let r=e.horizontal?n.clientY:n.clientX;e.onChange(r-t.current),t.current=r},onPointerUp:n=>{t.current=null,n.currentTarget.releasePointerCapture(n.pointerId)},onPointerCancel:()=>{t.current=null},onKeyDown:n=>{["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(n.key)&&(n.preventDefault(),e.onChange(n.key==="ArrowLeft"||n.key==="ArrowUp"?-20:20))}})}var hm={searched:0,read:1,wrote:2},pm=new Map;function gm(e,t){return t===null?e.events.map(n=>({event:n,at:Date.parse(n.at)})):e.events.filter(n=>n.turn===t.turn).map((n,r)=>({event:n,at:t.startedAt+r*700}))}function mm(e,t,n=null){if(e===null)return pm;let r=new Map,i=new Map;for(let{event:a,at:o}of gm(e,n)){let s=t-o;if(n!==null&&s<0)continue;let l=Math.min(1,1-s/6e4);if(l>0)for(let c of a.slugs){let u=`note:${c}`,d=i.get(u)===a.turn?r.get(u):void 0,h=d===void 0||hm[a.kind]>hm[d.kind]?a.kind:d.kind;r.set(u,{kind:h,strength:Math.max(l,d?.strength??0)}),i.set(u,a.turn)}}return r.size===0?pm:r}function vm(e,t,n=null){return e===null?!1:gm(e,n).some(({at:r})=>t-r<6e4)}var MT={add:"created",append:"appended",finalize:"finalized",links:"fixed links in"};function GT(e,t){let n=e.slugs.map(r=>({id:`note:${r}`,label:t.get(`note:${r}`)??r}));if(e.kind==="searched"){let r=e.slugs.length;return{key:`${e.seq}:s`,kind:"searched",verb:e.query===void 0?"searched":`searched "${e.query}"`,notes:[],detail:r===0?"no hits":`${r} hit${r===1?"":"s"}`}}return{key:`${e.seq}:${e.kind}`,kind:e.kind,verb:e.kind==="read"?"read":MT[e.action]??"wrote",notes:n,detail:null}}function fm(e,t=!1){let n=new Date(e);return Number.isNaN(n.getTime())?"":[n.getHours(),n.getMinutes(),...t?[n.getSeconds()]:[]].map(i=>String(i).padStart(2,"0")).join(":")}function wm(e,t){if(e===null||e.events.length===0)return[];let n=new Map((t?.model.nodes??[]).map(s=>[s.id,s.label])),r=new Map;for(let s of e.events){let l=r.get(s.turn);l===void 0?r.set(s.turn,[s]):l.push(s)}let i=[...r.entries()].sort(([s],[l])=>l-s),a=i.map(([,s])=>fm(s[0].at)),o=i.map(([s,l],c)=>{let u=new Set(l.filter(h=>h.kind!=="searched").flatMap(h=>h.slugs)),d=a.filter(h=>h===a[c]).length>1;return{turn:s,time:fm(l[0].at,d),steps:l.map(h=>GT(h,n)),used:u.size}});return e.turn>o[0].turn&&o.unshift({turn:e.turn,time:"",steps:[],used:0}),o.slice(0,5)}var ym="Nothing recalled yet.";function Bl(e,t){return t?"This turn":e.time===""?`Turn ${e.turn}`:e.time}function bm(e){if(e===null)return null;for(let t=e.events.length-1;t>=0;t--){let n=e.events[t];if(n.turn!==e.turn)return null;if(!(n.kind!=="searched"||n.query===void 0||n.query.trim()===""))return{seq:n.seq,query:n.query,ids:n.slugs.map(r=>`note:${r}`)}}return null}function xm(e,t,n){return t===null?e===null?null:{query:"",ids:[],agent:null}:t.seq===e||n&&e===null?null:{query:t.query,ids:t.ids,agent:t.seq}}function km(e){let t=e.turns[0];if(t===void 0)return null;let n=e.turns.find(r=>r.turn===e.shownTurn)??t;return p("section",{class:"weave-ctx-group weave-trail","aria-label":"What your agent recalled",children:[p("h4",{class:"weave-ctx-head weave-trail-head",children:[p("span",{class:"weave-trail-title",children:Bl(n,n===t)}),p("span",{class:"weave-ctx-count",title:"Notes read or written",children:n.used})]}),n.steps.length===0?p("p",{class:"weave-trail-empty",children:ym}):null,p("ol",{class:"weave-trail-steps",children:n.steps.map(r=>p("li",{class:`weave-trail-step weave-trail-${r.kind}`,children:[p("span",{class:"weave-trail-verb",children:r.verb}),r.notes.map(i=>p("button",{type:"button",class:"weave-trail-note",onClick:a=>e.onSelect(i.id,a.metaKey||a.ctrlKey),children:i.label},i.id)),r.detail===null?null:p("span",{class:"weave-trail-detail",children:r.detail})]},r.key))}),e.turns.length<2?null:p("div",{class:"weave-trail-turns",role:"group","aria-label":"Earlier turns",children:e.turns.map((r,i)=>p("button",{type:"button",class:`weave-trail-turn${r.turn===n.turn?" weave-trail-turn-on":""}`,"aria-pressed":r.turn===n.turn,onClick:()=>e.onReplay(r.turn),children:Bl(r,i===0)},r.turn))})]})}function _m({row:e,onSelect:t}){return p("li",{class:`weave-ctx-row${e.selected?" weave-row-on":""}`,children:p("button",{type:"button",class:"weave-ctx-link",onClick:n=>t(n.metaKey||n.ctrlKey),children:[p("span",{class:"weave-kind","aria-hidden":"true",children:p(ce,{name:e.kindIcon,class:"weave-icon"})}),p("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),p("span",{class:"weave-label",children:e.label})]})})}function Tm({view:e,onToggle:t}){return p("h4",{class:"weave-ctx-head",children:p("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!e.collapsed,"aria-controls":ro(e.heading),onClick:t,children:[p("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:p(ce,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,p("span",{class:"weave-ctx-count",children:e.count})]})})}function OT({view:e,onSelect:t,onToggle:n}){return p("section",{class:"weave-ctx-group",children:[p(Tm,{view:e,onToggle:n}),p("ul",{class:"weave-ctx-rows",id:ro(e.heading),hidden:e.collapsed,children:e.rows.map(r=>p(_m,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function FT({tag:e,onSelect:t}){return p("li",{class:"weave-ctx-tag",children:[p("span",{class:"weave-tag",children:["#",e.tag]}),p("ul",{class:"weave-ctx-rows",children:e.siblings.map(n=>p(_m,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function Sm(e){let t=V(null),n=no(e.graph,e.selectedId),[r,i]=K(sm),a=s=>()=>i(dm(r,s.heading,s.collapsed)),o=um(n.tags,r);return p("div",{class:"weave-rail","aria-label":op.title,children:[e.trail===void 0?null:p(km,{turns:e.trail,shownTurn:e.trailTurn??null,onSelect:e.onSelect,onReplay:s=>e.onReplay?.(s)}),n.empty===null?null:p("p",{class:"weave-ctx-empty",children:n.empty}),n.groups.map(s=>{let l=cm(s,r);return p(OT,{view:l,onSelect:e.onSelect,onToggle:a(l)},s.heading)}),n.tags.length===0?null:p("section",{class:"weave-ctx-group",children:[p(Tm,{view:o,onToggle:a(o)}),p("ul",{class:"weave-ctx-tags weave-context-tags",ref:t,style:{height:e.tagHeight},id:ro(o.heading),hidden:o.collapsed,children:n.tags.map(s=>p(FT,{tag:s,onSelect:e.onSelect},s.tag))}),o.collapsed?null:p(Kn,{label:"Resize tags section",horizontal:!0,min:60,max:600,value:e.tagHeight,onChange:s=>e.onTagResize(Math.max(60,Math.min(600,(t.current?.clientHeight??e.tagHeight)+s)))})]})]})}function Em(e){let t=null,n=!1,r=!1,i=async()=>{if(!(n||r)){r=!0;try{let s=await Vc(e.fetch,t);if(n||!s.ok||s.cached)return;t=s.data,e.onTrail(s.data)}finally{r=!1}}},o=(e.repeat??((s,l)=>{let c=setInterval(s,l);return()=>clearInterval(c)}))(()=>{i()},Ja);return i(),()=>{n=!0,o()}}function $T(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function Rm(e,t){let n=$T(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function Am(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function Cm(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function Lm(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):sn[e.key]}function Nm(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function Pm(e){return Qn.every(t=>Object.is(e[t.key],sn[t.key]))}function Dm(e){return p("div",{class:"weave-settings-forces",children:[Qn.map(t=>p("label",{class:"weave-setting-row",children:[p("span",{children:[p("strong",{children:t.label}),p("small",{children:t.hint})]}),p("span",{class:"weave-setting-range",children:[p("input",{"aria-label":t.label,type:"range",min:t.min,max:t.max,step:t.step,value:Cm(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:Lm(t,n.currentTarget.value)})}),p("output",{children:Nm(e.forces[t.key])})]})]},t.key)),p("button",{type:"button",disabled:Pm(e.forces),onClick:()=>e.onChange({...sn}),children:"Reset graph layout"})]})}var Im=["General","Appearance","Interface","Editor","Files","Backup"];function vt(e){return p("label",{class:"weave-setting-row",children:[p("span",{children:[p("strong",{children:e.name}),p("small",{children:e.hint})]}),e.children]})}function Mm(e){let[t,n]=K("General"),[r,i]=K(0),a=br(),[o,s]=K(null),[l,c]=K(!1);ne(()=>{Ho(we).then(f=>{f.ok&&s(f.data.enabled)})},[]);let u=f=>{s(f),c(!0),Ho(we,f).then(g=>{s(g.ok?g.data.enabled:!f),c(!1)})},d=e.layout.preferences,h=f=>e.onChange({...e.layout,preferences:{...d,...f}});return p("div",{class:"weave-scrim weave-settings-scrim",onClick:e.onClose,children:p("div",{class:"weave-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",tabIndex:-1,ref:a.ref,onClick:f=>f.stopPropagation(),onKeyDown:f=>{a.onKeyDown(f)},children:[p("header",{children:[p("h2",{children:"Settings"}),p("button",{type:"button","aria-label":"Close settings",onClick:e.onClose,children:"×"})]}),p("nav",{"aria-label":"Settings categories",children:e.compact?p("select",{class:"weave-settings-category","aria-label":"Settings category",value:t,onChange:f=>n(f.currentTarget.value),children:Im.map(f=>p("option",{value:f,children:f},f))}):Im.map(f=>p("button",{type:"button","aria-current":t===f?"page":void 0,onClick:()=>n(f),children:f},f))}),p("section",{"aria-label":`${t} settings`,children:[p("h3",{children:t}),t==="General"?p(xe,{children:[p("p",{children:["Pi Weave ",e.info.version]}),p("dl",{class:"weave-settings-locations",children:[p("dt",{children:"Vault"}),p("dd",{children:p("code",{children:e.info.vaultRoot||"Loading…"})}),p("dt",{children:"Repository"}),p("dd",{children:p("code",{children:e.cwd})})]}),p("div",{class:"weave-settings-actions",children:[p("button",{type:"button",onClick:()=>{i(f=>f+1),e.onRefresh()},children:[p("span",{class:r?"weave-refresh-spin":"","aria-hidden":"true",children:"↻"},r)," Refresh workspace"]}),p("a",{href:"https://github.com/EranYonai/pi-weave#readme",target:"_blank",rel:"noreferrer",children:"Documentation ↗"})]}),p("details",{children:[p("summary",{tabIndex:0,children:"Keyboard shortcuts"}),xa(e.shortcut.slice(0,-1)).map(f=>p("div",{children:[p("h4",{children:f.title}),f.entries.map(g=>p("div",{class:"weave-key-row",children:[p("kbd",{children:g.combo}),p("span",{children:g.what})]},g.combo))]},f.title))]})]}):null,t==="Appearance"?p(xe,{children:[p(vt,{name:"Color scheme",hint:"System follows your device and uses your chosen light and dark themes.",children:p("select",{"aria-label":"Color scheme",value:e.layout.theme==="system"?"system":ve[e.layout.theme].scheme,onChange:f=>e.onChange({...e.layout,theme:f.currentTarget.value==="system"?"system":f.currentTarget.value==="light"?d.lightTheme:d.darkTheme}),children:[p("option",{value:"system",children:"System"}),p("option",{value:"light",children:"Light"}),p("option",{value:"dark",children:"Dark"})]})}),["light","dark"].map(f=>p(vt,{name:`${f==="light"?"Light":"Dark"} theme`,hint:`Used in ${f} mode and by the ribbon theme button.`,children:p("select",{"aria-label":`${f==="light"?"Light":"Dark"} theme`,value:d[`${f}Theme`],onChange:g=>{let w=g.currentTarget.value;e.onChange({...e.layout,preferences:{...d,[`${f}Theme`]:w},theme:e.layout.theme!=="system"&&ve[e.layout.theme].scheme===f?w:e.layout.theme})},children:Object.entries(ve).filter(([,g])=>g.scheme===f).map(([g,w])=>p("option",{value:g,children:w.name},g))})},f)),p(vt,{name:"Accent color",hint:"Choose independently of the theme. Shades adapt to light and dark backgrounds.",children:p("select",{"aria-label":"Accent color",value:d.accent,onChange:f=>h({accent:f.currentTarget.value}),children:[p("option",{value:"theme",children:"Theme default"}),Object.entries(Sn).map(([f,g])=>p("option",{value:f,children:g.name},f))]})}),p(vt,{name:"Note font size",hint:"Applies to reading and editing notes.",children:p("span",{class:"weave-setting-range",children:[p("input",{"aria-label":"Note font size",type:"range",min:12,max:22,step:1,value:d.fontSize,onInput:f=>h({fontSize:Number(f.currentTarget.value)})}),p("output",{children:[d.fontSize,"px"]})]})})]}):null,t==="Interface"?p(xe,{children:[p(vt,{name:"Notes sidebar",hint:"Show files and recent notes.",children:p("input",{type:"checkbox",checked:e.layout.treeVisible,onChange:f=>e.onChange({...e.layout,treeVisible:f.currentTarget.checked})})}),p(vt,{name:"Context sidebar",hint:"Show links, backlinks, and related items.",children:p("input",{type:"checkbox",checked:e.layout.contextVisible,onChange:f=>e.onChange({...e.layout,contextVisible:f.currentTarget.checked})})}),p(vt,{name:"Color graph by group",hint:"Give each containment group its own color.",children:p("input",{type:"checkbox",checked:d.groupColors,onChange:f=>h({groupColors:f.currentTarget.checked})})}),p("h4",{children:"Graph layout"}),p("p",{class:"weave-settings-hint",children:"Adjust the graph live. Your choices are saved for this workspace."}),p(Dm,{forces:d.forces,onChange:f=>h({forces:f})})]}):null,t==="Editor"?p(xe,{children:[p(vt,{name:"Spellcheck",hint:"Use your browser or device’s spellchecker while editing.",children:p("input",{type:"checkbox",checked:d.spellcheck,onChange:f=>h({spellcheck:f.currentTarget.checked})})}),p(vt,{name:"Readable line length",hint:"Keep note text in a comfortable reading column.",children:p("input",{type:"checkbox",checked:d.readable,onChange:f=>h({readable:f.currentTarget.checked})})}),p(vt,{name:"Open notes in editing mode",hint:"Newly opened notes start in the editor. Existing drafts are preserved.",children:p("input",{type:"checkbox",checked:d.defaultEdit,onChange:f=>h({defaultEdit:f.currentTarget.checked})})}),p(vt,{name:"Note history",hint:"Save a copy of a note after every change, by you or your agent, so History can replay how it was written. Turning it off keeps what is already saved.",children:p("input",{type:"checkbox",disabled:o===null||l,checked:o??!1,onChange:f=>u(f.currentTarget.checked)})})]}):null,t==="Files"?p(xe,{children:[p(vt,{name:"On startup",hint:"Choose which tabs appear when you reopen this workspace.",children:p("select",{"aria-label":"On startup",value:d.startup,onChange:f=>h({startup:f.currentTarget.value}),children:[p("option",{value:"restore",children:"Restore open tabs"}),p("option",{value:"empty",children:"Start with an empty tab"})]})}),p(vt,{name:"Focus new tabs",hint:"Switch to notes opened in a new tab, including from the graph.",children:p("input",{type:"checkbox",checked:d.focusNewTabs,onChange:f=>h({focusNewTabs:f.currentTarget.checked})})}),p("h4",{children:"Deleting files"}),p("p",{children:"Deleting a note or folder removes it from the vault after confirmation. Download a backup before deleting anything you may need again."})]}):null,t==="Backup"?p(xe,{children:[p("h4",{children:"Download your vault"}),p("p",{children:"Save a ZIP containing the vault’s files and folders, including notes, metadata, and attachments. Linked files and folders are included as files."}),p("p",{children:"Save any unsaved edits first. The download contains files saved on disk. Backups are manual; store the ZIP somewhere safe."}),p("a",{class:"weave-settings-download",href:"/api/backup",download:!0,children:"Download vault ZIP"})]}):null]})]})})}function zT({group:e}){return p("div",{children:[p("p",{class:"weave-key-group",children:e.title}),e.entries.map(t=>p("div",{class:"weave-key-row",children:[p("kbd",{class:"weave-key-combo",children:t.combo}),p("span",{class:"weave-key-what",children:t.what})]},t.combo))]})}function Gm(e){let t=br(),n=e.shortcut.slice(0,-1);return p("div",{class:"weave-scrim",onClick:e.onClose,children:p("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":qs,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[p("h2",{class:"weave-help-title",children:qs}),p("div",{class:"weave-keys",children:xa(n).map(r=>p(zT,{group:r},r.title))}),p("p",{class:"weave-help-foot",children:[p("button",{type:"button",class:"weave-chip",onClick:e.onClose,children:"close"}),p("span",{class:"weave-help-hint",children:fp})]})]})})}function Om(e,t){let n=r=>{if(r.defaultPrevented)return;let i=dp(hp(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function Fm({model:e}){return p("footer",{class:"weave-status",children:[p("span",{class:"weave-status-cwd",title:e.cwd,children:e.cwd}),p("span",{class:"weave-status-sel",title:"Current item",children:e.selection}),e.hint===""?null:p("span",{class:"weave-status-hint",children:e.hint})]})}var $m="pi-weave.theme.v1";function io(e){try{let t=e.getItem($m);return Xn(t)?t:null}catch{return null}}function zm(e,t){try{return e.setItem($m,t),!0}catch{return!1}}function ao(e,t,n=ln){return ve[Vl(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function Vl(e,t,n=ln){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function Hm(e){return e==="system"?null:e}function Kl(e){return e==="system"?"System":ve[e].name}function Wm(e,t="dark",n=ln){return{glyph:e==="system"?"◐":ve[e].scheme==="light"?"○":"●",icon:e==="system"?"system":ve[e].scheme==="light"?"sun":"moon",label:Kl(e),hint:`Colour theme: ${Kl(e)} — click for ${Kl(ao(e,t,n))}`}}function oo(e,t){if(e.kind==="graph")return"Graph view";let n=Mt(e);return n===null?"New tab":t?.model.nodes.find(r=>r.id===n)?.label??n.replace(/^[^:]+:/,"")}function WT(e){let[t]=K(e.visits);return p("div",{class:"weave-recents",children:ap(t,e.graph,e.selectedId).map(n=>p("button",{type:"button","aria-current":n.selected?"page":void 0,title:n.label,onClick:r=>e.onSelect(n.id,r.metaKey||r.ctrlKey),children:[p("span",{class:"weave-kind",children:p(ce,{name:n.icon,class:"weave-icon"})}),p("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function UT(e){let t=Mt(e.tab),n=t?.startsWith("note:")?t.slice(5):null,[r,i]=K(null),a=V(null),o=V(e.tab.scroll),[s,l]=K(!1),[c,u]=K(""),[d,h]=K(!1),f=V(null);ze(()=>{s&&f.current?.focus()},[s]),ne(()=>{if(n===null)return;let v=e.drafts.nextLoadVersion();return am(we,n,y=>{i({slug:n,note:y.ok?y.data:null,failed:!y.ok,version:v})})},[n,e.graph?.stamp,e.revision]);let g=r?.slug===n?r:null;if(ze(()=>{let v=a.current?.querySelector(".weave-note");v!=null&&(v.scrollTop=o.current),n!==null&&e.drafts.get(n)!==null&&a.current?.querySelector(".weave-note-editor")?.focus()},[t,g?.note?.note.slug]),t===null)return p("div",{class:"weave-welcome",children:[p("span",{class:"weave-welcome-mark","aria-hidden":"true",children:"✳"}),p("h1",{children:"Your knowledge, connected."}),p("p",{children:"Ask your agent to write, organize, and connect your notes. Browse that knowledge here, or start a note yourself."}),p("div",{children:[p("button",{type:"button",onClick:e.onSearch,children:["Search workspace ",p("kbd",{children:"⌘K"})]}),p("button",{type:"button",onClick:e.onGraph,children:"Explore graph"}),p("button",{type:"button",onClick:()=>l(!0),children:"New note"})]}),s?p("form",{class:"weave-new-note",onSubmit:v=>{v.preventDefault(),!(d||!c.trim())&&(h(!0),e.onCreate(c.trim()).finally(()=>h(!1)))},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),d||l(!1))},children:[p("label",{for:`new-note-${e.tab.id}`,children:"Note title"}),p("input",{id:`new-note-${e.tab.id}`,ref:f,required:!0,value:c,disabled:d,onInput:v=>u(v.currentTarget.value)}),p("div",{children:[p("button",{type:"submit",disabled:d||!c.trim(),children:d?"Creating…":"Create note"}),p("button",{type:"button",disabled:d,onClick:()=>l(!1),children:"Cancel"})]})]}):null]});let w=e.graph!==null&&!e.graph.model.nodes.some(v=>v.id===t);if(w||g?.failed&&e.drafts.isDirty(n??"")){let v=n===null?null:e.drafts.get(n);return v!==null&&n!==null&&e.drafts.isDirty(n)?p("div",{class:"weave-welcome",children:[p("h2",{children:w?"This item is no longer here":"This note could not be loaded"}),p("p",{children:["Your unsaved draft is preserved below. Select and copy it before closing this workspace. ",w?"Saving cannot restore or recreate the missing note.":"Reopen this tab to retry loading the note."]}),p("label",{class:"weave-note-meta",for:`missing-draft-${e.tab.id}`,children:"Unsaved draft (read-only)"}),p("textarea",{id:`missing-draft-${e.tab.id}`,class:"weave-note-editor","aria-label":"Unsaved draft for missing note",rows:16,readOnly:!0,value:v.body}),p("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]}):p("div",{class:"weave-welcome",children:[p("h2",{children:"This item is no longer here"}),p("p",{children:"It may have been moved or deleted. Your other tabs are still available."}),p("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]})}return p("div",{class:"weave-document",ref:a,onScrollCapture:v=>{let y=v.target;y.classList.contains("weave-note")&&(o.current=y.scrollTop,e.onScroll(y.scrollTop))},children:p(Cg,{spellcheck:e.preferences.spellcheck,defaultEdit:e.preferences.defaultEdit,note:g?.note??null,loadFailed:g?.failed??!1,loadVersion:g?.version??0,graph:e.graph,selectedId:t,onSelect:e.onSelect,onOpen:v=>{Yc(we,v).then(y=>{y.ok?y.data.opened||window.alert("Could not open the note in an editor."):window.alert(y.message)})},onSave:e.onSave,onHistory:v=>su(we,v),drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function Um(e){let[t,n]=K(Wl),[r,i]=K(()=>({...Lo(),theme:io(localStorage)??"system"})),[a,o]=K(null),[s,l]=K(!1),[c,u]=K(Date.now),[d,h]=K(null),[f,g]=K(Date.now),[w,v]=K(null),[y,b]=K(e.initialWidth),[_,x]=K(()=>Qr(window)),[R,O]=K(!1),[N,j]=K({version:"",vaultRoot:""}),[P,A]=K(!1),[H,Z]=K(0),[,G]=K(0),[J,X]=K(null),se=V(null),[Ye,Ae]=K(null),[ye,ue]=K(""),[Te,ct]=K(null),[Pe,oe]=K(null),Se=V(null),[ut,Nt]=K(null),[L,W]=K(null),[te,ge]=K(!1),[Fe,wt]=K([]),[pe,_t]=K(!1),[ie]=K(Va),Tt=V(null),Ke=V(null),mn=V(location.hash),xr=V(!1),Ve=V(null),kr=V(null),vn=V(null),_r=V(null),[Tr,Pt]=K({left:0,top:0,width:600,height:500}),zt=En(r),et=Rn(r),wn=Wm(r.theme,_,r.preferences),Dt=Vl(r.theme,_,r.preferences),Vn=De(()=>({theme:Dt,accent:r.preferences.accent}),[Dt,r.preferences.accent]),yt=Mt(et),Ee=et.kind==="graph"?J:yt,$e=r.panes.find(k=>k.tabs.some(S=>S.id===k.activeTab&&S.kind==="graph")),yn=$e!==void 0&&(y>=850||$e.id===r.activePane),Ce=s&&et.kind==="document"&&!yn,Ht=y<1050?pe:r.contextVisible,Qt=!r.contextPinned,bn=De(()=>om(no(t.graph,Ee)),[t.graph,Ee]),Sr=Math.max(240,Math.min(320,r.contextWidth)),Jt=()=>{y<1050?_t(!0):i({...r,contextVisible:!0})},tt=yn||Ce&&Ht&&yt!==null,vi=r.panes.some(k=>k.tabs.some(S=>S.kind==="graph")),nt=V({layout:r,overlay:a,selectedId:Ee,graphPreviewId:Ye,select:k=>{}}),en=k=>{nt.current.graphPreviewId=k,Ae(k)};ne(()=>{en(null)},[tt,Ce,yt]),ne(()=>{yt!==null?(se.current=yt,X(yt)):et.kind==="graph"&&X(se.current)},[et.id,et.kind,yt]);let St=k=>{ag(ie,nt.current.layout,k,()=>window.confirm(ya))&&i(k)},dt=(k,S=!1,B=r.activePane,Q=!1)=>{let I=(k===null?cn:Hc)(r,k,{newTab:S,paneId:B});St(y<850&&!Q?{...I,treeVisible:!1}:I),s||_t(!1)},jn=()=>{let k=!(Ce&&Ht);l(k),k&&(i(S=>({...Bi(S),contextVisible:!0})),_t(!0))},tn=()=>i(k=>({...Po(k),...y<850?{treeVisible:!1}:{}})),ht=k=>{if(en(null),Ce){dt(k,!0);return}let S=r.panes.find(B=>B.id!==$e?.id);dt(k,!0,S?.id??$e?.id??r.activePane)},nn=k=>{Ce||X(k),rp(nt.current.graphPreviewId,k)?ht(k):en(k)},Er=k=>{en(null),St(ip(r,k,$e?.id))},Rr=(k,S=[])=>{ue(k),ct({query:k,ids:S}),oe(null),tn()},so=k=>{ue(k),oe(null)};nt.current={layout:r,overlay:a,selectedId:Ee,graphPreviewId:Ye,select:dt};let wi=k=>og(ie,k,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),Ar=async(k,S,B)=>{let Q=await Xc(we,k,S,B?.raw===!0);return Q.ok?(Z(I=>I+1),Tt.current?.refresh(),!0):(B?.quiet!==!0&&window.alert(Q.message),!1)},yi=async(k,S)=>{let B=await Zc(we,k);if(!B.ok)return window.alert(B.message),!1;let Q=await qi(we);return n(I=>({...I,graph:Q.ok?Q.data:null,graphFailed:!Q.ok})),ie.open(B.data.note.slug,B.data.note.body),St(cn(nt.current.layout,`note:${B.data.note.slug}`,{paneId:S})),Tt.current?.refresh(),!0};ne(()=>ie.subscribe(()=>G(k=>k+1)),[ie]),ne(()=>(Tt.current=im({fetch:we,state:Wl(),setState:n}),()=>Tt.current?.stop()),[]),ne(()=>{let k=!0;return(async()=>{try{let S=await we("/api/workspace-state"),B=await S.json();if(!k)return;if(S.ok&&typeof B.viewId=="string"){Ke.current=B.viewId,B.info&&j(B.info);let Q=$c(B.layout);if(Q){let I=zc(Q);i(I),se.current=Mt(Rn(Bi(I))),X(se.current),wt(Q.panes.flatMap(ee=>ee.tabs.flatMap(Ue=>Ue.history)).reduce(Ks,[]))}}else A(!0)}catch{k&&A(!0)}finally{k&&O(!0)}})(),()=>{k=!1}},[]),ne(()=>{if(!R||t.graph===null||xr.current)return;xr.current=!0;let k=Rm(mn.current,t.graph);k!==null&&i(S=>cn(S,k))},[R,t.graph]),ne(()=>{R&&wt(k=>Ks(k,Ee))},[R,Ee]),ne(()=>{R&&(history.replaceState(null,"",Am(Ee)),document.documentElement.dataset.weaveTheme=Dt,document.documentElement.dataset.weaveScheme=ve[Dt].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,zm(localStorage,r.theme))},[R,Ee,r.theme,Dt,r.preferences.accent]);let qn=V(Promise.resolve());ne(()=>{if(!R||!Ke.current)return;let k=Ke.current,S=window.setTimeout(()=>{qn.current=qn.current.then(async()=>{try{let B=await we("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:k,layout:r})});A(!B.ok)}catch{A(!0)}})},350);return()=>window.clearTimeout(S)},[r,R]),ne(()=>Em({fetch:we,onTrail:k=>{h(k),v(null),g(Date.now())}}),[]);let bi=vm(d,f,w);ne(()=>{if(!bi){w!==null&&v(null);return}let k=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(k)},[bi]);let xn=De(()=>mm(d,f,w),[d,f,w]),xi=De(()=>wm(d,t.graph),[d,t.graph]),ki=De(()=>bm(d),[d]);ne(()=>{let k=ye.trim()!==""&&document.activeElement?.classList.contains("weave-spotlight-input")===!0,S=xm(Pe,ki,k);S!==null&&(ue(S.query),ct({query:S.query,ids:S.ids}),oe(S.agent))},[ki?.seq]);let be=r.split==="down"?r.panes[0]:r.panes.at(-1),rn=be?.tabs.find(k=>k.id===be.activeTab)?.kind==="graph",_i=Qt&&(rn||Ee===null&&xi.length===0),kn=Ht&&!_i,Cr=k=>{let S=Date.now();g(S),v({turn:k,startedAt:S})};ne(()=>{let k=window.setInterval(()=>u(Date.now()),lp),S=()=>b(window.innerWidth);window.addEventListener("resize",S);let B=Jh(window,x),Q=Ue=>{for(let an of document.querySelectorAll(".weave-pane-menu[open]"))an.contains(Ue.target)||(an.open=!1)};document.addEventListener("pointerdown",Q);let I=Ue=>{ie.dirtySlugs().length&&(Ue.preventDefault(),Ue.returnValue="")},ee=()=>{Ke.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:Ke.current,layout:nt.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",ee),window.addEventListener("beforeunload",I),()=>{window.clearInterval(k),window.removeEventListener("resize",S),window.removeEventListener("beforeunload",I),window.removeEventListener("pagehide",ee),document.removeEventListener("pointerdown",Q),B()}},[]),ne(()=>Om(document,{context:()=>({overlay:nt.current.overlay,hasSelection:nt.current.selectedId!==null}),run:k=>pp(k,{setOverlay:o,fitGraph:()=>_r.current?.(),clearSelection:()=>{Rn(nt.current.layout).kind==="graph"?(X(null),en(null)):nt.current.select(null)},closeTab:()=>{let S=nt.current.layout;St(Io(S,S.activePane,Rn(S).id))},toggleTheme:()=>i(S=>({...S,theme:ao(S.theme,Qr(window),S.preferences)})),toggleContext:()=>{window.innerWidth<1050?_t(S=>!S):i(S=>({...S,contextVisible:!S.contextVisible}))},focusSelector:S=>(S===cr.graph?i(B=>({...Po(B),...window.innerWidth<850?{treeVisible:!1}:{}})):S===cr.tree||S===js?i(B=>({...B,treeVisible:!0})):i(Bi),requestAnimationFrame(()=>{S===cr.note&&ba(document,".weave-pane-active .weave-note-editor")||!ba(document,S)&&S===cr.note&&ba(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),ze(()=>{for(let k of r.panes)document.getElementById(`tab-${k.activeTab}`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[r.panes.map(k=>k.activeTab).join(","),r.activePane,y,R,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),ze(()=>{let k=Ce?vn.current:kr.current,S=Ve.current;if(!tt||!k||!S)return;let B=()=>{let I=k.getBoundingClientRect(),ee=S.getBoundingClientRect();Pt({left:I.left-ee.left,top:I.top-ee.top,width:I.width,height:I.height})};B();let Q=new ResizeObserver(B);return Q.observe(k),Q.observe(S),()=>Q.disconnect()},[Ce,tt,r,y]);let Ti=(k,S)=>i(B=>({...B,panes:B.panes.map(Q=>({...Q,tabs:Q.tabs.map(I=>I.id===k?{...I,scroll:S}:I)}))})),Lr=(k,S)=>{Vi(r,k,Se.current)===null&&!S.dataTransfer?.types.includes(Jr)||(S.preventDefault(),S.dataTransfer&&(S.dataTransfer.dropEffect=Se.current===null?"copy":"move"),Nt(null),W(k))},Si=(k,S)=>{let B=np(t.graph,S.dataTransfer?.getData(Jr)??"");if(B!==null){S.preventDefault(),dt(B,!0,k),W(null);return}let Q=Se.current;Vi(r,k,Q)!==null&&(S.preventDefault(),i(I=>{let ee=Vi(I,k,Q);return ee===null?I:tr(I,ee,Q)}),Se.current=null,W(null),Nt(null))},Ei=(k,S,B)=>{k.tabs.some(Q=>Q.id===Se.current)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect="move",W(null),Nt({paneId:k.id,before:S}))},Ri=(k,S)=>{let B=Se.current;B===null||!k.tabs.some(Q=>Q.id===B)||(S.preventDefault(),S.stopPropagation(),i(Q=>Oo(Q,k.id,B,ut?.paneId===k.id?ut.before:null)),Se.current=null,Nt(null),W(null))},lo=k=>{let S=k.tabs.find(I=>I.id===k.activeTab),B=k.id===r.activePane,Q=Qt&&kn&&(r.split==="down"||k===r.panes.at(-1));return p("section",{class:`weave-pane${B?" weave-pane-active":""}${L===k.id?" weave-pane-drop":""}${Q?" weave-pane-under-card":""}`,"data-drop-label":Se.current===null?"Open note here":"Move tab here","aria-label":`Workspace pane ${r.panes.indexOf(k)+1}`,onDragOver:I=>Lr(k.id,I),onDrop:I=>Si(k.id,I),onDragLeave:I=>{I.currentTarget.contains(I.relatedTarget)||W(null)},hidden:y<850&&!B,onFocusCapture:()=>{B||i(I=>({...I,activePane:k.id}))},onPointerDown:()=>{B||i(I=>({...I,activePane:k.id}))},children:[p("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:I=>Ei(k,null,I),onDrop:I=>Ri(k,I),children:[k.tabs.map(I=>p("div",{class:`weave-tab${I.id===S.id?" weave-tab-active":""}${ut?.paneId===k.id&&ut.before===I.id?" weave-tab-drop-before":""}${ut?.paneId===k.id&&ut.before===null&&I===k.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:ee=>{let Ue=ee.currentTarget.getBoundingClientRect(),an=ee.clientX<Ue.left+Ue.width/2?I.id:k.tabs[k.tabs.indexOf(I)+1]?.id??null;Ei(k,an,ee)},onDrop:ee=>Ri(k,ee),children:[p("button",{type:"button",role:"tab",title:oo(I,t.graph),id:`tab-${I.id}`,"aria-selected":I.id===S.id,"aria-controls":`panel-${k.id}`,tabIndex:I.id===S.id?0:-1,draggable:!0,onDragStart:ee=>{Se.current=I.id,ee.dataTransfer.effectAllowed="move",ee.dataTransfer.setData("application/x-weave-tab",I.id)},onClick:()=>i(Do(r,k.id,I.id)),onKeyDown:ee=>{let Ue=ee.key==="ArrowRight"?1:ee.key==="ArrowLeft"?-1:0;if(Ue&&ee.altKey&&!ee.ctrlKey&&!ee.metaKey){ee.preventDefault(),ee.stopPropagation();let Pr=k.tabs.indexOf(I),Yn=Ue<0?k.tabs[Math.max(0,Pr-1)].id:k.tabs[Pr+2]?.id??null;i(Oo(r,k.id,I.id,Yn)),requestAnimationFrame(()=>document.getElementById(`tab-${I.id}`)?.focus());return}if(!Ue&&ee.key!=="Home"&&ee.key!=="End")return;ee.preventDefault();let an=ee.key==="Home"?0:ee.key==="End"?k.tabs.length-1:(k.tabs.indexOf(I)+Ue+k.tabs.length)%k.tabs.length,Nr=k.tabs[an];i(Do(r,k.id,Nr.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Nr.id}`)?.focus())},children:[p("span",{"aria-hidden":"true",children:p(ce,{name:I.kind==="graph"?"graph":"note",class:"weave-icon"})}),p("span",{children:oo(I,t.graph)}),ie.isDirty((Mt(I)??"").slice(5))?p("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),p("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${oo(I,t.graph)}`,onClick:()=>St(Io(r,k.id,I.id)),children:"×"})]},I.id)),p("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>dt(null,!0,k.id),children:"+"})]}),p("div",{class:"weave-pane-toolbar",children:[p("button",{type:"button","aria-label":"Navigate back",disabled:S.kind==="graph"||S.cursor===0,onClick:()=>St(Mo({...r,activePane:k.id},k.id,-1)),children:"←"}),p("button",{type:"button","aria-label":"Navigate forward",disabled:S.kind==="graph"||S.cursor>=S.history.length-1,onClick:()=>St(Mo({...r,activePane:k.id},k.id,1)),children:"→"}),p("span",{class:"weave-breadcrumb",children:oo(S,t.graph)}),p("details",{class:"weave-pane-menu",onKeyDown:I=>{I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),I.currentTarget.open=!1,I.currentTarget.querySelector("summary")?.focus())},children:[p("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),p("div",{onClick:I=>{let ee=I.currentTarget.closest("details");ee&&(ee.open=!1)},children:[p("button",{type:"button",onClick:()=>i(Go({...r,activePane:k.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),p("button",{type:"button",onClick:()=>i(Go({...r,activePane:k.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?p(xe,{children:[p("button",{type:"button",onClick:()=>i(tr(r,k.id,S.id)),children:"Move tab to other pane"}),p("button",{type:"button",title:"Move all tabs to the other pane and close this pane",onClick:()=>i(Fc(r,k.id)),children:"Close pane"})]}):null]})]})]}),p("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${k.id}`,"aria-labelledby":`tab-${S.id}`,...S.kind==="graph"?{ref:kr}:{},children:S.kind==="document"?p(UT,{preferences:r.preferences,tab:S,graph:t.graph,drafts:ie,revision:H,now:c,onSelect:(I,ee)=>dt(I,ee,k.id),onSave:Ar,onScroll:I=>Ti(S.id,I),onSearch:()=>o("search"),onGraph:tn,onCreate:I=>yi(I,k.id)},`${S.id}:${S.cursor}:${Mt(S)}`):null})]},k.id)};return p(xe,{children:[p("div",{class:"weave-workbench",style:{"--weave-note-size":`${r.preferences.fontSize}px`,"--weave-reading-width":r.preferences.readable?"760px":"100%","--weave-card-width":`${Sr}px`},ref:Ve,onDragEnd:()=>{Se.current=null,W(null),Nt(null)},children:[p("nav",{class:"weave-ribbon","aria-label":"Workspace tools",children:[p("button",{type:"button","aria-label":"Toggle notes sidebar","aria-pressed":r.treeVisible,title:"Notes",onClick:()=>i({...r,treeVisible:!r.treeVisible}),children:p(ce,{name:"sidebar",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Open graph view",title:"Graph view",onClick:tn,children:p(ce,{name:"graph",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Toggle note graph",title:"Note graph","aria-pressed":Ce&&Ht,onClick:jn,children:p(ce,{name:"noteGraph",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Search notes and repository",title:cp(ei(ti(e.platform))),onClick:()=>o("search"),children:p(ce,{name:"search",class:"weave-icon"})}),p("span",{class:"weave-ribbon-space"}),p("button",{type:"button","aria-label":"Toggle context sidebar","aria-pressed":Ht,title:"Context",onClick:()=>y<1050?_t(!pe):i({...r,contextVisible:!r.contextVisible}),children:p(ce,{name:"context",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{Tt.current?.refresh(),Z(k=>k+1)},children:p(ce,{name:"refresh",class:"weave-icon"})}),p("button",{type:"button","aria-label":wn.hint,title:wn.hint,onClick:()=>i({...r,theme:ao(r.theme,_,r.preferences)}),children:p(ce,{name:wn.icon,class:"weave-icon"})}),p("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>o("settings"),children:p(ce,{name:"settings",class:"weave-icon"})})]}),p("div",{class:"weave-sidebar-dock weave-notes-dock","data-open":r.treeVisible,inert:!r.treeVisible,"aria-hidden":!r.treeVisible,style:{"--weave-sidebar-width":`${Math.min(r.treeWidth,y-90)}px`},children:[p("aside",{class:"weave-sidebar weave-sidebar-notes","aria-label":"Notes sidebar",children:[p("div",{class:"weave-sidebar-heading",children:[p("button",{type:"button","aria-pressed":!te,onClick:()=>ge(!1),children:"Files"}),p("button",{type:"button","aria-pressed":te,onClick:()=>ge(!0),children:"Recent"}),p("button",{type:"button","aria-label":"Hide notes sidebar",onClick:()=>{Ve.current?.querySelector('[aria-label="Toggle notes sidebar"]')?.focus(),i({...r,treeVisible:!1})},children:"«"})]}),te?p(WT,{visits:Fe,graph:t.graph,selectedId:Ee,onSelect:dt}):p(mp,{graph:t.graph,selectedId:Ee,recentIds:t.recentIds,onSelect:(k,S,B)=>dt(k,S,r.activePane,B),onMutate:wi,onRefresh:()=>Tt.current?.refresh(),now:c}),p("div",{class:"weave-vault-label",children:[p("span",{children:"Workspace"}),p("strong",{title:e.cwd,children:e.cwd.split(/[\\/]/).filter(Boolean).pop()??"Weave"})]})]}),p(Kn,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:k=>i(S=>({...S,treeWidth:Math.max(180,Math.min(420,S.treeWidth+k))}))})]}),p("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&y>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:R?r.panes.map((k,S)=>p(xe,{children:[S>0&&y>=850?p(Kn,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:B=>{let Q=r.split==="right"?Ve.current?.querySelector("main")?.clientWidth:Ve.current?.querySelector("main")?.clientHeight;i(I=>({...I,ratio:Math.max(.2,Math.min(.8,I.ratio+B/(Q??800)))}))}}):null,lo(k)]})):p("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),p("div",{class:`weave-sidebar-dock weave-context-dock${Qt?" weave-context-float":""}`,"data-open":kn,inert:!kn,"aria-hidden":!kn,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[p(Kn,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:k=>i(S=>({...S,contextWidth:Math.max(180,Math.min(400,S.contextWidth-k))}))}),p("aside",{class:"weave-sidebar weave-sidebar-context","aria-label":"Context sidebar",children:[p("div",{class:"weave-sidebar-heading weave-context-heading",children:[p("strong",{children:"Context"}),p("span",{class:"weave-context-count",children:bn}),p("button",{type:"button",class:"weave-context-pin","aria-pressed":r.contextPinned,"aria-label":r.contextPinned?"Float context over the page":"Dock context as a column",title:r.contextPinned?"Float over the page":"Dock as a column",onClick:()=>i({...r,contextPinned:!r.contextPinned}),children:p(ce,{name:"pin",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Hide context sidebar",title:"Fold (])",onClick:()=>{Ve.current?.querySelector('[aria-label="Toggle context sidebar"]')?.focus(),_t(!1),i({...r,contextVisible:!1})},children:Qt?p(ce,{name:"chevron",class:"weave-icon weave-icon-open"}):"»"})]}),Ce?p("section",{class:"weave-context-graph-section","aria-label":"Note connections",children:[p("div",{class:"weave-context-graph-heading",children:[p("strong",{children:"Note graph"}),p("button",{type:"button","aria-label":"Hide note graph",onClick:()=>{Ve.current?.querySelector('[aria-label="Toggle note graph"]')?.focus(),l(!1)},children:"×"})]}),p("div",{class:"weave-context-graph-slot",ref:vn,style:{height:r.contextGraphHeight},children:yt===null?p("p",{children:"Select a note to see its connections."}):null}),p(Kn,{label:"Resize note graph",horizontal:!0,min:120,max:800,value:Tr.height,onChange:k=>i(S=>({...S,contextGraphHeight:Math.max(120,Math.min(800,(vn.current?.clientHeight??S.contextGraphHeight)+k))}))})]}):null,p(Sm,{graph:t.graph,selectedId:Ee,onSelect:dt,trail:xi,trailTurn:w?.turn??null,onReplay:Cr,tagHeight:r.contextTagsHeight,onTagResize:k=>i(S=>({...S,contextTagsHeight:k}))})]})]}),Qt&&!Ht&&!_i?p("button",{type:"button",class:"weave-context-pill","aria-label":`Show context, ${bn} items`,title:"Show context (])",onClick:Jt,children:[p(ce,{name:"context",class:"weave-icon"}),"Context",p("span",{class:"weave-context-count",children:bn})]}):null,vi||s?p("div",{class:`weave-graph-host${Ce?" weave-context-graph-host":""}`,onDragOver:k=>{!Ce&&$e&&Lr($e.id,k)},onDrop:k=>{!Ce&&$e&&Si($e.id,k)},onDragLeave:k=>{k.currentTarget.contains(k.relatedTarget)||W(null)},onPointerDown:()=>{!Ce&&$e&&i(k=>({...k,activePane:$e.id}))},onFocusCapture:()=>{!Ce&&$e&&i(k=>({...k,activePane:$e.id}))},"aria-hidden":!tt,inert:!tt,role:Ce?"region":void 0,"aria-label":Ce?"Note graph":void 0,style:{...Tr,visibility:tt?"visible":"hidden",pointerEvents:tt?"auto":"none"},children:p(wp,{graph:t.graph,selectedId:Ee,previewId:Ye,onSelect:nn,onOpen:ht,renderer:$f,storage:localStorage,host:window,scheme:Vn,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:_r,trail:xn,...Ce?{}:{query:ye,...Te?.query===ye?{found:Te.ids}:{},byAgent:Pe!==null,onQuery:so,onOpenSplit:Er},now:c})}):null]}),p("div",{class:"weave-footer",children:[p(Fm,{model:sp(e.cwd,Ee,ei(ti(e.platform)))}),P?p("span",{role:"status",children:"Workspace restoration unavailable"}):null,ie.dirtySlugs().length?p("span",{children:[ie.dirtySlugs().length," unsaved"]}):null,y<850&&r.panes.length>1?p("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(k=>k.id!==zt.id).id}),children:"Switch pane"}):null]}),a==="search"?p(tm,{graph:t.graph,onSelect:dt,onLightUp:Rr,onClose:()=>o(null),ports:{fetch:we}}):null,a==="settings"?p(Mm,{compact:y<=650,layout:r,info:N,cwd:e.cwd,shortcut:ei(ti(e.platform)),onChange:k=>{St(k),_t(k.contextVisible)},onRefresh:()=>{Tt.current?.refresh(),Z(k=>k+1)},onClose:()=>o(null)}):null,a==="help"?p(Gm,{shortcut:ei(ti(e.platform)),onClose:()=>o(null)}):null]})}var Bm=`
419
419
  .weave-workbench{position:relative;isolation:isolate;display:flex;min-height:0;overflow:hidden;background:var(--weave-page)}
420
420
  .weave-workbench button{font:inherit;color:inherit;cursor:pointer}
421
421
  .weave-workbench button:focus-visible,.weave-workbench summary:focus-visible{outline:2px solid var(--weave-accent);outline-offset:-2px}
@@ -608,9 +608,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
608
608
  @media(prefers-reduced-motion:reduce){.weave-settings-actions button{transition:none}.weave-settings-actions button:active{transform:none}.weave-refresh-spin{animation:none}}
609
609
  .weave-settings details summary{cursor:pointer;padding:12px 0}.weave-settings .weave-key-row{gap:16px;align-items:baseline}.weave-settings .weave-key-row kbd{min-width:150px;color:var(--weave-accent)}
610
610
  @media(max-width:650px){.weave-settings{grid-template-columns:1fr;grid-template-rows:auto auto minmax(0,1fr)}.weave-settings nav{border-right:0;border-bottom:1px solid var(--weave-line);padding:8px 16px}.weave-settings nav select{width:100%;max-width:none}.weave-settings section{padding:20px}.weave-setting-row{align-items:flex-start;gap:12px}.weave-settings select{max-width:170px}.weave-setting-range{width:140px}.weave-setting-range input{width:90px}}
611
- `;function Kl(e){let{scheme:t,colors:n}=ve[e];return Object.entries(n).map(([r,i])=>`--weave-${r}:${i};`).join("")+`--weave-new:color-mix(in srgb,var(--weave-accent) ${t==="light"?10:16}%,transparent);color-scheme:${t};--weave-vignette:radial-gradient(ellipse at center,transparent 55%,${t==="light"?"rgba(0,0,0,.10)":"rgba(0,0,0,.22)"} 100%);--weave-scrim:rgba(0,0,0,${t==="light"?".30":".45"});`}var $T=`
611
+ `;function jl(e){let{scheme:t,colors:n}=ve[e];return Object.entries(n).map(([r,i])=>`--weave-${r}:${i};`).join("")+`--weave-new:color-mix(in srgb,var(--weave-accent) ${t==="light"?10:16}%,transparent);color-scheme:${t};--weave-vignette:radial-gradient(ellipse at center,transparent 55%,${t==="light"?"rgba(0,0,0,.10)":"rgba(0,0,0,.22)"} 100%);--weave-scrim:rgba(0,0,0,${t==="light"?".30":".45"});`}var BT=`
612
612
  :root{
613
- ${Kl("dark")}
613
+ ${jl("dark")}
614
614
  --weave-row:26px;--weave-gutter:10px;
615
615
  /* The reading gutter is note-only: prose wants a wider margin than chrome.
616
616
  Rails, rows and bars keep --weave-gutter, so density is a property of the
@@ -661,11 +661,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
661
661
  --weave-px-subhead:14px;--weave-px-title:15px;--weave-px-display:26px;
662
662
  }
663
663
  @media (prefers-color-scheme: light){
664
- :root:not([data-weave-theme]){${Kl("light")}}
664
+ :root:not([data-weave-theme]){${jl("light")}}
665
665
  }
666
- ${Object.keys(ve).map(e=>`:root[data-weave-theme="${e}"]{${Kl(e)}}`).join(`
666
+ ${Object.keys(ve).map(e=>`:root[data-weave-theme="${e}"]{${jl(e)}}`).join(`
667
667
  `)}
668
- ${Object.entries(Tn).map(([e,t])=>["light","dark"].map(n=>`:root[data-weave-scheme="${n}"][data-weave-accent="${e}"]{--weave-accent:${t[n]};}`).join(`
668
+ ${Object.entries(Sn).map(([e,t])=>["light","dark"].map(n=>`:root[data-weave-scheme="${n}"][data-weave-accent="${e}"]{--weave-accent:${t[n]};}`).join(`
669
669
  `)).join(`
670
670
  `)}
671
671
  body{font-size:var(--weave-px-base)}
@@ -1431,7 +1431,7 @@ body{font-size:var(--weave-px-base)}
1431
1431
  @keyframes weave-fade-in{from{opacity:0}}
1432
1432
  @keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
1433
1433
  @media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
1434
- `,zT=["style[nonce]","style","script[nonce]","script[src]"];function HT(e){for(let t of zT){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function zm(e,t=$T+$m){let n=e.createElement("style"),r=HT(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var Hm=document.getElementById("app");if(Hm!==null){zm(document),WT();let e=vc(document.getElementById(mc)?.textContent??null);gc(p(Fm,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),Hm)}function WT(){let e=Gm(io(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
1434
+ `,KT=["style[nonce]","style","script[nonce]","script[src]"];function VT(e){for(let t of KT){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function Km(e,t=BT+Bm){let n=e.createElement("style"),r=VT(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var Vm=document.getElementById("app");if(Vm!==null){Km(document),jT();let e=yc(document.getElementById(wc)?.textContent??null);vc(p(Um,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),Vm)}function jT(){let e=Hm(io(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
1435
1435
  /*! Bundled license information:
1436
1436
 
1437
1437
  dompurify/dist/purify.es.mjs: