import cytoscape from"https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.17.1/cytoscape.esm.min.js";var init$2=function(){const e=document.querySelectorAll("ol.slipbox-list > li[value]");for(let t=0;t<e.length;t++){const r=e[t],n=r.value,i=document.querySelector(`section.slipbox-note[id="${n}"]`);if(!i){r.remove();continue}const s=i.querySelector("h1");if(!s){r.remove();continue}const o=document.createElement("a");o.href=`#${n}`,o.innerHTML=s.innerHTML,r.appendChild(o)}},list={init:init$2},commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e){var t={exports:{}};return e(t,t.exports),t.exports
/**
 * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9
 * Copyright (C) 2020 Oliver Nightingale
 * @license MIT
 */}var lunr=createCommonjsModule((function(e,t){!function(){var t,r,n,i,s,o,a,u,c,l,d,h,p,f,m,y,g,v,x,w,b,k,S,E,L,Q=function(e){var t=new Q.Builder;return t.pipeline.add(Q.trimmer,Q.stopWordFilter,Q.stemmer),t.searchPipeline.add(Q.stemmer),e.call(t,t),t.build()};Q.version="2.3.9",
/*!
 * lunr.utils
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.utils={},Q.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),Q.utils.asString=function(e){return null==e?"":e.toString()},Q.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),n=0;n<r.length;n++){var i=r[n],s=e[i];if(Array.isArray(s))t[i]=s.slice();else{if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s)throw new TypeError("clone is not deep and does not support nested objects");t[i]=s}}return t},Q.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},Q.FieldRef.joiner="/",Q.FieldRef.fromString=function(e){var t=e.indexOf(Q.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),n=e.slice(t+1);return new Q.FieldRef(n,r,e)},Q.FieldRef.prototype.toString=function(){return null==this._stringValue&&(this._stringValue=this.fieldName+Q.FieldRef.joiner+this.docRef),this._stringValue},
/*!
 * lunr.Set
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},Q.Set.complete={intersect:function(e){return e},union:function(){return this},contains:function(){return!0}},Q.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},Q.Set.prototype.contains=function(e){return!!this.elements[e]},Q.Set.prototype.intersect=function(e){var t,r,n,i=[];if(e===Q.Set.complete)return this;if(e===Q.Set.empty)return e;this.length<e.length?(t=this,r=e):(t=e,r=this),n=Object.keys(t.elements);for(var s=0;s<n.length;s++){var o=n[s];o in r.elements&&i.push(o)}return new Q.Set(i)},Q.Set.prototype.union=function(e){return e===Q.Set.complete?Q.Set.complete:e===Q.Set.empty?this:new Q.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},Q.idf=function(e,t){var r=0;for(var n in e)"_index"!=n&&(r+=Object.keys(e[n]).length);var i=(t-r+.5)/(r+.5);return Math.log(1+Math.abs(i))},Q.Token=function(e,t){this.str=e||"",this.metadata=t||{}},Q.Token.prototype.toString=function(){return this.str},Q.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},Q.Token.prototype.clone=function(e){return e=e||function(e){return e},new Q.Token(e(this.str,this.metadata),this.metadata)},
/*!
 * lunr.tokenizer
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.tokenizer=function(e,t){if(null==e||null==e)return[];if(Array.isArray(e))return e.map((function(e){return new Q.Token(Q.utils.asString(e).toLowerCase(),Q.utils.clone(t))}));for(var r=e.toString().toLowerCase(),n=r.length,i=[],s=0,o=0;s<=n;s++){var a=s-o;if(r.charAt(s).match(Q.tokenizer.separator)||s==n){if(a>0){var u=Q.utils.clone(t)||{};u.position=[o,a],u.index=i.length,i.push(new Q.Token(r.slice(o,s),u))}o=s+1}}return i},Q.tokenizer.separator=/[\s\-]+/,
/*!
 * lunr.Pipeline
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.Pipeline=function(){this._stack=[]},Q.Pipeline.registeredFunctions=Object.create(null),Q.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&Q.utils.warn("Overwriting existing registered function: "+t),e.label=t,Q.Pipeline.registeredFunctions[e.label]=e},Q.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||Q.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},Q.Pipeline.load=function(e){var t=new Q.Pipeline;return e.forEach((function(e){var r=Q.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load unregistered function: "+e);t.add(r)})),t},Q.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach((function(e){Q.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},Q.Pipeline.prototype.after=function(e,t){Q.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},Q.Pipeline.prototype.before=function(e,t){Q.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,t)},Q.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},Q.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r<t;r++){for(var n=this._stack[r],i=[],s=0;s<e.length;s++){var o=n(e[s],s,e);if(null!=o&&""!==o)if(Array.isArray(o))for(var a=0;a<o.length;a++)i.push(o[a]);else i.push(o)}e=i}return e},Q.Pipeline.prototype.runString=function(e,t){var r=new Q.Token(e,t);return this.run([r]).map((function(e){return e.toString()}))},Q.Pipeline.prototype.reset=function(){this._stack=[]},Q.Pipeline.prototype.toJSON=function(){return this._stack.map((function(e){return Q.Pipeline.warnIfFunctionNotRegistered(e),e.label}))},
/*!
 * lunr.Vector
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.Vector=function(e){this._magnitude=0,this.elements=e||[]},Q.Vector.prototype.positionForIndex=function(e){if(0==this.elements.length)return 0;for(var t=0,r=this.elements.length/2,n=r-t,i=Math.floor(n/2),s=this.elements[2*i];n>1&&(s<e&&(t=i),s>e&&(r=i),s!=e);)n=r-t,i=t+Math.floor(n/2),s=this.elements[2*i];return s==e||s>e?2*i:s<e?2*(i+1):void 0},Q.Vector.prototype.insert=function(e,t){this.upsert(e,t,(function(){throw"duplicate index"}))},Q.Vector.prototype.upsert=function(e,t,r){this._magnitude=0;var n=this.positionForIndex(e);this.elements[n]==e?this.elements[n+1]=r(this.elements[n+1],t):this.elements.splice(n,0,e,t)},Q.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e=0,t=this.elements.length,r=1;r<t;r+=2){var n=this.elements[r];e+=n*n}return this._magnitude=Math.sqrt(e)},Q.Vector.prototype.dot=function(e){for(var t=0,r=this.elements,n=e.elements,i=r.length,s=n.length,o=0,a=0,u=0,c=0;u<i&&c<s;)(o=r[u])<(a=n[c])?u+=2:o>a?c+=2:o==a&&(t+=r[u+1]*n[c+1],u+=2,c+=2);return t},Q.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},Q.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t<this.elements.length;t+=2,r++)e[r]=this.elements[t];return e},Q.Vector.prototype.toJSON=function(){return this.elements},
/*!
 * lunr.stemmer
 * Copyright (C) 2020 Oliver Nightingale
 * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt
 */
Q.stemmer=(t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},r={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[aeiouy]",i="[^aeiou][^aeiouy]*",s=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*"),o=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*"),a=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$"),u=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy]"),c=/^(.+?)(ss|i)es$/,l=/^(.+?)([^s])s$/,d=/^(.+?)eed$/,h=/^(.+?)(ed|ing)$/,p=/.$/,f=/(at|bl|iz)$/,m=new RegExp("([^aeiouylsz])\\1$"),y=new RegExp("^"+i+n+"[^aeiouwxy]$"),g=/^(.+?[^aeiou])y$/,v=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,x=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,w=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,b=/^(.+?)(s|t)(ion)$/,k=/^(.+?)e$/,S=/ll$/,E=new RegExp("^"+i+n+"[^aeiouwxy]$"),L=function(e){var n,i,L,Q,P,T,O;if(e.length<3)return e;if("y"==(L=e.substr(0,1))&&(e=L.toUpperCase()+e.substr(1)),P=l,(Q=c).test(e)?e=e.replace(Q,"$1$2"):P.test(e)&&(e=e.replace(P,"$1$2")),P=h,(Q=d).test(e)){var $=Q.exec(e);(Q=s).test($[1])&&(Q=p,e=e.replace(Q,""))}else P.test(e)&&(n=($=P.exec(e))[1],(P=u).test(n)&&(T=m,O=y,(P=f).test(e=n)?e+="e":T.test(e)?(Q=p,e=e.replace(Q,"")):O.test(e)&&(e+="e")));return(Q=g).test(e)&&(e=(n=($=Q.exec(e))[1])+"i"),(Q=v).test(e)&&(n=($=Q.exec(e))[1],i=$[2],(Q=s).test(n)&&(e=n+t[i])),(Q=x).test(e)&&(n=($=Q.exec(e))[1],i=$[2],(Q=s).test(n)&&(e=n+r[i])),P=b,(Q=w).test(e)?(n=($=Q.exec(e))[1],(Q=o).test(n)&&(e=n)):P.test(e)&&(n=($=P.exec(e))[1]+$[2],(P=o).test(n)&&(e=n)),(Q=k).test(e)&&(n=($=Q.exec(e))[1],P=a,T=E,((Q=o).test(n)||P.test(n)&&!T.test(n))&&(e=n)),P=o,(Q=S).test(e)&&P.test(e)&&(Q=p,e=e.replace(Q,"")),"y"==L&&(e=L.toLowerCase()+e.substr(1)),e},function(e){return e.update(L)}),Q.Pipeline.registerFunction(Q.stemmer,"stemmer"),
/*!
 * lunr.stopWordFilter
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.generateStopWordFilter=function(e){var t=e.reduce((function(e,t){return e[t]=t,e}),{});return function(e){if(e&&t[e.toString()]!==e.toString())return e}},Q.stopWordFilter=Q.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),Q.Pipeline.registerFunction(Q.stopWordFilter,"stopWordFilter"),
/*!
 * lunr.trimmer
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.trimmer=function(e){return e.update((function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")}))},Q.Pipeline.registerFunction(Q.trimmer,"trimmer"),
/*!
 * lunr.TokenSet
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.TokenSet=function(){this.final=!1,this.edges={},this.id=Q.TokenSet._nextId,Q.TokenSet._nextId+=1},Q.TokenSet._nextId=1,Q.TokenSet.fromArray=function(e){for(var t=new Q.TokenSet.Builder,r=0,n=e.length;r<n;r++)t.insert(e[r]);return t.finish(),t.root},Q.TokenSet.fromClause=function(e){return"editDistance"in e?Q.TokenSet.fromFuzzyString(e.term,e.editDistance):Q.TokenSet.fromString(e.term)},Q.TokenSet.fromFuzzyString=function(e,t){for(var r=new Q.TokenSet,n=[{node:r,editsRemaining:t,str:e}];n.length;){var i=n.pop();if(i.str.length>0){var s,o=i.str.charAt(0);o in i.node.edges?s=i.node.edges[o]:(s=new Q.TokenSet,i.node.edges[o]=s),1==i.str.length&&(s.final=!0),n.push({node:s,editsRemaining:i.editsRemaining,str:i.str.slice(1)})}if(0!=i.editsRemaining){if("*"in i.node.edges)var a=i.node.edges["*"];else{a=new Q.TokenSet;i.node.edges["*"]=a}if(0==i.str.length&&(a.final=!0),n.push({node:a,editsRemaining:i.editsRemaining-1,str:i.str}),i.str.length>1&&n.push({node:i.node,editsRemaining:i.editsRemaining-1,str:i.str.slice(1)}),1==i.str.length&&(i.node.final=!0),i.str.length>=1){if("*"in i.node.edges)var u=i.node.edges["*"];else{u=new Q.TokenSet;i.node.edges["*"]=u}1==i.str.length&&(u.final=!0),n.push({node:u,editsRemaining:i.editsRemaining-1,str:i.str.slice(1)})}if(i.str.length>1){var c,l=i.str.charAt(0),d=i.str.charAt(1);d in i.node.edges?c=i.node.edges[d]:(c=new Q.TokenSet,i.node.edges[d]=c),1==i.str.length&&(c.final=!0),n.push({node:c,editsRemaining:i.editsRemaining-1,str:l+i.str.slice(2)})}}}return r},Q.TokenSet.fromString=function(e){for(var t=new Q.TokenSet,r=t,n=0,i=e.length;n<i;n++){var s=e[n],o=n==i-1;if("*"==s)t.edges[s]=t,t.final=o;else{var a=new Q.TokenSet;a.final=o,t.edges[s]=a,t=a}}return r},Q.TokenSet.prototype.toArray=function(){for(var e=[],t=[{prefix:"",node:this}];t.length;){var r=t.pop(),n=Object.keys(r.node.edges),i=n.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(var s=0;s<i;s++){var o=n[s];t.push({prefix:r.prefix.concat(o),node:r.node.edges[o]})}}return e},Q.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var e=this.final?"1":"0",t=Object.keys(this.edges).sort(),r=t.length,n=0;n<r;n++){var i=t[n];e=e+i+this.edges[i].id}return e},Q.TokenSet.prototype.intersect=function(e){for(var t=new Q.TokenSet,r=void 0,n=[{qNode:e,output:t,node:this}];n.length;){r=n.pop();for(var i=Object.keys(r.qNode.edges),s=i.length,o=Object.keys(r.node.edges),a=o.length,u=0;u<s;u++)for(var c=i[u],l=0;l<a;l++){var d=o[l];if(d==c||"*"==c){var h=r.node.edges[d],p=r.qNode.edges[c],f=h.final&&p.final,m=void 0;d in r.output.edges?(m=r.output.edges[d]).final=m.final||f:((m=new Q.TokenSet).final=f,r.output.edges[d]=m),n.push({qNode:p,output:m,node:h})}}}return t},Q.TokenSet.Builder=function(){this.previousWord="",this.root=new Q.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},Q.TokenSet.Builder.prototype.insert=function(e){var t,r=0;if(e<this.previousWord)throw new Error("Out of order word insertion");for(var n=0;n<e.length&&n<this.previousWord.length&&e[n]==this.previousWord[n];n++)r++;this.minimize(r),t=0==this.uncheckedNodes.length?this.root:this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(n=r;n<e.length;n++){var i=new Q.TokenSet,s=e[n];t.edges[s]=i,this.uncheckedNodes.push({parent:t,char:s,child:i}),t=i}t.final=!0,this.previousWord=e},Q.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},Q.TokenSet.Builder.prototype.minimize=function(e){for(var t=this.uncheckedNodes.length-1;t>=e;t--){var r=this.uncheckedNodes[t],n=r.child.toString();n in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[n]:(r.child._str=n,this.minimizedNodes[n]=r.child),this.uncheckedNodes.pop()}},
/*!
 * lunr.Index
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},Q.Index.prototype.search=function(e){return this.query((function(t){new Q.QueryParser(e,t).parse()}))},Q.Index.prototype.query=function(e){for(var t=new Q.Query(this.fields),r=Object.create(null),n=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a<this.fields.length;a++)n[this.fields[a]]=new Q.Vector;e.call(t,t);for(a=0;a<t.clauses.length;a++){var u=t.clauses[a],c=null,l=Q.Set.empty;c=u.usePipeline?this.pipeline.runString(u.term,{fields:u.fields}):[u.term];for(var d=0;d<c.length;d++){var h=c[d];u.term=h;var p=Q.TokenSet.fromClause(u),f=this.tokenSet.intersect(p).toArray();if(0===f.length&&u.presence===Q.Query.presence.REQUIRED){for(var m=0;m<u.fields.length;m++){s[I=u.fields[m]]=Q.Set.empty}break}for(var y=0;y<f.length;y++){var g=f[y],v=this.invertedIndex[g],x=v._index;for(m=0;m<u.fields.length;m++){var w=v[I=u.fields[m]],b=Object.keys(w),k=g+"/"+I,S=new Q.Set(b);if(u.presence==Q.Query.presence.REQUIRED&&(l=l.union(S),void 0===s[I]&&(s[I]=Q.Set.complete)),u.presence!=Q.Query.presence.PROHIBITED){if(n[I].upsert(x,u.boost,(function(e,t){return e+t})),!i[k]){for(var E=0;E<b.length;E++){var L,P=b[E],T=new Q.FieldRef(P,I),O=w[P];void 0===(L=r[T])?r[T]=new Q.MatchData(g,I,O):L.add(g,I,O)}i[k]=!0}}else void 0===o[I]&&(o[I]=Q.Set.empty),o[I]=o[I].union(S)}}}if(u.presence===Q.Query.presence.REQUIRED)for(m=0;m<u.fields.length;m++){s[I=u.fields[m]]=s[I].intersect(l)}}var $=Q.Set.complete,C=Q.Set.empty;for(a=0;a<this.fields.length;a++){var I;s[I=this.fields[a]]&&($=$.intersect(s[I])),o[I]&&(C=C.union(o[I]))}var R=Object.keys(r),j=[],N=Object.create(null);if(t.isNegated()){R=Object.keys(this.fieldVectors);for(a=0;a<R.length;a++){T=R[a];var _=Q.FieldRef.fromString(T);r[T]=new Q.MatchData}}for(a=0;a<R.length;a++){var F=(_=Q.FieldRef.fromString(R[a])).docRef;if($.contains(F)&&!C.contains(F)){var D,A=this.fieldVectors[_],V=n[_.fieldName].similarity(A);if(void 0!==(D=N[F]))D.score+=V,D.matchData.combine(r[_]);else{var M={ref:F,score:V,matchData:r[_]};N[F]=M,j.push(M)}}}return j.sort((function(e,t){return t.score-e.score}))},Q.Index.prototype.toJSON=function(){var e=Object.keys(this.invertedIndex).sort().map((function(e){return[e,this.invertedIndex[e]]}),this),t=Object.keys(this.fieldVectors).map((function(e){return[e,this.fieldVectors[e].toJSON()]}),this);return{version:Q.version,fields:this.fields,fieldVectors:t,invertedIndex:e,pipeline:this.pipeline.toJSON()}},Q.Index.load=function(e){var t={},r={},n=e.fieldVectors,i=Object.create(null),s=e.invertedIndex,o=new Q.TokenSet.Builder,a=Q.Pipeline.load(e.pipeline);e.version!=Q.version&&Q.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+Q.version+"' does not match serialized index '"+e.version+"'");for(var u=0;u<n.length;u++){var c=(d=n[u])[0],l=d[1];r[c]=new Q.Vector(l)}for(u=0;u<s.length;u++){var d,h=(d=s[u])[0],p=d[1];o.insert(h),i[h]=p}return o.finish(),t.fields=e.fields,t.fieldVectors=r,t.invertedIndex=i,t.tokenSet=o.root,t.pipeline=a,new Q.Index(t)},
/*!
 * lunr.Builder
 * Copyright (C) 2020 Oliver Nightingale
 */
Q.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=Q.tokenizer,this.pipeline=new Q.Pipeline,this.searchPipeline=new Q.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},Q.Builder.prototype.ref=function(e){this._ref=e},Q.Builder.prototype.field=function(e,t){if(/\//.test(e))throw new RangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=t||{}},Q.Builder.prototype.b=function(e){this._b=e<0?0:e>1?1:e},Q.Builder.prototype.k1=function(e){this._k1=e},Q.Builder.prototype.add=function(e,t){var r=e[this._ref],n=Object.keys(this._fields);this._documents[r]=t||{},this.documentCount+=1;for(var i=0;i<n.length;i++){var s=n[i],o=this._fields[s].extractor,a=o?o(e):e[s],u=this.tokenizer(a,{fields:[s]}),c=this.pipeline.run(u),l=new Q.FieldRef(r,s),d=Object.create(null);this.fieldTermFrequencies[l]=d,this.fieldLengths[l]=0,this.fieldLengths[l]+=c.length;for(var h=0;h<c.length;h++){var p=c[h];if(null==d[p]&&(d[p]=0),d[p]+=1,null==this.invertedIndex[p]){var f=Object.create(null);f._index=this.termIndex,this.termIndex+=1;for(var m=0;m<n.length;m++)f[n[m]]=Object.create(null);this.invertedIndex[p]=f}null==this.invertedIndex[p][s][r]&&(this.invertedIndex[p][s][r]=Object.create(null));for(var y=0;y<this.metadataWhitelist.length;y++){var g=this.metadataWhitelist[y],v=p.metadata[g];null==this.invertedIndex[p][s][r][g]&&(this.invertedIndex[p][s][r][g]=[]),this.invertedIndex[p][s][r][g].push(v)}}}},Q.Builder.prototype.calculateAverageFieldLengths=function(){for(var e=Object.keys(this.fieldLengths),t=e.length,r={},n={},i=0;i<t;i++){var s=Q.FieldRef.fromString(e[i]),o=s.fieldName;n[o]||(n[o]=0),n[o]+=1,r[o]||(r[o]=0),r[o]+=this.fieldLengths[s]}var a=Object.keys(this._fields);for(i=0;i<a.length;i++){var u=a[i];r[u]=r[u]/n[u]}this.averageFieldLength=r},Q.Builder.prototype.createFieldVectors=function(){for(var e={},t=Object.keys(this.fieldTermFrequencies),r=t.length,n=Object.create(null),i=0;i<r;i++){for(var s=Q.FieldRef.fromString(t[i]),o=s.fieldName,a=this.fieldLengths[s],u=new Q.Vector,c=this.fieldTermFrequencies[s],l=Object.keys(c),d=l.length,h=this._fields[o].boost||1,p=this._documents[s.docRef].boost||1,f=0;f<d;f++){var m,y,g,v=l[f],x=c[v],w=this.invertedIndex[v]._index;void 0===n[v]?(m=Q.idf(this.invertedIndex[v],this.documentCount),n[v]=m):m=n[v],y=m*((this._k1+1)*x)/(this._k1*(1-this._b+this._b*(a/this.averageFieldLength[o]))+x),y*=h,y*=p,g=Math.round(1e3*y)/1e3,u.insert(w,g)}e[s]=u}this.fieldVectors=e},Q.Builder.prototype.createTokenSet=function(){this.tokenSet=Q.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},Q.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new Q.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},Q.Builder.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},Q.MatchData=function(e,t,r){for(var n=Object.create(null),i=Object.keys(r||{}),s=0;s<i.length;s++){var o=i[s];n[o]=r[o].slice()}this.metadata=Object.create(null),void 0!==e&&(this.metadata[e]=Object.create(null),this.metadata[e][t]=n)},Q.MatchData.prototype.combine=function(e){for(var t=Object.keys(e.metadata),r=0;r<t.length;r++){var n=t[r],i=Object.keys(e.metadata[n]);null==this.metadata[n]&&(this.metadata[n]=Object.create(null));for(var s=0;s<i.length;s++){var o=i[s],a=Object.keys(e.metadata[n][o]);null==this.metadata[n][o]&&(this.metadata[n][o]=Object.create(null));for(var u=0;u<a.length;u++){var c=a[u];null==this.metadata[n][o][c]?this.metadata[n][o][c]=e.metadata[n][o][c]:this.metadata[n][o][c]=this.metadata[n][o][c].concat(e.metadata[n][o][c])}}}},Q.MatchData.prototype.add=function(e,t,r){if(!(e in this.metadata))return this.metadata[e]=Object.create(null),void(this.metadata[e][t]=r);if(t in this.metadata[e])for(var n=Object.keys(r),i=0;i<n.length;i++){var s=n[i];s in this.metadata[e][t]?this.metadata[e][t][s]=this.metadata[e][t][s].concat(r[s]):this.metadata[e][t][s]=r[s]}else this.metadata[e][t]=r},Q.Query=function(e){this.clauses=[],this.allFields=e},Q.Query.wildcard=new String("*"),Q.Query.wildcard.NONE=0,Q.Query.wildcard.LEADING=1,Q.Query.wildcard.TRAILING=2,Q.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},Q.Query.prototype.clause=function(e){return"fields"in e||(e.fields=this.allFields),"boost"in e||(e.boost=1),"usePipeline"in e||(e.usePipeline=!0),"wildcard"in e||(e.wildcard=Q.Query.wildcard.NONE),e.wildcard&Q.Query.wildcard.LEADING&&e.term.charAt(0)!=Q.Query.wildcard&&(e.term="*"+e.term),e.wildcard&Q.Query.wildcard.TRAILING&&e.term.slice(-1)!=Q.Query.wildcard&&(e.term=e.term+"*"),"presence"in e||(e.presence=Q.Query.presence.OPTIONAL),this.clauses.push(e),this},Q.Query.prototype.isNegated=function(){for(var e=0;e<this.clauses.length;e++)if(this.clauses[e].presence!=Q.Query.presence.PROHIBITED)return!1;return!0},Q.Query.prototype.term=function(e,t){if(Array.isArray(e))return e.forEach((function(e){this.term(e,Q.utils.clone(t))}),this),this;var r=t||{};return r.term=e.toString(),this.clause(r),this},Q.QueryParseError=function(e,t,r){this.name="QueryParseError",this.message=e,this.start=t,this.end=r},Q.QueryParseError.prototype=new Error,Q.QueryLexer=function(e){this.lexemes=[],this.str=e,this.length=e.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},Q.QueryLexer.prototype.run=function(){for(var e=Q.QueryLexer.lexText;e;)e=e(this)},Q.QueryLexer.prototype.sliceString=function(){for(var e=[],t=this.start,r=this.pos,n=0;n<this.escapeCharPositions.length;n++)r=this.escapeCharPositions[n],e.push(this.str.slice(t,r)),t=r+1;return e.push(this.str.slice(t,this.pos)),this.escapeCharPositions.length=0,e.join("")},Q.QueryLexer.prototype.emit=function(e){this.lexemes.push({type:e,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},Q.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},Q.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return Q.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},Q.QueryLexer.prototype.width=function(){return this.pos-this.start},Q.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},Q.QueryLexer.prototype.backup=function(){this.pos-=1},Q.QueryLexer.prototype.acceptDigitRun=function(){var e,t;do{t=(e=this.next()).charCodeAt(0)}while(t>47&&t<58);e!=Q.QueryLexer.EOS&&this.backup()},Q.QueryLexer.prototype.more=function(){return this.pos<this.length},Q.QueryLexer.EOS="EOS",Q.QueryLexer.FIELD="FIELD",Q.QueryLexer.TERM="TERM",Q.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",Q.QueryLexer.BOOST="BOOST",Q.QueryLexer.PRESENCE="PRESENCE",Q.QueryLexer.lexField=function(e){return e.backup(),e.emit(Q.QueryLexer.FIELD),e.ignore(),Q.QueryLexer.lexText},Q.QueryLexer.lexTerm=function(e){if(e.width()>1&&(e.backup(),e.emit(Q.QueryLexer.TERM)),e.ignore(),e.more())return Q.QueryLexer.lexText},Q.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(Q.QueryLexer.EDIT_DISTANCE),Q.QueryLexer.lexText},Q.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(Q.QueryLexer.BOOST),Q.QueryLexer.lexText},Q.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(Q.QueryLexer.TERM)},Q.QueryLexer.termSeparator=Q.tokenizer.separator,Q.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==Q.QueryLexer.EOS)return Q.QueryLexer.lexEOS;if(92!=t.charCodeAt(0)){if(":"==t)return Q.QueryLexer.lexField;if("~"==t)return e.backup(),e.width()>0&&e.emit(Q.QueryLexer.TERM),Q.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),e.width()>0&&e.emit(Q.QueryLexer.TERM),Q.QueryLexer.lexBoost;if("+"==t&&1===e.width())return e.emit(Q.QueryLexer.PRESENCE),Q.QueryLexer.lexText;if("-"==t&&1===e.width())return e.emit(Q.QueryLexer.PRESENCE),Q.QueryLexer.lexText;if(t.match(Q.QueryLexer.termSeparator))return Q.QueryLexer.lexTerm}else e.escapeCharacter()}},Q.QueryParser=function(e,t){this.lexer=new Q.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},Q.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=Q.QueryParser.parseClause;e;)e=e(this);return this.query},Q.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},Q.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},Q.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},Q.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(null!=t)switch(t.type){case Q.QueryLexer.PRESENCE:return Q.QueryParser.parsePresence;case Q.QueryLexer.FIELD:return Q.QueryParser.parseField;case Q.QueryLexer.TERM:return Q.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+t.type;throw t.str.length>=1&&(r+=" with value '"+t.str+"'"),new Q.QueryParseError(r,t.start,t.end)}},Q.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(null!=t){switch(t.str){case"-":e.currentClause.presence=Q.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=Q.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+t.str+"'";throw new Q.QueryParseError(r,t.start,t.end)}var n=e.peekLexeme();if(null==n){r="expecting term or field, found nothing";throw new Q.QueryParseError(r,t.start,t.end)}switch(n.type){case Q.QueryLexer.FIELD:return Q.QueryParser.parseField;case Q.QueryLexer.TERM:return Q.QueryParser.parseTerm;default:r="expecting term or field, found '"+n.type+"'";throw new Q.QueryParseError(r,n.start,n.end)}}},Q.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(null!=t){if(-1==e.query.allFields.indexOf(t.str)){var r=e.query.allFields.map((function(e){return"'"+e+"'"})).join(", "),n="unrecognised field '"+t.str+"', possible fields: "+r;throw new Q.QueryParseError(n,t.start,t.end)}e.currentClause.fields=[t.str];var i=e.peekLexeme();if(null==i){n="expecting term, found nothing";throw new Q.QueryParseError(n,t.start,t.end)}switch(i.type){case Q.QueryLexer.TERM:return Q.QueryParser.parseTerm;default:n="expecting term, found '"+i.type+"'";throw new Q.QueryParseError(n,i.start,i.end)}}},Q.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(null!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(null!=r)switch(r.type){case Q.QueryLexer.TERM:return e.nextClause(),Q.QueryParser.parseTerm;case Q.QueryLexer.FIELD:return e.nextClause(),Q.QueryParser.parseField;case Q.QueryLexer.EDIT_DISTANCE:return Q.QueryParser.parseEditDistance;case Q.QueryLexer.BOOST:return Q.QueryParser.parseBoost;case Q.QueryLexer.PRESENCE:return e.nextClause(),Q.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+r.type+"'";throw new Q.QueryParseError(n,r.start,r.end)}else e.nextClause()}},Q.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var n="edit distance must be numeric";throw new Q.QueryParseError(n,t.start,t.end)}e.currentClause.editDistance=r;var i=e.peekLexeme();if(null!=i)switch(i.type){case Q.QueryLexer.TERM:return e.nextClause(),Q.QueryParser.parseTerm;case Q.QueryLexer.FIELD:return e.nextClause(),Q.QueryParser.parseField;case Q.QueryLexer.EDIT_DISTANCE:return Q.QueryParser.parseEditDistance;case Q.QueryLexer.BOOST:return Q.QueryParser.parseBoost;case Q.QueryLexer.PRESENCE:return e.nextClause(),Q.QueryParser.parsePresence;default:n="Unexpected lexeme type '"+i.type+"'";throw new Q.QueryParseError(n,i.start,i.end)}else e.nextClause()}},Q.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var n="boost must be numeric";throw new Q.QueryParseError(n,t.start,t.end)}e.currentClause.boost=r;var i=e.peekLexeme();if(null!=i)switch(i.type){case Q.QueryLexer.TERM:return e.nextClause(),Q.QueryParser.parseTerm;case Q.QueryLexer.FIELD:return e.nextClause(),Q.QueryParser.parseField;case Q.QueryLexer.EDIT_DISTANCE:return Q.QueryParser.parseEditDistance;case Q.QueryLexer.BOOST:return Q.QueryParser.parseBoost;case Q.QueryLexer.PRESENCE:return e.nextClause(),Q.QueryParser.parsePresence;default:n="Unexpected lexeme type '"+i.type+"'";throw new Q.QueryParseError(n,i.start,i.end)}else e.nextClause()}},e.exports=Q}()}));function extractTitle(e){const t=e?.querySelector("h1")?.textContent,r=document.createElement("h3");return r.innerHTML=`<a href="#${e.id}">${t}</a>`,t?r:null}function extractSummary(e){const t=extractTitle(e);if(!t)return null;const r=document.createDocumentFragment();r.appendChild(t);const n=t.textContent;let i=3;for(const t of e.children){if(i--<=0)break;const e=t.cloneNode(!0);"H1"===e.tagName&&e.textContent===n||r.appendChild(e)}return r}function createResultFromSection(e){const t=extractSummary(e);if(!t)return null;const r=document.createElement("div");return r.classList.add("search-result"),r.appendChild(t),r}class Search{constructor(e,t=null){this.index=lunr((function(){this.ref("id"),this.field("textContent"),e.forEach((function(e){this.add(e)}),this)}))}render(e){e.input.addEventListener("change",(()=>{window.location.hash="#search";const t=this.index.search(e.input.value);e.results.textContent="";for(const r of t){const t=createResultFromSection(document.getElementById(r.ref));t&&e.results.appendChild(t),e.results.appendChild(document.createElement("hr"))}}))}}var init$1=function(){const e=Array.from(document.getElementsByClassName("slipbox-note"));new Search(e).render({results:document.querySelector("#search > .search-results"),input:document.querySelector("#primary .search-input")})},search={init:init$1},SlipboxCollection_1=class{constructor(){this.cy=cytoscape({headless:!0})}addNote(e){const t=document.getElementById(e),r=t.querySelector("h1").textContent,n=t.getAttribute("data-filename");this.cy.add({data:{id:e,title:r,filename:n,label:r,bgColor:"gray"}})}addLink(e,t,r){const n=`${e}-${t}${r}`;this.cy.add({data:{id:n,source:e,target:t,tag:r}})}colorEntrypoints(){this.cy.nodes((e=>0===e.indegree(!1)&&e.outdegree(!1)>0)).data("bgColor","#4444aa")}},slipbox={SlipboxCollection:SlipboxCollection_1},filters$1=createCommonjsModule((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.hasPrefix=t.matches=t.equals=t.isHome=t.check=void 0,t.check=function(e){return function(t){if(!e(t))throw t.control.next}},t.isHome=function(e){return""===e.id},t.equals=function(e){return function(t){return t.id===e}},t.matches=function(e){return function(t){var r=e.exec(t.id);return!!r&&(t.matched=r,t.matched.groups&&(t.params=t.matched.groups),!0)}},t.hasPrefix=function(e){return function(t){return!e||!!t.id.startsWith(e)&&(t.id=t.id.slice(e.length),t.prefix=t.prefix||""+e,!0)}}})),renderer=createCommonjsModule((function(e,t){var r,n=commonjsGlobal&&commonjsGlobal.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=commonjsGlobal&&commonjsGlobal.__assign||function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.DomWriter=t.DomAppender=void 0;var s=function(){function e(e,t){void 0===t&&(t={}),this.router=e,this.options=i({container:document.body},t),this.temporary=[],this.replaced=[]}return e.prototype.currentId=function(){var e=new Error("null request"),t=this.router.currentRequest(e);return t.prefix||""+t.id},e.prototype.currentFragment=function(){var e=this.currentId();return e?this.options.container.querySelector('[id="'+e+'"]'):null},e.prototype.restore=function(){for(;this.temporary.length;)this.temporary.pop().remove();for(;this.replaced.length;){var e=this.replaced.pop(),t=e.original;e.replacement.replaceWith(t)}},e.prototype.renderContent=function(e){this.render(function(e,t){var r=document.createElement("div");return r.id=e,r.textContent=t,r}(this.currentId(),e.toString()))},e.prototype.renderHtml=function(e){var t=document.createElement("template");t.innerHTML=e;var r=t.content;this.render(r.firstElementChild)},e}(),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.render=function(e){this.restore(),e.id=this.currentId(),this.options.container.appendChild(e)},t}(s);t.DomAppender=o;var a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.render=function(e){this.restore(),e.id=this.currentId();var t=this.currentFragment();t?(t.replaceWith(e),this.replaced.push({original:t,replacement:e})):(this.options.container.appendChild(e),this.temporary.push(e))},t}(s);t.DomWriter=a})),router$3=createCommonjsModule((function(e,t){var r=commonjsGlobal&&commonjsGlobal.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.Router=t.createRequest=void 0;var n=function(){},i=function(){};function s(e){return{id:e,control:{next:new n,abort:new i}}}t.createRequest=s;var o=function(){function e(){this.routes=[],this.subrouters=[],this.request=null,this.deferred=[],this.exitHandlers=[]}return e.prototype.currentRequest=function(e){if(this.request)return this.request;if(!e)return null;throw e},e.prototype.route=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length>0&&this.routes.push(e),this},e.prototype.mount=function(e,t){t!==this&&this.subrouters.push([e,t])},e.prototype.runRoute=function(e){for(var t=this.request,r=0,i=e;r<i.length;r++){var s=i[r];try{s(t)}catch(e){if(e instanceof n)return!1;throw e}}return!0},e.prototype.defer=function(e){this.deferred.push(e)},e.prototype.onExit=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];(e=this.exitHandlers).push.apply(e,t)},e.prototype.runDeferred=function(){var e=this.currentRequest();try{for(var t=0,r=this.deferred;t<r.length;t++){(0,r[t])(e)}}catch(t){throw e.control.abort}finally{this.deferred=[]}},e.prototype.runExitHandlers=function(){for(var e=0,t=this.subrouters;e<t.length;e++){t[e][1].runExitHandlers()}for(var r=0,n=this.exitHandlers;r<n.length;r++){(0,n[r])()}this.exitHandlers=[]},e.prototype.runRoutes=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=0,o=this.subrouters;n<o.length;n++){var a=o[n],u=a[0],c=a[1],l=c.runRoutes.apply(c,r(e,[filters$1.check(filters$1.hasPrefix(u))]));if(l)return!0}for(var d=!1,h=0,p=this.routes;h<p.length;h++){var f=p[h],m=s(window.location.hash.slice(1));this.request=m;try{for(var y=0,g=e;y<g.length;y++){var v=g[y];v(m)}}catch(e){break}try{if(this.runRoute(f)){this.runDeferred(),d=!0;break}}catch(e){if(e instanceof i)break}}return this.request=null,d},e.prototype.run=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.runExitHandlers(),this.runRoutes.apply(this,e)},e.prototype.listen=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=function(){return e.run.apply(e,t)};return window.addEventListener("load",n),window.addEventListener("hashchange",n),this},e}();t.Router=o})),dist$1=createCommonjsModule((function(e,t){var r=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),n(filters$1,t),n(renderer,t),n(router$3,t)})),dist=createCommonjsModule((function(e,t){function r(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e;var n=Object.getPrototypeOf(e);return n?r(n,t):null}function n(e,t,n){if(null!=e){var i=r(e,t);if(i){var s=Object.getOwnPropertyDescriptor(i,t),o=s.set||s.value;if(o&&"function"==typeof o){var a=function(e,t,r){function n(){var n=t.apply(e,arguments);return r(),n}return Object.defineProperty(n,"name",{value:t.name,writable:!1}),n}(e,o,n);if(i===e)e[t]=a;else{var u=function(e){var t={};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.setPrototypeOf(e,t),t}(e);s.set?Object.defineProperty(u,t,{get:s.get,set:a}):u[t]=a}}}}}Object.defineProperty(t,"__esModule",{value:!0}),t.View=t.hook=void 0,t.hook=n;var i=function(){function e(e){var t=this;this.state=null==e?void 0:e.state,this.container=(null==e?void 0:e.container)||document.body.appendChild(document.createElement("div"));for(var r=0,i=(null==e?void 0:e.hooks)||[];r<i.length;r++){var s=i[r];n(this.state,s,(function(){return t.update()}))}}return e.prototype.$=function(e){return this.container.querySelector(e)},e}();t.View=i}));function isNote$2(e){if(!e.id||!Number.isInteger(Number(e.id)))return!1;const t=document.getElementById(e.id);return Boolean(t?.classList.contains("slipbox-note"))}function isTag$1(e){if(!e.id.startsWith("tags/"))return!1;const t=document.getElementById(e.id);return Boolean(t?.classList.contains("level1"))}function isHome$2(e){return""===e.id}var filters={isHome:isHome$2,isNote:isNote$2,isTag:isTag$1};class List$1{constructor(e){this.data=e,this.prev=this,this.next=this}static from(e){return 0===e.length?null:e.slice(1).reduce(((e,t)=>e.append(new List$1(t))),new List$1(e[0]))}append(e){const t=e.prev;return e.prev=this.prev,e.prev.next=e,this.prev=t,this.prev.next=this,this}remove(){if(this.next===this)return this;const e=this.next;return this.next.prev=this.prev,this.prev.next=this.next,this.prev=this,this.next=this,e}*[Symbol.iterator](){yield this.data;let e=this.next;for(;e!==this;)yield e.data,e=e.next}}var List_1=List$1,linkedList={List:List_1};const{check:check$1,DomWriter:DomWriter$1,Router:Router$2}=dist$1,{View:View}=dist,{isNote:isNote$1,isHome:isHome$1}=filters,{List:List}=linkedList;class Flashcard extends List{constructor(e,t,r){super({id:e,prompt:t,response:r,status:"hidden"})}get id(){return this.data.id}get prompt(){return this.data.prompt}get response(){return this.data.response}get status(){return this.data.status}setStatus(e){switch(e){case"hidden":case"prompt":case"response":case"done":this.data.status=e;break;default:throw new Error("invalid value")}}}class FlashcardDeck{constructor(e){this.current=e}isDone(){return null==this.current||this.current.next===this&&"done"===this.current.status}start(){null!=this.current&&this.current.setStatus("prompt")}again(){null!=this.current&&(this.current.setStatus("hidden"),this.current.next!==this.current?(this.current=this.current.next,this.current.setStatus("prompt")):this.current.setStatus("prompt"))}next(){null!=this.current&&(this.current.setStatus("done"),this.current.next!==this.current?(this.current=this.current.remove(),this.current.setStatus("prompt")):this.current=null)}*[Symbol.iterator](){let e=this.current;if(null!=e)for(yield e,e=e.next;e!==this.current;)yield e,e=e.next}}class CardView extends View{constructor(e,t){super({container:t,state:e,hooks:["setStatus"]})}initialize(){this.container.innerHTML=`\n      <h2 class="flashcard-prompt">${this.state.prompt.innerHTML}</h2>\n      <div class="buttons">\n        <button type="button" class="button flashcard-show is-${this.state.status}">Show answer</button>\n      </div>\n      <div class="flashcard-response is-${this.state.status}">${this.state.response.innerHTML}</div>\n      <div class="buttons">\n        <button type="button" class="button flashcard-again is-${this.state.status}">Again?</button>\n        <button type="button" class="button flashcard-next is-${this.state.status}">Next&gt;</button>\n      </div>\n    `,this.$(".flashcard-response").querySelector("h1")?.remove(),this.$(".flashcard-show").addEventListener("click",(()=>this.state.setStatus("response")))}update(){this.$(".flashcard-show").className=`button flashcard-show is-${this.state.status}`,this.$(".flashcard-again").className=`button flashcard-again is-${this.state.status}`,this.$(".flashcard-next").className=`button flashcard-next is-${this.state.status}`,this.$(".flashcard-response").className=`flashcard-response is-${this.state.status}`}}class DeckView extends View{constructor(e,t){super({container:t,state:e,hooks:["again","next"]})}initialize(){const e=this.container;this.cardViews=new Map,e.innerHTML="";const t=document.createDocumentFragment();for(const e of this.state){const r=document.createElement("div");r.className="flashcard",t.appendChild(r);const n=new CardView(e,r);this.cardViews.set(e,n),n.initialize()}const r=document.createElement("div");r.className="flashcard flashcard-end "+(this.state.isDone()?"":"is-hidden"),r.innerHTML='\n      <p>You\'ve reached the end!</p>\n      <div class="buttons">\n        <a href="#review/" class="button">Go back</a>\n      </div>\n    ',t.appendChild(r),e.appendChild(t);for(const e of this.state){const t=this.cardViews.get(e);t.$(".flashcard-again").onclick=()=>this.state.again(),t.$(".flashcard-next").onclick=()=>this.state.next()}}update(){this.$(".flashcard-end").className="flashcard flashcard-end "+(this.state.isDone()?"":"is-hidden"),this.state.isDone()?this.$(".flashcard-end").scrollIntoView():this.cardViews.get(this.state.current).container.scrollIntoView()}}class SummarizedCardView extends View{constructor(e,t){super({container:t,state:e})}initialize(){this.container.innerHTML=`<a href="#review/${this.state.id}"></a>`,this.$("a").innerHTML=this.state.prompt.innerHTML}update(){}}function getEntrypoints(){return window.slipbox.cy.nodes((e=>0===e.indegree(!1)))}function createCard(e){const t=document.getElementById(e),r=t.querySelector("h1").cloneNode(!0),n=t.cloneNode(!0);return r.id="",new Flashcard(e,r,n)}class SrsPageView extends View{constructor(e){super({container:e})}initialize(){const e=this.container;e.innerHTML="\n      <h1>Review notes</h1>\n      <p>Pick a question to start with.</p>\n    ";const t=getEntrypoints().map((e=>{const t=createCard(e.id()),r=document.createElement("div");return r.className="flashcard",new SummarizedCardView(t,r)}));for(const r of t)r.initialize(),e.appendChild(r.container)}update(){}}function randomChoice(e){const t=e.length;return e[Math.floor(Math.random()*t)]}function randomPath(e){const t=[e.id()];for(;;){const r=e.outgoers().edges().targets((e=>!t.includes(e.id())));if(0===r.length)break;const n=randomChoice(r);t.push(n.id()),e=n}return t}function createDeck(e){const t=randomPath(window.slipbox.cy.$(`#${e}`)).map(createCard).reduce(((e,t)=>e.append(t)));return new FlashcardDeck(t)}const router$2=new Router$2,writer$1=new DomWriter$1(router$2);router$2.route(check$1(isNote$1),(e=>{const t=createDeck(e.id);t.start();const r=document.createElement("div"),n=new DeckView(t,r);n.initialize(),router$2.defer((()=>writer$1.render(n.container))),router$2.onExit((()=>writer$1.restore()))})),router$2.route(check$1(isHome$1),(()=>{const e=document.createElement("div"),t=new SrsPageView(e);t.initialize(),router$2.defer((()=>writer$1.render(t.container))),router$2.onExit((()=>writer$1.restore()))})),router$2.route((()=>router$2.defer((()=>{writer$1.restore(),window.location.replace("#review/")}))));var review={router:router$2,Flashcard:Flashcard};const{check:check,DomWriter:DomWriter,Router:Router$1}=dist$1,{isHome:isHome,isNote:isNote,isTag:isTag}=filters,router$1=new Router$1,writer=new DomWriter(router$1),secondaryWriter=new DomWriter(router$1);function clusterElements(e,t){const r=e.cy.edges(`[tag="${t}"]`);return r.connectedNodes().union(r.filter((e=>e.data("source")!==e.data("target"))))}function neighborElements(e,t){const r=e.cy.getElementById(t),n=new Set,i=r.incomers().edges("edge[tag]");for(;i.length>0;){const e=i.pop(),t=e.data("tag");n.has(e)||(i.push(...e.source().incomers(`edge[tag="${t}"]`)),n.add(e))}const s=new Set,o=r.outgoers().edges("edge[tag]");for(;o.length>0;){const e=o.pop(),t=e.data("tag");s.has(e)||(o.push(...e.target().outgoers(`edge[tag="${t}"]`)),s.add(e))}const a=e.cy.collection().union(Array.from(n)).union(Array.from(s)),u=a.connectedNodes(),c=r.openNeighborhood(),l=u.union(a).union(c).filter((e=>e.isNode()||e.data("source")!==e.data("target"))),d=l.getElementById(t).clone();return d.data("bgColor","black"),d.union(l)}function createGraphArea(){const e=document.createElement("div");return e.classList.add("slipbox-graph-cytoscape"),e}function createInfoArea(){const e=document.createElement("div");return e.classList.add("slipbox-graph-info"),e.innerHTML='\n    <h3><a href=""></a></h3>\n    <p></p>\n  ',e}function createPageCytoscape(e,t){const r=cytoscape({container:e,selectionType:"additive",style:[{selector:"node",style:{label:"data(label)",height:"2em",width:"2em",shape:"round-rectangle",color:"black","background-color":"data(bgColor)","text-wrap":"wrap","text-max-width":100}},{selector:"edge",style:{width:2,"curve-style":"bezier","line-color":"black","line-style":"solid","target-arrow-color":"black","target-arrow-shape":"triangle"}}]}),n=t.querySelector(".slipbox-graph-info a"),i=t.querySelector(".slipbox-graph-info p");return r.on("select","node",(e=>{const t=e.target.data("id");n.textContent=e.target.data("title"),n.href="#"+t,i.textContent=e.target.data("filename"),e.target.data("label",t)})),r.on("unselect","node",(e=>{n.textContent="",i.textContent="",e.target.data("label",e.target.data("title"))})),r}function changePageCytoscapeLayout(e,t="breadthfirst"){"cose"===t?e.layout({name:"cose",nodeDimensionsIncludeLabels:!0,numIter:300,fit:!0}).run():e.layout({name:"breadthfirst",spacingFactor:1,fit:!0,directed:!0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!0}).run()}function renderGraph(e,t="breadthfirst"){const r=createGraphArea(),n=createInfoArea();writer.render(r),secondaryWriter.render(n),router$1.onExit((()=>{writer.restore(),secondaryWriter.restore()}));const i=createPageCytoscape(r,n);i.add(e),changePageCytoscapeLayout(i,t)}function init(){const e=document.createElement("div");document.body.appendChild(e),writer.options.container=e,secondaryWriter.options.container=document.getElementById("secondary")}router$1.route(check(isNote),(e=>{const t=neighborElements(window.slipbox,e.id);t.length>=2&&router$1.defer((()=>renderGraph(t,"breadthfirst")))})),router$1.route(check(isTag),(e=>{const t=clusterElements(window.slipbox,"#"+e.id.slice(5));t.length>=2&&router$1.defer((()=>renderGraph(t,"breadthfirst")))})),router$1.route(check(isHome),(e=>{const t=window.slipbox.cy.elements().filter((e=>e.isNode()||e.data("source")!==e.data("target")));if(t.length>=2){const e=t.nodes().length>30?"cose":"breadthfirst";router$1.defer((()=>renderGraph(t,e)))}})),router$1.route((()=>writer.restore()));var graph={router:router$1,init:init};const{SlipboxCollection:SlipboxCollection}=slipbox,{Router:Router}=dist$1,router=new Router;router.mount("review/",review.router),router.mount("",graph.router),window.slipbox=new SlipboxCollection,window.initSlipbox=function(){window.slipbox.colorEntrypoints();const e=document.getElementById("title-block-header");e&&e.remove(),list.init(),search.init(),graph.init(),router.listen()};var src={};export default src;