pi-weave 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/package.json +1 -1
- package/src/web/client/context/context.model.ts +5 -0
- package/src/web/client/dist/app.js +400 -167
- package/src/web/client/graph/Graph.tsx +148 -12
- package/src/web/client/graph/column.model.ts +58 -1
- package/src/web/client/graph/graph.model.ts +114 -0
- package/src/web/client/graph/renderer.ts +21 -7
- package/src/web/client/graph/spotlight.model.ts +476 -0
- package/src/web/client/note/Note.tsx +212 -59
- package/src/web/client/note/Replay.tsx +18 -7
- package/src/web/client/note/drafts.ts +69 -6
- package/src/web/client/note/editbar.model.ts +153 -0
- package/src/web/client/note/note.model.ts +65 -1
- package/src/web/client/note/replay.model.ts +75 -0
- package/src/web/client/search/SearchPalette.tsx +103 -34
- package/src/web/client/search/search.model.ts +533 -26
- package/src/web/client/shell/Shell.tsx +79 -21
- package/src/web/client/shell/StatusBar.tsx +1 -0
- package/src/web/client/shell/icons.model.ts +68 -1
- package/src/web/client/shell/keys.model.ts +11 -1
- package/src/web/client/shell/shell.model.ts +48 -1
- package/src/web/client/shell/theme.model.ts +3 -0
- package/src/web/client/shell/theme.ts +260 -61
- package/src/web/client/shell/workspace.css.ts +38 -11
- package/src/web/client/trail/TrailStrip.tsx +0 -1
- package/src/web/client/trail/trail.model.ts +61 -6
- package/src/web/client/tree/Tree.tsx +3 -7
- package/src/web/shared/themes.ts +1 -1
- package/src/web/shared/workspace.ts +10 -2
|
@@ -18,18 +18,88 @@
|
|
|
18
18
|
* sigma@3.0.3 — MIT
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
"use strict";(()=>{var Cg=Object.create;var gl=Object.defineProperty;var Lg=Object.getOwnPropertyDescriptor;var Ng=Object.getOwnPropertyNames;var Pg=Object.getPrototypeOf,Dg=Object.prototype.hasOwnProperty;var ml=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Ig=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ng(t))!Dg.call(e,i)&&i!==n&&gl(e,i,{get:()=>t[i],enumerable:!(r=Lg(t,i))||r.enumerable});return e};var pr=(e,t,n)=>(n=e!=null?Cg(Pg(e)):{},Ig(t||!e||!e.__esModule?gl(n,"default",{value:e,enumerable:!0}):n,e));var Xi=ml((yE,hs)=>{"use strict";var Qn=typeof Reflect=="object"?Reflect:null,rh=Qn&&typeof Qn.apply=="function"?Qn.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},qi;Qn&&typeof Qn.ownKeys=="function"?qi=Qn.ownKeys:Object.getOwnPropertySymbols?qi=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:qi=function(t){return Object.getOwnPropertyNames(t)};function Kw(e){console&&console.warn&&console.warn(e)}var oh=Number.isNaN||function(t){return t!==t};function oe(){oe.init.call(this)}hs.exports=oe;hs.exports.once=Yw;oe.EventEmitter=oe;oe.prototype._events=void 0;oe.prototype._eventsCount=0;oe.prototype._maxListeners=void 0;var ih=10;function Yi(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(oe,"defaultMaxListeners",{enumerable:!0,get:function(){return ih},set:function(e){if(typeof e!="number"||e<0||oh(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");ih=e}});oe.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};oe.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||oh(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 ah(e){return e._maxListeners===void 0?oe.defaultMaxListeners:e._maxListeners}oe.prototype.getMaxListeners=function(){return ah(this)};oe.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[t];if(l===void 0)return!1;if(typeof l=="function")rh(l,this,n);else for(var c=l.length,u=dh(l,c),r=0;r<c;++r)rh(u[r],this,n);return!0};function sh(e,t,n,r){var i,o,a;if(Yi(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),a===void 0)a=o[t]=n,++e._eventsCount;else if(typeof a=="function"?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=ah(e),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=a.length,Kw(s)}return e}oe.prototype.addListener=function(t,n){return sh(this,t,n,!1)};oe.prototype.on=oe.prototype.addListener;oe.prototype.prependListener=function(t,n){return sh(this,t,n,!0)};function Vw(){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 lh(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=Vw.bind(r);return i.listener=n,r.wrapFn=i,i}oe.prototype.once=function(t,n){return Yi(n),this.on(t,lh(this,t,n)),this};oe.prototype.prependOnceListener=function(t,n){return Yi(n),this.prependListener(t,lh(this,t,n)),this};oe.prototype.removeListener=function(t,n){var r,i,o,a,s;if(Yi(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():jw(r,o),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};oe.prototype.off=oe.prototype.removeListener;oe.prototype.removeAllListeners=function(t){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this};function ch(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?qw(i):dh(i,i.length)}oe.prototype.listeners=function(t){return ch(this,t,!0)};oe.prototype.rawListeners=function(t){return ch(this,t,!1)};oe.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):uh.call(e,t)};oe.prototype.listenerCount=uh;function uh(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}oe.prototype.eventNames=function(){return this._eventsCount>0?qi(this._events):[]};function dh(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function jw(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function qw(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Yw(e,t){return new Promise(function(n,r){function i(a){e.removeListener(t,o),r(a)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}hh(e,t,o,{once:!0}),t!=="error"&&Xw(e,i,{once:!0})})}function Xw(e,t,n){typeof e.on=="function"&&hh(e,"error",t,n)}function hh(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var ps=ml((kE,fh)=>{"use strict";fh.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var gi,ie,xl,Mg,Yt,vl,kl,_l,Ho,ci,fr,Tl,Bo,Wo,Uo,Gg,hi={},pi=[],Og=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,mi=Array.isArray;function It(e,t){for(var n in t)e[n]=t[n];return e}function Ko(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Fg(e,t,n){var r,i,o,a={};for(o in t)o=="key"?r=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?gi.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return ui(e,a,r,i,null)}function ui(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++xl,__i:-1,__u:0};return i==null&&ie.vnode!=null&&ie.vnode(o),o}function me(e){return e.children}function di(e,t){this.props=e,this.context=t}function ln(e,t){if(t==null)return e.__?ln(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"?ln(e):null}function $g(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=It({},t);o.__v=t.__v+1,ie.vnode&&ie.vnode(o),Vo(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ln(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,Cl(r,o,i),t.__e=t.__=null,o.__e!=n&&El(o)}}function El(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}),El(e)}function wl(e){(!e.__d&&(e.__d=!0)&&Yt.push(e)&&!fi.__r++||vl!=ie.debounceRendering)&&((vl=ie.debounceRendering)||kl)(fi)}function fi(){try{for(var e,t=1;Yt.length;)Yt.length>t&&Yt.sort(_l),e=Yt.shift(),t=Yt.length,$g(e)}finally{Yt.length=fi.__r=0}}function Sl(e,t,n,r,i,o,a,s,l,c,u){var h,d,p,g,y,w,v=r&&r.__k||pi,b=t.length;for(l=zg(n,t,v,l,b),h=0;h<b;h++)(p=n.__k[h])!=null&&(d=p.__i!=-1&&v[p.__i]||hi,p.__i=h,w=Vo(e,p,d,i,o,a,s,l,c,u),g=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&jo(d.ref,null,p),u.push(p.ref,p.__c||g,p)),y==null&&g!=null&&(y=g),4&p.__u?(l=Rl(p,l,e),d.__e&&(d.__e=null)):typeof p.type=="function"&&w!==void 0?l=w:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=y,l}function zg(e,t,n,r,i){var o,a,s,l,c,u=n.length,h=u,d=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[o]=ui(null,a,null,null,null):mi(a)?a=e.__k[o]=ui(me,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=ui(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,l=o+d,a.__=e,a.__b=e.__b+1,s=null,(c=a.__i=Hg(a,n,l,h))!=-1&&(h--,(s=n[c])&&(s.__u|=2)),s==null||s.__v==null?(c==-1&&(i>u?d--:i<u&&d++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,a.__u|=4))):e.__k[o]=null;if(h)for(o=0;o<u;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ln(s)),Nl(s,s));return r}function Rl(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=Rl(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=ln(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Hg(e,t,n,r){var i,o,a,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,o=n+1;i>=0||o<t.length;)if((c=t[a=i>=0?i--:o++])!=null&&(2&c.__u)==0&&s==c.key&&l==c.type)return a}return-1}function yl(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Og.test(t)?n:n+"px"}function li(e,t,n,r,i){var o,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||yl(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||yl(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Tl,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[fr]=r[fr]:(n[fr]=Bo,e.addEventListener(t,o?Uo:Wo,o)):e.removeEventListener(t,o?Uo:Wo,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function bl(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[ci]==null)t[ci]=Bo++;else if(t[ci]<n[fr])return;return n(ie.event?ie.event(t):t)}}}function Vo(e,t,n,r,i,o,a,s,l,c){var u,h,d,p,g,y,w,v,b,x,T,A,O,N,G,$,F=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=t.__e=n.__e]),(u=ie.__b)&&u(t);e:if(typeof F=="function"){h=a.length;try{if(b=t.props,x=F.prototype&&F.prototype.render,T=(u=F.contextType)&&r[u.__c],A=u?T?T.props.value:u.__:r,n.__c?v=(d=t.__c=n.__c).__=d.__E:(x?t.__c=d=new F(b,A):(t.__c=d=new di(b,A),d.constructor=F,d.render=Ug),T&&T.sub(d),d.state||(d.state={}),d.__n=r,p=d.__d=!0,d.__h=[],d._sb=[]),x&&d.__s==null&&(d.__s=d.state),x&&F.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=It({},d.__s)),It(d.__s,F.getDerivedStateFromProps(b,d.__s))),g=d.props,y=d.state,d.__v=t,p)x&&F.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),x&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(x&&F.getDerivedStateFromProps==null&&b!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,A),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,A)===!1){t.__v!=n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(X){X&&(X.__=t)}),pi.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=ln(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,A),x&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,y,w)})}if(d.context=A,d.props=b,d.__P=e,d.__e=!1,O=ie.__r,N=0,x)d.state=d.__s,d.__d=!1,O&&O(t),u=d.render(d.props,d.state,d.context),pi.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,O&&O(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++N<25);d.state=d.__s,d.getChildContext!=null&&(r=It(It({},r),d.getChildContext())),x&&!p&&d.getSnapshotBeforeUpdate!=null&&(w=d.getSnapshotBeforeUpdate(g,y)),G=u!=null&&u.type===me&&u.key==null?Ll(u.props.children):u,s=Sl(e,mi(G)?G:[G],t,n,r,i,o,a,s,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),v&&(d.__E=d.__=null)}catch(X){if(a.length=h,t.__v=null,l||o!=null){if(X.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),t.__e=s}else if(o!=null)for($=o.length;$--;)Ko(o[$])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),X.then||Al(t),ie.__e(X,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Wg(n.__e,t,n,r,i,o,a,l,c);return(u=ie.diffed)&&u(t),128&t.__u?void 0:s}function Al(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Al))}function Cl(e,t,n){for(var r=0;r<n.length;r++)jo(n[r],n[++r],n[++r]);ie.__c&&ie.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){ie.__e(o,i.__v)}})}function Ll(e){return typeof e!="object"||e==null||e.__b>0?e:mi(e)?e.map(Ll):e.constructor!==void 0?null:It({},e)}function Wg(e,t,n,r,i,o,a,s,l){var c,u,h,d,p,g,y,w=n.props||hi,v=t.props,b=t.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((p=o[c])&&"setAttribute"in p==!!b&&(b?p.localName==b:p.nodeType==3)){e=p,o[c]=null;break}}if(e==null){if(b==null)return document.createTextNode(v);e=document.createElementNS(i,b,v.is&&v),s&&(ie.__m&&ie.__m(t,o),s=!1),o=null}if(b==null)w===v||s&&e.data==v||(e.data=v);else{if(o=b=="textarea"&&v.defaultValue!=null?null:o&&gi.call(e.childNodes),!s&&o!=null)for(w={},c=0;c<e.attributes.length;c++)w[(p=e.attributes[c]).name]=p.value;for(c in w)p=w[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in v||c=="value"&&"defaultValue"in v||c=="checked"&&"defaultChecked"in v||li(e,c,null,p,i);for(c in v)p=v[c],c=="children"?d=p:c=="dangerouslySetInnerHTML"?u=p:c=="value"?g=p:c=="checked"?y=p:s&&typeof p!="function"||w[c]===p||li(e,c,p,w[c],i);if(u)s||h&&(u.__html==h.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(h&&(e.innerHTML=""),Sl(t.type=="template"?e.content:e,mi(d)?d:[d],t,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&ln(n,0),s,l),o!=null)for(c=o.length;c--;)Ko(o[c]);s&&b!="textarea"||(c="value",b=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[c]||b=="progress"&&!g||b=="option"&&g!=w[c])&&li(e,c,g,w[c],i),c="checked",y!=null&&y!=e[c]&&li(e,c,y,w[c],i))}return e}function jo(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){ie.__e(i,n)}}function Nl(e,t,n){var r,i;if(ie.unmount&&ie.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||jo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){ie.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Nl(r[i],t,n||typeof e.type!="function");n||Ko(e.__e),e.__c=e.__=e.__e=void 0}function Ug(e,t,n){return this.constructor(e,n)}function Pl(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),ie.__&&ie.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,o=[],a=[],Vo(t,e=(!r&&n||t).__k=Fg(me,null,[e]),i||hi,hi,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?gi.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),Cl(o,e,a),e.props.children=null}gi=pi.slice,ie={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},xl=0,Mg=function(e){return e!=null&&e.constructor===void 0},di.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=It({},this.state),typeof e=="function"&&(e=e(It({},n),this.props)),e&&It(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),wl(this))},di.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),wl(this))},di.prototype.render=me,Yt=[],kl=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_l=function(e,t){return e.__v.__b-t.__v.__b},fi.__r=0,Ho=Math.random().toString(8),ci="__d"+Ho,fr="__a"+Ho,Tl=/(PointerCapture)$|Capture$/i,Bo=0,Wo=bl(!1),Uo=bl(!0),Gg=0;var Dl="weave-bootstrap";var qo={cwd:""};function Bg(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function Il(e){if(e===null||e.trim()==="")return qo;let t;try{t=JSON.parse(e)}catch{return qo}return Bg(t)?t:qo}var cn,ve,Yo,Ml,gr=0,Ul=[],xe=ie,Gl=xe.__b,Ol=xe.__r,Fl=xe.diffed,$l=xe.__c,zl=xe.unmount,Hl=xe.__;function mr(e,t){xe.__h&&xe.__h(ve,e,gr||t),gr=0;var n=ve.__H||(ve.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function V(e){return gr=1,Kg(Vl,e)}function Kg(e,t,n){var r=mr(cn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Vl(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=ve,!ve.__f)){var i=function(s,l,c){if(!r.__c.__H)return!0;var u=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(p){if(p.__N){u=!0;var g=p.__[0];p.__=p.__N,p.__N=void 0,g!==p.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,c);return u?d||h:d}return!u||h};ve.__f=!0;var o=ve.shouldComponentUpdate,a=ve.componentWillUpdate;ve.componentWillUpdate=function(s,l,c){if(this.__e){var u=o;o=void 0,i(s,l,c),o=u}a&&a.call(this,s,l,c)},ve.shouldComponentUpdate=i}return r.__N||r.__}function ee(e,t){var n=mr(cn++,3);!xe.__s&&Zo(n.__H,t)&&(n.__=e,n.u=t,ve.__H.__h.push(n))}function De(e,t){var n=mr(cn++,4);!xe.__s&&Zo(n.__H,t)&&(n.__=e,n.u=t,ve.__h.push(n))}function Y(e){return gr=5,nt(function(){return{current:e}},[])}function nt(e,t){var n=mr(cn++,7);return Zo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Bl(e,t){return gr=8,nt(function(){return e},t)}function Kl(){var e=mr(cn++,11);if(!e.__){for(var t=ve.__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 Vg(){for(var e;e=Ul.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(vi),t.__h.some(Xo),t.__h=[]}catch(n){t.__h=[],xe.__e(n,e.__v)}}}xe.__b=function(e){ve=null,Gl&&Gl(e)},xe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Hl&&Hl(e,t)},xe.__r=function(e){Ol&&Ol(e),cn=0;var t=(ve=e.__c).__H;t&&(Yo===ve?(t.__h=[],ve.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(vi),t.__h.some(Xo),t.__h=[],cn=0)),Yo=ve},xe.diffed=function(e){Fl&&Fl(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ul.push(t)!==1&&Ml===xe.requestAnimationFrame||((Ml=xe.requestAnimationFrame)||jg)(Vg)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Yo=ve=null},xe.__c=function(e,t){t.some(function(n){try{n.__h.some(vi),n.__h=n.__h.filter(function(r){return!r.__||Xo(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],xe.__e(r,n.__v)}}),$l&&$l(e,t)},xe.unmount=function(e){zl&&zl(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{vi(r)}catch(i){t=i}}),n.__H=void 0,t&&xe.__e(t,n.__v))};var Wl=typeof requestAnimationFrame=="function";function jg(e){var t,n=function(){clearTimeout(r),Wl&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Wl&&(t=requestAnimationFrame(n))}function vi(e){var t=ve,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ve=t}function Xo(e){var t=ve;e.__c=e.__(),ve=t}function Zo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Vl(e,t){return typeof t=="function"?t(e):t}var jl={bg:"#eff1f5",panel:"#e6e9ef",page:"#dce0e8",raise:"#ccd0da",fg:"#4c4f69",dim:"#56586a",faint:"#606274",line:"#ccd0da","line-strong":"#bcc0cc",accent:"#7113ec",ok:"#28641b",warn:"#7c4f10",bad:"#b20d30"},ql={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"},pe={light:{name:"Catppuccin Latte · Mauve",scheme:"light",colors:jl},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...jl,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:ql},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...ql,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"}}},Yl=["system",...Object.keys(pe)];function $n(e){return typeof e=="string"&&Yl.includes(e)}var un={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 wi(e){return typeof e=="string"?e:e.theme}function Xl(e,t){return t==="theme"?pe[e].colors.accent:un[t][pe[e].scheme]}var Ye={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},Xt={...Ye};function Qo(e){Object.assign(Ye,e)}var zn=[{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}],Zt={lightTheme:"light",darkTheme:"dark",accent:"theme",fontSize:14,readable:!0,spellcheck:!0,defaultEdit:!1,startup:"restore",focusNewTabs:!0,groupColors:!0,forces:{...Xt}};function Zl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ql(e){if(!Zl(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(Zt).length)return null;for(let i of["light","dark"]){let o=n[`${i}Theme`];if(!$n(o)||o==="system"||pe[o].scheme!==i)return null}if(n.accent!=="theme"&&(typeof n.accent!="string"||!Object.hasOwn(un,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(!Zl(r)||Object.keys(r).length!==zn.length)return null;for(let{key:i,min:o,max:a}of zn){let s=r[i];if(typeof s!="number"||!Number.isFinite(s)||s<o||s>a)return null}return n}var na=40,Jl=100,qg=1e9,vr=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function ra(){return{version:1,panes:[{id:"pane-1",tabs:[vr("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,treeWidth:240,contextWidth:240,contextGraphHeight:260,contextTagsHeight:180,theme:"system",preferences:Zt}}function wr(e){return e.panes.find(t=>t.id===e.activePane)}function dn(e){let t=wr(e);return t.tabs.find(n=>n.id===t.activeTab)}function Rt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function Wn(e,t){let n=new Set(e.panes.flatMap(i=>[i.id,...i.tabs.map(o=>o.id)])),r=1;for(;n.has(`${t}-${r}`);)r++;return`${t}-${r}`}function hn(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?bi({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function ia(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function bi(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??ia(e);return r?{...n,lastDocumentTab:r.id}:n}function xi(e){if(dn(e).kind==="document")return e;let t=wr(e),n=ia(t);return n?hn(e,t,n):Un(e,null,{newTab:!0})}function ki(e,t,n){let r=e.panes.find(o=>o.id===t),i=r?.tabs.find(o=>o.id===n);return r&&i?{pane:r,tab:i}:null}function ta(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=na?e:hn(e,{...t,tabs:[...t.tabs,n]},n)}function Jo(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>Jl&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function Un(e,t,n={}){let r=e.panes.find(s=>s.id===(n.paneId??e.activePane));if(!r)return e;let i=r.activeTab,o=r.tabs.find(s=>s.id===i);if(o?.kind==="graph"&&(o=ia(r),o?r={...r,activeTab:o.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!o)return ta(e,r,Jo(vr(Wn(e,"tab")),t));let a=Jo(o,t);return a===o&&r.id===e.activePane&&i===o.id?e:hn(e,r,a)}function oa(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:hn(e,t.pane,t.tab);let n=wr(e);return ta(e,n,{id:Wn(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function aa(e,t,n){let r=ki(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:hn(e,r.pane,r.tab)}function sa(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(h=>h.id!==t);if(c)return{...e,panes:[c],activePane:c.id};let u=vr(Wn(e,"tab"));return hn(e,{...i,tabs:[u]},u)}let o=i.tabs.filter(c=>c.id!==n),a=i.activeTab===n,s=o[Math.max(0,i.tabs.findIndex(c=>c.id===n)-1)],l=bi({...i,tabs:o,activeTab:a?s.id:i.activeTab});return{...e,activePane:a?t:e.activePane,panes:e.panes.map(c=>c.id===t?l:c)}}function la(e,t,n){let r=e.panes.find(a=>a.id===t),i=r?.tabs.find(a=>a.id===r.activeTab);if(!r||!i||i.kind!=="document")return e;let o=i.cursor+n;return o<0||o>=i.history.length?e:hn(e,r,{...i,cursor:o,scroll:0})}function ca(e,t){if(e.panes.length===2)return e.split===t?e:{...e,split:t};let n=Ti(e,e.activePane,dn(e).id);return n===e?e:{...n,split:t}}function ec(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 ua(e,t,n,r){let i=ki(e,t,n);if(!i||r===n||r!==null&&!i.pane.tabs.some(a=>a.id===r))return e;let o=i.pane.tabs.filter(a=>a.id!==n);return o.splice(r===null?o.length:o.findIndex(a=>a.id===r),0,i.tab),o.every((a,s)=>a===i.pane.tabs[s])?e:{...e,panes:e.panes.map(a=>a.id===t?{...a,tabs:o}:a)}}function _i(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 Ti(e,t,n){let r=ki(e,t,n);if(!r)return e;let i=e.panes.find(u=>u.id!==t)??{id:Wn(e,"pane"),tabs:[],activeTab:""},o=r.pane.tabs.filter(u=>u.id!==n),a=bi({...i,tabs:[...i.tabs,r.tab],activeTab:r.tab.id});if(!o.length&&e.panes.length===2)return{...e,panes:[a],activePane:i.id};if(!o.length&&e.panes.reduce((u,h)=>u+h.tabs.length,0)>=na)return e;let s=o.length?null:vr(Wn(e,"tab")),l=o.length?o:[s],c=bi({...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,a]:e.panes.map(u=>u.id===c.id?c:a)}}function ea(e,t){return Object.keys(e).length===t.length&&t.every(n=>Object.hasOwn(e,n))}function yi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Hn(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 tc(e){if(!yi(e)||!ea(e,["version","panes","activePane","split","ratio","treeVisible","contextVisible","treeWidth","contextWidth","theme",...["preferences","contextGraphHeight","contextTagsHeight"].filter(c=>Object.hasOwn(e,c))])||e.version!==1||!Array.isArray(e.panes)||e.panes.length<1||e.panes.length>2||!Hn(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"||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 t=Object.hasOwn(e,"contextGraphHeight")?e.contextGraphHeight:260,n=Object.hasOwn(e,"contextTagsHeight")?e.contextTagsHeight:180;if(typeof t!="number"||!Number.isFinite(t)||t<120||t>800||typeof n!="number"||!Number.isFinite(n)||n<60||n>600||!$n(e.theme))return null;let r=Object.hasOwn(e,"preferences")?Ql(e.preferences):Zt;if(r===null)return null;let i=e.preferences;e.theme!=="system"&&(!yi(i)||!Object.hasOwn(i,"lightTheme"))&&(r={...r,[`${pe[e.theme].scheme}Theme`]:e.theme});let o=new Set,a=0,s=0,l=[];for(let c of e.panes){if(!yi(c)||!ea(c,Object.hasOwn(c,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!Hn(c.id,"pane")||!Array.isArray(c.tabs)||c.tabs.length<1||!Hn(c.activeTab,"tab")||o.has(c.id))return null;o.add(c.id);let u=[],h=!1;for(let p of c.tabs){if(!yi(p)||!ea(p,["id","kind","history","cursor","scroll"])||!Hn(p.id,"tab")||o.has(p.id)||(o.add(p.id),p.kind!=="document"&&p.kind!=="graph"))return null;let g=p.kind;if(!Array.isArray(p.history)||p.history.length<1||p.history.length>Jl||!Number.isInteger(p.cursor)||p.cursor<0||p.cursor>=p.history.length||p.history.some(y=>y!==null&&!Hn(y))||typeof p.scroll!="number"||!Number.isFinite(p.scroll)||p.scroll<0||p.scroll>qg)return null;g==="graph"&&s++,a++,p.id===c.activeTab&&(h=!0),u.push({id:p.id,kind:g,history:p.history,cursor:p.cursor,scroll:p.scroll})}if(!h)return null;let d=c.lastDocumentTab;if(Object.hasOwn(c,"lastDocumentTab")&&(!Hn(d,"tab")||!u.some(p=>p.id===d&&p.kind==="document")))return null;l.push({id:c.id,tabs:u,activeTab:c.activeTab,...typeof d=="string"?{lastDocumentTab:d}:{}})}return a>na||s>1||!l.some(c=>c.id===e.activePane)?null:{version:1,panes:l,activePane:e.activePane,split:e.split,ratio:e.ratio,treeVisible:e.treeVisible,contextVisible:e.contextVisible,treeWidth:e.treeWidth,contextWidth:e.contextWidth,contextGraphHeight:t,contextTagsHeight:n,theme:e.theme,preferences:r}}function nc(e){if(e.preferences.startup==="restore")return e;let t=ra();return{...e,panes:t.panes,activePane:t.activePane}}function rc(e,t,n={}){let r=Un(e,t,n);return!n.newTab||e.preferences.focusNewTabs?r:{...r,activePane:e.activePane,panes:r.panes.map(i=>{let o=e.panes.find(l=>l.id===i.id),{lastDocumentTab:a,...s}=i;return{...s,activeTab:o.activeTab,...o.lastDocumentTab?{lastDocumentTab:o.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 Ei(e,t=!1){return{ok:!0,data:e,cached:t}}function At(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function ic(e){return e===403?"auth":e===404?"missing":"server"}function oc(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function pn(e,t,n,r){let i;try{i=await e(t,r)}catch(a){return At("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return At(ic(i.status),i.status,oc(i.status));let o;try{o=await i.json()}catch{return At("malformed",i.status,"response was not valid JSON")}return n(o)?Ei(o):At("malformed",i.status,"response did not match the expected shape")}function Xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ac(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Yg(e){if(!Xe(e)||typeof e.stamp!="string")return!1;let t=e.model;return!Xe(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:Xe(e.tags)&&Xe(e.dangling)}function Xg(e){if(!Xe(e)||typeof e.stamp!="string"||typeof e.turn!="number")return!1;let t=e.events;return Array.isArray(t)&&t.every(n=>Xe(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"&&ac(n.slugs)&&(n.query===void 0||typeof n.query=="string"))}function Zg(e){if(!Xe(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return ac(e.tags)}function sc(e){return Xe(e)&&Zg(e.note)}function Qg(e){return Xe(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function Jg(e){return Xe(e)&&typeof e.opened=="boolean"}var em=new Set(["human","agent","outside","system"]),tm=e=>Number.isInteger(e)&&e>=0;function nm(e){if(!Xe(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(!Xe(n)||typeof n.at!="string"||!em.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(tm)&&typeof n.text=="string"})}function rm(e){let t=[],n=null;for(let{at:r,by:i,op:o,full:a,keep:s,text:l}of e.revisions){if(a!==void 0)n=a;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:o,body:n})}return{slug:e.slug,enabled:e.enabled,trimmed:e.trimmed,revisions:t}}function im(e){return Xe(e)&&typeof e.enabled=="boolean"}function om(e){return Xe(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}function Si(e,t=null){return cc(e,"/api/graph",t,Yg)}function lc(e,t=null){return cc(e,"/api/trail",t,Xg)}async function cc(e,t,n,r){let i=n===null?void 0:{"if-none-match":`"${n.stamp}"`},o;try{o=await e(t,i===void 0?{}:{headers:i})}catch(s){return At("network",0,s instanceof Error?s.message:"network request failed")}if(o.status===304)return n===null?At("malformed",304,"server sent 304 for an unconditional request"):Ei(n,!0);if(!o.ok)return At(ic(o.status),o.status,oc(o.status));let a;try{a=await o.json()}catch{return At("malformed",o.status,"response was not valid JSON")}return r(a)?Ei(a):At("malformed",o.status,"response did not match the expected shape")}function da(e,t){return pn(e,`/api/note/${encodeURIComponent(t)}`,sc)}function uc(e,t,n){return pn(e,`/api/search?q=${encodeURIComponent(t)}`,Qg,n===void 0?void 0:{signal:n})}function dc(e,t){return pn(e,"/api/open",Jg,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function hc(e,t){return pn(e,"/api/notes",sc,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})}function fn(e,t,n,r){return pn(e,t,om,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var Ri=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,ha=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,pc=(e,t,n,r=!1)=>fn(e,Ri(t),"POST",r?{body:n,raw:!0}:{body:n}),fc=(e,t,n)=>fn(e,Ri(t,"/rename"),"POST",{name:n}),gc=(e,t,n)=>fn(e,Ri(t,"/move"),"POST",{folder:n}),mc=(e,t)=>fn(e,Ri(t),"DELETE"),vc=(e,t)=>fn(e,ha(t),"POST"),wc=(e,t,n)=>fn(e,ha(t,"/rename"),"POST",{name:n}),yc=(e,t)=>fn(e,ha(t),"DELETE");async function bc(e,t){let n=await pn(e,`/api/history/${encodeURIComponent(t)}`,nm);if(!n.ok)return n;let r=rm(n.data);return r===null?At("malformed",200,"history did not fit together"):Ei(r,n.cached)}function pa(e,t){return pn(e,"/api/history-settings",im,t===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:t})})}function rt(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 am(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 o=l=>{if(!l.detail.path)return null;let c=l.detail.path,u=null,h=0,d=n.get("repository")??[];for(let p of d){let g=t.get(p);if(g&&g.kind==="module"&&g.detail.path){let y=g.detail.path;c.startsWith(y+"/")&&y.length>h&&(u=p,h=y.length)}}return u},a=new Map;for(let l of e.nodes){if(l.kind!=="entryPoint")continue;let c=o(l);if(c){let u=a.get(c);u?u.push(l.id):a.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:a,roots:s}}function _c(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 sm(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function xc(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function lm(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),o=t.get(r),a=xc(i),s=xc(o);if(a!==s)return a?-1:1;let l=rt(i),c=rt(o);return l.localeCompare(c)})}function kc(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 cm(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?kc(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?kc(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 fa(e,t){let n=am(e),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let v=(i.get(g)??[]).filter(b=>{let x=r.get(b);if(!x||x.kind!=="entryPoint")return!0;for(let[,T]of o)if(T.includes(b))return!1;return!0}).concat(o.get(g)??[]);return v=v.filter(b=>r.has(b)),t.showInternals||(v=v.filter(b=>{let x=r.get(b);return!(x&&sm(x.kind))})),lm(v,r)},l=t.provFilter!==null||t.query.length>0,c=g=>!(t.provFilter!==null&&g.provenance!==t.provFilter||t.query.length>0&&!rt(g).toLowerCase().includes(t.query.toLowerCase())),u=new Set,h=g=>{let y=r.get(g),w=!1;for(let b of s(g))h(b)&&(w=!0);let v=c(y)||w;return v&&u.add(g),v};for(let g of a)h(g);let d=[],p=(g,y)=>{if(!u.has(g))return;let w=r.get(g),v=s(g),b=v.filter(T=>u.has(T)),x=l?b.length>0:t.expanded.has(g);if(d.push({id:g,depth:y,hasKids:v.length>0,expanded:x,label:rt(w),kind:w.kind,provenance:w.provenance,meta:cm(w)}),x)for(let T of b)p(T,y+1)};for(let g of a)p(g,0);return d}function ga(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 yr(e,t){if(!e)return"";let n=Date.parse(e);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var um=7;function ma(e,t){if(e===null)return"";switch(e.kind){case"relTime":return yr(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,um);case"text":return e.text}}var dm="## Raw",hm=/^[ \t]*(`{3,}|~{3,})(.*)$/gm,pm=new RegExp(`^${dm}[ \\t]*\\r?$`,"m");function Tc(e){let t=[],n=null;for(let r of e.matchAll(hm)){let i=r[1],o=r[2];n===null?n={at:r.index,marker:i[0],length:i.length}:i[0]===n.marker&&i.length>=n.length&&o.trim()===""&&(t.push([n.at,r.index+r[0].length]),n=null)}return n!==null&&t.push([n.at,e.length]),t}function Ec(e,t){let n=0;for(;;){let r=e.slice(n),i=pm.exec(r);if(i===null)return e.length;let o=n+i.index,a=t.find(([s,l])=>o>=s&&o<l);if(a===void 0)return o;n=a[1]}}var fm=/(?:^|\n)-{3,}[ \t]*\r?\n\s*$/;function gm(e){let t=Ec(e,Tc(e));if(t===e.length)return t;let n=fm.exec(e.slice(0,t));return n===null?t:n.index===0&&!e.startsWith(`
|
|
22
|
-
`)?0:n.index+1}function
|
|
21
|
+
"use strict";(()=>{var Vm=Object.create;var Zl=Object.defineProperty;var jm=Object.getOwnPropertyDescriptor;var qm=Object.getOwnPropertyNames;var Ym=Object.getPrototypeOf,Zm=Object.prototype.hasOwnProperty;var Xl=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Xm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qm(t))!Zm.call(e,i)&&i!==n&&Zl(e,i,{get:()=>t[i],enumerable:!(r=jm(t,i))||r.enumerable});return e};var Dr=(e,t,n)=>(n=e!=null?Vm(Ym(e)):{},Xm(t||!e||!e.__esModule?Zl(n,"default",{value:e,enumerable:!0}):n,e));var Ra=Xl((iR,rl)=>{"use strict";var dr=typeof Reflect=="object"?Reflect:null,$p=dr&&typeof dr.apply=="function"?dr.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Sa;dr&&typeof dr.ownKeys=="function"?Sa=dr.ownKeys:Object.getOwnPropertySymbols?Sa=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Sa=function(t){return Object.getOwnPropertyNames(t)};function Vx(e){console&&console.warn&&console.warn(e)}var Hp=Number.isNaN||function(t){return t!==t};function ue(){ue.init.call(this)}rl.exports=ue;rl.exports.once=Zx;ue.EventEmitter=ue;ue.prototype._events=void 0;ue.prototype._eventsCount=0;ue.prototype._maxListeners=void 0;var zp=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(ue,"defaultMaxListeners",{enumerable:!0,get:function(){return zp},set:function(e){if(typeof e!="number"||e<0||Hp(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");zp=e}});ue.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};ue.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Hp(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 Wp(e){return e._maxListeners===void 0?ue.defaultMaxListeners:e._maxListeners}ue.prototype.getMaxListeners=function(){return Wp(this)};ue.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")$p(l,this,n);else for(var c=l.length,u=jp(l,c),r=0;r<c;++r)$p(u[r],this,n);return!0};function Up(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=Wp(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,Vx(s)}return e}ue.prototype.addListener=function(t,n){return Up(this,t,n,!1)};ue.prototype.on=ue.prototype.addListener;ue.prototype.prependListener=function(t,n){return Up(this,t,n,!0)};function jx(){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 Bp(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=jx.bind(r);return i.listener=n,r.wrapFn=i,i}ue.prototype.once=function(t,n){return Ea(n),this.on(t,Bp(this,t,n)),this};ue.prototype.prependOnceListener=function(t,n){return Ea(n),this.prependListener(t,Bp(this,t,n)),this};ue.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():qx(r,a),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};ue.prototype.off=ue.prototype.removeListener;ue.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 Kp(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?Yx(i):jp(i,i.length)}ue.prototype.listeners=function(t){return Kp(this,t,!0)};ue.prototype.rawListeners=function(t){return Kp(this,t,!1)};ue.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Vp.call(e,t)};ue.prototype.listenerCount=Vp;function Vp(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}ue.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 qx(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Yx(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Zx(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))}qp(e,t,a,{once:!0}),t!=="error"&&Xx(e,i,{once:!0})})}function Xx(e,t,n){typeof e.on=="function"&&qp(e,"error",t,n)}function qp(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 il=Xl((sR,Zp)=>{"use strict";Zp.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Fi,se,nc,Qm,an,Ql,rc,ic,ho,Pi,Ir,ac,go,po,fo,Jm,Mi={},Gi=[],ev=/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 mo(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function tv(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??++nc,__i:-1,__u:0};return i==null&&se.vnode!=null&&se.vnode(a),a}function ye(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 nv(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ht({},t);a.__v=t.__v+1,se.vnode&&se.vnode(a),vo(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,uc(r,a,i),t.__e=t.__=null,a.__e!=n&&oc(a)}}function oc(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}),oc(e)}function Jl(e){(!e.__d&&(e.__d=!0)&&an.push(e)&&!Oi.__r++||Ql!=se.debounceRendering)&&((Ql=se.debounceRendering)||rc)(Oi)}function Oi(){try{for(var e,t=1;an.length;)an.length>t&&an.sort(ic),e=an.shift(),t=an.length,nv(e)}finally{an.length=Oi.__r=0}}function sc(e,t,n,r,i,a,o,s,l,c,u){var d,h,f,g,y,v,w=r&&r.__k||Gi,b=t.length;for(l=rv(n,t,w,l,b),d=0;d<b;d++)(f=n.__k[d])!=null&&(h=f.__i!=-1&&w[f.__i]||Mi,f.__i=d,v=vo(e,f,h,i,a,o,s,l,c,u),g=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&wo(h.ref,null,f),u.push(f.ref,f.__c||g,f)),y==null&&g!=null&&(y=g),4&f.__u?(l=lc(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=y,l}function rv(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(ye,{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=iv(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)),hc(s,s));return r}function lc(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=lc(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 iv(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 ec(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||ev.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||ec(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||ec(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(ac,"$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[Ir]=r[Ir]:(n[Ir]=go,e.addEventListener(t,a?fo:po,a)):e.removeEventListener(t,a?fo:po,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 tc(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Pi]==null)t[Pi]=go++;else if(t[Pi]<n[Ir])return;return n(se.event?se.event(t):t)}}}function vo(e,t,n,r,i,a,o,s,l,c){var u,d,h,f,g,y,v,w,b,_,x,S,O,z,L,G,I=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=se.__b)&&u(t);e:if(typeof I=="function"){d=o.length;try{if(b=t.props,_=I.prototype&&I.prototype.render,x=(u=I.contextType)&&r[u.__c],S=u?x?x.props.value:u.__:r,n.__c?w=(h=t.__c=n.__c).__=h.__E:(_?t.__c=h=new I(b,S):(t.__c=h=new Ii(b,S),h.constructor=I,h.render=ov),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),_&&I.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Ht({},h.__s)),Ht(h.__s,I.getDerivedStateFromProps(b,h.__s))),g=h.props,y=h.state,h.__v=t,f)_&&I.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),_&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(_&&I.getDerivedStateFromProps==null&&b!==g&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(b,S),t.__v==n.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(b,h.__s,S)===!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(M){M&&(M.__=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,S),_&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(g,y,v)})}if(h.context=S,h.props=b,h.__P=e,h.__e=!1,O=se.__r,z=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&&++z<25);h.state=h.__s,h.getChildContext!=null&&(r=Ht(Ht({},r),h.getChildContext())),_&&!f&&h.getSnapshotBeforeUpdate!=null&&(v=h.getSnapshotBeforeUpdate(g,y)),L=u!=null&&u.type===ye&&u.key==null?dc(u.props.children):u,s=sc(e,$i(L)?L:[L],t,n,r,i,a,o,s,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),w&&(h.__E=h.__=null)}catch(M){if(o.length=d,t.__v=null,l||a!=null){if(M.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(G=a.length;G--;)mo(a[G])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),M.then||cc(t),se.__e(M,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=av(n.__e,t,n,r,i,a,o,l,c);return(u=se.diffed)&&u(t),128&t.__u?void 0:s}function cc(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(cc))}function uc(e,t,n){for(var r=0;r<n.length;r++)wo(n[r],n[++r],n[++r]);se.__c&&se.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){se.__e(a,i.__v)}})}function dc(e){return typeof e!="object"||e==null||e.__b>0?e:$i(e)?e.map(dc):e.constructor!==void 0?null:Ht({},e)}function av(e,t,n,r,i,a,o,s,l){var c,u,d,h,f,g,y,v=n.props||Mi,w=t.props,b=t.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),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(w);e=document.createElementNS(i,b,w.is&&w),s&&(se.__m&&se.__m(t,a),s=!1),a=null}if(b==null)v===w||s&&e.data==w||(e.data=w);else{if(a=b=="textarea"&&w.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 w||c=="value"&&"defaultValue"in w||c=="checked"&&"defaultChecked"in w||Ni(e,c,null,f,i);for(c in w)f=w[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?u=f:c=="value"?g=f:c=="checked"?y=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=""),sc(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--;)mo(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",y!=null&&y!=e[c]&&Ni(e,c,y,v[c],i))}return e}function wo(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){se.__e(i,n)}}function hc(e,t,n){var r,i;if(se.unmount&&se.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||wo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){se.__e(a,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&hc(r[i],t,n||typeof e.type!="function");n||mo(e.__e),e.__c=e.__=e.__e=void 0}function ov(e,t,n){return this.constructor(e,n)}function pc(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),se.__&&se.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,a=[],o=[],vo(t,e=(!r&&n||t).__k=tv(ye,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),uc(a,e,o),e.props.children=null}Fi=Gi.slice,se={__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}},nc=0,Qm=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),Jl(this))},Ii.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Jl(this))},Ii.prototype.render=ye,an=[],rc=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ic=function(e,t){return e.__v.__b-t.__v.__b},Oi.__r=0,ho=Math.random().toString(8),Pi="__d"+ho,Ir="__a"+ho,ac=/(PointerCapture)$|Capture$/i,go=0,po=tc(!1),fo=tc(!0),Jm=0;var fc="weave-bootstrap";var yo={cwd:""};function sv(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function gc(e){if(e===null||e.trim()==="")return yo;let t;try{t=JSON.parse(e)}catch{return yo}return sv(t)?t:yo}var _n,ke,bo,mc,Mr=0,Tc=[],Re=se,vc=Re.__b,wc=Re.__r,yc=Re.diffed,bc=Re.__c,xc=Re.unmount,kc=Re.__;function Gr(e,t){Re.__h&&Re.__h(ke,e,Mr||t),Mr=0;var n=ke.__H||(ke.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function K(e){return Mr=1,lv(Rc,e)}function lv(e,t,n){var r=Gr(_n++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Rc(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 te(e,t){var n=Gr(_n++,3);!Re.__s&&ko(n.__H,t)&&(n.__=e,n.u=t,ke.__H.__h.push(n))}function $e(e,t){var n=Gr(_n++,4);!Re.__s&&ko(n.__H,t)&&(n.__=e,n.u=t,ke.__h.push(n))}function V(e){return Mr=5,Pe(function(){return{current:e}},[])}function Pe(e,t){var n=Gr(_n++,7);return ko(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Sc(e,t){return Mr=8,Pe(function(){return e},t)}function Ec(){var e=Gr(_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 cv(){for(var e;e=Tc.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(zi),t.__h.some(xo),t.__h=[]}catch(n){t.__h=[],Re.__e(n,e.__v)}}}Re.__b=function(e){ke=null,vc&&vc(e)},Re.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),kc&&kc(e,t)},Re.__r=function(e){wc&&wc(e),_n=0;var t=(ke=e.__c).__H;t&&(bo===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(xo),t.__h=[],_n=0)),bo=ke},Re.diffed=function(e){yc&&yc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Tc.push(t)!==1&&mc===Re.requestAnimationFrame||((mc=Re.requestAnimationFrame)||uv)(cv)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),bo=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.__||xo(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Re.__e(r,n.__v)}}),bc&&bc(e,t)},Re.unmount=function(e){xc&&xc(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 _c=typeof requestAnimationFrame=="function";function uv(e){var t,n=function(){clearTimeout(r),_c&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);_c&&(t=requestAnimationFrame(n))}function zi(e){var t=ke,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ke=t}function xo(e){var t=ke;e.__c=e.__(),ke=t}function ko(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Rc(e,t){return typeof t=="function"?t(e):t}var Ac={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"},Cc={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"},me={light:{name:"Catppuccin Latte · Mauve",scheme:"light",colors:Ac},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...Ac,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:Cc},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...Cc,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"}}},Lc=["system",...Object.keys(me)];function Xn(e){return typeof e=="string"&&Lc.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 Nc(e,t){return t==="theme"?me[e].colors.accent:Tn[t][me[e].scheme]}var it={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},on={...it};function _o(e){Object.assign(it,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 Pc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Dc(e){if(!Pc(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"||me[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(!Pc(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 Ro=40,Ic=100,dv=1e9,Or=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function Ao(){return{version:1,panes:[{id:"pane-1",tabs:[Or("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 Co(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")??Co(e);return r?{...n,lastDocumentTab:r.id}:n}function Bi(e){if(En(e).kind==="document")return e;let t=Sn(e),n=Co(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 Eo(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=Ro?e:Rn(e,{...t,tabs:[...t.tabs,n]},n)}function To(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>Ic&&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=Co(r),a?r={...r,activeTab:a.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!a)return Eo(e,r,To(Or(er(e,"tab")),t));let o=To(a,t);return o===a&&r.id===e.activePane&&i===a.id?e:Rn(e,r,o)}function Lo(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 Eo(e,n,{id:er(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function No(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 Po(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=Or(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 Do(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 Io(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 Mc(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 Mo(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)>=Ro)return e;let s=a.length?null:Or(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 So(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 Gc(e){if(!Wi(e)||!So(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")?Dc(e.preferences):sn;if(i===null)return null;let a=e.preferences;e.theme!=="system"&&(!Wi(a)||!Object.hasOwn(a,"lightTheme"))&&(i={...i,[`${me[e.theme].scheme}Theme`]:e.theme});let o=new Set,s=0,l=0,c=[];for(let u of e.panes){if(!Wi(u)||!So(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)||!So(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 y=g.kind;if(!Array.isArray(g.history)||g.history.length<1||g.history.length>Ic||!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>dv)return null;y==="graph"&&l++,s++,g.id===u.activeTab&&(h=!0),d.push({id:g.id,kind:y,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>Ro||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 Oc(e){if(e.preferences.startup==="restore")return e;let t=Ao();return{...e,panes:t.panes,activePane:t.activePane}}function Fc(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 $c(e){return e===403?"auth":e===404?"missing":"server"}function zc(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($c(i.status),i.status,zc(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 at(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Hc(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function hv(e){if(!at(e)||typeof e.stamp!="string")return!1;let t=e.model;return!at(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:at(e.tags)&&at(e.dangling)}function pv(e){if(!at(e)||typeof e.stamp!="string"||typeof e.turn!="number")return!1;let t=e.events;return Array.isArray(t)&&t.every(n=>at(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"&&Hc(n.slugs)&&(n.query===void 0||typeof n.query=="string"))}function fv(e){if(!at(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return Hc(e.tags)}function Wc(e){return at(e)&&fv(e.note)}function gv(e){return at(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function mv(e){return at(e)&&typeof e.opened=="boolean"}var vv=new Set(["human","agent","outside","system"]),wv=e=>Number.isInteger(e)&&e>=0;function yv(e){if(!at(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(!at(n)||typeof n.at!="string"||!vv.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(wv)&&typeof n.text=="string"})}function bv(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 xv(e){return at(e)&&typeof e.enabled=="boolean"}function kv(e){return at(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}function qi(e,t=null){return Bc(e,"/api/graph",t,hv)}function Uc(e,t=null){return Bc(e,"/api/trail",t,pv)}async function Bc(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($c(a.status),a.status,zc(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 Go(e,t){return An(e,`/api/note/${encodeURIComponent(t)}`,Wc)}function Kc(e,t,n){return An(e,`/api/search?q=${encodeURIComponent(t)}`,gv,n===void 0?void 0:{signal:n})}function Vc(e,t){return An(e,"/api/open",mv,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function jc(e,t){return An(e,"/api/notes",Wc,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})}function Cn(e,t,n,r){return An(e,t,kv,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var Yi=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,Oo=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,qc=(e,t,n,r=!1)=>Cn(e,Yi(t),"POST",r?{body:n,raw:!0}:{body:n}),Yc=(e,t,n)=>Cn(e,Yi(t,"/rename"),"POST",{name:n}),Zc=(e,t,n)=>Cn(e,Yi(t,"/move"),"POST",{folder:n}),Xc=(e,t)=>Cn(e,Yi(t),"DELETE"),Qc=(e,t)=>Cn(e,Oo(t),"POST"),Jc=(e,t,n)=>Cn(e,Oo(t,"/rename"),"POST",{name:n}),eu=(e,t)=>Cn(e,Oo(t),"DELETE");async function tu(e,t){let n=await An(e,`/api/history/${encodeURIComponent(t)}`,yv);if(!n.ok)return n;let r=bv(n.data);return r===null?Gt("malformed",200,"history did not fit together"):ji(r,n.cached)}function Fo(e,t){return An(e,"/api/history-settings",xv,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 _v(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 y=g.detail.path;c.startsWith(y+"/")&&y.length>d&&(u=f,d=y.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 iu(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 Tv(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function nu(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function Sv(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),a=t.get(r),o=nu(i),s=nu(a);if(o!==s)return o?-1:1;let l=pt(i),c=pt(a);return l.localeCompare(c)})}function ru(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 Ev(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?ru(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?ru(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 $o(e,t){let n=_v(e),{byId:r,tree:i,moduleEntries:a,roots:o}=n,s=g=>{let w=(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 w=w.filter(b=>r.has(b)),t.showInternals||(w=w.filter(b=>{let _=r.get(b);return!(_&&Tv(_.kind))})),Sv(w,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 y=r.get(g),v=!1;for(let b of s(g))d(b)&&(v=!0);let w=c(y)||v;return w&&u.add(g),w};for(let g of o)d(g);let h=[],f=(g,y)=>{if(!u.has(g))return;let v=r.get(g),w=s(g),b=w.filter(x=>u.has(x)),_=l?b.length>0:t.expanded.has(g);if(h.push({id:g,depth:y,hasKids:w.length>0,expanded:_,label:pt(v),kind:v.kind,provenance:v.provenance,meta:Ev(v)}),_)for(let x of b)f(x,y+1)};for(let g of o)f(g,0);return h}function zo(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 Rv=7;function Ho(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,Rv);case"text":return e.text}}var Av="## Raw",Cv=/^[ \t]*(`{3,}|~{3,})(.*)$/gm,Lv=new RegExp(`^${Av}[ \\t]*\\r?$`,"m");function au(e){let t=[],n=null;for(let r of e.matchAll(Cv)){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 ou(e,t){let n=0;for(;;){let r=e.slice(n),i=Lv.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 Nv=/(?:^|\n)-{3,}[ \t]*\r?\n\s*$/;function Pv(e){let t=ou(e,au(e));if(t===e.length)return t;let n=Nv.exec(e.slice(0,t));return n===null?t:n.index===0&&!e.startsWith(`
|
|
22
|
+
`)?0:n.index+1}function nr(e){let t=Pv(e);return{head:e.slice(0,t).trimEnd(),tail:e.slice(t).trimEnd()}}function Wo(e,t){return t===""?e:e===""?t:`${e}
|
|
23
23
|
|
|
24
|
-
${t}`}var
|
|
24
|
+
${t}`}var Dv=/^<!--(?! appended\b).*-->[ \t]*\r?$/;function Fr(e){let t=ou(e,au(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);
|
|
27
|
-
|
|
28
|
-
${t.replace(/^\s*\n/,"").trimEnd()}`}var vm=["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 ba(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 vm){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of e.edges){if(s.source!==t)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${rt(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of e.edges){if(s.kind!=="links-to"||s.target!==t)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${rt(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:rt(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Ci(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 wm=["contains","anchored-at"];function ym(e){return wm.includes(e)}function Li(e,t){let n=new Map;for(let d of e.nodes)n.set(d.id,d);let r=bm(e,n),i=_c(e),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!t.has(d)))for(let p of r.get(d)??[])a(p)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,xm(d,r));let l=new Map;for(let d of e.nodes)if(!(!o.has(d.id)||t.has(d.id)))for(let p of s.get(d.id)??[])!o.has(p)&&!l.has(p)&&l.set(p,d.id);for(let d of e.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let c=new Map;for(let[d,p]of r){let g=s.get(d);c.set(d,{children:p,descendants:g,members:g.filter(y=>l.get(y)===d),provenance:km(g,n),expanded:t.has(d)})}let u=new Set,h=[];for(let d of e.nodes)o.has(d.id)?h.push(d):u.add(d.id);return{nodes:h,edges:_m(e.edges,o,l),clusters:c,hidden:u,representative:l,roots:i}}function bm(e,t){let n=new Map;for(let r of e.edges){if(!ym(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 xm(e,t){let n=[],r=new Set([e]),i=o=>{for(let a of t.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(e),n}function km(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 _m(e,t,n){let r=a=>t.has(a)?a:n.get(a),i=[],o=new Set;for(let a of e){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let c=`${s}\0${l}\0${a.kind}`;o.has(c)||(o.add(c),i.push({source:s,target:l,kind:a.kind}))}return i}function xa(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 Bn=[null,"human","agent","generated"];function Sc(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function Ta(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 gn(e){return{...e.model,danglingLinks:e.dangling}}function Rc(e,t){return e===null?[]:fa(gn(e),t)}var Kn="vfolder:\0draft";function Ac(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function Cc(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function Lc(e,t){if(t===null)return[...e];let n={id:Kn,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(o=>o.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 Ea(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Tm(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return n.add(t),{...e,expanded:n}}function Em(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function Sa(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function mn(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 Pi(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 Nc(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 Ra(e){return e.type==="folder"}function Pc(e,t,n){return Ra(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function Dc(e,t){return e.query===t?e:{...e,query:t}}function Ic(e){let t=Bn.indexOf(e.provFilter),n=Bn[(t+1)%Bn.length]??null;return{...e,provFilter:n}}function Mc(e){return{...e,showInternals:!e.showInternals}}function Di(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function _a(e,t){return e[t]?.id??null}function ka(e,t,n){if(e.length===0)return null;let r=Di(e,t),i=r===-1?n>0?-1:e.length:r;return _a(e,Math.min(e.length-1,Math.max(0,i+n)))}function Sm(e,t){let n=Di(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 Rm={j:"ArrowDown",k:"ArrowUp"};function Am(e){return Rm[e]??e}function Gc(e,t,n,r,i=!1){let o={state:t,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:t,selectedId:h,handled:!0}),s=Am(r);if(s==="ArrowDown")return a(ka(e,n,1));if(s==="ArrowUp")return a(ka(e,n,-1));if(s==="Home")return a(_a(e,0));if(s==="End")return a(_a(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=Di(e,n),c=l===-1?void 0:e[l];if(c===void 0||n===null)return o;if(s==="ArrowRight")return c.hasKids?c.expanded?a(ka(e,n,1)):{state:Tm(t,n),selectedId:n,handled:!0}:o;if(c.hasKids&&c.expanded)return{state:Em(t,n),selectedId:n,handled:!0};let u=Sm(e,n);return u===null?o:a(u)}var Cm={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function vn(e){return Cm[e]}var Lm={human:"●",agent:"◐",generated:"○"};function wn(e){return e===null?"":Lm[e]}function Vn(e){return e===null?"":`${e}-authored`}function Oc(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Nm(e){let t=e.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())t[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of e.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),t}function Pm(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:Oc(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:vn(e.kind),provenance:e.provenance,provenanceGlyph:wn(e.provenance),provenanceTitle:Vn(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:ma(e.meta,n),level:e.depth+1}}function Fc(e,t,n){let r=Nm(e);return e.map((i,o)=>Pm(i,t,n,r[o]))}function $c(e,t){return Di(e,t)===-1?null:Oc(t)}function zc(e){return{"--weave-depth":String(Math.max(0,e))}}function Ni(e){return e===null?"all":e}function Hc(e){let t=Bn.indexOf(e),n=Bn[(t+1)%Bn.length]??null;return`provenance filter: ${Ni(e)} — click for ${Ni(n)}`}function Wc(e){return e?"internals":"knowledge"}function Uc(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 Bc="filter…",Kc="Vault and repository",Vc="Filter the tree",jc="Filter the tree (/)";function qc(e,t,n){if(e===null)return"loading…";let r=ga(gn(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 Yc(e){return e.length===1?"1 row":`${e.length} rows`}function Xc(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Zc(this.cover(t,n),t,n,e)}function Zc(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o=e._root,a={data:r},s=e._x0,l=e._y0,c=e._x1,u=e._y1,h,d,p,g,y,w,v,b;if(!o)return e._root=a,e;for(;o.length;)if((y=t>=(h=(s+c)/2))?s=h:c=h,(w=n>=(d=(l+u)/2))?l=d:u=d,i=o,!(o=o[v=w<<1|y]))return i[v]=a,e;if(p=+e._x.call(null,o.data),g=+e._y.call(null,o.data),t===p&&n===g)return a.next=o,i?i[v]=a:e._root=a,e;do i=i?i[v]=new Array(4):e._root=new Array(4),(y=t>=(h=(s+c)/2))?s=h:c=h,(w=n>=(d=(l+u)/2))?l=d:u=d;while((v=w<<1|y)===(b=(g>=d)<<1|p>=h));return i[b]=o,i[v]=a,e}function Qc(e){var t,n,r=e.length,i,o,a=new Array(r),s=new Array(r),l=1/0,c=1/0,u=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(o=+this._y.call(null,t))||(a[n]=i,s[n]=o,i<l&&(l=i),i>u&&(u=i),o<c&&(c=o),o>h&&(h=o));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),n=0;n<r;++n)Zc(this,a[n],s[n],e[n]);return this}function Jc(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,o=(r=Math.floor(t))+1;else{for(var a=i-n||1,s=this._root,l,c;n>e||e>=i||r>t||t>=o;)switch(c=(t<r)<<1|e<n,l=new Array(4),l[c]=s,s=l,a*=2,c){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function eu(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function tu(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 Ie(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function nu(e,t,n){var r,i=this._x0,o=this._y0,a,s,l,c,u=this._x1,h=this._y1,d=[],p=this._root,g,y;for(p&&d.push(new Ie(p,i,o,u,h)),n==null?n=1/0:(i=e-n,o=t-n,u=e+n,h=t+n,n*=n);g=d.pop();)if(!(!(p=g.node)||(a=g.x0)>u||(s=g.y0)>h||(l=g.x1)<i||(c=g.y1)<o))if(p.length){var w=(a+l)/2,v=(s+c)/2;d.push(new Ie(p[3],w,v,l,c),new Ie(p[2],a,v,w,c),new Ie(p[1],w,s,l,v),new Ie(p[0],a,s,w,v)),(y=(t>=v)<<1|e>=w)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-y],d[d.length-1-y]=g)}else{var b=e-+this._x.call(null,p.data),x=t-+this._y.call(null,p.data),T=b*b+x*x;if(T<n){var A=Math.sqrt(n=T);i=e-A,o=t-A,u=e+A,h=t+A,r=p.data}}return r}function ru(e){if(isNaN(u=+this._x.call(null,e))||isNaN(h=+this._y.call(null,e)))return this;var t,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,c=this._y1,u,h,d,p,g,y,w,v;if(!n)return this;if(n.length)for(;;){if((g=u>=(d=(a+l)/2))?a=d:l=d,(y=h>=(p=(s+c)/2))?s=p:c=p,t=n,!(n=n[w=y<<1|g]))return this;if(!n.length)break;(t[w+1&3]||t[w+2&3]||t[w+3&3])&&(r=t,v=w)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):t?(o?t[w]=o:delete t[w],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[v]=n:this._root=n),this):(this._root=o,this)}function iu(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function ou(){return this._root}function au(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function su(e){var t=[],n,r=this._root,i,o,a,s,l;for(r&&t.push(new Ie(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var c=(o+s)/2,u=(a+l)/2;(i=r[3])&&t.push(new Ie(i,c,u,s,l)),(i=r[2])&&t.push(new Ie(i,o,u,c,l)),(i=r[1])&&t.push(new Ie(i,c,a,s,u)),(i=r[0])&&t.push(new Ie(i,o,a,c,u))}return this}function lu(e){var t=[],n=[],r;for(this._root&&t.push(new Ie(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,c=r.y1,u=(a+l)/2,h=(s+c)/2;(o=i[0])&&t.push(new Ie(o,a,s,u,h)),(o=i[1])&&t.push(new Ie(o,u,s,l,h)),(o=i[2])&&t.push(new Ie(o,a,h,u,c)),(o=i[3])&&t.push(new Ie(o,u,h,l,c))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function cu(e){return e[0]}function uu(e){return arguments.length?(this._x=e,this):this._x}function du(e){return e[1]}function hu(e){return arguments.length?(this._y=e,this):this._y}function yn(e,t,n){var r=new Aa(t??cu,n??du,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function Aa(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function pu(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ue=yn.prototype=Aa.prototype;Ue.copy=function(){var e=new Aa(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=pu(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]=pu(r));return e};Ue.add=Xc;Ue.addAll=Qc;Ue.cover=Jc;Ue.data=eu;Ue.extent=tu;Ue.find=nu;Ue.remove=ru;Ue.removeAll=iu;Ue.root=ou;Ue.size=au;Ue.visit=su;Ue.visitAfter=lu;Ue.x=uu;Ue.y=hu;function Ee(e){return function(){return e}}function vt(e){return(e()-.5)*1e-6}function Dm(e){return e.x+e.vx}function Im(e){return e.y+e.vy}function Ca(e){var t,n,r,i=1,o=1;typeof e!="function"&&(e=Ee(e==null?1:+e));function a(){for(var c,u=t.length,h,d,p,g,y,w,v=0;v<o;++v)for(h=yn(t,Dm,Im).visitAfter(s),c=0;c<u;++c)d=t[c],y=n[d.index],w=y*y,p=d.x+d.vx,g=d.y+d.vy,h.visit(b);function b(x,T,A,O,N){var G=x.data,$=x.r,F=y+$;if(G){if(G.index>d.index){var X=p-G.x-G.vx,Z=g-G.y-G.vy,Q=X*X+Z*Z;Q<F*F&&(X===0&&(X=vt(r),Q+=X*X),Z===0&&(Z=vt(r),Q+=Z*Z),Q=(F-(Q=Math.sqrt(Q)))/Q*i,d.vx+=(X*=Q)*(F=($*=$)/(w+$)),d.vy+=(Z*=Q)*F,G.vx-=X*(F=1-F),G.vy-=Z*F)}return}return T>p+F||O<p-F||A>g+F||N<g-F}}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,h;for(n=new Array(u),c=0;c<u;++c)h=t[c],n[h.index]=+e(h,c,t)}}return a.initialize=function(c,u){t=c,r=u,l()},a.iterations=function(c){return arguments.length?(o=+c,a):o},a.strength=function(c){return arguments.length?(i=+c,a):i},a.radius=function(c){return arguments.length?(e=typeof c=="function"?c:Ee(+c),l(),a):e},a}function Mm(e){return e.index}function fu(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function La(e){var t=Mm,n=h,r,i=Ee(30),o,a,s,l,c,u=1;e==null&&(e=[]);function h(w){return 1/Math.min(s[w.source.index],s[w.target.index])}function d(w){for(var v=0,b=e.length;v<u;++v)for(var x=0,T,A,O,N,G,$,F;x<b;++x)T=e[x],A=T.source,O=T.target,N=O.x+O.vx-A.x-A.vx||vt(c),G=O.y+O.vy-A.y-A.vy||vt(c),$=Math.sqrt(N*N+G*G),$=($-o[x])/$*w*r[x],N*=$,G*=$,O.vx-=N*(F=l[x]),O.vy-=G*F,A.vx+=N*(F=1-F),A.vy+=G*F}function p(){if(a){var w,v=a.length,b=e.length,x=new Map(a.map((A,O)=>[t(A,O,a),A])),T;for(w=0,s=new Array(v);w<b;++w)T=e[w],T.index=w,typeof T.source!="object"&&(T.source=fu(x,T.source)),typeof T.target!="object"&&(T.target=fu(x,T.target)),s[T.source.index]=(s[T.source.index]||0)+1,s[T.target.index]=(s[T.target.index]||0)+1;for(w=0,l=new Array(b);w<b;++w)T=e[w],l[w]=s[T.source.index]/(s[T.source.index]+s[T.target.index]);r=new Array(b),g(),o=new Array(b),y()}}function g(){if(a)for(var w=0,v=e.length;w<v;++w)r[w]=+n(e[w],w,e)}function y(){if(a)for(var w=0,v=e.length;w<v;++w)o[w]=+i(e[w],w,e)}return d.initialize=function(w,v){a=w,c=v,p()},d.links=function(w){return arguments.length?(e=w,p(),d):e},d.id=function(w){return arguments.length?(t=w,d):t},d.iterations=function(w){return arguments.length?(u=+w,d):u},d.strength=function(w){return arguments.length?(n=typeof w=="function"?w:Ee(+w),g(),d):n},d.distance=function(w){return arguments.length?(i=typeof w=="function"?w:Ee(+w),y(),d):i},d}var Gm={value:()=>{}};function mu(){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 Ii(n)}function Ii(e){this._=e}function Om(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}})}Ii.prototype=mu.prototype={constructor:Ii,on:function(e,t){var n=this._,r=Om(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=Fm(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=gu(n[i],e.name,t);else if(t==null)for(i in n)n[i]=gu(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 Ii(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function Fm(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function gu(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Gm,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Na=mu;var jn=0,xr=0,br=0,wu=1e3,Mi,kr,Gi=0,bn=0,Oi=0,_r=typeof performance=="object"&&performance.now?performance:Date,yu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ia(){return bn||(yu($m),bn=_r.now()+Oi)}function $m(){bn=0}function Pa(){this._call=this._time=this._next=null}Pa.prototype=Fi.prototype={constructor:Pa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Ia():+n)+(t==null?0:+t),!this._next&&kr!==this&&(kr?kr._next=this:Mi=this,kr=this),this._call=e,this._time=n,Da()},stop:function(){this._call&&(this._call=null,this._time=1/0,Da())}};function Fi(e,t,n){var r=new Pa;return r.restart(e,t,n),r}function bu(){Ia(),++jn;for(var e=Mi,t;e;)(t=bn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--jn}function vu(){bn=(Gi=_r.now())+Oi,jn=xr=0;try{bu()}finally{jn=0,Hm(),bn=0}}function zm(){var e=_r.now(),t=e-Gi;t>wu&&(Oi-=t,Gi=e)}function Hm(){for(var e,t=Mi,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:Mi=n);kr=e,Da(r)}function Da(e){if(!jn){xr&&(xr=clearTimeout(xr));var t=e-bn;t>24?(e<1/0&&(xr=setTimeout(vu,e-_r.now()-Oi)),br&&(br=clearInterval(br))):(br||(Gi=_r.now(),br=setInterval(zm,wu)),jn=1,yu(vu))}}function xu(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function ku(e){return e.x}function _u(e){return e.y}var Wm=10,Um=Math.PI*(3-Math.sqrt(5));function Ma(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=Fi(h),c=Na("tick","end"),u=xu();e==null&&(e=[]);function h(){d(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function d(y){var w,v=e.length,b;y===void 0&&(y=1);for(var x=0;x<y;++x)for(n+=(o-n)*i,s.forEach(function(T){T(n)}),w=0;w<v;++w)b=e[w],b.fx==null?b.x+=b.vx*=a:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=a:(b.y=b.fy,b.vy=0);return t}function p(){for(var y=0,w=e.length,v;y<w;++y){if(v=e[y],v.index=y,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),isNaN(v.x)||isNaN(v.y)){var b=Wm*Math.sqrt(.5+y),x=y*Um;v.x=b*Math.cos(x),v.y=b*Math.sin(x)}(isNaN(v.vx)||isNaN(v.vy))&&(v.vx=v.vy=0)}}function g(y){return y.initialize&&y.initialize(e,u),y}return p(),t={tick:d,restart:function(){return l.restart(h),t},stop:function(){return l.stop(),t},nodes:function(y){return arguments.length?(e=y,p(),s.forEach(g),t):e},alpha:function(y){return arguments.length?(n=+y,t):n},alphaMin:function(y){return arguments.length?(r=+y,t):r},alphaDecay:function(y){return arguments.length?(i=+y,t):+i},alphaTarget:function(y){return arguments.length?(o=+y,t):o},velocityDecay:function(y){return arguments.length?(a=1-y,t):1-a},randomSource:function(y){return arguments.length?(u=y,s.forEach(g),t):u},force:function(y,w){return arguments.length>1?(w==null?s.delete(y):s.set(y,g(w)),t):s.get(y)},find:function(y,w,v){var b=0,x=e.length,T,A,O,N,G;for(v==null?v=1/0:v*=v,b=0;b<x;++b)N=e[b],T=y-N.x,A=w-N.y,O=T*T+A*A,O<v&&(G=N,v=O);return G},on:function(y,w){return arguments.length>1?(c.on(y,w),t):c.on(y)}}}function Ga(){var e,t,n,r,i=Ee(-30),o,a=1,s=1/0,l=.81;function c(p){var g,y=e.length,w=yn(e,ku,_u).visitAfter(h);for(r=p,g=0;g<y;++g)t=e[g],w.visit(d)}function u(){if(e){var p,g=e.length,y;for(o=new Array(g),p=0;p<g;++p)y=e[p],o[y.index]=+i(y,p,e)}}function h(p){var g=0,y,w,v=0,b,x,T;if(p.length){for(b=x=T=0;T<4;++T)(y=p[T])&&(w=Math.abs(y.value))&&(g+=y.value,v+=w,b+=w*y.x,x+=w*y.y);p.x=b/v,p.y=x/v}else{y=p,y.x=y.data.x,y.y=y.data.y;do g+=o[y.data.index];while(y=y.next)}p.value=g}function d(p,g,y,w){if(!p.value)return!0;var v=p.x-t.x,b=p.y-t.y,x=w-g,T=v*v+b*b;if(x*x/l<T)return T<s&&(v===0&&(v=vt(n),T+=v*v),b===0&&(b=vt(n),T+=b*b),T<a&&(T=Math.sqrt(a*T)),t.vx+=v*p.value*r/T,t.vy+=b*p.value*r/T),!0;if(p.length||T>=s)return;(p.data!==t||p.next)&&(v===0&&(v=vt(n),T+=v*v),b===0&&(b=vt(n),T+=b*b),T<a&&(T=Math.sqrt(a*T)));do p.data!==t&&(x=o[p.data.index]*r/T,t.vx+=v*x,t.vy+=b*x);while(p=p.next)}return c.initialize=function(p,g){e=p,n=g,u()},c.strength=function(p){return arguments.length?(i=typeof p=="function"?p:Ee(+p),u(),c):i},c.distanceMin=function(p){return arguments.length?(a=p*p,c):Math.sqrt(a)},c.distanceMax=function(p){return arguments.length?(s=p*p,c):Math.sqrt(s)},c.theta=function(p){return arguments.length?(l=p*p,c):Math.sqrt(l)},c}function Oa(e){var t=Ee(.1),n,r,i;typeof e!="function"&&(e=Ee(e==null?0:+e));function o(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 a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:Ee(+s),a(),o):t},o.x=function(s){return arguments.length?(e=typeof s=="function"?s:Ee(+s),a(),o):e},o}function Fa(e){var t=Ee(.1),n,r,i;typeof e!="function"&&(e=Ee(e==null?0:+e));function o(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 a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:Ee(+s),a(),o):t},o.y=function(s){return arguments.length?(e=typeof s=="function"?s:Ee(+s),a(),o):e},o}var Bm=9,$i=6,Tr=18,Km=32,Su=9,Er=Bm+Su;function $a(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+Km));return $i+(Tr-$i)*n}function za(e){return e+Su}var Vm=300,Ru=1,Tu=.001;function Eu(e){return e==="contains"||e==="anchored-at"}function jm(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function qm(e){let t=[],n=new Set;for(let o of e.nodes)n.has(o.id)||(n.add(o.id),t.push(o.id));let r=[],i=new Set;for(let o of e.edges){if(o.source===o.target||!n.has(o.source)||!n.has(o.target))continue;let a=`${o.source}\0${o.target}\0${o.kind}`;i.has(a)||(i.add(a),r.push(o))}return{ids:t,edges:r}}function Ha(e){let t=La(e.links).id(n=>n.id).distance(n=>Eu(n.kind)?Ye.containsRest:Ye.relationDistance).strength(n=>Eu(n.kind)?Ye.containsStrength:Ye.relationStrength).iterations(2);return Ma(e.nodes).randomSource(jm(e.seed??Ru)).force("charge",Ga().strength(Ye.charge).distanceMax(Ye.chargeMax)).force("link",t).force("collide",Ca(n=>n.r??Er).strength(1)).force("x",Oa(0).strength(Ye.center)).force("y",Fa(0).strength(Ye.center)).stop()}function Ym(e,t,n){let r=Ha({nodes:e,links:t.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(Tu).alphaDecay(n.ticks>0?1-Math.pow(Tu,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function Au(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??Vm)),{ids:r,edges:i}=qm(e),o=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}),a=new Map;for(let l of i)a.set(l.source,(a.get(l.source)??0)+1),a.set(l.target,(a.get(l.target)??0)+1);for(let l of o)l.r=za($a(a.get(l.id)??0));o.length>1&&Ym(o,i,{ticks:n,seed:t.seed??Ru,warm:t.initial!==void 0});let s=new Map;for(let l of o)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}var Xm=Object.fromEntries(Object.entries(pe).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 Mt(e){let t=Xm[wi(e)];return typeof e=="string"?t:{...t,accent:Xl(e.theme,e.accent)}}var Zm={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},Qm={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function Jm(e,t){return Mt(t)[Zm[e]]}function Cu(e,t){return Mt(t)[Qm[e]]}function ev(e,t){return tv(e)?Ba(Cu(e,t),t,nv):Cu(e,t)}function tv(e){return e==="contains"||e==="anchored-at"}var Ua=.85,nv=.3;function qn(e,t,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(e),o=r(t);if(i===null||o===null)return e;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,c)=>Math.round(l+(c-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function Ba(e,t,n=Ua){return qn(e,Mt(t).ground,n)}var rv={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},Lu=1.6,Nu=32,iv=Nu/2;function ov(e,t=Nu){if(t<=0)return e.length>0?"…":e;if(e.length<=t)return e;let n=t-1,i=e.slice(0,n).lastIndexOf(" "),o=i>=iv?i:n;return`${e.slice(0,o).trimEnd()}…`}function av(e){let t=wn(e.provenance),n=rt(e);return ov(t===""?n:`${t} ${n}`)}var sv=6,lv=6;function cv(e){return(t,n,r)=>{if(n.label===null||n.label==="")return;let i=Mt(e);t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=lv,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+sv),t.restore()}}function Pu(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(o++,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(o===0)return null;let a=Math.max(Tr,(Er*4-Math.max(r-t,i-n))/2);return{x:[t-a,r+a],y:[n-a,i+a]}}var Du={nodes:[],edges:[]};function Iu(e){return`${e.source}\0${e.target}\0${e.kind}`}function uv(e,t){let n=new Map,r=new Set;for(let i of e){if(i.source===i.target||!t.has(i.source)||!t.has(i.target))continue;let o=Iu(i);r.has(o)||(r.add(o),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function Mu(e,t,n,r,i){let o=new Map;for(let h of e){if(o.has(h.id))continue;let d=n.get(h.id);d===void 0||!Number.isFinite(d.x)||!Number.isFinite(d.y)||o.set(h.id,h)}let a=new Set(o.keys()),s=uv(t,a),l=[];for(let[h,d]of o){let p=n.get(h),g=$a(s.get(h)??0);l.push({id:h,x:p.x,y:p.y,size:g,label:av(d),color:i?.get(h)??Jm(d.kind,r),kind:d.kind,provenance:d.provenance,zIndex:Math.round(g),type:"circle"})}let c=[],u=new Set;for(let h of t){if(h.source===h.target||!a.has(h.source)||!a.has(h.target))continue;let d=Iu(h);u.has(d)||(u.add(d),c.push({key:d,source:h.source,target:h.target,size:rv[h.kind],color:ev(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function Gu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:r===t&&e.has(r)?{zIndex:i.zIndex+Wa*2,size:i.size*Sr(fv,n)}:e.has(r)?{zIndex:i.zIndex+Wa,size:i.size*Sr(gv,n)}:{color:Ba(i.color,o,Ua*n),label:n>=pv?null:i.label,zIndex:0}}var dv=60,hv=.004;function Ou(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/dv);return Math.abs(t-i)<hv?t:i}function Sr(e,t){return 1+(e-1)*t}var pv=.5,fv=1.45,gv=1.15,Wa=Tr+1;function Fu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:!e.has(i.source)||!e.has(i.target)?{color:Ba(i.color,o,Ua*n)}:t!=null&&(i.source===t||i.target===t)?{zIndex:2,size:i.size*Sr(Lu*1.35,n),color:qn(i.color,Mt(o).accent,n)}:{zIndex:1,size:i.size*Sr(Lu,n)}}var mv={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 $u(e,t,n,r){if(e===void 0||!(e.strength>0))return{};let i=mv[e.kind],o=Math.min(1,e.strength);return{color:qn(t.color,Mt(n)[i.slot],i.blend*o),size:t.size*Sr(i.growth,o),zIndex:t.zIndex+Wa*3,label:r}}var zu=($i+Tr)/2,vv=30;function Ka(e){return e<vv?0:zu}var wv=Er*4,yv=1;function Hu(e){let t=Mt(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:yv,labelGridCellSize:wv,labelRenderedSizeThreshold:zu,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:Er,defaultDrawNodeHover:cv(e),allowInvalidContainer:!0}}function Wu(e){return e==="contains"||e==="anchored-at"}function bv(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)Wu(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 xv(e,t){let n=bv(e,t),r=new Map;for(let i of e){let o=i.id,a=i.id,s=0,l=new Set([o]);for(;;){let c=n.get(o);if(c===void 0||l.has(c))break;l.add(c),a=o,o=c,s++}r.set(i.id,{key:a,depth:Math.max(0,s-1)})}return r}function kv(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var _v={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},Tv=3;function Ev(e,t){let n=_v[pe[wi(t)].scheme],i=[...kv(e).entries()].sort((a,s)=>s[1]-a[1]||(a[0]<s[0]?-1:a[0]>s[0]?1:0)),o=new Map;return i.forEach(([a],s)=>o.set(a,n[s*Tv%n.length])),o}var Sv=.11,Rv=.34;function Av(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return qn(e,Mt(n).ground,Math.min(Rv,r*Sv))}var Cv=.26,Lv=.55;function Nv(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let o of t){let a=Math.min(Cv,Lv-i);if(a<=0)break;i+=a,r=qn(r,o,a)}return r}function Uu(e,t,n){let r=xv(e,t),i=new Map;for(let[u,h]of r)i.set(u,h.key);let o=Ev(i,n),a=new Set(e.map(u=>u.id)),s=new Map,l=(u,h)=>{let d=r.get(u)?.key,p=r.get(h)?.key;if(d===void 0||p===void 0||d===p)return;let g=s.get(u);g===void 0?s.set(u,new Set([p])):g.add(p)};for(let u of t)Wu(u.kind)||u.source!==u.target&&(!a.has(u.source)||!a.has(u.target)||(l(u.source,u.target),l(u.target,u.source)));let c=new Map;for(let u of e){let h=r.get(u.id);if(h===void 0)continue;let d=o.get(h.key);if(d===void 0)continue;let p=Av(d,h.depth,n),g=[...s.get(u.id)??[]].sort().map(y=>o.get(y)).filter(y=>y!==void 0);c.set(u.id,Nv(p,g,n))}return c}function Va(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 Pv=300,Dv=1;function Iv(e,t,n){let r=new Map(n??[]);if(r.size>0)for(let o of t){if(o.kind!=="contains"&&o.kind!=="anchored-at"||r.has(o.target))continue;let a=r.get(o.source);a!==void 0&&r.set(o.target,{x:a.x,y:a.y})}let i={ticks:Pv,seed:Dv,pinWarm:!0};return r.size>0&&(i.initial=r),Au({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function Mv(e,t){let n=0,r=0;for(let o of e){let a=Va(o.id);n^=a,r=r+a>>>0}for(let o of t){let a=Va(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[...[e.length,t.length,n>>>0,r].map(o=>o.toString(16)),Va(JSON.stringify(Ye)).toString(16)].join("-")}var Ku="pi-weave.graph.positions.v4";function Bu(e){return Math.round(e*10)/10}function Gv(e,t){let n={};for(let[r,i]of t)n[r]=[Bu(i.x),Bu(i.y)];return JSON.stringify({v:4,key:e,at:n})}function Ov(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 o=new Map;for(let[a,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;o.set(a,{x:l,y:c})}return o.size===0?null:o}function Fv(e,t){let n;try{n=e.getItem(Ku)}catch{return null}return Ov(n,t)}function $v(e,t,n){try{return e.setItem(Ku,Gv(t,n)),!0}catch{return!1}}function Vu(e,t,n){let r=Mv(t,n),i=Fv(e,r);if(i!==null&&t.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Iv(t,n);return $v(e,r,o),{key:r,positions:o,cached:!1}}function qu(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:vn(n.kind)}}function zv(e){return{expanded:new Set(Li(e,new Set).clusters.keys())}}function Yu(e,t){return t!==null?t:e===null?{expanded:new Set}:zv(gn(e))}function Hv(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Wv(e,t){return t===null?null:Ci(t,e)}function Xu(e,t,n){return t===null?n:Ci(t,e)}var Zu="fit",Qu="frame the whole graph",zi={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Ju(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function Uv(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 Bv="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",ju={graph:Du,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function ed(e,t,n,r,i,o=!1,a=!0){if(e===null)return o?{...ju,empty:Bv}:ju;let s=gn(e),l=Li(s,n.expanded),u=n.expanded.has("vault")?l.edges.filter(g=>g.source!=="vault"&&g.target!=="vault"):l.edges,h=Vu(r,l.nodes,u),d=a?Uu(l.nodes,u,i):void 0;return{graph:Mu(l.nodes,u,h.positions,i,d),highlight:Wv(u,t),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:Uv(e,l.nodes.length)}}function td(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:Hv(e,n),selectedId:n}}var nd="(prefers-color-scheme: light)";function Rr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(nd).matches?"light":"dark"}function rd(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(nd);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}var Kv=.06,Vv=.2,ja=.001,id=.5;function od(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:za(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];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),o.push({source:s.source,target:s.target,kind:s.kind}))}let a=Ha({nodes:n,links:o,seed:1}).alpha(Kv).alphaMin(ja);return{tick(){a.tick()},awake(){return a.alphaTarget()>ja||a.alpha()>ja},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)<id&&Math.abs(c.fy-l.y)<id;c.fx=l.x,c.fy=l.y,a.alphaTarget(u?0:Vv)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}var ad={searched:0,read:1,wrote:2},sd=new Map;function cd(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 ud(e,t,n=null){if(e===null)return sd;let r=new Map,i=new Map;for(let{event:o,at:a}of cd(e,n)){let s=t-a;if(n!==null&&s<0)continue;let l=Math.min(1,1-s/6e4);if(l>0)for(let c of o.slugs){let u=`note:${c}`,h=i.get(u)===o.turn?r.get(u):void 0,d=h===void 0||ad[o.kind]>ad[h.kind]?o.kind:h.kind;r.set(u,{kind:d,strength:Math.max(l,h?.strength??0)}),i.set(u,o.turn)}}return r.size===0?sd:r}function dd(e,t,n=null){return e===null?!1:cd(e,n).some(({at:r})=>t-r<6e4)}var jv={add:"created",append:"appended",finalize:"finalized",links:"fixed links in"};function qv(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":jv[e.action]??"wrote",notes:n,detail:null}}function ld(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 hd(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),o=i.map(([,s])=>ld(s[0].at)),a=i.map(([s,l],c)=>{let u=new Set(l.filter(d=>d.kind!=="searched").flatMap(d=>d.slugs)),h=o.filter(d=>d===o[c]).length>1;return{turn:s,time:ld(l[0].at,h),steps:l.map(d=>qv(d,n)),used:u.size}});return e.turn>a[0].turn&&a.unshift({turn:e.turn,time:"",steps:[],used:0}),a.slice(0,5)}var pd="Nothing recalled yet.";function qa(e,t){return t?"This turn":e.time===""?`Turn ${e.turn}`:e.time}function fd(e){if(e===void 0)return"";let t=e.strength>.66?3:e.strength>.33?2:1;return` weave-row-trail weave-row-trail-${e.kind} weave-row-trail-${t}`}var Ar="application/x-weave-note";function gd(e,t){return t.startsWith("note:")&&e?.model.nodes.some(n=>n.id===t&&n.kind==="note")?t:null}function Ya(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function md(e,t){return t!==null&&t===e}function vd(e,t,n){return e.map(r=>{let i=t?.model.nodes.find(a=>a.id===r),o=i?.kind??(r.startsWith("vfolder:")?"module":r.startsWith("artifact:")?"file":"note");return{id:r,label:i?.label??r.replace(/^[^:]+:/,""),icon:vn(o),selected:r===n}})}var wd={title:"Context"},Yv="—";function yd(e,t){return{cwd:e===""?Yv:e,selection:t??"nothing selected"}}var bd=6e4;function Hi(e){return e?"⌘K":"Ctrl K"}function xd(e){return`Search notes and repository (${e})`}function Wi(e){return/mac|iphone|ipad/i.test(e)}var Xv={k:{type:"openSearch"},",":{type:"openSettings"}},kd={1:"tree",2:"note",3:"graph"};function Zv(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function Qv(e){return!e.ctrl&&!e.meta&&!e.alt}var Jv={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"}};function _d(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(Zv(e)){let n=Xv[e.key.toLowerCase()];if(n!==void 0)return n;let r=kd[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection&&e.navigating?{type:"clearSelection"}:null:!Qv(e)||e.typing?null:Jv[e.key]??null}var ew=["INPUT","TEXTAREA","SELECT"];function Xa(e,t){return t?!0:e!==null&&ew.includes(e.toUpperCase())}var tw=".weave-sidebar-notes, .weave-graph-host";function Td(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:Xa(e.target?.tagName??null,e.target?.isContentEditable===!0),navigating:(e.target?.closest?.(tw)??null)!==null}}var Yn={tree:".weave-sidebar-notes .weave-rows",note:".weave-pane-active .weave-note-body",graph:".weave-graph-host .weave-graph-canvas"},Za=".weave-sidebar-notes .weave-filter";function nw(e){let t=e;return typeof t?.focus=="function"?t:null}function Ui(e,t){let n=nw(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function Ed(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(Yn[e.column]);case"filterTree":return void t.focusSelector(Za);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"closeTab":return t.closeTab();case"toggleTheme":return t.toggleTheme()}}function Bi(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(kd).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:"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:"Esc",what:"Close the palette"}]}]}var Qa="Keyboard shortcuts",Sd="esc close";var Rd={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}};var rw=0;function f(e,t,n,r,i,o){t||(t={});var a,s,l=t;if("ref"in l)for(s in l={},t)s=="ref"?a=t[s]:l[s]=t[s];var c={type:e,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rw,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return ie.vnode&&ie.vnode(c),c}function Gt({name:e,class:t}){let n=Rd[e];return f("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=>f("path",{d:r}))})}function ow({view:e,recentIds:t,trail:n,edit:r,onEdit:i,onRename:o,onSelect:a,onToggle:s,onMenu:l,onDrop:c}){let u=Sa(e.id);return f("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":""}${fd(n)}`,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:zc(e.depth),onClick:h=>a(h.metaKey||h.ctrlKey),draggable:e.id.startsWith("note:"),"aria-label":e.id===Kn?"New folder":void 0,onDragStart:h=>{h.dataTransfer?.setData("text/plain",e.id),h.dataTransfer?.setData(Ar,e.id),h.dataTransfer&&(h.dataTransfer.effectAllowed="copyMove")},onDragOver:u===void 0?void 0:h=>h.preventDefault(),onDrop:u===void 0?void 0:h=>{h.preventDefault(),c(h.dataTransfer?.getData("text/plain")??"")},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),l(h.clientX,h.clientY)},children:[f("span",{class:"weave-twisty","aria-hidden":"true",onClick:h=>{h.stopPropagation(),s()},children:e.hasKids?f(Gt,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),f("span",{class:"weave-kind","aria-hidden":"true",children:f(Gt,{name:e.kindIcon,class:"weave-icon"})}),f("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),r===null?f("span",{class:"weave-label",children:e.label}):f(aw,{value:r,draft:e.id===Kn,onEdit:i,onCommit:o}),f("span",{class:"weave-meta",children:e.meta})]})}function aw({value:e,draft:t,onEdit:n,onCommit:r}){let i=Y(null);return De(()=>{let o=i.current;o!==null&&(o.focus(),o.select())},[]),f("input",{ref:i,class:"weave-tree-rename",value:e,placeholder:t?"New folder name…":void 0,onClick:o=>o.stopPropagation(),onInput:o=>n(o.currentTarget.value),onBlur:o=>r(o.currentTarget.value),onKeyDown:o=>{o.stopPropagation(),o.key==="Enter"?o.currentTarget.blur():o.key==="Escape"&&r(null)}})}function Ad(e){let[t,n]=V(Sc),[r,i]=V(null),o=Y(null);De(()=>{r!==null&&o.current?.querySelector(".weave-menu button")?.focus()},[r?.id]);let a=()=>{i(null),o.current?.querySelector(".weave-tree-actions")?.focus()},[s,l]=V(null),[c,u]=V(null),h=Lc(Rc(e.graph,t),c),d=qc(e.graph,h,t),p=async(v,b)=>{let x=await v;if(!x.ok)window.alert(x.message);else{let T=x.data.id??b;T!==void 0&&e.onSelect(T),e.onRefresh()}},g=async v=>{if(r===null)return;let b=mn(r.id);if(i(null),b!==null){if(v==="newFolder"){let x=Ac(b);n(T=>Ta(T,x)),u(x),l({id:Kn,label:"",value:""})}else if(v==="rename")n(x=>Ta(x,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(Pi(e.graph,b)))return;await p(b.type==="note"?mc(we,b.path):yc(we,b.path),Nc(e.selectedId,b)?"vault":void 0)}}},y=v=>{if(r!==null){if(Ra(v)&&r.armed!==!0){i({...r,armed:!0});return}g("delete")}},w=v=>{let b=s,x=c;if(l(null),u(null),b===null)return;let T=v?.trim();if(b.id===Kn){let O=x===null||!T?null:Cc(x,T);O!==null&&p(vc(we,O));return}let A=mn(b.id);if(A!==null&&T&&T!==b.label){if(!e.onMutate(Pi(e.graph,A)))return;p(A.type==="note"?fc(we,A.path,T):wc(we,A.path,T))}};return f("div",{class:"weave-tree",ref:o,onKeyDown:v=>{if(r!==null&&v.key==="Escape"){v.preventDefault(),v.stopPropagation(),a();return}let b=v.target,x=Gc(h,t,e.selectedId,v.key,Xa(b?.tagName??null,b?.isContentEditable===!0));x.handled&&(v.preventDefault(),n(x.state),x.selectedId!==null&&e.onSelect(x.selectedId,!1,!0))},children:[f("div",{class:"weave-tree-controls",children:[f("input",{type:"search",class:"weave-filter",value:t.query,placeholder:Bc,"aria-label":Vc,title:jc,onInput:v=>n(Dc(t,v.currentTarget.value))}),f("button",{type:"button",class:"weave-chip",title:Hc(t.provFilter),onClick:()=>n(Ic(t)),children:["◧ ",Ni(t.provFilter)]}),f("button",{type:"button",class:"weave-chip",title:Uc(t.showInternals),onClick:()=>n(Mc(t)),children:["◧ ",Wc(t.showInternals)]}),f("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:v=>{let b=e.selectedId!==null&&mn(e.selectedId)!==null?e.selectedId:"vault",x=v.currentTarget.getBoundingClientRect();i({id:b,label:e.graph?.model.nodes.find(T=>T.id===b)?.label??"Vault",x:x.left,y:x.bottom})},children:"···"})]}),d===null?f("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Kc,"aria-activedescendant":$c(h,e.selectedId)??void 0,onContextMenu:v=>{v.preventDefault(),i({id:"vault",label:"Vault",x:v.clientX,y:v.clientY})},children:Fc(h,e.selectedId,e.now).map(v=>f(ow,{view:v,recentIds:e.recentIds,trail:e.trail?.get(v.id),edit:s?.id===v.id?s.value:null,onEdit:b=>l(x=>x===null?null:{...x,value:b}),onRename:w,onSelect:b=>{e.onSelect(v.id,b),v.hasKids&&n(x=>Ea(x,v.id))},onToggle:()=>n(Ea(t,v.id)),onMenu:(b,x)=>i({id:v.id,label:v.label,x:b,y:x}),onDrop:b=>{let x=Sa(v.id);if(b.startsWith("note:")&&x!==void 0){let T=mn(b);if(T!==null&&!e.onMutate(Pi(e.graph,T)))return;p(gc(we,b.slice(5),x))}}},v.id))}):f("p",{class:"weave-tree-empty",children:d}),f("p",{class:"weave-tree-count",children:Yc(h)}),r!==null&&mn(r.id)!==null?(()=>{let v=mn(r.id);return f(me,{children:[f("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:a}),f("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},onKeyDown:b=>{if(b.key==="Escape")b.preventDefault(),a();else if(["ArrowDown","ArrowUp","Home","End"].includes(b.key)){b.preventDefault();let x=[...b.currentTarget.querySelectorAll("button")],T=x.indexOf(document.activeElement),A=b.key==="Home"?0:b.key==="End"?x.length-1:(T+(b.key==="ArrowDown"?1:-1)+x.length)%x.length;x[A]?.focus()}b.stopPropagation()},children:[f("button",{type:"button",role:"menuitem",onClick:()=>{g("newFolder")},children:"New folder…"}),v.type!=="vault"?f(me,{children:[f("button",{type:"button",role:"menuitem",onClick:()=>{g("rename")},children:"Rename…"}),f("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>y(v),children:Pc(v,r.label,r.armed===!0)})]}):null]})]})})():null]})}var Cd=new Map;function Ld(e){let t=Y(null),n=Y(null),r=Y(null),i=Y(null),o=Y(!1),a=Bl(()=>{if(i.current!==null)return;let v=()=>{i.current=null;let b=r.current;if(b!==null){if(b.tick(),!b.awake()){o.current||(o.current=!0,n.current?.fit());return}n.current?.setPositions(b.positions()),i.current=requestAnimationFrame(v)}};i.current=requestAnimationFrame(v)},[]),[s,l]=V(null),c=nt(()=>(Qo(e.forces),JSON.stringify(e.forces)),[e.forces]),u=e.groupColors,h=e.scheme??Rr(e.host),d=Yu(e.graph,s),p=nt(()=>ed(e.graph,e.selectedId,d,e.storage,h,e.bootFailed,u),[e.graph,e.selectedId,d,e.storage,h,e.bootFailed,c,u]),g=qu(e.graph,e.previewId),y=Y(Cd);y.current=e.trail??Cd;let w=Y({view:d,model:p,onSelect:e.onSelect,selectedId:e.selectedId});return w.current={view:d,model:p,onSelect:e.onSelect,selectedId:e.selectedId},ee(()=>{let v=e.renderer(h);return v.onSelect(b=>{let x=td(w.current.view,w.current.model.clusters,b);l(x.state),w.current.onSelect(x.selectedId)}),v.onHover(b=>{let{model:x,selectedId:T}=w.current;v.setHighlight(Xu(x.graph.edges,b,x.highlight),b??T)}),v.onDragStart(b=>{let x=n.current?.positions().get(b);x&&(r.current?.pin(b,x),a())}),v.onDragMove((b,x)=>{r.current?.pin(b,x)}),v.onDragEnd(b=>{r.current?.release(b)}),v.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=v,v.setGraph(w.current.model.graph),v.setHighlight(w.current.model.highlight,w.current.selectedId),v.setTrail(y.current),e.fit.current=()=>v.fit(),()=>{v.destroy(),n.current=null,e.fit.current=null}},[e.renderer,h]),ee(()=>{n.current?.setGraph(p.graph)},[p.key,c,u]),ee(()=>{let v=od(p.graph,n.current?.positions());return r.current=v,v!==null&&a(),()=>{r.current=null}},[p.key,a,c]),ee(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),ee(()=>{n.current?.setHighlight(p.highlight,e.selectedId)},[p.highlight,e.selectedId]),ee(()=>{n.current?.setTrail(y.current)},[e.trail]),f("div",{class:"weave-graph",children:[p.empty===null?null:f("p",{class:"weave-graph-empty",children:p.empty}),f("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),g===null?null:f("aside",{class:"weave-graph-preview","aria-label":"Selected graph node",children:[f("div",{class:"weave-graph-preview-info",children:[f("span",{class:"weave-kind","aria-hidden":"true",children:f(Gt,{name:g.icon,class:"weave-icon"})}),f("div",{class:"weave-graph-preview-copy",children:[f("span",{class:"weave-graph-preview-kind",children:g.kind}),f("strong",{class:"weave-graph-preview-title",title:g.title,children:g.title})]})]}),f("button",{type:"button",class:"weave-graph-preview-close","aria-label":"Clear graph selection",onClick:()=>e.onSelect(null),children:"×"}),f("button",{type:"button",class:"weave-chip",onClick:()=>e.onOpen(g.id),children:"Open in new tab"})]}),f("div",{class:"weave-graph-controls",children:[f("button",{type:"button",class:"weave-chip",title:Qu,onClick:()=>n.current?.fit(),children:Zu}),f("span",{class:"weave-graph-legend",children:[f("span",{class:"weave-legend-on",children:["◉ ",zi.selected]}),f("span",{class:"weave-legend-near",children:["● ",zi.neighborhood]}),f("span",{class:"weave-legend-dim",children:["· ",zi.dimmed]})]})]}),f("p",{class:"weave-graph-count",children:Ju(p.visible,p.total)})]})}function sw(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 kn(e){var t=sw(e,"string");return typeof t=="symbol"?t:t+""}function Ce(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Nd(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,kn(r.key),r)}}function Le(e,t,n){return t&&Nd(e.prototype,t),n&&Nd(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function xn(e){return xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},xn(e)}function Pd(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Pd=function(){return!!e})()}function lw(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cw(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 lw(e)}function Be(e,t,n){return t=xn(t),cw(e,Pd()?Reflect.construct(t,n||[],xn(e).constructor):t.apply(e,n))}function Ja(e,t){return Ja=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Ja(e,t)}function Ke(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&&Ja(e,t)}function uw(e){if(Array.isArray(e))return e}function dw(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function Vi(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 rs(e,t){if(e){if(typeof e=="string")return Vi(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)?Vi(e,t):void 0}}function hw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`)
|
|
32
|
-
|
|
26
|
+
`,n+1),i=e.slice(n+1,r===-1?e.length:r);Dv.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 Uo(e,t){return t.trim()===""?"":`${e}
|
|
27
|
+
|
|
28
|
+
${t.replace(/^\s*\n/,"").trimEnd()}`}var Iv=["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 Bo(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 Iv){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 Mv=["contains","anchored-at"];function Gv(e){return Mv.includes(e)}function Xi(e,t){let n=new Map;for(let h of e.nodes)n.set(h.id,h);let r=Ov(e,n),i=iu(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,Fv(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(y=>l.get(y)===h),provenance:$v(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:zv(e.edges,a,l),clusters:c,hidden:u,representative:l,roots:i}}function Ov(e,t){let n=new Map;for(let r of e.edges){if(!Gv(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 Fv(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 $v(e,t){let n={human:0,agent:0,generated:0,none:0};for(let r of e){let i=t.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function zv(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 Ko(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 su(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function qo(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 lu(e,t){return e===null?[]:$o(Ln(e),t)}var ir="vfolder:\0draft";function cu(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function uu(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function du(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 Yo(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Hv(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return 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.delete(t),{...e,expanded:n}}function Zo(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 hu(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 Xo(e){return e.type==="folder"}function pu(e,t,n){return Xo(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function fu(e,t){return e.query===t?e:{...e,query:t}}function gu(e){let t=rr.indexOf(e.provFilter),n=rr[(t+1)%rr.length]??null;return{...e,provFilter:n}}function mu(e){return{...e,showInternals:!e.showInternals}}function ea(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function jo(e,t){return e[t]?.id??null}function Vo(e,t,n){if(e.length===0)return null;let r=ea(e,t),i=r===-1?n>0?-1:e.length:r;return jo(e,Math.min(e.length-1,Math.max(0,i+n)))}function Uv(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 Bv={j:"ArrowDown",k:"ArrowUp"};function Kv(e){return Bv[e]??e}function vu(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=Kv(r);if(s==="ArrowDown")return o(Vo(e,n,1));if(s==="ArrowUp")return o(Vo(e,n,-1));if(s==="Home")return o(jo(e,0));if(s==="End")return o(jo(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(Vo(e,n,1)):{state:Hv(t,n),selectedId:n,handled:!0}:a;if(c.hasKids&&c.expanded)return{state:Wv(t,n),selectedId:n,handled:!0};let u=Uv(e,n);return u===null?a:o(u)}var Vv={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Pn(e){return Vv[e]}var jv={human:"●",agent:"◐",generated:"○"};function Ut(e){return e===null?"":jv[e]}function cn(e){return e===null?"":`${e}-authored`}function wu(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function qv(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 Yv(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:wu(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:Ho(e.meta,n),level:e.depth+1}}function yu(e,t,n){let r=qv(e);return e.map((i,a)=>Yv(i,t,n,r[a]))}function bu(e,t){return ea(e,t)===-1?null:wu(t)}function xu(e){return{"--weave-depth":String(Math.max(0,e))}}function Qi(e){return e===null?"all":e}function ku(e){let t=rr.indexOf(e),n=rr[(t+1)%rr.length]??null;return`provenance filter: ${Qi(e)} — click for ${Qi(n)}`}function _u(e){return e?"internals":"knowledge"}function Tu(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 Su="filter…",Eu="Vault and repository",Ru="Filter the tree",Au="Filter the tree (/)";function Cu(e,t,n){if(e===null)return"loading…";let r=zo(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 Lu(e){return e.length===1?"1 row":`${e.length} rows`}function Nu(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Pu(this.cover(t,n),t,n,e)}function Pu(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,y,v,w,b;if(!a)return e._root=o,e;for(;a.length;)if((y=t>=(d=(s+c)/2))?s=d:c=d,(v=n>=(h=(l+u)/2))?l=h:u=h,i=a,!(a=a[w=v<<1|y]))return i[w]=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[w]=o:e._root=o,e;do i=i?i[w]=new Array(4):e._root=new Array(4),(y=t>=(d=(s+c)/2))?s=d:c=d,(v=n>=(h=(l+u)/2))?l=h:u=h;while((w=v<<1|y)===(b=(g>=h)<<1|f>=d));return i[b]=a,i[w]=o,e}function Du(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)Pu(this,o[n],s[n],e[n]);return this}function Iu(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 Mu(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Gu(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 ze(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Ou(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,y;for(f&&h.push(new ze(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,w=(s+c)/2;h.push(new ze(f[3],v,w,l,c),new ze(f[2],o,w,v,c),new ze(f[1],v,s,l,w),new ze(f[0],o,s,v,w)),(y=(t>=w)<<1|e>=v)&&(g=h[h.length-1],h[h.length-1]=h[h.length-1-y],h[h.length-1-y]=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 S=Math.sqrt(n=x);i=e-S,a=t-S,u=e+S,d=t+S,r=f.data}}return r}function Fu(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,y,v,w;if(!n)return this;if(n.length)for(;;){if((g=u>=(h=(o+l)/2))?o=h:l=h,(y=d>=(f=(s+c)/2))?s=f:c=f,t=n,!(n=n[v=y<<1|g]))return this;if(!n.length)break;(t[v+1&3]||t[v+2&3]||t[v+3&3])&&(r=t,w=v)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(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[w]=n:this._root=n),this):(this._root=a,this)}function $u(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function zu(){return this._root}function Hu(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Wu(e){var t=[],n,r=this._root,i,a,o,s,l;for(r&&t.push(new ze(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 ze(i,c,u,s,l)),(i=r[2])&&t.push(new ze(i,a,u,c,l)),(i=r[1])&&t.push(new ze(i,c,o,s,u)),(i=r[0])&&t.push(new ze(i,a,o,c,u))}return this}function Uu(e){var t=[],n=[],r;for(this._root&&t.push(new ze(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 ze(a,o,s,u,d)),(a=i[1])&&t.push(new ze(a,u,s,l,d)),(a=i[2])&&t.push(new ze(a,o,d,u,c)),(a=i[3])&&t.push(new ze(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 Bu(e){return e[0]}function Ku(e){return arguments.length?(this._x=e,this):this._x}function Vu(e){return e[1]}function ju(e){return arguments.length?(this._y=e,this):this._y}function Dn(e,t,n){var r=new Qo(t??Bu,n??Vu,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function Qo(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 qu(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ze=Dn.prototype=Qo.prototype;Ze.copy=function(){var e=new Qo(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=qu(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]=qu(r));return e};Ze.add=Nu;Ze.addAll=Du;Ze.cover=Iu;Ze.data=Mu;Ze.extent=Gu;Ze.find=Ou;Ze.remove=Fu;Ze.removeAll=$u;Ze.root=zu;Ze.size=Hu;Ze.visit=Wu;Ze.visitAfter=Uu;Ze.x=Ku;Ze.y=ju;function Ce(e){return function(){return e}}function Et(e){return(e()-.5)*1e-6}function Zv(e){return e.x+e.vx}function Xv(e){return e.y+e.vy}function Jo(e){var t,n,r,i=1,a=1;typeof e!="function"&&(e=Ce(e==null?1:+e));function o(){for(var c,u=t.length,d,h,f,g,y,v,w=0;w<a;++w)for(d=Dn(t,Zv,Xv).visitAfter(s),c=0;c<u;++c)h=t[c],y=n[h.index],v=y*y,f=h.x+h.vx,g=h.y+h.vy,d.visit(b);function b(_,x,S,O,z){var L=_.data,G=_.r,I=y+G;if(L){if(L.index>h.index){var M=f-L.x-L.vx,q=g-L.y-L.vy,Y=M*M+q*q;Y<I*I&&(M===0&&(M=Et(r),Y+=M*M),q===0&&(q=Et(r),Y+=q*q),Y=(I-(Y=Math.sqrt(Y)))/Y*i,h.vx+=(M*=Y)*(I=(G*=G)/(v+G)),h.vy+=(q*=Y)*I,L.vx-=M*(I=1-I),L.vy-=q*I)}return}return x>f+I||O<f-I||S>g+I||z<g-I}}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:Ce(+c),l(),o):e},o}function Qv(e){return e.index}function Yu(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function es(e){var t=Qv,n=d,r,i=Ce(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 w=0,b=e.length;w<u;++w)for(var _=0,x,S,O,z,L,G,I;_<b;++_)x=e[_],S=x.source,O=x.target,z=O.x+O.vx-S.x-S.vx||Et(c),L=O.y+O.vy-S.y-S.vy||Et(c),G=Math.sqrt(z*z+L*L),G=(G-a[_])/G*v*r[_],z*=G,L*=G,O.vx-=z*(I=l[_]),O.vy-=L*I,S.vx+=z*(I=1-I),S.vy+=L*I}function f(){if(o){var v,w=o.length,b=e.length,_=new Map(o.map((S,O)=>[t(S,O,o),S])),x;for(v=0,s=new Array(w);v<b;++v)x=e[v],x.index=v,typeof x.source!="object"&&(x.source=Yu(_,x.source)),typeof x.target!="object"&&(x.target=Yu(_,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),y()}}function g(){if(o)for(var v=0,w=e.length;v<w;++v)r[v]=+n(e[v],v,e)}function y(){if(o)for(var v=0,w=e.length;v<w;++v)a[v]=+i(e[v],v,e)}return h.initialize=function(v,w){o=v,c=w,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:Ce(+v),g(),h):n},h.distance=function(v){return arguments.length?(i=typeof v=="function"?v:Ce(+v),y(),h):i},h}var Jv={value:()=>{}};function Xu(){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 ew(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=Xu.prototype={constructor:ta,on:function(e,t){var n=this._,r=ew(e+"",n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=tw(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]=Zu(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Zu(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 tw(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Zu(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Jv,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ts=Xu;var ar=0,zr=0,$r=0,Ju=1e3,na,Hr,ra=0,In=0,ia=0,Wr=typeof performance=="object"&&performance.now?performance:Date,ed=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function is(){return In||(ed(nw),In=Wr.now()+ia)}function nw(){In=0}function ns(){this._call=this._time=this._next=null}ns.prototype=aa.prototype={constructor:ns,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?is():+n)+(t==null?0:+t),!this._next&&Hr!==this&&(Hr?Hr._next=this:na=this,Hr=this),this._call=e,this._time=n,rs()},stop:function(){this._call&&(this._call=null,this._time=1/0,rs())}};function aa(e,t,n){var r=new ns;return r.restart(e,t,n),r}function td(){is(),++ar;for(var e=na,t;e;)(t=In-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ar}function Qu(){In=(ra=Wr.now())+ia,ar=zr=0;try{td()}finally{ar=0,iw(),In=0}}function rw(){var e=Wr.now(),t=e-ra;t>Ju&&(ia-=t,ra=e)}function iw(){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);Hr=e,rs(r)}function rs(e){if(!ar){zr&&(zr=clearTimeout(zr));var t=e-In;t>24?(e<1/0&&(zr=setTimeout(Qu,e-Wr.now()-ia)),$r&&($r=clearInterval($r))):($r||(ra=Wr.now(),$r=setInterval(rw,Ju)),ar=1,ed(Qu))}}function nd(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function rd(e){return e.x}function id(e){return e.y}var aw=10,ow=Math.PI*(3-Math.sqrt(5));function as(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=ts("tick","end"),u=nd();e==null&&(e=[]);function d(){h(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function h(y){var v,w=e.length,b;y===void 0&&(y=1);for(var _=0;_<y;++_)for(n+=(a-n)*i,s.forEach(function(x){x(n)}),v=0;v<w;++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 y=0,v=e.length,w;y<v;++y){if(w=e[y],w.index=y,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var b=aw*Math.sqrt(.5+y),_=y*ow;w.x=b*Math.cos(_),w.y=b*Math.sin(_)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function g(y){return y.initialize&&y.initialize(e,u),y}return f(),t={tick:h,restart:function(){return l.restart(d),t},stop:function(){return l.stop(),t},nodes:function(y){return arguments.length?(e=y,f(),s.forEach(g),t):e},alpha:function(y){return arguments.length?(n=+y,t):n},alphaMin:function(y){return arguments.length?(r=+y,t):r},alphaDecay:function(y){return arguments.length?(i=+y,t):+i},alphaTarget:function(y){return arguments.length?(a=+y,t):a},velocityDecay:function(y){return arguments.length?(o=1-y,t):1-o},randomSource:function(y){return arguments.length?(u=y,s.forEach(g),t):u},force:function(y,v){return arguments.length>1?(v==null?s.delete(y):s.set(y,g(v)),t):s.get(y)},find:function(y,v,w){var b=0,_=e.length,x,S,O,z,L;for(w==null?w=1/0:w*=w,b=0;b<_;++b)z=e[b],x=y-z.x,S=v-z.y,O=x*x+S*S,O<w&&(L=z,w=O);return L},on:function(y,v){return arguments.length>1?(c.on(y,v),t):c.on(y)}}}function os(){var e,t,n,r,i=Ce(-30),a,o=1,s=1/0,l=.81;function c(f){var g,y=e.length,v=Dn(e,rd,id).visitAfter(d);for(r=f,g=0;g<y;++g)t=e[g],v.visit(h)}function u(){if(e){var f,g=e.length,y;for(a=new Array(g),f=0;f<g;++f)y=e[f],a[y.index]=+i(y,f,e)}}function d(f){var g=0,y,v,w=0,b,_,x;if(f.length){for(b=_=x=0;x<4;++x)(y=f[x])&&(v=Math.abs(y.value))&&(g+=y.value,w+=v,b+=v*y.x,_+=v*y.y);f.x=b/w,f.y=_/w}else{y=f,y.x=y.data.x,y.y=y.data.y;do g+=a[y.data.index];while(y=y.next)}f.value=g}function h(f,g,y,v){if(!f.value)return!0;var w=f.x-t.x,b=f.y-t.y,_=v-g,x=w*w+b*b;if(_*_/l<x)return x<s&&(w===0&&(w=Et(n),x+=w*w),b===0&&(b=Et(n),x+=b*b),x<o&&(x=Math.sqrt(o*x)),t.vx+=w*f.value*r/x,t.vy+=b*f.value*r/x),!0;if(f.length||x>=s)return;(f.data!==t||f.next)&&(w===0&&(w=Et(n),x+=w*w),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+=w*_,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:Ce(+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 ss(e){var t=Ce(.1),n,r,i;typeof e!="function"&&(e=Ce(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:Ce(+s),o(),a):t},a.x=function(s){return arguments.length?(e=typeof s=="function"?s:Ce(+s),o(),a):e},a}function ls(e){var t=Ce(.1),n,r,i;typeof e!="function"&&(e=Ce(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:Ce(+s),o(),a):t},a.y=function(s){return arguments.length?(e=typeof s=="function"?s:Ce(+s),o(),a):e},a}var sw=9,oa=6,Ur=18,lw=32,sd=9,Br=sw+sd;function cs(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+lw));return oa+(Ur-oa)*n}function us(e){return e+sd}var cw=300,ld=1,ad=.001;function od(e){return e==="contains"||e==="anchored-at"}function uw(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function dw(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 ds(e){let t=es(e.links).id(n=>n.id).distance(n=>od(n.kind)?it.containsRest:it.relationDistance).strength(n=>od(n.kind)?it.containsStrength:it.relationStrength).iterations(2);return as(e.nodes).randomSource(uw(e.seed??ld)).force("charge",os().strength(it.charge).distanceMax(it.chargeMax)).force("link",t).force("collide",Jo(n=>n.r??Br).strength(1)).force("x",ss(0).strength(it.center)).force("y",ls(0).strength(it.center)).stop()}function hw(e,t,n){let r=ds({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(ad).alphaDecay(n.ticks>0?1-Math.pow(ad,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function cd(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??cw)),{ids:r,edges:i}=dw(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=us(cs(o.get(l.id)??0));a.length>1&&hw(a,i,{ticks:n,seed:t.seed??ld,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 pw=Object.fromEntries(Object.entries(me).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=pw[Hi(e)];return typeof e=="string"?t:{...t,accent:Nc(e.theme,e.accent)}}var fw={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},gw={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function mw(e,t){return Ot(t)[fw[e]]}function ud(e,t){return Ot(t)[gw[e]]}function vw(e,t){return ww(e)?Kr(ud(e,t),t,yw):ud(e,t)}function ww(e){return e==="contains"||e==="anchored-at"}var ps=.85,yw=.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=ps){return Mn(e,Ot(t).ground,n)}var bw={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},hs=1.6,dd=32,xw=dd/2;function kw(e,t=dd){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>=xw?i:n;return`${e.slice(0,a).trimEnd()}…`}function _w(e){let t=Ut(e.provenance),n=pt(e);return kw(t===""?n:`${t} ${n}`)}var Tw=6,Sw=6;function Ew(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=Sw,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+Tw),t.restore()}}function hd(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(Ur,(Br*4-Math.max(r-t,i-n))/2);return{x:[t-o,r+o],y:[n-o,i+o]}}var pd={nodes:[],edges:[]};function fd(e){return`${e.source}\0${e.target}\0${e.kind}`}function Rw(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=fd(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 gd(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=Rw(t,o),l=[];for(let[d,h]of a){let f=n.get(d),g=cs(s.get(d)??0);l.push({id:d,x:f.x,y:f.y,size:g,label:_w(h),color:i?.get(d)??mw(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=fd(d);u.has(h)||(u.add(h),c.push({key:h,source:d.source,target:d.target,size:bw[d.kind],color:vw(d.kind,r),kind:d.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function md(e,t,n=1,r="neighbourhood"){return(i,a,o)=>e===null||n<=0?{}:r==="spotlight"?Dw(e,t??null,n,i,a,o):i===t&&e.has(i)?{zIndex:a.zIndex+Vr*2,size:a.size*Bt(Gw,n)}:e.has(i)?{zIndex:a.zIndex+Vr,size:a.size*Bt(Ow,n)}:{color:Kr(a.color,o,ps*n),label:n>=yd?null:a.label,zIndex:0}}var vd=.92,Aw=1.4,Cw=1.7,Lw=.75,Nw=40,Pw="warning";function Dw(e,t,n,r,i,a){let o=n>=yd;return r===t?{zIndex:i.zIndex+Vr*2,size:i.size*Bt(Cw,n),forceLabel:o}:e.has(r)?{zIndex:i.zIndex+Vr,size:i.size*Bt(Aw,n),forceLabel:o&&e.size<=Nw}:{color:Kr(i.color,a,vd*n),label:o?null:i.label,size:i.size*Bt(Lw,n),zIndex:0}}var Iw=60,Mw=.004;function wd(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/Iw);return Math.abs(t-i)<Mw?t:i}function Bt(e,t){return 1+(e-1)*t}var yd=.5,Gw=1.45,Ow=1.15,Vr=Ur+1;function bd(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,vd*n)}:{zIndex:2,size:a.size*Bt(hs*1.35,n),color:Mn(a.color,Ot(o)[Pw],n)}:!e.has(a.source)||!e.has(a.target)?{color:Kr(a.color,o,ps*n)}:t!=null&&(a.source===t||a.target===t)?{zIndex:2,size:a.size*Bt(hs*1.35,n),color:Mn(a.color,Ot(o).accent,n)}:{zIndex:1,size:a.size*Bt(hs,n)}}var Fw={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 xd(e,t,n,r){if(e===void 0||!(e.strength>0))return{};let i=Fw[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 kd=(oa+Ur)/2,$w=30;function fs(e){return e<$w?0:kd}var zw=Br*4,Hw=1;function _d(e){let t=Ot(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Hw,labelGridCellSize:zw,labelRenderedSizeThreshold:kd,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:Br,defaultDrawNodeHover:Ew(e),allowInvalidContainer:!0}}function Td(e){return e==="contains"||e==="anchored-at"}function Ww(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)Td(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 Uw(e,t){let n=Ww(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 Bw(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var Kw={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},Vw=3;function jw(e,t){let n=Kw[me[Hi(t)].scheme],i=[...Bw(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*Vw%n.length])),a}var qw=.11,Yw=.34;function Zw(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return Mn(e,Ot(n).ground,Math.min(Yw,r*qw))}var Xw=.26,Qw=.55;function Jw(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let a of t){let o=Math.min(Xw,Qw-i);if(o<=0)break;i+=o,r=Mn(r,a,o)}return r}function Sd(e,t,n){let r=Uw(e,t),i=new Map;for(let[u,d]of r)i.set(u,d.key);let a=jw(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)Td(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=Zw(h,d.depth,n),g=[...s.get(u.id)??[]].sort().map(y=>a.get(y)).filter(y=>y!==void 0);c.set(u.id,Jw(f,g,n))}return c}function gs(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 ey=300,ty=1;function ny(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:ey,seed:ty,pinWarm:!0};return r.size>0&&(i.initial=r),cd({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function ry(e,t){let n=0,r=0;for(let a of e){let o=gs(a.id);n^=o,r=r+o>>>0}for(let a of t){let o=gs(`${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)),gs(JSON.stringify(it)).toString(16)].join("-")}var Rd="pi-weave.graph.positions.v4";function Ed(e){return Math.round(e*10)/10}function iy(e,t){let n={};for(let[r,i]of t)n[r]=[Ed(i.x),Ed(i.y)];return JSON.stringify({v:4,key:e,at:n})}function ay(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 oy(e,t){let n;try{n=e.getItem(Rd)}catch{return null}return ay(n,t)}function sy(e,t,n){try{return e.setItem(Rd,iy(t,n)),!0}catch{return!1}}function Ad(e,t,n){let r=ry(t,n),i=oy(e,r);if(i!==null&&t.every(o=>i.has(o.id)))return{key:r,positions:i,cached:!0};let a=ny(t,n);return sy(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 ly(e){return{expanded:new Set(Xi(e,new Set).clusters.keys())}}function Ld(e,t){return t!==null?t:e===null?{expanded:new Set}:ly(Ln(e))}function cy(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function uy(e,t){return t===null?null:Zi(t,e)}function dy(e,t,n){return t===null?n:Zi(t,e)}function Nd(e,t,n){return n===null?{highlight:e,selectedId:t,style:"neighbourhood"}:{highlight:n,selectedId:t,style:"spotlight"}}function Pd(e,t,n){return n.style==="spotlight"?t===null?n:{...n,selectedId:t}:{highlight:dy(e,t,n.highlight),selectedId:t??n.selectedId,style:"neighbourhood"}}var Dd="fit",Id="frame the whole graph",la={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Md(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function hy(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 py="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",Cd={graph:pd,highlight:null,key:"",cached:!1,clusters:new Map,representative:new Map,visible:0,total:0,empty:"Loading…"};function Gd(e,t,n,r,i,a=!1,o=!0){if(e===null)return a?{...Cd,empty:py}:Cd;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=Ad(r,l.nodes,u),h=o?Sd(l.nodes,u,i):void 0;return{graph:gd(l.nodes,u,d.positions,i,h),highlight:uy(u,t),key:d.key,cached:d.cached,clusters:l.clusters,representative:l.representative,visible:l.nodes.length,total:s.nodes.length,empty:hy(e,l.nodes.length)}}function Od(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:cy(e,n),selectedId:n}}function ys(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Fn=ys();function Kd(e){Fn=e}var Gn={exec:()=>null};function or(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 ee(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 fy=((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:or(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:or(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:or(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:or(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:or(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:or(e=>new RegExp(`^ {0,${e}}>`))},gy=/^(?:[ \t]*(?:\n|$))+/,my=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,vy=/^ {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+|$)/,wy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,bs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Vd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,jd=ee(Vd).replace(/bull/g,bs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),yy=ee(Vd).replace(/bull/g,bs).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(),xs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,by=/^[^\n]+/,ks=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xy=ee(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ks).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ky=ee(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,bs).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",_s=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_y=ee("^ {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",_s).replace("tag",pa).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),qd=e=>ee(xs).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(),Ty=qd(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Sy=qd(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Ey=ee(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Sy).getRegex(),Ts={blockquote:Ey,code:my,def:xy,fences:vy,heading:wy,hr:Yr,html:_y,lheading:jd,list:ky,newline:gy,paragraph:Ty,table:Gn,text:by},Fd=ee("^ *([^\\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(),Ry={...Ts,lheading:yy,table:Fd,paragraph:ee(xs).replace("hr",Yr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fd).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()},Ay={...Ts,html:ee(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",_s).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:ee(xs).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()},Cy=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ly=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Yd=/^( {2,}|\\)\n(?!\s*$)/,Ny=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kt=/[\p{P}\p{S}]/u,sr=/[\s\p{P}\p{S}]/u,Zr=/[^\s\p{P}\p{S}]/u,Py=ee(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,sr).getRegex(),Dy=/[\p{Pi}\p{Ps}"']/u,Zd=/(?!~)[\p{P}\p{S}]/u,Iy=/(?!~)[\s\p{P}\p{S}]/u,My=/(?:[^\s\p{P}\p{S}]|~)/u,Gy=ee(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",fy?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Xd=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Oy=ee(Xd,"u").replace(/punct/g,Kt).getRegex(),Fy=ee(Xd,"u").replace(/punct/g,Zd).getRegex(),$y=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,zy=ee($y,"u").replace(/openQuote/g,Dy).replace(/punct/g,Kt).getRegex(),Qd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Hy=ee(Qd,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,sr).replace(/punct/g,Kt).getRegex(),Wy=ee(Qd,"gu").replace(/notPunctSpace/g,My).replace(/punctSpace/g,Iy).replace(/punct/g,Zd).getRegex(),Uy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",By=ee(Uy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,sr).replace(/punct/g,Kt).getRegex(),Ky=ee("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,sr).replace(/punct/g,Kt).getRegex(),Vy="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",jy=ee(Vy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,sr).replace(/punct/g,Kt).getRegex(),qy=ee(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Kt).getRegex(),Yy="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Zy=ee(Yy,"gu").replace(/notPunctSpace/g,Zr).replace(/punctSpace/g,sr).replace(/punct/g,Kt).getRegex(),Xy=ee(/\\(punct)/,"gu").replace(/punct/g,Kt).getRegex(),Qy=ee(/^<(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(),Jy=ee(_s).replace("(?:-->|$)","-->").getRegex(),eb=ee("^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",Jy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ua=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,tb=ee(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ua).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Jd=ee(/^!?\[(label)\]\[(ref)\]/).replace("label",ua).replace("ref",ks).getRegex(),eh=ee(/^!?\[(ref)\](?:\[\])?/).replace("ref",ks).getRegex(),nb=ee("reflink|nolink(?!\\()","g").replace("reflink",Jd).replace("nolink",eh).getRegex(),$d=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ss={_backpedal:Gn,anyPunctuation:Xy,autolink:Qy,blockSkip:Gy,br:Yd,code:Ly,del:Gn,delLDelim:Gn,delRDelim:Gn,emStrongLDelim:Oy,emStrongRDelimAst:Hy,emStrongRDelimUnd:Ky,escape:Cy,link:tb,nolink:eh,punctuation:Py,reflink:Jd,reflinkSearch:nb,tag:eb,text:Ny,url:Gn},rb={...Ss,emStrongLDelim:zy,emStrongRDelimAst:By,emStrongRDelimUnd:jy,link:ee(/^!?\[(label)\]\((.*?)\)/).replace("label",ua).getRegex(),reflink:ee(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ua).getRegex()},ms={...Ss,emStrongRDelimAst:Wy,emStrongLDelim:Fy,delLDelim:qy,delRDelim:Zy,url:ee(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",$d).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:ee(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",$d).getRegex()},ib={...ms,br:ee(Yd).replace("{2,}","*").getRegex(),text:ee(ms.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ca={normal:Ts,gfm:Ry,pedantic:Ay},jr={normal:Ss,gfm:ms,breaks:ib,pedantic:rb},ab={"&":"&","<":"<",">":">",'"':""","'":"'"},zd=e=>ab[e];function Ft(e,t){if(t){if(je.escapeTest.test(e))return e.replace(je.escapeReplace,zd)}else if(je.escapeTestNoEncode.test(e))return e.replace(je.escapeReplaceNoEncode,zd);return e}function Hd(e){try{e=encodeURI(e).replace(je.percentDecode,"%")}catch{return null}return e}function Wd(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 Ud(e){let t=e.split(`
|
|
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 ob(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 sb(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 Bd(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 lb(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
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]:Ud(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=lb(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],`
|
|
36
|
+
`).split(`
|
|
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
|
+
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
39
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
40
|
+
${c}`:c,i=i?`${i}
|
|
41
|
+
${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,a,!0),this.lexer.state.top=d,n.length===0)break;let h=a.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let f=h,g=n.join(`
|
|
42
|
+
`),y=f.raw+`
|
|
43
|
+
`+g.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(y);a[a.length-1]=v,r=`${r}
|
|
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
|
+
`+n.join(`
|
|
46
|
+
`),y=this.list(g);a[a.length-1]=y,r=r.substring(0,r.length-h.raw.length)+y.raw,i=i.substring(0,i.length-f.raw.length)+y.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=sb(t[2].split(`
|
|
48
|
+
`,1)[0],t[1].length),h=e.split(`
|
|
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 y=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),w=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 S=e.split(`
|
|
51
|
+
`,1)[0],O;if(h=S,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),O=h):O=h.replace(this.rules.other.tabCharGlobal," "),w.test(h)||b.test(h)||_.test(h)||x.test(h)||y.test(h)||v.test(h))break;if(O.search(this.rules.other.nonSpaceChar)>=g||!h.trim())u+=`
|
|
52
|
+
`+O.slice(g);else{if(f||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(d)||b.test(d)||v.test(d))break;u+=`
|
|
53
|
+
`+h}f=!h.trim(),c+=S+`
|
|
54
|
+
`,e=e.substring(S.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=Ud(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=Wd(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(Wd(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],`
|
|
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=ob(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)),Bd(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 Bd(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 y=f.slice(1,-1);return{type:"em",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}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}}}},ot=class vs{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 vs(n).lex(t)}static lexInline(t,n){return new vs(n).inlineTokens(t)}lex(t){t=t.replace(je.carriageReturn,`
|
|
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
|
+
`: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
|
+
`)?"":`
|
|
63
|
+
`)+a.raw,s.text+=`
|
|
64
|
+
`+a.text,this.inlineQueue.at(-1).src=s.text):n.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
65
|
+
`)?"":`
|
|
66
|
+
`)+a.raw,s.text+=`
|
|
67
|
+
`+a.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),n.push(a);continue}let o=t;if(this.options.extensions?.startBlock){let s=1/0,l=t.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(o=t.substring(0,s+1))}if(this.state.top&&(a=this.tokenizer.paragraph(o))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
|
|
68
|
+
`)?"":`
|
|
69
|
+
`)+a.raw,s.text+=`
|
|
70
|
+
`+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(a),r=o.length!==t.length,t=t.substring(a.raw.length);continue}if(a=this.tokenizer.text(t)){t=t.substring(a.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
71
|
+
`)?"":`
|
|
72
|
+
`)+a.raw,s.text+=`
|
|
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>
|
|
76
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
77
|
+
${this.parser.parse(e)}</blockquote>
|
|
78
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
79
|
+
`}hr(e){return`<hr>
|
|
80
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let s=e.items[o];r+=this.listitem(s)}let i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
|
|
81
|
+
`+r+"</"+i+`>
|
|
82
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
83
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
84
|
+
`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let a=e.rows[i];n="";for(let o=0;o<a.length;o++)n+=this.tablecell(a[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
85
|
+
<thead>
|
|
86
|
+
`+t+`</thead>
|
|
87
|
+
`+r+`</table>
|
|
88
|
+
`}tablerow({text:e}){return`<tr>
|
|
89
|
+
${e}</tr>
|
|
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=Hd(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=Hd(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)}},Es=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 ws{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 Es}static parse(t,n){return new ws(n).parse(t)}static parseInline(t,n){return new ws(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?ot.lex:ot.lexInline}provideParser(e=this.block){return e?Rt.parse:Rt.parseInline}},fa=class{defaults=ys();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Rt;Renderer=ha;TextRenderer=Es;Lexer=ot;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 ot.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?ot.lex:ot.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?ot.lex:ot.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 pe(e,t){return On.parse(e,t)}pe.options=pe.setOptions=function(e){return On.setOptions(e),pe.defaults=On.defaults,Kd(pe.defaults),pe};pe.getDefaults=ys;pe.defaults=Fn;function cb(...e){return On.use(...e),pe.defaults=On.defaults,Kd(pe.defaults),pe}pe.use=cb;pe.walkTokens=function(e,t){return On.walkTokens(e,t)};pe.parseInline=On.parseInline;pe.Parser=Rt;pe.parser=Rt.parse;pe.Renderer=ha;pe.TextRenderer=Es;pe.Lexer=ot;pe.lexer=ot.lex;pe.Tokenizer=da;pe.Hooks=qr;pe.parse=pe;var t1=pe.options,n1=pe.setOptions,r1=pe.walkTokens,i1=pe.parseInline;var a1=Rt.parse,o1=ot.lex;var nh={"&":"&","<":"<",">":">",'"':""","'":"'"},ub=new RegExp(`[${Object.keys(nh).join("")}]`,"g");function ft(e){return e.replace(ub,t=>nh[t])}var db=["http:","https:","mailto:"],rh=/^[a-z][a-z0-9+.-]*:/i,ih=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function th(e){let t=e.replace(ih,""),n=rh.exec(t);return n===null?t===""?null:e:db.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:",hb={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function pb(e){if(e.kind!=="note"||!e.id.startsWith(ma))return null;let t=e.id.slice(ma.length);return t===""?null:t}function ah(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 oh(e){let t=ah(e);return t===null?null:`${t}:${e.detail.updated??""}`}function sh(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:ah(n)}function lh(e,t){if(e===null)return hb;let n=new Map;for(let i of e.model.nodes){let a=pb(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 ch(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function fb(e,t){if(e.currentSlug===null||rh.test(t.replace(ih,"")))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:ch(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function gb(e){return e.hasGhosts}var mb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function vb(e){let t=e.indexOf("[[");return t===-1?void 0:t}function wb(e){return{name:"wikilink",level:"inline",start:vb,tokenizer(t){return bb(t)},renderer(t){return yb(e,t)}}}function yb(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return xb(e,n,r)}function bb(e){let t=mb.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function xb(e,t,n){let r=ft((n===""?t:n).trim());if(r==="")return"";let i=ch(e,t);return i!==null?`<a class="weave-wiki" ${Vt}="${ft(i)}" role="link" tabindex="0" title="${ft(t.trim())}">${r}</a>`:gb(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${ft(t.trim())}">${r}</span>`:r}function kb(e){let t=0;return new fa({gfm:!0,async:!1,extensions:[wb(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=th(n),o=this.parser.parseInline(i),s=a===null?null:fb(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=th(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 _b(e,t){return kb(t).parse(e,{async:!1})}function ga(e){return Object.freeze(e)}var Tb=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 As(e,t,n){return Eb(e.sanitize(_b(t,n),Tb))}var Sb=/^(\s*<h1>[\s\S]*?<\/h1>)?\s*<p><strong>TL;?DR[ \t]*:?<\/strong>[ \t]*:?[ \t\n]*/i,Rs=/<(\/?)(?:ul|ol)\b[^>]*>/g;function Eb(e){let t=Sb.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){Rs.lastIndex=a;let l=0;for(let c=Rs.exec(e);c!==null;c=Rs.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
|
+
<div class="weave-tldr"><p><span class="weave-tldr-label">TLDR</span>${i}</p>${s}
|
|
94
|
+
</div>${e.slice(a)}`}var Rb=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function Ab(e){let t=[],n=e.replace(/\r\n?/g,`
|
|
95
|
+
`),r=0;for(let l of ot.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=Rb.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(ot.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 uh(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=Ab(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function dh(e){let t=e?.getAttribute($n);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var hh=32;function Cs(e){let t=e;for(let n=0;t!==null&&n<hh;n++){let r=t.getAttribute(Vt);if(r!==null&&r!=="")return`${ma}${r}`;t=t.parentElement}return null}function ph(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 fh="edited",gh="created",mh="Edit",vh="Done";var wh="Note body",yh="Start writing…",bh="Raw notes",xh="Raw notes text",kh="Raw";function _h(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 Cb(e){return e==="human"?"You wrote this":e==="agent"?"Agent wrote this":"Generated by pi-weave"}var Lb="Vault";function Nb(e){return[Lb,...e.split("/").slice(0,-1)].join(" / ")}function Th(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:Cb(e.source),folder:Nb(e.slug)}}function Sh(e){return`#${e}`}var Pb=200,Db=8,Ib="no note";function Ls(e){let t=e;for(let n=0;t!==null&&n<hh;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 Ns(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=Pb){let n=Ns(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function Eh(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:Ib,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 Rh(e,t,n,r,i,a,o=Db){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 Ah(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 Ch(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 Nh="Light up notes, tags or code",Ph="Light up in graph",Dh="Esc",Ms="Clear the spotlight (Esc)",Ih="agent",Mh="Your agent searched for this. Type to light up something else.",Gs={lit:"lit",dimmed:"not lit"},Mb="search match";function Gh(e){return e===0?"no matches":`${e} lit`}function Gb(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 Ob(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 Fb(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 $b(e,t,n){let r=e.label.toLowerCase(),i=Ob(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 Oh(e,t,n=[]){let r=Gb(t);if(r.length===0)return null;let i=new Set,a=new Map;if(e!==null){let o=Fb(e);for(let l of e.model.nodes){if(i.has(l.id))continue;let c=$b(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,[Mb]))}return{terms:r,lit:i,reasons:a,count:i.size}}function Fh(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 zb(e,t){let n=e?.reasons.get(t);return n===void 0||n.length===0?null:n.join(", ")}function $h(e,t,n){return e!==""&&(t||!n)}function Ps(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 Hb=6,Os="Connected";function zh(e,t){return t>e?`+${t-e} more`:null}var Hh="Graph node details",Fs="Close details",Wh="Open",Uh="Open in split",Bh="Lit because:",Wb={human:"You",agent:"Agent",generated:"Generated"},Is=new Set(["contains","anchored-at"]);function Ub(e){let t=new Map;for(let n of e)Is.has(n.kind)&&!t.has(n.target)&&n.source!==n.target&&t.set(n.target,n.source);return t}var Lh=3;function Bb(e,t){let n=Ub(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>Lh?["…",...s.slice(-Lh)]:s).join(" / ")}function Kb(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=Ns(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 Ds=200;function Vb(e,t){let n=e.detail.preview??"",r=Kb(n);if(r!==null)return{heading:"TLDR",parts:Ps(Xr(r,Ds),t)};let i=e.detail.summary??e.detail.description??"";if(i.trim()!=="")return{heading:"Summary",parts:Ps(Xr(i,Ds),t)};let a=Xr(n,Ds);return a===""?null:{heading:"Preview",parts:Ps(a,t)}}function jb(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=>Is.has(l.kind)?null:l.source===t?l.target:l.target===t?l.source:null);return(a.length>0?a:i(l=>Is.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 Kh(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=jb(e,i.id,n);return{id:i.id,title:i.title,kind:i.kind,icon:i.icon,crumb:Bb(e,i.id),who:a.provenance===null?null:{provenance:a.provenance,glyph:Ut(a.provenance),word:Wb[a.provenance],title:cn(a.provenance)},when:Wt(a.detail.updated,r),text:Vb(a,n?.terms??[]),litBecause:zb(n,i.id),connected:o.slice(0,Hb),connectedTotal:o.length}}var Vh="(prefers-color-scheme: light)";function Qr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(Vh).matches?"light":"dark"}function jh(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(Vh);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}var qb=.06,Yb=.2,$s=.001,qh=.5;function Yh(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:us(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=ds({nodes:n,links:a,seed:1}).alpha(qb).alphaMin($s);return{tick(){o.tick()},awake(){return o.alphaTarget()>$s||o.alpha()>$s},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)<qh&&Math.abs(c.fy-l.y)<qh;c.fx=l.x,c.fy=l.y,o.alphaTarget(u?0:Yb)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,o.alphaTarget(0))}}}var Jr="application/x-weave-note";function Zh(e,t){return t.startsWith("note:")&&e?.model.nodes.some(n=>n.id===t&&n.kind==="note")?t:null}function zs(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function Xh(e,t){return t!==null&&t===e}function Qh(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 Jh(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 ep={title:"Context"},Zb="—";function tp(e,t,n=""){return{cwd:e===""?Zb:e,selection:Xb(t),hint:n===""?"":`${n} search`}}function Xb(e){return e===null?"nothing selected":e.startsWith("note:")&&e.length>5?`${e.slice(5)}.md`:e}var np=6e4;function ei(e){return e?"⌘K":"Ctrl K"}function rp(e){return`Search notes and repository (${e})`}function ti(e){return/mac|iphone|ipad/i.test(e)}var Qb={k:{type:"openSearch"},",":{type:"openSettings"}},ip={1:"tree",2:"note",3:"graph"};function Jb(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function ex(e){return!e.ctrl&&!e.meta&&!e.alt}var tx={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"},"]":{type:"toggleContext"}};function ap(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(Jb(e)){let n=Qb[e.key.toLowerCase()];if(n!==void 0)return n;let r=ip[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection&&e.navigating?{type:"clearSelection"}:null:!ex(e)||e.typing?null:tx[e.key]??null}var nx=["INPUT","TEXTAREA","SELECT"];function Hs(e,t){return t?!0:e!==null&&nx.includes(e.toUpperCase())}var rx=".weave-sidebar-notes, .weave-graph-host";function op(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:Hs(e.target?.tagName??null,e.target?.isContentEditable===!0),navigating:(e.target?.closest?.(rx)??null)!==null}}var lr={tree:".weave-sidebar-notes .weave-rows",note:".weave-pane-active .weave-note-body",graph:".weave-graph-host .weave-graph-canvas"},Ws=".weave-sidebar-notes .weave-filter";function ix(e){let t=e;return typeof t?.focus=="function"?t:null}function ba(e,t){let n=ix(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function sp(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(lr[e.column]);case"filterTree":return void t.focusSelector(Ws);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(ip).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 Us="Keyboard shortcuts",lp="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 ax=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:--ax,__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 se.vnode&&se.vnode(c),c}function le({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 ox({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:a,onToggle:o,onMenu:s,onDrop:l}){let c=Zo(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:xu(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(le,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),p("span",{class:"weave-kind","aria-hidden":"true",children:p(le,{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(sx,{value:n,draft:e.id===ir,onEdit:r,onCommit:i}),p("span",{class:"weave-meta",children:e.meta})]})}function sx({value:e,draft:t,onEdit:n,onCommit:r}){let i=V(null);return $e(()=>{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 up(e){let[t,n]=K(su),[r,i]=K(null),a=V(null);$e(()=>{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=du(lu(e.graph,t),c),h=Cu(e.graph,d,t),f=async(w,b)=>{let _=await w;if(!_.ok)window.alert(_.message);else{let x=_.data.id??b;x!==void 0&&e.onSelect(x),e.onRefresh()}},g=async w=>{if(r===null)return;let b=Nn(r.id);if(i(null),b!==null){if(w==="newFolder"){let _=cu(b);n(x=>qo(x,_)),u(_),l({id:ir,label:"",value:""})}else if(w==="rename")n(_=>qo(_,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"?Xc(_e,b.path):eu(_e,b.path),hu(e.selectedId,b)?"vault":void 0)}}},y=w=>{if(r!==null){if(Xo(w)&&r.armed!==!0){i({...r,armed:!0});return}g("delete")}},v=w=>{let b=s,_=c;if(l(null),u(null),b===null)return;let x=w?.trim();if(b.id===ir){let O=_===null||!x?null:uu(_,x);O!==null&&f(Qc(_e,O));return}let S=Nn(b.id);if(S!==null&&x&&x!==b.label){if(!e.onMutate(Ji(e.graph,S)))return;f(S.type==="note"?Yc(_e,S.path,x):Jc(_e,S.path,x))}};return p("div",{class:"weave-tree",ref:a,onKeyDown:w=>{if(r!==null&&w.key==="Escape"){w.preventDefault(),w.stopPropagation(),o();return}let b=w.target,_=vu(d,t,e.selectedId,w.key,Hs(b?.tagName??null,b?.isContentEditable===!0));_.handled&&(w.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:Su,"aria-label":Ru,title:Au,onInput:w=>n(fu(t,w.currentTarget.value))}),p("button",{type:"button",class:"weave-chip",title:ku(t.provFilter),onClick:()=>n(gu(t)),children:["◧ ",Qi(t.provFilter)]}),p("button",{type:"button",class:"weave-chip",title:Tu(t.showInternals),onClick:()=>n(mu(t)),children:["◧ ",_u(t.showInternals)]}),p("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:w=>{let b=e.selectedId!==null&&Nn(e.selectedId)!==null?e.selectedId:"vault",_=w.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":Eu,"aria-activedescendant":bu(d,e.selectedId)??void 0,onContextMenu:w=>{w.preventDefault(),i({id:"vault",label:"Vault",x:w.clientX,y:w.clientY})},children:yu(d,e.selectedId,e.now).map(w=>p(ox,{view:w,recentIds:e.recentIds,edit:s?.id===w.id?s.value:null,onEdit:b=>l(_=>_===null?null:{..._,value:b}),onRename:v,onSelect:b=>{e.onSelect(w.id,b),w.hasKids&&n(_=>Yo(_,w.id))},onToggle:()=>n(Yo(t,w.id)),onMenu:(b,_)=>i({id:w.id,label:w.label,x:b,y:_}),onDrop:b=>{let _=Zo(w.id);if(b.startsWith("note:")&&_!==void 0){let x=Nn(b);if(x!==null&&!e.onMutate(Ji(e.graph,x)))return;f(Zc(_e,b.slice(5),_))}}},w.id))}):p("p",{class:"weave-tree-empty",children:h}),p("p",{class:"weave-tree-count",children:Lu(d)}),r!==null&&Nn(r.id)!==null?(()=>{let w=Nn(r.id);return p(ye,{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),S=b.key==="Home"?0:b.key==="End"?_.length-1:(x+(b.key==="ArrowDown"?1:-1)+_.length)%_.length;_[S]?.focus()}b.stopPropagation()},children:[p("button",{type:"button",role:"menuitem",onClick:()=>{g("newFolder")},children:"New folder…"}),w.type!=="vault"?p(ye,{children:[p("button",{type:"button",role:"menuitem",onClick:()=>{g("rename")},children:"Rename…"}),p("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>y(w),children:pu(w,r.label,r.armed===!0)})]}):null]})]})})():null]})}var dp=new Map;function hp(e){let t=V(null),n=V(null),r=V(null),i=V(null),a=V(!1),o=Sc(()=>{if(i.current!==null)return;let M=()=>{i.current=null;let q=r.current;if(q!==null){if(q.tick(),!q.awake()){a.current||(a.current=!0,n.current?.fit());return}n.current?.setPositions(q.positions()),i.current=requestAnimationFrame(M)}};i.current=requestAnimationFrame(M)},[]),[s,l]=K(null),c=Pe(()=>(_o(e.forces),JSON.stringify(e.forces)),[e.forces]),u=e.groupColors,d=e.scheme??Qr(e.host),h=Ld(e.graph,s),f=Pe(()=>Gd(e.graph,e.selectedId,h,e.storage,d,e.bootFailed,u),[e.graph,e.selectedId,h,e.storage,d,e.bootFailed,c,u]),g=e.onQuery!==void 0,y=g?e.query??"":"",v=Pe(()=>Oh(e.graph,y,e.found),[e.graph,y,e.found]),w=Pe(()=>Fh(v,f.representative),[v,f.representative]),b=Pe(()=>Nd(f.highlight,e.selectedId,w),[f.highlight,e.selectedId,w]),_=g?null:sa(e.graph,e.previewId),x=e.now??Date.now(),S=Pe(()=>g?Kh(e.graph,e.previewId,v,x):null,[g,e.graph,e.previewId,v,x]),O=V(null),z=V(dp);z.current=e.trail??dp;let L=V({view:h,model:f,picture:b,onSelect:e.onSelect,selectedId:e.selectedId});L.current={view:h,model:f,picture:b,onSelect:e.onSelect,selectedId:e.selectedId},te(()=>{let M=e.renderer(d);M.onSelect(Y=>{let re=Od(L.current.view,L.current.model.clusters,Y);l(re.state),L.current.onSelect(re.selectedId)}),M.onHover(Y=>{let{model:re,picture:oe}=L.current,be=Pd(re.graph.edges,Y,oe);M.setHighlight(be.highlight,be.selectedId,be.style)}),M.onDragStart(Y=>{let re=n.current?.positions().get(Y);re&&(r.current?.pin(Y,re),o())}),M.onDragMove((Y,re)=>{r.current?.pin(Y,re)}),M.onDragEnd(Y=>{r.current?.release(Y)}),M.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=M,M.setGraph(L.current.model.graph);let q=L.current.picture;return M.setHighlight(q.highlight,q.selectedId,q.style),M.setTrail(z.current),e.fit.current=()=>M.fit(),()=>{M.destroy(),n.current=null,e.fit.current=null}},[e.renderer,d]),te(()=>{n.current?.setGraph(f.graph)},[f.key,c,u]),te(()=>{let M=Yh(f.graph,n.current?.positions());return r.current=M,M!==null&&o(),()=>{r.current=null}},[f.key,o,c]),te(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),te(()=>{n.current?.setHighlight(b.highlight,b.selectedId,b.style)},[b]),te(()=>{n.current?.setTrail(z.current)},[e.trail]);let G=M=>{M.key!=="Escape"||!$h(y,M.target===O.current,S!==null)||(M.preventDefault(),e.onQuery?.(""))},I=S===null?null:zh(S.connected.length,S.connectedTotal);return p("div",{class:"weave-graph",onKeyDown:G,children:[f.empty===null?null:p("p",{class:"weave-graph-empty",children:f.empty}),p("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),g?p("div",{class:`weave-spotlight${v===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:O,class:"weave-spotlight-input",type:"search",value:y,placeholder:Nh,"aria-label":Ph,spellcheck:!1,autoComplete:"off",onInput:M=>e.onQuery?.(M.currentTarget.value)}),v===null?null:p(ye,{children:[e.byAgent===!0?p("span",{class:"weave-spotlight-by",title:Mh,children:Ih}):null,p("span",{class:`weave-spotlight-count${v.count===0?" weave-spotlight-none":""}`,role:"status",children:Gh(v.count)}),p("button",{type:"button",class:"weave-spotlight-clear",title:Ms,"aria-label":Ms,onClick:()=>{e.onQuery?.(""),O.current?.focus()},children:Dh})]})]}):null,S===null?null:p("aside",{class:"weave-sheet","aria-label":Hh,children:[p("button",{type:"button",class:"weave-sheet-close","aria-label":Fs,title:Fs,onClick:()=>e.onSelect(null),children:"×"}),p("p",{class:"weave-sheet-crumb",children:[p(le,{name:S.crumb===""?S.icon:"module",class:"weave-icon"}),p("span",{children:S.crumb===""?S.kind:S.crumb})]}),p("h2",{class:"weave-sheet-title",children:S.title}),p("p",{class:"weave-sheet-meta",children:[S.who===null?null:p("span",{class:`weave-prov weave-prov-${S.who.provenance}`,title:S.who.title,"aria-hidden":"true",children:S.who.glyph}),p("span",{children:S.who===null?S.kind:S.who.word}),S.when===""?null:p("span",{class:"weave-sheet-when",children:["· ",S.when]})]}),S.text===null?null:p("div",{class:"weave-sheet-text",children:[p("span",{class:"weave-sheet-text-head",children:S.text.heading}),S.text.parts.map(M=>M.hit?p("mark",{class:"weave-sheet-mark",children:M.text}):M.text)]}),S.litBecause===null?null:p("p",{class:"weave-sheet-why",children:[p("span",{"aria-hidden":"true",children:"✳"}),Bh," ",S.litBecause]}),S.connectedTotal===0?null:p("section",{class:"weave-sheet-section","aria-label":Os,children:[p("h3",{class:"weave-sheet-heading",children:[Os,p("span",{class:"weave-sheet-count",children:S.connectedTotal})]}),p("ul",{class:"weave-sheet-rows",children:S.connected.map(M=>p("li",{children:p("button",{type:"button",class:"weave-sheet-row",title:M.label,"aria-label":M.ariaLabel,onClick:()=>e.onSelect(M.id),children:[p("span",{class:`weave-sheet-dot${M.lit?" weave-sheet-dot-lit":""}`,"aria-hidden":"true"}),p("span",{class:"weave-sheet-row-label",children:M.label})]})},M.id))}),I===null?null:p("p",{class:"weave-sheet-more",children:I})]}),p("div",{class:"weave-sheet-actions",children:[p("button",{type:"button",class:"weave-sheet-open",onClick:()=>e.onOpen(S.id),children:Wh}),e.onOpenSplit===void 0?null:p("button",{type:"button",class:"weave-sheet-split",onClick:()=>e.onOpenSplit?.(S.id),children:Uh})]})]}),_===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(le,{name:_.icon,class:"weave-icon"})}),p("div",{class:"weave-graph-preview-copy",children:[p("span",{class:"weave-graph-preview-kind",children:_.kind}),p("strong",{class:"weave-graph-preview-title",title:_.title,children:_.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(_.id),children:"Open in new tab"})]}),p("div",{class:"weave-graph-controls",children:[p("button",{type:"button",class:"weave-chip",title:Id,onClick:()=>n.current?.fit(),children:Dd}),p("span",{class:"weave-graph-legend",children:[p("span",{class:"weave-legend-on",children:["◉ ",la.selected]}),v===null?p("span",{class:"weave-legend-near",children:["● ",la.neighborhood]}):p("span",{class:"weave-legend-lit",children:["● ",Gs.lit]}),p("span",{class:"weave-legend-dim",children:["· ",v===null?la.dimmed:Gs.dimmed]})]})]}),p("p",{class:"weave-graph-count",children:Md(f.visible,f.total)})]})}function lx(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=lx(e,"string");return typeof t=="symbol"?t:t+""}function De(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pp(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 Ie(e,t,n){return t&&pp(e.prototype,t),n&&pp(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 fp(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(fp=function(){return!!e})()}function cx(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ux(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 cx(e)}function Xe(e,t,n){return t=zn(t),ux(e,fp()?Reflect.construct(t,n||[],zn(e).constructor):t.apply(e,n))}function Bs(e,t){return Bs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Bs(e,t)}function Qe(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&&Bs(e,t)}function dx(e){if(Array.isArray(e))return e}function hx(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 qs(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 px(){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 dx(e)||hx(e,t)||qs(e,t)||px()}var Ks={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 gp=new Int8Array(4),Vs=new Int32Array(gp.buffer,0,1),fx=new Float32Array(gp.buffer,0,1),gx=/^\s*rgba?\s*\(/,mx=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function vx(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(gx.test(e)){var a=e.match(mx);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 cr={};for(ni in Ks)cr[ni]=ur(Ks[ni]),cr[Ks[ni]]=cr[ni];var ni;function mp(e,t,n,r,i){return Vs[0]=r<<24|n<<16|t<<8|e,i&&(Vs[0]=Vs[0]&4278190079),fx[0]}function ur(e){if(e=e.toLowerCase(),typeof cr[e]<"u")return cr[e];var t=vx(e),n=t.r,r=t.g,i=t.b,a=t.a;a=a*255|0;var o=mp(n,r,i,a,!0);return cr[e]=o,o}var js={};function Ys(e){if(typeof js[e]<"u")return js[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,a=mp(t,n,r,i,!0);return js[e]=a,a}function Zs(e,t,n,r){return n+(t<<8)+(e<<16)}function Xs(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 vp(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 H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vp(Object(n),!0).forEach(function(r){A(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vp(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function wx(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=zn(e))!==null;);return e}function el(){return el=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=wx(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},el.apply(null,arguments)}function Tp(e,t,n,r){var i=el(zn(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(a){return i.apply(n,a)}:i}function yx(e){return e.normalized?1:e.size}function Qs(e){var t=0;return e.forEach(function(n){return t+=yx(n)}),t}function Sp(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
|
+
`.concat(o,`
|
|
101
|
+
`).concat(n))}return i}function bx(e,t){return Sp("VERTEX",e,t)}function xx(e,t){return Sp("FRAGMENT",e,t)}function kx(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 wp(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 yp=`#define PICKING_MODE
|
|
102
|
+
`,_x=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 Ep=(function(){function e(t,n,r){De(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=Qs(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,yp+i.VERTEX_SHADER_SOURCE,yp+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var a=Qs(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 Ie(e,[{key:"kill",value:function(){wp(this.normalProgram),this.pickProgram&&(wp(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=bx(r,i),u=xx(r,a),d=kx(r,[c,u]),h={};s.UNIFORMS.forEach(function(y){var v=r.getUniformLocation(d,y);v&&(h[y]=v)});var f={};s.ATTRIBUTES.forEach(function(y){f[y.name]=r.getAttribLocation(d,y.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(y){f[y.name]=r.getAttribLocation(d,y.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=_x[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:Qs(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(H(H({},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 Tx=(function(e){function t(){return De(this,t),Xe(this,t,arguments)}return Qe(t,e),Ie(t,[{key:"kill",value:function(){Tp(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(Ys(r),o,a)}}])})(Ep);var tl=(function(e){function t(){var n;De(this,t);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n=Xe(this,t,[].concat(i)),A(n,"drawLabel",void 0),n}return Qe(t,e),Ie(t,[{key:"kill",value:function(){Tp(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(Ys(r),l,a,o,s)}}])})(Ep);function Sx(e,t){return(function(){function n(r,i,a){De(this,n),A(this,"drawLabel",t),this.programs=e.map(function(o){return new o(r,i,a)})}return Ie(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 Rp(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,y=r.y,v=(h+g)/2,w=(f+y)/2,b=g-h,_=y-f,x=Math.sqrt(b*b+_*_);if(!(x<u+d)){h+=b*u/x,f+=_*u/x,g-=b*d/x,y-=_*d/x,v=(h+g)/2,w=(f+y)/2,b=g-h,_=y-f,x=Math.sqrt(b*b+_*_);var S=e.measureText(c).width;if(S>x){var O="…";for(c=c+O,S=e.measureText(c).width;S>x&&c.length>1;)c=c.slice(0,-2)+O,S=e.measureText(c).width;if(c.length<4)return}var z;b>0?_>0?z=Math.acos(b/x):z=Math.asin(_/x):_>0?z=Math.acos(b/x)+Math.PI:z=Math.asin(b/x)+Math.PI/2,e.save(),e.translate(v,w),e.rotate(z),e.fillText(c,-S/2,t.size/2+a),e.restore()}}}function nl(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 Ap(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,nl(e,t,n)}var Ex=`
|
|
33
103
|
precision highp float;
|
|
34
104
|
|
|
35
105
|
varying vec4 v_color;
|
|
@@ -61,7 +131,7 @@ void main(void) {
|
|
|
61
131
|
gl_FragColor = mix(v_color, transparent, t);
|
|
62
132
|
#endif
|
|
63
133
|
}
|
|
64
|
-
`,
|
|
134
|
+
`,Rx=Ex,Ax=`
|
|
65
135
|
attribute vec4 a_id;
|
|
66
136
|
attribute vec4 a_color;
|
|
67
137
|
attribute vec2 a_position;
|
|
@@ -102,7 +172,7 @@ void main() {
|
|
|
102
172
|
|
|
103
173
|
v_color.a *= bias;
|
|
104
174
|
}
|
|
105
|
-
`,
|
|
175
|
+
`,Cx=Ax,Cp=WebGLRenderingContext,bp=Cp.UNSIGNED_BYTE,Js=Cp.FLOAT,Lx=["u_sizeRatio","u_correctionRatio","u_matrix"],ii=(function(e){function t(){return De(this,t),Xe(this,t,arguments)}return Qe(t,e),Ie(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Cx,FRAGMENT_SHADER_SOURCE:Rx,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Lx,ATTRIBUTES:[{name:"a_position",size:2,type:Js},{name:"a_size",size:1,type:Js},{name:"a_color",size:4,type:bp,normalized:!0},{name:"a_id",size:4,type:bp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Js}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,a){var o=this.array,s=ur(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)}}])})(Tx);A(ii,"ANGLE_1",0);A(ii,"ANGLE_2",2*Math.PI/3);A(ii,"ANGLE_3",4*Math.PI/3);var Nx=`
|
|
106
176
|
precision mediump float;
|
|
107
177
|
|
|
108
178
|
varying vec4 v_color;
|
|
@@ -110,7 +180,7 @@ varying vec4 v_color;
|
|
|
110
180
|
void main(void) {
|
|
111
181
|
gl_FragColor = v_color;
|
|
112
182
|
}
|
|
113
|
-
`,
|
|
183
|
+
`,Px=Nx,Dx=`
|
|
114
184
|
attribute vec2 a_position;
|
|
115
185
|
attribute vec2 a_normal;
|
|
116
186
|
attribute float a_radius;
|
|
@@ -176,7 +246,7 @@ void main() {
|
|
|
176
246
|
|
|
177
247
|
v_color.a *= bias;
|
|
178
248
|
}
|
|
179
|
-
`,
|
|
249
|
+
`,Ix=Dx,Lp=WebGLRenderingContext,xp=Lp.UNSIGNED_BYTE,Ta=Lp.FLOAT,Mx=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Np={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Pp(e){var t=H(H({},Np),e||{});return(function(n){function r(){return De(this,r),Xe(this,r,arguments)}return Qe(r,n),Ie(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ix,FRAGMENT_SHADER_SOURCE:Px,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Mx,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:xp,normalized:!0},{name:"a_id",size:4,type:xp,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,y=l.x,v=l.y,w=ur(c.color),b=y-f,_=v-g,x=b*b+_*_,S=0,O=0;x&&(x=1/Math.sqrt(x),S=-_*x*d,O=b*x*d);var z=this.array;z[o++]=y,z[o++]=v,z[o++]=-S,z[o++]=-O,z[o++]=h,z[o++]=w,z[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)}}])})(tl)}var tR=Pp();var Gx=`
|
|
180
250
|
precision mediump float;
|
|
181
251
|
|
|
182
252
|
varying vec4 v_color;
|
|
@@ -202,7 +272,7 @@ void main(void) {
|
|
|
202
272
|
gl_FragColor = mix(v_color, transparent, t);
|
|
203
273
|
#endif
|
|
204
274
|
}
|
|
205
|
-
`,
|
|
275
|
+
`,Dp=Gx,Ox=`
|
|
206
276
|
attribute vec4 a_id;
|
|
207
277
|
attribute vec4 a_color;
|
|
208
278
|
attribute vec2 a_normal;
|
|
@@ -270,7 +340,7 @@ void main() {
|
|
|
270
340
|
|
|
271
341
|
v_color.a *= bias;
|
|
272
342
|
}
|
|
273
|
-
`,
|
|
343
|
+
`,Fx=Ox,Ip=WebGLRenderingContext,kp=Ip.UNSIGNED_BYTE,Wn=Ip.FLOAT,$x=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],zx={lengthToThicknessRatio:Np.lengthToThicknessRatio};function Mp(e){var t=H(H({},zx),e||{});return(function(n){function r(){return De(this,r),Xe(this,r,arguments)}return Qe(r,n),Ie(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Fx,FRAGMENT_SHADER_SOURCE:Dp,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$x,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:kp,normalized:!0},{name:"a_id",size:4,type:kp,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,y=ur(c.color),v=f-d,w=g-h,b=l.size||1,_=v*v+w*w,x=0,S=0;_&&(_=1/Math.sqrt(_),x=-w*_*u,S=v*_*u);var O=this.array;O[o++]=d,O[o++]=h,O[o++]=f,O[o++]=g,O[o++]=x,O[o++]=S,O[o++]=y,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,y=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(y,a.minEdgeThickness),s.uniform1f(v,t.lengthToThicknessRatio)}}])})(tl)}var nR=Mp();function Hx(e){return Sx([Mp(e),Pp(e)])}var Wx=Hx(),Gp=Wx,Ux=`
|
|
274
344
|
attribute vec4 a_id;
|
|
275
345
|
attribute vec4 a_color;
|
|
276
346
|
attribute vec2 a_normal;
|
|
@@ -335,86 +405,23 @@ void main() {
|
|
|
335
405
|
|
|
336
406
|
v_color.a *= bias;
|
|
337
407
|
}
|
|
338
|
-
`,Uw=Ww,th=WebGLRenderingContext,Hd=th.UNSIGNED_BYTE,Lr=th.FLOAT,Bw=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],nh=(function(e){function t(){return Ce(this,t),Be(this,t,arguments)}return Ke(t,e),Le(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Uw,FRAGMENT_SHADER_SOURCE:Zd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Bw,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Lr},{name:"a_positionEnd",size:2,type:Lr},{name:"a_normal",size:2,type:Lr},{name:"a_color",size:4,type:Hd,normalized:!0},{name:"a_id",size:4,type:Hd,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Lr},{name:"a_normalCoef",size:1,type:Lr}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,c=o.x,u=o.y,h=a.x,d=a.y,p=Zn(s.color),g=h-c,y=d-u,w=g*g+y*y,v=0,b=0;w&&(w=1/Math.sqrt(w),v=-y*w*l,b=g*w*l);var x=this.array;x[i++]=c,x[i++]=u,x[i++]=h,x[i++]=d,x[i++]=v,x[i++]=b,x[i++]=p,x[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,c=a.u_feather,u=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,p=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(u,r.pixelRatio),o.uniform1f(c,r.antiAliasingFeather),o.uniform1f(p,r.minEdgeThickness)}}])})(us);var ph=pr(Xi()),Zi=(function(e){function t(){var n;return Ce(this,t),n=Be(this,t),n.rawEmitter=n,n}return Ke(t,e),Le(t)})(ph.EventEmitter);var vh=pr(ps());var Zw=function(t){return t},Qw=function(t){return t*t},Jw=function(t){return t*(2-t)},ey=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},ty=function(t){return t*t*t},ny=function(t){return--t*t*t+1},ry=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},wh={linear:Zw,quadraticIn:Qw,quadraticOut:Jw,quadraticInOut:ey,cubicIn:ty,cubicOut:ny,cubicInOut:ry},yh={easing:"quadraticInOut",duration:150};function ht(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Qi(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function gh(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 mh(e,t,n){return e[6]=t,e[7]=n,e}function Jt(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=t[0],d=t[1],p=t[2],g=t[3],y=t[4],w=t[5],v=t[6],b=t[7],x=t[8];return e[0]=h*n+d*o+p*l,e[1]=h*r+d*a+p*c,e[2]=h*i+d*s+p*u,e[3]=g*n+y*o+w*l,e[4]=g*r+y*a+w*c,e[5]=g*i+y*s+w*u,e[6]=v*n+b*o+x*l,e[7]=v*r+b*a+x*c,e[8]=v*i+b*s+x*u,e}function Ji(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],a=e[4],s=e[6],l=e[7],c=t.x,u=t.y;return{x:c*r+u*o+s*n,y:c*i+u*a+l*n}}function iy(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 Jn(e,t,n,r,i){var o=e.angle,a=e.ratio,s=e.x,l=e.y,c=t.width,u=t.height,h=ht(),d=Math.min(c,u)-2*r,p=iy(t,n);return i?(Jt(h,mh(ht(),s,l)),Jt(h,Qi(ht(),a)),Jt(h,gh(ht(),o)),Jt(h,Qi(ht(),c/d/2/p,u/d/2/p))):(Jt(h,Qi(ht(),2*(d/c)*p,2*(d/u)*p)),Jt(h,gh(ht(),-o)),Jt(h,Qi(ht(),1/a)),Jt(h,mh(ht(),-s,-l))),h}function bh(e,t,n){var r=Ji(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function xh(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,a){var s=a.x,l=a.y;s<t&&(t=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[t,n],y:[r,i]}}function kh(e){if(!(0,vh.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 _h(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function fs(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function gs(e,t,n){return n.sort(function(r,i){var o=t(r)||0,a=t(i)||0;return o<a?-1:o>a?1:0})}function ms(e){var t=Qt(e.x,2),n=t[0],r=t[1],i=Qt(e.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,c=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(c)&&(c=0);var u=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-c)/s}};return u.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-c)/s},u.inverse=function(h){return{x:l+s*(h.x-.5),y:c+s*(h.y-.5)}},u.ratio=s,u}function eo(e){"@babel/helpers - typeof";return eo=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},eo(e)}function vs(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function to(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 no={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:Kd,defaultDrawNodeLabel:ds,defaultDrawNodeHover:Vd,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:{}},oy={circle:Nr},ay={arrow:eh,line:nh};function ro(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 Th(e){var t=to({},no,e);return t.nodeProgramClasses=to({},oy,t.nodeProgramClasses),t.edgeProgramClasses=to({},ay,t.edgeProgramClasses),t}var GE=pr(Xi()),OE=pr(ps()),io=1.5,Eh=(function(e){function t(){var n;return Ce(this,t),n=Be(this,t),S(n,"x",.5),S(n,"y",.5),S(n,"angle",0),S(n,"ratio",1),S(n,"minRatio",null),S(n,"maxRatio",null),S(n,"enabledZooming",!0),S(n,"enabledPanning",!0),S(n,"enabledRotation",!0),S(n,"clean",null),S(n,"nextFrame",null),S(n,"previousState",null),S(n,"enabled",!0),n.previousState=n.getState(),n}return Ke(t,e),Le(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(H(H({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(p){return i.animate(r,o,p)});if(this.enabled){var s=H(H({},yh),o),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:wh[s.easing],u=Date.now(),h=this.getState(),d=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 y=c(g),w={};typeof l.x=="number"&&(w.x=h.x+(l.x-h.x)*y),typeof l.y=="number"&&(w.y=h.y+(l.y-h.y)*y),i.enabledRotation&&typeof l.angle=="number"&&(w.angle=h.angle+(l.angle-h.angle)*y),typeof l.ratio=="number"&&(w.ratio=h.ratio+(l.ratio-h.ratio)*y),i.setState(w),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||io)},r):this.animate({ratio:this.ratio/io})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||io)},r):this.animate({ratio:this.ratio*io})}},{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)}}])})(Zi);function wt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Ot(e,t){var n=H(H({},wt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Pr(e){var t="x"in e?e:H(H({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function sy(e,t){return H(H({},Ot(e,t)),{},{delta:Nh(e)})}var ly=2;function oo(e){for(var t=[],n=0,r=Math.min(e.length,ly);n<r;n++)t.push(e[n]);return t}function Dr(e,t,n){var r={touches:oo(e.touches).map(function(i){return wt(i,n)}),previousTouches:t.map(function(i){return wt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Nh(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 Ph=(function(e){function t(n,r){var i;return Ce(this,t),i=Be(this,t),i.container=n,i.renderer=r,i}return Ke(t,e),Le(t)})(Zi),cy=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],uy=cy.reduce(function(e,t){return H(H({},e),{},S({},t,no[t]))},{}),dy=(function(e){function t(n,r){var i;return Ce(this,t),i=Be(this,t,[n,r]),S(i,"enabled",!0),S(i,"draggedEvents",0),S(i,"downStartTime",null),S(i,"lastMouseX",null),S(i,"lastMouseY",null),S(i,"isMouseDown",!1),S(i,"isMoving",!1),S(i,"movingTimeout",null),S(i,"startCameraState",null),S(i,"clicks",0),S(i,"doubleClickTimeout",null),S(i,"currentWheelDirection",0),S(i,"settings",uy),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 Ke(t,e),Le(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",Ot(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Ot(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Ot(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(wt(r,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=wt(r,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Ot(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=wt(r,this.container),s=a.x,l=a.y,c=o.getState(),u=o.getPreviousState()||{x:0,y:0};this.isMoving?o.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)&&o.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Ot(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Ot(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=wt(r,this.container),l=s.x,c=s.y,u=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:c}),d=u.x-h.x,p=u.y-h.y,g=a.getState(),y=g.x+d,w=g.y+p;a.setState({x:y,y:w}),this.lastMouseX=l,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",Ot(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Ot(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Nh(r);if(a){var s=sy(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,c=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,u=o.getBoundedRatio(l*c),h=a>0?1:-1,d=Date.now();l!==u&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(wt(r,this.container),u),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Ph),hy=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],py=hy.reduce(function(e,t){return H(H({},e),{},S({},t,no[t]))},{}),fy=(function(e){function t(n,r){var i;return Ce(this,t),i=Be(this,t,[n,r]),S(i,"enabled",!0),S(i,"isMoving",!1),S(i,"hasMoved",!1),S(i,"touchMode",0),S(i,"startTouchesPositions",[]),S(i,"lastTouches",[]),S(i,"lastTap",null),S(i,"settings",py),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 Ke(t,e),Le(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=oo(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(p){return wt(p,i.container)}),this.touchMode===2){var a=Qt(this.startTouchesPositions,2),s=a[0],l=s.x,c=s.y,u=a[1],h=u.x,d=u.y;this.startTouchesAngle=Math.atan2(d-c,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-c,2))}this.emit("touchdown",Dr(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",Dr(r,this.lastTouches,this.container)),!r.touches.length){var s=wt(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=Dr(r,this.lastTouches,this.container);if(this.emit("doubletap",u),this.lastTap=null,!u.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var p=Dr(r,this.lastTouches,this.container);this.emit("tap",p),this.lastTap={time:Date.now(),position:p.touches[0]||p.previousTouches[0]}}}this.lastTouches=oo(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=oo(r.touches),a=o.map(function(Re){return wt(Re,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=Dr(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Re,P){var z=i.startTouchesPositions[P];return z&&(Re.x!==z.x||Re.y!==z.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,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),p=d.x,g=d.y,y=this.renderer.viewportToFramedGraph(a[0]),w=y.x,v=y.y;c.setState({x:u.x+p-w,y:u.y+g-v});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},x=a[0],T=x.x,A=x.y,O=a[1],N=O.x,G=O.y,$=Math.atan2(G-A,N-T)-this.startTouchesAngle,F=Math.hypot(G-A,N-T)/this.startTouchesDistance,X=c.getBoundedRatio(u.ratio/F);b.ratio=X,b.angle=u.angle+$;var Z=this.getDimensions(),Q=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),ne=Math.min(Z.width,Z.height)-2*h,re=ne/Z.width,ke=ne/Z.height,Ve=X/ne,He=T-ne/2/re,de=A-ne/2/ke,fe=[He*Math.cos(-b.angle)-de*Math.sin(-b.angle),de*Math.cos(-b.angle)+He*Math.sin(-b.angle)];He=fe[0],de=fe[1],b.x=Q.x-He*Ve,b.y=Q.y+de*Ve,c.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Ph);function gy(e){if(Array.isArray(e))return Vi(e)}function my(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function vy(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
339
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sh(e){return gy(e)||my(e)||rs(e)||vy()}function wy(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 ws(e,t){if(e==null)return{};var n,r,i=wy(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Rh=(function(){function e(t,n){Ce(this,e),this.key=t,this.size=n}return Le(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Ah=(function(){function e(){Ce(this,e),S(this,"width",0),S(this,"height",0),S(this,"cellSize",0),S(this,"columns",0),S(this,"rows",0),S(this,"cells",{})}return Le(e,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new Rh(n,r),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(Rh.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var c in this.cells)for(var u=this.cells[c],h=0;h<Math.min(s,u.length);h++)l.push(u[h].key);return l}}])})();function yy(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.forEachEdge(function(a,s,l,c){(l===n||c===n||r.has(l)||r.has(c)||i.has(l)&&i.has(c))&&o.push(a)}),o}var Ch=150,Lh=50,Ft=Object.prototype.hasOwnProperty;function by(e,t,n){if(!Ft.call(n,"x")||!Ft.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),Ft.call(n,"hidden")||(n.hidden=!1),Ft.call(n,"highlighted")||(n.highlighted=!1),Ft.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function xy(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Ft.call(n,"hidden")||(n.hidden=!1),Ft.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var ky=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Ce(this,t),i=Be(this,t),S(i,"elements",{}),S(i,"canvasContexts",{}),S(i,"webGLContexts",{}),S(i,"pickingLayers",new Set),S(i,"textures",{}),S(i,"frameBuffers",{}),S(i,"activeListeners",{}),S(i,"labelGrid",new Ah),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",ht()),S(i,"invMatrix",ht()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",ms({x:[0,1],y:[0,1]})),S(i,"graphToViewportRatio",1),S(i,"itemIDsIndex",{}),S(i,"nodeIndices",{}),S(i,"edgeIndices",{}),S(i,"width",0),S(i,"height",0),S(i,"pixelRatio",fs()),S(i,"pickingDownSizingRatio",2*i.pixelRatio),S(i,"displayedNodeLabels",new Set),S(i,"displayedEdgeLabels",new Set),S(i,"highlightedNodes",new Set),S(i,"hoveredNode",null),S(i,"hoveredEdge",null),S(i,"renderFrame",null),S(i,"renderHighlightedNodesFrame",null),S(i,"needToProcess",!1),S(i,"checkEdgesEventsFrame",null),S(i,"nodePrograms",{}),S(i,"nodeHoverPrograms",{}),S(i,"edgePrograms",{}),i.settings=Th(o),ro(i.settings),kh(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new Eh,i.bindCameraHandlers(),i.mouseCaptor=new dy(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new fy(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ke(t,e),Le(t,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=ws(i,[r].map(kn));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=ws(s,[r].map(kn));l.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=ws(i,[r].map(kn));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],a=this.textures[r];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[r]=s,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,a=as(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=os.apply(void 0,Sh(a)),l=this.itemIDsIndex[s];return l&&l.type==="node"?l.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=Pr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},l=r.getNodeAtPosition(a);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",H(H({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",H(H({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",H(H({},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",H(H({},s),{},{edge:r.hoveredEdge})),u&&r.emit("enterEdge",H(H({},s),{},{edge:u})),r.hoveredEdge=u)}},this.activeListeners.handleMoveBody=function(o){var a=Pr(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Pr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",H(H({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",H(H({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",H({},s))},this.activeListeners.handleEnter=function(o){var a=Pr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",H({},s))};var i=function(a){return function(s){var l=Pr(s),c={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},u=r.getNodeAtPosition(l);if(u)return r.emit("".concat(a,"Node"),H(H({},c),{},{node:u}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),H(H({},c),{},{edge:h}))}return r.emit("".concat(a,"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,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(u){return r.updateNode(u)});var c=!l||l.some(function(u){return o.has(u)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(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(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=as(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=os.apply(void 0,Sh(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=xh(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,c=this.nodeExtent,u=c.x,h=c.y;this.nodeExtent={x:[(u[0]+u[1])/2-s/2,(u[0]+u[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=ms(this.customBBox||this.nodeExtent);var d=new Eh,p=Jn(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},y={},w={},v={},b=1,x=i.nodes(),T=0,A=x.length;T<A;T++){var O=x[T],N=this.nodeDataCache[O],G=i.getNodeAttributes(O);N.x=G.x,N.y=G.y,this.normalizationFunction.applyTo(N),typeof N.label=="string"&&!N.hidden&&this.labelGrid.add(O,N.size,this.framedGraphToViewport(N,{matrix:p})),g[N.type]=(g[N.type]||0)+1}this.labelGrid.organize();for(var $ in this.nodePrograms){if(!Ft.call(this.nodePrograms,$))throw new Error('Sigma: could not find a suitable program for node type "'.concat($,'"!'));this.nodePrograms[$].reallocate(g[$]||0),g[$]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(x=gs(this.nodeZExtent,function(ye){return r.nodeDataCache[ye].zIndex},x));for(var F=0,X=x.length;F<X;F++){var Z=x[F];y[Z]=b,v[y[Z]]={type:"node",id:Z},b++;var Q=this.nodeDataCache[Z];this.addNodeToProgram(Z,y[Z],g[Q.type]++)}for(var ne={},re=i.edges(),ke=0,Ve=re.length;ke<Ve;ke++){var He=re[ke],de=this.edgeDataCache[He];ne[de.type]=(ne[de.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(re=gs(this.edgeZExtent,function(ye){return r.edgeDataCache[ye].zIndex},re));for(var fe in this.edgePrograms){if(!Ft.call(this.edgePrograms,fe))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(fe,'"!'));this.edgePrograms[fe].reallocate(ne[fe]||0),ne[fe]=0}for(var Re=0,P=re.length;Re<P;Re++){var z=re[Re];w[z]=b,v[w[z]]={type:"edge",id:z},b++;var K=this.edgeDataCache[z];this.addEdgeToProgram(z,w[z],ne[K.type]++)}return this.itemIDsIndex=v,this.nodeIndices=y,this.edgeIndices=w,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(u){return i.cleanCameraState(u,o.cameraPanBoundaries&&eo(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var c in r.nodeProgramClasses)o.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]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=H({},r),c=s||this.nodeExtent,u=Qt(c.x,2),h=u[0],d=u[1],p=Qt(c.y,2),g=p[0],y=p[1],w=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y},{cameraState:r}),this.graphToViewport({x:d,y},{cameraState:r})],v=1/0,b=-1/0,x=1/0,T=-1/0;w.forEach(function(ne){var re=ne.x,ke=ne.y;v=Math.min(v,re),b=Math.max(b,re),x=Math.min(x,ke),T=Math.max(T,ke)});var A=b-v,O=T-x,N=this.getDimensions(),G=N.width,$=N.height,F=0,X=0;if(A>=G?b<G-a?F=b-(G-a):v>a&&(F=v-a):b>G+a?F=b-(G+a):v<-a&&(F=v+a),O>=$?T<$-a?X=T-($-a):x>a&&(X=x-a):T>$+a?X=T-($+a):x<-a&&(X=x+a),F||X){var Z=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Q=this.viewportToFramedGraph({x:F,y:X},{cameraState:r});F=Q.x-Z.x,X=Q.y-Z.y,l.x+=F,l.y+=X}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);vs(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],c=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!c.hidden){var u=this.framedGraphToViewport(c),h=u.x,d=u.y,p=this.scaleSize(c.size);if(!(!c.forceLabel&&p<this.settings.labelRenderedSizeThreshold)&&!(h<-Ch||h>this.width+Ch||d<-Lh||d>this.height+Lh)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,y=this.nodePrograms[c.type],w=y?.drawLabel||g;w(o,H(H({key:l},c),{},{size:p,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=yy({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});vs(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],c=this.graph.extremities(l),u=this.nodeDataCache[c[0]],h=this.nodeDataCache[c[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||u.hidden||h.hidden)){var p=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[d.type],y=g?.drawLabel||p;y(r,H(H({key:l},d),{},{size:this.scaleSize(d.size)}),H(H(H({key:c[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),H(H(H({key:c[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(p){var g=r.nodeDataCache[p],y=r.framedGraphToViewport(g),w=y.x,v=y.y,b=r.scaleSize(g.size),x=r.settings.defaultDrawNodeHover,T=r.nodePrograms[g.type],A=T?.drawHover||x;A(i,H(H({key:p},g),{},{size:b,x:w,y:v}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==r.hoveredNode&&a.push(d)}),a.forEach(function(d){return o(d)});var s={};a.forEach(function(d){var p=r.nodeDataCache[d].type;s[p]=(s[p]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var p=r.nodeDataCache[d];r.nodeHoverPrograms[p.type].process(0,s[p.type]++,p)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var u in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[u];h.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(w){return r.resetWebGLTexture(w)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),c=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=Jn(s,l,c,u),this.invMatrix=Jn(s,l,c,u,!0),this.correctionRatio=bh(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var p=this.nodePrograms[d];p.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var g in this.edgePrograms){var y=this.edgePrograms[g];y.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=by(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=xy(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Ah,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),c=this.nodeDataCache[l[0]],u=this.nodeDataCache[l[1]];s.process(i,o,c,u,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=_h(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(a.style,o.style),this.elements[r]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var a=H({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var 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 o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return H({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=H({},this.settings);return this.settings[r]=i,ro(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=H({},this.settings);return this.settings=H(H({},this.settings),r),ro(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=fs(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var 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 h=this.textures[c];h&&u.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(T){return i.addNode(T)}),this.graph.forEachEdge(function(T){return i.addEdge(T)});else{for(var l,c,u=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=u?.length||0;h<d;h++){var p=u[h];if(this.updateNode(p),o){var g=this.nodeProgramIndex[p];if(g===void 0)throw new Error('Sigma: node "'.concat(p,`" can't be repaint`));this.addNodeToProgram(p,this.nodeIndices[p],g)}}for(var y=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],w=0,v=y.length;w<v;w++){var b=y[w];if(this.updateEdge(b),o){var x=this.edgeProgramIndex[b];if(x===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],x)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(H(H({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,c=o.y,u=this.settings,h=u.minCameraRatio,d=u.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var p=i/a,g={x:this.width/2,y:this.height/2},y=this.viewportToFramedGraph(r),w=this.viewportToFramedGraph(g);return{angle:s,x:(y.x-w.x)*(1-p)+l,y:(y.y-w.y)*(1-p)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Jn(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Ji(a,r);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?Jn(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Ji(a,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return l/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(Zi),Dh=ky;var Oh=pr(Xi(),1);function _y(){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 Ne=_y;typeof Object.assign=="function"&&(Ne=Object.assign);function ft(e,t,n,r){let i=e._nodes.get(t),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function Oe(e){return typeof e=="object"&&e!==null}function Fh(e){let t;for(t in e)return!1;return!0}function pt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function yt(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 Ih(e){return!(!Oe(e)||e.attributes&&!Array.isArray(e.attributes))}function Ty(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function $t(){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 tr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Gr=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},M=class e extends Gr{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},D=class e extends Gr{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},j=class e extends Gr{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function $h(e,t){this.key=e,this.attributes=t,this.clear()}$h.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 zh(e,t){this.key=e,this.attributes=t,this.clear()}zh.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Hh(e,t){this.key=e,this.attributes=t,this.clear()}Hh.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function nr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}nr.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)};nr.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");let i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};nr.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]};nr.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 Wh=0,Uh=1,Ey=2,Bh=3;function zt(e,t,n,r,i,o,a){let s,l,c,u;if(r=""+r,n===Wh){if(s=e._nodes.get(r),!s)throw new D(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,u=o}else if(n===Bh){if(i=""+i,l=e._edges.get(i),!l)throw new D(`Graph.${t}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new D(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);c=o,u=a}else{if(l=e._edges.get(r),!l)throw new D(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Uh?s=l.source:s=l.target,c=i,u=o}return[s,c,u]}function Sy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=zt(this,t,n,r,i,o);return a.attributes[s]}}function Ry(e,t,n){e.prototype[t]=function(r,i){let[o]=zt(this,t,n,r,i);return o.attributes}}function Ay(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=zt(this,t,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function Cy(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,c]=zt(this,t,n,r,i,o,a);return s.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Ly(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,c]=zt(this,t,n,r,i,o,a);if(typeof c!="function")throw new M(`Graph.${t}: updater should be a function.`);let u=s.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Ny(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=zt(this,t,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Py(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=zt(this,t,n,r,i,o);if(!Oe(s))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Dy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=zt(this,t,n,r,i,o);if(!Oe(s))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return Ne(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Iy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=zt(this,t,n,r,i,o);if(typeof s!="function")throw new M(`Graph.${t}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var My=[{name:e=>`get${e}Attribute`,attacher:Sy},{name:e=>`get${e}Attributes`,attacher:Ry},{name:e=>`has${e}Attribute`,attacher:Ay},{name:e=>`set${e}Attribute`,attacher:Cy},{name:e=>`update${e}Attribute`,attacher:Ly},{name:e=>`remove${e}Attribute`,attacher:Ny},{name:e=>`replace${e}Attributes`,attacher:Py},{name:e=>`merge${e}Attributes`,attacher:Dy},{name:e=>`update${e}Attributes`,attacher:Iy}];function Gy(e){My.forEach(function({name:t,attacher:n}){n(e,t("Node"),Wh),n(e,t("Source"),Uh),n(e,t("Target"),Ey),n(e,t("Opposite"),Bh)})}function Oy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ft(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function Fy(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=ft(this,o,a,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function $y(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ft(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function zy(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=ft(this,s,l,n),!a)throw new D(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Hy(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=ft(this,s,l,n),!a)throw new D(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new M(`Graph.${t}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Wy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ft(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function Uy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ft(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Oe(i))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function By(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ft(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Oe(i))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return Ne(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function Ky(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ft(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new M(`Graph.${t}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var Vy=[{name:e=>`get${e}Attribute`,attacher:Oy},{name:e=>`get${e}Attributes`,attacher:Fy},{name:e=>`has${e}Attribute`,attacher:$y},{name:e=>`set${e}Attribute`,attacher:zy},{name:e=>`update${e}Attribute`,attacher:Hy},{name:e=>`remove${e}Attribute`,attacher:Wy},{name:e=>`replace${e}Attributes`,attacher:Uy},{name:e=>`merge${e}Attributes`,attacher:By},{name:e=>`update${e}Attributes`,attacher:Ky}];function jy(e){Vy.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var qy=[{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 Yy(e,t,n,r){let i=!1;for(let o in t){if(o===r)continue;let a=t[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),e&&i)return a.key}}function Xy(e,t,n,r){let i,o,a,s=!1;for(let l in t)if(l!==r){i=t[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function ys(e,t){let n=Object.keys(e),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===t){i=void 0;continue}i=e[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function Zy(e,t,n,r){let i=t[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&e)return i.key}function Qy(e,t,n,r){let i=t[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&o)return i.key;i=i.next}while(i!==void 0)}function bs(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Jy(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());let n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function Kh(e,t,n,r){if(t.size===0)return;let i=n!=="mixed"&&n!==t.type,o=n==="undirected",a,s,l=!1,c=t._edges.values();for(;a=c.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:u,attributes:h,source:d,target:p}=s;if(l=r(u,h,d.key,p.key,d.attributes,p.attributes,s.undirected),e&&l)return u}}function eb(e,t){if(e.size===0)return tr();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function xs(e,t,n,r,i,o){let a=t?Xy:Yy,s;if(n!=="undirected"&&(r!=="out"&&(s=a(e,i.in,o),e&&s)||r!=="in"&&(s=a(e,i.out,o,r?void 0:i.key),e&&s))||n!=="directed"&&(s=a(e,i.undirected,o),e&&s))return s}function tb(e,t,n,r){let i=[];return xs(!1,e,t,n,r,function(o){i.push(o)}),i}function nb(e,t,n){let r=tr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=$t(r,ys(n.in))),t!=="in"&&typeof n.out<"u"&&(r=$t(r,ys(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=$t(r,ys(n.undirected))),r}function ks(e,t,n,r,i,o,a){let s=n?Qy:Zy,l;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(e,i.in,o,a),e&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(e,i.out,o,a),e&&l))||t!=="directed"&&typeof i.undirected<"u"&&(l=s(e,i.undirected,o,a),e&&l))return l}function rb(e,t,n,r,i){let o=[];return ks(!1,e,t,n,r,i,function(a){o.push(a)}),o}function ib(e,t,n,r){let i=tr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=$t(i,bs(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=$t(i,bs(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=$t(i,bs(n.undirected,r))),i}function ob(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return Jy(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new D(`Graph.${n}: could not find the "${o}" node in the graph.`);return tb(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){o=""+o,a=""+a;let s=this._nodes.get(o);if(!s)throw new D(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new D(`Graph.${n}: could not find the "${a}" target node in the graph.`);return rb(r,this.multi,i,s,a)}throw new M(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ab(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,u,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=c,Kh(!1,this,r,h);if(arguments.length===2){c=""+c,h=u;let d=this._nodes.get(c);if(typeof d>"u")throw new D(`Graph.${o}: could not find the "${c}" node in the graph.`);return xs(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){c=""+c,u=""+u;let d=this._nodes.get(c);if(!d)throw new D(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new D(`Graph.${o}: could not find the "${u}" target node in the graph.`);return ks(!1,r,this.multi,i,d,u,h)}throw new M(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),h;if(c.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let p=0;c.push((g,y,w,v,b,x,T)=>{h[p++]=u(g,y,w,v,b,x,T)})}else h=[],c.push((d,p,g,y,w,v,b)=>{h.push(u(d,p,g,y,w,v,b))});return this[o].apply(this,c),h};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),h=[];return c.push((d,p,g,y,w,v,b)=>{u(d,p,g,y,w,v,b)&&h.push(d)}),this[o].apply(this,c),h};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 M(`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 M(`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,h;c.length===2?(u=c[0],h=c[1],c=[]):c.length===3?(u=c[1],h=c[2],c=[c[0]]):c.length===4&&(u=c[2],h=c[3],c=[c[0],c[1]]);let d=h;return c.push((p,g,y,w,v,b,x)=>{d=u(d,p,g,y,w,v,b,x)}),this[o].apply(this,c),d}}function sb(e,t){let{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(l,c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return u=l,Kh(!0,this,r,u);if(arguments.length===2){l=""+l,u=c;let h=this._nodes.get(l);if(typeof h>"u")throw new D(`Graph.${o}: could not find the "${l}" node in the graph.`);return xs(!0,this.multi,r==="mixed"?this.type:r,i,h,u)}if(arguments.length===3){l=""+l,c=""+c;let h=this._nodes.get(l);if(!h)throw new D(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new D(`Graph.${o}: could not find the "${c}" target node in the graph.`);return ks(!0,r,this.multi,i,h,c,u)}throw new M(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,d,p,g,y,w,v)=>c(h,d,p,g,y,w,v)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,d,p,g,y,w,v)=>!c(h,d,p,g,y,w,v)),!this[o].apply(this,l)}}function lb(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return tr();if(!arguments.length)return eb(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new D(`Graph.${o}: could not find the "${a}" node in the graph.`);return nb(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new D(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new D(`Graph.${o}: could not find the "${s}" target node in the graph.`);return ib(r,i,l,s)}throw new M(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function cb(e){qy.forEach(t=>{ob(e,t),ab(e,t),sb(e,t),lb(e,t)})}var ub=[{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 po(){this.A=null,this.B=null}po.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};po.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Ir(e,t,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.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 _s(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Ir(e,null,r,r.undirected,i);if(typeof n=="string")return Ir(e,null,r,r[n],i)}let o=new po,a;if(t!=="undirected"){if(n!=="out"){if(a=Ir(e,null,r,r.in,i),e&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Ir(e,o,r,r.out,i),e&&a)return a;o.wrap(r.out)}}if(t!=="directed"&&(a=Ir(e,o,r,r.undirected,i),e&&a))return a}function db(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 _s(!1,e,t,n,function(i){r.push(i)}),r}function Mr(e,t,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return e&&e.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,c=s.target;if(a=l===t?c:l,e&&e.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function hb(e,t,n){if(e!=="mixed"){if(e==="undirected")return Mr(null,n,n.undirected);if(typeof t=="string")return Mr(null,n,n[t])}let r=tr(),i=new po;return e!=="undirected"&&(t!=="out"&&(r=$t(r,Mr(i,n,n.in))),t!=="in"&&(r=$t(r,Mr(i,n,n.out)))),e!=="directed"&&(r=$t(r,Mr(i,n,n.undirected))),r}function pb(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new D(`Graph.${n}: could not find the "${o}" node in the graph.`);return db(r==="mixed"?this.type:r,i,a)}}function fb(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let h=this._nodes.get(c);if(typeof h>"u")throw new D(`Graph.${o}: could not find the "${c}" node in the graph.`);_s(!1,r==="mixed"?this.type:r,i,h,u)};let a="map"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(c,u){let h=[];return this[o](c,(d,p)=>{h.push(u(d,p))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,u){let h=[];return this[o](c,(d,p)=>{u(d,p)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(c,u,h){if(arguments.length<3)throw new M(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d=h;return this[o](c,(p,g)=>{d=u(d,p,g)}),d}}function gb(e,t){let{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;e.prototype[a]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let h=this._nodes.get(c);if(typeof h>"u")throw new D(`Graph.${a}: could not find the "${c}" node in the graph.`);return _s(!0,r==="mixed"?this.type:r,i,h,u)};let s="some"+o;e.prototype[s]=function(c,u){return!!this[a](c,u)};let l="every"+o;e.prototype[l]=function(c,u){return!this[a](c,(d,p)=>!u(d,p))}}function mb(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return tr();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new D(`Graph.${o}: could not find the "${a}" node in the graph.`);return hb(r==="mixed"?this.type:r,i,s)}}function vb(e){ub.forEach(t=>{pb(e,t),fb(e,t),gb(e,t),mb(e,t)})}function ao(e,t,n,r,i){let o=r._nodes.values(),a=r.type,s,l,c,u,h,d,p;for(;s=o.next(),s.done!==!0;){let g=!1;if(l=s.value,a!=="undirected"){u=l.out;for(c in u){h=u[c];do{if(d=h.target,g=!0,p=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),e&&p)return h;h=h.next}while(h)}}if(a!=="directed"){u=l.undirected;for(c in u)if(!(t&&l.key>c)){h=u[c];do{if(d=h.target,d.key!==c&&(d=h.source),g=!0,p=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),e&&p)return h;h=h.next}while(h)}}if(n&&!g&&(p=i(l.key,null,l.attributes,null,null,null,null),e&&p))return null}}function wb(e,t){let n={key:e};return Fh(t.attributes)||(n.attributes=Ne({},t.attributes)),n}function yb(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return Fh(n.attributes)||(r.attributes=Ne({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function bb(e){if(!Oe(e))throw new M('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new M("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!Oe(e.attributes)||e.attributes===null))throw new M("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function xb(e){if(!Oe(e))throw new M('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new M("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new M("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!Oe(e.attributes)||e.attributes===null))throw new M("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new M("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var kb=Ty(),_b=new Set(["directed","undirected","mixed"]),Mh=new Set(["domain","_events","_eventsCount","_maxListeners"]),Tb=[{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"}],Eb={allowSelfLoops:!0,multi:!1,type:"mixed"};function Sb(e,t,n){if(n&&!Oe(n))throw new M(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new j(`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 Gh(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 Vh(e,t,n,r,i,o,a,s){if(!r&&e.type==="undirected")throw new j(`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 j(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Oe(s))throw new M(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!e.allowSelfLoops&&o===a)throw new j(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),c=e._nodes.get(a);if(!l)throw new D(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new D(`Graph.${t}: target node "${a}" not found.`);let u={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new j(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new j(`Graph.${t}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let h=new nr(r,i,l,c,s);e._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,c.undirectedDegree++,d&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,c.inDegree++,d&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,u.key=i,e.emit("edgeAdded",u),i}function Rb(e,t,n,r,i,o,a,s,l){if(!r&&e.type==="undirected")throw new j(`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 j(`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 M(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!Oe(s))throw new M(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let c;if(l&&(c=s,s=void 0),!e.allowSelfLoops&&o===a)throw new j(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=e._nodes.get(o),h=e._nodes.get(a),d,p;if(!n&&(d=e._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new j(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);p=d}if(!p&&!e.multi&&u&&(p=r?u.undirected[a]:u.out[a]),p){let b=[p.key,!1,!1,!1];if(l?!c:!s)return b;if(l){let x=p.attributes;p.attributes=c(x),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else Ne(p.attributes,s),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:s});return b}s=s||{},l&&c&&(s=c(s));let g={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new j(`Graph.${t}: the "${i}" edge already exists in the graph.`);let y=!1,w=!1;u||(u=Gh(e,o,{}),y=!0,o===a&&(h=u,w=!0)),h||(h=Gh(e,a,{}),w=!0),d=new nr(r,i,u,h,s),e._edges.set(i,d);let v=o===a;return r?(u.undirectedDegree++,h.undirectedDegree++,v&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,v&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,g.key=i,e.emit("edgeAdded",g),[i,!0,y,w]}function er(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,o=t.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}var ae=class e extends Oh.EventEmitter{constructor(t){if(super(),t=Ne({},Eb,t),typeof t.multi!="boolean")throw new M(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!_b.has(t.type))throw new M(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new M(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);let n=t.type==="mixed"?$h:t.type==="directed"?zh:Hh;pt(this,"NodeDataClass",n);let r="geid_"+kb()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};pt(this,"_attributes",{}),pt(this,"_nodes",new Map),pt(this,"_edges",new Map),pt(this,"_directedSize",0),pt(this,"_undirectedSize",0),pt(this,"_directedSelfLoopCount",0),pt(this,"_undirectedSelfLoopCount",0),pt(this,"_edgeKeyGenerator",o),pt(this,"_options",t),Mh.forEach(a=>pt(this,a,this[a])),yt(this,"order",()=>this._nodes.size),yt(this,"size",()=>this._edges.size),yt(this,"directedSize",()=>this._directedSize),yt(this,"undirectedSize",()=>this._undirectedSize),yt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),yt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),yt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),yt(this,"multi",this._options.multi),yt(this,"type",this._options.type),yt(this,"allowSelfLoops",this._options.allowSelfLoops),yt(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 M(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(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 M(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(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 M(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new j("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 D(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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 j("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 D(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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 j("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 D(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new D(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;let r=this._edges.get(t);if(!r)throw new D(`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 D(`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 D(`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 D(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return Sb(this,t,n).key}mergeNode(t,n){if(n&&!Oe(n))throw new M(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Ne(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 M(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`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 er(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do er(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do er(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=ft(this,r,i,this.type),!n)throw new D(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new D(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return er(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new j("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 j("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=ft(this,t,n,"directed");if(!r)throw new D(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return er(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new j("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 j("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=ft(this,t,n,"undirected");if(!r)throw new D(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return er(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 M("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(!Oe(t))throw new M("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(!Oe(t))throw new M("Graph.mergeAttributes: provided attributes are not a plain object.");return Ne(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new M("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 M("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!Ih(n))throw new M("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new M("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!Ih(n))throw new M("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=t(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new M("Graph.forEachAdjacencyEntry: expecting a callback.");ao(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ao(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ao(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ao(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new M("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 M("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 M("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new M("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 M("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 M("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new M("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new M("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=t(r,a.key,a.attributes);return r}nodeEntries(){let t=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=t.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let t=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{t[n++]=wb(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=yb(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof e)return t.forEachNode((l,c)=>{n?this.mergeNode(l,c):this.addNode(l,c)}),t.forEachEdge((l,c,u,h,d,p,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,u,h,c):this.mergeDirectedEdgeWithKey(l,u,h,c):g?this.addUndirectedEdgeWithKey(l,u,h,c):this.addDirectedEdgeWithKey(l,u,h,c)}),this;if(!Oe(t))throw new M("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Oe(t.attributes))throw new M("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,a,s;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new M("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],bb(a);let{key:l,attributes:c}=a;n?this.mergeNode(l,c):this.addNode(l,c)}}if(t.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=t.edges,!Array.isArray(o))throw new M("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],xb(s);let{source:c,target:u,attributes:h,undirected:d=l}=s,p;"key"in s?(p=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,p.call(this,s.key,c,u,h)):(p=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,p.call(this,c,u,h))}}return this}nullCopy(t){let n=new e(Ne({},this._options,t));return n.replaceAttributes(Ne({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let o=Ne({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new j(`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 j("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 j("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let n=this.emptyCopy(t),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,Vh(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Ne({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let t={};this._nodes.forEach((o,a)=>{t[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",c=o.source.key,u=o.target.key,h;o.undirected&&c>u&&(h=c,c=u,u=h);let d=`(${c})${s}(${u})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!Mh.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,pt(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(ae.prototype[Symbol.for("nodejs.util.inspect.custom")]=ae.prototype.inspect);Tb.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?Vh:Rb;e.generateKey?ae.prototype[n]=function(i,o,a){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,a,t==="update")}:ae.prototype[n]=function(i,o,a,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,a,s,t==="update")}})});Gy(ae);jy(ae);cb(ae);vb(ae);var so=class extends ae{constructor(t){let n=Ne({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new M("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new M('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},lo=class extends ae{constructor(t){let n=Ne({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new M("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new M('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},co=class extends ae{constructor(t){let n=Ne({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new M("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},uo=class extends ae{constructor(t){let n=Ne({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new M("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new M('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},ho=class extends ae{constructor(t){let n=Ne({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new M("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new M('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function rr(e){e.from=function(t,n){let r=Ne({},t.options,n),i=new e(r);return i.import(t),i}}rr(ae);rr(so);rr(lo);rr(co);rr(uo);rr(ho);ae.Graph=ae;ae.DirectedGraph=so;ae.UndirectedGraph=lo;ae.MultiGraph=co;ae.MultiDirectedGraph=uo;ae.MultiUndirectedGraph=ho;ae.InvalidArgumentsGraphError=M;ae.NotFoundGraphError=D;ae.UsageGraphError=j;function Ab(){return new ae({multi:!0,type:"directed"})}function Ts(e){let t=Ab();for(let n of e.nodes){let{id:r,...i}=n;t.addNode(r,i)}for(let n of e.edges){let{key:r,source:i,target:o,...a}=n;t.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return t}function jh(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 Es(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var qh=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function Yh(e,t,n){let r=null,i=Ts({nodes:[],edges:[]}),o=null,a=null,s=new Map,l=0,c=0,u=null,h=0,d=()=>{},p=()=>{},g=()=>{},y=()=>{},w=()=>{},v=null,b=!1,x=N=>{if(v===null)return;let G=v;v=null,r?.setSetting("enableCameraPanning",!0),(N===null||N===G)&&w(G)},T=()=>Pu([...Es(i).values()]),A=N=>{let G=Gu(o,a,l),$=Fu(o,a,l),F=s;N.setSetting("nodeReducer",(X,Z)=>{let Q={...Z,...G(X,Z,t)};return{...Q,...$u(F.get(X),Q,t,Z.label)}}),N.setSetting("edgeReducer",(X,Z)=>({...Z,...$(X,Z,t)}))},O=()=>{if(n===void 0||u!==null)return;h=n.now();let N=()=>{u=null;let G=n.now();if(l=Ou(l,c,G-h),h=G,r!==null&&A(r),l===c){l===0&&(o=null);return}u=n.request(N)};u=n.request(N)};return{mount(N){if(r!==null)return;let G=e(i,N,Hu(t));G.on("clickNode",({node:$})=>{b||d($)}),G.on("doubleClickNode",({node:$,preventSigmaDefault:F})=>{F(),b||d($)}),G.on("clickStage",()=>d(null)),G.on("downNode",({node:$})=>{v=$,b=!1,r?.setSetting("enableCameraPanning",!1),g($)}),G.on("moveBody",$=>{v!==null&&(b=!0,$.preventSigmaDefault(),y(v,G.viewportToGraph({x:$.event.x,y:$.event.y})))}),G.on("enterNode",({node:$})=>p($)),G.on("leaveNode",()=>p(null)),G.on("upNode",()=>x(v)),G.on("upStage",()=>x(null)),A(G),G.setSetting("labelRenderedSizeThreshold",Ka(i.order)),G.setCustomBBox(T()),r=G},setGraph(N){i=Ts(N),r?.setGraph(i),r?.setSetting("labelRenderedSizeThreshold",Ka(i.order)),r?.setCustomBBox(T())},setPositions(N){jh(i,N),r?.refresh()},setHighlight(N,G=null){if(n===void 0){o=N,a=G,l=N===null?0:1,c=l,r!==null&&A(r);return}if(N===null){if(c=0,o===null)return}else o=N,a=G,c=1;r!==null&&A(r),l!==c&&O()},setTrail(N){s=N,r!==null&&A(r)},onSelect(N){d=N},onHover(N){p=N},onDragStart(N){g=N},onDragMove(N){y=N},onDragEnd(N){w=N},fit(){r?.setCustomBBox(T()),r?.getCamera().animatedReset()},positions(){return Es(i)},destroy(){u!==null&&(n?.cancel(u),u=null),r?.kill(),r=null}}}var Xh=e=>Yh((t,n,r)=>new Dh(t,n,r),e,qh(window));function Zh(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 Cb(e){if(Array.isArray(e))return e}function Lb(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function Nb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
340
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pb(e,t){return Cb(e)||Lb(e,t)||Db(e,t)||Nb()}function Db(e,t){if(e){if(typeof e=="string")return Zh(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)?Zh(e,t):void 0}}var hp=Object.entries,Qh=Object.setPrototypeOf,Ib=Object.isFrozen,Mb=Object.getPrototypeOf,Gb=Object.getOwnPropertyDescriptor,Pe=Object.freeze,Me=Object.seal,ir=Object.create,pp=typeof Reflect<"u"&&Reflect,Ps=pp.apply,Ds=pp.construct;Pe||(Pe=function(t){return t});Me||(Me=function(t){return t});Ps||(Ps=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return t.apply(n,i)});Ds||(Ds=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 En=Se(Array.prototype.forEach),Ob=Se(Array.prototype.lastIndexOf),Jh=Se(Array.prototype.pop),Or=Se(Array.prototype.push),Fb=Se(Array.prototype.splice),or=Array.isArray,zr=Se(String.prototype.toLowerCase),Ss=Se(String.prototype.toString),ep=Se(String.prototype.match),Fr=Se(String.prototype.replace),tp=Se(String.prototype.indexOf),$b=Se(String.prototype.trim),zb=Se(Number.prototype.toString),Hb=Se(Boolean.prototype.toString),np=typeof BigInt>"u"?null:Se(BigInt.prototype.toString),rp=typeof Symbol>"u"?null:Se(Symbol.prototype.toString),Ze=Se(Object.prototype.hasOwnProperty),$r=Se(Object.prototype.toString),$e=Se(RegExp.prototype.test),Tn=Wb(TypeError);function Se(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 Ps(e,t,r)}}function Wb(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ds(e,n)}}function te(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:zr;if(Qh&&Qh(e,null),!or(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let o=n(i);o!==i&&(Ib(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Ub(e){for(let t=0;t<e.length;t++)Ze(e,t)||(e[t]=null);return e}function ot(e){let t=ir(null);for(let r of hp(e)){var n=Pb(r,2);let i=n[0],o=n[1];Ze(e,i)&&(or(o)?t[i]=Ub(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=ot(o):t[i]=o)}return t}function Bb(e){switch(typeof e){case"string":return e;case"number":return zb(e);case"boolean":return Hb(e);case"bigint":return np?np(e):"0";case"symbol":return rp?rp(e):"Symbol()";case"undefined":return $r(e);case"function":case"object":{if(e===null)return $r(e);let t=e,n=bt(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:$r(r)}return $r(e)}default:return $r(e)}}function bt(e,t){for(;e!==null;){let r=Gb(e,t);if(r){if(r.get)return Se(r.get);if(typeof r.value=="function")return Se(r.value)}e=Mb(e)}function n(){return null}return n}function Kb(e){try{return $e(e,""),!0}catch{return!1}}var ip=Pe(["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"]),Rs=Pe(["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"]),As=Pe(["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"]),Vb=Pe(["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"]),Cs=Pe(["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"]),jb=Pe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),op=Pe(["#text"]),ap=Pe(["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"]),Ls=Pe(["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"]),sp=Pe(["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"]),fo=Pe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),qb=Me(/{{[\w\W]*|^[\w\W]*}}/g),Yb=Me(/<%[\w\W]*|^[\w\W]*%>/g),Xb=Me(/\${[\w\W]*/g),Zb=Me(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qb=Me(/^aria-[\-\w]+$/),lp=Me(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Jb=Me(/^(?:\w+script|data):/i),ex=Me(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tx=Me(/^html$/i),nx=Me(/^[a-z][.\w]*(-[.\w]+)+$/i),cp=Me(/<[/\w!]/g),up=Me(/<[/\w]/g),rx=Me(/<\/no(script|embed|frames)/i),ix=Me(/\/>/i),it={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},fp=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],ox=Pe(te({},fp)),ax=(function(){let e={};return En(fp,t=>{e[t]=Me(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Pe(e)})(),sx=function(){return typeof window>"u"?null:window},lx=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},dp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},en=function(t,n,r,i){return Ze(t,n)&&or(t[n])?te(i.base?ot(i.base):{},t[n],i.transform):r},Ns=function(t,n,r){let i=Ze(t,n)?t[n]:void 0;return i&&typeof i=="object"?ot(i):r()};function gp(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sx(),t=C=>gp(C);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==it.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,a=e.Node,s=e.Element,l=e.NodeFilter,c=e.NamedNodeMap;c===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let u=e.DOMParser,h=e.trustedTypes,d=s.prototype,p=bt(d,"cloneNode"),g=bt(d,"remove"),y=bt(d,"nextSibling"),w=bt(d,"childNodes"),v=bt(d,"parentNode"),b=bt(d,"shadowRoot"),x=bt(d,"attributes"),T=a&&a.prototype?bt(a.prototype,"nodeType"):null,A=a&&a.prototype?bt(a.prototype,"nodeName"):null,O=a&&a.prototype?bt(a.prototype,"ownerDocument"):null,N=function(m){return T?T(m):m.nodeType},G=function(m){return A?A(m):m.nodeName};if(typeof o=="function"){let C=n.createElement("template");C.content&&C.content.ownerDocument&&(n=C.content.ownerDocument)}let $,F="",X,Z=!1,Q=0,ne=function(){if(Q>0)throw Tn('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.')},re=function(m){ne(),Q++;try{return $.createHTML(m)}finally{Q--}},ke=function(m){ne(),Q++;try{return $.createScriptURL(m)}finally{Q--}},Ve=function(){return Z||(X=lx(h,i),Z=!0),X},He=n,de=He.implementation,fe=He.createNodeIterator,Re=He.createDocumentFragment,P=He.getElementsByTagName,z=r.importNode,K=dp();t.isSupported=typeof hp=="function"&&typeof v=="function"&&de&&de.createHTMLDocument!==void 0;let ye=qb,Je=Yb,kt=Xb,jr=Zb,nn=Qb,lt=Jb,_t=ex,rn=nx,qr=lp,se=null,gt=te({},[...ip,...Rs,...As,...Cs,...op]),le=null,on=te({},[...ap,...Ls,...sp,...fo]),et=Object.seal(ir(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}})),Ut=null,Yr=null,Tt=Object.seal(ir(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Lt=!0,an=!0,Bt=!1,Xr=!0,Ge=!1,Ae=!0,_e=!1,Nn=!1,be=null,ct=null,mt=!1,Kt=!1,Fe=!1,Nt=!1,Et=!0,tt=!1,Zr="user-content-",Pn=!0,Dn=!1,Vt={},jt=null,Qr=te({},["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"]),Jr=null,cr=te({},["audio","video","img","source","image","track"]),ur=null,dr=te({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),In="http://www.w3.org/1998/Math/MathML",Mn="http://www.w3.org/2000/svg",ut="http://www.w3.org/1999/xhtml",Pt=ut,Gn=!1,On=null,ei=te({},[In,Mn,ut],Ss),ti=Pe(["mi","mo","mn","ms","mtext"]),_=te({},ti),R=Pe(["annotation-xml"]),B=te({},R),L=te({},["title","style","font","a","script"]),W=null,Te=["application/xhtml+xml","text/html"],dt="text/html",ce=null,Dt=null,Go=n.createElement("form"),nl=function(m){return m instanceof RegExp||m instanceof Function},Oo=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Dt&&Dt===m)return;(!m||typeof m!="object")&&(m={}),m=ot(m),W=Te.indexOf(m.PARSER_MEDIA_TYPE)===-1?dt:m.PARSER_MEDIA_TYPE,ce=W==="application/xhtml+xml"?Ss:zr,se=en(m,"ALLOWED_TAGS",gt,{transform:ce}),le=en(m,"ALLOWED_ATTR",on,{transform:ce}),On=en(m,"ALLOWED_NAMESPACES",ei,{transform:Ss}),ur=en(m,"ADD_URI_SAFE_ATTR",dr,{transform:ce,base:dr}),Jr=en(m,"ADD_DATA_URI_TAGS",cr,{transform:ce,base:cr}),jt=en(m,"FORBID_CONTENTS",Qr,{transform:ce}),Ut=en(m,"FORBID_TAGS",ot({}),{transform:ce}),Yr=en(m,"FORBID_ATTR",ot({}),{transform:ce}),Vt=Ze(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?ot(m.USE_PROFILES):m.USE_PROFILES:!1,Lt=m.ALLOW_ARIA_ATTR!==!1,an=m.ALLOW_DATA_ATTR!==!1,Bt=m.ALLOW_UNKNOWN_PROTOCOLS||!1,Xr=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ge=m.SAFE_FOR_TEMPLATES||!1,Ae=m.SAFE_FOR_XML!==!1,_e=m.WHOLE_DOCUMENT||!1,Kt=m.RETURN_DOM||!1,Fe=m.RETURN_DOM_FRAGMENT||!1,Nt=m.RETURN_TRUSTED_TYPE||!1,mt=m.FORCE_BODY||!1,Et=m.SANITIZE_DOM!==!1,tt=m.SANITIZE_NAMED_PROPS||!1,Pn=m.KEEP_CONTENT!==!1,Dn=m.IN_PLACE||!1,qr=Kb(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:lp,Pt=typeof m.NAMESPACE=="string"?m.NAMESPACE:ut,_=Ns(m,"MATHML_TEXT_INTEGRATION_POINTS",()=>te({},ti)),B=Ns(m,"HTML_INTEGRATION_POINTS",()=>te({},R));let k=Ns(m,"CUSTOM_ELEMENT_HANDLING",()=>ir(null));if(et=ir(null),Ze(k,"tagNameCheck")&&nl(k.tagNameCheck)&&(et.tagNameCheck=k.tagNameCheck),Ze(k,"attributeNameCheck")&&nl(k.attributeNameCheck)&&(et.attributeNameCheck=k.attributeNameCheck),Ze(k,"allowCustomizedBuiltInElements")&&typeof k.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=k.allowCustomizedBuiltInElements),Me(et),Ge&&(an=!1),Fe&&(Kt=!0),Vt&&(se=te({},op),le=ir(null),Vt.html===!0&&(te(se,ip),te(le,ap)),Vt.svg===!0&&(te(se,Rs),te(le,Ls),te(le,fo)),Vt.svgFilters===!0&&(te(se,As),te(le,Ls),te(le,fo)),Vt.mathMl===!0&&(te(se,Cs),te(le,sp),te(le,fo))),Tt.tagCheck=null,Tt.attributeCheck=null,Ze(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Tt.tagCheck=m.ADD_TAGS:or(m.ADD_TAGS)&&(se===gt&&(se=ot(se)),te(se,m.ADD_TAGS,ce))),Ze(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Tt.attributeCheck=m.ADD_ATTR:or(m.ADD_ATTR)&&(le===on&&(le=ot(le)),te(le,m.ADD_ATTR,ce))),Ze(m,"ADD_FORBID_CONTENTS")&&or(m.ADD_FORBID_CONTENTS)&&(jt===Qr&&(jt=ot(jt)),te(jt,m.ADD_FORBID_CONTENTS,ce)),Pn&&(se["#text"]=!0),_e&&te(se,["html","head","body"]),se.table&&(te(se,["tbody"]),delete Ut.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw Tn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Tn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=$;$=m.TRUSTED_TYPES_POLICY;try{F=re("")}catch(I){throw $=E,I}}else m.TRUSTED_TYPES_POLICY===null?($=void 0,F=""):($===void 0&&($=Ve()),$&&typeof F=="string"&&(F=re("")));Pe&&Pe(m),Dt=m},rl=te({},[...Rs,...As,...Vb]),il=te({},[...Cs,...jb]),wg=function(m,k,E){return k.namespaceURI===ut?m==="svg":k.namespaceURI===In?m==="svg"&&(E==="annotation-xml"||_[E]):!!rl[m]},yg=function(m,k,E){return k.namespaceURI===ut?m==="math":k.namespaceURI===Mn?m==="math"&&B[E]:!!il[m]},bg=function(m,k,E){return k.namespaceURI===Mn&&!B[E]||k.namespaceURI===In&&!_[E]?!1:!il[m]&&(L[m]||!rl[m])},xg=function(m){let k=v(m);(!k||!k.tagName)&&(k={namespaceURI:Pt,tagName:"template"});let E=zr(m.tagName),I=zr(k.tagName);return On[m.namespaceURI]?m.namespaceURI===Mn?wg(E,k,I):m.namespaceURI===In?yg(E,k,I):m.namespaceURI===ut?bg(E,k,I):!!(W==="application/xhtml+xml"&&On[m.namespaceURI]):!1},qt=function(m){Or(t.removed,{element:m});try{v(m).removeChild(m)}catch{if(g(m),!v(m))throw Tn("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ol=function(m,k,E){try{m.removeAttributeNode(k)}catch{try{m.removeAttribute(E)}catch{}}},ni=function(m){ri(m);let k=w(m);if(k){let I=[];En(k,U=>{Or(I,U)}),En(I,U=>{try{g(U)}catch{}})}let E=x(m);if(E)for(let I=E.length-1;I>=0;--I){let U=E[I],q=U&&U.name;typeof q=="string"&&ol(m,U,q)}},sn=function(m,k,E){if(!E)try{E=k.getAttributeNode(m)}catch{E=null}Or(t.removed,{attribute:E||null,from:k});try{E?k.removeAttributeNode(E):k.removeAttribute(m)}catch{try{k.removeAttribute(m)}catch{}}if(m==="is")if(Kt||Fe)try{qt(k)}catch{}else try{k.setAttribute(m,"")}catch{}},kg=function(m){let k=x(m);if(k)for(let E=k.length-1;E>=0;--E){let I=k[E],U=I&&I.name;typeof U!="string"||le[ce(U)]||ol(m,I,U)}},ri=function(m){let k=[m];for(;k.length>0;){let E=k.pop();N(E)===it.element&&kg(E);let U=w(E);if(U)for(let q=U.length-1;q>=0;--q)k.push(U[q])}},al=function(m,k){return Ae?m==="patchsrc"?!0:m==="for"&&k!=="label"&&k!=="output":!1},_g=function(m){if(!Ae)return;let k=[m];for(;k.length>0;){let E=k.pop(),I=N(E);if(I===it.processingInstruction||I===it.comment&&$e(up,E.data)){try{g(E)}catch{}continue}if(I===it.element){let q=E,he=ce(G(E));try{q.hasAttribute&&q.hasAttribute("patchsrc")&&q.removeAttribute("patchsrc"),q.hasAttribute&&q.hasAttribute("for")&&al("for",he)&&q.removeAttribute("for")}catch{}}let U=w(E);if(U)for(let q=U.length-1;q>=0;--q)k.push(U[q])}},sl=function(m){let k=null,E=null;if(mt)m="<remove></remove>"+m;else{let q=ep(m,/^[\r\n\t ]+/);E=q&&q[0]}W==="application/xhtml+xml"&&Pt===ut&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");let I=$?re(m):m;if(Pt===ut)try{k=new u().parseFromString(I,W)}catch{}if(!k||!k.documentElement){k=de.createDocument(Pt,"template",null);try{k.documentElement.innerHTML=Gn?F:I}catch{}}let U=k.body||k.documentElement;return m&&E&&U.insertBefore(n.createTextNode(E),U.childNodes[0]||null),Pt===ut?P.call(k,_e?"html":"body")[0]:_e?k.documentElement:U},ll=function(m){let k=O?O(m):m.ownerDocument;return fe.call(k||m,m,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},ii=function(m){return m=Fr(m,ye," "),m=Fr(m,Je," "),m=Fr(m,kt," "),m},Fo=function(m){var k;m.normalize();let E=O?O(m):m.ownerDocument,I=fe.call(E||m,m,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),U=I.nextNode();for(;U;)U.data=ii(U.data),U=I.nextNode();let q=(k=m.querySelectorAll)===null||k===void 0?void 0:k.call(m,"template");q&&En(q,he=>{Fn(he.content)&&Fo(he.content)})},oi=function(m){let k=A?A(m):null;return typeof k!="string"||ce(k)!=="form"?!1:typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||m.attributes!==x(m)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function"||m.nodeType!==T(m)||m.childNodes!==w(m)},Fn=function(m){if(!T||typeof m!="object"||m===null)return!1;try{return T(m)===it.documentFragment}catch{return!1}},hr=function(m){if(!T||typeof m!="object"||m===null)return!1;try{return typeof T(m)=="number"}catch{return!1}};function St(C,m,k){C.length!==0&&En(C,E=>{E.call(t,m,k,Dt)})}let Tg=function(m,k){return!!(Ae&&m.hasChildNodes()&&!hr(m.firstElementChild)&&$e(cp,m.textContent)&&$e(cp,m.innerHTML)||Ae&&m.namespaceURI===ut&&ox[k]&&(hr(m.firstElementChild)||typeof m.textContent=="string"&&$e(ax[k],m.textContent))||m.nodeType===it.processingInstruction||Ae&&m.nodeType===it.comment&&$e(up,m.data))},ai=function(m,k){if(m instanceof RegExp)return $e(m,k);if(m instanceof Function){for(var E=arguments.length,I=new Array(E>2?E-2:0),U=2;U<E;U++)I[U-2]=arguments[U];return!!m(k,...I)}return!1},Eg=function(m,k,E){if(!Ut[k]&&pl(k)&&ai(et.tagNameCheck,k))return!1;if(Pn&&!jt[k]){let I=v(m),U=w(m);if(U&&I){let q=U.length;for(let he=q-1;he>=0;--he){let ge=m===E?p(U[he],!0):U[he];I.insertBefore(ge,y(m))}}}return qt(m),!0},cl=function(m,k,E,I){return m.length===0?k:k===E||k===I?ot(k):k},ul=function(m,k){return m===k||v(m)!==null?!1:(Dn&&ri(m),!0)},dl=function(m,k){if(St(K.beforeSanitizeElements,m,null),ul(m,k))return!0;if(oi(m))return qt(m),!0;let E=ce(G(m));if(se=cl(K.uponSanitizeElement,se,gt,be),St(K.uponSanitizeElement,m,{tagName:E,allowedTags:se}),ul(m,k))return!0;if(Tg(m,E))return qt(m),!0;if(Ut[E]||!(Tt.tagCheck instanceof Function&&Tt.tagCheck(E))&&!se[E]){let U=Eg(m,E,k);return U===!1&&St(K.afterSanitizeElements,m,null),U}if(N(m)===it.element&&!xg(m)||(E==="noscript"||E==="noembed"||E==="noframes")&&$e(rx,m.innerHTML))return qt(m),!0;if(Ge&&m.nodeType===it.text){let U=ii(m.textContent);m.textContent!==U&&(Or(t.removed,{element:m.cloneNode()}),m.textContent=U)}return St(K.afterSanitizeElements,m,null),!1},hl=function(m,k,E){if(Yr[k]||al(k,m)||Et&&(k==="id"||k==="name")&&(E in n||E in Go))return!1;let I=le[k]||Tt.attributeCheck instanceof Function&&Tt.attributeCheck(k,m);return an&&$e(jr,k)||Lt&&$e(nn,k)?!0:I?ur[k]||$e(qr,Fr(E,_t,""))||(k==="src"||k==="xlink:href"||k==="href")&&m!=="script"&&tp(E,"data:")===0&&Jr[m]||Bt&&!$e(lt,Fr(E,_t,""))?!0:!E:pl(m)&&ai(et.tagNameCheck,m)&&ai(et.attributeNameCheck,k,m)||k==="is"&&et.allowCustomizedBuiltInElements&&ai(et.tagNameCheck,E)},Sg=te({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pl=function(m){return!Sg[zr(m)]&&$e(rn,m)},Rg=function(m,k,E,I){if($&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(m,k)){case"TrustedHTML":return re(I);case"TrustedScriptURL":return ke(I)}return I},Ag=function(m,k,E,I){try{E?m.setAttributeNS(E,k,I):m.setAttribute(k,I),oi(m)?qt(m):Jh(t.removed)}catch{sn(k,m)}},fl=function(m){St(K.beforeSanitizeAttributes,m,null);let k=m.attributes;if(!k||oi(m))return;le=cl(K.uponSanitizeAttribute,le,on,ct);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:le,forceKeepAttr:void 0},I=k.length,U=ce(m.nodeName);for(;I--;){let q=k[I],he=q.name,ge=q.namespaceURI,je=q.value,qe=ce(he),zo=je,We=he==="value"?zo:$b(zo);if(E.attrName=qe,E.attrValue=We,E.keepAttr=!0,E.forceKeepAttr=void 0,St(K.uponSanitizeAttribute,m,E),We=E.attrValue,tt&&(qe==="id"||qe==="name")&&tp(We,Zr)!==0&&(sn(he,m,q),We=Zr+We),Ae&&$e(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,We)){sn(he,m,q);continue}if(qe==="attributename"&&ep(We,"href")){sn(he,m,q);continue}if(!E.forceKeepAttr){if(!E.keepAttr){sn(he,m,q);continue}if(!Xr&&$e(ix,We)){sn(he,m,q);continue}if(Ge&&(We=ii(We)),!hl(U,qe,We)){sn(he,m,q);continue}We=Rg(U,qe,ge,We),We!==zo&&Ag(m,he,ge,We)}}St(K.afterSanitizeAttributes,m,null)},si=function(m){let k=null,E=ll(m);for(St(K.beforeSanitizeShadowDOM,m,null);k=E.nextNode();)if(St(K.uponSanitizeShadowNode,k,null),dl(k,m),fl(k),Fn(k.content)&&si(k.content),N(k)===it.element){let I=b(k);Fn(I)&&($o(I),si(I))}St(K.afterSanitizeShadowDOM,m,null)},$o=function(m){let k=[{node:m,shadow:null}];for(;k.length>0;){let E=k.pop();if(E.shadow){si(E.shadow);continue}let I=E.node,q=N(I)===it.element,he=w(I);if(he)for(let ge=he.length-1;ge>=0;--ge)k.push({node:he[ge],shadow:null});if(q){let ge=A?A(I):null;if(typeof ge=="string"&&ce(ge)==="template"){let je=I.content;Fn(je)&&k.push({node:je,shadow:null})}}if(q){let ge=b(I);Fn(ge)&&k.push({node:null,shadow:ge},{node:ge,shadow:null})}}};return t.sanitize=function(C){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,E=null,I=null,U=null;if(Gn=!C,Gn&&(C="<!-->"),typeof C!="string"&&!hr(C)&&(C=Bb(C),typeof C!="string"))throw Tn("dirty is not a string, aborting");if(!t.isSupported)return C;Nn?(se=be,le=ct):Oo(m),(K.uponSanitizeElement.length>0||K.uponSanitizeAttribute.length>0)&&(se=ot(se)),K.uponSanitizeAttribute.length>0&&(le=ot(le)),t.removed=[];let q=Dn&&typeof C!="string"&&hr(C);if(q){_g(C);let je=G(C);if(typeof je=="string"){let qe=ce(je);if(!se[qe]||Ut[qe])throw ni(C),Tn("root node is forbidden and cannot be sanitized in-place")}if(oi(C))throw ni(C),Tn("root node is clobbered and cannot be sanitized in-place");try{$o(C)}catch(qe){throw ni(C),qe}}else if(hr(C))k=sl("<!---->"),E=k.ownerDocument.importNode(C,!0),E.nodeType===it.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?k=E:k.appendChild(E),$o(E);else{if(!Kt&&!Ge&&!_e&&C.indexOf("<")===-1)return $&&Nt?re(C):C;if(k=sl(C),!k)return Kt?null:Nt?F:""}k&&mt&&qt(k.firstChild);let he=q?C:k;try{let je=ll(he);for(;I=je.nextNode();)dl(I,he),fl(I),Fn(I.content)&&si(I.content)}catch(je){throw q&&(ni(C),En(t.removed,qe=>{qe.element&&ri(qe.element)})),je}if(q)return En(t.removed,je=>{je.element&&ri(je.element)}),Ge&&Fo(C),C;if(Kt){if(Ge&&Fo(k),Fe)for(U=Re.call(k.ownerDocument);k.firstChild;)U.appendChild(k.firstChild);else U=k;return(le.shadowroot||le.shadowrootmode)&&(U=z.call(r,U,!0)),U}let ge=_e?k.outerHTML:k.innerHTML;return _e&&se["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&$e(tx,k.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
|
|
341
|
-
`+
|
|
342
|
-
|
|
343
|
-
`),n=t.length-1;for(;n
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
`)
|
|
348
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=tn(t[0],`
|
|
349
|
-
`).split(`
|
|
350
|
-
`),r="",i="",o=[];for(;n.length>0;){let a=!1,s=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))s.push(n[l]),a=!0;else if(!a)s.push(n[l]);else break;n=n.slice(l);let c=s.join(`
|
|
351
|
-
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
352
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
353
|
-
${c}`:c,i=i?`${i}
|
|
354
|
-
${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let p=d,g=n.join(`
|
|
355
|
-
`),y=p.raw+`
|
|
356
|
-
`+g.replace(this.rules.other.blockquoteSetextReplace2,""),w=this.blockquote(y);o[o.length-1]=w,r=`${r}
|
|
357
|
-
${g}`,i=i.substring(0,i.length-p.text.length)+w.text;break}else if(d?.type==="list"){let p=d,g=p.raw+`
|
|
358
|
-
`+n.join(`
|
|
359
|
-
`),y=this.list(g);o[o.length-1]=y,r=r.substring(0,r.length-d.raw.length)+y.raw,i=i.substring(0,i.length-p.raw.length)+y.raw,n=g.substring(o.at(-1).raw.length).split(`
|
|
360
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:o,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 o=this.rules.other.listItemRegex(n),a=!1;for(;e;){let l=!1,c="",u="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let h=nk(t[2].split(`
|
|
361
|
-
`,1)[0],t[1].length),d=e.split(`
|
|
362
|
-
`,1)[0],p=!h.trim(),g=0;if(this.options.pedantic?(g=2,u=h.trimStart()):p?g=t[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,u=h.slice(g),g+=t[1].length),p&&this.rules.other.blankLine.test(d)&&(c+=d+`
|
|
363
|
-
`,e=e.substring(d.length+1),l=!0),!l){let y=this.rules.other.nextBulletRegex(g),w=this.rules.other.hrRegex(g),v=this.rules.other.fencesBeginRegex(g),b=this.rules.other.headingBeginRegex(g),x=this.rules.other.htmlBeginRegex(g),T=this.rules.other.blockquoteBeginRegex(g);for(;e;){let A=e.split(`
|
|
364
|
-
`,1)[0],O;if(d=A,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),O=d):O=d.replace(this.rules.other.tabCharGlobal," "),v.test(d)||b.test(d)||x.test(d)||T.test(d)||y.test(d)||w.test(d))break;if(O.search(this.rules.other.nonSpaceChar)>=g||!d.trim())u+=`
|
|
365
|
-
`+O.slice(g);else{if(p||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(h)||b.test(h)||w.test(h))break;u+=`
|
|
366
|
-
`+d}p=!d.trim(),c+=A+`
|
|
367
|
-
`,e=e.substring(A.length+1),h=O.slice(g)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!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(h=>h.type==="space"),u=c.length>0&&c.some(h=>this.rules.other.anyLine.test(h.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 h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let 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=xp(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:tn(t[0],`
|
|
368
|
-
`),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=bp(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
369
|
-
`):[],o={type:"table",raw:tn(t[0],`
|
|
370
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(bp(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:tn(t[0],`
|
|
371
|
-
`),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)===`
|
|
372
|
-
`?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 o=tn(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=tk(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[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)),kp(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 o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return kp(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,o,a,s=i,l=0,c=r[0][0],u=n===c,h=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+i);(r=h.exec(t))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){s+=a;continue}else if(r[5]||r[6]){if(i%3&&!((i+a)%3)){l+=a;continue}if(u)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,p=e.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let y=p.slice(1,-1);return{type:"em",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}let g=p.slice(2,-2);return{type:"strong",raw:p,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,o,a,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+i);(r=l.exec(t))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(a=[...o].length,a!==i))continue;if(r[3]||r[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let c=[...r[0]][0].length,u=e.slice(0,i+r.index+c+a),h=u.slice(i,-i);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}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}}}},Qe=class Gs{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||An,this.options.tokenizer=this.options.tokenizer||new vo,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:ze,block:go.normal,inline:Hr.normal};this.options.pedantic?(n.block=go.pedantic,n.inline=Hr.pedantic):this.options.gfm&&(n.block=go.gfm,this.options.breaks?n.inline=Hr.breaks:n.inline=Hr.gfm),this.tokenizer.rules=n}static get rules(){return{block:go,inline:Hr}}static lex(t,n){return new Gs(n).lex(t)}static lexInline(t,n){return new Gs(n).inlineTokens(t)}lex(t){t=t.replace(ze.carriageReturn,`
|
|
373
|
-
`),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(ze.tabCharGlobal," ").replace(ze.spaceLine,""));let i=1/0;for(;t;){if(t.length<i)i=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
|
|
374
|
-
`:n.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
375
|
-
`)?"":`
|
|
376
|
-
`)+o.raw,s.text+=`
|
|
377
|
-
`+o.text,this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
378
|
-
`)?"":`
|
|
379
|
-
`)+o.raw,s.text+=`
|
|
380
|
-
`+o.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),n.push(o);continue}let a=t;if(this.options.extensions?.startBlock){let s=1/0,l=t.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(a=t.substring(0,s+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
|
|
381
|
-
`)?"":`
|
|
382
|
-
`)+o.raw,s.text+=`
|
|
383
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
384
|
-
`)?"":`
|
|
385
|
-
`)+o.raw,s.text+=`
|
|
386
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);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,o="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(o=""),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,o)){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,o)){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),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},u),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),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)!=="_"&&(o=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)}},wo=class{options;parser;constructor(e){this.options=e||An}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(ze.notSpaceStart)?.[0],i=e.replace(ze.endingNewline,"")+`
|
|
387
|
-
`;return r?'<pre><code class="language-'+Ct(r)+'">'+(n?i:Ct(i,!0))+`</code></pre>
|
|
388
|
-
`:"<pre><code>"+(n?i:Ct(i,!0))+`</code></pre>
|
|
389
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
390
|
-
${this.parser.parse(e)}</blockquote>
|
|
391
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
392
|
-
`}hr(e){return`<hr>
|
|
393
|
-
`}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let s=e.items[a];r+=this.listitem(s)}let i=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
|
|
394
|
-
`+r+"</"+i+`>
|
|
395
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
396
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
397
|
-
`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let o=e.rows[i];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
398
|
-
<thead>
|
|
399
|
-
`+t+`</thead>
|
|
400
|
-
`+r+`</table>
|
|
401
|
-
`}tablerow({text:e}){return`<tr>
|
|
402
|
-
${e}</tr>
|
|
403
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
404
|
-
`}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>${Ct(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=yp(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ct(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=yp(e);if(i===null)return Ct(n);e=i;let o=`<img src="${e}" alt="${Ct(n)}"`;return t&&(o+=` title="${Ct(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ct(e.text)}},Ks=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}},xt=class Os{options;renderer;textRenderer;constructor(t){this.options=t||An,this.options.renderer=this.options.renderer||new wo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ks}static parse(t,n){return new Os(n).parse(t)}static parseInline(t,n){return new Os(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 a=i,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let o=t[i];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){r+=s||"";continue}}let a=o;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},Wr=class{options;block;constructor(e){this.options=e||An}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?Qe.lex:Qe.lexInline}provideParser(e=this.block){return e?xt.parse:xt.parseInline}},bo=class{defaults=Fs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=xt;Renderer=wo;TextRenderer=Ks;Lexer=Qe;Tokenizer=vo;Hooks=Wr;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 o of i.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.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(o=>{let a=i[o].flat(1/0);n=n.concat(this.walkTokens(a,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 o=t.renderers[i.name];o?t.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),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 o=t[i.level];o?o.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 wo(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=n.renderer[a],l=i[a];i[a]=(...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 vo(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=n.tokenizer[a],l=i[a];i[a]=(...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 Wr;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,s=n.hooks[a],l=i[a];Wr.passThroughHooks.has(o)?i[a]=c=>{if(this.defaults.async&&Wr.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,c);return l.call(i,h)})();let u=s.call(i,c);return l.call(i,u)}:i[a]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,c);return h===!1&&(h=await l.apply(i,c)),h})();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,o=n.walkTokens;r.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),i&&(s=s.concat(i.call(this,a))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Qe.lex(e,t??this.defaults)}parser(e,t){return xt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(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 a=i.hooks?await i.hooks.preprocess(t):t,s=await(i.hooks?await i.hooks.provideLexer(e):e?Qe.lex:Qe.lexInline)(a,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?xt.parse:xt.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let a=(i.hooks?i.hooks.provideLexer(e):e?Qe.lex:Qe.lexInline)(t,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(e):e?xt.parse:xt.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
405
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Ct(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Rn=new bo;function ue(e,t){return Rn.parse(e,t)}ue.options=ue.setOptions=function(e){return Rn.setOptions(e),ue.defaults=Rn.defaults,_p(ue.defaults),ue};ue.getDefaults=Fs;ue.defaults=An;function ik(...e){return Rn.use(...e),ue.defaults=Rn.defaults,_p(ue.defaults),ue}ue.use=ik;ue.walkTokens=function(e,t){return Rn.walkTokens(e,t)};ue.parseInline=Rn.parseInline;ue.Parser=xt;ue.parser=xt.parse;ue.Renderer=wo;ue.TextRenderer=Ks;ue.Lexer=Qe;ue.lexer=Qe.lex;ue.Tokenizer=vo;ue.Hooks=Wr;ue.parse=ue;var YE=ue.options,XE=ue.setOptions,ZE=ue.walkTokens,QE=ue.parseInline;var JE=xt.parse,eS=Qe.lex;var Ip={"&":"&","<":"<",">":">",'"':""","'":"'"},ok=new RegExp(`[${Object.keys(Ip).join("")}]`,"g");function at(e){return e.replace(ok,t=>Ip[t])}var ak=["http:","https:","mailto:"],Mp=/^[a-z][a-z0-9+.-]*:/i,Gp=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Dp(e){let t=e.replace(Gp,""),n=Mp.exec(t);return n===null?t===""?null:e:ak.includes(n[0].toLowerCase())?e:null}var Wt="data-weave-target",Cn="data-weave-task";function To(e){return e?"Mark task incomplete":"Mark task complete"}var ko="note:",sk={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function lk(e){if(e.kind!=="note"||!e.id.startsWith(ko))return null;let t=e.id.slice(ko.length);return t===""?null:t}function Op(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 Fp(e){let t=Op(e);return t===null?null:`${t}:${e.detail.updated??""}`}function $p(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:Op(n)}function zp(e,t){if(e===null)return sk;let n=new Map;for(let i of e.model.nodes){let o=lk(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=t!==null&&(e.dangling[t]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:t}}function Hp(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function ck(e,t){if(e.currentSlug===null||Mp.test(t.replace(Gp,"")))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:Hp(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function uk(e){return e.hasGhosts}var dk=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function hk(e){let t=e.indexOf("[[");return t===-1?void 0:t}function pk(e){return{name:"wikilink",level:"inline",start:hk,tokenizer(t){return gk(t)},renderer(t){return fk(e,t)}}}function fk(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return mk(e,n,r)}function gk(e){let t=dk.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function mk(e,t,n){let r=at((n===""?t:n).trim());if(r==="")return"";let i=Hp(e,t);return i!==null?`<a class="weave-wiki" ${Wt}="${at(i)}" role="link" tabindex="0" title="${at(t.trim())}">${r}</a>`:uk(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${at(t.trim())}">${r}</span>`:r}function vk(e){let t=0;return new bo({gfm:!0,async:!1,extensions:[pk(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${Cn}="${t++}" aria-label="${To(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":at(n)},link({href:n,title:r,tokens:i}){let o=Dp(n),a=this.parser.parseInline(i),s=o===null?null:ck(e,o);if(s!==null){let c=r==null||r===""?"":` title="${at(r)}"`;return`<a class="weave-wiki" ${Wt}="${at(s)}" role="link" tabindex="0"${c}>${a}</a>`}return`<a${[o===null?"":` href="${at(o)}"`,r==null||r===""?"":` title="${at(r)}"`,o===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${a}</a>`},image({href:n,title:r,text:i}){let o=Dp(n);if(o===null)return at(i);let a=r==null||r===""?"":` title="${at(r)}"`;return`<img src="${at(o)}" alt="${at(i)}"${a}>`}}})}function wk(e,t){return vk(t).parse(e,{async:!1})}function xo(e){return Object.freeze(e)}var yk=xo({ALLOWED_TAGS:xo(["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:xo(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",Wt,Cn]),ADD_URI_SAFE_ATTR:xo([Wt,Cn]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function Vs(e,t,n){return e.sanitize(wk(t,n),yk)}var bk=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function xk(e){let t=[],n=e.replace(/\r\n?/g,`
|
|
406
|
-
`),r=0;for(let l of Qe.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 h=l.raw.indexOf(`
|
|
407
|
-
`,u),d=h===-1?l.raw.length:h,p=l.raw.slice(u,d).replace(/\r$/,""),g=bk.exec(p);g!==null&&t.push(c+u+g[1].length),u=h===-1?l.raw.length:h+1}}let i=new bo,o=l=>{let c=[];return i.walkTokens(Qe.lex(l,{gfm:!0}),u=>{u.type==="checkbox"&&c.push(u.checked)}),c},a=o(n),s=a.map(()=>null);for(let l of t){let c=`${n.slice(0,l)}${n[l]===" "?"x":" "}${n.slice(l+1)}`,u=o(c);if(u.length!==a.length)continue;let h=-1;for(let d=0;d<a.length;d+=1)if(u[d]!==a[d]){if(h!==-1){h=-1;break}h=d}h!==-1&&(s[h]=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]===`
|
|
408
|
-
`?2:1,u+=1;return c})}function Wp(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=xk(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function Up(e){let t=e?.getAttribute(Cn);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var Bp=32;function js(e){let t=e;for(let n=0;t!==null&&n<Bp;n++){let r=t.getAttribute(Wt);if(r!==null&&r!=="")return`${ko}${r}`;t=t.parentElement}return null}function Kp(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 Vp="edited",jp="created",qp="Edit",Yp="Done",Xp="Save",Zp="Saving…",Qp="Note body",Jp="Start writing…",ef="Raw notes",tf="Raw notes text",nf="Raw";function rf(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(`
|
|
409
|
-
`).length;return`${r} ${r===1?"line":"lines"}`}var Eo="Discard unsaved changes to this note?";function of(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:wn(e.source),provenanceTitle:Vn(e.source),updated:yr(e.updated,t),updatedIso:e.updated,created:yr(e.created,t),createdIso:e.created,tags:e.tags}}function af(e){return`#${e}`}var kk=200,_k=8,Tk="no note";function qs(e){let t=e;for(let n=0;t!==null&&n<Bp;n++){let r=t.getAttribute(Wt);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 Ek(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 Sk(e,t=kk){let n=Ek(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function sf(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:Tk,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} · ${Vn(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Sk(n.detail.preview??"")}}function lf(e,t,n,r,i,o,a=_k){let s=e+a,l=t+a;return s+n>i-a&&(s=e-a-n),l+r>o-a&&(l=t-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var _o={anchor:null,pointerX:0,pointerY:0};function cf(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:_o;case"dismiss":return _o}}function uf(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(ko)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function So(){let e=new Map,t=new Map,n=new Set,r=0,i=()=>n.forEach(a=>a()),o=a=>a.body!==a.baseline||a.raw!==a.rawBaseline;return{get:a=>e.get(a)??null,subscribe(a){return n.add(a),()=>n.delete(a)},open(a,s){if(e.has(a))return;let{head:l,tail:c}=va(s),{entries:u}=Ai(c);e.set(a,{body:l,baseline:l,tail:c,raw:u,rawBaseline:u,saving:!1}),i()},edit(a,s){let l=e.get(a);l===void 0||l.body===s||(l.body=s,i())},editRaw(a,s){let l=e.get(a);l===void 0||l.raw===s||(l.raw=s,i())},discard(a){e.delete(a)&&i()},isDirty(a){let s=e.get(a);return s!==void 0&&o(s)},dirtySlugs(){return[...e].filter(([,a])=>o(a)).map(([a])=>a)},async save(a,s){let l=e.get(a);if(l===void 0||l.saving||t.get(a)?.saving)return;let c=l.body,u=l.raw,h=u!==l.rawBaseline,d=h?ya(Ai(l.tail).opening,u):l.tail,p=wa(c,d);l.saving=!0,i();let g=!1;try{g=await s(a,p,h?{raw:!0}:void 0)}finally{if(e.get(a)===l){let y=t.get(a);g&&y!==void 0&&(y.body=p,y.version=++r,delete y.pending),g&&l.body===c&&l.raw===u?e.delete(a):(g&&(l.baseline=c,l.rawBaseline=u,l.tail=d),l.saving=!1),i()}}},nextLoadVersion(){return++r},getTaskBody(a,s){return t.get(a)?.body??s},taskBody(a,s,l){let c=t.get(a),u=!1;return c===void 0?(c={body:s,version:l,saving:!1},t.set(a,c)):l>c.version&&(c.saving?(c.pending===void 0||l>c.pending.version)&&(c.pending={body:s,version:l}):(u=c.body!==s,c.body=s,c.version=l)),u&&i(),c.body},isTaskSaving:a=>t.get(a)?.saving??!1,async saveTask(a,s,l){let c=t.get(a);if(c===void 0||c.saving||e.get(a)?.saving)return!1;c.saving=!0,i();let u=!1;try{return u=await l(a,s),u}finally{t.get(a)===c&&(u?(c.body=s,c.version=++r):c.pending!==void 0&&c.pending.version>c.version&&(c.body=c.pending.body,c.version=c.pending.version),delete c.pending,c.saving=!1,i())}},clearTaskSources(a){let s=!1;for(let l of a)s=t.delete(l)||s;s&&i()}}}function df(e,t,n,r){let i=new Set(t.panes.flatMap(s=>s.tabs.map(Rt))),o=new Set(n.panes.flatMap(s=>s.tabs.map(Rt))),a=[...i].filter(s=>s!==null&&s.startsWith("note:")&&!o.has(s)).map(s=>s.slice(5));return a.some(s=>e.isDirty(s))&&!r()?!1:(a.forEach(s=>e.discard(s)),e.clearTaskSources(a),!0)}function hf(e,t,n){let r=new Set(t);return e.dirtySlugs().filter(o=>r.has(o)).length>0&&!n()?!1:(r.forEach(o=>e.discard(o)),e.clearTaskSources([...r]),!0)}function pf(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 Rk=/^[ \t]*(?:#{1,6}[ \t]+|>[ \t]?|(?:[*+-]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)*/,Ak=/^[ \t]*(?:`{3,}|~{3,}|<!--|(?:[-*_][ \t]*){3,}$)/,Ck=/!?\[\[[^\]\n]*\]\]|!?\[[^\]\n]*\]\([^)\n]*\)|<[a-z][a-z0-9+.-]*:[^>\s]*>/gi;function Lk(e,t){let{start:n,end:r}=pf(e??"",t);if(n>=r)return t;let i=[],o=t.lastIndexOf(`
|
|
410
|
-
`,n-1)+1;for(;o<r;){let s=t.indexOf(`
|
|
411
|
-
`,o),l=s===-1?t.length:s,c=t.slice(o,l);if(!Ak.test(c)){let u=Rk.exec(c)[0].length,h=Math.max(n-o,u),d=Math.min(r,l)-o;for(let p of c.matchAll(Ck)){let g=p.index+p[0].length;h>p.index&&h<g&&(h=p.index),d>p.index&&d<g&&(d=g)}c.slice(h,d).trim()!==""&&i.push([o+h,o+d])}o=l+1}let a=t;for(let[s,l]of i.reverse())a=a.slice(0,s)+""+a.slice(s,l)+""+a.slice(l);return a}function ff(e,t){let n=[],r="",i=t;for(let o of e)o===""||o===""?(r!==""&&n.push({text:r,marked:i}),r="",i=o===""):r+=o;return r!==""&&n.push({text:r,marked:i}),{parts:n,inside:i}}var Nk={human:"You",agent:"Agent",outside:"Outside edit",system:"pi-weave"},Pk={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 Dk(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 Ro(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],o=pf(i?.body??"",r.body),a=o.end-o.start,s=[a>0?`+${a}`:"",o.removed>0?`−${o.removed}`:""].filter(Boolean).join(" "),l=Pk[r.op]??r.op;return{position:`${n+1} of ${e.length}`,action:r.op==="baseline"?l[0].toUpperCase()+l.slice(1):`${Nk[r.by]} ${l}`,at:Dk(r.at,i?.at??null),atIso:r.at,change:s,marked:Lk(i?.body??null,r.body),by:r.by}}function gf(e,t){return e+1<t?e+1:null}var mf="History",vf="Close history",Ys="History is off, so new changes are not being saved. Turn it on in Settings → Editor.",wf="Older versions were trimmed",yf="No saved versions yet. Changes are saved from now on.";function bf(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let o=t.nextNode();o!==null;o=t.nextNode())n.push(o);let r=!1,i=null;for(let o of n){let a=o.data;if(!r&&!a.includes("")&&!a.includes(""))continue;let s=ff(a,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 h=e.ownerDocument.createElement("mark");h.className="weave-replay-mark",h.append(u),l.append(h),i??=h}o.replaceWith(l)}return i}var Gk=80,Kr=e=>f("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:f("path",{d:e.d})});function xf(e){let{revisions:t,index:n,playing:r,enabled:i,trimmed:o,error:a}=e.state,s=Y(null),l=t===null?0:t.length-1;if(De(()=>{s.current?.style.setProperty("--weave-replay-at",`${l===0?100:n/l*100}%`)},[n,l]),a!==null)return f("div",{class:"weave-replay weave-replay-note",role:"status",children:a});if(t===null)return f("div",{class:"weave-replay weave-replay-note",role:"status",children:"Loading history…"});let c=Ro(t,n);return c===null?f("div",{class:"weave-replay weave-replay-note",role:"status",children:i?yf:Ys}):f("div",{class:"weave-replay",role:"group","aria-label":"Note history",children:[f("p",{class:"weave-replay-caption","aria-live":"polite",children:[f("span",{class:"weave-replay-clock",children:f(Kr,{d:"M9 3a6 6 0 1 0 0 12A6 6 0 0 0 9 3zM9 5.5V9l2.5 1.5"})}),f("span",{class:"weave-replay-position",children:["Version ",c.position]}),f("span",{class:`weave-replay-who weave-replay-${c.by}`,children:c.action}),f("span",{class:"weave-replay-time",title:c.atIso,children:c.at}),c.change===""?null:f("span",{class:"weave-replay-change",children:c.change}),o&&n===0?f("span",{class:"weave-replay-time",children:wf}):null]}),f("div",{class:"weave-replay-controls",children:[f("button",{type:"button","aria-label":"Previous version",disabled:n<=0,onClick:()=>e.onIndex(n-1),children:f(Kr,{d:"m11 4-5 5 5 5"})}),f("button",{type:"button",class:"weave-replay-play","aria-label":r?"Pause replay":"Play replay",disabled:l===0,onClick:e.onPlay,children:r?f(Kr,{d:"M5 4h3v10H5zM10 4h3v10h-3z",fill:!0}):f(Kr,{d:"M6 4v10l8-5z",fill:!0})}),f("button",{type:"button","aria-label":"Next version",disabled:n>=l,onClick:()=>e.onIndex(n+1),children:f(Kr,{d:"m7 4 5 5-5 5"})}),f("div",{class:"weave-replay-track",ref:s,children:[t.length>Gk||l===0?null:f("span",{class:"weave-replay-ticks","aria-hidden":"true",children:t.map((u,h)=>f("span",{class:`weave-replay-tick weave-replay-${u.by}${h>n?" weave-replay-ahead":""}`},h))}),f("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:f("p",{class:"weave-replay-hint",children:Ys})]})}var Fk="weave-preview-x",$k="weave-preview-y";function zk({view:e,open:t,editing:n,saving:r,taskSaving:i,onToggle:o,onSave:a,replaying:s,onHistory:l}){return f("header",{class:"weave-note-head",children:[f("h3",{class:"weave-note-title",children:e.title}),f("p",{class:"weave-note-meta",children:[n?f(me,{children:[f("button",{type:"button",class:"weave-note-save",disabled:r||i,onClick:a,children:r?Zp:Xp}),f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:Yp})]}):s?null:f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:qp}),n||l===null?null:f("button",{type:"button",class:"weave-note-edit weave-note-history","aria-pressed":s,onClick:l,children:s?vf:mf}),f("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:t,children:f("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),f("span",{class:`weave-prov weave-prov-${e.provenance}`,title:e.provenanceTitle,children:[e.provenanceGlyph," ",e.provenance]}),f("span",{class:"weave-note-time",title:e.updatedIso,children:[Vp," ",e.updated]}),f("span",{class:"weave-note-time",title:e.createdIso,children:[jp," ",e.created]})]}),f("p",{class:"weave-note-tags",children:e.tags.map(c=>f("span",{class:"weave-tag",children:af(c)},c))})]})}function kf(e){let t=Y(So()),n=e.drafts??t.current,r=Kl(),i=`${e.idPrefix??r}-weave-preview`,[o,a]=V(0);ee(()=>n.subscribe(()=>a(P=>P+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),c=$p(e.graph,e.selectedId),u=uf(e.selectedId,s,e.loadFailed),h=nt(()=>s===null?null:zp(e.graph,s.slug),[s,e.graph]),d=nt(()=>s===null||h===null?"":Vs(Is,l,h),[s,l,h]),[p,g]=V(_o),y=P=>{g(z=>cf(z,P))},w=Y(null),v=Y(null),b=Y(null),x=Y(!1),T=s===null?null:n.get(s.slug),[A,O]=V(!1),N=s!==null&&n.isTaskSaving(s.slug),G=async()=>{s!==null&&!n.isTaskSaving(s.slug)&&await n.save(s.slug,e.onSave)},$=async(P,z)=>{let K=()=>{P.checked=!P.checked,P.setAttribute("aria-label",To(P.checked))};if(s===null||n.isTaskSaving(s.slug)){K();return}let ye=Wp(n.getTaskBody(s.slug,s.body),z);if(ye===null){K();return}let Je=[...w.current?.querySelectorAll(`input[${Cn}]`)??[]];P.setAttribute("aria-label",To(P.checked));for(let kt of Je)kt.disabled=!0;try{await n.saveTask(s.slug,ye,e.onSave)||K()}catch(kt){throw K(),kt}finally{for(let kt of Je)kt.disabled=n.isTaskSaving(s.slug)}},F=Y(null);ee(()=>{s!==null&&F.current!==s.slug&&(F.current=s.slug,e.defaultEdit&&n.get(s.slug)===null&&(x.current=!0,n.open(s.slug,l)))},[s?.slug,e.defaultEdit]);let X=()=>{s===null||n.isTaskSaving(s.slug)||(n.get(s.slug)===null?(x.current=!0,n.open(s.slug,l)):(!n.isDirty(s.slug)||window.confirm(Eo))&&n.discard(s.slug))},Z=P=>{if(P.key==="Escape"){P.stopPropagation(),X();return}P.key.toLowerCase()!=="s"||!(P.metaKey||P.ctrlKey)||(P.preventDefault(),G())},Q=p.anchor===null?null:sf(e.graph,p.anchor);De(()=>{let P=b.current;P===null||!x.current||(x.current=!1,P.focus(),P.setSelectionRange(P.value.length,P.value.length))},[T!==null]);let[ne,re]=V(null),ke=Y(null),Ve=e.onHistory,He=()=>{if(s===null||Ve===void 0)return;if(ne!==null){ke.current=null,re(null);return}let P=s.slug;ke.current=P,re({revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:null}),Ve(P).then(z=>{ke.current===P&&re(z.ok?{revisions:z.data.revisions,enabled:z.data.enabled,trimmed:z.data.trimmed,index:Math.max(0,z.data.revisions.length-1),playing:!1,error:null}:{revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:`Could not load history: ${z.message}`})})},de=ne?.revisions==null?null:Ro(ne.revisions,ne.index),fe=nt(()=>de===null||h===null?null:Vs(Is,de.marked,h),[de?.marked,h]);if(De(()=>{ke.current=null,re(null),O(!1)},[s===null?null:s.slug]),De(()=>{fe===null||w.current===null||bf(w.current)?.scrollIntoView?.({block:"nearest"})},[fe]),ee(()=>{if(ne===null||!ne.playing||ne.revisions===null)return;let P=ne.revisions.length,z=window.setTimeout(()=>{re(K=>{if(K===null)return K;let ye=gf(K.index,P);return ye===null?{...K,playing:!1}:{...K,index:ye}})},900);return()=>window.clearTimeout(z)},[ne]),De(()=>{s!==null&&n.taskBody(s.slug,s.body,e.loadVersion)},[n,s===null?null:s.slug,s?.body,e.loadVersion]),De(()=>{y({type:"hide"})},[s===null?null:s.slug]),De(()=>{if(s===null)return;let P=n.isTaskSaving(s.slug);for(let z of w.current?.querySelectorAll(`input[${Cn}]`)??[])z.disabled=P},[s===null?null:s.slug,o,d]),De(()=>{let P=w.current;if(P!==null){let ye=p.anchor?.slug??null;for(let Je of P.querySelectorAll(`a[${Wt}]`))ye!==null&&Je.getAttribute(Wt)===ye?Je.setAttribute("aria-describedby",i):Je.removeAttribute("aria-describedby")}let z=v.current;if(z===null||Q===null)return;let K=lf(p.pointerX,p.pointerY,z.offsetWidth,z.offsetHeight,window.innerWidth,window.innerHeight);z.style.setProperty(`--${Fk}`,`${K.x}px`),z.style.setProperty(`--${$k}`,`${K.y}px`)},[p,Q,i]),c!==null){let P=e.graph?.model.nodes.find(ye=>ye.id===e.selectedId),z=P?.label??c,K=P===void 0?c:Fp(P)??c;return f("article",{class:"weave-note weave-note-artifact",children:[f("header",{class:"weave-note-head",children:[f("h3",{class:"weave-note-title",children:z}),f("p",{class:"weave-note-meta",children:f("span",{class:"weave-note-time",children:c})})]}),f("iframe",{class:"weave-artifact-frame",title:z,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(c)}`},K)]},K)}if(s===null||h===null)return f("p",{class:"weave-note-empty",children:u});let Re=of(s,e.now);return f("article",{class:`weave-note weave-note-${Re.provenance}`,children:[f(zk,{view:Re,open:()=>e.onOpen(s.slug),editing:T!==null,saving:T?.saving??!1,taskSaving:N,onToggle:X,onSave:()=>{G()},replaying:ne!==null,onHistory:Ve===void 0?null:He}),ne===null?null:f(xf,{state:ne,onIndex:P=>re(z=>z===null?z:{...z,index:P,playing:!1}),onPlay:()=>re(P=>{if(P===null||P.revisions===null)return P;if(P.playing)return{...P,playing:!1};let z=P.index>=P.revisions.length-1;return{...P,index:z?0:P.index,playing:!0}})}),T!==null?f(me,{children:[f("textarea",{ref:b,class:"weave-note-editor","aria-label":Qp,placeholder:Jp,spellcheck:e.spellcheck??!0,value:T.body,onInput:P=>n.edit(s.slug,P.target.value),onKeyDown:Z}),T.tail===""?null:f("section",{class:"weave-raw","aria-label":ef,"data-open":A?"":void 0,children:[f("div",{class:"weave-raw-head",children:[f("button",{type:"button",class:"weave-raw-toggle","aria-expanded":A,"aria-controls":`${e.idPrefix??r}-weave-raw`,onClick:()=>O(P=>!P),children:[f("svg",{class:"weave-raw-chevron",width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:f("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"})}),nf]}),f("span",{class:"weave-raw-hint",children:rf(T.raw,A)})]}),A?f("textarea",{id:`${e.idPrefix??r}-weave-raw`,class:"weave-raw-editor","aria-label":tf,spellcheck:e.spellcheck??!0,value:T.raw,onInput:P=>n.editRaw(s.slug,P.target.value),onKeyDown:Z}):null]})]}):f("div",{ref:w,class:"weave-note-body",tabIndex:-1,onMouseOver:P=>{let z=qs(P.target);y(z!==null?{type:"show",anchor:z,x:P.clientX,y:P.clientY}:{type:"hide"})},onMouseLeave:()=>y({type:"hide"}),onFocus:P=>{let z=qs(P.target);if(z===null)return;let K=P.target.getBoundingClientRect?.();y({type:"show",anchor:z,x:K?.left??0,y:K?.bottom??0})},onBlur:()=>y({type:"hide"}),onClick:P=>{let z=P.target,K=Up(z);if(K!==null&&fe!==null){P.preventDefault();return}if(K!==null){$(z,K);return}let ye=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(Kp(ye))return;let Je=js(P.target);Je!==null&&e.onSelect(Je,P.metaKey||P.ctrlKey||P.shiftKey)},onKeyDown:P=>{if(P.key==="Escape"&&p.anchor!==null){P.stopPropagation(),y({type:"dismiss"});return}if(P.key!=="Enter"&&P.key!==" ")return;let z=js(P.target);z!==null&&(P.preventDefault(),e.onSelect(z,P.metaKey||P.ctrlKey||P.shiftKey))},dangerouslySetInnerHTML:{__html:fe??d}}),Q===null?null:f("div",{ref:v,id:i,role:"tooltip",class:`weave-preview${Q.ghost?" weave-preview-ghost":""}`,children:[f("span",{class:"weave-preview-kind",children:Q.kind}),f("span",{class:"weave-preview-title",children:Q.title}),Q.text===""?null:f("p",{class:"weave-preview-text",children:Q.text})]})]},s.slug)}var _f=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Tf(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 Ef(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Sf(e){return e===null?!1:(e.focus(),!0)}function lr(){let e=Y(null);return ee(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Sf(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Ef(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(_f)??[]],r=Tf(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}function Cf(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 Hk(e){return Math.min(Math.max(e,0),10)*2}function Wk(e){return`note:${e}`}function Uk(e,t){return Cf(e.summary.title,t)+Hk(e.score)}function Bk(e,t){return Cf(e.label,t)}var Kk=["path","manifest","url","slug"];function Vk(e){for(let t of Kk){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}function jk(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 qk(e,t,n,r){let i=new Map;for(let o of e){let a=Wk(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Uk(o,t)})}for(let o of n){if(i.has(o.id))continue;let a=Bk(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Vk(o),badge:o.kind,score:a})}return[...i.values()].sort(jk).slice(0,20)}function Lf(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Xs(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Rf(e,t,n){return n<=0?0:((e+t)%n+n)%n}function Nf(e,t){return t===null?null:e[t]?.id??null}function Pf(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Xs(e,n);return t==="ArrowDown"?{...r,cursor:Rf(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Rf(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Xs(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}}var Ao="Search the workspace",Df="Search notes and repository…",If="↑↓ move · ↵ open · esc close";function Yk(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, modules, files and entry points."}function Xk(e){return e===1?"1 result":`${e} results`}function Af(e){return`weave-search-row-${e}`}function Mf(e,t){let n=qk(e.hits,e.answered,t?.model.nodes??[],e.query),r=Xs(e.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Af(a)})),status:Yk(e,n.length),count:n.length,countLabel:Xk(n.length),cursor:r,activeDomId:n.length?Af(r):null}}function Qk({row:e,onPick:t,onHover:n}){return f("li",{id:e.domId,role:"option","aria-selected":e.active,class:`weave-hit weave-hit-${e.kind}${e.active?" weave-hit-on":""}`,onMouseMove:n,onClick:r=>t(r.metaKey||r.ctrlKey),children:[f("span",{class:"weave-hit-badge",children:e.badge}),f("span",{class:"weave-hit-label",children:e.label}),f("span",{class:"weave-hit-detail",children:e.detail})]})}function Gf(e){let[t,n]=V(Lf),r=Y(0),i=Y(null),o=lr(),a=Y(null);ee(()=>{a.current?.focus()},[]),ee(()=>{let c=t.query.trim(),u=!0;if(!c)return i.current?.abort(),n(d=>({...d,hits:[],answered:"",loading:!1,failed:!1})),()=>{u=!1};let h=window.setTimeout(async()=>{let d=++r.current;i.current?.abort();let p=new AbortController;i.current=p,n(y=>({...y,loading:!0,failed:!1}));let g=await uc(e.ports.fetch,c,p.signal);!u||p.signal.aborted||d!==r.current||n(y=>g.ok?{...y,hits:g.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...y,loading:!1,failed:!0})},140);return()=>{u=!1,window.clearTimeout(h),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Mf(t,e.graph),l=(c,u=!1)=>{let h=Nf(s.rows,c);h!==null&&e.onSelect(h,u),e.onClose()};return f("div",{class:"weave-scrim",onClick:()=>l(null),children:f("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Ao,tabIndex:-1,ref:o.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{if(o.onKeyDown(c))return;let u=Pf(t.cursor,c.key,s.count);u.handled&&(c.preventDefault(),n(h=>({...h,cursor:u.cursor})),u.dismiss&&l(u.activate,c.metaKey||c.ctrlKey))},children:[f("input",{type:"search",class:"weave-palette-input",ref:a,value:t.query,placeholder:Df,"aria-label":Ao,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:c=>n(u=>({...u,query:c.currentTarget.value,cursor:0}))}),s.status===null?f("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Ao,children:s.rows.map((c,u)=>f(Qk,{row:c,onPick:h=>l(u,h),onHover:()=>n(h=>({...h,cursor:u}))},c.id))}):f("p",{class:"weave-palette-status",role:"status",children:s.status}),f("p",{class:"weave-palette-foot",children:[f("span",{children:s.countLabel}),f("button",{type:"button",class:"weave-chip",disabled:s.count===0,onClick:()=>l(t.cursor,!0),children:"Open in new tab"}),f("span",{class:"weave-palette-hint",children:[If," · ⌘/Ctrl ↵ new tab"]})]})]})})}function Zs(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Co=2e3,Jk=3e3,Ff=new Set;function e_(e,t){if(e===null)return Ff;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 Of(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function $f(e){let t=e.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([p,g])=>t[p]===g)||(t={...t,...d},e.setState(t))},a=e.defer??((d,p)=>{let g=setTimeout(d,p);return()=>clearTimeout(g)}),s=async()=>{let d=Of(t.selectedId);if(d===null){o({note:null,noteFailed:!1});return}let p=await da(e.fetch,d);p.ok?o({note:p.data,noteFailed:!1}):o({note:null,noteFailed:!0})},l=async()=>{let d=t.graph,p=await Si(e.fetch,t.graph);if(!p.ok)return t.graph===null&&o({graphFailed:!0}),p;if(!p.cached){let g=e_(d,p.data);o({graph:p.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=a(()=>{i=null,o({recentIds:Ff})},Jk))}return p},c=async()=>{if(!(n||r)){r=!0;try{let d=await l();Of(t.selectedId)!==null&&(t.note===null||d.ok&&!d.cached)&&await s()}finally{r=!1}}},h=(e.repeat??((d,p)=>{let g=setInterval(d,p);return()=>clearInterval(g)}))(()=>{c()},Co);return c(),{refresh:()=>{c()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function zf(e,t,n,r=(i,o)=>{let a=setTimeout(i,o);return()=>clearTimeout(a)}){let i=!1,o=null,a=async()=>{if(i)return;let s=await da(e,t);i||(n(s),s.ok||(o=r(()=>{a()},Co)))};return a(),()=>{i=!0,o?.()}}var Vr={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function No(e,t,n){return{id:e,target:t.id,label:rt(t),kind:t.kind,kindIcon:vn(t.kind),provenance:t.provenance,provenanceGlyph:wn(t.provenance),provenanceTitle:Vn(t.provenance),selected:t.id===n}}function t_(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:No(e.id,i,n)}function n_(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var r_=["link:links-to:"];function i_(e){return r_.some(t=>e.id.startsWith(t))}function o_(e){return e.id.startsWith("link:mentions:")}function a_(e,t,n,r){let i=[];for(let[o,a]of Object.entries(e.tags)){if(!a.includes(t))continue;let s=[];for(let l of a){if(l===t)continue;let c=n.get(`note:${l}`);c!==void 0&&s.push(No(`tag:${o}:${l}`,c,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function s_(e,t,n,r){let i=[];for(let o of e.edges){if(o.kind!=="mentions"||o.target!==t)continue;let a=n.get(o.source);a!==void 0&&i.push(No(`mentioned-by:${o.source}`,a,r))}return i}function l_(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var Lo={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 Qs(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function Hf(e,t){if(e===null)return Qs(Lo.loading);if(t===null)return Qs(Lo.noSelection);let n=gn(e),r=ba(n,t);if(r===null)return Qs(Lo.unknown);let i=n_(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>t_(d,i,t)).filter(d=>d!==null);a(Vr.links,s(r.links.filter(i_)));let l=xa(n.edges).get(t)??[];a(Vr.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>No(`backlink:${h.id}`,h,t))),a(Vr.mentions,[...s(r.links.filter(o_)),...s_(n,t,i,t)]);let c=l_(t),u=c===null?[]:a_(e,c,i,t);return o.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:Lo.isolated}:{subject:r.label,groups:o,tags:u,tagsCount:u.length,empty:null}}function Wf(){return{open:new Set,closed:new Set}}var c_=8;function Uf(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>c_}function u_(e){return e.some(t=>t.selected)}function Bf(e,t){let n=Uf(t,e.heading,e.count,u_(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function Kf(e,t){let n=Uf(t,Vr.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:Vr.tags,count:e.length,collapsed:n,rows:[]}}function Vf(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 Po(e){return`weave-ctx-panel-${e.toLowerCase()}`}function Ln(e){let t=Y(null);return f("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))}})}function jf(e){let t=e.turns[0];if(t===void 0)return null;let n=e.turns.find(r=>r.turn===e.shownTurn)??t;return f("section",{class:"weave-ctx-group weave-trail","aria-label":"What your agent recalled",children:[f("h4",{class:"weave-ctx-head weave-trail-head",children:[f("span",{class:"weave-trail-title",children:qa(n,n===t)}),f("span",{class:"weave-ctx-count",title:"Notes read or written",children:n.used}),n.steps.length===0?null:f("button",{type:"button",class:"weave-trail-replay",title:"Replay this turn's glow",onClick:()=>e.onReplay(n.turn),children:"Replay"})]}),n.steps.length===0?f("p",{class:"weave-trail-empty",children:pd}):null,f("ol",{class:"weave-trail-steps",children:n.steps.map(r=>f("li",{class:`weave-trail-step weave-trail-${r.kind}`,children:[f("span",{class:"weave-trail-verb",children:r.verb}),r.notes.map(i=>f("button",{type:"button",class:"weave-trail-note",onClick:o=>e.onSelect(i.id,o.metaKey||o.ctrlKey),children:i.label},i.id)),r.detail===null?null:f("span",{class:"weave-trail-detail",children:r.detail})]},r.key))}),e.turns.length<2?null:f("div",{class:"weave-trail-turns",role:"group","aria-label":"Earlier turns",children:e.turns.map((r,i)=>f("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:qa(r,i===0)},r.turn))})]})}function qf({row:e,onSelect:t}){return f("li",{class:`weave-ctx-row${e.selected?" weave-row-on":""}`,children:f("button",{type:"button",class:"weave-ctx-link",onClick:n=>t(n.metaKey||n.ctrlKey),children:[f("span",{class:"weave-kind","aria-hidden":"true",children:f(Gt,{name:e.kindIcon,class:"weave-icon"})}),f("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),f("span",{class:"weave-label",children:e.label})]})})}function Yf({view:e,onToggle:t}){return f("h4",{class:"weave-ctx-head",children:f("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!e.collapsed,"aria-controls":Po(e.heading),onClick:t,children:[f("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:f(Gt,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,f("span",{class:"weave-ctx-count",children:e.count})]})})}function d_({view:e,onSelect:t,onToggle:n}){return f("section",{class:"weave-ctx-group",children:[f(Yf,{view:e,onToggle:n}),f("ul",{class:"weave-ctx-rows",id:Po(e.heading),hidden:e.collapsed,children:e.rows.map(r=>f(qf,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function h_({tag:e,onSelect:t}){return f("li",{class:"weave-ctx-tag",children:[f("span",{class:"weave-tag",children:["#",e.tag]}),f("ul",{class:"weave-ctx-rows",children:e.siblings.map(n=>f(qf,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function Xf(e){let t=Y(null),n=Hf(e.graph,e.selectedId),[r,i]=V(Wf),o=s=>()=>i(Vf(r,s.heading,s.collapsed)),a=Kf(n.tags,r);return f("div",{class:"weave-rail","aria-label":wd.title,children:[e.trail===void 0?null:f(jf,{turns:e.trail,shownTurn:e.trailTurn??null,onSelect:e.onSelect,onReplay:s=>e.onReplay?.(s)}),n.empty===null?null:f("p",{class:"weave-ctx-empty",children:n.empty}),n.groups.map(s=>{let l=Bf(s,r);return f(d_,{view:l,onSelect:e.onSelect,onToggle:o(l)},s.heading)}),n.tags.length===0?null:f("section",{class:"weave-ctx-group",children:[f(Yf,{view:a,onToggle:o(a)}),f("ul",{class:"weave-ctx-tags weave-context-tags",ref:t,style:{height:e.tagHeight},id:Po(a.heading),hidden:a.collapsed,children:n.tags.map(s=>f(h_,{tag:s,onSelect:e.onSelect},s.tag))}),a.collapsed?null:f(Ln,{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 Zf(e){let t=null,n=!1,r=!1,i=async()=>{if(!(n||r)){r=!0;try{let s=await lc(e.fetch,t);if(n||!s.ok||s.cached)return;t=s.data,e.onTrail(s.data)}finally{r=!1}}},a=(e.repeat??((s,l)=>{let c=setInterval(s,l);return()=>clearInterval(c)}))(()=>{i()},Co);return i(),()=>{n=!0,a()}}function p_(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function Qf(e,t){let n=p_(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function Jf(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function eg(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function tg(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):Xt[e.key]}function ng(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function rg(e){return zn.every(t=>Object.is(e[t.key],Xt[t.key]))}function ig(e){return f("div",{class:"weave-settings-forces",children:[zn.map(t=>f("label",{class:"weave-setting-row",children:[f("span",{children:[f("strong",{children:t.label}),f("small",{children:t.hint})]}),f("span",{class:"weave-setting-range",children:[f("input",{"aria-label":t.label,type:"range",min:t.min,max:t.max,step:t.step,value:eg(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:tg(t,n.currentTarget.value)})}),f("output",{children:ng(e.forces[t.key])})]})]},t.key)),f("button",{type:"button",disabled:rg(e.forces),onClick:()=>e.onChange({...Xt}),children:"Reset graph layout"})]})}var og=["General","Appearance","Interface","Editor","Files","Backup"];function st(e){return f("label",{class:"weave-setting-row",children:[f("span",{children:[f("strong",{children:e.name}),f("small",{children:e.hint})]}),e.children]})}function ag(e){let[t,n]=V("General"),[r,i]=V(0),o=lr(),[a,s]=V(null),[l,c]=V(!1);ee(()=>{pa(we).then(p=>{p.ok&&s(p.data.enabled)})},[]);let u=p=>{s(p),c(!0),pa(we,p).then(g=>{s(g.ok?g.data.enabled:!p),c(!1)})},h=e.layout.preferences,d=p=>e.onChange({...e.layout,preferences:{...h,...p}});return f("div",{class:"weave-scrim weave-settings-scrim",onClick:e.onClose,children:f("div",{class:"weave-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",tabIndex:-1,ref:o.ref,onClick:p=>p.stopPropagation(),onKeyDown:p=>{o.onKeyDown(p)},children:[f("header",{children:[f("h2",{children:"Settings"}),f("button",{type:"button","aria-label":"Close settings",onClick:e.onClose,children:"×"})]}),f("nav",{"aria-label":"Settings categories",children:e.compact?f("select",{class:"weave-settings-category","aria-label":"Settings category",value:t,onChange:p=>n(p.currentTarget.value),children:og.map(p=>f("option",{value:p,children:p},p))}):og.map(p=>f("button",{type:"button","aria-current":t===p?"page":void 0,onClick:()=>n(p),children:p},p))}),f("section",{"aria-label":`${t} settings`,children:[f("h3",{children:t}),t==="General"?f(me,{children:[f("p",{children:["Pi Weave ",e.info.version]}),f("dl",{class:"weave-settings-locations",children:[f("dt",{children:"Vault"}),f("dd",{children:f("code",{children:e.info.vaultRoot||"Loading…"})}),f("dt",{children:"Repository"}),f("dd",{children:f("code",{children:e.cwd})})]}),f("div",{class:"weave-settings-actions",children:[f("button",{type:"button",onClick:()=>{i(p=>p+1),e.onRefresh()},children:[f("span",{class:r?"weave-refresh-spin":"","aria-hidden":"true",children:"↻"},r)," Refresh workspace"]}),f("a",{href:"https://github.com/EranYonai/pi-weave#readme",target:"_blank",rel:"noreferrer",children:"Documentation ↗"})]}),f("details",{children:[f("summary",{tabIndex:0,children:"Keyboard shortcuts"}),Bi(e.shortcut.slice(0,-1)).map(p=>f("div",{children:[f("h4",{children:p.title}),p.entries.map(g=>f("div",{class:"weave-key-row",children:[f("kbd",{children:g.combo}),f("span",{children:g.what})]},g.combo))]},p.title))]})]}):null,t==="Appearance"?f(me,{children:[f(st,{name:"Color scheme",hint:"System follows your device and uses your chosen light and dark themes.",children:f("select",{"aria-label":"Color scheme",value:e.layout.theme==="system"?"system":pe[e.layout.theme].scheme,onChange:p=>e.onChange({...e.layout,theme:p.currentTarget.value==="system"?"system":p.currentTarget.value==="light"?h.lightTheme:h.darkTheme}),children:[f("option",{value:"system",children:"System"}),f("option",{value:"light",children:"Light"}),f("option",{value:"dark",children:"Dark"})]})}),["light","dark"].map(p=>f(st,{name:`${p==="light"?"Light":"Dark"} theme`,hint:`Used in ${p} mode and by the ribbon theme button.`,children:f("select",{"aria-label":`${p==="light"?"Light":"Dark"} theme`,value:h[`${p}Theme`],onChange:g=>{let y=g.currentTarget.value;e.onChange({...e.layout,preferences:{...h,[`${p}Theme`]:y},theme:e.layout.theme!=="system"&&pe[e.layout.theme].scheme===p?y:e.layout.theme})},children:Object.entries(pe).filter(([,g])=>g.scheme===p).map(([g,y])=>f("option",{value:g,children:y.name},g))})},p)),f(st,{name:"Accent color",hint:"Choose independently of the theme. Shades adapt to light and dark backgrounds.",children:f("select",{"aria-label":"Accent color",value:h.accent,onChange:p=>d({accent:p.currentTarget.value}),children:[f("option",{value:"theme",children:"Theme default"}),Object.entries(un).map(([p,g])=>f("option",{value:p,children:g.name},p))]})}),f(st,{name:"Note font size",hint:"Applies to reading and editing notes.",children:f("span",{class:"weave-setting-range",children:[f("input",{"aria-label":"Note font size",type:"range",min:12,max:22,step:1,value:h.fontSize,onInput:p=>d({fontSize:Number(p.currentTarget.value)})}),f("output",{children:[h.fontSize,"px"]})]})})]}):null,t==="Interface"?f(me,{children:[f(st,{name:"Notes sidebar",hint:"Show files and recent notes.",children:f("input",{type:"checkbox",checked:e.layout.treeVisible,onChange:p=>e.onChange({...e.layout,treeVisible:p.currentTarget.checked})})}),f(st,{name:"Context sidebar",hint:"Show links, backlinks, and related items.",children:f("input",{type:"checkbox",checked:e.layout.contextVisible,onChange:p=>e.onChange({...e.layout,contextVisible:p.currentTarget.checked})})}),f(st,{name:"Color graph by group",hint:"Give each containment group its own color.",children:f("input",{type:"checkbox",checked:h.groupColors,onChange:p=>d({groupColors:p.currentTarget.checked})})}),f("h4",{children:"Graph layout"}),f("p",{class:"weave-settings-hint",children:"Adjust the graph live. Your choices are saved for this workspace."}),f(ig,{forces:h.forces,onChange:p=>d({forces:p})})]}):null,t==="Editor"?f(me,{children:[f(st,{name:"Spellcheck",hint:"Use your browser or device’s spellchecker while editing.",children:f("input",{type:"checkbox",checked:h.spellcheck,onChange:p=>d({spellcheck:p.currentTarget.checked})})}),f(st,{name:"Readable line length",hint:"Keep note text in a comfortable reading column.",children:f("input",{type:"checkbox",checked:h.readable,onChange:p=>d({readable:p.currentTarget.checked})})}),f(st,{name:"Open notes in editing mode",hint:"Newly opened notes start in the editor. Existing drafts are preserved.",children:f("input",{type:"checkbox",checked:h.defaultEdit,onChange:p=>d({defaultEdit:p.currentTarget.checked})})}),f(st,{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:f("input",{type:"checkbox",disabled:a===null||l,checked:a??!1,onChange:p=>u(p.currentTarget.checked)})})]}):null,t==="Files"?f(me,{children:[f(st,{name:"On startup",hint:"Choose which tabs appear when you reopen this workspace.",children:f("select",{"aria-label":"On startup",value:h.startup,onChange:p=>d({startup:p.currentTarget.value}),children:[f("option",{value:"restore",children:"Restore open tabs"}),f("option",{value:"empty",children:"Start with an empty tab"})]})}),f(st,{name:"Focus new tabs",hint:"Switch to notes opened in a new tab, including from the graph.",children:f("input",{type:"checkbox",checked:h.focusNewTabs,onChange:p=>d({focusNewTabs:p.currentTarget.checked})})}),f("h4",{children:"Deleting files"}),f("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"?f(me,{children:[f("h4",{children:"Download your vault"}),f("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."}),f("p",{children:"Save any unsaved edits first. The download contains files saved on disk. Backups are manual; store the ZIP somewhere safe."}),f("a",{class:"weave-settings-download",href:"/api/backup",download:!0,children:"Download vault ZIP"})]}):null]})]})})}function f_({group:e}){return f("div",{children:[f("p",{class:"weave-key-group",children:e.title}),e.entries.map(t=>f("div",{class:"weave-key-row",children:[f("kbd",{class:"weave-key-combo",children:t.combo}),f("span",{class:"weave-key-what",children:t.what})]},t.combo))]})}function sg(e){let t=lr(),n=e.shortcut.slice(0,-1);return f("div",{class:"weave-scrim",onClick:e.onClose,children:f("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":Qa,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[f("h2",{class:"weave-help-title",children:Qa}),f("div",{class:"weave-keys",children:Bi(n).map(r=>f(f_,{group:r},r.title))}),f("p",{class:"weave-help-foot",children:[f("button",{type:"button",class:"weave-chip",onClick:e.onClose,children:"close"}),f("span",{class:"weave-help-hint",children:Sd})]})]})})}function lg(e,t){let n=r=>{if(r.defaultPrevented)return;let i=_d(Td(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function cg({model:e}){return f("footer",{class:"weave-status",children:[f("span",{class:"weave-status-cwd",title:e.cwd,children:e.cwd}),f("span",{class:"weave-status-sel",title:"Current item",children:e.selection})]})}var ug="pi-weave.theme.v1";function Do(e){try{let t=e.getItem(ug);return $n(t)?t:null}catch{return null}}function dg(e,t){try{return e.setItem(ug,t),!0}catch{return!1}}function Io(e,t,n=Zt){return pe[el(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function el(e,t,n=Zt){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function hg(e){return e==="system"?null:e}function Js(e){return e==="system"?"System":pe[e].name}function pg(e,t="dark",n=Zt){return{glyph:e==="system"?"◐":pe[e].scheme==="light"?"○":"●",label:Js(e),hint:`Colour theme: ${Js(e)} — click for ${Js(Io(e,t,n))}`}}function Mo(e,t){if(e.kind==="graph")return"Graph view";let n=Rt(e);return n===null?"New tab":t?.model.nodes.find(r=>r.id===n)?.label??n.replace(/^[^:]+:/,"")}function m_(e){let[t]=V(e.visits);return f("div",{class:"weave-recents",children:vd(t,e.graph,e.selectedId).map(n=>f("button",{type:"button","aria-current":n.selected?"page":void 0,title:n.label,onClick:r=>e.onSelect(n.id,r.metaKey||r.ctrlKey),children:[f("span",{class:"weave-kind",children:f(Gt,{name:n.icon,class:"weave-icon"})}),f("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function v_(e){let t=Rt(e.tab),n=t?.startsWith("note:")?t.slice(5):null,[r,i]=V(null),o=Y(null),a=Y(e.tab.scroll),[s,l]=V(!1),[c,u]=V(""),[h,d]=V(!1),p=Y(null);De(()=>{s&&p.current?.focus()},[s]),ee(()=>{if(n===null)return;let w=e.drafts.nextLoadVersion();return zf(we,n,v=>{i({slug:n,note:v.ok?v.data:null,failed:!v.ok,version:w})})},[n,e.graph?.stamp,e.revision]);let g=r?.slug===n?r:null;if(De(()=>{let w=o.current?.querySelector(".weave-note");w!=null&&(w.scrollTop=a.current),n!==null&&e.drafts.get(n)!==null&&o.current?.querySelector(".weave-note-editor")?.focus()},[t,g?.note?.note.slug]),t===null)return f("div",{class:"weave-welcome",children:[f("span",{class:"weave-welcome-mark","aria-hidden":"true",children:"✳"}),f("h1",{children:"Your knowledge, connected."}),f("p",{children:"Ask your agent to write, organize, and connect your notes. Browse that knowledge here, or start a note yourself."}),f("div",{children:[f("button",{type:"button",onClick:e.onSearch,children:["Search workspace ",f("kbd",{children:"⌘K"})]}),f("button",{type:"button",onClick:e.onGraph,children:"Explore graph"}),f("button",{type:"button",onClick:()=>l(!0),children:"New note"})]}),s?f("form",{class:"weave-new-note",onSubmit:w=>{w.preventDefault(),!(h||!c.trim())&&(d(!0),e.onCreate(c.trim()).finally(()=>d(!1)))},onKeyDown:w=>{w.key==="Escape"&&(w.stopPropagation(),h||l(!1))},children:[f("label",{for:`new-note-${e.tab.id}`,children:"Note title"}),f("input",{id:`new-note-${e.tab.id}`,ref:p,required:!0,value:c,disabled:h,onInput:w=>u(w.currentTarget.value)}),f("div",{children:[f("button",{type:"submit",disabled:h||!c.trim(),children:h?"Creating…":"Create note"}),f("button",{type:"button",disabled:h,onClick:()=>l(!1),children:"Cancel"})]})]}):null]});let y=e.graph!==null&&!e.graph.model.nodes.some(w=>w.id===t);if(y||g?.failed&&e.drafts.isDirty(n??"")){let w=n===null?null:e.drafts.get(n);return w!==null&&n!==null&&e.drafts.isDirty(n)?f("div",{class:"weave-welcome",children:[f("h2",{children:y?"This item is no longer here":"This note could not be loaded"}),f("p",{children:["Your unsaved draft is preserved below. Select and copy it before closing this workspace. ",y?"Saving cannot restore or recreate the missing note.":"Reopen this tab to retry loading the note."]}),f("label",{class:"weave-note-meta",for:`missing-draft-${e.tab.id}`,children:"Unsaved draft (read-only)"}),f("textarea",{id:`missing-draft-${e.tab.id}`,class:"weave-note-editor","aria-label":"Unsaved draft for missing note",rows:16,readOnly:!0,value:w.body}),f("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]}):f("div",{class:"weave-welcome",children:[f("h2",{children:"This item is no longer here"}),f("p",{children:"It may have been moved or deleted. Your other tabs are still available."}),f("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]})}return f("div",{class:"weave-document",ref:o,onScrollCapture:w=>{let v=w.target;v.classList.contains("weave-note")&&(a.current=v.scrollTop,e.onScroll(v.scrollTop))},children:f(kf,{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:w=>{dc(we,w).then(v=>{v.ok?v.data.opened||window.alert("Could not open the note in an editor."):window.alert(v.message)})},onSave:e.onSave,onHistory:w=>bc(we,w),drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function fg(e){let[t,n]=V(Zs),[r,i]=V(()=>({...ra(),theme:Do(localStorage)??"system"})),[o,a]=V(null),[s,l]=V(!1),[c,u]=V(Date.now),[h,d]=V(null),[p,g]=V(Date.now),[y,w]=V(null),[v,b]=V(e.initialWidth),[x,T]=V(()=>Rr(window)),[A,O]=V(!1),[N,G]=V({version:"",vaultRoot:""}),[$,F]=V(!1),[X,Z]=V(0),[,Q]=V(0),[ne,re]=V(null),ke=Y(null),[Ve,He]=V(null),de=Y(null),[fe,Re]=V(null),[P,z]=V(null),[K,ye]=V(!1),[Je,kt]=V([]),[jr,nn]=V(!1),[lt]=V(So),_t=Y(null),rn=Y(null),qr=Y(location.hash),se=Y(!1),gt=Y(null),le=Y(null),on=Y(null),et=Y(null),[Ut,Yr]=V({left:0,top:0,width:600,height:500}),Tt=wr(r),Lt=dn(r),an=pg(r.theme,x,r.preferences),Bt=el(r.theme,x,r.preferences),Xr=nt(()=>({theme:Bt,accent:r.preferences.accent}),[Bt,r.preferences.accent]),Ge=Rt(Lt),Ae=Lt.kind==="graph"?ne:Ge,_e=r.panes.find(_=>_.tabs.some(R=>R.id===_.activeTab&&R.kind==="graph")),Nn=_e!==void 0&&(v>=850||_e.id===r.activePane),be=s&&Lt.kind==="document"&&!Nn,ct=v<1050?jr:r.contextVisible,mt=Nn||be&&ct&&Ge!==null,Kt=r.panes.some(_=>_.tabs.some(R=>R.kind==="graph")),Fe=Y({layout:r,overlay:o,selectedId:Ae,graphPreviewId:Ve,select:_=>{}}),Nt=_=>{Fe.current.graphPreviewId=_,He(_)};ee(()=>{Nt(null)},[mt,be,Ge]),ee(()=>{Ge!==null?(ke.current=Ge,re(Ge)):Lt.kind==="graph"&&re(ke.current)},[Lt.id,Lt.kind,Ge]);let Et=_=>{df(lt,Fe.current.layout,_,()=>window.confirm(Eo))&&i(_)},tt=(_,R=!1,B=r.activePane,L=!1)=>{let W=(_===null?Un:rc)(r,_,{newTab:R,paneId:B});Et(v<850&&!L?{...W,treeVisible:!1}:W),s||nn(!1)},Zr=()=>{let _=!(be&&ct);l(_),_&&(i(R=>({...xi(R),contextVisible:!0})),nn(!0))},Pn=()=>i(_=>({...oa(_),...v<850?{treeVisible:!1}:{}})),Dn=_=>{if(Nt(null),be){tt(_,!0);return}let R=r.panes.find(B=>B.id!==_e?.id);tt(_,!0,R?.id??_e?.id??r.activePane)},Vt=_=>{be||re(_),md(Fe.current.graphPreviewId,_)?Dn(_):Nt(_)};Fe.current={layout:r,overlay:o,selectedId:Ae,graphPreviewId:Ve,select:tt};let jt=_=>hf(lt,_,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),Qr=async(_,R,B)=>{let L=await pc(we,_,R,B?.raw===!0);return L.ok?(Z(W=>W+1),_t.current?.refresh(),!0):(window.alert(L.message),!1)},Jr=async(_,R)=>{let B=await hc(we,_);if(!B.ok)return window.alert(B.message),!1;let L=await Si(we);return n(W=>({...W,graph:L.ok?L.data:null,graphFailed:!L.ok})),lt.open(B.data.note.slug,B.data.note.body),Et(Un(Fe.current.layout,`note:${B.data.note.slug}`,{paneId:R})),_t.current?.refresh(),!0};ee(()=>lt.subscribe(()=>Q(_=>_+1)),[lt]),ee(()=>(_t.current=$f({fetch:we,state:Zs(),setState:n}),()=>_t.current?.stop()),[]),ee(()=>{let _=!0;return(async()=>{try{let R=await we("/api/workspace-state"),B=await R.json();if(!_)return;if(R.ok&&typeof B.viewId=="string"){rn.current=B.viewId,B.info&&G(B.info);let L=tc(B.layout);if(L){let W=nc(L);i(W),ke.current=Rt(dn(xi(W))),re(ke.current),kt(L.panes.flatMap(Te=>Te.tabs.flatMap(dt=>dt.history)).reduce(Ya,[]))}}else F(!0)}catch{_&&F(!0)}finally{_&&O(!0)}})(),()=>{_=!1}},[]),ee(()=>{if(!A||t.graph===null||se.current)return;se.current=!0;let _=Qf(qr.current,t.graph);_!==null&&i(R=>Un(R,_))},[A,t.graph]),ee(()=>{A&&kt(_=>Ya(_,Ae))},[A,Ae]),ee(()=>{A&&(history.replaceState(null,"",Jf(Ae)),document.documentElement.dataset.weaveTheme=Bt,document.documentElement.dataset.weaveScheme=pe[Bt].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,dg(localStorage,r.theme))},[A,Ae,r.theme,Bt,r.preferences.accent]);let cr=Y(Promise.resolve());ee(()=>{if(!A||!rn.current)return;let _=rn.current,R=window.setTimeout(()=>{cr.current=cr.current.then(async()=>{try{let B=await we("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:_,layout:r})});F(!B.ok)}catch{F(!0)}})},350);return()=>window.clearTimeout(R)},[r,A]),ee(()=>Zf({fetch:we,onTrail:_=>{d(_),w(null),g(Date.now())}}),[]);let ur=dd(h,p,y);ee(()=>{if(!ur){y!==null&&w(null);return}let _=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(_)},[ur]);let dr=nt(()=>ud(h,p,y),[h,p,y]),In=nt(()=>hd(h,t.graph),[h,t.graph]),Mn=_=>{let R=Date.now();g(R),w({turn:_,startedAt:R})};ee(()=>{let _=window.setInterval(()=>u(Date.now()),bd),R=()=>b(window.innerWidth);window.addEventListener("resize",R);let B=rd(window,T),L=dt=>{for(let ce of document.querySelectorAll(".weave-pane-menu[open]"))ce.contains(dt.target)||(ce.open=!1)};document.addEventListener("pointerdown",L);let W=dt=>{lt.dirtySlugs().length&&(dt.preventDefault(),dt.returnValue="")},Te=()=>{rn.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:rn.current,layout:Fe.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",Te),window.addEventListener("beforeunload",W),()=>{window.clearInterval(_),window.removeEventListener("resize",R),window.removeEventListener("beforeunload",W),window.removeEventListener("pagehide",Te),document.removeEventListener("pointerdown",L),B()}},[]),ee(()=>lg(document,{context:()=>({overlay:Fe.current.overlay,hasSelection:Fe.current.selectedId!==null}),run:_=>Ed(_,{setOverlay:a,fitGraph:()=>et.current?.(),clearSelection:()=>{dn(Fe.current.layout).kind==="graph"?(re(null),Nt(null)):Fe.current.select(null)},closeTab:()=>{let R=Fe.current.layout;Et(sa(R,R.activePane,dn(R).id))},toggleTheme:()=>i(R=>({...R,theme:Io(R.theme,Rr(window),R.preferences)})),focusSelector:R=>(R===Yn.graph?i(B=>({...oa(B),...window.innerWidth<850?{treeVisible:!1}:{}})):R===Yn.tree||R===Za?i(B=>({...B,treeVisible:!0})):i(xi),requestAnimationFrame(()=>{R===Yn.note&&Ui(document,".weave-pane-active .weave-note-editor")||!Ui(document,R)&&R===Yn.note&&Ui(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),De(()=>{for(let _ of r.panes)document.getElementById(`tab-${_.activeTab}`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[r.panes.map(_=>_.activeTab).join(","),r.activePane,v,A,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),De(()=>{let _=be?on.current:le.current,R=gt.current;if(!mt||!_||!R)return;let B=()=>{let W=_.getBoundingClientRect(),Te=R.getBoundingClientRect();Yr({left:W.left-Te.left,top:W.top-Te.top,width:W.width,height:W.height})};B();let L=new ResizeObserver(B);return L.observe(_),L.observe(R),()=>L.disconnect()},[be,mt,r,v]);let ut=(_,R)=>i(B=>({...B,panes:B.panes.map(L=>({...L,tabs:L.tabs.map(W=>W.id===_?{...W,scroll:R}:W)}))})),Pt=(_,R)=>{_i(r,_,de.current)===null&&!R.dataTransfer?.types.includes(Ar)||(R.preventDefault(),R.dataTransfer&&(R.dataTransfer.dropEffect=de.current===null?"copy":"move"),Re(null),z(_))},Gn=(_,R)=>{let B=gd(t.graph,R.dataTransfer?.getData(Ar)??"");if(B!==null){R.preventDefault(),tt(B,!0,_),z(null);return}let L=de.current;_i(r,_,L)!==null&&(R.preventDefault(),i(W=>{let Te=_i(W,_,L);return Te===null?W:Ti(W,Te,L)}),de.current=null,z(null),Re(null))},On=(_,R,B)=>{_.tabs.some(L=>L.id===de.current)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect="move",z(null),Re({paneId:_.id,before:R}))},ei=(_,R)=>{let B=de.current;B===null||!_.tabs.some(L=>L.id===B)||(R.preventDefault(),R.stopPropagation(),i(L=>ua(L,_.id,B,fe?.paneId===_.id?fe.before:null)),de.current=null,Re(null),z(null))},ti=_=>{let R=_.tabs.find(L=>L.id===_.activeTab),B=_.id===r.activePane;return f("section",{class:`weave-pane${B?" weave-pane-active":""}${P===_.id?" weave-pane-drop":""}`,"data-drop-label":de.current===null?"Open note here":"Move tab here","aria-label":`Workspace pane ${r.panes.indexOf(_)+1}`,onDragOver:L=>Pt(_.id,L),onDrop:L=>Gn(_.id,L),onDragLeave:L=>{L.currentTarget.contains(L.relatedTarget)||z(null)},hidden:v<850&&!B,onFocusCapture:()=>{B||i(L=>({...L,activePane:_.id}))},onPointerDown:()=>{B||i(L=>({...L,activePane:_.id}))},children:[f("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:L=>On(_,null,L),onDrop:L=>ei(_,L),children:[_.tabs.map(L=>f("div",{class:`weave-tab${L.id===R.id?" weave-tab-active":""}${fe?.paneId===_.id&&fe.before===L.id?" weave-tab-drop-before":""}${fe?.paneId===_.id&&fe.before===null&&L===_.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:W=>{let Te=W.currentTarget.getBoundingClientRect(),dt=W.clientX<Te.left+Te.width/2?L.id:_.tabs[_.tabs.indexOf(L)+1]?.id??null;On(_,dt,W)},onDrop:W=>ei(_,W),children:[f("button",{type:"button",role:"tab",title:Mo(L,t.graph),id:`tab-${L.id}`,"aria-selected":L.id===R.id,"aria-controls":`panel-${_.id}`,tabIndex:L.id===R.id?0:-1,draggable:!0,onDragStart:W=>{de.current=L.id,W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("application/x-weave-tab",L.id)},onClick:()=>i(aa(r,_.id,L.id)),onKeyDown:W=>{let Te=W.key==="ArrowRight"?1:W.key==="ArrowLeft"?-1:0;if(Te&&W.altKey&&!W.ctrlKey&&!W.metaKey){W.preventDefault(),W.stopPropagation();let Dt=_.tabs.indexOf(L),Go=Te<0?_.tabs[Math.max(0,Dt-1)].id:_.tabs[Dt+2]?.id??null;i(ua(r,_.id,L.id,Go)),requestAnimationFrame(()=>document.getElementById(`tab-${L.id}`)?.focus());return}if(!Te&&W.key!=="Home"&&W.key!=="End")return;W.preventDefault();let dt=W.key==="Home"?0:W.key==="End"?_.tabs.length-1:(_.tabs.indexOf(L)+Te+_.tabs.length)%_.tabs.length,ce=_.tabs[dt];i(aa(r,_.id,ce.id)),requestAnimationFrame(()=>document.getElementById(`tab-${ce.id}`)?.focus())},children:[f("span",{"aria-hidden":"true",children:L.kind==="graph"?"◌":"▤"}),f("span",{children:Mo(L,t.graph)}),lt.isDirty((Rt(L)??"").slice(5))?f("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),f("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${Mo(L,t.graph)}`,onClick:()=>Et(sa(r,_.id,L.id)),children:"×"})]},L.id)),f("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>tt(null,!0,_.id),children:"+"})]}),f("div",{class:"weave-pane-toolbar",children:[f("button",{type:"button","aria-label":"Navigate back",disabled:R.kind==="graph"||R.cursor===0,onClick:()=>Et(la({...r,activePane:_.id},_.id,-1)),children:"←"}),f("button",{type:"button","aria-label":"Navigate forward",disabled:R.kind==="graph"||R.cursor>=R.history.length-1,onClick:()=>Et(la({...r,activePane:_.id},_.id,1)),children:"→"}),f("span",{class:"weave-breadcrumb",children:Mo(R,t.graph)}),f("details",{class:"weave-pane-menu",onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),L.currentTarget.open=!1,L.currentTarget.querySelector("summary")?.focus())},children:[f("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),f("div",{onClick:L=>{let W=L.currentTarget.closest("details");W&&(W.open=!1)},children:[f("button",{type:"button",onClick:()=>i(ca({...r,activePane:_.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),f("button",{type:"button",onClick:()=>i(ca({...r,activePane:_.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?f(me,{children:[f("button",{type:"button",onClick:()=>i(Ti(r,_.id,R.id)),children:"Move tab to other pane"}),f("button",{type:"button",title:"Move all tabs to the other pane and close this pane",onClick:()=>i(ec(r,_.id)),children:"Close pane"})]}):null]})]})]}),f("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${_.id}`,"aria-labelledby":`tab-${R.id}`,...R.kind==="graph"?{ref:le}:{},children:R.kind==="document"?f(v_,{preferences:r.preferences,tab:R,graph:t.graph,drafts:lt,revision:X,now:c,onSelect:(L,W)=>tt(L,W,_.id),onSave:Qr,onScroll:L=>ut(R.id,L),onSearch:()=>a("search"),onGraph:Pn,onCreate:L=>Jr(L,_.id)},`${R.id}:${R.cursor}:${Rt(R)}`):null})]},_.id)};return f(me,{children:[f("div",{class:"weave-workbench",style:{"--weave-note-size":`${r.preferences.fontSize}px`,"--weave-reading-width":r.preferences.readable?"760px":"100%"},ref:gt,onDragEnd:()=>{de.current=null,z(null),Re(null)},children:[f("nav",{class:"weave-ribbon","aria-label":"Workspace tools",children:[f("button",{type:"button","aria-label":"Toggle notes sidebar","aria-pressed":r.treeVisible,title:"Notes",onClick:()=>i({...r,treeVisible:!r.treeVisible}),children:"▤"}),f("button",{type:"button","aria-label":"Open graph view",title:"Graph view",onClick:Pn,children:"◌"}),f("button",{type:"button","aria-label":"Toggle note graph",title:"Note graph","aria-pressed":be&&ct,onClick:Zr,children:f("svg",{viewBox:"0 0 20 20",width:18,height:18,fill:"none",stroke:"currentColor","stroke-width":1.5,"aria-hidden":"true",children:[f("rect",{x:"2",y:"2",width:"16",height:"16",rx:"3"}),f("circle",{cx:"10",cy:"10",r:"4"})]})}),f("button",{type:"button","aria-label":"Search notes and repository",title:xd(Hi(Wi(e.platform))),onClick:()=>a("search"),children:f("svg",{viewBox:"0 0 20 20",width:16,height:16,fill:"none",stroke:"currentColor","stroke-width":1.7,"aria-hidden":"true",children:[f("circle",{cx:"8.5",cy:"8.5",r:"5.5"}),f("path",{d:"m13 13 4 4"})]})}),f("span",{class:"weave-ribbon-space"}),f("button",{type:"button","aria-label":"Toggle context sidebar","aria-pressed":ct,title:"Context",onClick:()=>v<1050?nn(!jr):i({...r,contextVisible:!r.contextVisible}),children:"☷"}),f("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{_t.current?.refresh(),Z(_=>_+1)},children:"↻"}),f("button",{type:"button","aria-label":an.hint,title:an.hint,onClick:()=>i({...r,theme:Io(r.theme,x,r.preferences)}),children:an.glyph}),f("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>a("settings"),children:"⚙"})]}),f("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,v-90)}px`},children:[f("aside",{class:"weave-sidebar weave-sidebar-notes","aria-label":"Notes sidebar",children:[f("div",{class:"weave-sidebar-heading",children:[f("button",{type:"button","aria-pressed":!K,onClick:()=>ye(!1),children:"Files"}),f("button",{type:"button","aria-pressed":K,onClick:()=>ye(!0),children:"Recent"}),f("button",{type:"button","aria-label":"Hide notes sidebar",onClick:()=>{gt.current?.querySelector('[aria-label="Toggle notes sidebar"]')?.focus(),i({...r,treeVisible:!1})},children:"«"})]}),K?f(m_,{visits:Je,graph:t.graph,selectedId:Ae,onSelect:tt}):f(Ad,{graph:t.graph,selectedId:Ae,recentIds:t.recentIds,trail:dr,onSelect:(_,R,B)=>tt(_,R,r.activePane,B),onMutate:jt,onRefresh:()=>_t.current?.refresh(),now:c}),f("div",{class:"weave-vault-label",children:[f("span",{children:"Workspace"}),f("strong",{title:e.cwd,children:e.cwd.split(/[\\/]/).filter(Boolean).pop()??"Weave"})]})]}),f(Ln,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:_=>i(R=>({...R,treeWidth:Math.max(180,Math.min(420,R.treeWidth+_))}))})]}),f("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&v>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:A?r.panes.map((_,R)=>f(me,{children:[R>0&&v>=850?f(Ln,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:B=>{let L=r.split==="right"?gt.current?.querySelector("main")?.clientWidth:gt.current?.querySelector("main")?.clientHeight;i(W=>({...W,ratio:Math.max(.2,Math.min(.8,W.ratio+B/(L??800)))}))}}):null,ti(_)]})):f("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),f("div",{class:"weave-sidebar-dock weave-context-dock","data-open":ct,inert:!ct,"aria-hidden":!ct,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[f(Ln,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:_=>i(R=>({...R,contextWidth:Math.max(180,Math.min(400,R.contextWidth-_))}))}),f("aside",{class:"weave-sidebar weave-sidebar-context","aria-label":"Context sidebar",children:[f("div",{class:"weave-sidebar-heading",children:[f("strong",{children:"Context"}),f("button",{type:"button","aria-label":"Hide context sidebar",onClick:()=>{gt.current?.querySelector('[aria-label="Toggle context sidebar"]')?.focus(),nn(!1),i({...r,contextVisible:!1})},children:"»"})]}),be?f("section",{class:"weave-context-graph-section","aria-label":"Note connections",children:[f("div",{class:"weave-context-graph-heading",children:[f("strong",{children:"Note graph"}),f("button",{type:"button","aria-label":"Hide note graph",onClick:()=>{gt.current?.querySelector('[aria-label="Toggle note graph"]')?.focus(),l(!1)},children:"×"})]}),f("div",{class:"weave-context-graph-slot",ref:on,style:{height:r.contextGraphHeight},children:Ge===null?f("p",{children:"Select a note to see its connections."}):null}),f(Ln,{label:"Resize note graph",horizontal:!0,min:120,max:800,value:Ut.height,onChange:_=>i(R=>({...R,contextGraphHeight:Math.max(120,Math.min(800,(on.current?.clientHeight??R.contextGraphHeight)+_))}))})]}):null,f(Xf,{graph:t.graph,selectedId:Ae,onSelect:tt,trail:In,trailTurn:y?.turn??null,onReplay:Mn,tagHeight:r.contextTagsHeight,onTagResize:_=>i(R=>({...R,contextTagsHeight:_}))})]})]}),Kt||s?f("div",{class:`weave-graph-host${be?" weave-context-graph-host":""}`,onDragOver:_=>{!be&&_e&&Pt(_e.id,_)},onDrop:_=>{!be&&_e&&Gn(_e.id,_)},onDragLeave:_=>{_.currentTarget.contains(_.relatedTarget)||z(null)},onPointerDown:()=>{!be&&_e&&i(_=>({..._,activePane:_e.id}))},onFocusCapture:()=>{!be&&_e&&i(_=>({..._,activePane:_e.id}))},"aria-hidden":!mt,inert:!mt,role:be?"region":void 0,"aria-label":be?"Note graph":void 0,style:{...Ut,visibility:mt?"visible":"hidden",pointerEvents:mt?"auto":"none"},children:f(Ld,{graph:t.graph,selectedId:Ae,previewId:Ve,onSelect:Vt,onOpen:Dn,renderer:Xh,storage:localStorage,host:window,scheme:Xr,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:et,trail:dr})}):null]}),f("div",{class:"weave-footer",children:[f(cg,{model:yd(e.cwd,Ae)}),$?f("span",{role:"status",children:"Workspace restoration unavailable"}):null,lt.dirtySlugs().length?f("span",{children:[lt.dirtySlugs().length," unsaved"]}):null,v<850&&r.panes.length>1?f("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(_=>_.id!==Tt.id).id}),children:"Switch pane"}):null]}),o==="search"?f(Gf,{graph:t.graph,onSelect:tt,onClose:()=>a(null),ports:{fetch:we}}):null,o==="settings"?f(ag,{compact:v<=650,layout:r,info:N,cwd:e.cwd,shortcut:Hi(Wi(e.platform)),onChange:_=>{Et(_),nn(_.contextVisible)},onRefresh:()=>{_t.current?.refresh(),Z(_=>_+1)},onClose:()=>a(null)}):null,o==="help"?f(sg,{shortcut:Hi(Wi(e.platform)),onClose:()=>a(null)}):null]})}var gg=`
|
|
408
|
+
`,Bx=Ux,Op=WebGLRenderingContext,_p=Op.UNSIGNED_BYTE,ri=Op.FLOAT,Kx=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Fp=(function(e){function t(){return De(this,t),Xe(this,t,arguments)}return Qe(t,e),Ie(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Bx,FRAGMENT_SHADER_SOURCE:Dp,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Kx,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:_p,normalized:!0},{name:"a_id",size:4,type:_p,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=ur(s.color),g=d-c,y=h-u,v=g*g+y*y,w=0,b=0;v&&(v=1/Math.sqrt(v),w=-y*v*l,b=g*v*l);var _=this.array;_[i++]=c,_[i++]=u,_[i++]=d,_[i++]=h,_[i++]=w,_[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)}}])})(tl);var Yp=Dr(Ra()),Aa=(function(e){function t(){var n;return De(this,t),n=Xe(this,t),n.rawEmitter=n,n}return Qe(t,e),Ie(t)})(Yp.EventEmitter);var Jp=Dr(il());var Qx=function(t){return t},Jx=function(t){return t*t},ek=function(t){return t*(2-t)},tk=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},nk=function(t){return t*t*t},rk=function(t){return--t*t*t+1},ik=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},ef={linear:Qx,quadraticIn:Jx,quadraticOut:ek,quadraticInOut:tk,cubicIn:nk,cubicOut:rk,cubicInOut:ik},tf={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 Xp(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 Qp(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],y=t[4],v=t[5],w=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+y*a+v*l,e[4]=g*r+y*o+v*c,e[5]=g*i+y*s+v*u,e[6]=w*n+b*a+_*l,e[7]=w*r+b*o+_*c,e[8]=w*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 ak(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 hr(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=ak(t,n);return i?(pn(d,Qp(bt(),s,l)),pn(d,Ca(bt(),o)),pn(d,Xp(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,Xp(bt(),-a)),pn(d,Ca(bt(),1/o)),pn(d,Qp(bt(),-s,-l))),d}function nf(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 rf(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 af(e){if(!(0,Jp.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 of(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 al(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function ol(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 sl(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 ll(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:Rp,defaultDrawNodeLabel:nl,defaultDrawNodeHover:Ap,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:{}},ok={circle:ii},sk={arrow:Gp,line:Fp};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 sf(e){var t=Pa({},Da,e);return t.nodeProgramClasses=Pa({},ok,t.nodeProgramClasses),t.edgeProgramClasses=Pa({},sk,t.edgeProgramClasses),t}var xR=Dr(Ra()),kR=Dr(il()),Ma=1.5,lf=(function(e){function t(){var n;return De(this,t),n=Xe(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 Qe(t,e),Ie(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(H(H({},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=H(H({},tf),a),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:ef[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 y=c(g),v={};typeof l.x=="number"&&(v.x=d.x+(l.x-d.x)*y),typeof l.y=="number"&&(v.y=d.y+(l.y-d.y)*y),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=d.angle+(l.angle-d.angle)*y),typeof l.ratio=="number"&&(v.ratio=d.ratio+(l.ratio-d.ratio)*y),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=H(H({},At(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function ai(e){var t="x"in e?e:H(H({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function lk(e,t){return H(H({},jt(e,t)),{},{delta:ff(e)})}var ck=2;function Ga(e){for(var t=[],n=0,r=Math.min(e.length,ck);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 ff(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 gf=(function(e){function t(n,r){var i;return De(this,t),i=Xe(this,t),i.container=n,i.renderer=r,i}return Qe(t,e),Ie(t)})(Aa),uk=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],dk=uk.reduce(function(e,t){return H(H({},e),{},A({},t,Da[t]))},{}),hk=(function(e){function t(n,r){var i;return De(this,t),i=Xe(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",dk),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 Qe(t,e),Ie(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(),y=g.x+h,v=g.y+f;o.setState({x:y,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=ff(r);if(o){var s=lk(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}}])})(gf),pk=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],fk=pk.reduce(function(e,t){return H(H({},e),{},A({},t,Da[t]))},{}),gk=(function(e){function t(n,r){var i;return De(this,t),i=Xe(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",fk),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 Qe(t,e),Ie(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 Ne=i.startTouchesPositions[ct];return Ne&&(Te.x!==Ne.x||Te.y!==Ne.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var 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,y=this.renderer.viewportToFramedGraph(o[0]),v=y.x,w=y.y;c.setState({x:u.x+f-v,y:u.y+g-w});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},_=o[0],x=_.x,S=_.y,O=o[1],z=O.x,L=O.y,G=Math.atan2(L-S,z-x)-this.startTouchesAngle,I=Math.hypot(L-S,z-x)/this.startTouchesDistance,M=c.getBoundedRatio(u.ratio/I);b.ratio=M,b.angle=u.angle+G;var q=this.getDimensions(),Y=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),re=Math.min(q.width,q.height)-2*d,oe=re/q.width,be=re/q.height,lt=M/re,Be=x-re/2/oe,ve=S-re/2/be,ce=[Be*Math.cos(-b.angle)-ve*Math.sin(-b.angle),ve*Math.cos(-b.angle)+Be*Math.sin(-b.angle)];Be=ce[0],ve=ce[1],b.x=Y.x-Be*lt,b.y=Y.y+ve*lt,c.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(gf);function mk(e){if(Array.isArray(e))return _a(e)}function vk(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function wk(){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 cf(e){return mk(e)||vk(e)||qs(e)||wk()}function yk(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 cl(e,t){if(e==null)return{};var n,r,i=yk(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 uf=(function(){function e(t,n){De(this,e),this.key=t,this.size=n}return Ie(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),df=(function(){function e(){De(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 Ie(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 uf(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(uf.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 bk(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 hf=150,pf=50,qt=Object.prototype.hasOwnProperty;function xk(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 kk(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 _k=(function(e){function t(n,r){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(De(this,t),i=Xe(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 df),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",sl({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",al()),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=sf(a),Ia(i.settings),af(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 lf,i.bindCameraHandlers(),i.mouseCaptor=new hk(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new gk(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Qe(t,e),Ie(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=cl(i,[r].map(Hn));a.kill(),this.nodePrograms=o}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=cl(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=cl(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=Xs(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),s=Zs.apply(void 0,cf(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",H(H({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",H(H({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(o)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",H(H({},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",H(H({},s),{},{edge:r.hoveredEdge})),u&&r.emit("enterEdge",H(H({},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",H(H({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",H(H({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",H({},s))},this.activeListeners.handleEnter=function(a){var o=ai(a),s={event:o,preventSigmaDefault:function(){o.preventSigmaDefault()}};r.emit("enterStage",H({},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"),H(H({},c),{},{node:u}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(l.x,l.y);if(d)return r.emit("".concat(o,"Edge"),H(H({},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=Xs(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),o=Zs.apply(void 0,cf(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=rf(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=sl(this.customBBox||this.nodeExtent);var h=new lf,f=hr(h.getState(),o,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(o,a.labelGridCellSize);for(var g={},y={},v={},w={},b=1,_=i.nodes(),x=0,S=_.length;x<S;x++){var O=_[x],z=this.nodeDataCache[O],L=i.getNodeAttributes(O);z.x=L.x,z.y=L.y,this.normalizationFunction.applyTo(z),typeof z.label=="string"&&!z.hidden&&this.labelGrid.add(O,z.size,this.framedGraphToViewport(z,{matrix:f})),g[z.type]=(g[z.type]||0)+1}this.labelGrid.organize();for(var G in this.nodePrograms){if(!qt.call(this.nodePrograms,G))throw new Error('Sigma: could not find a suitable program for node type "'.concat(G,'"!'));this.nodePrograms[G].reallocate(g[G]||0),g[G]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=ol(this.nodeZExtent,function(Se){return r.nodeDataCache[Se].zIndex},_));for(var I=0,M=_.length;I<M;I++){var q=_[I];y[q]=b,w[y[q]]={type:"node",id:q},b++;var Y=this.nodeDataCache[q];this.addNodeToProgram(q,y[q],g[Y.type]++)}for(var re={},oe=i.edges(),be=0,lt=oe.length;be<lt;be++){var Be=oe[be],ve=this.edgeDataCache[Be];re[ve.type]=(re[ve.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(oe=ol(this.edgeZExtent,function(Se){return r.edgeDataCache[Se].zIndex},oe));for(var ce in this.edgePrograms){if(!qt.call(this.edgePrograms,ce))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ce,'"!'));this.edgePrograms[ce].reallocate(re[ce]||0),re[ce]=0}for(var Te=0,ct=oe.length;Te<ct;Te++){var Ne=oe[Te];v[Ne]=b,w[v[Ne]]={type:"edge",id:Ne},b++;var ae=this.edgeDataCache[Ne];this.addEdgeToProgram(Ne,v[Ne],re[ae.type]++)}return this.itemIDsIndex=w,this.nodeIndices=y,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=H({},r),c=s||this.nodeExtent,u=hn(c.x,2),d=u[0],h=u[1],f=hn(c.y,2),g=f[0],y=f[1],v=[this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y},{cameraState:r}),this.graphToViewport({x:h,y},{cameraState:r})],w=1/0,b=-1/0,_=1/0,x=-1/0;v.forEach(function(re){var oe=re.x,be=re.y;w=Math.min(w,oe),b=Math.max(b,oe),_=Math.min(_,be),x=Math.max(x,be)});var S=b-w,O=x-_,z=this.getDimensions(),L=z.width,G=z.height,I=0,M=0;if(S>=L?b<L-o?I=b-(L-o):w>o&&(I=w-o):b>L+o?I=b-(L+o):w<-o&&(I=w+o),O>=G?x<G-o?M=x-(G-o):_>o&&(M=_-o):x>G+o?M=x-(G+o):_<-o&&(M=_+o),I||M){var q=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Y=this.viewportToFramedGraph({x:I,y:M},{cameraState:r});I=Y.x-q.x,M=Y.y-q.y,l.x+=I,l.y+=M}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);ll(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<-hf||d>this.width+hf||h<-pf||h>this.height+pf)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,y=this.nodePrograms[c.type],v=y?.drawLabel||g;v(a,H(H({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=bk({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ll(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],y=g?.drawLabel||f;y(r,H(H({key:l},h),{},{size:this.scaleSize(h.size)}),H(H(H({key:c[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),H(H(H({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],y=r.framedGraphToViewport(g),v=y.x,w=y.y,b=r.scaleSize(g.size),_=r.settings.defaultDrawNodeHover,x=r.nodePrograms[g.type],S=x?.drawHover||_;S(i,H(H({key:f},g),{},{size:b,x:v,y:w}),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=hr(s,l,c,u),this.invMatrix=hr(s,l,c,u,!0),this.correctionRatio=nf(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 y=this.edgePrograms[g];y.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=xk(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=kk(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 df,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=of(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=H({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 H({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var a=H({},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=H({},this.settings);return this.settings=H(H({},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=al(),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 y=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],v=0,w=y.length;v<w;v++){var b=y[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(H(H({},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},y=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(y.x-v.x)*(1-f)+l,y:(y.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?hr(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?hr(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),mf=_k;var bf=Dr(Ra(),1);function Tk(){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 Me=Tk;typeof Object.assign=="function"&&(Me=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 Ue(e){return typeof e=="object"&&e!==null}function xf(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 vf(e){return!(!Ue(e)||e.attributes&&!Array.isArray(e.attributes))}function Sk(){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 fr(){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)}},D=class e extends ci{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},j=class e extends ci{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function kf(e,t){this.key=e,this.attributes=t,this.clear()}kf.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 _f(e,t){this.key=e,this.attributes=t,this.clear()}_f.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Tf(e,t){this.key=e,this.attributes=t,this.clear()}Tf.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function gr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}gr.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)};gr.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};gr.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]};gr.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 Sf=0,Ef=1,Ek=2,Rf=3;function Zt(e,t,n,r,i,a,o){let s,l,c,u;if(r=""+r,n===Sf){if(s=e._nodes.get(r),!s)throw new D(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,u=a}else if(n===Rf){if(i=""+i,l=e._edges.get(i),!l)throw new D(`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 D(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===Ef?s=l.source:s=l.target,c=i,u=a}return[s,c,u]}function Rk(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 Ak(e,t,n){e.prototype[t]=function(r,i){let[a]=Zt(this,t,n,r,i);return a.attributes}}function Ck(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 Lk(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 Nk(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 Pk(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 Dk(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);if(!Ue(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 Ik(e,t,n){e.prototype[t]=function(r,i,a){let[o,s]=Zt(this,t,n,r,i,a);if(!Ue(s))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return Me(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Mk(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 Gk=[{name:e=>`get${e}Attribute`,attacher:Rk},{name:e=>`get${e}Attributes`,attacher:Ak},{name:e=>`has${e}Attribute`,attacher:Ck},{name:e=>`set${e}Attribute`,attacher:Lk},{name:e=>`update${e}Attribute`,attacher:Nk},{name:e=>`remove${e}Attribute`,attacher:Pk},{name:e=>`replace${e}Attributes`,attacher:Dk},{name:e=>`merge${e}Attributes`,attacher:Ik},{name:e=>`update${e}Attributes`,attacher:Mk}];function Ok(e){Gk.forEach(function({name:t,attacher:n}){n(e,t("Node"),Sf),n(e,t("Source"),Ef),n(e,t("Target"),Ek),n(e,t("Opposite"),Rf)})}function Fk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]}}function $k(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function zk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function Hk(e,t,n){e.prototype[t]=function(r,i,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new j(`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 D(`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 Wk(e,t,n){e.prototype[t]=function(r,i,a){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new j(`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 D(`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 Uk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`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 Bk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Ue(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 Kk(e,t,n){e.prototype[t]=function(r,i){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Ue(i))throw new $(`Graph.${t}: provided attributes are not a plain object.`);return Me(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data: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 j(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new j(`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 D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new j(`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 D(`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 jk=[{name:e=>`get${e}Attribute`,attacher:Fk},{name:e=>`get${e}Attributes`,attacher:$k},{name:e=>`has${e}Attribute`,attacher:zk},{name:e=>`set${e}Attribute`,attacher:Hk},{name:e=>`update${e}Attribute`,attacher:Wk},{name:e=>`remove${e}Attribute`,attacher:Uk},{name:e=>`replace${e}Attributes`,attacher:Bk},{name:e=>`merge${e}Attributes`,attacher:Kk},{name:e=>`update${e}Attributes`,attacher:Vk}];function qk(e){jk.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var Yk=[{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 Zk(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 Xk(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 ul(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 Qk(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 Jk(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 dl(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 e0(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 Af(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 t0(e,t){if(e.size===0)return fr();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 hl(e,t,n,r,i,a){let o=t?Xk:Zk,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 n0(e,t,n,r){let i=[];return hl(!1,e,t,n,r,function(a){i.push(a)}),i}function r0(e,t,n){let r=fr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Yt(r,ul(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Yt(r,ul(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Yt(r,ul(n.undirected))),r}function pl(e,t,n,r,i,a,o){let s=n?Jk:Qk,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 i0(e,t,n,r,i){let a=[];return pl(!1,e,t,n,r,i,function(o){a.push(o)}),a}function a0(e,t,n,r){let i=fr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=Yt(i,dl(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=Yt(i,dl(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=Yt(i,dl(n.undirected,r))),i}function o0(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 e0(this,r);if(arguments.length===1){a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new D(`Graph.${n}: could not find the "${a}" node in the graph.`);return n0(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 D(`Graph.${n}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new D(`Graph.${n}: could not find the "${o}" target node in the graph.`);return i0(r,this.multi,i,s,o)}throw new $(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function s0(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,Af(!1,this,r,d);if(arguments.length===2){c=""+c,d=u;let h=this._nodes.get(c);if(typeof h>"u")throw new D(`Graph.${a}: could not find the "${c}" node in the graph.`);return hl(!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 D(`Graph.${a}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new D(`Graph.${a}: could not find the "${u}" target node in the graph.`);return pl(!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,y,v,w,b,_,x)=>{d[f++]=u(g,y,v,w,b,_,x)})}else d=[],c.push((h,f,g,y,v,w,b)=>{d.push(u(h,f,g,y,v,w,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,y,v,w,b)=>{u(h,f,g,y,v,w,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,y,v,w,b,_)=>{h=u(h,f,g,y,v,w,b,_)}),this[a].apply(this,c),h}}function l0(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,Af(!0,this,r,u);if(arguments.length===2){l=""+l,u=c;let d=this._nodes.get(l);if(typeof d>"u")throw new D(`Graph.${a}: could not find the "${l}" node in the graph.`);return hl(!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 D(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new D(`Graph.${a}: could not find the "${c}" target node in the graph.`);return pl(!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,y,v,w)=>c(d,h,f,g,y,v,w)),!!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,y,v,w)=>!c(d,h,f,g,y,v,w)),!this[a].apply(this,l)}}function c0(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 fr();if(!arguments.length)return t0(this,r);if(arguments.length===1){o=""+o;let l=this._nodes.get(o);if(!l)throw new D(`Graph.${a}: could not find the "${o}" node in the graph.`);return r0(r,i,l)}if(arguments.length===2){o=""+o,s=""+s;let l=this._nodes.get(o);if(!l)throw new D(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new D(`Graph.${a}: could not find the "${s}" target node in the graph.`);return a0(r,i,l,s)}throw new $(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function u0(e){Yk.forEach(t=>{o0(e,t),s0(e,t),l0(e,t),c0(e,t)})}var d0=[{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 fl(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 h0(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 fl(!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 p0(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=fr(),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 f0(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 D(`Graph.${n}: could not find the "${a}" node in the graph.`);return h0(r==="mixed"?this.type:r,i,o)}}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){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let d=this._nodes.get(c);if(typeof d>"u")throw new D(`Graph.${a}: could not find the "${c}" node in the graph.`);fl(!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 m0(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 D(`Graph.${o}: could not find the "${c}" node in the graph.`);return fl(!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 v0(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 fr();o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new D(`Graph.${a}: could not find the "${o}" node in the graph.`);return p0(r==="mixed"?this.type:r,i,s)}}function w0(e){d0.forEach(t=>{f0(e,t),g0(e,t),m0(e,t),v0(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 y0(e,t){let n={key:e};return xf(t.attributes)||(n.attributes=Me({},t.attributes)),n}function b0(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return xf(n.attributes)||(r.attributes=Me({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function x0(e){if(!Ue(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&&(!Ue(e.attributes)||e.attributes===null))throw new $("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function k0(e){if(!Ue(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&&(!Ue(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 _0=Sk(),T0=new Set(["directed","undirected","mixed"]),wf=new Set(["domain","_events","_eventsCount","_maxListeners"]),S0=[{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"}],E0={allowSelfLoops:!0,multi:!1,type:"mixed"};function R0(e,t,n){if(n&&!Ue(n))throw new $(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new j(`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 yf(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 Cf(e,t,n,r,i,a,o,s){if(!r&&e.type==="undirected")throw new j(`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 j(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Ue(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 j(`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 D(`Graph.${t}: source node "${a}" not found.`);if(!c)throw new D(`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 j(`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 j(`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 gr(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 A0(e,t,n,r,i,a,o,s,l){if(!r&&e.type==="undirected")throw new j(`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 j(`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(!Ue(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 j(`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 j(`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 Me(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 j(`Graph.${t}: the "${i}" edge already exists in the graph.`);let y=!1,v=!1;u||(u=yf(e,a,{}),y=!0,a===o&&(d=u,v=!0)),d||(d=yf(e,o,{}),v=!0),h=new gr(r,i,u,d,s),e._edges.set(i,h);let w=a===o;return r?(u.undirectedDegree++,d.undirectedDegree++,w&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,d.inDegree++,w&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,g.key=i,e.emit("edgeAdded",g),[i,!0,y,v]}function pr(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 de=class e extends bf.EventEmitter{constructor(t){if(super(),t=Me({},E0,t),typeof t.multi!="boolean")throw new $(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!T0.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"?kf:t.type==="directed"?_f:Tf;xt(this,"NodeDataClass",n);let r="geid_"+_0()+"_",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),wf.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 j("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 D(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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 j("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 D(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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 j("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 D(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`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 D(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return R0(this,t,n).key}mergeNode(t,n){if(n&&!Ue(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&&(Me(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 D(`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 pr(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do pr(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do pr(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 D(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new D(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return pr(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new j("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 j("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 D(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return pr(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new j("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 j("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 D(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return pr(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(!Ue(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(!Ue(t))throw new $("Graph.mergeAttributes: provided attributes are not a plain object.");return Me(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&&!vf(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&&!vf(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++]=y0(a,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,a)=>{r[n++]=b0(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(!Ue(t))throw new $("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Ue(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],x0(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],k0(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(Me({},this._options,t));return n.replaceAttributes(Me({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let a=Me({},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 j(`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 j("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 j("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,Cf(n,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,Me({},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)&&!wf.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"&&(de.prototype[Symbol.for("nodejs.util.inspect.custom")]=de.prototype.inspect);S0.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?Cf:A0;e.generateKey?de.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,a,o,t==="update")}:de.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,a,o,s,t==="update")}})});Ok(de);qk(de);u0(de);w0(de);var Fa=class extends de{constructor(t){let n=Me({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 de{constructor(t){let n=Me({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 de{constructor(t){let n=Me({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 de{constructor(t){let n=Me({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 de{constructor(t){let n=Me({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 mr(e){e.from=function(t,n){let r=Me({},t.options,n),i=new e(r);return i.import(t),i}}mr(de);mr(Fa);mr($a);mr(za);mr(Ha);mr(Wa);de.Graph=de;de.DirectedGraph=Fa;de.UndirectedGraph=$a;de.MultiGraph=za;de.MultiDirectedGraph=Ha;de.MultiUndirectedGraph=Wa;de.InvalidArgumentsGraphError=$;de.NotFoundGraphError=D;de.UsageGraphError=j;function C0(){return new de({multi:!0,type:"directed"})}function gl(e){let t=C0();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 Lf(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 ml(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var Nf=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function Pf(e,t,n){let r=null,i=gl({nodes:[],edges:[]}),a=null,o=null,s="neighbourhood",l=new Map,c=0,u=0,d=null,h=0,f=()=>{},g=()=>{},y=()=>{},v=()=>{},w=()=>{},b=null,_=!1,x=L=>{if(b===null)return;let G=b;b=null,r?.setSetting("enableCameraPanning",!0),(L===null||L===G)&&w(G)},S=()=>hd([...ml(i).values()]),O=L=>{let G=md(a,o,c,s),I=bd(a,o,c,s),M=l;L.setSetting("nodeReducer",(q,Y)=>{let re={...Y,...G(q,Y,t)};return{...re,...xd(M.get(q),re,t,Y.label)}}),L.setSetting("edgeReducer",(q,Y)=>({...Y,...I(q,Y,t)}))},z=()=>{if(n===void 0||d!==null)return;h=n.now();let L=()=>{d=null;let G=n.now();if(c=wd(c,u,G-h),h=G,r!==null&&O(r),c===u){c===0&&(a=null);return}d=n.request(L)};d=n.request(L)};return{mount(L){if(r!==null)return;let G=e(i,L,_d(t));G.on("clickNode",({node:I})=>{_||f(I)}),G.on("doubleClickNode",({node:I,preventSigmaDefault:M})=>{M(),_||f(I)}),G.on("clickStage",()=>f(null)),G.on("downNode",({node:I})=>{b=I,_=!1,r?.setSetting("enableCameraPanning",!1),y(I)}),G.on("moveBody",I=>{b!==null&&(_=!0,I.preventSigmaDefault(),v(b,G.viewportToGraph({x:I.event.x,y:I.event.y})))}),G.on("enterNode",({node:I})=>g(I)),G.on("leaveNode",()=>g(null)),G.on("upNode",()=>x(b)),G.on("upStage",()=>x(null)),O(G),G.setSetting("labelRenderedSizeThreshold",fs(i.order)),G.setCustomBBox(S()),r=G},setGraph(L){i=gl(L),r?.setGraph(i),r?.setSetting("labelRenderedSizeThreshold",fs(i.order)),r?.setCustomBBox(S())},setPositions(L){Lf(i,L),r?.refresh()},setHighlight(L,G=null,I="neighbourhood"){if(n===void 0){a=L,o=G,s=I,c=L===null?0:1,u=c,r!==null&&O(r);return}if(L===null){if(u=0,a===null)return}else a=L,o=G,s=I,u=1;r!==null&&O(r),c!==u&&z()},setTrail(L){l=L,r!==null&&O(r)},onSelect(L){f=L},onHover(L){g=L},onDragStart(L){y=L},onDragMove(L){v=L},onDragEnd(L){w=L},fit(){let L=r;L!==null&&(L.setCustomBBox(S()),L.getCamera().animatedReset().then(()=>{r===L&&L.refresh()},()=>{}))},positions(){return ml(i)},destroy(){d!==null&&(n?.cancel(d),d=null),r?.kill(),r=null}}}var Df=e=>Pf((t,n,r)=>new mf(t,n,r),e,Nf(window));function If(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 L0(e){if(Array.isArray(e))return e}function N0(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 P0(){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 D0(e,t){return L0(e)||N0(e,t)||I0(e,t)||P0()}function I0(e,t){if(e){if(typeof e=="string")return If(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)?If(e,t):void 0}}var Yf=Object.entries,Mf=Object.setPrototypeOf,M0=Object.isFrozen,G0=Object.getPrototypeOf,O0=Object.getOwnPropertyDescriptor,Ge=Object.freeze,He=Object.seal,vr=Object.create,Zf=typeof Reflect<"u"&&Reflect,_l=Zf.apply,Tl=Zf.construct;Ge||(Ge=function(t){return t});He||(He=function(t){return t});_l||(_l=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)});Tl||(Tl=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=Le(Array.prototype.forEach),F0=Le(Array.prototype.lastIndexOf),Gf=Le(Array.prototype.pop),ui=Le(Array.prototype.push),$0=Le(Array.prototype.splice),wr=Array.isArray,pi=Le(String.prototype.toLowerCase),vl=Le(String.prototype.toString),Of=Le(String.prototype.match),di=Le(String.prototype.replace),Ff=Le(String.prototype.indexOf),z0=Le(String.prototype.trim),H0=Le(Number.prototype.toString),W0=Le(Boolean.prototype.toString),$f=typeof BigInt>"u"?null:Le(BigInt.prototype.toString),zf=typeof Symbol>"u"?null:Le(Symbol.prototype.toString),st=Le(Object.prototype.hasOwnProperty),hi=Le(Object.prototype.toString),qe=Le(RegExp.prototype.test),Un=U0(TypeError);function Le(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 _l(e,t,r)}}function U0(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Tl(e,n)}}function ie(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pi;if(Mf&&Mf(e,null),!wr(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let a=n(i);a!==i&&(M0(t)||(t[r]=a),i=a)}e[i]=!0}return e}function B0(e){for(let t=0;t<e.length;t++)st(e,t)||(e[t]=null);return e}function mt(e){let t=vr(null);for(let r of Yf(e)){var n=D0(r,2);let i=n[0],a=n[1];st(e,i)&&(wr(a)?t[i]=B0(a):a&&typeof a=="object"&&a.constructor===Object?t[i]=mt(a):t[i]=a)}return t}function K0(e){switch(typeof e){case"string":return e;case"number":return H0(e);case"boolean":return W0(e);case"bigint":return $f?$f(e):"0";case"symbol":return zf?zf(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=O0(e,t);if(r){if(r.get)return Le(r.get);if(typeof r.value=="function")return Le(r.value)}e=G0(e)}function n(){return null}return n}function V0(e){try{return qe(e,""),!0}catch{return!1}}var Hf=Ge(["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"]),wl=Ge(["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"]),yl=Ge(["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"]),j0=Ge(["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"]),bl=Ge(["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"]),q0=Ge(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Wf=Ge(["#text"]),Uf=Ge(["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"]),xl=Ge(["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"]),Bf=Ge(["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"]),Ba=Ge(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y0=He(/{{[\w\W]*|^[\w\W]*}}/g),Z0=He(/<%[\w\W]*|^[\w\W]*%>/g),X0=He(/\${[\w\W]*/g),Q0=He(/^data-[\-\w.\u00B7-\uFFFF]+$/),J0=He(/^aria-[\-\w]+$/),Kf=He(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),e_=He(/^(?:\w+script|data):/i),t_=He(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),n_=He(/^html$/i),r_=He(/^[a-z][.\w]*(-[.\w]+)+$/i),Vf=He(/<[/\w!]/g),jf=He(/<[/\w]/g),i_=He(/<\/no(script|embed|frames)/i),a_=He(/\/>/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},Xf=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],o_=Ge(ie({},Xf)),s_=(function(){let e={};return Bn(Xf,t=>{e[t]=He(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Ge(e)})(),l_=function(){return typeof window>"u"?null:window},c_=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}},qf=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},fn=function(t,n,r,i){return st(t,n)&&wr(t[n])?ie(i.base?mt(i.base):{},t[n],i.transform):r},kl=function(t,n,r){let i=st(t,n)?t[n]:void 0;return i&&typeof i=="object"?mt(i):r()};function Qf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:l_(),t=N=>Qf(N);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"),y=Lt(h,"nextSibling"),v=Lt(h,"childNodes"),w=Lt(h,"parentNode"),b=Lt(h,"shadowRoot"),_=Lt(h,"attributes"),x=o&&o.prototype?Lt(o.prototype,"nodeType"):null,S=o&&o.prototype?Lt(o.prototype,"nodeName"):null,O=o&&o.prototype?Lt(o.prototype,"ownerDocument"):null,z=function(m){return x?x(m):m.nodeType},L=function(m){return S?S(m):m.nodeName};if(typeof a=="function"){let N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let G,I="",M,q=!1,Y=0,re=function(){if(Y>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.')},oe=function(m){re(),Y++;try{return G.createHTML(m)}finally{Y--}},be=function(m){re(),Y++;try{return G.createScriptURL(m)}finally{Y--}},lt=function(){return q||(M=c_(d,i),q=!0),M},Be=n,ve=Be.implementation,ce=Be.createNodeIterator,Te=Be.createDocumentFragment,ct=Be.getElementsByTagName,Ne=r.importNode,ae=qf();t.isSupported=typeof Yf=="function"&&typeof w=="function"&&ve&&ve.createHTMLDocument!==void 0;let Se=Y0,ut=Z0,Nt=X0,C=Q0,W=J0,J=e_,fe=t_,Oe=r_,wt=Kf,he=null,_t=ie({},[...Hf,...wl,...yl,...bl,...Wf]),ne=null,Tt=ie({},[...Uf,...xl,...Bf,...Ba]),Ke=Object.seal(vr(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,br=null,Ve=Object.seal(vr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),xr=!0,mn=!0,kr=!1,_r=!0,Pt=!1,$t=!0,Je=!1,vn=!1,Dt=null,Vn=null,yt=!1,Ee=!1,Fe=!1,wn=!1,Ae=!0,zt=!1,Xt="user-content-",yn=!0,Tr=!1,Qt={},et=null,vi=ie({},["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"]),tt=null,Jt=ie({},["audio","video","img","source","image","track"]),St=null,dt=ie({},["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,Sr=!1,Er=null,oo=ie({},[jn,en,ht],vl),wi=Ge(["mi","mo","mn","ms","mtext"]),Rr=ie({},wi),yi=Ge(["annotation-xml"]),qn=ie({},yi),bi=ie({},["title","style","font","a","script"]),bn=null,xi=["application/xhtml+xml","text/html"],ki="text/html",we=null,nn=null,_i=n.createElement("form"),xn=function(m){return m instanceof RegExp||m instanceof Function},Ar=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,we=bn==="application/xhtml+xml"?vl:pi,he=fn(m,"ALLOWED_TAGS",_t,{transform:we}),ne=fn(m,"ALLOWED_ATTR",Tt,{transform:we}),Er=fn(m,"ALLOWED_NAMESPACES",oo,{transform:vl}),St=fn(m,"ADD_URI_SAFE_ATTR",dt,{transform:we,base:dt}),tt=fn(m,"ADD_DATA_URI_TAGS",Jt,{transform:we,base:Jt}),et=fn(m,"FORBID_CONTENTS",vi,{transform:we}),gn=fn(m,"FORBID_TAGS",mt({}),{transform:we}),br=fn(m,"FORBID_ATTR",mt({}),{transform:we}),Qt=st(m,"USE_PROFILES")?m.USE_PROFILES&&typeof m.USE_PROFILES=="object"?mt(m.USE_PROFILES):m.USE_PROFILES:!1,xr=m.ALLOW_ARIA_ATTR!==!1,mn=m.ALLOW_DATA_ATTR!==!1,kr=m.ALLOW_UNKNOWN_PROTOCOLS||!1,_r=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pt=m.SAFE_FOR_TEMPLATES||!1,$t=m.SAFE_FOR_XML!==!1,Je=m.WHOLE_DOCUMENT||!1,Ee=m.RETURN_DOM||!1,Fe=m.RETURN_DOM_FRAGMENT||!1,wn=m.RETURN_TRUSTED_TYPE||!1,yt=m.FORCE_BODY||!1,Ae=m.SANITIZE_DOM!==!1,zt=m.SANITIZE_NAMED_PROPS||!1,yn=m.KEEP_CONTENT!==!1,Tr=m.IN_PLACE||!1,wt=V0(m.ALLOWED_URI_REGEXP)?m.ALLOWED_URI_REGEXP:Kf,tn=typeof m.NAMESPACE=="string"?m.NAMESPACE:ht,Rr=kl(m,"MATHML_TEXT_INTEGRATION_POINTS",()=>ie({},wi)),qn=kl(m,"HTML_INTEGRATION_POINTS",()=>ie({},yi));let T=kl(m,"CUSTOM_ELEMENT_HANDLING",()=>vr(null));if(Ke=vr(null),st(T,"tagNameCheck")&&xn(T.tagNameCheck)&&(Ke.tagNameCheck=T.tagNameCheck),st(T,"attributeNameCheck")&&xn(T.attributeNameCheck)&&(Ke.attributeNameCheck=T.attributeNameCheck),st(T,"allowCustomizedBuiltInElements")&&typeof T.allowCustomizedBuiltInElements=="boolean"&&(Ke.allowCustomizedBuiltInElements=T.allowCustomizedBuiltInElements),He(Ke),Pt&&(mn=!1),Fe&&(Ee=!0),Qt&&(he=ie({},Wf),ne=vr(null),Qt.html===!0&&(ie(he,Hf),ie(ne,Uf)),Qt.svg===!0&&(ie(he,wl),ie(ne,xl),ie(ne,Ba)),Qt.svgFilters===!0&&(ie(he,yl),ie(ne,xl),ie(ne,Ba)),Qt.mathMl===!0&&(ie(he,bl),ie(ne,Bf),ie(ne,Ba))),Ve.tagCheck=null,Ve.attributeCheck=null,st(m,"ADD_TAGS")&&(typeof m.ADD_TAGS=="function"?Ve.tagCheck=m.ADD_TAGS:wr(m.ADD_TAGS)&&(he===_t&&(he=mt(he)),ie(he,m.ADD_TAGS,we))),st(m,"ADD_ATTR")&&(typeof m.ADD_ATTR=="function"?Ve.attributeCheck=m.ADD_ATTR:wr(m.ADD_ATTR)&&(ne===Tt&&(ne=mt(ne)),ie(ne,m.ADD_ATTR,we))),st(m,"ADD_FORBID_CONTENTS")&&wr(m.ADD_FORBID_CONTENTS)&&(et===vi&&(et=mt(et)),ie(et,m.ADD_FORBID_CONTENTS,we)),yn&&(he["#text"]=!0),Je&&ie(he,["html","head","body"]),he.table&&(ie(he,["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 R=G;G=m.TRUSTED_TYPES_POLICY;try{I=oe("")}catch(F){throw G=R,F}}else m.TRUSTED_TYPES_POLICY===null?(G=void 0,I=""):(G===void 0&&(G=lt()),G&&typeof I=="string"&&(I=oe("")));Ge&&Ge(m),nn=m},Ti=ie({},[...wl,...yl,...j0]),Cr=ie({},[...bl,...q0]),Si=function(m,T,R){return T.namespaceURI===ht?m==="svg":T.namespaceURI===jn?m==="svg"&&(R==="annotation-xml"||Rr[R]):!!Ti[m]},Ei=function(m,T,R){return T.namespaceURI===ht?m==="math":T.namespaceURI===en?m==="math"&&qn[R]:!!Cr[m]},Ri=function(m,T,R){return T.namespaceURI===en&&!qn[R]||T.namespaceURI===jn&&!Rr[R]?!1:!Cr[m]&&(bi[m]||!Ti[m])},so=function(m){let T=w(m);(!T||!T.tagName)&&(T={namespaceURI:tn,tagName:"template"});let R=pi(m.tagName),F=pi(T.tagName);return Er[m.namespaceURI]?m.namespaceURI===en?Si(R,T,F):m.namespaceURI===jn?Ei(R,T,F):m.namespaceURI===ht?Ri(R,T,F):!!(bn==="application/xhtml+xml"&&Er[m.namespaceURI]):!1},k=function(m){ui(t.removed,{element:m});try{w(m).removeChild(m)}catch{if(g(m),!w(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")}},E=function(m,T,R){try{m.removeAttributeNode(T)}catch{try{m.removeAttribute(R)}catch{}}},B=function(m){Q(m);let T=v(m);if(T){let F=[];Bn(T,U=>{ui(F,U)}),Bn(F,U=>{try{g(U)}catch{}})}let R=_(m);if(R)for(let F=R.length-1;F>=0;--F){let U=R[F],Z=U&&U.name;typeof Z=="string"&&E(m,U,Z)}},X=function(m,T,R){if(!R)try{R=T.getAttributeNode(m)}catch{R=null}ui(t.removed,{attribute:R||null,from:T});try{R?T.removeAttributeNode(R):T.removeAttribute(m)}catch{try{T.removeAttribute(m)}catch{}}if(m==="is")if(Ee||Fe)try{k(T)}catch{}else try{T.setAttribute(m,"")}catch{}},P=function(m){let T=_(m);if(T)for(let R=T.length-1;R>=0;--R){let F=T[R],U=F&&F.name;typeof U!="string"||ne[we(U)]||E(m,F,U)}},Q=function(m){let T=[m];for(;T.length>0;){let R=T.pop();z(R)===gt.element&&P(R);let U=v(R);if(U)for(let Z=U.length-1;Z>=0;--Z)T.push(U[Z])}},We=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 R=T.pop(),F=z(R);if(F===gt.processingInstruction||F===gt.comment&&qe(jf,R.data)){try{g(R)}catch{}continue}if(F===gt.element){let Z=R,ge=we(L(R));try{Z.hasAttribute&&Z.hasAttribute("patchsrc")&&Z.removeAttribute("patchsrc"),Z.hasAttribute&&Z.hasAttribute("for")&&We("for",ge)&&Z.removeAttribute("for")}catch{}}let U=v(R);if(U)for(let Z=U.length-1;Z>=0;--Z)T.push(U[Z])}},Lr=function(m){let T=null,R=null;if(yt)m="<remove></remove>"+m;else{let Z=Of(m,/^[\r\n\t ]+/);R=Z&&Z[0]}bn==="application/xhtml+xml"&&tn===ht&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");let F=G?oe(m):m;if(tn===ht)try{T=new u().parseFromString(F,bn)}catch{}if(!T||!T.documentElement){T=ve.createDocument(tn,"template",null);try{T.documentElement.innerHTML=Sr?I:F}catch{}}let U=T.body||T.documentElement;return m&&R&&U.insertBefore(n.createTextNode(R),U.childNodes[0]||null),tn===ht?ct.call(T,Je?"html":"body")[0]:Je?T.documentElement:U},Nr=function(m){let T=O?O(m):m.ownerDocument;return ce.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},lo=function(m){var T;m.normalize();let R=O?O(m):m.ownerDocument,F=ce.call(R||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 Z=(T=m.querySelectorAll)===null||T===void 0?void 0:T.call(m,"template");Z&&Bn(Z,ge=>{Zn(ge.content)&&lo(ge.content)})},Ai=function(m){let T=S?S(m):null;return typeof T!="string"||we(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}},Pr=function(m){if(!x||typeof m!="object"||m===null)return!1;try{return typeof x(m)=="number"}catch{return!1}};function It(N,m,T){N.length!==0&&Bn(N,R=>{R.call(t,m,T,nn)})}let Hm=function(m,T){return!!($t&&m.hasChildNodes()&&!Pr(m.firstElementChild)&&qe(Vf,m.textContent)&&qe(Vf,m.innerHTML)||$t&&m.namespaceURI===ht&&o_[T]&&(Pr(m.firstElementChild)||typeof m.textContent=="string"&&qe(s_[T],m.textContent))||m.nodeType===gt.processingInstruction||$t&&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 R=arguments.length,F=new Array(R>2?R-2:0),U=2;U<R;U++)F[U-2]=arguments[U];return!!m(T,...F)}return!1},Wm=function(m,T,R){if(!gn[T]&&ql(T)&&Ci(Ke.tagNameCheck,T))return!1;if(yn&&!et[T]){let F=w(m),U=v(m);if(U&&F){let Z=U.length;for(let ge=Z-1;ge>=0;--ge){let xe=m===R?f(U[ge],!0):U[ge];F.insertBefore(xe,y(m))}}}return k(m),!0},Bl=function(m,T,R,F){return m.length===0?T:T===R||T===F?mt(T):T},Kl=function(m,T){return m===T||w(m)!==null?!1:(Tr&&Q(m),!0)},Vl=function(m,T){if(It(ae.beforeSanitizeElements,m,null),Kl(m,T))return!0;if(Ai(m))return k(m),!0;let R=we(L(m));if(he=Bl(ae.uponSanitizeElement,he,_t,Dt),It(ae.uponSanitizeElement,m,{tagName:R,allowedTags:he}),Kl(m,T))return!0;if(Hm(m,R))return k(m),!0;if(gn[R]||!(Ve.tagCheck instanceof Function&&Ve.tagCheck(R))&&!he[R]){let U=Wm(m,R,T);return U===!1&&It(ae.afterSanitizeElements,m,null),U}if(z(m)===gt.element&&!so(m)||(R==="noscript"||R==="noembed"||R==="noframes")&&qe(i_,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(ae.afterSanitizeElements,m,null),!1},jl=function(m,T,R){if(br[T]||We(T,m)||Ae&&(T==="id"||T==="name")&&(R in n||R in _i))return!1;let F=ne[T]||Ve.attributeCheck instanceof Function&&Ve.attributeCheck(T,m);return mn&&qe(C,T)||xr&&qe(W,T)?!0:F?St[T]||qe(wt,di(R,fe,""))||(T==="src"||T==="xlink:href"||T==="href")&&m!=="script"&&Ff(R,"data:")===0&&tt[m]||kr&&!qe(J,di(R,fe,""))?!0:!R:ql(m)&&Ci(Ke.tagNameCheck,m)&&Ci(Ke.attributeNameCheck,T,m)||T==="is"&&Ke.allowCustomizedBuiltInElements&&Ci(Ke.tagNameCheck,R)},Um=ie({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ql=function(m){return!Um[pi(m)]&&qe(Oe,m)},Bm=function(m,T,R,F){if(G&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!R)switch(d.getAttributeType(m,T)){case"TrustedHTML":return oe(F);case"TrustedScriptURL":return be(F)}return F},Km=function(m,T,R,F){try{R?m.setAttributeNS(R,T,F):m.setAttribute(T,F),Ai(m)?k(m):Gf(t.removed)}catch{X(T,m)}},Yl=function(m){It(ae.beforeSanitizeAttributes,m,null);let T=m.attributes;if(!T||Ai(m))return;ne=Bl(ae.uponSanitizeAttribute,ne,Tt,Vn);let R={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0},F=T.length,U=we(m.nodeName);for(;F--;){let Z=T[F],ge=Z.name,xe=Z.namespaceURI,nt=Z.value,rt=we(ge),uo=nt,Ye=ge==="value"?uo:z0(uo);if(R.attrName=rt,R.attrValue=Ye,R.keepAttr=!0,R.forceKeepAttr=void 0,It(ae.uponSanitizeAttribute,m,R),Ye=R.attrValue,zt&&(rt==="id"||rt==="name")&&Ff(Ye,Xt)!==0&&(X(ge,m,Z),Ye=Xt+Ye),$t&&qe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ye)){X(ge,m,Z);continue}if(rt==="attributename"&&Of(Ye,"href")){X(ge,m,Z);continue}if(!R.forceKeepAttr){if(!R.keepAttr){X(ge,m,Z);continue}if(!_r&&qe(a_,Ye)){X(ge,m,Z);continue}if(Pt&&(Ye=Yn(Ye)),!jl(U,rt,Ye)){X(ge,m,Z);continue}Ye=Bm(U,rt,xe,Ye),Ye!==uo&&Km(m,ge,xe,Ye)}}It(ae.afterSanitizeAttributes,m,null)},Li=function(m){let T=null,R=Nr(m);for(It(ae.beforeSanitizeShadowDOM,m,null);T=R.nextNode();)if(It(ae.uponSanitizeShadowNode,T,null),Vl(T,m),Yl(T),Zn(T.content)&&Li(T.content),z(T)===gt.element){let F=b(T);Zn(F)&&(co(F),Li(F))}It(ae.afterSanitizeShadowDOM,m,null)},co=function(m){let T=[{node:m,shadow:null}];for(;T.length>0;){let R=T.pop();if(R.shadow){Li(R.shadow);continue}let F=R.node,Z=z(F)===gt.element,ge=v(F);if(ge)for(let xe=ge.length-1;xe>=0;--xe)T.push({node:ge[xe],shadow:null});if(Z){let xe=S?S(F):null;if(typeof xe=="string"&&we(xe)==="template"){let nt=F.content;Zn(nt)&&T.push({node:nt,shadow:null})}}if(Z){let xe=b(F);Zn(xe)&&T.push({node:null,shadow:xe},{node:xe,shadow:null})}}};return t.sanitize=function(N){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,R=null,F=null,U=null;if(Sr=!N,Sr&&(N="<!-->"),typeof N!="string"&&!Pr(N)&&(N=K0(N),typeof N!="string"))throw Un("dirty is not a string, aborting");if(!t.isSupported)return N;vn?(he=Dt,ne=Vn):Ar(m),(ae.uponSanitizeElement.length>0||ae.uponSanitizeAttribute.length>0)&&(he=mt(he)),ae.uponSanitizeAttribute.length>0&&(ne=mt(ne)),t.removed=[];let Z=Tr&&typeof N!="string"&&Pr(N);if(Z){rn(N);let nt=L(N);if(typeof nt=="string"){let rt=we(nt);if(!he[rt]||gn[rt])throw B(N),Un("root node is forbidden and cannot be sanitized in-place")}if(Ai(N))throw B(N),Un("root node is clobbered and cannot be sanitized in-place");try{co(N)}catch(rt){throw B(N),rt}}else if(Pr(N))T=Lr("<!---->"),R=T.ownerDocument.importNode(N,!0),R.nodeType===gt.element&&R.nodeName==="BODY"||R.nodeName==="HTML"?T=R:T.appendChild(R),co(R);else{if(!Ee&&!Pt&&!Je&&N.indexOf("<")===-1)return G&&wn?oe(N):N;if(T=Lr(N),!T)return Ee?null:wn?I:""}T&&yt&&k(T.firstChild);let ge=Z?N:T;try{let nt=Nr(ge);for(;F=nt.nextNode();)Vl(F,ge),Yl(F),Zn(F.content)&&Li(F.content)}catch(nt){throw Z&&(B(N),Bn(t.removed,rt=>{rt.element&&Q(rt.element)})),nt}if(Z)return Bn(t.removed,nt=>{nt.element&&Q(nt.element)}),Pt&&lo(N),N;if(Ee){if(Pt&&lo(T),Fe)for(U=Te.call(T.ownerDocument);T.firstChild;)U.appendChild(T.firstChild);else U=T;return(ne.shadowroot||ne.shadowrootmode)&&(U=Ne.call(r,U,!0)),U}let xe=Je?T.outerHTML:T.innerHTML;return Je&&he["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&qe(n_,T.ownerDocument.doctype.name)&&(xe="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
411
|
+
`+xe),Pt&&(xe=Yn(xe)),G&&wn?oe(xe):xe},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ar(N),vn=!0,Dt=he,Vn=ne},t.clearConfig=function(){nn=null,vn=!1,Dt=null,Vn=null,G=M,I=""},t.isValidAttribute=function(N,m,T){nn||Ar({});let R=we(N),F=we(m);return jl(R,F,T)},t.addHook=function(N,m){typeof m=="function"&&st(ae,N)&&ui(ae[N],m)},t.removeHook=function(N,m){if(st(ae,N)){if(m!==void 0){let T=F0(ae[N],m);return T===-1?void 0:$0(ae[N],T,1)[0]}return Gf(ae[N])}},t.removeHooks=function(N){st(ae,N)&&(ae[N]=[])},t.removeAllHooks=function(){ae=qf()},t}var Sl=Qf();function Ka(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}=Fr(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}=Fr(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?Uo(Fr(u.tail).opening,h):u.tail,y=Wo(d,g);u.saving=!0,a();let v=!1;try{let w={...f?{raw:!0}:{},...c?.keepOpen?{quiet:!0}:{}};v=await l(s,y,Object.keys(w).length===0?void 0:w)}finally{if(t.get(s)===u){let w=n.get(s);v&&w!==void 0&&(w.body=y,w.version=++i,delete w.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 Jf(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 eg(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="",Va="",tg=900;function Rl(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 u_=/^[ \t]*(?:#{1,6}[ \t]+|>[ \t]?|(?:[*+-]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)*/,d_=/^[ \t]*(?:`{3,}|~{3,}|<!--|(?:[-*_][ \t]*){3,}$)/,h_=/!?\[\[[^\]\n]*\]\]|!?\[[^\]\n]*\]\([^)\n]*\)|<[a-z][a-z0-9+.-]*:[^>\s]*>/gi;function p_(e,t){let{start:n,end:r}=Rl(e??"",t);if(n>=r)return t;let i=[],a=t.lastIndexOf(`
|
|
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(!d_.test(c)){let u=u_.exec(c)[0].length,d=Math.max(n-a,u),h=Math.min(r,l)-a;for(let f of c.matchAll(h_)){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)+Va+o.slice(l);return o}function ng(e,t){let n=[],r="",i=t;for(let a of e)a===fi||a===Va?(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 f_={human:"You",agent:"Agent",outside:"Outside edit",system:"pi-weave"},g_={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 m_(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 v_(e,t){let{head:n,tail:r}=nr(e);return r!==""&&t>=n.length}function ja(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=Rl(i?.body??"",r.body),o=a.end-a.start,s=[o>0?`+${o}`:"",a.removed>0?`−${a.removed}`:""].filter(Boolean).join(" "),l=g_[r.op]??r.op;return{position:`${n+1} of ${e.length}`,action:r.op==="baseline"?l[0].toUpperCase()+l.slice(1):`${f_[r.by]} ${l}`,at:m_(r.at,i?.at??null),atIso:r.at,change:s,marked:p_(i?.body??null,r.body),by:r.by,follow:!v_(r.body,a.start)}}var El=.14;function rg(e){let t=e.map((r,i)=>{let a=Rl(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?El:El+(1-El)*(Math.log1p(t[i])/n),by:r.by}))}function ig(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 ag(e,t){return e+1<t?e+1:null}var og="History",sg="Close history",Al="History is off, so new changes are not being saved. Turn it on in Settings → Editor.",lg="Older versions were trimmed",cg="No saved versions yet. Changes are saved from now on.";function ug(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(Va))continue;let s=ng(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 w_=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 dg(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($e(()=>{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=ja(t,n);return c===null?p("div",{class:"weave-replay weave-replay-note",role:"status",children:i?cg:Al}):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:lg}):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>w_||l===0?null:p("span",{class:"weave-replay-bars","aria-hidden":"true",style:{"--weave-bars":`${t.length}`},children:rg(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:ig(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:Al})]})}var Cl="Editing",mg="Discard changes",vg="Retry",wg="Put this note back the way it was when you started editing?";function y_(e){return new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function yg(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 ${y_(e.savedAt)}`}:{kind:"clean",label:"No changes yet"}}var Ll=[{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 bg(e){return Ll.find(t=>t.key===e.toLowerCase())?.kind??null}function qa(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 hg(e,t){let n=e.value.lastIndexOf(`
|
|
414
|
+
`,e.start-1)+1,r=e.end>e.start&&e.value[e.end-1]===`
|
|
415
|
+
`?e.end-1:e.end,i=e.value.indexOf(`
|
|
416
|
+
`,r),a=i===-1?e.value.length:i,o=e.value.slice(n,a).split(`
|
|
417
|
+
`).map(t).join(`
|
|
418
|
+
`);return{value:e.value.slice(0,n)+o+e.value.slice(a),start:n,end:n+o.length}}var pg=/^#{1,6}[ \t]+/,fg=/^([ \t]*)[-*+][ \t]+\[[ xX]\][ \t]+/,gg=/^([ \t]*)[-*+][ \t]+/;function xg(e,t){switch(t){case"bold":return qa(e,"**","**","bold text");case"italic":return qa(e,"_","_","italic text");case"wikilink":return qa(e,"[[","]]","note title");case"link":{let n=e.value.slice(e.start,e.end);if(n==="")return qa(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 hg(e,n=>pg.test(n)?n.replace(pg,""):`## ${n}`);case"task":return hg(e,n=>fg.test(n)?n.replace(fg,"$1"):gg.test(n)?n.replace(gg,"$1- [ ] "):`- [ ] ${n}`)}}function kg(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 x_="weave-preview-x",k_="weave-preview-y";function __({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(le,{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:`${gh} ${e.created} · ${e.createdIso}`,children:[fh," ",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(le,{name:"history",class:"weave-icon"}),a?sg:og]}),a?null:p("button",{type:"button",class:"weave-note-action weave-note-edit",disabled:r,onClick:i,children:[p(le,{name:"edit",class:"weave-icon"}),mh]}),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:Sh(s)},s))})]})}function T_({status:e,busy:t,onFormat:n,onRetry:r,onDiscard:i,onDone:a}){return p("div",{class:"weave-editbar",role:"toolbar","aria-label":Cl,children:[p("span",{class:"weave-editbar-badge",children:[p(le,{name:"edit",class:"weave-icon"}),Cl]}),p("span",{class:"weave-editbar-tools",children:Ll.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(le,{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(le,{name:"check",class:"weave-icon"}):null,e.label,e.kind==="failed"?p("button",{type:"button",class:"weave-editbar-retry",onClick:r,children:vg}):null]}),p("button",{type:"button",class:"weave-editbar-discard",disabled:t||e.kind==="saving",onClick:i,children:mg}),p("button",{type:"button",class:"weave-editbar-done",disabled:t,onClick:a,children:vh})]})}function _g(e){let t=V(Ka()),n=e.drafts??t.current,r=Ec(),i=`${e.idPrefix??r}-weave-preview`,[a,o]=K(0);te(()=>n.subscribe(()=>o(C=>C+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),c=sh(e.graph,e.selectedId),u=Ch(e.selectedId,s,e.loadFailed),d=Pe(()=>s===null?null:lh(e.graph,s.slug),[s,e.graph]),h=Pe(()=>s===null||d===null?"":As(Sl,l,d),[s,l,d]),[f,g]=K(va),y=C=>{g(W=>Ah(W,C))},v=V(null),w=V(null),b=V(null),_=V(!1),x=s===null?null:n.get(s.slug),[S,O]=K(!1),z=s!==null&&n.isTaskSaving(s.slug),L=()=>{s!==null&&!n.isTaskSaving(s.slug)&&n.save(s.slug,e.onSave,{keepOpen:!0})},G=async(C,W)=>{let J=()=>{C.checked=!C.checked,C.setAttribute("aria-label",wa(C.checked))};if(s===null||n.isTaskSaving(s.slug)){J();return}let fe=uh(n.getTaskBody(s.slug,s.body),W);if(fe===null){J();return}let Oe=[...v.current?.querySelectorAll(`input[${$n}]`)??[]];C.setAttribute("aria-label",wa(C.checked));for(let wt of Oe)wt.disabled=!0;try{await n.saveTask(s.slug,fe,e.onSave)||J()}catch(wt){throw J(),wt}finally{for(let wt of Oe)wt.disabled=n.isTaskSaving(s.slug)}},I=V(null);te(()=>{s!==null&&I.current!==s.slug&&(I.current=s.slug,e.defaultEdit&&n.get(s.slug)===null&&(_.current=!0,n.open(s.slug,l)))},[s?.slug,e.defaultEdit]);let M=()=>{s===null||n.isTaskSaving(s.slug)||n.get(s.slug)!==null||(_.current=!0,n.open(s.slug,l))},q=V(!1),Y=()=>{if(!(s===null||x===null||n.isTaskSaving(s.slug))){if(x.saving){q.current=!0;return}q.current=!1,n.isDirty(s.slug)?n.save(s.slug,e.onSave):n.discard(s.slug)}},re=()=>{if(s===null||x===null||x.saving)return;if(q.current=!1,x.baseline!==x.original||x.rawBaseline!==x.originalRaw){if(!window.confirm(wg))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)},oe=V(null),be=V("body"),lt=C=>{if(s===null)return;let W=be.current==="raw"&&oe.current!==null,J=W?oe.current:b.current;if(J===null)return;let fe=xg({value:J.value,start:J.selectionStart,end:J.selectionEnd},C),Oe=kg(J.value,fe.value);J.focus(),J.setSelectionRange(Oe.start,Oe.end),(!(typeof document.execCommand=="function"&&document.execCommand(Oe.text===""?"delete":"insertText",!1,Oe.text))||J.value!==fe.value)&&(J.value=fe.value),W?n.editRaw(s.slug,fe.value):n.edit(s.slug,fe.value),J.setSelectionRange(fe.start,fe.end)},Be=C=>{if(C.key==="Escape"){C.stopPropagation(),Y();return}if(!(C.metaKey||C.ctrlKey)||C.altKey)return;if(C.key.toLowerCase()==="s"){C.preventDefault(),s!==null&&n.isDirty(s.slug)&&L();return}let W=bg(C.key);W===null||C.shiftKey||(C.preventDefault(),lt(W))};te(()=>{if(s===null||x===null||x.saving||x.failed||!n.isDirty(s.slug))return;let C=window.setTimeout(L,2500);return()=>window.clearTimeout(C)},[s?.slug,x,x?.body,x?.raw,x?.saving,x?.failed]),te(()=>{q.current&&x!==null&&!x.saving&&Y()},[x?.saving]);let ve=f.anchor===null?null:Eh(e.graph,f.anchor);$e(()=>{let C=b.current;C===null||!_.current||(_.current=!1,C.focus(),C.setSelectionRange(C.value.length,C.value.length))},[x!==null]);let[ce,Te]=K(null),ct=V(null),Ne=e.onHistory,ae=()=>{if(s===null||Ne===void 0)return;if(ce!==null){ct.current=null,Te(null);return}let C=s.slug;ct.current=C,Te({revisions:null,enabled:!0,trimmed:!1,index:0,playing:!1,error:null}),Ne(C).then(W=>{ct.current===C&&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=ce?.revisions==null?null:ja(ce.revisions,ce.index),ut=Pe(()=>Se===null||d===null?null:As(Sl,Se.marked,d),[Se?.marked,d]);if($e(()=>{ct.current=null,Te(null),O(!1)},[s===null?null:s.slug]),$e(()=>{if(ut===null||v.current===null)return;let C=ug(v.current);Se?.follow&&C?.scrollIntoView?.({block:"nearest"})},[ut]),te(()=>{if(ce===null||!ce.playing||ce.revisions===null)return;let C=ce.revisions.length,W=window.setTimeout(()=>{Te(J=>{if(J===null)return J;let fe=ag(J.index,C);return fe===null?{...J,playing:!1}:{...J,index:fe}})},tg);return()=>window.clearTimeout(W)},[ce]),$e(()=>{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]),$e(()=>{y({type:"hide"})},[s===null?null:s.slug]),$e(()=>{if(s===null)return;let C=n.isTaskSaving(s.slug);for(let W of v.current?.querySelectorAll(`input[${$n}]`)??[])W.disabled=C},[s===null?null:s.slug,a,h]),$e(()=>{let C=v.current;if(C!==null){let fe=f.anchor?.slug??null;for(let Oe of C.querySelectorAll(`a[${Vt}]`))fe!==null&&Oe.getAttribute(Vt)===fe?Oe.setAttribute("aria-describedby",i):Oe.removeAttribute("aria-describedby")}let W=w.current;if(W===null||ve===null)return;let J=Rh(f.pointerX,f.pointerY,W.offsetWidth,W.offsetHeight,window.innerWidth,window.innerHeight);W.style.setProperty(`--${x_}`,`${J.x}px`),W.style.setProperty(`--${k_}`,`${J.y}px`)},[f,ve,i]),c!==null){let C=e.graph?.model.nodes.find(fe=>fe.id===e.selectedId),W=C?.label??c,J=C===void 0?c:oh(C)??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)}`},J)]},J)}if(s===null||d===null)return p("p",{class:"weave-note-empty",children:u});let Nt=Th(s,e.now);return p("article",{class:`weave-note weave-note-${Nt.provenance}`,children:[x===null?null:p(T_,{status:yg({saving:x.saving,failed:x.failed,dirty:n.isDirty(s.slug),savedAt:x.savedAt}),busy:z,onFormat:lt,onRetry:L,onDiscard:re,onDone:Y}),p(__,{view:Nt,open:()=>e.onOpen(s.slug),editing:x!==null,taskSaving:z,onEdit:M,replaying:ce!==null,onHistory:Ne===void 0?null:ae}),ce===null?null:p(dg,{state:ce,now:e.now,onIndex:C=>Te(W=>W===null?W:{...W,index:C,playing:!1}),onPlay:()=>Te(C=>{if(C===null||C.revisions===null)return C;if(C.playing)return{...C,playing:!1};let W=C.index>=C.revisions.length-1;return{...C,index:W?0:C.index,playing:!0}})}),x!==null?p(ye,{children:[p("textarea",{ref:b,class:"weave-note-editor","aria-label":wh,placeholder:yh,spellcheck:e.spellcheck??!0,value:x.body,onInput:C=>n.edit(s.slug,C.target.value),onFocus:()=>{be.current="body"},onKeyDown:Be}),x.tail===""?null:p("section",{class:"weave-raw","aria-label":bh,"data-open":S?"":void 0,children:[p("div",{class:"weave-raw-head",children:[p("button",{type:"button",class:"weave-raw-toggle","aria-expanded":S,"aria-controls":`${e.idPrefix??r}-weave-raw`,onClick:()=>O(C=>!C),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"})}),kh]}),p("span",{class:"weave-raw-hint",children:_h(x.raw,S)})]}),S?p("textarea",{id:`${e.idPrefix??r}-weave-raw`,class:"weave-raw-editor","aria-label":xh,spellcheck:e.spellcheck??!0,value:x.raw,ref:oe,onInput:C=>n.editRaw(s.slug,C.target.value),onFocus:()=>{be.current="raw"},onKeyDown:Be}):null]})]}):p("div",{ref:v,class:"weave-note-body",tabIndex:-1,onMouseOver:C=>{let W=Ls(C.target);y(W!==null?{type:"show",anchor:W,x:C.clientX,y:C.clientY}:{type:"hide"})},onMouseLeave:()=>y({type:"hide"}),onFocus:C=>{let W=Ls(C.target);if(W===null)return;let J=C.target.getBoundingClientRect?.();y({type:"show",anchor:W,x:J?.left??0,y:J?.bottom??0})},onBlur:()=>y({type:"hide"}),onClick:C=>{let W=C.target,J=dh(W);if(J!==null&&ut!==null){C.preventDefault();return}if(J!==null){G(W,J);return}let fe=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(ph(fe))return;let Oe=Cs(C.target);Oe!==null&&e.onSelect(Oe,C.metaKey||C.ctrlKey||C.shiftKey)},onKeyDown:C=>{if(C.key==="Escape"&&f.anchor!==null){C.stopPropagation(),y({type:"dismiss"});return}if(C.key!=="Enter"&&C.key!==" ")return;let W=Cs(C.target);W!==null&&(C.preventDefault(),e.onSelect(W,C.metaKey||C.ctrlKey||C.shiftKey))},dangerouslySetInnerHTML:{__html:ut??h}}),ve===null?null:p("div",{ref:w,id:i,role:"tooltip",class:`weave-preview${ve.ghost?" weave-preview-ghost":""}`,children:[p("span",{class:"weave-preview-kind",children:ve.kind}),p("span",{class:"weave-preview-title",children:ve.title}),ve.text===""?null:p("p",{class:"weave-preview-text",children:ve.text})]})]},s.slug)}var Tg=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Sg(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 Eg(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Rg(e){return e===null?!1:(e.focus(),!0)}function yr(){let e=V(null);return te(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Rg(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Eg(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Tg)??[]],r=Sg(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}var Ag=20,S_=10,Ng=140,Pg=["notes","code","tags"],E_=["all",...Pg],Cg={all:"All",notes:"Notes",code:"Code",tags:"Tags"},R_=["note:","vfolder:","artifact:"];function Za(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 A_(e){return Math.min(Math.max(e,0),S_)*2}function C_(e){return`note:${e}`}function L_(e,t){return Za(e.summary.title,t)+A_(e.score)}function N_(e,t){return Za(e.label,t)}var P_=["path","manifest","url","slug"];function D_(e){for(let t of P_){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}var I_=["preview","summary","description"];function M_(e){for(let n of I_){let r=e.detail[n];if(typeof r=="string"&&r)return r}let t=D_(e);return t===e.label?"":t}var G_={entryPoint:"entry point",gitState:"git",external:"remote"};function O_(e){return e.id.startsWith("vfolder:")?"folder":e.id.startsWith("artifact:")?"artifact":G_[e.kind]??e.kind}function F_(e){return e.kind==="vault"||R_.some(t=>e.id.startsWith(t))?"notes":"code"}function Dg(e){return e.id.startsWith("note:")?e.id.slice(5):e.id.startsWith("artifact:")?e.id.slice(9):""}function $_(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 Il(e){let t=e.trim();return t.startsWith("#")?t.slice(1).trim():null}function Ml(e){return Il(e)===null?e.trim():""}function z_(e){return e===1?"1 note":`${e} notes`}function H_(e,t){let n=Il(t),r=[];for(let[i,a]of Object.entries(e)){let o=n===""?1:Za(i,n??t);o&&r.push({id:`tag:${i}`,kind:"tag",group:"tags",icon:"tag",label:`#${i}`,detail:z_(a.length),badge:"tag",score:o,path:"",updated:""})}return r.sort((i,a)=>a.score-i.score)}function W_(e,t){let n=new Map;for(let[r,i]of Object.entries(e)){let a=Za(r,t);if(a)for(let o of i)n.set(o,Math.max(a,n.get(o)??0))}return n}function U_(e,t){let{slug:n,title:r,updated:i}=e.summary;return{id:C_(n),kind:"note",group:"notes",icon:"note",label:r,detail:e.snippet,badge:"note",score:L_(e,t),path:n,updated:i}}function B_(e,t){return{id:e.id,kind:"node",group:F_(e),icon:e.kind,label:e.label,detail:M_(e),badge:O_(e),score:t,path:Dg(e),updated:e.detail.updated??""}}function Ig(e,t,n,r,i={}){let a=Il(r),o=a?W_(i,a):new Map,s=new Map;for(let u of e){let d=U_(u,t);s.set(d.id,d)}for(let u of n){if(s.has(u.id))continue;let d=a===null?N_(u,r):u.kind==="note"?o.get(Dg(u))??0:0;d&&s.set(u.id,B_(u,d))}let l=[...s.values()].sort($_),c=u=>l.filter(d=>d.group===u).slice(0,Ag);return[...c("notes"),...c("code"),...H_(i,r).slice(0,Ag)]}var K_=/(?:\*\*|__)TL;?DR[ \t]*:?[ \t]*(?:\*\*|__)[ \t]*:?|\bTL;?DR[ \t]*:/i;function V_(e){let t=K_.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 Ya="\0";function j_(e){let t=[];return e.replace(/`{3,}[^\s`]*/g," ").replace(/`([^`\n]*)`/g,(n,r)=>`${Ya}${t.push(r)-1}${Ya}`).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(`${Ya}(\\d+)${Ya}`,"g"),(n,r)=>t[Number(r)]).replace(/\s+/g," ").trim()}function q_(e){return j_(V_(e)??e)}var Y_=2;function Z_(e){let t=e.trim().replace(/^#/,"").trim();return t?[...new Set([t,...t.split(/\s+/).filter(n=>n.length>=Y_)])]:[]}function X_(e,t){let n=[];for(let i of Z_(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 Q_=40,J_=16;function Lg(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 eT(e,t){let n=q_(e),r=X_(n,t),i=r[0];if(i===void 0||i[0]<=Q_)return Lg(n,r);let a=i[0]-J_,o=n.indexOf(" ",a),s=o>=0&&o<i[0]?o+1:a,l=s-1;return Lg(`…${n.slice(s)}`,r.map(([c,u])=>[c-l,u-l]))}function tT(e){return e.split("/").slice(0,-1).join("/")}function nT(e,t){return Wt(e,t).replace(/ ago$/,"")}function rT(e,t){return e.kind==="tag"?"":e.updated?[tT(e.path),nT(e.updated,t)].filter(n=>n!=="").join(" · "):e.badge}var Mg={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},iT={d:["M2.75 2.75h5l5.5 5.5-5 5-5.5-5.5Z","M5.5 5.5h.01"],filled:!1};function aT(e){return e==="tag"?iT:ka[e]}function Gg(){return{query:"",answered:"",hits:[],cursor:0,scope:"all",loading:!1,failed:!1}}function Nl(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Pl(e,t,n){return n<=0?0:((e+t)%n+n)%n}function oT(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Nl(e,n);return t==="ArrowDown"?{...r,cursor:Pl(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Pl(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Nl(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 sT(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 Og(e){return E_.filter(t=>t==="all"||e[t]>0)}function lT(e,t){return Og(t).includes(e)?e:"all"}function cT(e,t,n){return e[Pl(Math.max(e.indexOf(t),0),n?-1:1,e.length)]??"all"}var Xa="Search the workspace",Fg="Search notes and repository…",$g="↑↓ move · ↵ open · ⌘↵ open in new tab · Tab scope",zg="Search scope",Hg="⇧↵";function Wg(e){return`Light up ${e} in the graph`}function uT(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 Ug(e){return`weave-search-row-${e}`}function dT(e){return`weave-search-group-${e}`}function hT(e,t,n,r,i){return{id:e.id,kind:e.kind,group:e.group,label:e.label,icon:aT(e.icon),mono:e.group==="code",parts:eT(e.detail,r),meta:rT(e,i),active:t===n,domId:Ug(t),index:t}}function pT(e,t,n){return(e.answered===Ml(e.query)?n:Ig([],"",t?.model.nodes??[],e.query,t?.tags??{})).filter(i=>i.kind!=="tag").map(i=>i.id)}function Bg(e,t,n){let r=e.query.trim(),i=Ig(e.hits,e.answered,t?.model.nodes??[],e.query,t?.tags??{}),a=sT(i),o=lT(e.scope,a),s=o==="all"?i:i.filter(h=>h.group===o),l=Nl(e.cursor,s.length),c=s.map((h,f)=>hT(h,f,l,e.query,n)),u=Pg.flatMap(h=>{let f=c.filter(g=>g.group===h);return f.length?[{group:h,heading:`${Cg[h]} · ${f.length}`,domId:dT(h),rows:f}]:[]}),d=r?Og(a).map(h=>({scope:h,label:Cg[h],count:a[h],active:h===o})):[];return{groups:u,rows:c,scopes:d,scope:o,status:uT(e,s.length),count:s.length,cursor:l,activeDomId:c.length?Ug(l):null,query:r,lightUp:pT(e,t,i)}}var Dl={type:"none"};function Gl(e,t){return e.kind==="tag"?{type:"tag",query:`#${e.id.slice(4)}`}:{type:"open",id:e.id,newTab:t}}function Ol(e){return e.query&&e.lightUp.length>0?{type:"lightUp",query:e.query,ids:e.lightUp}:Dl}function Kg(e,t,n){if(t.key==="Tab")return!t.inInput||t.mod||e.scopes.length<2?Dl:{type:"scope",scope:cT(e.scopes.map(i=>i.scope),e.scope,t.shift)};if(t.key==="Enter"&&t.shift&&n)return Ol(e);let r=oT(e.cursor,t.key,e.count);return r.handled?r.activate!==null?Gl(e.rows[r.activate],t.mod):r.dismiss?{type:"close"}:{type:"move",cursor:r.cursor}:Dl}function Vg(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 qg({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 fT({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(qg,{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 Yg(e){let[t,n]=K(Gg),r=V(0),i=V(null),a=yr(),o=V(null);te(()=>{o.current?.focus()},[]),te(()=>{let c=Ml(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(y=>({...y,loading:!0,failed:!1}));let g=await Kc(e.ports.fetch,c,f.signal);!u||f.signal.aborted||h!==r.current||n(y=>g.ok?{...y,hits:g.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...y,loading:!1,failed:!0})},Ng);return()=>{u=!1,window.clearTimeout(d),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Bg(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=>Vg(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":Xa,tabIndex:-1,ref:a.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{let u=Kg(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(qg,{def:Mg,class:"weave-icon weave-palette-glyph"}),p("input",{type:"search",class:"weave-palette-input",ref:o,value:t.query,placeholder:Fg,role:"combobox","aria-label":Xa,"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":zg,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":Xa,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(fT,{row:u,onPick:d=>l(Gl(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:$g}),e.onLightUp&&s.lightUp.length>0?p("button",{type:"button",class:"weave-palette-light",onClick:()=>l(Ol(s)),children:[Wg(s.lightUp.length)," ",p("kbd",{class:"weave-palette-kbd",children:Hg})]}):null]})]})})}function Fl(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Qa=2e3,gT=3e3,Xg=new Set;function mT(e,t){if(e===null)return Xg;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 Zg(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function Qg(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=Zg(t.selectedId);if(h===null){a({note:null,noteFailed:!1});return}let f=await Go(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=mT(h,f.data);a({graph:f.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=o(()=>{i=null,a({recentIds:Xg})},gT))}return f},c=async()=>{if(!(n||r)){r=!0;try{let h=await l();Zg(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()},Qa);return c(),{refresh:()=>{c()},select:async h=>{a({selectedId:h}),await s()},syncNote:s,stop:()=>{n||(n=!0,d(),i?.(),i=null)}}}function Jg(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 Go(e,t);i||(n(s),s.ok||(a=r(()=>{o()},Qa)))};return o(),()=>{i=!0,a?.()}}var mi={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function eo(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 vT(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:eo(e.id,i,n)}function wT(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var yT=["link:links-to:"];function bT(e){return yT.some(t=>e.id.startsWith(t))}function xT(e){return e.id.startsWith("link:mentions:")}function kT(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(eo(`tag:${a}:${l}`,c,r))}i.push({tag:a,count:o.length,siblings:s})}return i}function _T(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(eo(`mentioned-by:${a.source}`,o,r))}return i}function TT(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var Ja={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 $l(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function em(e){return e.groups.reduce((t,n)=>t+n.count,0)+e.tagsCount}function to(e,t){if(e===null)return $l(Ja.loading);if(t===null)return $l(Ja.noSelection);let n=Ln(e),r=Bo(n,t);if(r===null)return $l(Ja.unknown);let i=wT(n),a=[],o=(d,h)=>{h.length>0&&a.push({heading:d,count:h.length,rows:h})},s=d=>d.map(h=>vT(h,i,t)).filter(h=>h!==null);o(mi.links,s(r.links.filter(bT)));let l=Ko(n.edges).get(t)??[];o(mi.backlinks,l.map(d=>i.get(d)).filter(d=>d!==void 0).map(d=>eo(`backlink:${d.id}`,d,t))),o(mi.mentions,[...s(r.links.filter(xT)),..._T(n,t,i,t)]);let c=TT(t),u=c===null?[]:kT(e,c,i,t);return a.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:Ja.isolated}:{subject:r.label,groups:a,tags:u,tagsCount:u.length,empty:null}}function tm(){return{open:new Set,closed:new Set}}var ST=8;function nm(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>ST}function ET(e){return e.some(t=>t.selected)}function rm(e,t){let n=nm(t,e.heading,e.count,ET(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function im(e,t){let n=nm(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 am(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 no(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 om={searched:0,read:1,wrote:2},sm=new Map;function cm(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 um(e,t,n=null){if(e===null)return sm;let r=new Map,i=new Map;for(let{event:a,at:o}of cm(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||om[a.kind]>om[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?sm:r}function dm(e,t,n=null){return e===null?!1:cm(e,n).some(({at:r})=>t-r<6e4)}var RT={add:"created",append:"appended",finalize:"finalized",links:"fixed links in"};function AT(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":RT[e.action]??"wrote",notes:n,detail:null}}function lm(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 hm(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])=>lm(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:lm(l[0].at,d),steps:l.map(h=>AT(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 pm="Nothing recalled yet.";function zl(e,t){return t?"This turn":e.time===""?`Turn ${e.turn}`:e.time}function fm(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 gm(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 mm(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:zl(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:pm}):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:zl(r,i===0)},r.turn))})]})}function vm({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(le,{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 wm({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":no(e.heading),onClick:t,children:[p("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:p(le,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,p("span",{class:"weave-ctx-count",children:e.count})]})})}function CT({view:e,onSelect:t,onToggle:n}){return p("section",{class:"weave-ctx-group",children:[p(wm,{view:e,onToggle:n}),p("ul",{class:"weave-ctx-rows",id:no(e.heading),hidden:e.collapsed,children:e.rows.map(r=>p(vm,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function LT({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(vm,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function ym(e){let t=V(null),n=to(e.graph,e.selectedId),[r,i]=K(tm),a=s=>()=>i(am(r,s.heading,s.collapsed)),o=im(n.tags,r);return p("div",{class:"weave-rail","aria-label":ep.title,children:[e.trail===void 0?null:p(mm,{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=rm(s,r);return p(CT,{view:l,onSelect:e.onSelect,onToggle:a(l)},s.heading)}),n.tags.length===0?null:p("section",{class:"weave-ctx-group",children:[p(wm,{view:o,onToggle:a(o)}),p("ul",{class:"weave-ctx-tags weave-context-tags",ref:t,style:{height:e.tagHeight},id:no(o.heading),hidden:o.collapsed,children:n.tags.map(s=>p(LT,{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 bm(e){let t=null,n=!1,r=!1,i=async()=>{if(!(n||r)){r=!0;try{let s=await Uc(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()},Qa);return i(),()=>{n=!0,o()}}function NT(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function xm(e,t){let n=NT(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function km(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function _m(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function Tm(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):on[e.key]}function Sm(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function Em(e){return Qn.every(t=>Object.is(e[t.key],on[t.key]))}function Rm(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:_m(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:Tm(t,n.currentTarget.value)})}),p("output",{children:Sm(e.forces[t.key])})]})]},t.key)),p("button",{type:"button",disabled:Em(e.forces),onClick:()=>e.onChange({...on}),children:"Reset graph layout"})]})}var Am=["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 Cm(e){let[t,n]=K("General"),[r,i]=K(0),a=yr(),[o,s]=K(null),[l,c]=K(!1);te(()=>{Fo(_e).then(f=>{f.ok&&s(f.data.enabled)})},[]);let u=f=>{s(f),c(!0),Fo(_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:Am.map(f=>p("option",{value:f,children:f},f))}):Am.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(ye,{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(ye,{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":me[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 y=g.currentTarget.value;e.onChange({...e.layout,preferences:{...d,[`${f}Theme`]:y},theme:e.layout.theme!=="system"&&me[e.layout.theme].scheme===f?y:e.layout.theme})},children:Object.entries(me).filter(([,g])=>g.scheme===f).map(([g,y])=>p("option",{value:g,children:y.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(ye,{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(Rm,{forces:d.forces,onChange:f=>h({forces:f})})]}):null,t==="Editor"?p(ye,{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(ye,{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(ye,{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 PT({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 Lm(e){let t=yr(),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":Us,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[p("h2",{class:"weave-help-title",children:Us}),p("div",{class:"weave-keys",children:xa(n).map(r=>p(PT,{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:lp})]})]})})}function Nm(e,t){let n=r=>{if(r.defaultPrevented)return;let i=ap(op(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function Pm({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 Dm="pi-weave.theme.v1";function ro(e){try{let t=e.getItem(Dm);return Xn(t)?t:null}catch{return null}}function Im(e,t){try{return e.setItem(Dm,t),!0}catch{return!1}}function io(e,t,n=sn){return me[Wl(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function Wl(e,t,n=sn){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function Mm(e){return e==="system"?null:e}function Hl(e){return e==="system"?"System":me[e].name}function Gm(e,t="dark",n=sn){return{glyph:e==="system"?"◐":me[e].scheme==="light"?"○":"●",icon:e==="system"?"system":me[e].scheme==="light"?"sun":"moon",label:Hl(e),hint:`Colour theme: ${Hl(e)} — click for ${Hl(io(e,t,n))}`}}function ao(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 IT(e){let[t]=K(e.visits);return p("div",{class:"weave-recents",children:Jh(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(le,{name:n.icon,class:"weave-icon"})}),p("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function MT(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);$e(()=>{s&&f.current?.focus()},[s]),te(()=>{if(n===null)return;let v=e.drafts.nextLoadVersion();return Jg(_e,n,w=>{i({slug:n,note:w.ok?w.data:null,failed:!w.ok,version:v})})},[n,e.graph?.stamp,e.revision]);let g=r?.slug===n?r:null;if($e(()=>{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 y=e.graph!==null&&!e.graph.model.nodes.some(v=>v.id===t);if(y||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:y?"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. ",y?"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 w=v.target;w.classList.contains("weave-note")&&(o.current=w.scrollTop,e.onScroll(w.scrollTop))},children:p(_g,{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=>{Vc(_e,v).then(w=>{w.ok?w.data.opened||window.alert("Could not open the note in an editor."):window.alert(w.message)})},onSave:e.onSave,onHistory:v=>tu(_e,v),drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function Om(e){let[t,n]=K(Fl),[r,i]=K(()=>({...Ao(),theme:ro(localStorage)??"system"})),[a,o]=K(null),[s,l]=K(!1),[c,u]=K(Date.now),[d,h]=K(null),[f,g]=K(Date.now),[y,v]=K(null),[w,b]=K(e.initialWidth),[_,x]=K(()=>Qr(window)),[S,O]=K(!1),[z,L]=K({version:"",vaultRoot:""}),[G,I]=K(!1),[M,q]=K(0),[,Y]=K(0),[re,oe]=K(null),be=V(null),[lt,Be]=K(null),[ve,ce]=K(""),[Te,ct]=K(null),[Ne,ae]=K(null),Se=V(null),[ut,Nt]=K(null),[C,W]=K(null),[J,fe]=K(!1),[Oe,wt]=K([]),[he,_t]=K(!1),[ne]=K(Ka),Tt=V(null),Ke=V(null),gn=V(location.hash),br=V(!1),Ve=V(null),xr=V(null),mn=V(null),kr=V(null),[_r,Pt]=K({left:0,top:0,width:600,height:500}),$t=Sn(r),Je=En(r),vn=Gm(r.theme,_,r.preferences),Dt=Wl(r.theme,_,r.preferences),Vn=Pe(()=>({theme:Dt,accent:r.preferences.accent}),[Dt,r.preferences.accent]),yt=Mt(Je),Ee=Je.kind==="graph"?re:yt,Fe=r.panes.find(k=>k.tabs.some(E=>E.id===k.activeTab&&E.kind==="graph")),wn=Fe!==void 0&&(w>=850||Fe.id===r.activePane),Ae=s&&Je.kind==="document"&&!wn,zt=w<1050?he:r.contextVisible,Xt=!r.contextPinned,yn=Pe(()=>em(to(t.graph,Ee)),[t.graph,Ee]),Tr=Math.max(240,Math.min(320,r.contextWidth)),Qt=()=>{w<1050?_t(!0):i({...r,contextVisible:!0})},et=wn||Ae&&zt&&yt!==null,vi=r.panes.some(k=>k.tabs.some(E=>E.kind==="graph")),tt=V({layout:r,overlay:a,selectedId:Ee,graphPreviewId:lt,select:k=>{}}),Jt=k=>{tt.current.graphPreviewId=k,Be(k)};te(()=>{Jt(null)},[et,Ae,yt]),te(()=>{yt!==null?(be.current=yt,oe(yt)):Je.kind==="graph"&&oe(be.current)},[Je.id,Je.kind,yt]);let St=k=>{Jf(ne,tt.current.layout,k,()=>window.confirm(ya))&&i(k)},dt=(k,E=!1,B=r.activePane,X=!1)=>{let P=(k===null?ln:Fc)(r,k,{newTab:E,paneId:B});St(w<850&&!X?{...P,treeVisible:!1}:P),s||_t(!1)},jn=()=>{let k=!(Ae&&zt);l(k),k&&(i(E=>({...Bi(E),contextVisible:!0})),_t(!0))},en=()=>i(k=>({...Lo(k),...w<850?{treeVisible:!1}:{}})),ht=k=>{if(Jt(null),Ae){dt(k,!0);return}let E=r.panes.find(B=>B.id!==Fe?.id);dt(k,!0,E?.id??Fe?.id??r.activePane)},tn=k=>{Ae||oe(k),Xh(tt.current.graphPreviewId,k)?ht(k):Jt(k)},Sr=k=>{Jt(null),St(Qh(r,k,Fe?.id))},Er=(k,E=[])=>{ce(k),ct({query:k,ids:E}),ae(null),en()},oo=k=>{ce(k),ae(null)};tt.current={layout:r,overlay:a,selectedId:Ee,graphPreviewId:lt,select:dt};let wi=k=>eg(ne,k,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),Rr=async(k,E,B)=>{let X=await qc(_e,k,E,B?.raw===!0);return X.ok?(q(P=>P+1),Tt.current?.refresh(),!0):(B?.quiet!==!0&&window.alert(X.message),!1)},yi=async(k,E)=>{let B=await jc(_e,k);if(!B.ok)return window.alert(B.message),!1;let X=await qi(_e);return n(P=>({...P,graph:X.ok?X.data:null,graphFailed:!X.ok})),ne.open(B.data.note.slug,B.data.note.body),St(ln(tt.current.layout,`note:${B.data.note.slug}`,{paneId:E})),Tt.current?.refresh(),!0};te(()=>ne.subscribe(()=>Y(k=>k+1)),[ne]),te(()=>(Tt.current=Qg({fetch:_e,state:Fl(),setState:n}),()=>Tt.current?.stop()),[]),te(()=>{let k=!0;return(async()=>{try{let E=await _e("/api/workspace-state"),B=await E.json();if(!k)return;if(E.ok&&typeof B.viewId=="string"){Ke.current=B.viewId,B.info&&L(B.info);let X=Gc(B.layout);if(X){let P=Oc(X);i(P),be.current=Mt(En(Bi(P))),oe(be.current),wt(X.panes.flatMap(Q=>Q.tabs.flatMap(We=>We.history)).reduce(zs,[]))}}else I(!0)}catch{k&&I(!0)}finally{k&&O(!0)}})(),()=>{k=!1}},[]),te(()=>{if(!S||t.graph===null||br.current)return;br.current=!0;let k=xm(gn.current,t.graph);k!==null&&i(E=>ln(E,k))},[S,t.graph]),te(()=>{S&&wt(k=>zs(k,Ee))},[S,Ee]),te(()=>{S&&(history.replaceState(null,"",km(Ee)),document.documentElement.dataset.weaveTheme=Dt,document.documentElement.dataset.weaveScheme=me[Dt].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,Im(localStorage,r.theme))},[S,Ee,r.theme,Dt,r.preferences.accent]);let qn=V(Promise.resolve());te(()=>{if(!S||!Ke.current)return;let k=Ke.current,E=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})});I(!B.ok)}catch{I(!0)}})},350);return()=>window.clearTimeout(E)},[r,S]),te(()=>bm({fetch:_e,onTrail:k=>{h(k),v(null),g(Date.now())}}),[]);let bi=dm(d,f,y);te(()=>{if(!bi){y!==null&&v(null);return}let k=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(k)},[bi]);let bn=Pe(()=>um(d,f,y),[d,f,y]),xi=Pe(()=>hm(d,t.graph),[d,t.graph]),ki=Pe(()=>fm(d),[d]);te(()=>{let k=ve.trim()!==""&&document.activeElement?.classList.contains("weave-spotlight-input")===!0,E=gm(Ne,ki,k);E!==null&&(ce(E.query),ct({query:E.query,ids:E.ids}),ae(E.agent))},[ki?.seq]);let we=r.split==="down"?r.panes[0]:r.panes.at(-1),nn=we?.tabs.find(k=>k.id===we.activeTab)?.kind==="graph",_i=Xt&&(nn||Ee===null&&xi.length===0),xn=zt&&!_i,Ar=k=>{let E=Date.now();g(E),v({turn:k,startedAt:E})};te(()=>{let k=window.setInterval(()=>u(Date.now()),np),E=()=>b(window.innerWidth);window.addEventListener("resize",E);let B=jh(window,x),X=We=>{for(let rn of document.querySelectorAll(".weave-pane-menu[open]"))rn.contains(We.target)||(rn.open=!1)};document.addEventListener("pointerdown",X);let P=We=>{ne.dirtySlugs().length&&(We.preventDefault(),We.returnValue="")},Q=()=>{Ke.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:Ke.current,layout:tt.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",Q),window.addEventListener("beforeunload",P),()=>{window.clearInterval(k),window.removeEventListener("resize",E),window.removeEventListener("beforeunload",P),window.removeEventListener("pagehide",Q),document.removeEventListener("pointerdown",X),B()}},[]),te(()=>Nm(document,{context:()=>({overlay:tt.current.overlay,hasSelection:tt.current.selectedId!==null}),run:k=>sp(k,{setOverlay:o,fitGraph:()=>kr.current?.(),clearSelection:()=>{En(tt.current.layout).kind==="graph"?(oe(null),Jt(null)):tt.current.select(null)},closeTab:()=>{let E=tt.current.layout;St(Po(E,E.activePane,En(E).id))},toggleTheme:()=>i(E=>({...E,theme:io(E.theme,Qr(window),E.preferences)})),toggleContext:()=>{window.innerWidth<1050?_t(E=>!E):i(E=>({...E,contextVisible:!E.contextVisible}))},focusSelector:E=>(E===lr.graph?i(B=>({...Lo(B),...window.innerWidth<850?{treeVisible:!1}:{}})):E===lr.tree||E===Ws?i(B=>({...B,treeVisible:!0})):i(Bi),requestAnimationFrame(()=>{E===lr.note&&ba(document,".weave-pane-active .weave-note-editor")||!ba(document,E)&&E===lr.note&&ba(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),$e(()=>{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,w,S,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),$e(()=>{let k=Ae?mn.current:xr.current,E=Ve.current;if(!et||!k||!E)return;let B=()=>{let P=k.getBoundingClientRect(),Q=E.getBoundingClientRect();Pt({left:P.left-Q.left,top:P.top-Q.top,width:P.width,height:P.height})};B();let X=new ResizeObserver(B);return X.observe(k),X.observe(E),()=>X.disconnect()},[Ae,et,r,w]);let Ti=(k,E)=>i(B=>({...B,panes:B.panes.map(X=>({...X,tabs:X.tabs.map(P=>P.id===k?{...P,scroll:E}:P)}))})),Cr=(k,E)=>{Vi(r,k,Se.current)===null&&!E.dataTransfer?.types.includes(Jr)||(E.preventDefault(),E.dataTransfer&&(E.dataTransfer.dropEffect=Se.current===null?"copy":"move"),Nt(null),W(k))},Si=(k,E)=>{let B=Zh(t.graph,E.dataTransfer?.getData(Jr)??"");if(B!==null){E.preventDefault(),dt(B,!0,k),W(null);return}let X=Se.current;Vi(r,k,X)!==null&&(E.preventDefault(),i(P=>{let Q=Vi(P,k,X);return Q===null?P:tr(P,Q,X)}),Se.current=null,W(null),Nt(null))},Ei=(k,E,B)=>{k.tabs.some(X=>X.id===Se.current)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect="move",W(null),Nt({paneId:k.id,before:E}))},Ri=(k,E)=>{let B=Se.current;B===null||!k.tabs.some(X=>X.id===B)||(E.preventDefault(),E.stopPropagation(),i(X=>Mo(X,k.id,B,ut?.paneId===k.id?ut.before:null)),Se.current=null,Nt(null),W(null))},so=k=>{let E=k.tabs.find(P=>P.id===k.activeTab),B=k.id===r.activePane,X=Xt&&xn&&(r.split==="down"||k===r.panes.at(-1));return p("section",{class:`weave-pane${B?" weave-pane-active":""}${C===k.id?" weave-pane-drop":""}${X?" 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:P=>Cr(k.id,P),onDrop:P=>Si(k.id,P),onDragLeave:P=>{P.currentTarget.contains(P.relatedTarget)||W(null)},hidden:w<850&&!B,onFocusCapture:()=>{B||i(P=>({...P,activePane:k.id}))},onPointerDown:()=>{B||i(P=>({...P,activePane:k.id}))},children:[p("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:P=>Ei(k,null,P),onDrop:P=>Ri(k,P),children:[k.tabs.map(P=>p("div",{class:`weave-tab${P.id===E.id?" weave-tab-active":""}${ut?.paneId===k.id&&ut.before===P.id?" weave-tab-drop-before":""}${ut?.paneId===k.id&&ut.before===null&&P===k.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:Q=>{let We=Q.currentTarget.getBoundingClientRect(),rn=Q.clientX<We.left+We.width/2?P.id:k.tabs[k.tabs.indexOf(P)+1]?.id??null;Ei(k,rn,Q)},onDrop:Q=>Ri(k,Q),children:[p("button",{type:"button",role:"tab",title:ao(P,t.graph),id:`tab-${P.id}`,"aria-selected":P.id===E.id,"aria-controls":`panel-${k.id}`,tabIndex:P.id===E.id?0:-1,draggable:!0,onDragStart:Q=>{Se.current=P.id,Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("application/x-weave-tab",P.id)},onClick:()=>i(No(r,k.id,P.id)),onKeyDown:Q=>{let We=Q.key==="ArrowRight"?1:Q.key==="ArrowLeft"?-1:0;if(We&&Q.altKey&&!Q.ctrlKey&&!Q.metaKey){Q.preventDefault(),Q.stopPropagation();let Nr=k.tabs.indexOf(P),Yn=We<0?k.tabs[Math.max(0,Nr-1)].id:k.tabs[Nr+2]?.id??null;i(Mo(r,k.id,P.id,Yn)),requestAnimationFrame(()=>document.getElementById(`tab-${P.id}`)?.focus());return}if(!We&&Q.key!=="Home"&&Q.key!=="End")return;Q.preventDefault();let rn=Q.key==="Home"?0:Q.key==="End"?k.tabs.length-1:(k.tabs.indexOf(P)+We+k.tabs.length)%k.tabs.length,Lr=k.tabs[rn];i(No(r,k.id,Lr.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Lr.id}`)?.focus())},children:[p("span",{"aria-hidden":"true",children:p(le,{name:P.kind==="graph"?"graph":"note",class:"weave-icon"})}),p("span",{children:ao(P,t.graph)}),ne.isDirty((Mt(P)??"").slice(5))?p("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),p("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${ao(P,t.graph)}`,onClick:()=>St(Po(r,k.id,P.id)),children:"×"})]},P.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:E.kind==="graph"||E.cursor===0,onClick:()=>St(Do({...r,activePane:k.id},k.id,-1)),children:"←"}),p("button",{type:"button","aria-label":"Navigate forward",disabled:E.kind==="graph"||E.cursor>=E.history.length-1,onClick:()=>St(Do({...r,activePane:k.id},k.id,1)),children:"→"}),p("span",{class:"weave-breadcrumb",children:ao(E,t.graph)}),p("details",{class:"weave-pane-menu",onKeyDown:P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),P.currentTarget.open=!1,P.currentTarget.querySelector("summary")?.focus())},children:[p("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),p("div",{onClick:P=>{let Q=P.currentTarget.closest("details");Q&&(Q.open=!1)},children:[p("button",{type:"button",onClick:()=>i(Io({...r,activePane:k.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),p("button",{type:"button",onClick:()=>i(Io({...r,activePane:k.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?p(ye,{children:[p("button",{type:"button",onClick:()=>i(tr(r,k.id,E.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(Mc(r,k.id)),children:"Close pane"})]}):null]})]})]}),p("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${k.id}`,"aria-labelledby":`tab-${E.id}`,...E.kind==="graph"?{ref:xr}:{},children:E.kind==="document"?p(MT,{preferences:r.preferences,tab:E,graph:t.graph,drafts:ne,revision:M,now:c,onSelect:(P,Q)=>dt(P,Q,k.id),onSave:Rr,onScroll:P=>Ti(E.id,P),onSearch:()=>o("search"),onGraph:en,onCreate:P=>yi(P,k.id)},`${E.id}:${E.cursor}:${Mt(E)}`):null})]},k.id)};return p(ye,{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":`${Tr}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(le,{name:"sidebar",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Open graph view",title:"Graph view",onClick:en,children:p(le,{name:"graph",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Toggle note graph",title:"Note graph","aria-pressed":Ae&&zt,onClick:jn,children:p(le,{name:"noteGraph",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Search notes and repository",title:rp(ei(ti(e.platform))),onClick:()=>o("search"),children:p(le,{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:()=>w<1050?_t(!he):i({...r,contextVisible:!r.contextVisible}),children:p(le,{name:"context",class:"weave-icon"})}),p("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{Tt.current?.refresh(),q(k=>k+1)},children:p(le,{name:"refresh",class:"weave-icon"})}),p("button",{type:"button","aria-label":vn.hint,title:vn.hint,onClick:()=>i({...r,theme:io(r.theme,_,r.preferences)}),children:p(le,{name:vn.icon,class:"weave-icon"})}),p("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>o("settings"),children:p(le,{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,w-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":!J,onClick:()=>fe(!1),children:"Files"}),p("button",{type:"button","aria-pressed":J,onClick:()=>fe(!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:"«"})]}),J?p(IT,{visits:Oe,graph:t.graph,selectedId:Ee,onSelect:dt}):p(up,{graph:t.graph,selectedId:Ee,recentIds:t.recentIds,onSelect:(k,E,B)=>dt(k,E,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(E=>({...E,treeWidth:Math.max(180,Math.min(420,E.treeWidth+k))}))})]}),p("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&w>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:S?r.panes.map((k,E)=>p(ye,{children:[E>0&&w>=850?p(Kn,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:B=>{let X=r.split==="right"?Ve.current?.querySelector("main")?.clientWidth:Ve.current?.querySelector("main")?.clientHeight;i(P=>({...P,ratio:Math.max(.2,Math.min(.8,P.ratio+B/(X??800)))}))}}):null,so(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(E=>({...E,contextWidth:Math.max(180,Math.min(400,E.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(le,{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(le,{name:"chevron",class:"weave-icon weave-icon-open"}):"»"})]}),Ae?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:_r.height,onChange:k=>i(E=>({...E,contextGraphHeight:Math.max(120,Math.min(800,(mn.current?.clientHeight??E.contextGraphHeight)+k))}))})]}):null,p(ym,{graph:t.graph,selectedId:Ee,onSelect:dt,trail:xi,trailTurn:y?.turn??null,onReplay:Ar,tagHeight:r.contextTagsHeight,onTagResize:k=>i(E=>({...E,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(le,{name:"context",class:"weave-icon"}),"Context",p("span",{class:"weave-context-count",children:yn})]}):null,vi||s?p("div",{class:`weave-graph-host${Ae?" weave-context-graph-host":""}`,onDragOver:k=>{!Ae&&Fe&&Cr(Fe.id,k)},onDrop:k=>{!Ae&&Fe&&Si(Fe.id,k)},onDragLeave:k=>{k.currentTarget.contains(k.relatedTarget)||W(null)},onPointerDown:()=>{!Ae&&Fe&&i(k=>({...k,activePane:Fe.id}))},onFocusCapture:()=>{!Ae&&Fe&&i(k=>({...k,activePane:Fe.id}))},"aria-hidden":!et,inert:!et,role:Ae?"region":void 0,"aria-label":Ae?"Note graph":void 0,style:{..._r,visibility:et?"visible":"hidden",pointerEvents:et?"auto":"none"},children:p(hp,{graph:t.graph,selectedId:Ee,previewId:lt,onSelect:tn,onOpen:ht,renderer:Df,storage:localStorage,host:window,scheme:Vn,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:kr,trail:bn,...Ae?{}:{query:ve,...Te?.query===ve?{found:Te.ids}:{},byAgent:Ne!==null,onQuery:oo,onOpenSplit:Sr},now:c})}):null]}),p("div",{class:"weave-footer",children:[p(Pm,{model:tp(e.cwd,Ee,ei(ti(e.platform)))}),G?p("span",{role:"status",children:"Workspace restoration unavailable"}):null,ne.dirtySlugs().length?p("span",{children:[ne.dirtySlugs().length," unsaved"]}):null,w<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(Yg,{graph:t.graph,onSelect:dt,onLightUp:Er,onClose:()=>o(null),ports:{fetch:_e}}):null,a==="settings"?p(Cm,{compact:w<=650,layout:r,info:z,cwd:e.cwd,shortcut:ei(ti(e.platform)),onChange:k=>{St(k),_t(k.contextVisible)},onRefresh:()=>{Tt.current?.refresh(),q(k=>k+1)},onClose:()=>o(null)}):null,a==="help"?p(Lm,{shortcut:ei(ti(e.platform)),onClose:()=>o(null)}):null]})}var Fm=`
|
|
412
419
|
.weave-workbench{position:relative;isolation:isolate;display:flex;min-height:0;overflow:hidden;background:var(--weave-page)}
|
|
413
420
|
.weave-workbench button{font:inherit;color:inherit;cursor:pointer}
|
|
414
421
|
.weave-workbench button:focus-visible,.weave-workbench summary:focus-visible{outline:2px solid var(--weave-accent);outline-offset:-2px}
|
|
415
422
|
.weave-workbench button:disabled{opacity:.35;cursor:default}
|
|
416
423
|
.weave-ribbon{width:44px;flex:none;display:flex;align-items:center;flex-direction:column;gap:8px;padding:12px 0;background:var(--weave-panel);border-right:1px solid var(--weave-line)}
|
|
417
|
-
.weave-ribbon button{width:32px;height:32px;border:0;border-radius:var(--weave-radius);background:transparent;font-size:var(--weave-px-display);color:var(--weave-dim)}
|
|
424
|
+
.weave-ribbon button{width:32px;height:32px;display:grid;place-items:center;border:0;border-radius:var(--weave-radius);background:transparent;font-size:var(--weave-px-display);color:var(--weave-dim)}
|
|
418
425
|
.weave-ribbon button:hover,.weave-ribbon button[aria-pressed=true]{color:var(--weave-accent);background:var(--weave-new)}
|
|
419
426
|
.weave-ribbon-space{flex:1}
|
|
420
427
|
.weave-sidebar{flex:none;min-width:0;display:flex;flex-direction:column;background:var(--weave-panel);overflow:hidden}
|
|
@@ -474,20 +481,24 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
474
481
|
.weave-pane-menu button{text-align:left;border:0;background:none;padding:9px 10px;font-size:var(--weave-px-row)}
|
|
475
482
|
.weave-pane-menu button:hover{background:var(--weave-new)}
|
|
476
483
|
.weave-pane-content{min-width:0;min-height:0;display:flex;overflow:hidden;position:relative}
|
|
477
|
-
.
|
|
484
|
+
/* The reading column's gutters. Centred at the reading width; where the
|
|
485
|
+
floating Context card covers the right margin, the right gutter grows to
|
|
486
|
+
clear it and the column slides left before it narrows. */
|
|
487
|
+
.weave-document{display:flex;min-width:0;min-height:0;flex:1;
|
|
488
|
+
--weave-gutter-c:max(24px,calc((100% - var(--weave-reading-width,760px))/2));
|
|
489
|
+
--weave-gutter-r:max(var(--weave-gutter-c),var(--weave-card-space,0px));
|
|
490
|
+
--weave-gutter-l:max(24px,min(var(--weave-gutter-c),calc(100% - var(--weave-reading-width,760px) - var(--weave-gutter-r))))}
|
|
478
491
|
.weave-document .weave-note{width:100%;border-left:0}
|
|
479
|
-
.weave-document .weave-note-head{position:static;padding:28px
|
|
480
|
-
.weave-document .weave-note-title{font-size:var(--weave-px-display);letter-spacing:-.03em;margin-bottom:
|
|
481
|
-
.weave-document .weave-note-body{padding:10px
|
|
492
|
+
.weave-document .weave-note-head{position:static;padding:28px var(--weave-gutter-r) 18px var(--weave-gutter-l);border:0}
|
|
493
|
+
.weave-document .weave-note-title{font-size:var(--weave-px-display);letter-spacing:-.03em;margin-bottom:10px}
|
|
494
|
+
.weave-document .weave-note-body{padding:10px var(--weave-gutter-r) 64px var(--weave-gutter-l);font-size:var(--weave-note-size,var(--weave-px-subhead));line-height:1.8}
|
|
482
495
|
.weave-document .weave-note-body h1{font-size:var(--weave-px-display);line-height:1.4;margin-bottom:18px}
|
|
483
496
|
.weave-document .weave-note-body h2{font-size:var(--weave-px-title);margin-top:28px}
|
|
484
|
-
.weave-document .weave-note-editor{padding:14px
|
|
497
|
+
.weave-document .weave-note-editor{padding:14px var(--weave-gutter-r) 14px var(--weave-gutter-l);min-height:220px;flex:1;font-size:var(--weave-note-size,var(--weave-px-subhead))}
|
|
485
498
|
.weave-document .weave-note-tags{margin-top:12px}
|
|
486
|
-
.weave-document .weave-replay{padding:12px
|
|
487
|
-
.weave-document .weave-raw{margin:0
|
|
488
|
-
.weave-document .weave-
|
|
489
|
-
.weave-document .weave-note-edit{color:var(--weave-dim);background:transparent;border-color:transparent}
|
|
490
|
-
.weave-document .weave-note-edit:hover{color:var(--weave-accent);background:var(--weave-new);border-color:transparent}
|
|
499
|
+
.weave-document .weave-replay{padding:12px var(--weave-gutter-r) 14px var(--weave-gutter-l)}
|
|
500
|
+
.weave-document .weave-raw{margin:0 var(--weave-gutter-r) 28px var(--weave-gutter-l)}
|
|
501
|
+
.weave-document .weave-editbar{padding-right:calc(12px + var(--weave-card-space,0px))}
|
|
491
502
|
.weave-welcome{align-self:center;margin:auto;padding:35px;max-width:560px;color:var(--weave-dim);line-height:1.7}
|
|
492
503
|
.weave-welcome-mark{font-size:var(--weave-px-display);color:var(--weave-accent)}
|
|
493
504
|
.weave-welcome h1{font-size:var(--weave-px-display);line-height:1.4;letter-spacing:-.025em;color:var(--weave-fg);font-weight:550}
|
|
@@ -526,6 +537,29 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
526
537
|
.weave-footer>.weave-status{flex:1;min-width:0;border:0}
|
|
527
538
|
.weave-footer>span{padding:4px 10px;white-space:nowrap}
|
|
528
539
|
.weave-footer>button{font:inherit;color:var(--weave-fg);background:none;border:0;padding:7px 12px;cursor:pointer}
|
|
540
|
+
/* Context as a floating card (C1): over the page's right margin, below the
|
|
541
|
+
pane toolbar, folding to a pill in the toolbar strip. Pinned, it is the
|
|
542
|
+
column it always was. The shadow is the card's only elevation, and lives
|
|
543
|
+
here rather than in THEME_CSS, whose surfaces are flat by rule. */
|
|
544
|
+
.weave-context-dock.weave-context-float{position:absolute;top:90px;right:14px;bottom:auto;z-index:10;width:var(--weave-card-width);max-height:calc(100% - 104px);border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);background:var(--weave-panel);box-shadow:0 12px 32px #0000001f,0 2px 6px #00000014;transition:opacity 160ms ease,visibility 0s}
|
|
545
|
+
.weave-context-dock.weave-context-float[data-open=false]{width:var(--weave-card-width);opacity:0;visibility:hidden;transition:opacity 160ms ease,visibility 0s 160ms}
|
|
546
|
+
.weave-context-float>.weave-workspace-divider{display:none}
|
|
547
|
+
.weave-context-float>.weave-sidebar,.weave-context-float[data-open=false]>.weave-sidebar{width:100%;max-height:100%;border:0;background:none;transform:none}
|
|
548
|
+
.weave-context-float .weave-sidebar-heading{height:38px;padding:0 6px 0 12px;border-bottom:1px solid var(--weave-line)}
|
|
549
|
+
.weave-context-float .weave-rail{padding:4px 12px 10px}
|
|
550
|
+
.weave-context-float .weave-context-graph-slot{max-height:calc(100dvh - 260px)}
|
|
551
|
+
.weave-context-float .weave-context-tags{height:auto!important;max-height:220px}
|
|
552
|
+
.weave-context-float .weave-ctx-group>.weave-workspace-divider{display:none}
|
|
553
|
+
.weave-context-heading strong{color:var(--weave-fg)}
|
|
554
|
+
.weave-context-count{min-width:18px;padding:1px 6px;border-radius:999px;background:var(--weave-raise);color:var(--weave-dim);font-size:var(--weave-px-caption);line-height:1.4;text-align:center}
|
|
555
|
+
.weave-sidebar-heading .weave-context-pin{margin-left:auto}
|
|
556
|
+
.weave-context-heading button:last-child{margin-left:0}
|
|
557
|
+
.weave-context-heading .weave-context-pin[aria-pressed=true]{color:var(--weave-accent)}
|
|
558
|
+
.weave-context-heading button{display:grid;place-items:center;width:28px;height:28px;padding:0}
|
|
559
|
+
.weave-context-pill{position:absolute;top:47px;right:54px;z-index:10;display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 6px 0 9px;border:1px solid var(--weave-line-strong);border-radius:999px;background:var(--weave-panel);color:var(--weave-dim)!important;font-size:var(--weave-px-caption)!important;box-shadow:0 2px 8px #00000014}
|
|
560
|
+
.weave-context-pill:hover{color:var(--weave-fg)!important;border-color:var(--weave-accent)}
|
|
561
|
+
.weave-context-pill .weave-icon{width:13px;height:13px}
|
|
562
|
+
.weave-pane-under-card{--weave-card-space:calc(var(--weave-card-width) + 28px)}
|
|
529
563
|
@media(max-width:1049px){
|
|
530
564
|
.weave-context-dock{position:absolute;right:0;top:0;bottom:0;z-index:10;width:var(--weave-sidebar-width)}
|
|
531
565
|
.weave-sidebar-context{border-left:1px solid var(--weave-line-strong)}
|
|
@@ -574,9 +608,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
574
608
|
@media(prefers-reduced-motion:reduce){.weave-settings-actions button{transition:none}.weave-settings-actions button:active{transform:none}.weave-refresh-spin{animation:none}}
|
|
575
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)}
|
|
576
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}}
|
|
577
|
-
`;function
|
|
611
|
+
`;function Ul(e){let{scheme:t,colors:n}=me[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 GT=`
|
|
578
612
|
:root{
|
|
579
|
-
${
|
|
613
|
+
${Ul("dark")}
|
|
580
614
|
--weave-row:26px;--weave-gutter:10px;
|
|
581
615
|
/* The reading gutter is note-only: prose wants a wider margin than chrome.
|
|
582
616
|
Rails, rows and bars keep --weave-gutter, so density is a property of the
|
|
@@ -584,8 +618,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
584
618
|
--weave-note-gutter:18px;
|
|
585
619
|
/* The desk-and-page split. The workspace is a desk of instruments — tree,
|
|
586
620
|
graph, rail, bars — on the --weave-bg ground; the note column is the one
|
|
587
|
-
*page* lying on it: crust
|
|
588
|
-
|
|
621
|
+
*page* lying on it: crust under dark, plain white under Latte (the
|
|
622
|
+
refresh's "quiet page": paper reads as paper), the ground that sits
|
|
623
|
+
furthest from the desk. Two
|
|
589
624
|
voices in total: sans for instruments and prose alike, mono for data — a
|
|
590
625
|
third face was tried (serif prose) and withdrawn at the user's call; two
|
|
591
626
|
voices read calmer than three. The CSP allows nothing fetched, and both
|
|
@@ -596,7 +631,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
596
631
|
two overlays that float above the grid. Tag pills are 999px — a capsule
|
|
597
632
|
shape, not a scale step. The gate test below refuses any literal px
|
|
598
633
|
radius so the scale cannot drift back. */
|
|
599
|
-
--weave-radius:
|
|
634
|
+
--weave-radius:6px;--weave-radius-pop:10px;
|
|
600
635
|
/* The type ramp, role-named because sizes drift and roles stick. Nine
|
|
601
636
|
steps; every font-size in this sheet is one of these vars — that is a
|
|
602
637
|
gate, not a convention:
|
|
@@ -608,7 +643,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
608
643
|
body 13.5 the note column's prose
|
|
609
644
|
subhead 14 palette input, note-body h2, ribbon icon buttons
|
|
610
645
|
title 15 note-body h1
|
|
611
|
-
display
|
|
646
|
+
display 26 the note's page title (20 before the refresh)
|
|
612
647
|
Two earlier sizes were merged into neighbours: 9px glyphs to prov, and
|
|
613
648
|
the 10px column overlines to caption (caps plus .09em tracking already
|
|
614
649
|
read larger than their point size suggests). \`display\` and \`body\` are
|
|
@@ -623,14 +658,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
|
|
|
623
658
|
rubber stamp. */
|
|
624
659
|
--weave-px-prov:9.5px;--weave-px-caption:10.5px;--weave-px-ui:11.5px;
|
|
625
660
|
--weave-px-row:12px;--weave-px-base:13px;--weave-px-body:13.5px;
|
|
626
|
-
--weave-px-subhead:14px;--weave-px-title:15px;--weave-px-display:
|
|
661
|
+
--weave-px-subhead:14px;--weave-px-title:15px;--weave-px-display:26px;
|
|
627
662
|
}
|
|
628
663
|
@media (prefers-color-scheme: light){
|
|
629
|
-
:root:not([data-weave-theme]){${
|
|
664
|
+
:root:not([data-weave-theme]){${Ul("light")}}
|
|
630
665
|
}
|
|
631
|
-
${Object.keys(
|
|
666
|
+
${Object.keys(me).map(e=>`:root[data-weave-theme="${e}"]{${Ul(e)}}`).join(`
|
|
632
667
|
`)}
|
|
633
|
-
${Object.entries(
|
|
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(`
|
|
634
669
|
`)).join(`
|
|
635
670
|
`)}
|
|
636
671
|
body{font-size:var(--weave-px-base)}
|
|
@@ -681,10 +716,14 @@ body{font-size:var(--weave-px-base)}
|
|
|
681
716
|
provenance glyph shape carries the distinction the colour swap drops;
|
|
682
717
|
elsewhere the hues are unaffected. The palette's hit rows need the same
|
|
683
718
|
remap: same selected ground, same failure. The label is restated last
|
|
684
|
-
so the selected row is always readable.
|
|
719
|
+
so the selected row is always readable. The ground itself is the Context
|
|
720
|
+
rail's selection: the --weave-new tint plus a 2px inset accent bar, kept
|
|
721
|
+
under the pointer too. It is the only tinted row: the tree is where you
|
|
722
|
+
are, not what the agent touched (the graph shows that). */
|
|
723
|
+
.weave-row-on,.weave-row-on:hover{background:var(--weave-new);box-shadow:inset 2px 0 0 var(--weave-accent)}
|
|
685
724
|
.weave-row-on .weave-twisty,.weave-row-on .weave-kind,.weave-row-on .weave-prov,
|
|
686
725
|
.weave-row-on .weave-meta,.weave-row-on .weave-label{color:var(--weave-fg)}
|
|
687
|
-
.weave-hit-on .weave-hit-
|
|
726
|
+
.weave-hit-on .weave-hit-icon,.weave-hit-on .weave-hit-detail,.weave-hit-on .weave-hit-meta{color:var(--weave-fg)}
|
|
688
727
|
/* A newly-arrived node (a file or note added since the last update, ):
|
|
689
728
|
one short highlight that fades while the label settles from bold back to
|
|
690
729
|
normal. The class is computed from the frame diff in workspace.ts and
|
|
@@ -696,16 +735,6 @@ body{font-size:var(--weave-px-base)}
|
|
|
696
735
|
40%{font-weight:700}
|
|
697
736
|
100%{background:transparent;font-weight:400}
|
|
698
737
|
}
|
|
699
|
-
/* Recall trail (issue #78): a note the agent searched, read or wrote. The
|
|
700
|
-
tint follows the graph's palette for the same kinds (warn → ok → accent)
|
|
701
|
-
and steps down through three strength buckets as the glow fades. */
|
|
702
|
-
.weave-row-trail{--weave-trail:var(--weave-warn);box-shadow:inset 2px 0 0 color-mix(in srgb,var(--weave-trail) var(--weave-trail-mix),transparent);background:color-mix(in srgb,var(--weave-trail) calc(var(--weave-trail-mix) / 6),transparent)}
|
|
703
|
-
.weave-row-trail-read{--weave-trail:var(--weave-ok)}
|
|
704
|
-
.weave-row-trail-wrote{--weave-trail:var(--weave-accent)}
|
|
705
|
-
.weave-row-trail-3{--weave-trail-mix:90%}
|
|
706
|
-
.weave-row-trail-2{--weave-trail-mix:55%}
|
|
707
|
-
.weave-row-trail-1{--weave-trail-mix:25%}
|
|
708
|
-
.weave-row-trail-wrote.weave-row-trail-3 .weave-label{font-weight:600}
|
|
709
738
|
.weave-twisty{width:16px;height:16px;flex:none;display:inline-flex;align-items:center;justify-content:center;color:var(--weave-faint);cursor:pointer}
|
|
710
739
|
.weave-kind{flex:none;color:var(--weave-faint);font-size:var(--weave-px-ui)}
|
|
711
740
|
.weave-prov{flex:none;font-size:var(--weave-px-prov)}
|
|
@@ -763,7 +792,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
763
792
|
.weave-note-head{position:sticky;top:0;z-index:2;padding:14px var(--weave-note-gutter) 9px;background:var(--weave-page);border-bottom:1px solid var(--weave-line)}
|
|
764
793
|
/* The page's largest voice, and the point of the review's headline finding:
|
|
765
794
|
a 15px title sat 1.5px above the body it named. --weave-px-display puts the
|
|
766
|
-
title where a page's title belongs, weight 650 for presence at
|
|
795
|
+
title where a page's title belongs, weight 650 for presence at 26px (600
|
|
767
796
|
reads thin at that size, 700 reads as a poster), tracking pulled in by a
|
|
768
797
|
hair because large sans needs it. */
|
|
769
798
|
.weave-note-title{margin:0 0 4px;font-size:var(--weave-px-display);font-weight:650;line-height:1.25;letter-spacing:-.005em;color:var(--weave-fg)}
|
|
@@ -780,20 +809,67 @@ body{font-size:var(--weave-px-base)}
|
|
|
780
809
|
}
|
|
781
810
|
.weave-note-open:hover{color:var(--weave-fg);background:var(--weave-line)}
|
|
782
811
|
.weave-note-open-mark{display:inline-flex;line-height:0}
|
|
783
|
-
/*
|
|
784
|
-
|
|
785
|
-
.
|
|
812
|
+
/* The note's own actions, at the end of the meta line. History is a quiet
|
|
813
|
+
word with an icon; Edit is the one bordered control, and neither outweighs
|
|
814
|
+
the title. */
|
|
815
|
+
.weave-note-actions{margin-left:auto;display:inline-flex;align-items:center;gap:4px}
|
|
816
|
+
.weave-note-meta .weave-note-action{
|
|
817
|
+
display:inline-flex;align-items:center;gap:5px;
|
|
786
818
|
font:inherit;font-size:var(--weave-px-caption);line-height:1;white-space:nowrap;cursor:pointer;
|
|
787
|
-
color:var(--weave-dim);background:
|
|
788
|
-
border:1px solid
|
|
819
|
+
color:var(--weave-dim);background:none;padding:5px 8px;
|
|
820
|
+
border:1px solid transparent;border-radius:var(--weave-radius);
|
|
821
|
+
}
|
|
822
|
+
.weave-note-meta .weave-note-action .weave-icon{width:13px;height:13px}
|
|
823
|
+
.weave-note-meta .weave-note-action:hover{color:var(--weave-fg);background:var(--weave-new)}
|
|
824
|
+
.weave-note-meta .weave-note-action:disabled{color:var(--weave-faint);background:none;cursor:default}
|
|
825
|
+
.weave-note-meta .weave-note-edit{color:var(--weave-fg);background:var(--weave-page);border-color:var(--weave-line-strong)}
|
|
826
|
+
.weave-note-meta .weave-note-edit:hover{border-color:var(--weave-accent);background:var(--weave-page)}
|
|
827
|
+
.weave-note-meta .weave-note-history[aria-pressed="true"]{color:var(--weave-accent);background:var(--weave-new)}
|
|
828
|
+
/* Where the note lives, above its title: a crumb, not a heading. */
|
|
829
|
+
.weave-note-crumb{margin:0 0 6px;display:flex;align-items:center;gap:5px;font-size:var(--weave-px-caption);color:var(--weave-faint)}
|
|
830
|
+
.weave-note-crumb .weave-icon{width:12px;height:12px}
|
|
831
|
+
/* Who wrote it, in words, with the spine's colour as a dot. */
|
|
832
|
+
.weave-note-meta .weave-prov{display:inline-flex;align-items:center;gap:6px;font-size:var(--weave-px-ui);color:var(--weave-dim)}
|
|
833
|
+
.weave-prov-dot{width:7px;height:7px;border-radius:999px;background:var(--weave-spine,var(--weave-accent))}
|
|
834
|
+
/* The edit bar (E1): one row while editing, pinned over the text it edits.
|
|
835
|
+
Formatting on the left, where the words are; the save state and the two
|
|
836
|
+
ways out on the right. Saving is automatic, so Done is the only
|
|
837
|
+
affirmative control and the only one in the accent. */
|
|
838
|
+
.weave-editbar{
|
|
839
|
+
position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:6px;flex-wrap:wrap;
|
|
840
|
+
min-height:40px;padding:5px 12px;font-size:var(--weave-px-ui);
|
|
841
|
+
background:var(--weave-page);border-bottom:1px solid var(--weave-line);
|
|
789
842
|
}
|
|
790
|
-
.weave-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
.weave-
|
|
843
|
+
.weave-editbar .weave-icon{width:14px;height:14px}
|
|
844
|
+
.weave-editbar-badge{
|
|
845
|
+
display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:999px;
|
|
846
|
+
font-size:var(--weave-px-caption);font-weight:600;color:var(--weave-accent);background:var(--weave-new);
|
|
847
|
+
}
|
|
848
|
+
.weave-editbar-badge .weave-icon{width:12px;height:12px}
|
|
849
|
+
.weave-editbar-tools{display:inline-flex;align-items:center;gap:1px;margin-left:4px;padding-left:8px;border-left:1px solid var(--weave-line)}
|
|
850
|
+
.weave-editbar .weave-editbar-tool{
|
|
851
|
+
display:inline-grid;place-items:center;width:28px;height:28px;padding:0;cursor:pointer;
|
|
852
|
+
color:var(--weave-dim);background:none;border:0;border-radius:var(--weave-radius);
|
|
853
|
+
}
|
|
854
|
+
.weave-editbar .weave-editbar-tool:hover{color:var(--weave-fg);background:var(--weave-new)}
|
|
855
|
+
.weave-editbar-status{margin-left:auto;display:inline-flex;align-items:center;gap:5px;white-space:nowrap;font-size:var(--weave-px-caption);color:var(--weave-faint)}
|
|
856
|
+
.weave-editbar-pending,.weave-editbar-saving{color:var(--weave-dim)}
|
|
857
|
+
.weave-editbar-saved{color:var(--weave-ok)}
|
|
858
|
+
.weave-editbar-failed{color:var(--weave-bad);font-weight:600}
|
|
859
|
+
.weave-editbar .weave-editbar-retry{font:inherit;color:var(--weave-accent);background:none;border:0;padding:2px 4px;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
|
|
860
|
+
.weave-editbar .weave-editbar-discard,.weave-editbar .weave-editbar-done{font:inherit;font-size:var(--weave-px-caption);line-height:1;white-space:nowrap;cursor:pointer;border-radius:var(--weave-radius)}
|
|
861
|
+
.weave-editbar .weave-editbar-discard{padding:7px 9px;color:var(--weave-dim);background:none;border:1px solid transparent}
|
|
862
|
+
.weave-editbar .weave-editbar-discard:hover{color:var(--weave-fg);background:var(--weave-new)}
|
|
863
|
+
.weave-editbar .weave-editbar-done{padding:7px 14px;font-weight:600;color:var(--weave-page);background:var(--weave-accent);border:1px solid var(--weave-accent)}
|
|
864
|
+
.weave-editbar .weave-editbar-done:hover{filter:brightness(1.08)}
|
|
865
|
+
.weave-editbar .weave-editbar-discard:disabled,.weave-editbar .weave-editbar-done:disabled{opacity:.5;cursor:default;filter:none}
|
|
866
|
+
/* A finalized note's opening TLDR, set apart as the first thing to read.
|
|
867
|
+
The label is the card's own; task boxes keep their row and lose the bullet. */
|
|
868
|
+
.weave-tldr{margin:0 0 18px;padding:12px 16px;background:var(--weave-new);border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius)}
|
|
869
|
+
.weave-tldr>p,.weave-tldr>ul,.weave-tldr>ol{margin:0 0 6px}
|
|
870
|
+
.weave-tldr>*:last-child{margin-bottom:0}
|
|
871
|
+
.weave-tldr ul:has(>li>input[type="checkbox"]){list-style:none;padding-left:2px}
|
|
872
|
+
.weave-tldr-label{display:block;margin-bottom:3px;font-size:var(--weave-px-prov);font-weight:700;letter-spacing:.08em;color:var(--weave-accent)}
|
|
797
873
|
/* The replay band sits under the header like the header itself: full width,
|
|
798
874
|
the note's gutter, one line of words, one line of controls. Dots on the
|
|
799
875
|
track are the versions, coloured by who made them. */
|
|
@@ -824,25 +900,28 @@ body{font-size:var(--weave-px-base)}
|
|
|
824
900
|
.weave-replay-controls button:disabled{color:var(--weave-faint);cursor:default;opacity:.6}
|
|
825
901
|
.weave-replay-controls .weave-replay-play{color:var(--weave-page);background:var(--weave-accent);border-color:var(--weave-accent)}
|
|
826
902
|
.weave-replay-controls .weave-replay-play:hover:not(:disabled){filter:brightness(1.08)}
|
|
827
|
-
|
|
903
|
+
/* The change bars (the refresh's H2): one bar per version, as tall as the
|
|
904
|
+
change was big, coloured by who made it; the version on screen is ringed.
|
|
905
|
+
The day labels sit under the band. Heights and label positions arrive as
|
|
906
|
+
custom properties through Preact's CSSOM style path, never an attribute. */
|
|
907
|
+
.weave-replay-track{--weave-replay-at:100%;position:relative;flex:1;min-width:80px;height:46px;margin-left:8px}
|
|
828
908
|
.weave-replay-track::before{
|
|
829
|
-
content:"";position:absolute;left:7px;right:7px;top:
|
|
909
|
+
content:"";position:absolute;left:7px;right:7px;top:31px;height:2px;border-radius:999px;
|
|
830
910
|
background:linear-gradient(to right,color-mix(in srgb,var(--weave-accent) 55%,transparent) var(--weave-replay-at),var(--weave-line-strong) var(--weave-replay-at));
|
|
831
911
|
}
|
|
832
|
-
.weave-replay-
|
|
833
|
-
.weave-replay-
|
|
834
|
-
.weave-replay-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
.weave-replay-ahead::before{opacity:.4}
|
|
912
|
+
.weave-replay-bars{position:absolute;left:7px;right:7px;top:2px;height:26px;pointer-events:none}
|
|
913
|
+
.weave-replay-bar{position:absolute;bottom:0;left:var(--weave-bar-at,0);width:max(1px,min(8px,calc(100% / var(--weave-bars,1) - 2px)));transform:translateX(-50%);height:var(--weave-bar,14%);border-radius:var(--weave-radius);background:var(--weave-who);opacity:.85}
|
|
914
|
+
.weave-replay-ahead{opacity:.35}
|
|
915
|
+
.weave-replay-current{opacity:1;outline:2px solid var(--weave-accent);outline-offset:1px}
|
|
916
|
+
.weave-replay-days{position:absolute;left:7px;right:7px;top:34px;height:12px;pointer-events:none}
|
|
917
|
+
.weave-replay-day{position:absolute;left:var(--weave-day-at,0);transform:translateX(-2px);font-size:var(--weave-px-prov);line-height:12px;color:var(--weave-faint);white-space:nowrap}
|
|
839
918
|
.weave-replay-slider{position:absolute;inset:0;width:100%;height:100%;margin:0;background:transparent;-webkit-appearance:none;appearance:none;cursor:pointer}
|
|
840
919
|
.weave-replay-slider:disabled{cursor:default}
|
|
841
920
|
.weave-replay-slider:focus{outline:none}
|
|
842
|
-
.weave-replay-slider::-webkit-slider-runnable-track{height:
|
|
843
|
-
.weave-replay-slider::-moz-range-track{height:
|
|
921
|
+
.weave-replay-slider::-webkit-slider-runnable-track{height:46px;background:transparent}
|
|
922
|
+
.weave-replay-slider::-moz-range-track{height:46px;background:transparent}
|
|
844
923
|
.weave-replay-slider::-webkit-slider-thumb{
|
|
845
|
-
-webkit-appearance:none;appearance:none;width:14px;height:14px;margin-top:
|
|
924
|
+
-webkit-appearance:none;appearance:none;width:14px;height:14px;margin-top:25px;border-radius:999px;
|
|
846
925
|
background:var(--weave-page);border:2px solid var(--weave-accent);box-sizing:border-box;
|
|
847
926
|
}
|
|
848
927
|
.weave-replay-slider::-moz-range-thumb{
|
|
@@ -860,7 +939,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
860
939
|
display:block;width:100%;flex:1 0 auto;min-height:12em;resize:none;
|
|
861
940
|
padding:12px var(--weave-note-gutter) 28px;box-sizing:border-box;
|
|
862
941
|
font-family:var(--weave-mono);font-size:var(--weave-px-row);line-height:1.6;
|
|
863
|
-
color:var(--weave-fg);background:var(--weave-
|
|
942
|
+
color:var(--weave-fg);background:var(--weave-page);border:0;outline:0;
|
|
864
943
|
}
|
|
865
944
|
/* The \`## Raw\` box under the editor: folded by default so a long
|
|
866
945
|
dictation never outgrows the note, a dashed edge to say "captured, not
|
|
@@ -1034,6 +1113,114 @@ body{font-size:var(--weave-px-base)}
|
|
|
1034
1113
|
border-top:1px solid var(--weave-line);
|
|
1035
1114
|
}
|
|
1036
1115
|
|
|
1116
|
+
/* graph spotlight (G1) ---------------------------------------------------
|
|
1117
|
+
The field floating top-left over the canvas, and the side sheet top-right.
|
|
1118
|
+
Both are overlays on the stage, so they sit on the panel ground with a
|
|
1119
|
+
hairline and the pop radius — no elevation shadow, per the sheet's rule.
|
|
1120
|
+
The spotlight's voice is --weave-warn: the highlighter colour the WebGL
|
|
1121
|
+
side paints lit edges in (graph.model.ts SPOTLIGHT_EDGE_SLOT), so the chip,
|
|
1122
|
+
the legend, the marked words and the lit dots all say "lit" in one hue.
|
|
1123
|
+
The sheet stops short of the control strip and count line under the
|
|
1124
|
+
canvas (about 54px together) and scrolls inside itself. Button rules are
|
|
1125
|
+
qualified by their overlay (.weave-sheet .weave-sheet-open) because the
|
|
1126
|
+
workspace sheet's \`.weave-workbench button{font:inherit;color:inherit}\`
|
|
1127
|
+
reset is installed later and would outrank a single class. */
|
|
1128
|
+
.weave-spotlight{
|
|
1129
|
+
position:absolute;z-index:3;top:10px;left:10px;width:min(330px,calc(100% - 20px));box-sizing:border-box;
|
|
1130
|
+
display:flex;align-items:center;gap:6px;padding:3px 5px 3px 9px;
|
|
1131
|
+
color:var(--weave-faint);background:var(--weave-panel);
|
|
1132
|
+
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);
|
|
1133
|
+
}
|
|
1134
|
+
/* The pill is the focus ring: the input inside it drops the global outline
|
|
1135
|
+
and the frame takes a 2px accent edge (border plus an inset hairline). */
|
|
1136
|
+
.weave-spotlight:focus-within{border-color:var(--weave-accent);box-shadow:inset 0 0 0 1px var(--weave-accent)}
|
|
1137
|
+
.weave-spotlight-input:focus-visible{outline:none}
|
|
1138
|
+
.weave-spotlight-on{color:var(--weave-warn)}
|
|
1139
|
+
.weave-spotlight-icon{flex:none;display:block}
|
|
1140
|
+
.weave-spotlight-input{
|
|
1141
|
+
flex:1;min-width:0;height:24px;padding:0;font:inherit;font-size:var(--weave-px-row);
|
|
1142
|
+
color:var(--weave-fg);background:transparent;border:0;outline:0;
|
|
1143
|
+
}
|
|
1144
|
+
.weave-spotlight-input::placeholder{color:var(--weave-faint)}
|
|
1145
|
+
.weave-spotlight-input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none}
|
|
1146
|
+
.weave-spotlight-count{
|
|
1147
|
+
flex:none;padding:1px 7px;font-size:var(--weave-px-caption);font-weight:650;white-space:nowrap;
|
|
1148
|
+
color:var(--weave-warn);background:color-mix(in srgb,var(--weave-warn) 16%,transparent);border-radius:999px;
|
|
1149
|
+
}
|
|
1150
|
+
.weave-spotlight-none{color:var(--weave-dim);background:var(--weave-line)}
|
|
1151
|
+
.weave-spotlight-by{flex:none;font-size:var(--weave-px-caption);color:var(--weave-dim);white-space:nowrap}
|
|
1152
|
+
.weave-spotlight .weave-spotlight-clear{
|
|
1153
|
+
flex:none;padding:1px 5px;cursor:pointer;font-family:var(--weave-mono);font-size:var(--weave-px-prov);
|
|
1154
|
+
color:var(--weave-faint);background:transparent;border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
|
|
1155
|
+
}
|
|
1156
|
+
.weave-spotlight .weave-spotlight-clear:hover{color:var(--weave-fg);border-color:var(--weave-accent)}
|
|
1157
|
+
.weave-legend-lit{color:var(--weave-warn)}
|
|
1158
|
+
.weave-sheet{
|
|
1159
|
+
position:absolute;z-index:3;top:10px;right:10px;width:min(300px,calc(100% - 20px));max-height:calc(100% - 74px);
|
|
1160
|
+
box-sizing:border-box;overflow:auto;padding:12px 14px 14px;
|
|
1161
|
+
font-size:var(--weave-px-base);color:var(--weave-fg);background:var(--weave-panel);
|
|
1162
|
+
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);
|
|
1163
|
+
}
|
|
1164
|
+
.weave-sheet .weave-sheet-close{
|
|
1165
|
+
position:absolute;top:6px;right:6px;width:24px;height:24px;padding:0;cursor:pointer;
|
|
1166
|
+
font-size:var(--weave-px-display);line-height:1;color:var(--weave-dim);
|
|
1167
|
+
background:transparent;border:0;border-radius:var(--weave-radius);
|
|
1168
|
+
}
|
|
1169
|
+
.weave-sheet .weave-sheet-close:hover{color:var(--weave-fg);background:var(--weave-line)}
|
|
1170
|
+
.weave-sheet-crumb{
|
|
1171
|
+
margin:0 28px 2px 0;display:flex;align-items:center;gap:5px;min-width:0;
|
|
1172
|
+
font-size:var(--weave-px-caption);color:var(--weave-faint);
|
|
1173
|
+
}
|
|
1174
|
+
.weave-sheet-crumb span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1175
|
+
.weave-sheet-title{
|
|
1176
|
+
margin:0 20px 4px 0;font-size:var(--weave-px-title);font-weight:650;line-height:1.3;overflow-wrap:anywhere;
|
|
1177
|
+
}
|
|
1178
|
+
.weave-sheet-meta{margin:0;display:flex;align-items:center;gap:5px;font-size:var(--weave-px-ui);color:var(--weave-dim);text-transform:capitalize}
|
|
1179
|
+
.weave-sheet-when{color:var(--weave-faint);text-transform:none}
|
|
1180
|
+
.weave-sheet-text{
|
|
1181
|
+
margin:10px 0 0;padding:8px 10px;line-height:1.55;overflow-wrap:anywhere;
|
|
1182
|
+
background:var(--weave-new);border:1px solid color-mix(in srgb,var(--weave-accent) 30%,transparent);
|
|
1183
|
+
border-radius:var(--weave-radius-pop);
|
|
1184
|
+
}
|
|
1185
|
+
.weave-sheet-text-head{
|
|
1186
|
+
display:block;margin:0 0 2px;font-size:var(--weave-px-prov);font-weight:700;letter-spacing:.09em;
|
|
1187
|
+
text-transform:uppercase;color:var(--weave-accent);
|
|
1188
|
+
}
|
|
1189
|
+
.weave-sheet-mark{border-radius:var(--weave-radius)}
|
|
1190
|
+
.weave-sheet-why{margin:8px 0 0;display:flex;gap:5px;font-size:var(--weave-px-caption);color:var(--weave-dim)}
|
|
1191
|
+
.weave-sheet-why span{color:var(--weave-warn)}
|
|
1192
|
+
.weave-sheet-section{margin:12px 0 0}
|
|
1193
|
+
.weave-sheet-heading{
|
|
1194
|
+
margin:0 0 3px;display:flex;align-items:center;font-size:var(--weave-px-caption);font-weight:600;
|
|
1195
|
+
letter-spacing:.09em;text-transform:uppercase;color:var(--weave-faint);
|
|
1196
|
+
}
|
|
1197
|
+
.weave-sheet-count{margin-left:auto;font-family:var(--weave-mono);letter-spacing:0}
|
|
1198
|
+
.weave-sheet-rows{margin:0;padding:0;list-style:none}
|
|
1199
|
+
.weave-sheet .weave-sheet-row{
|
|
1200
|
+
display:flex;align-items:center;gap:7px;width:100%;padding:3px 0;cursor:pointer;text-align:left;
|
|
1201
|
+
font:inherit;font-size:var(--weave-px-row);color:var(--weave-fg);background:none;border:0;
|
|
1202
|
+
}
|
|
1203
|
+
.weave-sheet .weave-sheet-row:hover{color:var(--weave-accent)}
|
|
1204
|
+
.weave-sheet-row-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1205
|
+
.weave-sheet-dot{flex:none;width:6px;height:6px;border-radius:999px;background:var(--weave-faint)}
|
|
1206
|
+
.weave-sheet-dot-lit{background:var(--weave-warn)}
|
|
1207
|
+
.weave-sheet-more{margin:2px 0 0;font-size:var(--weave-px-caption);color:var(--weave-faint)}
|
|
1208
|
+
.weave-sheet-actions{margin:14px 0 0;display:flex;gap:6px;flex-wrap:wrap}
|
|
1209
|
+
.weave-sheet .weave-sheet-open,.weave-sheet .weave-sheet-split{
|
|
1210
|
+
padding:5px 11px;cursor:pointer;font:inherit;font-size:var(--weave-px-ui);font-weight:600;
|
|
1211
|
+
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
|
|
1212
|
+
}
|
|
1213
|
+
.weave-sheet .weave-sheet-open{color:var(--weave-page);background:var(--weave-accent);border-color:var(--weave-accent)}
|
|
1214
|
+
.weave-sheet .weave-sheet-open:hover{filter:brightness(1.08)}
|
|
1215
|
+
.weave-sheet .weave-sheet-split{color:var(--weave-fg);background:var(--weave-page)}
|
|
1216
|
+
.weave-sheet .weave-sheet-split:hover{border-color:var(--weave-accent)}
|
|
1217
|
+
/* Side by side the field (330) and the sheet (300) need about 660px of
|
|
1218
|
+
stage; a narrower graph — a split pane, a small window — drops the sheet
|
|
1219
|
+
under the field instead of letting the two overlap. */
|
|
1220
|
+
.weave-graph{container-type:inline-size}
|
|
1221
|
+
@container (max-width:680px){.weave-sheet{top:50px;max-height:calc(100% - 114px)}}
|
|
1222
|
+
/* end graph spotlight ---------------------------------------------------- */
|
|
1223
|
+
|
|
1037
1224
|
/* context rail ---------------------------------------------------------- */
|
|
1038
1225
|
/* The \`.weave-empty\` block that used to sit above went with \`EmptyState.tsx\`
|
|
1039
1226
|
in P3: every column now has its own empty state (\`treeEmptyMessage\`,
|
|
@@ -1053,9 +1240,8 @@ body{font-size:var(--weave-px-base)}
|
|
|
1053
1240
|
.weave-trail{padding-top:6px;padding-bottom:6px;border-bottom:1px solid var(--weave-line)}
|
|
1054
1241
|
.weave-trail-head{display:flex;align-items:center;gap:6px;font-size:var(--weave-px-caption);font-weight:600;letter-spacing:.09em;color:var(--weave-faint);text-transform:uppercase}
|
|
1055
1242
|
.weave-trail-head .weave-ctx-count{margin-left:0}
|
|
1056
|
-
.weave-trail-
|
|
1057
|
-
.weave-trail-
|
|
1058
|
-
.weave-trail-replay:hover,.weave-trail-turn:hover{color:var(--weave-fg)}
|
|
1243
|
+
.weave-trail-turn{font:inherit;font-size:var(--weave-px-caption);letter-spacing:0;text-transform:none;color:var(--weave-dim);background:none;border:1px solid var(--weave-line);border-radius:var(--weave-radius);padding:0 6px;cursor:pointer}
|
|
1244
|
+
.weave-trail-turn:hover{color:var(--weave-fg)}
|
|
1059
1245
|
.weave-trail-turn-on{color:var(--weave-accent);border-color:var(--weave-accent)}
|
|
1060
1246
|
.weave-trail-steps{margin:4px 0 0;padding:0;list-style:none;display:flex;flex-direction:column;gap:2px}
|
|
1061
1247
|
.weave-trail-step{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px;padding-left:10px;position:relative;line-height:1.45}
|
|
@@ -1114,6 +1300,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
1114
1300
|
.weave-status-cwd,.weave-status-sel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1115
1301
|
.weave-status-cwd{max-width:38%;color:var(--weave-faint)}
|
|
1116
1302
|
.weave-status-sel{color:var(--weave-fg)}
|
|
1303
|
+
.weave-status-hint{margin-left:auto;padding-left:8px;white-space:nowrap;color:var(--weave-faint)}
|
|
1117
1304
|
|
|
1118
1305
|
/* overlays: the ⌘K palette and the ? help sheet (P4) --------------------- */
|
|
1119
1306
|
/* The scrim is a click target that closes, and the reason both overlays sit
|
|
@@ -1129,31 +1316,77 @@ body{font-size:var(--weave-px-base)}
|
|
|
1129
1316
|
overflow:hidden;background:var(--weave-panel);color:var(--weave-fg);
|
|
1130
1317
|
border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);
|
|
1131
1318
|
}
|
|
1319
|
+
/* The ⌘K palette, grouped and compact: an input row (glyph, query, Esc), a
|
|
1320
|
+
scope row of pills that Tab cycles, one line per result under small
|
|
1321
|
+
capitals group heads, and a footer of key hints. Wider than the help sheet
|
|
1322
|
+
because a row carries a title, a snippet and a meta column side by side. */
|
|
1323
|
+
.weave-palette{max-width:640px}
|
|
1324
|
+
.weave-palette-bar{
|
|
1325
|
+
flex:none;display:flex;align-items:center;gap:8px;padding:0 11px;
|
|
1326
|
+
border-bottom:1px solid var(--weave-line);
|
|
1327
|
+
}
|
|
1328
|
+
.weave-palette-glyph{color:var(--weave-faint)}
|
|
1132
1329
|
.weave-palette-input{
|
|
1133
|
-
flex:
|
|
1134
|
-
color:var(--weave-fg);background:transparent;border:0;
|
|
1135
|
-
|
|
1330
|
+
flex:1;min-width:0;height:36px;padding:0;font:inherit;font-size:var(--weave-px-subhead);
|
|
1331
|
+
color:var(--weave-fg);background:transparent;border:0;border-radius:0;
|
|
1332
|
+
}
|
|
1333
|
+
.weave-palette-input:focus-visible{outline:0}
|
|
1334
|
+
.weave-palette-input::-webkit-search-cancel-button{display:none}
|
|
1335
|
+
.weave-palette-bar:focus-within{box-shadow:inset 0 -1px 0 var(--weave-accent)}
|
|
1336
|
+
.weave-palette-kbd{
|
|
1337
|
+
flex:none;padding:0 4px;font-family:inherit;font-size:var(--weave-px-prov);line-height:14px;
|
|
1338
|
+
color:var(--weave-faint);border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
|
|
1339
|
+
}
|
|
1340
|
+
.weave-palette-scopes{
|
|
1341
|
+
flex:none;display:flex;flex-wrap:wrap;gap:3px;padding:5px 8px;
|
|
1342
|
+
border-bottom:1px solid var(--weave-line);
|
|
1136
1343
|
}
|
|
1137
|
-
.weave-palette-
|
|
1138
|
-
|
|
1344
|
+
.weave-palette-scope{
|
|
1345
|
+
font:inherit;font-size:var(--weave-px-caption);line-height:1;padding:3px 9px;cursor:pointer;
|
|
1346
|
+
color:var(--weave-dim);background:none;border:0;border-radius:999px;
|
|
1347
|
+
}
|
|
1348
|
+
.weave-palette-scope:hover{color:var(--weave-fg);background:var(--weave-line)}
|
|
1349
|
+
.weave-palette-scope[aria-pressed="true"]{color:var(--weave-panel);background:var(--weave-fg);font-weight:600}
|
|
1350
|
+
.weave-palette-scope-count{font-variant-numeric:tabular-nums}
|
|
1351
|
+
.weave-hits{flex:1;min-height:0;overflow:auto;margin:0;padding:0 0 4px;list-style:none}
|
|
1352
|
+
.weave-hit-section{list-style:none}
|
|
1353
|
+
.weave-hit-group{
|
|
1354
|
+
padding:7px 11px 2px;font-size:var(--weave-px-prov);font-weight:700;letter-spacing:.08em;
|
|
1355
|
+
text-transform:uppercase;color:var(--weave-faint);
|
|
1356
|
+
}
|
|
1357
|
+
.weave-hit-rows{margin:0;padding:0;list-style:none}
|
|
1139
1358
|
.weave-hit{
|
|
1140
|
-
display:flex;align-items:
|
|
1141
|
-
min-width:0;white-space:nowrap;
|
|
1359
|
+
display:flex;align-items:center;gap:8px;padding:3px 11px;cursor:pointer;
|
|
1360
|
+
min-width:0;white-space:nowrap;font-size:var(--weave-px-row);
|
|
1142
1361
|
}
|
|
1143
1362
|
.weave-hit-on{background:var(--weave-new);box-shadow:inset 2px 0 0 var(--weave-accent)}
|
|
1144
|
-
.weave-hit-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
}
|
|
1148
|
-
.weave-hit-note .weave-hit-badge{color:var(--weave-accent)}
|
|
1149
|
-
.weave-hit-label{flex:none;max-width:46%;overflow:hidden;text-overflow:ellipsis}
|
|
1363
|
+
.weave-hit-icon{color:var(--weave-faint)}
|
|
1364
|
+
.weave-hit-notes .weave-hit-icon{color:var(--weave-accent)}
|
|
1365
|
+
.weave-hit-label{flex:none;max-width:46%;overflow:hidden;text-overflow:ellipsis;font-weight:600;color:var(--weave-fg)}
|
|
1366
|
+
.weave-hit-mono{font-family:var(--weave-mono);font-size:var(--weave-px-ui);font-weight:500}
|
|
1150
1367
|
.weave-hit-detail{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:var(--weave-px-ui);color:var(--weave-dim)}
|
|
1368
|
+
/* The match marks (search rows, the graph sheet) are a find-in-page amber.
|
|
1369
|
+
Dark themes tint their own light --weave-warn, and the marked words go
|
|
1370
|
+
white: the theme's text on that tint measured 3.3–3.6:1 in the Catppuccin
|
|
1371
|
+
darks, white is 5.5:1 or better in every dark theme. A light theme's
|
|
1372
|
+
--weave-warn is a deep brown that tints to mud, so light schemes take a
|
|
1373
|
+
fixed amber under their own text instead. */
|
|
1374
|
+
.weave-hit-mark,.weave-sheet-mark{color:#fff;background:color-mix(in srgb,var(--weave-warn) 28%,transparent)}
|
|
1375
|
+
.weave-hit-mark{border-radius:var(--weave-radius);padding:0 1px}
|
|
1376
|
+
:root[data-weave-scheme="light"] .weave-hit-mark,:root[data-weave-scheme="light"] .weave-sheet-mark{color:var(--weave-fg);background:color-mix(in srgb,#f2a93b 34%,transparent)}
|
|
1377
|
+
.weave-hit-meta{flex:none;margin-left:auto;font-size:var(--weave-px-caption);color:var(--weave-faint);font-variant-numeric:tabular-nums}
|
|
1151
1378
|
.weave-palette-status{margin:0;padding:14px 11px;color:var(--weave-dim);line-height:1.5}
|
|
1152
1379
|
.weave-palette-foot,.weave-help-foot{
|
|
1153
1380
|
display:flex;gap:12px;margin:0;padding:4px 11px;font-size:var(--weave-px-caption);color:var(--weave-faint);
|
|
1154
1381
|
border-top:1px solid var(--weave-line);
|
|
1155
1382
|
}
|
|
1156
|
-
.weave-palette-
|
|
1383
|
+
.weave-palette-foot{align-items:center;flex-wrap:wrap;row-gap:2px;min-height:26px;box-sizing:border-box;background:var(--weave-bg)}
|
|
1384
|
+
.weave-palette-light{
|
|
1385
|
+
margin-left:auto;display:flex;align-items:center;gap:6px;padding:0;cursor:pointer;white-space:nowrap;
|
|
1386
|
+
font:inherit;font-weight:600;color:var(--weave-accent);background:none;border:0;
|
|
1387
|
+
}
|
|
1388
|
+
.weave-palette-light .weave-palette-kbd{color:inherit;border-color:currentColor}
|
|
1389
|
+
.weave-help-hint{margin-left:auto}
|
|
1157
1390
|
.weave-help-title{margin:0;padding:9px 11px;font-size:var(--weave-px-base);font-weight:600;border-bottom:1px solid var(--weave-line)}
|
|
1158
1391
|
.weave-keys{flex:1;min-height:0;overflow:auto;margin:0;padding:5px 11px}
|
|
1159
1392
|
.weave-key-group{margin:0 0 3px;font-size:var(--weave-px-prov);letter-spacing:.09em;text-transform:uppercase;color:var(--weave-faint)}
|
|
@@ -1198,7 +1431,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
1198
1431
|
@keyframes weave-fade-in{from{opacity:0}}
|
|
1199
1432
|
@keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
|
|
1200
1433
|
@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
|
|
1201
|
-
`,
|
|
1434
|
+
`,OT=["style[nonce]","style","script[nonce]","script[src]"];function FT(e){for(let t of OT){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function $m(e,t=GT+Fm){let n=e.createElement("style"),r=FT(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var zm=document.getElementById("app");if(zm!==null){$m(document),$T();let e=gc(document.getElementById(fc)?.textContent??null);pc(p(Om,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),zm)}function $T(){let e=Mm(ro(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
|
|
1202
1435
|
/*! Bundled license information:
|
|
1203
1436
|
|
|
1204
1437
|
dompurify/dist/purify.es.mjs:
|