@commentray/render 0.2.0 → 0.3.1

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.
Files changed (68) hide show
  1. package/dist/block-stretch-buffer-sync.d.ts +16 -0
  2. package/dist/block-stretch-buffer-sync.d.ts.map +1 -0
  3. package/dist/block-stretch-buffer-sync.js +271 -0
  4. package/dist/block-stretch-buffer-sync.js.map +1 -0
  5. package/dist/block-stretch-layout.d.ts +18 -5
  6. package/dist/block-stretch-layout.d.ts.map +1 -1
  7. package/dist/block-stretch-layout.js +119 -43
  8. package/dist/block-stretch-layout.js.map +1 -1
  9. package/dist/browse-page-slug.d.ts +3 -4
  10. package/dist/browse-page-slug.d.ts.map +1 -1
  11. package/dist/browse-page-slug.js +3 -4
  12. package/dist/browse-page-slug.js.map +1 -1
  13. package/dist/build-commentray-nav-search.d.ts +2 -2
  14. package/dist/build-commentray-nav-search.js +1 -1
  15. package/dist/code-browser-block-rays.d.ts +11 -0
  16. package/dist/code-browser-block-rays.d.ts.map +1 -1
  17. package/dist/code-browser-block-rays.js +25 -5
  18. package/dist/code-browser-block-rays.js.map +1 -1
  19. package/dist/code-browser-client.bundle.js +12 -11
  20. package/dist/code-browser-client.js +1366 -257
  21. package/dist/code-browser-client.js.map +1 -1
  22. package/dist/code-browser-pair-nav.d.ts +9 -2
  23. package/dist/code-browser-pair-nav.d.ts.map +1 -1
  24. package/dist/code-browser-pair-nav.js +53 -14
  25. package/dist/code-browser-pair-nav.js.map +1 -1
  26. package/dist/code-browser-scroll-sync-monotonic.d.ts +17 -0
  27. package/dist/code-browser-scroll-sync-monotonic.d.ts.map +1 -0
  28. package/dist/code-browser-scroll-sync-monotonic.js +22 -0
  29. package/dist/code-browser-scroll-sync-monotonic.js.map +1 -0
  30. package/dist/code-browser-scroll-sync-strategy.d.ts +12 -0
  31. package/dist/code-browser-scroll-sync-strategy.d.ts.map +1 -0
  32. package/dist/code-browser-scroll-sync-strategy.js +28 -0
  33. package/dist/code-browser-scroll-sync-strategy.js.map +1 -0
  34. package/dist/code-browser-scroll-sync.d.ts +2 -2
  35. package/dist/code-browser-scroll-sync.d.ts.map +1 -1
  36. package/dist/code-browser-scroll-sync.js +1 -1
  37. package/dist/code-browser-scroll-sync.js.map +1 -1
  38. package/dist/code-browser-smooth-reveal-dedup.d.ts +25 -0
  39. package/dist/code-browser-smooth-reveal-dedup.d.ts.map +1 -0
  40. package/dist/code-browser-smooth-reveal-dedup.js +25 -0
  41. package/dist/code-browser-smooth-reveal-dedup.js.map +1 -0
  42. package/dist/code-browser.d.ts +25 -8
  43. package/dist/code-browser.d.ts.map +1 -1
  44. package/dist/code-browser.js +382 -93
  45. package/dist/code-browser.js.map +1 -1
  46. package/dist/commentray-anchor-viewport-probe.d.ts +5 -1
  47. package/dist/commentray-anchor-viewport-probe.d.ts.map +1 -1
  48. package/dist/commentray-anchor-viewport-probe.js +8 -2
  49. package/dist/commentray-anchor-viewport-probe.js.map +1 -1
  50. package/dist/index.d.ts +2 -1
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +1 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/inject-md-line-anchors.d.ts +1 -1
  55. package/dist/inject-md-line-anchors.d.ts.map +1 -1
  56. package/dist/inject-md-line-anchors.js +9 -5
  57. package/dist/inject-md-line-anchors.js.map +1 -1
  58. package/dist/markdown-pipeline.d.ts.map +1 -1
  59. package/dist/markdown-pipeline.js +10 -3
  60. package/dist/markdown-pipeline.js.map +1 -1
  61. package/dist/mermaid-runtime-html.d.ts.map +1 -1
  62. package/dist/mermaid-runtime-html.js +4 -1
  63. package/dist/mermaid-runtime-html.js.map +1 -1
  64. package/dist/reading-viewport-comfort.d.ts +12 -0
  65. package/dist/reading-viewport-comfort.d.ts.map +1 -0
  66. package/dist/reading-viewport-comfort.js +14 -0
  67. package/dist/reading-viewport-comfort.js.map +1 -0
  68. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var z=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,i=e.length;r<i;r++)t[r]=e[r];return t}},ue=class{static getHashCode(e){let t=5381,r=t;for(let i=0,o=e.length;i<o&&e[i]!="\0"&&(t=(t<<5)+t^e.charCodeAt(i),i!==o-1&&e[i+1]!=="\0");i+=2)r=(r<<5)+r^e.charCodeAt(i+1);return t+1566083941*r|0}},b=class{constructor(e){this.entries=void 0,this.entries=e!==void 0?e:new Map}add(e,t){if(this.entries.has(e))throw new Error(`A meta entry with key ${e} is already present.`);this.entries.set(e,t)}get(e){return this.entries.get(e)}get allEntries(){return this.entries}toJSON(){return{entries:Object.fromEntries(this.entries)}}},J=class{static mergeMeta(e){if(e.length===0)return new b;if(e.length===1)return e[0];let t=new Map;for(let i of e)for(let[o,s]of i.allEntries){let a=t.get(o);a===void 0?t.set(o,[s]):a.push(s)}let r=new Map;for(let[i,o]of t)if(o.length!==1){if(o.every(s=>typeof s=="number")){let s=o.reduce((a,c)=>a+c,0);r.set(i,s);continue}for(let s=0;s<o.length;s++)r.set(`${i}_${s}`,o[s])}else r.set(i,o[0]);return new b(r)}},he=class{static isSurrogate(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}static isAlphanumeric(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122}static isLowerAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122}},de=class{constructor(e,t){this.usableSearchers=void 0,this.usableSearchers=new Map;for(let r of t)e.includes(r.type)&&this.usableSearchers.set(r.type,r)}has(e){return this.usableSearchers.has(e)}minQuality(e){return this.usableSearchers.get(e).minQuality}spec(e){return this.usableSearchers.get(e)}},$=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},y,X;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(y||(y={}));var Z=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},ee=class extends Z{constructor(e){super(y.Fuzzy,e)}},_=class extends Z{constructor(e){super(y.Substring,e)}},Q=class extends Z{constructor(e){super(y.Prefix,e)}},O=class{constructor(e,t=10,r=[new ee(.3),new _(0),new Q(0)]){this.string=void 0,this.topN=void 0,this.searchers=void 0,this.string=e,this.topN=Math.max(0,t),this.searchers=r}},Ne=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},ze=class{static mergeResults(e,t){let r=e.query,i=this.mergeMatches(e.matches,t.matches,r.topN),o=J.mergeMeta([e.meta,t.meta]);return new $(i,r,o)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let i=[...e,...t];return i.sort((o,s)=>o.quality>s.quality?-1:o.quality<s.quality?1:0),i.length<=r?i:i.slice(0,r)}},$e=class{constructor(e,t,r){this.maxQueryLength=void 0,this.mainSearcher=void 0,this.secondarySearcher=void 0,this.maxQueryLength=e,this.mainSearcher=t,this.secondarySearcher=r}indexEntities(e,t,r){return this.secondarySearcher.indexEntities([],t,r),this.mainSearcher.indexEntities(e,t,r)}getMatches(e){return e.string?(e.string.length>this.maxQueryLength&&(e=new O(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),ze.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new $([],e,new b)}tryGetTerms(e){let t=this.mainSearcher.tryGetTerms(e);return t!==null?t:this.secondarySearcher.tryGetTerms(e)}getTerms(){return this.mainSearcher.getTerms().concat(this.secondarySearcher.getTerms())}tryGetEntity(e){var t,r;return(t=(r=this.mainSearcher.tryGetEntity(e))!=null?r:this.secondarySearcher.tryGetEntity(e))!=null?t:null}getEntities(){return this.mainSearcher.getEntities().concat(this.secondarySearcher.getEntities())}removeEntities(e){let t=[];for(let i=0,o=e.length;i<o;i++)(this.mainSearcher.removeEntity(e[i])||this.secondarySearcher.removeEntity(e[i]))&&t.push(e[i]);let r=new b;return new Ne(t,r)}upsertEntities(e,t,r){let i=[],o=[];for(let s=0,a=e.length;s<a;s++){let c=e[s],l=t(c);this.tryUpdate(c,l,r)||(i.push(l),o.push(c))}return this.removeEntities(i),o.length>0?this.reindexSecondarySearcher(o,t,r):new b}reindexSecondarySearcher(e,t,r){let i=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(i,t,r)}tryUpdate(e,t,r){return this.tryUpdateSearcher(e,t,r,this.mainSearcher)||this.tryUpdateSearcher(e,t,r,this.secondarySearcher)}tryUpdateSearcher(e,t,r,i){let o=i.tryGetTerms(t);if(o===null)return!1;if(this.termsAreEqual(o,r(e))){if(!i.replaceEntity(t,e,t))throw new Error(`Entity with id ${t} was not present.`);return!0}return!1}termsAreEqual(e,t){return e===t||e!=null&&t!=null&&e.length===t.length&&e.every((r,i)=>r===t[i])}removeEntity(e){return this.mainSearcher.removeEntity(e)||this.secondarySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.mainSearcher.replaceEntity(e,t,r)||this.secondarySearcher.replaceEntity(e,t,r)}save(e){this.mainSearcher.save(e),this.secondarySearcher.save(e)}load(e){this.mainSearcher.load(e),this.secondarySearcher.load(e)}},Oe=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),i=Math.round(performance.now()-t);return r.meta.add("removalDuration",i),r}upsertEntities(e,t,r){let i=performance.now(),o=this.dynamicSearcher.upsertEntities(e,t,r),s=Math.round(performance.now()-i);return o.add("upsertDuration",s),o}indexEntities(e,t,r){let i=performance.now(),o=this.dynamicSearcher.indexEntities(e,t,r),s=Math.round(performance.now()-i);return o.add("indexingDurationTotal",s),o}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),i=Math.round(performance.now()-t);return r.meta.add("queryDuration",i),r}tryGetEntity(e){return this.dynamicSearcher.tryGetEntity(e)}getEntities(){return this.dynamicSearcher.getEntities()}tryGetTerms(e){return this.dynamicSearcher.tryGetTerms(e)}getTerms(){return this.dynamicSearcher.getTerms()}removeEntity(e){return this.dynamicSearcher.removeEntity(e)}replaceEntity(e,t,r){return this.dynamicSearcher.replaceEntity(e,t,r)}save(e){this.dynamicSearcher.save(e)}load(e){this.dynamicSearcher.load(e)}},qe=class{constructor(e,t,r){this.entity=void 0,this.quality=void 0,this.matchedString=void 0,this.entity=e,this.quality=t,this.matchedString=r}},We=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},te=class{constructor(e,t=0,r){this.string=void 0,this.minQuality=void 0,this.searcherType=void 0,this.string=e,this.minQuality=Math.max(0,Math.min(1,t)),this.searcherType=r}},Ge=class{constructor(e,t){this.stringSearcher=void 0,this.searcherTypes=void 0,this.entities=void 0,this.idToIndex=void 0,this.terms=void 0,this.termIndexToEntityIndex=void 0,this.entityIndexToFirstTermIndex=void 0,this.searchersAndQualityOffsets=[{searcherType:y.Prefix,qualityOffset:2},{searcherType:y.Substring,qualityOffset:1},{searcherType:y.Fuzzy,qualityOffset:0}],this.stringSearcher=e,this.searcherTypes=t,this.entities=[],this.idToIndex=new Map,this.terms=[],this.termIndexToEntityIndex=new Int32Array(0),this.entityIndexToFirstTermIndex=new Int32Array(0)}indexEntities(e,t,r){this.entities=[...e],this.idToIndex=new Map,this.terms=[];let i=[],o=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);o.push(this.terms.length),this.terms.push(...l),i.push(...l.map(()=>a))}this.termIndexToEntityIndex=z.ToInt32Array(i),this.entityIndexToFirstTermIndex=z.ToInt32Array(o);let s=this.stringSearcher.index(this.terms);return s.add("numberOfEntities",this.entities.length),s.add("numberOfTerms",this.terms.length),s}getMatches(e){let t=new We(e),r=new de(this.searcherTypes,e.searchers);for(let{searcherType:o,qualityOffset:s}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(o)&&this.addMatchesFromSearcher(t,r.spec(o),s)}let i=J.mergeMeta(t.meta);return new $(t.matches,e,i)}addMatchesFromSearcher(e,t,r){let i=Math.max(0,t.minQuality-r);if(i>1)return;let o=new te(e.query.string,i,t.type),s=this.stringSearcher.getMatches(o);this.addMatchesFromResult(e,s,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let i=0,o=t.matches.length;i<o;i++){let s=t.matches[i],a=this.termIndexToEntityIndex[s.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new qe(this.entities[a],s.quality+r,this.terms[s.index])),e.matches.length===e.query.topN))break}}tryGetEntity(e){let t=this.idToIndex.get(e);return t===void 0?null:this.entities[t]}getEntities(){return this.entities.filter(e=>e!==null)}tryGetTerms(e){let t=this.idToIndex.get(e);return t===void 0?null:this.terms.slice(this.entityIndexToFirstTermIndex[t],t===this.entities.length-1?this.terms.length:this.entityIndexToFirstTermIndex[t+1])}getTerms(){let e=[];for(let t=0,r=this.termIndexToEntityIndex.length;t<r;t++)this.entities[this.termIndexToEntityIndex[t]]!==null&&e.push(this.terms[t]);return e}removeEntity(e){let t=this.idToIndex.get(e);return t!==void 0&&(this.entities[t]=null,this.idToIndex.delete(e),!0)}replaceEntity(e,t,r){let i=this.idToIndex.get(e);return i!==void 0&&(this.entities[i]=t,this.idToIndex.delete(e),this.idToIndex.set(r,i),!0)}save(e){e.add(this.entities),e.add(this.idToIndex),e.add(this.terms),e.add(this.termIndexToEntityIndex),e.add(this.entityIndexToFirstTermIndex),this.stringSearcher.save(e)}load(e){this.entities=e.get(),this.idToIndex=e.get(),this.terms=e.get(),this.termIndexToEntityIndex=e.get(),this.entityIndexToFirstTermIndex=e.get(),this.stringSearcher.load(e)}},I=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},Ue=class{constructor(e,t){this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.numberOfSurrogateCharacters=0,this.treatCharacterAsSpace=e,this.allowCharacter=t}normalize(e){let t=new Array(e.length),r=0,i=!1,o=!1;for(let s=0,a=e.length;s<a;s++){let c=this.getNormalizedCharacter(e[s]);c!==""&&(c===" "?i=!0:(i&&o&&(t[r++]=" "),t[r++]=c,o=!0,i=!1))}return o?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!he.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(i=>this.normalize(i)),r=new b;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new I(t,r)}},_e=class{constructor(e){this.normalizationFunction=void 0,this.normalizationFunction=e}normalize(e){return this.normalizationFunction(e)}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new I(t,new b)}},Qe=class{constructor(e){this.normalizers=void 0,this.normalizers=e}normalize(e){for(let t=0,r=this.normalizers.length;t<r;t++)e=this.normalizers[t].normalize(e);return e}normalizeBulk(e){let t=new b;for(let r=0,i=this.normalizers.length;r<i;r++){let o=this.normalizers[r].normalizeBulk(e);e=o.strings;for(let s of o.meta.allEntries)t.add(s[0],s[1])}return new I(e,t)}},je=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new I(t,new b)}},Ye=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let i=new Map;for(let[o,s]of r)for(let a of s){let c=t(a);i.set(c,o)}this.replacements.push(i)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let i=0,o=e.length;i<o;i++)for(let s of this.replacements){let a=s.get(e[i]);if(a!==void 0){t[r++]=a;break}t[r++]=e[i]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new I(t,new b)}},Ve=class{static create(e){let t=new je,r=new Ye(e.replacements,s=>s.toLowerCase().normalize("NFKC")),i=new _e(s=>s.normalize("NFKD")),o=new Ue(e.treatCharacterAsSpace,e.allowCharacter);return new Qe([t,r,i,o])}},ne=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},H=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},Ke=class{constructor(e){this.stringSearcher=void 0,this.distinctMapping=void 0,this.sortMapping=void 0,this.stringSearcher=e,this.distinctMapping=new Int32Array(0),this.sortMapping=new Int32Array(0)}index(e){let t=e.map((c,l)=>({term:c,index:l}));t.sort((c,l)=>c.term<l.term?-1:c.term>l.term?1:0),this.sortMapping=new Int32Array(t.length);for(let c=0,l=t.length;c<l;c++)this.sortMapping[c]=t[c].index;let r=[],i=[],o=0,s=null;for(let c=0,l=t.length;c<l;c++){let u=t[c].term;u!=s&&(r[o]=u,i[o]=c,o++),s=u}i[o++]=t.length,this.distinctMapping=z.ToInt32Array(i);let a=this.stringSearcher.index(r);return a.add("numberOfDistinctTerms",r.length),a}getMatches(e){let t=this.stringSearcher.getMatches(e),r=new Array(t.matches.length),i=0;return t.matches.forEach(o=>{let s=this.distinctMapping[o.index+1];for(let a=this.distinctMapping[o.index];a<s;a++)r[i++]=new ne(this.sortMapping[a],o.quality)}),new H(r,e,t.meta)}save(e){e.add(this.distinctMapping),e.add(this.sortMapping),this.stringSearcher.save(e)}load(e){this.distinctMapping=e.get(),this.sortMapping=e.get(),this.stringSearcher.load(e)}},Je=class{constructor(e,t){this.entitySearcher=void 0,this.searcherTypes=void 0,this.entitySearcher=e,this.searcherTypes=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=new de(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(y.Prefix)&&t.minQuality(y.Prefix)<2.2){let r=new O(e.string,e.topN,[new Q(2.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new $(i.matches,e,i.meta)}if(e.string.length<=3&&!t.has(y.Prefix)&&t.has(y.Substring)&&t.minQuality(y.Substring)<1.2){let r=new O(e.string,e.topN,[new _(1.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new $(i.matches,e,i.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},me=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=z.ToInt32Array(this.ids),this.frequencies=z.ToInt32Array(this.frequencies)}get length(){return this.ids.length}save(e){e.add(this.ids),e.add(this.frequencies)}load(e){this.ids=e.get(),this.frequencies=e.get()}},K=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let i=this.ngramToTermIds.get(e);i||(i=new me,this.ngramToTermIds.set(e,i)),i.addId(t,r)}seal(){for(let e of this.ngramToTermIds.values())e.seal()}getIds(e){return this.ngramToTermIds.get(e)}get size(){return this.ngramToTermIds.size}save(e){e.add(this.ngramToTermIds.size);for(let[t,r]of this.ngramToTermIds)e.add(t),r.save(e)}load(e){let t=e.get();for(let r=0;r<t;r++){let i=e.get(),o=new me;o.load(e),this.ngramToTermIds.set(i,o)}}},Xe=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},Ze=class{constructor(e){this.ngramComputer=void 0,this.invertedIndex=void 0,this.numberOfNgrams=void 0,this.commonNgramCounts=void 0,this.ngramComputer=e,this.invertedIndex=new K,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new K,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let s=0,a=e.length;s<a;s++){let c=e[s];if(!this.isValidTerm(c)){this.numberOfNgrams[s]=0,r++;continue}let l=this.ngramComputer.computeNgrams(c);this.numberOfNgrams[s]=l.length;let u=this.getNgramsToFrequency(l);for(let[h,d]of u)this.invertedIndex.add(h,s,d)}this.invertedIndex.seal();let i=Math.round(performance.now()-t),o=new b;return o.add("numberOfInvalidTerms",r),o.add("indexingDurationFuzzySearcher",i),o}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new H([],e,new b);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),i=t.length;this.computeCommonNgramCounts(r);let o=this.getMatchesFromCommonNgrams(i,e.minQuality);return new H(o,e,new b)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let i=this.invertedIndex.getIds(t);if(i!=null)for(let o=0,s=i.length;o<s;o++)this.commonNgramCounts[i.ids[o]]+=Math.min(r,i.frequencies[o])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,i=e.length;r<i;r++){let o=e[r],s=t.get(o);t.set(o,s!==void 0?s+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let i=0,o=this.numberOfNgrams.length;i<o;i++){let s=Xe.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[i],this.commonNgramCounts[i]);s>t&&r.push(new ne(i,s))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new K,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},et=class{constructor(e,t){this.stringSearcher=void 0,this.penaltyFactor=void 0,this.hashCodes=void 0,this.stringSearcher=e,this.penaltyFactor=1-t,this.hashCodes=new Int32Array(0)}index(e){this.hashCodes=new Int32Array(e.length);for(let t=0,r=e.length;t<r;t++)this.hashCodes[t]=ue.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=ue.getHashCode(e.string),r=this.stringSearcher.getMatches(e),i=r.matches.map(o=>this.penalizeMatch(o,t)).filter(o=>o.quality>=e.minQuality);return new H(i,r.query,r.meta)}penalizeMatch(e,t){return e.quality*=this.hashCodes[e.index]===t?1:this.penaltyFactor,e}save(e){e.add(this.hashCodes),this.stringSearcher.save(e)}load(e){this.hashCodes=e.get(),this.stringSearcher.load(e)}},tt=class{constructor(e,t){this.ngramN=void 0,this.transformNgram=void 0,this.ngramN=e,this.transformNgram=t??(r=>r)}computeNgrams(e){if(e.length===0)return[];if(e.length<=this.ngramN){let r=this.transformNgram(e);return r?[r]:[]}let t=[];for(let r=0,i=this.maximumNumberOfNgrams(e);r<i;r++){let o=this.transformNgram(e.substring(r,r+this.ngramN));o&&t.push(o)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},nt=class{constructor(e,t,r){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r}normalize(e){return e&&`${this.paddingLeft}${e.split(" ").join(this.paddingMiddle)}${this.paddingRight}`}normalizeBulk(e){let t=e.map(i=>this.normalize(i)),r=new b;return new I(t,r)}},fe=class{};fe.Value=new Map([["a",["\u1D8F","\u2C65","\u0251","\u1D00","\u0250","\u0252"]],["aa",["\xE5","\uA733"]],["ae",["\xE4","\xE6","\u1D01","\u1D2D","\u1D46","\u01FD","\u01E3","\u1D02"]],["ao",["\uA735"]],["au",["\uA737"]],["av",["\uA739","\uA73B"]],["ay",["\uA73D"]],["b",["\u0180","\u0253","\u0183","\u1D6C","\u1D80","\u0299"]],["c",["\u023C","\u0188","\u0255","\u1D04","\uA73F","\u2184"]],["d",["\u0111","\xF0","\u0256","\u0257","\u018C","\u1D6D","\u1D81","\u1D91","\u0221","\u1D05","\uA77A"]],["db",["\u0238"]],["e",["\u1D92","\u0247","\u2C78","\u1D07","\u0259","\u01DD","\u025B"]],["eo",["\u1D14"]],["f",["\u0192","\u1D6E","\u1D82","\uA730","\uA77C"]],["g",["\u01E5","\u0260","\u1D83","\u0262","\u021D","\u014B","\uA7A1","\u1D79","\uA77F"]],["h",["\u0127","\u2C68","\u0266","\u029C","\u0303","\u0267","\u2C76","\u0265"]],["hv",["\u0195"]],["i",["\u0268","\u1D7B","\u1D96","\u0131","\u026A","\u0269"]],["j",["\u0249","\u0237","\u029D","\u025F","\u0284","\u1D0A"]],["k",["\u0199","\u2C6A","\u1D84","\uA741","\u1D0B","\uA743","\uA745","\uA7A3"]],["l",["\u0142","\u019A","\u2C61","\u026B","\u026C","\u1D85","\u026D","\u0234","\u029F","\uA749","\uA781","\uA747"]],["m",["\u1D6F","\u1D86","\u0271","\u1D0D","\u026F"]],["n",["\u0272","\u019E","\u1D70","\u1D87","\u0273","\u0235","\u0274","\uA791","\uA7A5"]],["o",["\xF8","\u01FF","\u0275","\u0254","\u2C7A","\u1D0F","\uA74B","\uA74D"]],["oe",["\xF6","\u0153"]],["oi",["\u01A3"]],["oo",["\uA74F"]],["ou",["\u0223"]],["p",["\u1D7D","\u01A5","\u1D71","\u1D88","\u1D18","\u01BF","\uA751","\uA753","\uA755"]],["q",["\u024B","\u02A0","\uA757","\uA759"]],["qp",["\u0239"]],["r",["\u024D","\u027D","\uA75B","\u1D72","\u1D89","\u027C","\u027E","\u1D73","\u0280","\u0279","\u0281","\uA7A7","\uA783"]],["s",["\u1D74","\u1D8A","\u0282","\u023F","\uA731","\u0283","\uA7A9","\uA785","\u017F"]],["ss",["\xDF"]],["t",["\u0167","\u2C66","\u01AD","\u0288","\u1D75","\u01AB","\u0236","\u1D1B","\uA787"]],["th",["\xFE"]],["tz",["\uA729"]],["u",["\u0289","\u028A","\u1D7E","\u1D1C","\u1D99"]],["ue",["\xFC","\u1D6B"]],["v",["\u028B","\u1D8C","\u2C71","\u2C74","\u1D20","\u028C","\uA75F"]],["vy",["\uA761"]],["w",["\u2C73","\u1D21","\u028D"]],["x",["\u1D8D"]],["y",["\u024F","\u01B4","\u028F","\u1EFF"]],["z",["\u01B6","\u0225","\u2C6C","\u1D76","\u1D8E","\u0290","\u0291","\u0240","\u1D22","\u0292","\u01B9","\uA763"]]]);var ge=class n{constructor(e,t,r){this.replacements=void 0,this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.replacements=e,this.treatCharacterAsSpace=t,this.allowCharacter=r}static createDefaultConfig(){let e=new Set(["_","-","\u2013","/",","," "]);return new n([fe.Value],t=>e.has(t),t=>he.isAlphanumeric(t))}},pe=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),i=Math.round(performance.now()-t),o=this.stringSearcher.index(r.strings);o.add(this.normalizationDurationMetaKey,i);for(let s of r.meta.allEntries)o.add(s[0],s[1]);return o}getMatches(e){let t=new te(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new H(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},rt=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new H([],e,new b);let t=this.modifyQueryString(e.string),r=new te(t,e.minQuality,e.searcherType);return this.suffixArraySearcher.getMatches(r,e.string.length)}modifyQueryString(e){return`${this.suffixArraySearcher.separator}${e}`}save(e){this.suffixArraySearcher.save(e)}load(e){this.suffixArraySearcher.load(e)}},it=class{constructor(e,t,r){this.prefixSearcher=void 0,this.substringSearcher=void 0,this.fuzzySearcher=void 0,this.prefixSearcher=e,this.substringSearcher=t,this.fuzzySearcher=r}index(e){let t=[];if(this.prefixSearcher&&!this.substringSearcher){let r=this.prefixSearcher.index(e);t.push(r)}if(this.substringSearcher){let r=this.substringSearcher.index(e);t.push(r)}if(this.fuzzySearcher){let r=this.fuzzySearcher.index(e);t.push(r)}return J.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case y.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case y.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case y.Fuzzy:if(!this.fuzzySearcher)throw new Error("No fuzzy searcher has been indexed.");return this.fuzzySearcher.getMatches(e);default:throw new Error(`Unknown searcher type: ${e.searcherType}`)}}save(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.save(e),this.substringSearcher&&this.substringSearcher.save(e),this.fuzzySearcher&&this.fuzzySearcher.save(e)}load(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.load(e),this.substringSearcher&&this.substringSearcher.load(e),this.fuzzySearcher&&this.fuzzySearcher.load(e)}};(function(n){n.QualityAndIndex="qualityAndIndex",n.QualityAndMatchedString="qualityAndMatchedString"})(X||(X={}));var ot=class{constructor(e,t){this.sortOrder=void 0,this.entitySearcher=void 0,this.collator=new Intl.Collator(void 0,{numeric:!0}),this.sortOrder=e,this.entitySearcher=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=this.entitySearcher.getMatches(e);switch(this.sortOrder){case X.QualityAndIndex:return t;case X.QualityAndMatchedString:return this.sortMatchesByQualityAndMatchedString(t.matches),t;default:throw new Error(`Unsupported sort order: ${this.sortOrder}`)}}sortMatchesByQualityAndMatchedString(e){e.sort((t,r)=>t.quality>r.quality?-1:t.quality<r.quality?1:this.collator.compare(t.matchedString,r.matchedString))}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}save(e){this.entitySearcher.save(e)}load(e){this.entitySearcher.load(e)}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}},st=class{constructor(e){this.stringSearcher=void 0,this.stringSearcher=e}index(e){return this.stringSearcher.index(e)}getMatches(e){let t=this.stringSearcher.getMatches(e);return t.matches.sort(this.compareMatchesByQualityAndIndex),t}compareMatchesByQualityAndIndex(e,t){return e.quality>t.quality?-1:e.quality<t.quality?1:e.index<t.index?-1:e.index>t.index?1:0}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},re=class{static compareOrdinal(e,t,r,i,o){let s=Math.min(t+o,e.length),a=Math.min(i+o,r.length),c=t,l=i;for(;c<s&&l<a;){let d=e.charCodeAt(c),f=r.charCodeAt(l);if(d<f)return-1;if(d>f)return 1;c++,l++}let u=s-t,h=a-i;return u===h?0:u<h?-1:1}},at=class n{static create(e){if(e==null)throw new Error("Input string cannot be null.");let t=new n(e);return t.FormInitialChains(),t.BuildSufixArray(),t.sa}constructor(e){this.inputString=void 0,this.eoc=2147483647,this.sa=void 0,this.isa=void 0,this.chainHeadsDict=void 0,this.chainStack=[],this.subChains=[],this.nextRank=1,this.inputString=e;let t=e.length;this.sa=new Int32Array(t),this.isa=new Int32Array(t),this.chainHeadsDict=new Map}FormInitialChains(){this.FindInitialChains(),this.SortAndPushSubchains()}FindInitialChains(){for(let e=0;e<this.inputString.length;e++){let t=this.inputString.charCodeAt(e),r=this.chainHeadsDict.get(t);this.isa[e]=r!==void 0?r:this.eoc,this.chainHeadsDict.set(t,e)}for(let e of this.chainHeadsDict.values()){let t=new ye(e,1);this.subChains.push(t)}}BuildSufixArray(){for(;this.chainStack.length>0;){let e=this.chainStack.pop();this.isa[e.head]===this.eoc?this.RankSuffix(e.head):this.RefineChainWithInductionSorting(e)}}RankSuffix(e){this.isa[e]=-this.nextRank,this.sa[this.nextRank-1]=e,this.nextRank++}RefineChainWithInductionSorting(e){let t=[];for(this.chainHeadsDict.clear(),this.subChains=[];e.head!==this.eoc;){let r=this.isa[e.head];if(e.head+e.length>this.inputString.length-1)this.RankSuffix(e.head);else if(this.isa[e.head+e.length]<0){let i=new ct(e.head,-this.isa[e.head+e.length]);t.push(i)}else this.ExtendChain(e);e.head=r}this.SortAndPushSubchains(),this.SortAndRankNotedSuffixes(t)}ExtendChain(e){let t=this.inputString.charCodeAt(e.head+e.length);if(this.chainHeadsDict.has(t))this.isa[this.chainHeadsDict.get(t)]=e.head,this.isa[e.head]=this.eoc;else{this.isa[e.head]=this.eoc;let r=new ye(e.head,e.length+1);this.subChains.push(r)}this.chainHeadsDict.set(t,e.head)}SortAndRankNotedSuffixes(e){e.sort((t,r)=>t.rank-r.rank);for(let t=0;t<e.length;t++)this.RankSuffix(e[t].head)}SortAndPushSubchains(){this.subChains.sort((e,t)=>{let r=Math.min(e.length,t.length);return re.compareOrdinal(this.inputString,e.head,this.inputString,t.head,r)});for(let e=this.subChains.length-1;e>=0;e--)this.chainStack.push(this.subChains[e])}},ct=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},ye=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},lt=class{constructor(e){this.separator=void 0,this.str=void 0,this.suffixArray=void 0,this.indexToTermIndex=void 0,this.termLengths=void 0,this.separator=e,this.str="",this.suffixArray=new Int32Array(0),this.indexToTermIndex=new Int32Array(0),this.termLengths=new Int32Array(0)}index(e){let t=performance.now();this.str=e.length>0?this.separator+e.join(this.separator)+this.separator:"",this.suffixArray=at.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let s=0;s<e.length;s++){this.termLengths[s]=e[s].length;for(let a=0;a<=e[s].length;a++)this.indexToTermIndex[r++]=s}this.indexToTermIndex[r++]=-1;let i=Math.round(performance.now()-t),o=new b;return o.add("indexingDurationSuffixArraySearcher",i),o}getMatches(e,t){if(!e.string)return new H([],e,new b);let[r,i]=this.GetPositionsInSuffixArray(e.string),o=new Int32Array(i-r),s=new Set,a=0;for(let u=r;u<i;u++){let h=this.indexToTermIndex[this.suffixArray[u]];s.has(h)||(s.add(h),o[a++]=h)}let c=[];t=t??e.string.length;let l=0;for(let u=0;u<a;u++)l=this.computeQuality(t,this.termLengths[o[u]]),l>e.minQuality&&c.push(new ne(o[u],l));return new H(c,e,new b)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,i=0;for(;t<r;)i=Math.floor((t+r)/2),re.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)>0?t=i+1:r=i;let o=t;for(r=this.suffixArray.length;t<r;)i=Math.floor((t+r)/2),re.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)==0?t=i+1:r=i;return[o,r]}save(e){e.add(this.str),e.add(this.suffixArray),e.add(this.indexToTermIndex),e.add(this.termLengths)}load(e){this.str=e.get(),this.suffixArray=e.get(),this.indexToTermIndex=e.get(),this.termLengths=e.get()}},be=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),i=this.tryCreateSubstringSearcher(e),o=this.tryCreatePrefixSearcher(e,i),s=new it(o,i,r);s=new Ke(s),s=new st(s),s=new pe(s,t,"normalizationDurationDefault");let a=new Ge(s,e.searcherTypes);return a=new Je(a,e.searcherTypes),a=new ot(e.sortOrder,a),a}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(i=>t.add(i)),e.fuzzySearchConfig.paddingRight.split("").forEach(i=>t.add(i)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(i=>t.add(i))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(i=>t.add(i));let r=new ge(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,i=>e.normalizerConfig.allowCharacter(i)&&!t.has(i));return Ve.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(y.Fuzzy))return null;if(e.fuzzySearchConfig===void 0)throw new Error("Unable to create fuzzy searcher: No fuzzy search config provided.");return this.createFuzzySearcher(e.fuzzySearchConfig)}static createFuzzySearcher(e){let t=new tt(e.ngramN,e.transformNgram),r=new nt(e.paddingLeft,e.paddingRight,e.paddingMiddle),i=new Ze(t);return i=new et(i,e.inequalityPenalty),i=new pe(i,r,"normalizationDurationNgrams"),i}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(y.Substring))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create substring searcher: No substring search config provided.");return this.createSubstringSearcher(e.substringSearchConfig)}static createSubstringSearcher(e){return new lt(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(y.Prefix))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create prefix searcher: No substring search config provided.");return this.createPrefixSearcher(e.substringSearchConfig,t)}static createPrefixSearcher(e,t){return t===null&&(t=this.createSubstringSearcher(e)),new rt(t)}},ut=class n{constructor(e,t,r,i,o,s){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.ngramN=void 0,this.transformNgram=void 0,this.inequalityPenalty=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r,this.ngramN=i,this.transformNgram=o,this.inequalityPenalty=s}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var ht=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},dt=class n{constructor(e,t,r,i,o,s){this.searcherTypes=void 0,this.maxQueryLength=void 0,this.sortOrder=void 0,this.normalizerConfig=void 0,this.fuzzySearchConfig=void 0,this.substringSearchConfig=void 0,this.searcherTypes=e,this.maxQueryLength=t,this.sortOrder=r,this.normalizerConfig=i,this.fuzzySearchConfig=o,this.substringSearchConfig=s}static createDefaultConfig(){let e=[y.Fuzzy,y.Substring,y.Prefix],t=X.QualityAndMatchedString,r=ge.createDefaultConfig(),i=ut.createDefaultConfig(),o=ht.createDefaultConfig();return new n(e,150,t,r,i,o)}},Se=class{static createSearcher(e){let t=be.createSearcher(e),r=be.createSearcher(e),i=new $e(e.maxQueryLength,t,r);return i=new Oe(i),i}static createDefaultSearcher(){let e=dt.createDefaultConfig();return this.createSearcher(e)}};function ie(n,e){if(n.length===0)return null;let t=[...n].sort((c,l)=>c.markerViewportHalfOpen1Based.lo-l.markerViewportHalfOpen1Based.lo),r=t[0];if(r===void 0)return null;let i=r.markerViewportHalfOpen1Based.lo,o=t.find(c=>c.markerViewportHalfOpen1Based.lo<=e&&e<c.markerViewportHalfOpen1Based.hiExclusive);if(o)return o.commentrayLine;if(e<i)return r.commentrayLine;let s=r,a=-1/0;for(let c of t){let l=c.markerViewportHalfOpen1Based.lo;l<=e&&l>a&&(s=c,a=l)}return s.commentrayLine}function mt(n,e){if(n.length===0)return null;let t=[...n].sort((o,s)=>o.commentrayLine-s.commentrayLine),r=t[0];if(r===void 0)return null;let i=r;for(let o of t)o.commentrayLine<=e&&(i=o);return i.markerViewportHalfOpen1Based.lo-1}function ft(n,e,t,r,i){let o=Math.max(0,e-t),s=Math.max(0,r-i);return o<=0?0:Math.min(1,Math.max(0,n/o))*s}function oe(n,e,t,r=5){let i=e+r,o=e+t-r;return n<i?{y:i-e,clipped:"above"}:n>o?{y:o-e,clipped:"below"}:{y:n-e,clipped:"none"}}function Zn(n,e,t,r,i={}){let{tension:o=.38,clipStart:s="none",clipEnd:a="none"}=i,l=Math.min(.66,o+.24),u=s==="none"?o:l,h=a==="none"?o:l,d=t-n;return[{x:n,y:e},{x:n+d*u,y:e},{x:t-d*h,y:r},{x:t,y:r}]}function gt(n,e,t,r){return`M ${R(n.x)} ${R(n.y)} C ${R(e.x)} ${R(e.y)} ${R(t.x)} ${R(t.y)} ${R(r.x)} ${R(r.y)}`}function er(n,e,t,r,i){let o=j(n,e,i),s=j(e,t,i),a=j(t,r,i),c=j(o,s,i),l=j(s,a,i),u=j(c,l,i);return[[n,o,c,u],[u,l,a,r]]}function j(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function yt(n,e,t,r,i={}){let{tension:o=.38,clipStart:s="none",clipEnd:a="none",splitT:c=.66}=i,l=Zn(n,e,t,r,{tension:o,clipStart:s,clipEnd:a}),[u,h,d,f]=l;if(!(s!=="none"||a!=="none"))return{solid:gt(u,h,d,f)};let[g,p]=er(u,h,d,f,c),[S,E,P,k]=g,[C,T,L,G]=p;return{solid:gt(S,E,P,k),dotted:gt(C,T,L,G)}}function R(n){return n.toFixed(2)}function we(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function Ut(n){let e=new Map;for(let t of we(n))e.has(t.id)||e.set(t.id,t);return we([...e.values()])}function _t(n){return[...n].sort((e,t)=>e.commentrayLine!==t.commentrayLine?e.commentrayLine-t.commentrayLine:e.sourceStart-t.sourceStart)}function Qt(n,e){let t=_t([...n]),r=t.findIndex(i=>i.id===e.id);if(!(r<0))return t[r+1]}function jt(n,e){if(n.length===0)return null;let t=ie(n,e);return t===null?null:n.find(i=>i.commentrayLine===t)?.id??null}function Yt(n,e){if(n.length===0)return null;let t=_t([...n]),r=t[0];if(r===void 0)return null;let i=r;for(let o of t)o.commentrayLine<=e&&(i=o);return i.id}function bt(n){return Math.max(0,n-1)}var St='.commentray-page-break[data-commentray-page-break="true"]';function Te(n,e){return(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0}function tr(n,e,t){return Array.from(n.querySelectorAll(St)).filter(r=>Te(e,r)&&(t===null||Te(r,t)))}var Gt=.5;function nr(n){let e=n.closest(St);return!!(e&&!n.isSameNode(e))}function pt(n,e,t){let r=e.getBoundingClientRect().top+2;for(let i of Array.from(n.querySelectorAll("*"))){if(!(i instanceof HTMLElement)||t!==null&&(i===t||!Te(i,t))||!Te(e,i)||nr(i)||i.matches(St))continue;let o=i.getBoundingClientRect();o.width<Gt||o.height<Gt||(r=Math.max(r,o.bottom))}return r}function wt(n,e,t){let r=tr(n,e,t),i=e.getBoundingClientRect().top+2,o=e;for(let s of r)i=Math.max(i,pt(n,o,s)),o=s;return t?i=Math.max(i,pt(n,o,t)):i=Math.max(i,pt(n,o,null)),i}function Vt(n,e){let t=0;for(let{line0:r,top:i}of n)i<=e+1+.001&&(t=Math.max(t,r));return t}function D(n){let e=n.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function Kt(n,e){function t(r){let i=n.getAttribute(r);return i!==null&&i.trim()!==""?i:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function ve(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Jt(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return ve(n);try{let r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`(${r.join("|")})`,"gi");return n.split(i).map((s,a)=>a%2===1?`<mark class="search-hit">${ve(s)}</mark>`:ve(s)).join("")}catch{return ve(n)}}function Me(n,e){let t=e.map(c=>c.trim()).filter(Boolean);if(t.length===0)return[];let r=n.toLowerCase(),i=t.map(c=>c.toLowerCase()),o=[],s=0,a=0;for(;s<n.length&&a<400;){let c=s,l=-1,u=!0;for(let h of i){if(h.length===0)continue;let d=r.indexOf(h,c);if(d<0){u=!1;break}l<0&&(l=d),c=d+h.length}if(!u||l<0)break;o.push({start:l,end:c}),a++,s=l+1}return o}function Xt(n,e){let t=Math.max(0,Math.min(e,n.length)),r=0;for(let i=0;i<t;i++)n[i]===`
2
- `&&r++;return r}function Zt(n,e){let t=n.split(`
3
- `);return e<0||e>=t.length?"":t[e]??""}function se(n){return n.trim().split(/\s+/).filter(Boolean)}function en(n,e){let t=se(e);return t.length===0?[...n]:n.filter(r=>{let i=r.sourcePath.replace(/\\/g,"/");return Me(i,t).length>0})}function tn(n){let e=new Set,t=new Set,r=[],i=0;for(let o of n){let s=o.sourcePath.trim(),a=o.commentrayPath.trim();if(s.length>0){let c=`${s}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:i++,text:s,spPath:o.sourcePath,crPath:o.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:i++,text:a,spPath:o.sourcePath,crPath:o.commentrayPath}))}return r}var rr=80;function nn(n,e=rr){let t=new Map;for(let o of n){let s=o.sourcePath.trim();if(s.length===0)continue;let a=t.get(s),c={sourcePath:o.sourcePath.trim(),commentrayPath:o.commentrayPath.trim()};if(!a){t.set(s,c);continue}c.commentrayPath.localeCompare(a.commentrayPath)<0&&t.set(s,c)}let r=t.size;return{rows:[...t.values()].sort((o,s)=>o.sourcePath.localeCompare(s.sourcePath)).slice(0,e),totalUnique:r}}function w(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function Ee(n){let e=n.indexOf("/browse/");if(e>=0){let r=n.slice(0,e).replace(/\/+$/,"");return r===""?"/":r}let t=n.replace(/\/[^/]*$/,"");return t===""||t==="/"?"/":t.replace(/\/+$/,"")||"/"}var Tt=/^(?:\.\/)?browse\/([^/?#]+\.html)$/i,vt=/^(?:\.\/)?browse\/(.+)\/index\.html$/i;function Le(n){let e=n.trim();return Tt.test(e)||vt.test(e)}function q(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let i=Ee(e),o=Tt.exec(r);if(o?.[1]){let a=i==="/"?`/browse/${o[1]}`:`${i}/browse/${o[1]}`;return`${t}${a}`}let s=vt.exec(r);if(s?.[1]){let a=s[1],c=i==="/"?`/browse/${a}/index.html`:`${i}/browse/${a}/index.html`;return`${t}${c}`}return new URL(r,`${t}${e}`).href}function rn(n,e,t){let r=n.trim();if(r.length===0)return"";let i=Tt.exec(r);if(i?.[1])return`./browse/${i[1]}`;let o=vt.exec(r);return o?.[1]?`./browse/${o[1]}/index.html`:q(r,e,t)}function Mt(n,e,t){let r=w(e),i=w(t);if(r.length>0){let o=n.find(s=>w(s.commentrayPath)===r);if(o)return o}if(i.length>0){let o=n.find(s=>w(s.sourcePath)===i);if(o)return o}}function Et(n,e,t){return w(n.sourcePath)===w(e)&&w(n.commentrayPath)===w(t)}var xt="commentray.codeCommentrayStatic.colorTheme",Lt=["system","light","dark"];function on(n){let e=Lt.indexOf(n),t=(e>=0?e+1:0)%Lt.length;return Lt[t]??"system"}function xe(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function ir(n){let e=globalThis.document;if(!e)return;let t=e.getElementById("commentray-hljs-light"),r=e.getElementById("commentray-hljs-dark");if(!(!(t instanceof HTMLLinkElement)||!(r instanceof HTMLLinkElement))){if(n==="light"){t.disabled=!1,t.removeAttribute("media"),r.disabled=!0,r.setAttribute("media","(prefers-color-scheme: dark)");return}if(n==="dark"){r.disabled=!1,r.removeAttribute("media"),t.disabled=!0,t.setAttribute("media","(prefers-color-scheme: light)");return}t.disabled=!1,r.disabled=!1,t.media="(prefers-color-scheme: light)",r.media="(prefers-color-scheme: dark)"}}function kt(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,ir(n))}function ke(n,e,t){return Math.max(e,Math.min(t,n))}function sn(n,e){let t=e.getBoundingClientRect(),r=globalThis.innerWidth,i=globalThis.innerHeight,o=n.getBoundingClientRect(),s=o.width>0?o.width:340,a=o.height>0?o.height:160,c=8,l=t.bottom+12+a<=i-c,u=l?Math.max(c,t.bottom+12):Math.max(c,t.top-a-12),h=ke(t.left,c,r-s-c);n.style.top=`${String(Math.round(u))}px`,n.style.left=`${String(Math.round(h))}px`,n.dataset.side=l?"below":"above";let d=ke(t.left+t.width/2-h-8,10,s-22);n.style.setProperty("--pointer-left",`${String(Math.round(d))}px`)}function an(n,e,t){if(e.replaceChildren(),t.length===0)return;let r=n.getBoundingClientRect(),i=r.left+r.width/2,o=r.top+r.height/2,s=12,a=8,c=12,l=n.dataset.side,u=Number.parseFloat(n.style.getPropertyValue("--pointer-left")),h=Number.isFinite(u)?r.left+u+8:i,d=l==="below"?r.top-a:l==="above"?r.bottom+a:o;for(let[f,m]of t.entries()){let g=m.getBoundingClientRect(),p=g.left+g.width/2,S=g.top+g.height/2,E=p-i,P=S-o,k=Math.abs(E)>=Math.abs(P),C=f-(t.length-1)/2,T,L;t.length===1&&(l==="below"||l==="above")?(T=h,L=d):k?(T=E>=0?r.right+a:r.left-a,L=ke(S+C*c,r.top+s,r.bottom-s)):(L=P>=0?r.bottom+a:r.top-a,T=ke(p+C*c,r.left+s,r.right-s));let G=p-T,le=S-L,U=Math.hypot(G,le);if(!Number.isFinite(U)||U<12)continue;let A=document.createElement("span");A.className="commentray-wide-intro-arrow",A.style.left=`${String(Math.round(T))}px`,A.style.top=`${String(Math.round(L))}px`,A.style.width=`${String(Math.round(U))}px`,A.style.setProperty("--wide-intro-arrow-angle",`${String(Math.atan2(le,G))}rad`);let V=document.createElement("span");V.className="commentray-wide-intro-arrow-head",A.appendChild(V),e.appendChild(A)}}function Ht(n,e){let t=e?"#mobile-pane-flip":"#shell",r=n.id.trim().length>0&&typeof globalThis.CSS?.escape=="function"?`#${globalThis.CSS.escape(n.id)}`:"#shell",i=t==="#shell"?r:t;return[{targetSelectors:e?[i]:["#code-pane","#doc-pane"],title:"Welcome",body:"Welcome to commentray, a system to create and view commentaries next to the source tree. Angles are different aspects of these commentaries, so switch between them and keep scrolling while both panes stay aligned."},{targetSelectors:e?[i]:["#code-pane","#doc-pane"],title:"Two views",body:e?"You are in narrow view now. Use the pane flip to switch code and commentary. Wide view shows both panes side by side.":"You are in wide view now. It shows code and commentary side by side. Narrow view uses one pane and a flip control."},{targetSelectors:e?["#mobile-pane-flip","#doc-pane"]:["#code-pane","#doc-pane"],title:e?"Scroll and toggle":"Scroll both panes",body:e?"Try scrolling commentary, then use the pane flip to switch to source and keep exploring.":"Try scrolling in either pane. Source and commentary stay aligned while you read side by side."},{targetSelector:"#search-q",title:"Search quickly",body:"Use this search input to jump to documented source lines and markdown snippets."},{targetSelector:"#angle-select",title:"Angle switch",body:"Change the Commentray angle to view a different narrative for this same source file."},{targetSelector:"#source-markdown-pane-flip",title:"Source view mode",body:"Toggle between raw source and rendered markdown in the source pane."},{targetSelector:"#wrap-lines",title:"Readability controls",body:"Wrap lines to reduce horizontal scrolling in both source and commentary panes.",fallbackActionLabel:"Switch to markdown source",fallbackAction:()=>{let o=document.getElementById("source-markdown-pane-flip");o instanceof HTMLButtonElement&&o.click()}},{targetSelector:"#commentray-theme-trigger",title:"Appearance",body:"Change theme mode from this trigger (menu on left-click, quick cycle on right-click)."},{targetSelector:"#commentray-share-link",title:"Share this view",body:"Use this link button to copy a shareable permalink to the exact page and state you are viewing."},{targetSelector:"#commentray-help-tour",title:"Need a refresher?",body:"You can always go back to this tutorial via the help button."}]}function or(n,e){let t=n[e];if(!t)return[];let r=Array.isArray(t.targetSelectors)&&t.targetSelectors.length>0?t.targetSelectors:t.targetSelector?[t.targetSelector]:[],i=[],o=new Set;for(let s of r){let a=document.querySelector(s);!(a instanceof HTMLElement)||o.has(a)||(o.add(a),i.push(a))}return i}function sr(n){if(n.hidden)return!1;let e=globalThis.getComputedStyle(n);if(e.display==="none"||e.visibility==="hidden")return!1;let t=n.getBoundingClientRect();return t.width>0&&t.height>0}function He(n,e){return or(n,e).filter(t=>sr(t))}function cn(){for(let t of Array.from(document.querySelectorAll(".commentray-wide-intro-target")))t instanceof HTMLElement&&t.classList.remove("commentray-wide-intro-target");let n=document.getElementById("commentray-wide-intro");n instanceof HTMLElement&&n.remove();let e=document.getElementById("commentray-wide-intro-arrows");e instanceof HTMLElement&&e.remove()}function ln(){let n=document.createElement("div");n.id="commentray-wide-intro-arrows",n.setAttribute("aria-hidden","true"),document.body.appendChild(n);let e=document.createElement("section");e.id="commentray-wide-intro",e.setAttribute("role","dialog"),e.setAttribute("aria-live","polite"),e.innerHTML=`
1
+ "use strict";(()=>{var W=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,o=e.length;r<o;r++)t[r]=e[r];return t}},ke=class{static getHashCode(e){let t=5381,r=t;for(let o=0,i=e.length;o<i&&e[o]!="\0"&&(t=(t<<5)+t^e.charCodeAt(o),o!==i-1&&e[o+1]!=="\0");o+=2)r=(r<<5)+r^e.charCodeAt(o+1);return t+1566083941*r|0}},v=class{constructor(e){this.entries=void 0,this.entries=e!==void 0?e:new Map}add(e,t){if(this.entries.has(e))throw new Error(`A meta entry with key ${e} is already present.`);this.entries.set(e,t)}get(e){return this.entries.get(e)}get allEntries(){return this.entries}toJSON(){return{entries:Object.fromEntries(this.entries)}}},le=class{static mergeMeta(e){if(e.length===0)return new v;if(e.length===1)return e[0];let t=new Map;for(let o of e)for(let[i,s]of o.allEntries){let a=t.get(i);a===void 0?t.set(i,[s]):a.push(s)}let r=new Map;for(let[o,i]of t)if(i.length!==1){if(i.every(s=>typeof s=="number")){let s=i.reduce((a,c)=>a+c,0);r.set(o,s);continue}for(let s=0;s<i.length;s++)r.set(`${o}_${s}`,i[s])}else r.set(o,i[0]);return new v(r)}},He=class{static isSurrogate(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}static isAlphanumeric(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122}static isLowerAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122}},xe=class{constructor(e,t){this.usableSearchers=void 0,this.usableSearchers=new Map;for(let r of t)e.includes(r.type)&&this.usableSearchers.set(r.type,r)}has(e){return this.usableSearchers.has(e)}minQuality(e){return this.usableSearchers.get(e).minQuality}spec(e){return this.usableSearchers.get(e)}},V=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},w,ue;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(w||(w={}));var de=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},he=class extends de{constructor(e){super(w.Fuzzy,e)}},Z=class extends de{constructor(e){super(w.Substring,e)}},ee=class extends de{constructor(e){super(w.Prefix,e)}},U=class{constructor(e,t=10,r=[new he(.3),new Z(0),new ee(0)]){this.string=void 0,this.topN=void 0,this.searchers=void 0,this.string=e,this.topN=Math.max(0,t),this.searchers=r}},it=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},st=class{static mergeResults(e,t){let r=e.query,o=this.mergeMatches(e.matches,t.matches,r.topN),i=le.mergeMeta([e.meta,t.meta]);return new V(o,r,i)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let o=[...e,...t];return o.sort((i,s)=>i.quality>s.quality?-1:i.quality<s.quality?1:0),o.length<=r?o:o.slice(0,r)}},at=class{constructor(e,t,r){this.maxQueryLength=void 0,this.mainSearcher=void 0,this.secondarySearcher=void 0,this.maxQueryLength=e,this.mainSearcher=t,this.secondarySearcher=r}indexEntities(e,t,r){return this.secondarySearcher.indexEntities([],t,r),this.mainSearcher.indexEntities(e,t,r)}getMatches(e){return e.string?(e.string.length>this.maxQueryLength&&(e=new U(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),st.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new V([],e,new v)}tryGetTerms(e){let t=this.mainSearcher.tryGetTerms(e);return t!==null?t:this.secondarySearcher.tryGetTerms(e)}getTerms(){return this.mainSearcher.getTerms().concat(this.secondarySearcher.getTerms())}tryGetEntity(e){var t,r;return(t=(r=this.mainSearcher.tryGetEntity(e))!=null?r:this.secondarySearcher.tryGetEntity(e))!=null?t:null}getEntities(){return this.mainSearcher.getEntities().concat(this.secondarySearcher.getEntities())}removeEntities(e){let t=[];for(let o=0,i=e.length;o<i;o++)(this.mainSearcher.removeEntity(e[o])||this.secondarySearcher.removeEntity(e[o]))&&t.push(e[o]);let r=new v;return new it(t,r)}upsertEntities(e,t,r){let o=[],i=[];for(let s=0,a=e.length;s<a;s++){let c=e[s],l=t(c);this.tryUpdate(c,l,r)||(o.push(l),i.push(c))}return this.removeEntities(o),i.length>0?this.reindexSecondarySearcher(i,t,r):new v}reindexSecondarySearcher(e,t,r){let o=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(o,t,r)}tryUpdate(e,t,r){return this.tryUpdateSearcher(e,t,r,this.mainSearcher)||this.tryUpdateSearcher(e,t,r,this.secondarySearcher)}tryUpdateSearcher(e,t,r,o){let i=o.tryGetTerms(t);if(i===null)return!1;if(this.termsAreEqual(i,r(e))){if(!o.replaceEntity(t,e,t))throw new Error(`Entity with id ${t} was not present.`);return!0}return!1}termsAreEqual(e,t){return e===t||e!=null&&t!=null&&e.length===t.length&&e.every((r,o)=>r===t[o])}removeEntity(e){return this.mainSearcher.removeEntity(e)||this.secondarySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.mainSearcher.replaceEntity(e,t,r)||this.secondarySearcher.replaceEntity(e,t,r)}save(e){this.mainSearcher.save(e),this.secondarySearcher.save(e)}load(e){this.mainSearcher.load(e),this.secondarySearcher.load(e)}},ct=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),o=Math.round(performance.now()-t);return r.meta.add("removalDuration",o),r}upsertEntities(e,t,r){let o=performance.now(),i=this.dynamicSearcher.upsertEntities(e,t,r),s=Math.round(performance.now()-o);return i.add("upsertDuration",s),i}indexEntities(e,t,r){let o=performance.now(),i=this.dynamicSearcher.indexEntities(e,t,r),s=Math.round(performance.now()-o);return i.add("indexingDurationTotal",s),i}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),o=Math.round(performance.now()-t);return r.meta.add("queryDuration",o),r}tryGetEntity(e){return this.dynamicSearcher.tryGetEntity(e)}getEntities(){return this.dynamicSearcher.getEntities()}tryGetTerms(e){return this.dynamicSearcher.tryGetTerms(e)}getTerms(){return this.dynamicSearcher.getTerms()}removeEntity(e){return this.dynamicSearcher.removeEntity(e)}replaceEntity(e,t,r){return this.dynamicSearcher.replaceEntity(e,t,r)}save(e){this.dynamicSearcher.save(e)}load(e){this.dynamicSearcher.load(e)}},lt=class{constructor(e,t,r){this.entity=void 0,this.quality=void 0,this.matchedString=void 0,this.entity=e,this.quality=t,this.matchedString=r}},ut=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},me=class{constructor(e,t=0,r){this.string=void 0,this.minQuality=void 0,this.searcherType=void 0,this.string=e,this.minQuality=Math.max(0,Math.min(1,t)),this.searcherType=r}},dt=class{constructor(e,t){this.stringSearcher=void 0,this.searcherTypes=void 0,this.entities=void 0,this.idToIndex=void 0,this.terms=void 0,this.termIndexToEntityIndex=void 0,this.entityIndexToFirstTermIndex=void 0,this.searchersAndQualityOffsets=[{searcherType:w.Prefix,qualityOffset:2},{searcherType:w.Substring,qualityOffset:1},{searcherType:w.Fuzzy,qualityOffset:0}],this.stringSearcher=e,this.searcherTypes=t,this.entities=[],this.idToIndex=new Map,this.terms=[],this.termIndexToEntityIndex=new Int32Array(0),this.entityIndexToFirstTermIndex=new Int32Array(0)}indexEntities(e,t,r){this.entities=[...e],this.idToIndex=new Map,this.terms=[];let o=[],i=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);i.push(this.terms.length),this.terms.push(...l),o.push(...l.map(()=>a))}this.termIndexToEntityIndex=W.ToInt32Array(o),this.entityIndexToFirstTermIndex=W.ToInt32Array(i);let s=this.stringSearcher.index(this.terms);return s.add("numberOfEntities",this.entities.length),s.add("numberOfTerms",this.terms.length),s}getMatches(e){let t=new ut(e),r=new xe(this.searcherTypes,e.searchers);for(let{searcherType:i,qualityOffset:s}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(i)&&this.addMatchesFromSearcher(t,r.spec(i),s)}let o=le.mergeMeta(t.meta);return new V(t.matches,e,o)}addMatchesFromSearcher(e,t,r){let o=Math.max(0,t.minQuality-r);if(o>1)return;let i=new me(e.query.string,o,t.type),s=this.stringSearcher.getMatches(i);this.addMatchesFromResult(e,s,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let o=0,i=t.matches.length;o<i;o++){let s=t.matches[o],a=this.termIndexToEntityIndex[s.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new lt(this.entities[a],s.quality+r,this.terms[s.index])),e.matches.length===e.query.topN))break}}tryGetEntity(e){let t=this.idToIndex.get(e);return t===void 0?null:this.entities[t]}getEntities(){return this.entities.filter(e=>e!==null)}tryGetTerms(e){let t=this.idToIndex.get(e);return t===void 0?null:this.terms.slice(this.entityIndexToFirstTermIndex[t],t===this.entities.length-1?this.terms.length:this.entityIndexToFirstTermIndex[t+1])}getTerms(){let e=[];for(let t=0,r=this.termIndexToEntityIndex.length;t<r;t++)this.entities[this.termIndexToEntityIndex[t]]!==null&&e.push(this.terms[t]);return e}removeEntity(e){let t=this.idToIndex.get(e);return t!==void 0&&(this.entities[t]=null,this.idToIndex.delete(e),!0)}replaceEntity(e,t,r){let o=this.idToIndex.get(e);return o!==void 0&&(this.entities[o]=t,this.idToIndex.delete(e),this.idToIndex.set(r,o),!0)}save(e){e.add(this.entities),e.add(this.idToIndex),e.add(this.terms),e.add(this.termIndexToEntityIndex),e.add(this.entityIndexToFirstTermIndex),this.stringSearcher.save(e)}load(e){this.entities=e.get(),this.idToIndex=e.get(),this.terms=e.get(),this.termIndexToEntityIndex=e.get(),this.entityIndexToFirstTermIndex=e.get(),this.stringSearcher.load(e)}},q=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},ht=class{constructor(e,t){this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.numberOfSurrogateCharacters=0,this.treatCharacterAsSpace=e,this.allowCharacter=t}normalize(e){let t=new Array(e.length),r=0,o=!1,i=!1;for(let s=0,a=e.length;s<a;s++){let c=this.getNormalizedCharacter(e[s]);c!==""&&(c===" "?o=!0:(o&&i&&(t[r++]=" "),t[r++]=c,i=!0,o=!1))}return i?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!He.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(o=>this.normalize(o)),r=new v;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new q(t,r)}},mt=class{constructor(e){this.normalizationFunction=void 0,this.normalizationFunction=e}normalize(e){return this.normalizationFunction(e)}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new q(t,new v)}},ft=class{constructor(e){this.normalizers=void 0,this.normalizers=e}normalize(e){for(let t=0,r=this.normalizers.length;t<r;t++)e=this.normalizers[t].normalize(e);return e}normalizeBulk(e){let t=new v;for(let r=0,o=this.normalizers.length;r<o;r++){let i=this.normalizers[r].normalizeBulk(e);e=i.strings;for(let s of i.meta.allEntries)t.add(s[0],s[1])}return new q(e,t)}},pt=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new q(t,new v)}},gt=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let o=new Map;for(let[i,s]of r)for(let a of s){let c=t(a);o.set(c,i)}this.replacements.push(o)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let o=0,i=e.length;o<i;o++)for(let s of this.replacements){let a=s.get(e[o]);if(a!==void 0){t[r++]=a;break}t[r++]=e[o]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new q(t,new v)}},yt=class{static create(e){let t=new pt,r=new gt(e.replacements,s=>s.toLowerCase().normalize("NFKC")),o=new mt(s=>s.normalize("NFKD")),i=new ht(e.treatCharacterAsSpace,e.allowCharacter);return new ft([t,r,o,i])}},fe=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},P=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},bt=class{constructor(e){this.stringSearcher=void 0,this.distinctMapping=void 0,this.sortMapping=void 0,this.stringSearcher=e,this.distinctMapping=new Int32Array(0),this.sortMapping=new Int32Array(0)}index(e){let t=e.map((c,l)=>({term:c,index:l}));t.sort((c,l)=>c.term<l.term?-1:c.term>l.term?1:0),this.sortMapping=new Int32Array(t.length);for(let c=0,l=t.length;c<l;c++)this.sortMapping[c]=t[c].index;let r=[],o=[],i=0,s=null;for(let c=0,l=t.length;c<l;c++){let u=t[c].term;u!=s&&(r[i]=u,o[i]=c,i++),s=u}o[i++]=t.length,this.distinctMapping=W.ToInt32Array(o);let a=this.stringSearcher.index(r);return a.add("numberOfDistinctTerms",r.length),a}getMatches(e){let t=this.stringSearcher.getMatches(e),r=new Array(t.matches.length),o=0;return t.matches.forEach(i=>{let s=this.distinctMapping[i.index+1];for(let a=this.distinctMapping[i.index];a<s;a++)r[o++]=new fe(this.sortMapping[a],i.quality)}),new P(r,e,t.meta)}save(e){e.add(this.distinctMapping),e.add(this.sortMapping),this.stringSearcher.save(e)}load(e){this.distinctMapping=e.get(),this.sortMapping=e.get(),this.stringSearcher.load(e)}},St=class{constructor(e,t){this.entitySearcher=void 0,this.searcherTypes=void 0,this.entitySearcher=e,this.searcherTypes=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=new xe(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(w.Prefix)&&t.minQuality(w.Prefix)<2.2){let r=new U(e.string,e.topN,[new ee(2.3)]),o=this.entitySearcher.getMatches(r);if(o.matches.length==e.topN)return new V(o.matches,e,o.meta)}if(e.string.length<=3&&!t.has(w.Prefix)&&t.has(w.Substring)&&t.minQuality(w.Substring)<1.2){let r=new U(e.string,e.topN,[new Z(1.3)]),o=this.entitySearcher.getMatches(r);if(o.matches.length==e.topN)return new V(o.matches,e,o.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},Ce=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=W.ToInt32Array(this.ids),this.frequencies=W.ToInt32Array(this.frequencies)}get length(){return this.ids.length}save(e){e.add(this.ids),e.add(this.frequencies)}load(e){this.ids=e.get(),this.frequencies=e.get()}},ce=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let o=this.ngramToTermIds.get(e);o||(o=new Ce,this.ngramToTermIds.set(e,o)),o.addId(t,r)}seal(){for(let e of this.ngramToTermIds.values())e.seal()}getIds(e){return this.ngramToTermIds.get(e)}get size(){return this.ngramToTermIds.size}save(e){e.add(this.ngramToTermIds.size);for(let[t,r]of this.ngramToTermIds)e.add(t),r.save(e)}load(e){let t=e.get();for(let r=0;r<t;r++){let o=e.get(),i=new Ce;i.load(e),this.ngramToTermIds.set(o,i)}}},Tt=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},wt=class{constructor(e){this.ngramComputer=void 0,this.invertedIndex=void 0,this.numberOfNgrams=void 0,this.commonNgramCounts=void 0,this.ngramComputer=e,this.invertedIndex=new ce,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new ce,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let s=0,a=e.length;s<a;s++){let c=e[s];if(!this.isValidTerm(c)){this.numberOfNgrams[s]=0,r++;continue}let l=this.ngramComputer.computeNgrams(c);this.numberOfNgrams[s]=l.length;let u=this.getNgramsToFrequency(l);for(let[d,h]of u)this.invertedIndex.add(d,s,h)}this.invertedIndex.seal();let o=Math.round(performance.now()-t),i=new v;return i.add("numberOfInvalidTerms",r),i.add("indexingDurationFuzzySearcher",o),i}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new P([],e,new v);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),o=t.length;this.computeCommonNgramCounts(r);let i=this.getMatchesFromCommonNgrams(o,e.minQuality);return new P(i,e,new v)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let o=this.invertedIndex.getIds(t);if(o!=null)for(let i=0,s=o.length;i<s;i++)this.commonNgramCounts[o.ids[i]]+=Math.min(r,o.frequencies[i])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,o=e.length;r<o;r++){let i=e[r],s=t.get(i);t.set(i,s!==void 0?s+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let o=0,i=this.numberOfNgrams.length;o<i;o++){let s=Tt.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[o],this.commonNgramCounts[o]);s>t&&r.push(new fe(o,s))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new ce,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},vt=class{constructor(e,t){this.stringSearcher=void 0,this.penaltyFactor=void 0,this.hashCodes=void 0,this.stringSearcher=e,this.penaltyFactor=1-t,this.hashCodes=new Int32Array(0)}index(e){this.hashCodes=new Int32Array(e.length);for(let t=0,r=e.length;t<r;t++)this.hashCodes[t]=ke.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=ke.getHashCode(e.string),r=this.stringSearcher.getMatches(e),o=r.matches.map(i=>this.penalizeMatch(i,t)).filter(i=>i.quality>=e.minQuality);return new P(o,r.query,r.meta)}penalizeMatch(e,t){return e.quality*=this.hashCodes[e.index]===t?1:this.penaltyFactor,e}save(e){e.add(this.hashCodes),this.stringSearcher.save(e)}load(e){this.hashCodes=e.get(),this.stringSearcher.load(e)}},Et=class{constructor(e,t){this.ngramN=void 0,this.transformNgram=void 0,this.ngramN=e,this.transformNgram=t??(r=>r)}computeNgrams(e){if(e.length===0)return[];if(e.length<=this.ngramN){let r=this.transformNgram(e);return r?[r]:[]}let t=[];for(let r=0,o=this.maximumNumberOfNgrams(e);r<o;r++){let i=this.transformNgram(e.substring(r,r+this.ngramN));i&&t.push(i)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},Lt=class{constructor(e,t,r){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r}normalize(e){return e&&`${this.paddingLeft}${e.split(" ").join(this.paddingMiddle)}${this.paddingRight}`}normalizeBulk(e){let t=e.map(o=>this.normalize(o)),r=new v;return new q(t,r)}},Ae=class{};Ae.Value=new Map([["a",["\u1D8F","\u2C65","\u0251","\u1D00","\u0250","\u0252"]],["aa",["\xE5","\uA733"]],["ae",["\xE4","\xE6","\u1D01","\u1D2D","\u1D46","\u01FD","\u01E3","\u1D02"]],["ao",["\uA735"]],["au",["\uA737"]],["av",["\uA739","\uA73B"]],["ay",["\uA73D"]],["b",["\u0180","\u0253","\u0183","\u1D6C","\u1D80","\u0299"]],["c",["\u023C","\u0188","\u0255","\u1D04","\uA73F","\u2184"]],["d",["\u0111","\xF0","\u0256","\u0257","\u018C","\u1D6D","\u1D81","\u1D91","\u0221","\u1D05","\uA77A"]],["db",["\u0238"]],["e",["\u1D92","\u0247","\u2C78","\u1D07","\u0259","\u01DD","\u025B"]],["eo",["\u1D14"]],["f",["\u0192","\u1D6E","\u1D82","\uA730","\uA77C"]],["g",["\u01E5","\u0260","\u1D83","\u0262","\u021D","\u014B","\uA7A1","\u1D79","\uA77F"]],["h",["\u0127","\u2C68","\u0266","\u029C","\u0303","\u0267","\u2C76","\u0265"]],["hv",["\u0195"]],["i",["\u0268","\u1D7B","\u1D96","\u0131","\u026A","\u0269"]],["j",["\u0249","\u0237","\u029D","\u025F","\u0284","\u1D0A"]],["k",["\u0199","\u2C6A","\u1D84","\uA741","\u1D0B","\uA743","\uA745","\uA7A3"]],["l",["\u0142","\u019A","\u2C61","\u026B","\u026C","\u1D85","\u026D","\u0234","\u029F","\uA749","\uA781","\uA747"]],["m",["\u1D6F","\u1D86","\u0271","\u1D0D","\u026F"]],["n",["\u0272","\u019E","\u1D70","\u1D87","\u0273","\u0235","\u0274","\uA791","\uA7A5"]],["o",["\xF8","\u01FF","\u0275","\u0254","\u2C7A","\u1D0F","\uA74B","\uA74D"]],["oe",["\xF6","\u0153"]],["oi",["\u01A3"]],["oo",["\uA74F"]],["ou",["\u0223"]],["p",["\u1D7D","\u01A5","\u1D71","\u1D88","\u1D18","\u01BF","\uA751","\uA753","\uA755"]],["q",["\u024B","\u02A0","\uA757","\uA759"]],["qp",["\u0239"]],["r",["\u024D","\u027D","\uA75B","\u1D72","\u1D89","\u027C","\u027E","\u1D73","\u0280","\u0279","\u0281","\uA7A7","\uA783"]],["s",["\u1D74","\u1D8A","\u0282","\u023F","\uA731","\u0283","\uA7A9","\uA785","\u017F"]],["ss",["\xDF"]],["t",["\u0167","\u2C66","\u01AD","\u0288","\u1D75","\u01AB","\u0236","\u1D1B","\uA787"]],["th",["\xFE"]],["tz",["\uA729"]],["u",["\u0289","\u028A","\u1D7E","\u1D1C","\u1D99"]],["ue",["\xFC","\u1D6B"]],["v",["\u028B","\u1D8C","\u2C71","\u2C74","\u1D20","\u028C","\uA75F"]],["vy",["\uA761"]],["w",["\u2C73","\u1D21","\u028D"]],["x",["\u1D8D"]],["y",["\u024F","\u01B4","\u028F","\u1EFF"]],["z",["\u01B6","\u0225","\u2C6C","\u1D76","\u1D8E","\u0290","\u0291","\u0240","\u1D22","\u0292","\u01B9","\uA763"]]]);var Be=class n{constructor(e,t,r){this.replacements=void 0,this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.replacements=e,this.treatCharacterAsSpace=t,this.allowCharacter=r}static createDefaultConfig(){let e=new Set(["_","-","\u2013","/",","," "]);return new n([Ae.Value],t=>e.has(t),t=>He.isAlphanumeric(t))}},Ie=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),o=Math.round(performance.now()-t),i=this.stringSearcher.index(r.strings);i.add(this.normalizationDurationMetaKey,o);for(let s of r.meta.allEntries)i.add(s[0],s[1]);return i}getMatches(e){let t=new me(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new P(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},Mt=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new P([],e,new v);let t=this.modifyQueryString(e.string),r=new me(t,e.minQuality,e.searcherType);return this.suffixArraySearcher.getMatches(r,e.string.length)}modifyQueryString(e){return`${this.suffixArraySearcher.separator}${e}`}save(e){this.suffixArraySearcher.save(e)}load(e){this.suffixArraySearcher.load(e)}},kt=class{constructor(e,t,r){this.prefixSearcher=void 0,this.substringSearcher=void 0,this.fuzzySearcher=void 0,this.prefixSearcher=e,this.substringSearcher=t,this.fuzzySearcher=r}index(e){let t=[];if(this.prefixSearcher&&!this.substringSearcher){let r=this.prefixSearcher.index(e);t.push(r)}if(this.substringSearcher){let r=this.substringSearcher.index(e);t.push(r)}if(this.fuzzySearcher){let r=this.fuzzySearcher.index(e);t.push(r)}return le.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case w.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case w.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case w.Fuzzy:if(!this.fuzzySearcher)throw new Error("No fuzzy searcher has been indexed.");return this.fuzzySearcher.getMatches(e);default:throw new Error(`Unknown searcher type: ${e.searcherType}`)}}save(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.save(e),this.substringSearcher&&this.substringSearcher.save(e),this.fuzzySearcher&&this.fuzzySearcher.save(e)}load(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.load(e),this.substringSearcher&&this.substringSearcher.load(e),this.fuzzySearcher&&this.fuzzySearcher.load(e)}};(function(n){n.QualityAndIndex="qualityAndIndex",n.QualityAndMatchedString="qualityAndMatchedString"})(ue||(ue={}));var Ht=class{constructor(e,t){this.sortOrder=void 0,this.entitySearcher=void 0,this.collator=new Intl.Collator(void 0,{numeric:!0}),this.sortOrder=e,this.entitySearcher=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=this.entitySearcher.getMatches(e);switch(this.sortOrder){case ue.QualityAndIndex:return t;case ue.QualityAndMatchedString:return this.sortMatchesByQualityAndMatchedString(t.matches),t;default:throw new Error(`Unsupported sort order: ${this.sortOrder}`)}}sortMatchesByQualityAndMatchedString(e){e.sort((t,r)=>t.quality>r.quality?-1:t.quality<r.quality?1:this.collator.compare(t.matchedString,r.matchedString))}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}save(e){this.entitySearcher.save(e)}load(e){this.entitySearcher.load(e)}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}},xt=class{constructor(e){this.stringSearcher=void 0,this.stringSearcher=e}index(e){return this.stringSearcher.index(e)}getMatches(e){let t=this.stringSearcher.getMatches(e);return t.matches.sort(this.compareMatchesByQualityAndIndex),t}compareMatchesByQualityAndIndex(e,t){return e.quality>t.quality?-1:e.quality<t.quality?1:e.index<t.index?-1:e.index>t.index?1:0}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},pe=class{static compareOrdinal(e,t,r,o,i){let s=Math.min(t+i,e.length),a=Math.min(o+i,r.length),c=t,l=o;for(;c<s&&l<a;){let h=e.charCodeAt(c),p=r.charCodeAt(l);if(h<p)return-1;if(h>p)return 1;c++,l++}let u=s-t,d=a-o;return u===d?0:u<d?-1:1}},Ct=class n{static create(e){if(e==null)throw new Error("Input string cannot be null.");let t=new n(e);return t.FormInitialChains(),t.BuildSufixArray(),t.sa}constructor(e){this.inputString=void 0,this.eoc=2147483647,this.sa=void 0,this.isa=void 0,this.chainHeadsDict=void 0,this.chainStack=[],this.subChains=[],this.nextRank=1,this.inputString=e;let t=e.length;this.sa=new Int32Array(t),this.isa=new Int32Array(t),this.chainHeadsDict=new Map}FormInitialChains(){this.FindInitialChains(),this.SortAndPushSubchains()}FindInitialChains(){for(let e=0;e<this.inputString.length;e++){let t=this.inputString.charCodeAt(e),r=this.chainHeadsDict.get(t);this.isa[e]=r!==void 0?r:this.eoc,this.chainHeadsDict.set(t,e)}for(let e of this.chainHeadsDict.values()){let t=new Pe(e,1);this.subChains.push(t)}}BuildSufixArray(){for(;this.chainStack.length>0;){let e=this.chainStack.pop();this.isa[e.head]===this.eoc?this.RankSuffix(e.head):this.RefineChainWithInductionSorting(e)}}RankSuffix(e){this.isa[e]=-this.nextRank,this.sa[this.nextRank-1]=e,this.nextRank++}RefineChainWithInductionSorting(e){let t=[];for(this.chainHeadsDict.clear(),this.subChains=[];e.head!==this.eoc;){let r=this.isa[e.head];if(e.head+e.length>this.inputString.length-1)this.RankSuffix(e.head);else if(this.isa[e.head+e.length]<0){let o=new At(e.head,-this.isa[e.head+e.length]);t.push(o)}else this.ExtendChain(e);e.head=r}this.SortAndPushSubchains(),this.SortAndRankNotedSuffixes(t)}ExtendChain(e){let t=this.inputString.charCodeAt(e.head+e.length);if(this.chainHeadsDict.has(t))this.isa[this.chainHeadsDict.get(t)]=e.head,this.isa[e.head]=this.eoc;else{this.isa[e.head]=this.eoc;let r=new Pe(e.head,e.length+1);this.subChains.push(r)}this.chainHeadsDict.set(t,e.head)}SortAndRankNotedSuffixes(e){e.sort((t,r)=>t.rank-r.rank);for(let t=0;t<e.length;t++)this.RankSuffix(e[t].head)}SortAndPushSubchains(){this.subChains.sort((e,t)=>{let r=Math.min(e.length,t.length);return pe.compareOrdinal(this.inputString,e.head,this.inputString,t.head,r)});for(let e=this.subChains.length-1;e>=0;e--)this.chainStack.push(this.subChains[e])}},At=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},Pe=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},Bt=class{constructor(e){this.separator=void 0,this.str=void 0,this.suffixArray=void 0,this.indexToTermIndex=void 0,this.termLengths=void 0,this.separator=e,this.str="",this.suffixArray=new Int32Array(0),this.indexToTermIndex=new Int32Array(0),this.termLengths=new Int32Array(0)}index(e){let t=performance.now();this.str=e.length>0?this.separator+e.join(this.separator)+this.separator:"",this.suffixArray=Ct.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let s=0;s<e.length;s++){this.termLengths[s]=e[s].length;for(let a=0;a<=e[s].length;a++)this.indexToTermIndex[r++]=s}this.indexToTermIndex[r++]=-1;let o=Math.round(performance.now()-t),i=new v;return i.add("indexingDurationSuffixArraySearcher",o),i}getMatches(e,t){if(!e.string)return new P([],e,new v);let[r,o]=this.GetPositionsInSuffixArray(e.string),i=new Int32Array(o-r),s=new Set,a=0;for(let u=r;u<o;u++){let d=this.indexToTermIndex[this.suffixArray[u]];s.has(d)||(s.add(d),i[a++]=d)}let c=[];t=t??e.string.length;let l=0;for(let u=0;u<a;u++)l=this.computeQuality(t,this.termLengths[i[u]]),l>e.minQuality&&c.push(new fe(i[u],l));return new P(c,e,new v)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,o=0;for(;t<r;)o=Math.floor((t+r)/2),pe.compareOrdinal(e,0,this.str,this.suffixArray[o],e.length)>0?t=o+1:r=o;let i=t;for(r=this.suffixArray.length;t<r;)o=Math.floor((t+r)/2),pe.compareOrdinal(e,0,this.str,this.suffixArray[o],e.length)==0?t=o+1:r=o;return[i,r]}save(e){e.add(this.str),e.add(this.suffixArray),e.add(this.indexToTermIndex),e.add(this.termLengths)}load(e){this.str=e.get(),this.suffixArray=e.get(),this.indexToTermIndex=e.get(),this.termLengths=e.get()}},Re=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),o=this.tryCreateSubstringSearcher(e),i=this.tryCreatePrefixSearcher(e,o),s=new kt(i,o,r);s=new bt(s),s=new xt(s),s=new Ie(s,t,"normalizationDurationDefault");let a=new dt(s,e.searcherTypes);return a=new St(a,e.searcherTypes),a=new Ht(e.sortOrder,a),a}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(o=>t.add(o)),e.fuzzySearchConfig.paddingRight.split("").forEach(o=>t.add(o)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(o=>t.add(o))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(o=>t.add(o));let r=new Be(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,o=>e.normalizerConfig.allowCharacter(o)&&!t.has(o));return yt.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(w.Fuzzy))return null;if(e.fuzzySearchConfig===void 0)throw new Error("Unable to create fuzzy searcher: No fuzzy search config provided.");return this.createFuzzySearcher(e.fuzzySearchConfig)}static createFuzzySearcher(e){let t=new Et(e.ngramN,e.transformNgram),r=new Lt(e.paddingLeft,e.paddingRight,e.paddingMiddle),o=new wt(t);return o=new vt(o,e.inequalityPenalty),o=new Ie(o,r,"normalizationDurationNgrams"),o}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(w.Substring))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create substring searcher: No substring search config provided.");return this.createSubstringSearcher(e.substringSearchConfig)}static createSubstringSearcher(e){return new Bt(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(w.Prefix))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create prefix searcher: No substring search config provided.");return this.createPrefixSearcher(e.substringSearchConfig,t)}static createPrefixSearcher(e,t){return t===null&&(t=this.createSubstringSearcher(e)),new Mt(t)}},It=class n{constructor(e,t,r,o,i,s){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.ngramN=void 0,this.transformNgram=void 0,this.inequalityPenalty=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r,this.ngramN=o,this.transformNgram=i,this.inequalityPenalty=s}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var Pt=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},Rt=class n{constructor(e,t,r,o,i,s){this.searcherTypes=void 0,this.maxQueryLength=void 0,this.sortOrder=void 0,this.normalizerConfig=void 0,this.fuzzySearchConfig=void 0,this.substringSearchConfig=void 0,this.searcherTypes=e,this.maxQueryLength=t,this.sortOrder=r,this.normalizerConfig=o,this.fuzzySearchConfig=i,this.substringSearchConfig=s}static createDefaultConfig(){let e=[w.Fuzzy,w.Substring,w.Prefix],t=ue.QualityAndMatchedString,r=Be.createDefaultConfig(),o=It.createDefaultConfig(),i=Pt.createDefaultConfig();return new n(e,150,t,r,o,i)}},De=class{static createSearcher(e){let t=Re.createSearcher(e),r=Re.createSearcher(e),o=new at(e.maxQueryLength,t,r);return o=new ct(o),o}static createDefaultSearcher(){let e=Rt.createDefaultConfig();return this.createSearcher(e)}};function te(n,e){if(n.length===0)return null;let t=[...n].sort((r,o)=>r.markerViewportHalfOpen1Based.lo-o.markerViewportHalfOpen1Based.lo);for(let r of t){let{lo:o,hiExclusive:i}=r.markerViewportHalfOpen1Based;if(o<=e&&e<i)return r}return null}function Dt(n,e){if(n.length===0)return!1;let t=1/0;for(let r of n)t=Math.min(t,r.markerViewportHalfOpen1Based.lo);return e<t}function Ft(n,e){if(n.length===0)return null;let t=[...n].sort((i,s)=>i.commentrayLine-s.commentrayLine),r=t[0];if(r===void 0)return null;let o=r;for(let i of t)i.commentrayLine<=e&&(o=i);return o}function Nt(n,e,t,r,o){let i=Math.max(0,e-t),s=Math.max(0,r-o);return i<=0?0:Math.min(1,Math.max(0,n/i))*s}function N(n,e,t,r=5){let o=e+r,i=e+t-r;return n<o?{y:o-e,clipped:"above"}:n>i?{y:i-e,clipped:"below"}:{y:n-e,clipped:"none"}}function uo(n,e,t,r,o={}){let{tension:i=.38,clipStart:s="none",clipEnd:a="none"}=o,l=Math.min(.66,i+.24),u=s==="none"?i:l,d=a==="none"?i:l,h=t-n;return[{x:n,y:e},{x:n+h*u,y:e},{x:t-h*d,y:r},{x:t,y:r}]}function Ot(n,e,t,r){return`M ${G(n.x)} ${G(n.y)} C ${G(e.x)} ${G(e.y)} ${G(t.x)} ${G(t.y)} ${G(r.x)} ${G(r.y)}`}function ho(n,e,t,r,o){let i=ne(n,e,o),s=ne(e,t,o),a=ne(t,r,o),c=ne(i,s,o),l=ne(s,a,o),u=ne(c,l,o);return[[n,i,c,u],[u,l,a,r]]}function ne(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function ge(n,e,t,r,o={}){let{tension:i=.38,clipStart:s="none",clipEnd:a="none",splitT:c=.66}=o,l=uo(n,e,t,r,{tension:i,clipStart:s,clipEnd:a}),[u,d,h,p]=l;if(!(s!=="none"||a!=="none"))return{solid:Ot(u,d,h,p)};let[f,g]=ho(u,d,h,p,c),[S,b,y,x]=f,[C,E,H,I]=g;return{solid:Ot(S,b,y,x),dotted:Ot(C,E,H,I)}}function G(n){return n.toFixed(2)}function Fe(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function Ln(n){let e=new Map;for(let t of Fe(n))e.has(t.id)||e.set(t.id,t);return Fe([...e.values()])}function Mn(n){return[...n].sort((e,t)=>e.commentrayLine!==t.commentrayLine?e.commentrayLine-t.commentrayLine:e.sourceStart-t.sourceStart)}function kn(n,e){let t=Mn([...n]),r=t.findIndex(o=>o.id===e.id);if(!(r<0))return t[r+1]}function Hn(n,e){return n.length===0?null:te(n,e)?.id??null}function xn(n,e){if(n.length===0)return null;let t=Mn([...n]),r=t[0];if(r===void 0)return null;let o=r;for(let i of t)i.commentrayLine<=e&&(o=i);return o.id}function zt(n){return Math.max(0,n-1)}var $t='.commentray-page-break[data-commentray-page-break="true"]';function Ne(n,e){return(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0}function Cn(n,e,t){return Array.from(n.querySelectorAll($t)).filter(r=>Ne(e,r)&&(t===null||Ne(r,t)))}var En=.5;function mo(n){let e=n.closest($t);return!!(e&&!n.isSameNode(e))}function _t(n,e,t){let r=e.getBoundingClientRect().top+2;for(let o of Array.from(n.querySelectorAll("*"))){if(!(o instanceof HTMLElement)||t!==null&&(o===t||!Ne(o,t))||!Ne(e,o)||mo(o)||o.matches($t))continue;let i=o.getBoundingClientRect();i.width<En||i.height<En||(r=Math.max(r,i.bottom))}return r}function Oe(n,e,t){let r=Cn(n,e,t),o=e.getBoundingClientRect().top+2,i=e;for(let s of r)o=Math.max(o,_t(n,i,s)),i=s;return t?o=Math.max(o,_t(n,i,t)):o=Math.max(o,_t(n,i,null)),o}function An(n,e,t){let r=t.getBoundingClientRect().top-3,o=e.getBoundingClientRect().top+4,s=Cn(n,e,t)[0];if(s!==void 0){let c=Oe(n,e,s),l=s.getBoundingClientRect().top-2;return Math.min(r,l,Math.max(o,c))}let a=Oe(n,e,t);return Math.min(r,Math.max(o,a))}function Bn(n,e){if(n.length===0)return null;let t=null;for(let{line0:r,top:o}of n)o<=e+1+.001&&(t=t===null?r:Math.max(t,r));return t}function R(n){let e=n.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function In(n,e){function t(r){let o=n.getAttribute(r);return o!==null&&o.trim()!==""?o:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function _e(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Pn(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return _e(n);try{let r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`(${r.join("|")})`,"gi");return n.split(o).map((s,a)=>a%2===1?`<mark class="search-hit">${_e(s)}</mark>`:_e(s)).join("")}catch{return _e(n)}}function ze(n,e){let t=e.map(c=>c.trim()).filter(Boolean);if(t.length===0)return[];let r=n.toLowerCase(),o=t.map(c=>c.toLowerCase()),i=[],s=0,a=0;for(;s<n.length&&a<400;){let c=s,l=-1,u=!0;for(let d of o){if(d.length===0)continue;let h=r.indexOf(d,c);if(h<0){u=!1;break}l<0&&(l=h),c=h+d.length}if(!u||l<0)break;i.push({start:l,end:c}),a++,s=l+1}return i}function Rn(n,e){let t=Math.max(0,Math.min(e,n.length)),r=0;for(let o=0;o<t;o++)n[o]===`
2
+ `&&r++;return r}function Dn(n,e){let t=n.split(`
3
+ `);return e<0||e>=t.length?"":t[e]??""}function ye(n){return n.trim().split(/\s+/).filter(Boolean)}function Fn(n,e){let t=ye(e);return t.length===0?[...n]:n.filter(r=>{let o=r.sourcePath.replace(/\\/g,"/");return ze(o,t).length>0})}function Nn(n){let e=new Set,t=new Set,r=[],o=0;for(let i of n){let s=i.sourcePath.trim(),a=i.commentrayPath.trim();if(s.length>0){let c=`${s}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:o++,text:s,spPath:i.sourcePath,crPath:i.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:o++,text:a,spPath:i.sourcePath,crPath:i.commentrayPath}))}return r}var fo=80;function On(n,e=fo){let t=new Map;for(let i of n){let s=i.sourcePath.trim();if(s.length===0)continue;let a=t.get(s),c={sourcePath:i.sourcePath.trim(),commentrayPath:i.commentrayPath.trim()};if(!a){t.set(s,c);continue}c.commentrayPath.localeCompare(a.commentrayPath)<0&&t.set(s,c)}let r=t.size;return{rows:[...t.values()].sort((i,s)=>i.sourcePath.localeCompare(s.sourcePath)).slice(0,e),totalUnique:r}}function k(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function po(n){let e=n.indexOf("/browse/");if(e>=0){let r=n.slice(0,e).replace(/\/+$/,"");return r===""?"/":r}let t=n.replace(/\/[^/]*$/,"");return t===""||t==="/"?"/":t.replace(/\/+$/,"")||"/"}var qt=/^(?:\.\/|\/)?browse\/(.+)\/index\.html$/i,Gt=/^(?:\.\/|\/)?browse\/(.+\.html)$/i;function go(n){return qt.test(n)}function yo(n){return Gt.test(n)&&!n.toLowerCase().endsWith("/index.html")}function $e(n){let e=n.trim();return go(e)||yo(e)}function Y(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let o=po(e),i=qt.exec(r);if(i?.[1]){let a=i[1],c=o==="/"?`/browse/${a}/index.html`:`${o}/browse/${a}/index.html`;return`${t}${c}`}let s=Gt.exec(r);if(s?.[1]&&!r.toLowerCase().endsWith("/index.html")){let a=o==="/"?`/browse/${s[1]}`:`${o}/browse/${s[1]}`;return`${t}${a}`}return new URL(r,`${t}${e}`).href}function Wt(n,e,t){let r=n.trim();if(r.length===0)return"";let o=qt.exec(r);if(o?.[1])return`./browse/${o[1]}/index.html`;let i=Gt.exec(r);return i?.[1]&&!r.toLowerCase().endsWith("/index.html")?`./browse/${i[1]}`:Y(r,e,t)}function Vt(n,e,t){let r=k(e),o=k(t);if(r.length>0){let i=n.find(s=>k(s.commentrayPath)===r);if(i)return i}if(o.length>0){let i=n.find(s=>k(s.sourcePath)===o);if(i)return i}}function Ut(n,e,t){return k(n.sourcePath)===k(e)&&k(n.commentrayPath)===k(t)}var Qt="commentray.codeCommentrayStatic.colorTheme",Yt=["system","light","dark"];function _n(n){let e=Yt.indexOf(n),t=(e>=0?e+1:0)%Yt.length;return Yt[t]??"system"}function qe(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function bo(n){let e=globalThis.document;if(!e)return;let t=e.getElementById("commentray-hljs-light"),r=e.getElementById("commentray-hljs-dark");if(!(!(t instanceof HTMLLinkElement)||!(r instanceof HTMLLinkElement))){if(n==="light"){t.disabled=!1,t.removeAttribute("media"),r.disabled=!0,r.setAttribute("media","(prefers-color-scheme: dark)");return}if(n==="dark"){r.disabled=!1,r.removeAttribute("media"),t.disabled=!0,t.setAttribute("media","(prefers-color-scheme: light)");return}t.disabled=!1,r.disabled=!1,t.media="(prefers-color-scheme: light)",r.media="(prefers-color-scheme: dark)"}}function jt(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,bo(n))}function zn(n){let e=n.eps??1.5,{driverDelta:t,partnerBefore:r,partnerAfter:o}=n;return Math.abs(t)<e?!1:t>e&&o<r-e||t<-e&&o>r+e}var So=["block-aware-proportional","block-snap-only","filler-blocks"],Kt="block-aware-proportional";function $n(n){if(n==null)return Kt;let e=n.trim();return e.length===0?Kt:So.includes(e)?e:Kt}function Q(n){return Math.max(12,Math.min(48,n*.18))}var j=12,Xt=8;function Ge(n,e,t){return Math.max(e,Math.min(t,n))}function qn(n,e){let t=e.getBoundingClientRect(),r=globalThis.innerWidth,o=globalThis.innerHeight,i=n.getBoundingClientRect(),s=i.width>0?i.width:340,a=i.height>0?i.height:160,c=8,l=t.bottom+12+a<=o-c,u=l?Math.max(c,t.bottom+12):Math.max(c,t.top-a-12),d=Ge(t.left,c,r-s-c);n.style.top=`${String(Math.round(u))}px`,n.style.left=`${String(Math.round(d))}px`,n.dataset.side=l?"below":"above";let h=Ge(t.left+t.width/2-d-8,10,s-22);n.style.setProperty("--pointer-left",`${String(Math.round(h))}px`)}function Gn(n,e,t){if(e.replaceChildren(),t.length===0)return;let r=n.getBoundingClientRect(),o=r.left+r.width/2,i=r.top+r.height/2,s=12,a=8,c=12,l=n.dataset.side,u=Number.parseFloat(n.style.getPropertyValue("--pointer-left")),d=Number.isFinite(u)?r.left+u+8:o,h=l==="below"?r.top-a:l==="above"?r.bottom+a:i;for(let[p,m]of t.entries()){let f=m.getBoundingClientRect(),g=f.left+f.width/2,S=f.top+f.height/2,b=g-o,y=S-i,x=Math.abs(b)>=Math.abs(y),C=p-(t.length-1)/2,E,H;t.length===1&&(l==="below"||l==="above")?(E=d,H=h):x?(E=b>=0?r.right+a:r.left-a,H=Ge(S+C*c,r.top+s,r.bottom-s)):(H=y>=0?r.bottom+a:r.top-a,E=Ge(g+C*c,r.left+s,r.right-s));let I=g-E,X=S-H,J=Math.hypot(I,X);if(!Number.isFinite(J)||J<12)continue;let F=document.createElement("span");F.className="commentray-wide-intro-arrow",F.style.left=`${String(Math.round(E))}px`,F.style.top=`${String(Math.round(H))}px`,F.style.width=`${String(Math.round(J))}px`,F.style.setProperty("--wide-intro-arrow-angle",`${String(Math.atan2(X,I))}rad`);let ae=document.createElement("span");ae.className="commentray-wide-intro-arrow-head",F.appendChild(ae),e.appendChild(F)}}function Jt(n,e){let t=e?"#mobile-pane-flip":"#shell",r=n.id.trim().length>0&&typeof globalThis.CSS?.escape=="function"?`#${globalThis.CSS.escape(n.id)}`:"#shell",o=t==="#shell"?r:t;return[{targetSelectors:e?[o]:["#code-pane","#doc-pane"],title:"Welcome",body:"Welcome to commentray, a system to create and view commentaries next to the source tree. Angles are different aspects of these commentaries, so switch between them and keep scrolling while both panes stay aligned."},{targetSelectors:e?[o]:["#code-pane","#doc-pane"],title:"Two views",body:e?"You are in narrow view now. Use the pane flip to switch code and commentary. Wide view shows both panes side by side.":"You are in wide view now. It shows code and commentary side by side. Narrow view uses one pane and a flip control."},{targetSelectors:e?["#mobile-pane-flip","#doc-pane"]:["#code-pane","#doc-pane"],title:e?"Scroll and toggle":"Scroll both panes",body:e?"Try scrolling commentary, then use the pane flip to switch to source and keep exploring.":"Try scrolling in either pane. Source and commentary stay aligned while you read side by side."},{targetSelector:"#search-q",title:"Search quickly",body:"Use this search input to jump to documented source lines and markdown snippets."},{targetSelector:"#angle-select",title:"Angle switch",body:"Change the Commentray angle to view a different narrative for this same source file."},{targetSelector:"#source-markdown-pane-flip",title:"Source view mode",body:"Toggle between raw source and rendered markdown in the source pane."},{targetSelector:"#wrap-lines",title:"Readability controls",body:"Wrap lines to reduce horizontal scrolling in both source and commentary panes.",fallbackActionLabel:"Switch to markdown source",fallbackAction:()=>{let i=document.getElementById("source-markdown-pane-flip");i instanceof HTMLButtonElement&&i.click()}},{targetSelector:"#commentray-theme-trigger",title:"Appearance",body:"Change theme mode from this trigger (menu on left-click, quick cycle on right-click)."},{targetSelector:"#commentray-share-link",title:"Share this view",body:"Use this link button to copy a shareable permalink to the exact page and state you are viewing."},{targetSelector:"#commentray-help-tour",title:"Need a refresher?",body:"You can always go back to this tutorial via the help button."}]}function To(n,e){let t=n[e];if(!t)return[];let r=Array.isArray(t.targetSelectors)&&t.targetSelectors.length>0?t.targetSelectors:t.targetSelector?[t.targetSelector]:[],o=[],i=new Set;for(let s of r){let a=document.querySelector(s);!(a instanceof HTMLElement)||i.has(a)||(i.add(a),o.push(a))}return o}function wo(n){if(n.hidden)return!1;let e=globalThis.getComputedStyle(n);if(e.display==="none"||e.visibility==="hidden")return!1;let t=n.getBoundingClientRect();return t.width>0&&t.height>0}function We(n,e){return To(n,e).filter(t=>wo(t))}function Wn(){for(let t of Array.from(document.querySelectorAll(".commentray-wide-intro-target")))t instanceof HTMLElement&&t.classList.remove("commentray-wide-intro-target");let n=document.getElementById("commentray-wide-intro");n instanceof HTMLElement&&n.remove();let e=document.getElementById("commentray-wide-intro-arrows");e instanceof HTMLElement&&e.remove()}function Vn(){let n=document.createElement("div");n.id="commentray-wide-intro-arrows",n.setAttribute("aria-hidden","true"),document.body.appendChild(n);let e=document.createElement("section");e.id="commentray-wide-intro",e.setAttribute("role","dialog"),e.setAttribute("aria-live","polite"),e.innerHTML=`
4
4
  <span class="commentray-wide-intro-pointer" aria-hidden="true"></span>
5
5
  <p class="commentray-wide-intro-title"></p>
6
6
  <p class="commentray-wide-intro-body"></p>
@@ -13,13 +13,14 @@
13
13
  <button type="button" data-wide-intro="skip">Skip</button>
14
14
  </div>
15
15
  </div>
16
- `,document.body.appendChild(e);let t=e.querySelector(".commentray-wide-intro-title"),r=e.querySelector(".commentray-wide-intro-body"),i=e.querySelector(".commentray-wide-intro-step-action"),o=e.querySelector(".commentray-wide-intro-progress"),s=e.querySelector('button[data-wide-intro="back"]'),a=e.querySelector('button[data-wide-intro="next"]'),c=e.querySelector('button[data-wide-intro="skip"]');return!(t instanceof HTMLElement)||!(r instanceof HTMLElement)||!(i instanceof HTMLButtonElement)||!(o instanceof HTMLElement)||!(s instanceof HTMLButtonElement)||!(a instanceof HTMLButtonElement)||!(c instanceof HTMLButtonElement)?(n.remove(),e.remove(),null):{bubble:e,arrowLayer:n,titleEl:t,bodyEl:r,stepActionBtn:i,progressEl:o,backBtn:s,nextBtn:a,skipBtn:c}}function F(n,e){try{return n.getItem(e)}catch{return null}}function B(n,e,t){try{n.setItem(e,t)}catch{}}var un="commentray.codeCommentrayStatic.wideModeIntro.v1";function hn(n){let e=n.isNarrowViewport()?"narrow":"wide";e!==n.viewportMode&&(n.viewportMode=e,n.steps=Ht(n.shell,e==="narrow"))}function dn(n){let{bubble:e,arrowLayer:t}=n.elements;hn(n);let r=He(n.steps,n.current),i=r[0];if(!i){e.dataset.side="none",e.style.top="12px",e.style.left="12px",t.replaceChildren();return}sn(e,i),an(e,t,r)}function ar(n){for(hn(n);n.current<n.steps.length;){let e=n.steps[n.current];if(!e)break;let t=He(n.steps,n.current),r=typeof e.fallbackAction=="function";if(t.length>0||r)break;n.current++}}function cr(n,e,t){let{stepActionBtn:r}=n.elements;if(t.length===0&&typeof e.fallbackAction=="function"&&e.fallbackActionLabel){r.hidden=!1,r.textContent=e.fallbackActionLabel,r.disabled=!1;return}r.hidden=!0,r.textContent="",r.disabled=!0}function lr(n,e){let{titleEl:t,bodyEl:r,progressEl:i,backBtn:o,nextBtn:s}=n.elements;if(ar(n),n.current>=n.steps.length){e();return}let a=n.steps[n.current];if(!a)return;let c=He(n.steps,n.current);for(let l of n.highlighted)l.classList.remove("commentray-wide-intro-target");n.highlighted=c;for(let l of n.highlighted)l.classList.add("commentray-wide-intro-target");t.textContent=a.title,r.textContent=a.body,cr(n,a,c),i.textContent=`${String(n.current+1)} / ${String(n.steps.length)}`,o.disabled=n.current===0,s.textContent=n.current===n.steps.length-1?"Done":"Next",dn(n)}function Ct(n,e,t){if(!t?.force&&F(localStorage,un)==="1")return;cn();let r=ln();if(!r)return;let i={shell:n,steps:Ht(n,e()),viewportMode:e()?"narrow":"wide",current:0,highlighted:[],elements:r,isNarrowViewport:e},{bubble:o,arrowLayer:s,stepActionBtn:a,backBtn:c,nextBtn:l,skipBtn:u}=i.elements,h=()=>{for(let p of i.highlighted)p.classList.remove("commentray-wide-intro-target");i.highlighted=[],s.remove(),o.remove(),globalThis.removeEventListener("resize",m),globalThis.removeEventListener("scroll",d,!0),document.removeEventListener("keydown",g,!0),B(localStorage,un,"1")},d=()=>{dn(i)},f=()=>{lr(i,h)},m=()=>{f()},g=p=>{p.key==="Escape"&&(p.preventDefault(),h())};c.addEventListener("click",()=>{i.current>0&&i.current--,f()}),a.addEventListener("click",()=>{let p=i.steps[i.current];!p||typeof p.fallbackAction!="function"||(p.fallbackAction(),f())}),l.addEventListener("click",()=>{if(i.current>=i.steps.length-1){h();return}i.current++,f()}),u.addEventListener("click",h),globalThis.addEventListener("resize",m),globalThis.addEventListener("scroll",d,!0),document.addEventListener("keydown",g,!0),f()}function Pe(n){let e=globalThis.location.pathname,t=globalThis.location.origin;for(let r of Array.from(n.querySelectorAll("a[href]"))){if(!(r instanceof HTMLAnchorElement))continue;let i=r.getAttribute("href")?.trim()??"";Le(i)&&(r.href=q(i,e,t))}}function Ie(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return;let t=Array.from(n.querySelectorAll("pre.mermaid")).filter(i=>{let o=i.closest(".commentray-mermaid");return o===null||o.querySelector("svg")===null});if(t.length===0)return;let r=globalThis.commentrayMermaid;r&&r.run({nodes:t}).catch(i=>{console.error("Commentray: mermaid.run failed",i)})}function v(n,e,t){return Math.max(e,Math.min(t,n))}function An(n,e,t){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return n.scrollTop+(r.top-i.top)-n.clientTop-t}function ae(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=v(e,0,t);Math.abs(n.scrollTop-r)<.25||(n.scrollTop=r)}function M(n){if(n.scrollHeight-n.clientHeight<=1)return!1;let t=getComputedStyle(n).overflowY;return t==="auto"||t==="scroll"||t==="overlay"}function Y(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function N(n){let e=Y(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=v(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function Dt(n,e,t){if(M(n)){ae(n,Math.round(An(n,e,t)));return}let r=Y(),i=e.getBoundingClientRect(),o=globalThis.scrollY+i.top-t,s=Math.max(0,r.scrollHeight-r.clientHeight),a=v(o,0,s);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function ce(){let n=Y(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?v(n.scrollTop/e,0,1):0}function Ce(n,e,t,r="code-line-"){let i=globalThis.matchMedia(zt).matches;if(t.k==="block"){let a=n.querySelector(`#${r}${String(t.src0)}`),c=a instanceof HTMLElement?a:_n(Pr(r),t.src0);c?Dt(n,c,2):N(t.winRatio);return}if(t.k==="mirrorW"){if(M(n)){let a=Math.max(0,n.scrollHeight-n.clientHeight);ae(n,t.ratio*a),i&&N(t.ratio)}else N(t.ratio);return}let o=ft(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(M(n)){if(ae(n,o),i){let a=Math.max(1,n.scrollHeight-n.clientHeight);N(v(o/a,0,1))}return}let s=Math.max(1,n.scrollHeight-n.clientHeight);N(v(o/s,0,1))}function Ae(n,e,t){if(t.k==="block"){let o=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);o instanceof HTMLElement?Dt(e,o,2):N(t.winRatio);return}if(t.k==="mirrorW"){if(M(e)){let o=Math.max(0,e.scrollHeight-e.clientHeight);ae(e,t.ratio*o)}else N(t.ratio);return}let r=ft(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(M(e)){ae(e,r);return}let i=Math.max(1,e.scrollHeight-e.clientHeight);N(v(r/i,0,1))}function mn(n,e){let t=M(n)?v(n.scrollTop/Math.max(1,n.scrollHeight-n.clientHeight),0,1):ce(),r=Hr(n);if(r!==null)return{k:"block",src0:r,winRatio:t};let i=e(),o=Ft(n),s=mt(i,o);return s!==null?{k:"block",src0:s,winRatio:t}:M(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:t}}function fn(n,e,t,r="code-line-"){let i=ce(),o=t(),s=On(n,r),a=ie(o,s);return a===null?M(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:i}:{k:"block",mdLine0:a,winRatio:i}}function gn(n){return M(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:ce()}}function pn(n){return M(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:ce()}}function x(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ur(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function hr(n,e){let t=new Map;for(let r of n){let i=r.kind==="path"?`path:${r.spPath??""}|${r.crPath??""}|${r.text.slice(0,120)}`:`${r.kind}:${r.line}:${r.crPath??""}`,o=t.get(i);(!o||r.score>o.score)&&t.set(i,r)}return[...t.values()].sort((r,i)=>i.score-r.score).slice(0,e)}function At(n,e,t){let r=Me(n,t),i=new Set,o=[];for(let s of r){let a=Xt(n,s.start);i.has(a)||(i.add(a),o.push({kind:e,line:a,text:Zt(n,a),score:1e3,source:"ordered"}))}return o}function dr(n,e,t){let r=e.trim();if(!r)return[];let i=new O(r,t,[new ee(.22),new _(0),new Q(0)]),o=n.getMatches(i),s=[];for(let a of o.matches){let c=a.entity;s.push({kind:c.kind,line:c.line,text:c.text,score:100+a.quality,source:"fuzzy",crPath:c.crPath,spPath:c.spPath})}return s}function mr(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||Me(r.text,e).length===0||t.push({kind:"path",line:r.line,text:r.text,score:1e3,source:"ordered",spPath:r.spPath,crPath:r.crPath});return t}function fr(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:i,rawMd:o,searcher:s,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:u}=n,h=(l&&l.trim().length>0?l.trim():[t,r].filter(p=>p.trim().length>0).join(`
17
- `))||"",d=e==="commentray-and-paths"?[]:At(i,"code",c),f=e==="commentray-and-paths"&&u&&u.length>0?mr(u,c):e==="commentray-and-paths"&&h?At(h,"path",c):[],m=At(o,"md",c),g=dr(s,a,60);return hr([...d,...f,...m,...g],80)}function gr(n){return n==="commentray-and-paths"?"Paths + indexed commentray (this page + browse pages when built). Ordered tokens + fuzzy lines.":"Whole source: whitespace tokens in order (may span lines). Per-line fuzzy ranking for typos."}function pr(n,e){if(n.kind==="code")return`Code L${n.line+1}`;if(n.kind==="path")return"Path";let t=n.crPath&&n.crPath!==e.currentCommentrayPath?` \xB7 ${n.crPath}`:"";return`Commentray L${n.line+1}${t}`}function Bn(n,e,t){let r=pr(n,t),i=n.source==="ordered"?"ordered":"fuzzy",o=Jt(ur(n.text,320),e),s=x(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=x(n.kind==="md"?n.spPath??t.currentSourcePath:n.spPath??"");return`<button type="button" class="hit" data-kind="${n.kind}" data-line="${String(n.line)}" data-cr-path="${s}" data-sp-path="${a}"><span class="meta">${x(r)} <span class="src-tag">(${i})</span></span><div class="snippet">${o}</div></button>`}function yr(n,e,t,r){if(e.length===0)return'<div class="hint">No matches. Try fewer tokens or looser spelling (fuzzy matches per line).</div>';let i=gr(n),o=[];o.push(`<div class="hint">${i} ${e.length} hit(s).</div>`);for(let s of e)o.push(Bn(s,t,r));return o.join("")}function Bt(n,e,t,r){return n==="full"?"Documented source for this page. Type to search.":r?"Documented source on this page. Type to search the index when it is available.":t>e?`Indexed source files (${String(e)} of ${String(t)} shown). Type to search.`:`Indexed source files (${String(t)}). Type to search.`}function Pt(n,e,t){let r=[],i=[`<div class="hint">${x(n)}</div>`],o=e.map((s,a)=>({kind:"path",line:a,text:s.sourcePath,score:1e3,source:"ordered",spPath:s.sourcePath,crPath:s.commentrayPath}));for(let s of o)i.push(Bn(s,r,t));return i.join("")}function Pn(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let s=Math.round(An(n,r,8)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:v(s,0,a),behavior:"smooth"});return}if(t<=1)return;let i=e/Math.max(1,t-1),o=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:i*o,behavior:"smooth"})}function In(n,e){if(n.staticBrowseUrl?.trim()){let r=q(n.staticBrowseUrl.trim(),globalThis.location.pathname,globalThis.location.origin),i=new URL(r);e!==null&&e>=0&&(i.hash=`commentray-md-line-${String(e)}`),globalThis.location.assign(i.toString());return}let t=(n.commentrayOnGithub??"").trim();if(t.length>0){let r=e!==null&&e>=0?`${t}#L${String(e+1)}`:t;globalThis.location.assign(r)}}function br(n){return{scope:(n.getAttribute("data-search-scope")||"")==="commentray-and-paths"?"commentray-and-paths":"full",filePathLabel:n.getAttribute("data-search-file-path")||"",commentrayPathLabel:n.getAttribute("data-search-commentray-path")||""}}function yn(n,e,t,r,i){let o=t.split(`
16
+ `,document.body.appendChild(e);let t=e.querySelector(".commentray-wide-intro-title"),r=e.querySelector(".commentray-wide-intro-body"),o=e.querySelector(".commentray-wide-intro-step-action"),i=e.querySelector(".commentray-wide-intro-progress"),s=e.querySelector('button[data-wide-intro="back"]'),a=e.querySelector('button[data-wide-intro="next"]'),c=e.querySelector('button[data-wide-intro="skip"]');return!(t instanceof HTMLElement)||!(r instanceof HTMLElement)||!(o instanceof HTMLButtonElement)||!(i instanceof HTMLElement)||!(s instanceof HTMLButtonElement)||!(a instanceof HTMLButtonElement)||!(c instanceof HTMLButtonElement)?(n.remove(),e.remove(),null):{bubble:e,arrowLayer:n,titleEl:t,bodyEl:r,stepActionBtn:o,progressEl:i,backBtn:s,nextBtn:a,skipBtn:c}}function D(n,e){try{return n.getItem(e)}catch{return null}}function A(n,e,t){try{n.setItem(e,t)}catch{}}var Un="commentray.codeCommentrayStatic.wideModeIntro.v1";function Yn(n){let e=n.isNarrowViewport()?"narrow":"wide";e!==n.viewportMode&&(n.viewportMode=e,n.steps=Jt(n.shell,e==="narrow"))}function Qn(n){let{bubble:e,arrowLayer:t}=n.elements;Yn(n);let r=We(n.steps,n.current),o=r[0];if(!o){e.dataset.side="none",e.style.top="12px",e.style.left="12px",t.replaceChildren();return}qn(e,o),Gn(e,t,r)}function vo(n){for(Yn(n);n.current<n.steps.length;){let e=n.steps[n.current];if(!e)break;let t=We(n.steps,n.current),r=typeof e.fallbackAction=="function";if(t.length>0||r)break;n.current++}}function Eo(n,e,t){let{stepActionBtn:r}=n.elements;if(t.length===0&&typeof e.fallbackAction=="function"&&e.fallbackActionLabel){r.hidden=!1,r.textContent=e.fallbackActionLabel,r.disabled=!1;return}r.hidden=!0,r.textContent="",r.disabled=!0}function Lo(n,e){let{titleEl:t,bodyEl:r,progressEl:o,backBtn:i,nextBtn:s}=n.elements;if(vo(n),n.current>=n.steps.length){e();return}let a=n.steps[n.current];if(!a)return;let c=We(n.steps,n.current);for(let l of n.highlighted)l.classList.remove("commentray-wide-intro-target");n.highlighted=c;for(let l of n.highlighted)l.classList.add("commentray-wide-intro-target");t.textContent=a.title,r.textContent=a.body,Eo(n,a,c),o.textContent=`${String(n.current+1)} / ${String(n.steps.length)}`,i.disabled=n.current===0,s.textContent=n.current===n.steps.length-1?"Done":"Next",Qn(n)}function Zt(n,e,t){if(!t?.force&&D(localStorage,Un)==="1")return;Wn();let r=Vn();if(!r)return;let o={shell:n,steps:Jt(n,e()),viewportMode:e()?"narrow":"wide",current:0,highlighted:[],elements:r,isNarrowViewport:e},{bubble:i,arrowLayer:s,stepActionBtn:a,backBtn:c,nextBtn:l,skipBtn:u}=o.elements,d=()=>{for(let g of o.highlighted)g.classList.remove("commentray-wide-intro-target");o.highlighted=[],s.remove(),i.remove(),globalThis.removeEventListener("resize",m),globalThis.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",f,!0),A(localStorage,Un,"1")},h=()=>{Qn(o)},p=()=>{Lo(o,d)},m=()=>{p()},f=g=>{g.key==="Escape"&&(g.preventDefault(),d())};c.addEventListener("click",()=>{o.current>0&&o.current--,p()}),a.addEventListener("click",()=>{let g=o.steps[o.current];!g||typeof g.fallbackAction!="function"||(g.fallbackAction(),p())}),l.addEventListener("click",()=>{if(o.current>=o.steps.length-1){d();return}o.current++,p()}),u.addEventListener("click",d),globalThis.addEventListener("resize",m),globalThis.addEventListener("scroll",h,!0),document.addEventListener("keydown",f,!0),p()}var Mo="__NON_SYNC_TAIL_SLACK__";function jn(n){return n.reduce((e,t)=>e+t.bufferAbove+t.height+t.bufferBelow,0)}function Kn(n,e){return n.map(t=>{let r=be(t.id)?e.get(t.id)??t.height:t.height;return{...t,bufferAbove:t.bufferAbove??0,bufferBelow:be(t.id)?r-t.height:t.bufferBelow??0,...t.syncRegionContinuationRows!==void 0?{syncRegionContinuationRows:[...t.syncRegionContinuationRows]}:{}}})}function be(n){return/^R\d+XX$/.test(n)}function Xn(n,e){let t=0;for(let o=0;o<e;o++){let i=n[o];i!==void 0&&(t+=i.bufferAbove+i.height+i.bufferBelow)}let r=n[e];return t+(r?.bufferAbove??0)}function Jn(n,e){return n.findIndex(t=>t.id===e)}function ko(n,e,t,r){let o=Xn(n,t),i=Xn(e,r);if(o===i)return!1;if(o>i){let d=o-i,h=n[t],p=h!==void 0?Math.min(d,h.bufferAbove):0,m=!1;p>0&&h!==void 0&&(h.bufferAbove-=p,m=!0);let f=d-p;if(f>0){let g=e[r];g!==void 0&&(g.bufferAbove+=f,m=!0)}return m}let s=i-o,a=e[r],c=a!==void 0?Math.min(s,a.bufferAbove):0,l=!1;c>0&&a!==void 0&&(a.bufferAbove-=c,l=!0);let u=s-c;if(u>0){let d=n[t];d!==void 0&&(d.bufferAbove+=u,l=!0)}return l}function Ho(n,e){let t=new Set;for(let i of n)be(i.id)&&t.add(i.id);let r=[];for(let i of t){let s=Jn(n,i),a=Jn(e,i);s>=0&&a>=0&&r.push({id:i,il:s,ir:a})}r.sort((i,s)=>i.il-s.il);let o=r.length+8;for(let i=0;i<o;i++){let s=!1;for(let{il:a,ir:c}of r)ko(n,e,a,c)&&(s=!0);if(!s)break}}function Zn(n){return{id:Mo,height:0,bufferAbove:0,bufferBelow:n}}function xo(n,e){let t=jn(n),r=jn(e),o=r-t;if(o>0&&n.length>0){er(n,e,o);return}let i=t-r;i>0&&e.length>0&&er(e,n,i)}function er(n,e,t){if(t<=0)return;let r=n.at(-1);if(r!==void 0&&!be(r.id)){n[n.length-1]={...r,bufferBelow:r.bufferBelow+t};return}n.push(Zn(t)),e.push(Zn(0))}function tr(n){return{...n,...n.syncRegionContinuationRows!==void 0?{syncRegionContinuationRows:[...n.syncRegionContinuationRows]}:{}}}function Co(n,e){let t=n.map(tr),r=e.map(tr);return Ho(t,r),xo(t,r),{left:t,right:r}}var Ve=class{synchronize(e,t){let r=[...e],o=[...t],i=new Map;for(let a of[...r,...o]){if(!be(a.id))continue;let c=i.get(a.id)??0;a.height>c&&i.set(a.id,a.height)}let s={left:Kn(r,i),right:Kn(o,i)};return Co(s.left,s.right)}};var Ao="tbody tr.stretch-row[data-commentray-stretch-sync-id]",en="commentray-mermaid-done",Bo=new Ve;function O(n){return!Number.isFinite(n)||n<=0?0:Math.max(0,Math.round(n))}var Ue=1;function Io(n){let e=n.querySelector(":scope .stretch-doc-inner");if(e===null||e.nodeType!==Ue)return 0;let t=e,r=t.scrollHeight;if(typeof r=="number"&&r>0)return O(r);let o=O(t.getBoundingClientRect().height);return o>0?o:0}function Po(n){let e=n.querySelector(":scope .stretch-code-stack");if(e===null||e.nodeType!==Ue)return 0;let t=e,r=t.scrollHeight;if(typeof r=="number"&&r>0)return O(r);let o=O(t.getBoundingClientRect().height);return o>0?o:0}function Ro(n){let e=n.querySelectorAll(".code-line");if(e.length===0)return 0;let t=1/0,r=-1/0;for(let i of e){let s=i.getBoundingClientRect();t=Math.min(t,s.top),r=Math.max(r,s.bottom)}if(r<=t||!Number.isFinite(t))return 0;let o=O(r-t);return o>0?o:0}function Do(n){let e=n.querySelector(".stretch-gap-mark");return e===null||e.nodeType!==Ue?0:O(e.getBoundingClientRect().height)}function nr(n){let e=Io(n);if(e>0)return e;let t=Po(n);if(t>0)return t;let r=n.querySelector(":scope > .stretch-cell-measure");if(r===null||r.nodeType!==Ue)return O(n.offsetHeight);let o=r,i=Ro(o);if(i>0)return i;let s=Do(r);if(s>0)return s;let a=O(o.getBoundingClientRect().height);return a>0?a:O(o.offsetHeight)}function Fo(n){return Array.from(n.querySelectorAll(Ao)).filter(e=>(e.dataset.commentrayStretchSyncId?.trim()??"").length>0)}function No(n,e){n.style.paddingBottom="",e.style.paddingBottom="",n.style.paddingTop="",e.style.paddingTop=""}function Oo(n,e,t,r){t.bufferAbove>0&&(n.style.paddingTop=`${String(t.bufferAbove)}px`),r.bufferAbove>0&&(e.style.paddingTop=`${String(r.bufferAbove)}px`),t.bufferBelow>0&&(n.style.paddingBottom=`${String(t.bufferBelow)}px`),r.bufferBelow>0&&(e.style.paddingBottom=`${String(r.bufferBelow)}px`)}function Ye(n){let e=n.querySelectorAll("td"),t=e[0],r=e[1];return t===void 0||r===void 0?null:{codeTd:t,docTd:r}}function _o(n){for(let e of n){let t=Ye(e);t!==null&&No(t.codeTd,t.docTd)}}function zo(n){let e=[],t=[];for(let r of n){let o=Ye(r);if(o===null)continue;let i=r.dataset.commentrayStretchSyncId?.trim()??"";e.push({id:i,height:nr(o.codeTd),bufferAbove:0,bufferBelow:0}),t.push({id:i,height:nr(o.docTd),bufferAbove:0,bufferBelow:0})}return e.length===0?null:{left:e,right:t}}function $o(n,e){let t=n.length;for(let r=0;r<t;r++){let o=n[r],i=o===void 0?null:Ye(o),s=e.left[r],a=e.right[r];i===null||s===void 0||a===void 0||Oo(i.codeTd,i.docTd,s,a)}}function qo(n){let e=n.at(-1);if(e===void 0||!e.classList.contains("stretch-row--gap"))return;let t=e===void 0?null:Ye(e);t!==null&&(t.codeTd.style.paddingBottom="",t.docTd.style.paddingBottom="")}function Go(n){let e=Fo(n);if(e.length===0)return;_o(e);let t=zo(e);if(t===null)return;let r=Bo.synchronize(t.left,t.right);$o(e,r),qo(e)}function rr(){globalThis.dispatchEvent(new CustomEvent(en))}function or(n){let e=0,t,r=()=>{e!==0&&globalThis.cancelAnimationFrame(e),e=globalThis.requestAnimationFrame(()=>{e=0,Go(n)})},o=()=>{t!==void 0&&globalThis.clearTimeout(t),t=globalThis.setTimeout(()=>{t=void 0,r()},32)},i=new ResizeObserver(()=>{r()});i.observe(n);let s=n.querySelector("tbody"),a=s!==null?new MutationObserver(()=>{o()}):null;a!==null&&s!==null&&a.observe(s,{childList:!0,subtree:!0});let c=()=>{r()};globalThis.addEventListener("resize",c,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",c,{passive:!0});let l=()=>{r()};return globalThis.addEventListener(en,l),queueMicrotask(()=>{r(),globalThis.requestAnimationFrame(()=>{r(),globalThis.requestAnimationFrame(()=>{r()})}),globalThis.setTimeout(()=>{r()},120)}),{disconnect:()=>{e!==0&&globalThis.cancelAnimationFrame(e),t!==void 0&&globalThis.clearTimeout(t),i.disconnect(),a?.disconnect(),globalThis.removeEventListener("resize",c),globalThis.visualViewport?.removeEventListener("resize",c),globalThis.removeEventListener(en,l)}}}function Ee(n){let e=globalThis.location.pathname,t=globalThis.location.origin;for(let r of Array.from(n.querySelectorAll("a[href]"))){if(!(r instanceof HTMLAnchorElement))continue;let o=r.getAttribute("href")?.trim()??"";$e(o)&&(r.href=Y(o,e,t))}}function se(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return Promise.resolve();let t=Array.from(n.querySelectorAll("pre.mermaid")).filter(o=>{let i=o.closest(".commentray-mermaid");return i===null||i.querySelector("svg")===null});if(t.length===0)return Promise.resolve();let r=globalThis.commentrayMermaid;return r?r.run({nodes:t}).then(()=>{rr()}).catch(o=>{console.error("Commentray: mermaid.run failed",o)}):Promise.resolve()}function L(n,e,t){return Math.max(e,Math.min(t,n))}function Er(n,e,t){let r=e.getBoundingClientRect(),o=n.getBoundingClientRect();return n.scrollTop+(r.top-o.top)-n.clientTop-t}function Te(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=L(e,0,t);Math.abs(n.scrollTop-r)<.25||(n.scrollTop=r)}function M(n){if(n.scrollHeight-n.clientHeight<=1)return!1;let t=getComputedStyle(n).overflowY;return t==="auto"||t==="scroll"||t==="overlay"}function $(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function _(n){return M(n)?n.scrollTop:$().scrollTop}function Wo(n,e){if(M(n)){let o=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTop=L(e,0,o);return}let t=$(),r=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop=L(e,0,r)}function je(n){let{driverDelta:e,partnerBefore:t,partnerPane:r,axis:o}=n,i=_(r);zn({driverDelta:e,partnerBefore:t,partnerAfter:i})&&(fn()&&globalThis.console.warn("[commentray:scroll-sync] monotonic.revert",{t:Math.round(performance.now()),axis:o??"?",driverDelta:e,partnerBefore:t,partnerAfter:i}),Wo(r,t))}function re(n){let e=$(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=L(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function mn(n,e,t){if(M(n)){let c=Math.round(Er(n,e,t));Te(n,c);return}let r=$(),o=e.getBoundingClientRect(),i=globalThis.scrollY+o.top-t,s=Math.max(0,r.scrollHeight-r.clientHeight),a=L(i,0,s);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function Lr(n,e,t){if(M(n)){let o=e.getBoundingClientRect(),i=n.getBoundingClientRect(),s=o.top-i.top-n.clientTop;return Math.abs(s-t)<=Xt}let r=e.getBoundingClientRect();return Math.abs(r.top-t)<=Xt}function Mr(n,e,t){let r=n.querySelector(`[data-commentray-line="${String(e)}"]`);return r instanceof HTMLElement?Lr(n,r,t):!1}function kr(n,e,t){let r=n.querySelector(`#${e}${String(t)}`);return r instanceof HTMLElement?r:jr(xi(e),t)}function Vo(n,e,t,r){let o=kr(n,e,t);return o?Lr(n,o,r):!1}function Hr(n,e,t,r,o){return Vo(n,e,t,j)?(T("doc\u2192code.plan",{reason:r,...o,src0:t,lineIdPrefix:e}),{k:"noop",skipProportionalFallbackOnFlip:!0}):null}var xr=6;function Uo(n,e,t){let r=te(n,e);if(r)return r;let o=t.sourceSticky.lockedId;if(o===null)return null;let i=n.find(l=>l.id===o);if(!i)return null;let{lo:s,hiExclusive:a}=i.markerViewportHalfOpen1Based,c=xr;return e>=s&&e<a+c?i:null}function Le(){let n=$(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?L(n.scrollTop/e,0,1):0}var Ke="commentrayDebugScroll";function Yo(){let n=new URLSearchParams(globalThis.location.search).get(Ke);return n==="1"||n==="true"||n===""}function ir(n){try{let e=n.getItem(Ke);return e==="1"||e==="true"}catch{return!1}}function Qo(){let n=globalThis.location.hash;return n===`#${Ke}`||n===`#${Ke}=1`}function jo(){let n=globalThis.location.hostname;return n==="localhost"||n==="127.0.0.1"||n==="0.0.0.0"||n==="::1"}function Cr(){try{return!!(Yo()||Qo()||ir(globalThis.sessionStorage)||ir(globalThis.localStorage))}catch{return!1}}var Ko=500,tn=!1,cn=-1/0;function sr(){cn=-1/0}function fn(){let n=performance.now();return n-cn<Ko||(cn=n,tn=Cr()),tn}typeof globalThis.addEventListener=="function"&&(globalThis.addEventListener("hashchange",sr),globalThis.addEventListener("storage",sr));function Xo(){let n=jo(),e=Cr();!n&&!e||globalThis.console.log("[commentray:scroll-sync] boot",{t:Math.round(performance.now()),href:globalThis.location.href,devHost:n,traceVerbose:e})}function T(n,e){fn()&&globalThis.console.log(`[commentray:scroll-sync] ${n}`,{t:Math.round(performance.now()),...e})}function oe(n){return n.k==="noop"?n.skipProportionalFallbackOnFlip===!0?"noop(skipFlipFallback)":"noop":n.k==="block"?`block(src0=${String(n.src0)})`:n.k==="mirrorW"?`mirrorW(ratio=${n.ratio.toFixed(4)})`:`mirrorI(docTop=${String(n.docTop)})`}function ie(n){return n.k==="noop"?"noop":n.k==="block"?`block(mdLine0=${String(n.mdLine0)})`:n.k==="mirrorW"?`mirrorW(ratio=${n.ratio.toFixed(4)})`:`mirrorI(codeTop=${String(n.codeTop)})`}function Xe(n,e,t,r="code-line-"){if(t.k==="noop")return;let o=globalThis.matchMedia(Me).matches;if(t.k==="block"){let a=kr(n,r,t.src0);a&&mn(n,a,j);return}if(t.k==="mirrorW"){if(M(n)){let a=Math.max(0,n.scrollHeight-n.clientHeight);Te(n,t.ratio*a),o&&re(t.ratio)}else re(t.ratio);return}let i=Nt(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(M(n)){if(Te(n,i),o){let a=Math.max(1,n.scrollHeight-n.clientHeight);re(L(i/a,0,1))}return}let s=Math.max(1,n.scrollHeight-n.clientHeight);re(L(i/s,0,1))}function Je(n,e,t){if(t.k==="noop")return;if(t.k==="block"){let i=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);i instanceof HTMLElement&&mn(e,i,j);return}if(t.k==="mirrorW"){if(M(e)){let i=Math.max(0,e.scrollHeight-e.clientHeight);Te(e,t.ratio*i)}else re(t.ratio);return}let r=Nt(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(M(e)){Te(e,r);return}let o=Math.max(1,e.scrollHeight-e.clientHeight);re(L(r/o,0,1))}function Ar(n,e){let t=e.map(r=>r.id).join("\0");t!==n.linksKey.current&&(n.sourceSticky.lockedId=null,n.commentraySticky.lockedId=null,n.linksKey.current=t)}function Jo(n,e,t,r,o,i){if(i===null)return null;let s=Ft(e,i),a=s!==null?s.markerViewportHalfOpen1Based.lo-1:null;if(s!==null&&(t.commentraySticky.lockedId=s.id),a===null)return null;let c=Hr(n,r,a,"block-code-anchor-already-aligned-noop",{mdLine0:i,blockId:s?.id??null});if(c)return c;let l={k:"block",src0:a,winRatio:o};return T("doc\u2192code.plan",{reason:"block-from-md-probe",plan:oe(l),mdLine0:i,blockId:s?.id??null,markerSpan:s?.markerViewportHalfOpen1Based??null}),l}function Zo(n,e,t,r,o){let i=Ti(n);if(i===null)return null;let s=Hr(e,t,i,"page-break-pull-code-anchor-already-aligned-noop",{mdLine0:o,pulledSrc0:i});if(s)return s;let a={k:"block",src0:i,winRatio:r};return T("doc\u2192code.plan",{reason:"page-break-pull",plan:oe(a),pulledSrc0:i,mdLine0:o}),a}function Br(n,e,t,r,o,i){let s=M(n)?L(n.scrollTop/Math.max(1,n.scrollHeight-n.clientHeight),0,1):Le(),a=t();Ar(r,a);let c=pn(n),l=Jo(e,a,r,o,s,c);if(l!==null)return l;let u=Zo(n,e,o,s,c);if(u!==null)return u;if(a.length>0){if(T("doc\u2192code.plan",{reason:i?"indexed-fallback-mirror-no-confident-block":"indexed-noop-no-src0",mdLine0:c,linkCount:a.length,allowProportionalMirror:i}),!i)return{k:"noop"}}else if(!i)return T("doc\u2192code.plan",{reason:"snap-only-no-index-noop",linkCount:0}),{k:"noop"};if(M(n)){let h={k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight};return T("doc\u2192code.plan",{reason:"no-index-mirror-internal",plan:oe(h)}),h}let d={k:"mirrorW",ratio:s};return T("doc\u2192code.plan",{reason:"no-index-mirror-window",plan:oe(d)}),d}function ar(n,e){return M(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:e}}function ei(n,e,t,r,o,i){let a=[...n].sort((u,d)=>u.markerViewportHalfOpen1Based.lo-d.markerViewportHalfOpen1Based.lo)[0];if(!a)return T("code\u2192doc.plan",{reason:"prelude-missing-first-link",line1:r,lineIdPrefix:o}),{k:"noop"};t.sourceSticky.lockedId=a.id;let c=a.commentrayLine;if(Mr(e,c,j))return T("code\u2192doc.plan",{reason:"prelude-anchor-already-aligned-noop",line1:r,blockId:a.id,mdLine0:c}),{k:"noop"};let l={k:"block",mdLine0:c,winRatio:i};return T("code\u2192doc.plan",{reason:"prelude-first-block",line1:r,blockId:a.id,mdLine0:c,plan:ie(l)}),l}function ti(n,e,t,r,o,i){r.sourceSticky.lockedId=n.id;let s=n.commentrayLine,a=e!==null&&e.id===n.id?"strict":"trailing-slack";if(Mr(t,s,j))return T("code\u2192doc.plan",{reason:"active-block-anchor-aligned-noop",line1:o,pickMode:a,blockId:n.id,mdLine0:s}),{k:"noop"};let c={k:"block",mdLine0:s,winRatio:i};return T("code\u2192doc.plan",{reason:"active-block-reveal",line1:o,pickMode:a,blockId:n.id,mdLine0:s,markerSpan:n.markerViewportHalfOpen1Based,plan:ie(c)}),c}function ni(n,e,t){let r=n.sourceSticky.lockedId;if(!r)return;let o=e.find(s=>s.id===r);if(!o){n.sourceSticky.lockedId=null;return}let i=o.markerViewportHalfOpen1Based.hiExclusive;t>=i+xr&&(n.sourceSticky.lockedId=null)}function Ir(n,e,t,r,o,i){let s=Le(),a=t();if(Ar(o,a),a.length===0){if(!i)return T("code\u2192doc.plan",{reason:"snap-only-no-block-links-noop",lineIdPrefix:r}),{k:"noop"};let h=ar(n,s);return T("code\u2192doc.plan",{reason:h.k==="mirrorI"?"no-block-links-mirror-internal":"no-block-links-mirror-window",lineIdPrefix:r,plan:ie(h)}),h}let c=Gr(n,r);if(Dt(a,c))return ei(a,e,o,c,r,s);let l=te(a,c),u=Uo(a,c,o);if(u)return ti(u,l,e,o,c,s);if(ni(o,a,c),!i)return T("code\u2192doc.plan",{reason:"snap-only-source-gap-noop",line1:c,lineIdPrefix:r,stickyLockAfter:o.sourceSticky.lockedId}),{k:"noop"};let d=ar(n,s);return T("code\u2192doc.plan",{reason:d.k==="mirrorI"?"source-gap-mirror-internal":"source-gap-mirror-window",line1:c,lineIdPrefix:r,stickyLockAfter:o.sourceSticky.lockedId,plan:ie(d)}),d}function ln(n){return M(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:Le()}}function un(n){return M(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:Le()}}function B(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ri(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function oi(n,e){let t=new Map;for(let r of n){let o=r.kind==="path"?`path:${r.spPath??""}|${r.crPath??""}|${r.text.slice(0,120)}`:`${r.kind}:${r.line}:${r.crPath??""}`,i=t.get(o);(!i||r.score>i.score)&&t.set(o,r)}return[...t.values()].sort((r,o)=>o.score-r.score).slice(0,e)}function nn(n,e,t){let r=ze(n,t),o=new Set,i=[];for(let s of r){let a=Rn(n,s.start);o.has(a)||(o.add(a),i.push({kind:e,line:a,text:Dn(n,a),score:1e3,source:"ordered"}))}return i}function ii(n,e,t){let r=e.trim();if(!r)return[];let o=new U(r,t,[new he(.22),new Z(0),new ee(0)]),i=n.getMatches(o),s=[];for(let a of i.matches){let c=a.entity;s.push({kind:c.kind,line:c.line,text:c.text,score:100+a.quality,source:"fuzzy",crPath:c.crPath,spPath:c.spPath})}return s}function si(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||ze(r.text,e).length===0||t.push({kind:"path",line:r.line,text:r.text,score:1e3,source:"ordered",spPath:r.spPath,crPath:r.crPath});return t}function ai(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:o,rawMd:i,searcher:s,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:u}=n,d=(l&&l.trim().length>0?l.trim():[t,r].filter(g=>g.trim().length>0).join(`
17
+ `))||"",h=e==="commentray-and-paths"?[]:nn(o,"code",c),p=e==="commentray-and-paths"&&u&&u.length>0?si(u,c):e==="commentray-and-paths"&&d?nn(d,"path",c):[],m=nn(i,"md",c),f=ii(s,a,60);return oi([...h,...p,...m,...f],80)}function ci(n){return n==="commentray-and-paths"?"Paths + indexed commentray (this page + browse pages when built). Ordered tokens + fuzzy lines.":"Whole source: whitespace tokens in order (may span lines). Per-line fuzzy ranking for typos."}function li(n,e){if(n.kind==="code")return`Code L${n.line+1}`;if(n.kind==="path")return"Path";let t=n.crPath&&n.crPath!==e.currentCommentrayPath?` \xB7 ${n.crPath}`:"";return`Commentray L${n.line+1}${t}`}function Pr(n,e,t){let r=li(n,t),o=n.source==="ordered"?"ordered":"fuzzy",i=Pn(ri(n.text,320),e),s=B(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=B(n.kind==="md"?n.spPath??t.currentSourcePath:n.spPath??"");return`<button type="button" class="hit" data-kind="${n.kind}" data-line="${String(n.line)}" data-cr-path="${s}" data-sp-path="${a}"><span class="meta">${B(r)} <span class="src-tag">(${o})</span></span><div class="snippet">${i}</div></button>`}function ui(n,e,t,r){if(e.length===0)return'<div class="hint">No matches. Try fewer tokens or looser spelling (fuzzy matches per line).</div>';let o=ci(n),i=[];i.push(`<div class="hint">${o} ${e.length} hit(s).</div>`);for(let s of e)i.push(Pr(s,t,r));return i.join("")}function rn(n,e,t,r){return n==="full"?"Documented source for this page. Type to search.":r?"Documented source on this page. Type to search the index when it is available.":t>e?`Indexed source files (${String(e)} of ${String(t)} shown). Type to search.`:`Indexed source files (${String(t)}). Type to search.`}function on(n,e,t){let r=[],o=[`<div class="hint">${B(n)}</div>`],i=e.map((s,a)=>({kind:"path",line:a,text:s.sourcePath,score:1e3,source:"ordered",spPath:s.sourcePath,crPath:s.commentrayPath}));for(let s of i)o.push(Pr(s,r,t));return o.join("")}function Rr(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let s=Math.round(Er(n,r,j)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:L(s,0,a),behavior:"smooth"});return}if(t<=1)return;let o=e/Math.max(1,t-1),i=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:o*i,behavior:"smooth"})}function Dr(n,e){if(n.staticBrowseUrl?.trim()){let r=Y(n.staticBrowseUrl.trim(),globalThis.location.pathname,globalThis.location.origin),o=new URL(r);e!==null&&e>=0&&(o.hash=`commentray-md-line-${String(e)}`),globalThis.location.assign(o.toString());return}let t=(n.commentrayOnGithub??"").trim();if(t.length>0){let r=e!==null&&e>=0?`${t}#L${String(e+1)}`:t;globalThis.location.assign(r)}}function di(n){return{scope:(n.getAttribute("data-search-scope")||"")==="commentray-and-paths"?"commentray-and-paths":"full",filePathLabel:n.getAttribute("data-search-file-path")||"",commentrayPathLabel:n.getAttribute("data-search-commentray-path")||""}}function cr(n,e,t,r,o){let i=t.split(`
18
18
  `),s=e.split(`
19
- `),a=[];return n==="commentray-and-paths"&&(r.trim()&&a.push({kind:"path",line:a.length,text:r}),i.trim()&&a.push({kind:"path",line:a.length,text:i})),[...n==="full"?s.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...o.map((c,l)=>({kind:"md",line:l,text:c}))]}function bn(n){let e=Se.createDefaultSearcher();return e.indexEntities(n,t=>t.kind==="md"&&t.crPath?`md:${t.crPath}:${t.line}`:t.kind==="path"?`path:${t.spPath??""}|${t.crPath??""}|${t.line}|${t.text.slice(0,120)}`:`${t.kind}:${t.line}`,t=>[t.text]),e}function Sr(n,e){let t=n;for(;t;){if(t.classList?.contains("hit"))return t;if(t===e)return null;t=t.parentElement}return null}function It(n){return[...n.querySelectorAll("button.hit")].filter(e=>e instanceof HTMLButtonElement)}function Sn(n){return[...n.querySelectorAll("a.tree-file-link")].filter(e=>e instanceof HTMLAnchorElement)}function wr(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Tr(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),i=Mt(e.mutable.documentedPairs,t,r);if(i&&Et(i,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}i&&In(i,null)}function vr(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),i=e.trim();if(i.length>0&&w(i)!==w(r)){let o=Mt(t.mutable.documentedPairs,i,"");if(o){In(o,n);return}return}Pn(t.docScrollEl,n,t.mutable.mdLines.length)}function Rn(n,e){let t=n.getAttribute("data-kind"),r=parseInt(n.getAttribute("data-line")||"0",10),i=n.getAttribute("data-cr-path")?.trim()??"";if(t==="code"){wr(r);return}if(t==="path"){Tr(n,e);return}vr(r,i,e)}function Mr(n,e,t){let r={currentCommentrayPath:t.commentrayPathLabel,currentSourcePath:e};if(n==="full"){let l=e.trim();if(l.length===0)return null;let u=[{sourcePath:l,commentrayPath:t.commentrayPathLabel.trim()}],h=Bt("full",u.length,u.length,!1);return Pt(h,u,r)}let{rows:i,totalUnique:o}=nn(t.documentedPairs);if(i.length>0){let l=Bt("commentray-and-paths",i.length,o,!1);return Pt(l,i,r)}let s=e.trim();if(s.length===0)return null;let a=[{sourcePath:s,commentrayPath:t.commentrayPathLabel.trim()}],c=Bt("commentray-and-paths",a.length,a.length,!0);return Pt(c,a,r)}function Er(n,e){n.addEventListener("keydown",t=>{if(t.isComposing||n.hidden)return;let r=It(n);if(r.length===0)return;let i=document.activeElement;if(!(i instanceof HTMLButtonElement)||!i.classList.contains("hit"))return;let o=r.indexOf(i);if(!(o<0)){if(t.key==="ArrowDown"&&o<r.length-1){r[o+1].focus({preventScroll:!0}),t.preventDefault();return}if(t.key==="ArrowUp"){if(o>0){r[o-1].focus({preventScroll:!0}),t.preventDefault();return}e.focus({preventScroll:!0}),t.preventDefault()}}})}function Lr(n,e,t){let{renderEmptyBrowsePreview:r,runSearch:i,cancelDebounceTimer:o,hitClickDeps:s}=t;n.addEventListener("keydown",a=>{if(a.isComposing)return;if(a.key==="ArrowDown"){if(!e.hidden){let l=It(e);if(l.length>0&&document.activeElement===n){l[0].focus({preventScroll:!0}),a.preventDefault();return}}if(se(n.value).length>0)return;r(),a.preventDefault();return}if(a.key!=="Enter")return;o(),se(n.value).length>0&&i();let c=It(e);!e.hidden&&c.length>0&&document.activeElement===n&&(a.preventDefault(),Rn(c[0],s))})}function xr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:i,searchInput:o,searchClear:s,searchResults:a,docScrollEl:c}=n,l;function u(){clearTimeout(l),l=void 0}function h(){u(),o.value="",a.innerHTML="",a.hidden=!0}function d(){let g=Mr(e,t,r);g!==null&&(a.hidden=!1,a.innerHTML=g)}function f(){let g=se(o.value);if(g.length===0){a.hidden=!0,a.innerHTML="";return}let p=fr({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:i,rawMd:r.rawMd,searcher:r.searcher,queryRaw:o.value,tokens:g,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=yr(e,p,g,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let m={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",g=>{let p=Sr(g.target,a);p&&Rn(p,m)}),Er(a,o),o.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(f,200)}),Lr(o,a,{renderEmptyBrowsePreview:d,runSearch:f,cancelDebounceTimer:u,hitClickDeps:m}),s.addEventListener("click",h),document.addEventListener("keydown",g=>{if(g.key!=="Escape")return;let p=o.value.trim().length>0,S=document.activeElement===o,E=!a.hidden;!p&&!S&&!E||(h(),S&&o.blur(),g.preventDefault())})}function Dn(n,e,t,r,...i){let o=i.filter(a=>a instanceof HTMLElement),s=F(localStorage,n)==="1";if(t.checked=s,s){e.classList.add("wrap");for(let a of o)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of o)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of o)a.classList.add("wrap");B(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of o)a.classList.remove("wrap");B(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function Fn(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(D(e));if(!Array.isArray(t))return[];let r=[];for(let i of t){if(typeof i!="object"||i===null)continue;let o=i;if(typeof o.id=="string"&&typeof o.commentrayLine=="number"&&typeof o.sourceStart=="number"&&typeof o.sourceEnd=="number"){let s=o.markerViewportHalfOpen1Based,a=typeof s=="object"&&s!==null&&typeof s.lo=="number"&&typeof s.hiExclusive=="number"?{lo:s.lo,hiExclusive:s.hiExclusive}:{lo:o.sourceStart,hiExclusive:o.sourceEnd+1};r.push({id:o.id,commentrayLine:o.commentrayLine,sourceStart:o.sourceStart,sourceEnd:o.sourceEnd,markerViewportHalfOpen1Based:a})}}return r}catch{return[]}}function Nn(n=56){let e=Y(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function zn(n,e=56){let t=Math.max(0,n.scrollHeight-n.clientHeight);return t>0&&n.scrollTop>=t-e}function $n(n){let e=n.getAttribute("data-commentray-line");return e===null||e===""?null:Number(e)}function wn(n,e){let t=[];for(let r of n){let i=$n(r);i!==null&&t.push({line0:i,top:r.getBoundingClientRect().top})}return Vt(t,e)}function Tn(n){let e=n[n.length-1];return e?$n(e)??0:0}function On(n,e="code-line-"){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return 1;if(!M(n)){if(Nn()){let u=t[t.length-1],h=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return h?Number(h[1])+1:t.length}let o=n.getBoundingClientRect(),s=globalThis.innerHeight,a=Math.max(0,o.top),c=Math.min(s,o.bottom),l=a+Math.max(2,Math.min(40,(c-a)*.15));for(let u of t)if(u.getBoundingClientRect().bottom>l-.001){let d=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return d?Number(d[1])+1:1}return t.length}if(zn(n)){let o=t[t.length-1],s=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return s?Number(s[1])+1:t.length}let i=n.getBoundingClientRect().top+n.clientTop+2;for(let o of t)if(o.getBoundingClientRect().bottom>i-.001){let a=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return a?Number(a[1])+1:1}return t.length}function Ft(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return 0;if(!M(n)){if(Nn())return Tn(e);let i=n.getBoundingClientRect(),o=globalThis.innerHeight,s=Math.max(0,i.top),a=Math.min(o,i.bottom),c=s+Math.max(2,Math.min(40,(a-s)*.15));return wn(e,c)}if(zn(n))return Tn(e);let r=n.getBoundingClientRect().top+n.clientTop+Math.max(2,Math.min(40,n.clientHeight*.15));return wn(e,r)}function qn(){let n=document.getElementById("shell");return n instanceof HTMLElement?n.getAttribute("data-page-breaks-enabled")==="true":!1}function kr(n){if(!M(n)){let t=n.getBoundingClientRect(),r=globalThis.innerHeight,i=Math.max(0,t.top),o=Math.min(r,t.bottom);return i+Math.max(2,Math.min(40,(o-i)*.15))}return n.getBoundingClientRect().top+n.clientTop+2}function Hr(n){if(!qn())return null;let e=kr(n),t=Array.from(n.querySelectorAll(".commentray-page-break[data-next-source-start]"));for(let r of t){let i=r.getAttribute("data-next-source-start");if(!i)continue;let o=Number.parseInt(i,10);if(!Number.isFinite(o)||o<=0)continue;let s=r.getBoundingClientRect().top,a=r.getAttribute("data-next-commentray-line"),c=a?Number.parseInt(a,10):Number.NaN,l=Number.isFinite(c)&&c>=0?n.querySelector(`[data-commentray-line="${String(c)}"]`):null,u=l?l.getBoundingClientRect().top:s+r.clientHeight;if(!(s<=e&&e<u))continue;let h=Math.max(1,u-s),d=v((e-s)/h,0,1),m=globalThis.matchMedia("(max-width: 767px)").matches?.2:.35;return d<m?null:o-1}return null}function vn(n){n.n++,queueMicrotask(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.n=Math.max(0,n.n-1)})})})}function Wn(n,e,t,r){let i="none",o={n:0},s={n:0};n.addEventListener("scroll",()=>{if(o.n>0){o.n--;return}i!=="doc"&&(i="code",vn(s),t(),i="none")},{passive:!0}),e.addEventListener("scroll",()=>{if(s.n>0){s.n--;return}i!=="code"&&(i="doc",vn(o),r(),i="none")},{passive:!0})}function Mn(n,e,t,r,i){let o=null,s=null,a=()=>{Ae(n,e,fn(n,e,t,r()))},c=()=>{Ce(n,e,mn(e,t),r())},l=()=>{if(i?.()===!0){o={k:"mirrorW",ratio:ce()};return}o=mn(e,t)},u=()=>{if(!o)return;let f=o;o=null,Ce(n,e,f,r())},h=()=>{s=fn(n,e,t,r())},d=()=>{if(!s)return;let f=s;s=null,Ae(n,e,f)};return Wn(n,e,a,c),{syncFromCodeToDoc:a,syncFromDocToCode:c,prepareMobileFlipToCode:l,finishMobileFlipToCode:u,prepareMobileFlipToDoc:h,finishMobileFlipToDoc:d}}function Cr(n,e){let t=null,r=null,i=()=>{Ae(n,e,pn(n))},o=()=>{Ce(n,e,gn(e))},s=()=>{t=gn(e)},a=()=>{if(!t)return;let u=t;t=null,Ce(n,e,u)},c=()=>{r=pn(n)},l=()=>{if(!r)return;let u=r;r=null,Ae(n,e,u)};return Wn(n,e,i,o),{syncFromCodeToDoc:i,syncFromDocToCode:o,prepareMobileFlipToCode:s,finishMobileFlipToCode:a,prepareMobileFlipToDoc:c,finishMobileFlipToDoc:l}}function Gn(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function En(n){return Gn(n)}function Ar(n,e,t,r){if(e){let a=document.getElementById(`commentray-block-${e.id}`);if(!a)return Gn(t);let c=a.getBoundingClientRect().top-3;if(!r)return c;let l=t.getBoundingClientRect().top+4,u=wt(n,t,a);return Math.min(c,Math.max(l,u))}let o=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];if(s&&(o=Math.min(o,s.getBoundingClientRect().bottom-4)),r){let a=t.getBoundingClientRect().top+4,c=wt(n,t,null);o=Math.min(o,Math.max(a,c))}return o}function Un(n,e){if(!n.startsWith(e))return null;let t=Number.parseInt(n.slice(e.length),10);return Number.isFinite(t)?t:null}function _n(n,e){let t=0,r=n.length-1,i=-1;for(;t<=r;){let o=t+r>>1;(n[o]?.line0??-1)>=e?(i=o,r=o-1):t=o+1}return i>=0?n[i]?.el??null:null}function Br(n,e){let t=0,r=n.length-1,i=-1;for(;t<=r;){let o=t+r>>1;(n[o]?.line0??-1)<=e?(i=o,t=o+1):r=o-1}return i>=0?n[i]?.el??null:null}function Pr(n){return Array.from(document.querySelectorAll(`[id^="${n}"]`)).map(e=>({line0:Un(e.id,n),el:e})).filter(e=>e.line0!==null).sort((e,t)=>e.line0-t.line0)}function Ir(n,e,t,r){let i=()=>r();e.addEventListener("scroll",i,{passive:!0}),t.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i);let o=new ResizeObserver(i);o.observe(n),o.observe(e),o.observe(t);let s=n.parentElement;s&&o.observe(s)}function Rr(n,e,t,r,i,o){let s=Ut(r()),a=we(s),c=e.getBoundingClientRect(),l=c.width,u=c.height;if(l<=0||u<=0||a.length===0){n.replaceChildren();return}let h=t.querySelector(".commentray-block-anchor")!==null?Yt(s,Ft(t)):jt(s,i()),d=qn();n.setAttribute("viewBox",`0 0 ${String(l)} ${String(u)}`),n.setAttribute("preserveAspectRatio","none");let f=[],m=Array.from(document.querySelectorAll(`[id^="${o}"]`)).map(g=>({line0:Un(g.id,o),el:g})).filter(g=>g.line0!==null).sort((g,p)=>g.line0-p.line0);for(let g=0;g<a.length;g++){let p=a[g];if(!p)continue;let S=Qt(s,p),E=bt(p.sourceStart),P=bt(p.sourceEnd),k=document.getElementById(`${o}${String(E)}`)??_n(m,E),C=document.getElementById(`${o}${String(P)}`)??Br(m,P),T=document.getElementById(`commentray-block-${p.id}`);if(!k||!C||!T)continue;let L=Ar(t,S,T,d),G=En(k),le=En(C),U=T.getBoundingClientRect().top+2,A=Math.max(L,U+4),V=oe(G,c.top,u),$t=oe(U,c.top,u),Ot=oe(le,c.top,u),qt=oe(A,c.top,u),Re=p.id===h?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",Wt=`${Re} gutter__rays-path--trail`,De=yt(0,V.y,l,$t.y,{tension:.38,clipStart:V.clipped,clipEnd:$t.clipped}),Fe=yt(0,Ot.y,l,qt.y,{tension:.38,clipStart:Ot.clipped,clipEnd:qt.clipped}),Jn=De.dotted?`<path class="${Wt}" d="${De.dotted}" />`:"",Xn=Fe.dotted?`<path class="${Wt}" d="${Fe.dotted}" />`:"";f.push(`<g class="gutter__rays-block" data-commentray-block="${x(p.id)}"><path class="${Re}" d="${De.solid}" />`+Jn+`<path class="${Re}" d="${Fe.solid}" />`+Xn+"</g>")}n.innerHTML=f.join("")}function Dr(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:i,probeTopSourceLine1Based:o}=n,s=n.sourceLineIdPrefix??(()=>"code-line-"),a="http://www.w3.org/2000/svg",c=document.createElement("div");c.className="gutter__rays",c.setAttribute("aria-hidden","true");let l=document.createElementNS(a,"svg");c.appendChild(l),e.appendChild(c);let u=0;function h(){u===0&&(u=globalThis.requestAnimationFrame(()=>{u=0,Rr(l,e,r,i,o,s())}))}return Ir(e,t,r,h),h(),globalThis.requestAnimationFrame(()=>{h(),globalThis.requestAnimationFrame(h)}),h}function Fr(n){if(typeof n!="object"||n===null)return!1;let e=n;if(typeof e.sourcePath!="string"||typeof e.commentrayPath!="string"||e.staticBrowseUrl!==void 0&&typeof e.staticBrowseUrl!="string")return!1;let t=e.sourceOnGithub,r=e.commentrayOnGithub,i=typeof t=="string";return!(i!==(typeof r=="string")||!(typeof e.staticBrowseUrl=="string"&&e.staticBrowseUrl.trim().length>0)&&!i)}function Nt(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)Fr(t)&&e.push(t);return e}function Nr(n){if(n.kind!=="commentrayLine"||typeof n.line!="number"||typeof n.text!="string")return null;let e=typeof n.sourcePath=="string"?n.sourcePath:"",t=typeof n.commentrayPath=="string"?n.commentrayPath:"";return{kind:"md",line:n.line,text:n.text,spPath:e,crPath:t}}function zr(n,e){if(n.kind!=="sourcePath"&&n.kind!=="commentrayPath")return null;let t=typeof n.sourcePath=="string"?n.sourcePath:"",r=typeof n.commentrayPath=="string"?n.commentrayPath:"",i=n.kind==="sourcePath"?t:r;return i?{kind:"path",line:e,text:i,spPath:t,crPath:r}:null}function $r(n){if(!n||typeof n!="object")return[];let e=n.rows;if(!Array.isArray(e))return[];let t=[],r=0;for(let i of e){if(!i||typeof i!="object")continue;let o=i,s=Nr(o);if(s){t.push(s);continue}let a=zr(o,r);a&&(t.push(a),r+=1)}return t}function Qn(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(D(e));return Nt(t)}catch{return[]}}function Or(n,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=n;for(let i=0;i<t.length;i++){let o=t[i];if(o===void 0)continue;r.children.has(o)||r.children.set(o,{children:new Map,pairs:[]});let s=r.children.get(o);if(s===void 0)return;i===t.length-1&&s.pairs.push(e),r=s}}function qr(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Wr(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function Gr(n,e){let t=qr(n.sourcePath);if(!e)return t;let r=Wr(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function Ur(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return q(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function _r(n){return(n.staticBrowseUrl??"").trim().length>0?`${n.sourcePath} \u2014 open this pair in the site viewer`:(n.commentrayOnGithub??"").trim().length>0?`${n.sourcePath} \u2014 open companion commentray on the repository host`:n.sourcePath}function Qr(n){for(let e of n.querySelectorAll("a.tree-file-link"))e instanceof HTMLAnchorElement&&(e.classList.remove("tree-file-link--current"),e.removeAttribute("aria-current"))}function jr(n,e,t){for(let r of n.querySelectorAll("a.tree-file-link")){if(!(r instanceof HTMLAnchorElement))continue;let i=r.getAttribute("data-pair-source-path")?.trim()??"",o=r.getAttribute("data-pair-commentray-path")?.trim()??"";if(Et({sourcePath:i,commentrayPath:o},e,t)){r.classList.add("tree-file-link--current"),r.setAttribute("aria-current","page");break}}}function jn(){let n=document.getElementById("shell"),e=document.getElementById("documented-files-tree");if(!(n instanceof HTMLElement)||!(e instanceof HTMLElement))return;Qr(e);let t=n.getAttribute("data-commentray-pair-source-path")?.trim()??"",r=n.getAttribute("data-commentray-pair-commentray-path")?.trim()??"";t.length===0||r.length===0||jr(e,t,r)}function Yn(n){let e=[...n.children.keys()].sort((r,i)=>r.localeCompare(i));if(e.length===0)return"";let t=[];for(let r of e){let i=n.children.get(r);if(i!==void 0){if(i.children.size>0){let o=Yn(i);t.push(`<li><div class="tree-dir">${x(r)}</div>${o}</li>`)}if(i.pairs.length>0){let o=i.pairs.length>1;for(let s of i.pairs){let a=x(Gr(s,o)),c=x(_r(s)),l=x(Ur(s)),u=x(w(s.sourcePath)),h=x(w(s.commentrayPath)),f=(s.staticBrowseUrl?.trim()??"").length>0?"":' target="_blank" rel="noopener noreferrer"';t.push(`<li><div class="tree-file"><a class="tree-file-link" href="${l}" data-pair-source-path="${u}" data-pair-commentray-path="${h}"${f} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function Yr(n,e,t){if(e.length===0){n.innerHTML=t?'<p class="nav-rail__doc-hub-hint" role="status">No paths match this filter.</p>':'<p class="nav-rail__doc-hub-hint" role="status">No documented pairs in this export.</p>';return}let r={children:new Map,pairs:[]};for(let i of e)Or(r,i);n.innerHTML=Yn(r),jn()}function Vr(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=Qn(e),t.length>0))return;if(n.length===0){t=[];return}let i=await fetch(n,{credentials:"same-origin"});if(!i.ok)throw new Error(`nav json ${String(i.status)}`);let o=await i.json();t=Nt(o.documentedPairs)})()),await r,t??[])}function Kr(n){let e=n.querySelector(".nav-rail__doc-hub-inner");if(!(e instanceof HTMLElement))return()=>{};let t=e,r=globalThis.matchMedia("(max-width: 767px)");function i(){let s=n.querySelector("summary");return s instanceof HTMLElement?s:null}function o(){if(!n.open||!r.matches){t.style.removeProperty("position"),t.style.removeProperty("top"),t.style.removeProperty("left"),t.style.removeProperty("right"),t.style.removeProperty("width"),t.style.removeProperty("max-width"),t.style.removeProperty("max-height"),t.style.removeProperty("z-index");return}let s=i();if(!s)return;let a=s.getBoundingClientRect(),c=8;t.style.position="fixed",t.style.top=`${String(Math.round(a.bottom+4))}px`,t.style.left=`${String(Math.round(c))}px`,t.style.right=`${String(Math.round(c))}px`,t.style.width="auto",t.style.maxWidth="none",t.style.maxHeight="min(52vh, 400px)",t.style.zIndex="200"}return r.addEventListener("change",o),globalThis.addEventListener("resize",o),globalThis.addEventListener("scroll",o,!0),o}function Jr(){let n=document.getElementById("documented-files-filter");n instanceof HTMLInputElement&&n.focus({preventScroll:!0})}function Xr(){let n=document.getElementById("documented-files-hub"),e=document.getElementById("documented-files-tree"),t=document.getElementById("documented-files-filter"),r=document.getElementById("shell");if(!(n instanceof HTMLDetailsElement)||!(e instanceof HTMLElement))return;let i=n,o=e,s=i.getAttribute("data-nav-json-url")?.trim()??"",a=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&a.length===0)return;let c=Kr(i),l=Vr(s,a),u=null;function h(){if(u===null)return;let m=t instanceof HTMLInputElement?t.value:"",g=en(u,m),p=m.trim().length>0;Yr(o,g,p&&u.length>0&&g.length===0)}async function d(){try{u=await l(),h()}catch{u=null,o.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}i.addEventListener("toggle",()=>{c(),i.open&&globalThis.requestAnimationFrame(()=>{c(),Jr()}),i.open&&d()});function f(m){if(!i.open||m.key!=="Escape")return;m.preventDefault(),i.open=!1;let g=i.querySelector("summary");g instanceof HTMLElement&&g.focus({preventScroll:!0})}document.addEventListener("keydown",f,!0),o.addEventListener("keydown",m=>{if(!i.open||m.isComposing)return;let g=m.target;if(!(g instanceof HTMLAnchorElement)||!g.classList.contains("tree-file-link"))return;let p=Sn(o);if(p.length===0)return;let S=p.indexOf(g);if(!(S<0)){if(m.key==="ArrowDown"){S<p.length-1&&(p[S+1].focus({preventScroll:!0}),m.preventDefault());return}if(m.key==="ArrowUp"){if(S>0){p[S-1].focus({preventScroll:!0}),m.preventDefault();return}t instanceof HTMLInputElement&&(t.focus({preventScroll:!0}),m.preventDefault())}}}),t instanceof HTMLInputElement&&(t.addEventListener("input",()=>{!i.open||u===null||h()}),t.addEventListener("keydown",m=>{if(!i.open||m.isComposing||m.key!=="ArrowDown")return;let g=Sn(o);g.length!==0&&(g[0].focus({preventScroll:!0}),m.preventDefault())}))}function Zr(n,e,t,r,i){let o=!1,s=i;function a(l){if(!o)return;let u=e.getBoundingClientRect(),h=l.clientX-u.left,d=v(h/u.width*100,15,85);s=d,t.style.flex=`0 0 ${d}%`,e.style.setProperty("--split-pct",`${String(d)}%`)}function c(){o=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect="",B(localStorage,n,String(s))}r.addEventListener("mousedown",l=>{l.preventDefault(),o=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var Ln="commentray.codeCommentrayStatic.splitPct",Vn="commentray.codeCommentrayStatic.wrap",xn="commentray.codeCommentrayStatic.dualMobilePane",ei="commentray.codeCommentrayStatic.sourceMarkdownPaneMode",ti="commentray.codeCommentrayStatic.pageBreaksEnabled",zt="(max-width: 767px)";function Rt(n){return n==="code"?"code":"doc"}function Kn(){return globalThis.matchMedia(zt).matches}function ni(n){let e=document.getElementById("commentray-help-tour");e instanceof HTMLButtonElement&&e.addEventListener("click",()=>{Ct(n,Kn,{force:!0})})}function W(n){return n.getAttribute("data-source-pane-mode")==="rendered-markdown"?"rendered-markdown":"source"}function ri(n){let e=(n??"").trim().toLowerCase();return!(e==="0"||e==="false"||e==="off")}function ii(n){let e=ri(F(localStorage,ti));n.setAttribute("data-page-breaks-enabled",e?"true":"false")}function oi(n){let e=()=>{let t=Math.max(globalThis.innerHeight,document.documentElement?.clientHeight??0);if(!Number.isFinite(t)||t<=0)return;let r=Math.round(v(t*.72,260,820));n.style.setProperty("--commentray-page-break-min-height",`${String(r)}px`)};globalThis.addEventListener("resize",e,{passive:!0}),globalThis.addEventListener("orientationchange",e,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",e,{passive:!0}),e()}function kn(n){let e=document.querySelector("label.toolbar-wrap-lines");e instanceof HTMLLabelElement&&(e.hidden=W(n)==="rendered-markdown")}function Be(n){return W(n)==="rendered-markdown"?"code-md-line-":"code-line-"}function si(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||Rt(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&Ie(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function ai(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},i=()=>{e.hidden=!1,e.classList.add("is-visible")},o=()=>{if(!t.matches){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?i():r()};globalThis.addEventListener("scroll",o,{passive:!0}),globalThis.addEventListener("resize",o,{passive:!0}),t.addEventListener("change",o),globalThis.requestAnimationFrame(o)}function ci(n,e){let t=()=>{e.hidden=!0,e.classList.remove("is-visible")},r=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{let o=n.getBoundingClientRect(),s=globalThis.innerHeight,a=10;o.bottom<a||o.top>s-a?r():t()};globalThis.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i,{passive:!0}),globalThis.requestAnimationFrame(i)}function li(n,e){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return null;let r=M(n)?n.getBoundingClientRect().top+n.clientTop+2:Math.max(0,n.getBoundingClientRect().top)+2;for(let s of t)if(s.getBoundingClientRect().bottom>r-.001){let c=/^(?:code-line-|code-md-line-)(\d+)$/.exec(s.id);return c?.[1]?Number.parseInt(c[1],10):null}let i=t[t.length-1];if(!i)return null;let o=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return o?.[1]?Number.parseInt(o[1],10):null}function ui(n,e,t,r,i){function o(){let c=W(n)==="rendered-markdown",u=`Switch source pane to ${c?"markdown source":"rendered markdown"}`,h=`Source pane: ${c?"rendered markdown":"markdown source"} (click to switch)`,d=f=>{f instanceof HTMLButtonElement&&(f.setAttribute("aria-pressed",c?"true":"false"),f.setAttribute("aria-label",u),f.title=h)};d(t),d(r)}n.setAttribute("data-source-pane-mode","rendered-markdown"),o(),kn(n);let s=()=>{let a=W(n),l=li(e,a==="rendered-markdown"?"code-md-line-":"code-line-"),u=a==="rendered-markdown"?"source":"rendered-markdown",h=u==="rendered-markdown"?"code-md-line-":"code-line-";if(n.setAttribute("data-source-pane-mode",u),B(localStorage,ei,u),o(),kn(n),l!==null){let d=e.querySelector(`#${h}${String(l)}`);d instanceof HTMLElement&&Dt(e,d,2)}if(u==="rendered-markdown"){let d=document.getElementById("code-pane-markdown-body");d instanceof HTMLElement&&(Ie(d),Pe(d))}i?.()};t.addEventListener("click",s),r&&(r.addEventListener("click",s),ci(t,r))}function hi(n,e,t,r){let i=globalThis.matchMedia(zt);function o(){return Rt(F(localStorage,xn))}function s(){i.matches?n.setAttribute("data-dual-mobile-pane",o()):n.removeAttribute("data-dual-mobile-pane")}let a=()=>{if(!i.matches)return;let l=Rt(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code",u=Y().scrollTop;l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),B(localStorage,xn,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{if(l==="code"){t.finishMobileFlipToCode();let h=Y();if(u>5&&h.scrollTop<=1){let d=Math.max(0,h.scrollHeight-h.clientHeight);h.scrollTop=v(u,0,d)}}else t.finishMobileFlipToDoc()})}),l==="doc"&&si(n,i)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),ai(e,r,i)),i.addEventListener("change",s),s()}function di(n){let e=document.getElementById("wrap-lines");e&&Dn(Vn,n,e,()=>{globalThis.dispatchEvent(new Event("resize"))})}function mi(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(D(e));if(!t||!Array.isArray(t.angles)||t.angles.length<2)return null;for(let r of t.angles)if(typeof r.id!="string"||typeof r.docInnerHtmlB64!="string")return null;return t}catch{return null}}function fi(){let n=document.getElementById("doc-pane"),e=document.getElementById("gutter"),t=document.getElementById("wrap-lines"),r=document.getElementById("search-q"),i=document.getElementById("search-clear"),o=document.getElementById("search-results");if(!n||!e||!t||!r||!i||!o)return null;let s=document.getElementById("doc-pane-body"),a=s instanceof HTMLElement?s:n;return{docBody:s,docScrollEl:a,gutter:e,wrapCb:t,searchInput:r,searchClear:i,searchResults:o}}function gi(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:i,pathRowsForOrdering:o,rawMd:s,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return yn(e,t,s,r,a);if(i.length>0)return i;let c=o.length>0?o:yn(e,t,s,r,a).filter(u=>u.kind==="path"),l=s.split(`
20
- `).map((u,h)=>({kind:"md",line:h,text:u,spPath:r,crPath:a}));return[...c,...l]}function pi(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let i=Qn(n.getAttribute("data-documented-pairs-b64")?.trim()??""),o=tn(i),s=o.length>0?o.map(a=>a.text).join(`
19
+ `),a=[];return n==="commentray-and-paths"&&(r.trim()&&a.push({kind:"path",line:a.length,text:r}),o.trim()&&a.push({kind:"path",line:a.length,text:o})),[...n==="full"?s.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...i.map((c,l)=>({kind:"md",line:l,text:c}))]}function lr(n){let e=De.createDefaultSearcher();return e.indexEntities(n,t=>t.kind==="md"&&t.crPath?`md:${t.crPath}:${t.line}`:t.kind==="path"?`path:${t.spPath??""}|${t.crPath??""}|${t.line}|${t.text.slice(0,120)}`:`${t.kind}:${t.line}`,t=>[t.text]),e}function hi(n,e){let t=n;for(;t;){if(t.classList?.contains("hit"))return t;if(t===e)return null;t=t.parentElement}return null}function dn(n){return[...n.querySelectorAll("button.hit")].filter(e=>e instanceof HTMLButtonElement)}function ur(n){return[...n.querySelectorAll("a.tree-file-link")].filter(e=>e instanceof HTMLAnchorElement)}function mi(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function fi(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),o=Vt(e.mutable.documentedPairs,t,r);if(o&&Ut(o,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}o&&Dr(o,null)}function pi(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),o=e.trim();if(o.length>0&&k(o)!==k(r)){let i=Vt(t.mutable.documentedPairs,o,"");if(i){Dr(i,n);return}return}Rr(t.docScrollEl,n,t.mutable.mdLines.length)}function Fr(n,e){let t=n.getAttribute("data-kind"),r=parseInt(n.getAttribute("data-line")||"0",10),o=n.getAttribute("data-cr-path")?.trim()??"";if(t==="code"){mi(r);return}if(t==="path"){fi(n,e);return}pi(r,o,e)}function gi(n,e,t){let r={currentCommentrayPath:t.commentrayPathLabel,currentSourcePath:e};if(n==="full"){let l=e.trim();if(l.length===0)return null;let u=[{sourcePath:l,commentrayPath:t.commentrayPathLabel.trim()}],d=rn("full",u.length,u.length,!1);return on(d,u,r)}let{rows:o,totalUnique:i}=On(t.documentedPairs);if(o.length>0){let l=rn("commentray-and-paths",o.length,i,!1);return on(l,o,r)}let s=e.trim();if(s.length===0)return null;let a=[{sourcePath:s,commentrayPath:t.commentrayPathLabel.trim()}],c=rn("commentray-and-paths",a.length,a.length,!0);return on(c,a,r)}function yi(n,e){n.addEventListener("keydown",t=>{if(t.isComposing||n.hidden)return;let r=dn(n);if(r.length===0)return;let o=document.activeElement;if(!(o instanceof HTMLButtonElement)||!o.classList.contains("hit"))return;let i=r.indexOf(o);if(!(i<0)){if(t.key==="ArrowDown"&&i<r.length-1){r[i+1].focus({preventScroll:!0}),t.preventDefault();return}if(t.key==="ArrowUp"){if(i>0){r[i-1].focus({preventScroll:!0}),t.preventDefault();return}e.focus({preventScroll:!0}),t.preventDefault()}}})}function bi(n,e,t){let{renderEmptyBrowsePreview:r,runSearch:o,cancelDebounceTimer:i,hitClickDeps:s}=t;n.addEventListener("keydown",a=>{if(a.isComposing)return;if(a.key==="ArrowDown"){if(!e.hidden){let l=dn(e);if(l.length>0&&document.activeElement===n){l[0].focus({preventScroll:!0}),a.preventDefault();return}}if(ye(n.value).length>0)return;r(),a.preventDefault();return}if(a.key!=="Enter")return;i(),ye(n.value).length>0&&o();let c=dn(e);!e.hidden&&c.length>0&&document.activeElement===n&&(a.preventDefault(),Fr(c[0],s))})}function Nr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:o,searchInput:i,searchClear:s,searchResults:a,docScrollEl:c}=n,l;function u(){clearTimeout(l),l=void 0}function d(){u(),i.value="",a.innerHTML="",a.hidden=!0}function h(){let f=gi(e,t,r);f!==null&&(a.hidden=!1,a.innerHTML=f)}function p(){let f=ye(i.value);if(f.length===0){a.hidden=!0,a.innerHTML="";return}let g=ai({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:o,rawMd:r.rawMd,searcher:r.searcher,queryRaw:i.value,tokens:f,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=ui(e,g,f,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let m={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",f=>{let g=hi(f.target,a);g&&Fr(g,m)}),yi(a,i),i.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(p,200)}),bi(i,a,{renderEmptyBrowsePreview:h,runSearch:p,cancelDebounceTimer:u,hitClickDeps:m}),s.addEventListener("click",d),document.addEventListener("keydown",f=>{if(f.key!=="Escape")return;let g=i.value.trim().length>0,S=document.activeElement===i,b=!a.hidden;!g&&!S&&!b||(d(),S&&i.blur(),f.preventDefault())})}function Or(n,e,t,r,...o){let i=o.filter(a=>a instanceof HTMLElement),s=D(localStorage,n)==="1";if(t.checked=s,s){e.classList.add("wrap");for(let a of i)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of i)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of i)a.classList.add("wrap");A(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of i)a.classList.remove("wrap");A(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function _r(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(R(e));if(!Array.isArray(t))return[];let r=[];for(let o of t){if(typeof o!="object"||o===null)continue;let i=o;if(typeof i.id=="string"&&typeof i.commentrayLine=="number"&&typeof i.sourceStart=="number"&&typeof i.sourceEnd=="number"){let s=i.markerViewportHalfOpen1Based,a=typeof s=="object"&&s!==null&&typeof s.lo=="number"&&typeof s.hiExclusive=="number"?{lo:s.lo,hiExclusive:s.hiExclusive}:{lo:i.sourceStart,hiExclusive:i.sourceEnd+1};r.push({id:i.id,commentrayLine:i.commentrayLine,sourceStart:i.sourceStart,sourceEnd:i.sourceEnd,markerViewportHalfOpen1Based:a})}}return r}catch{return[]}}function zr(n=64){let e=$(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function $r(n,e=64){let t=Math.max(0,n.scrollHeight-n.clientHeight);return t>0&&n.scrollTop>=t-e}function qr(n){let e=n.getAttribute("data-commentray-line");return e===null||e===""?null:Number(e)}function dr(n,e){let t=[];for(let r of n){let o=qr(r);o!==null&&t.push({line0:o,top:r.getBoundingClientRect().top})}return Bn(t,e)}function hr(n){for(let e=n.length-1;e>=0;e--){let t=n.item(e);if(!t)continue;let r=qr(t);if(r!==null)return r}return null}function Gr(n,e="code-line-"){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return 1;if(!M(n)){if(zr()){let u=t[t.length-1],d=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return d?Number(d[1])+1:t.length}let i=n.getBoundingClientRect(),s=globalThis.innerHeight,a=Math.max(0,i.top),c=Math.min(s,i.bottom),l=a+Q(c-a);for(let u of t)if(u.getBoundingClientRect().bottom>l-.001){let h=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return h?Number(h[1])+1:1}return t.length}if($r(n)){let i=t[t.length-1],s=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return s?Number(s[1])+1:t.length}let o=n.getBoundingClientRect().top+n.clientTop+Q(n.clientHeight);for(let i of t)if(i.getBoundingClientRect().bottom>o-.001){let a=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return a?Number(a[1])+1:1}return t.length}function pn(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return null;if(!M(n)){if(zr()){let l=hr(e);if(l!==null)return l}let o=n.getBoundingClientRect(),i=globalThis.innerHeight,s=Math.max(0,o.top),a=Math.min(i,o.bottom),c=s+Q(a-s);return dr(e,c)}if($r(n)){let o=hr(e);if(o!==null)return o}let r=n.getBoundingClientRect().top+n.clientTop+Q(n.clientHeight);return dr(e,r)}function Wr(){let n=document.getElementById("shell");return n instanceof HTMLElement?n.getAttribute("data-page-breaks-enabled")==="true":!1}function Si(n){if(!M(n)){let t=n.getBoundingClientRect(),r=globalThis.innerHeight,o=Math.max(0,t.top),i=Math.min(r,t.bottom);return o+Q(i-o)}return n.getBoundingClientRect().top+n.clientTop+Q(n.clientHeight)}function Ti(n){if(!Wr())return null;let e=Si(n),t=Array.from(n.querySelectorAll(".commentray-page-break[data-next-source-viewport-line]"));for(let r of t){let o=r.getAttribute("data-next-source-viewport-line");if(!o)continue;let i=Number.parseInt(o,10);if(!Number.isFinite(i)||i<=0)continue;let s=r.getBoundingClientRect().top,a=r.getAttribute("data-next-commentray-line"),c=a?Number.parseInt(a,10):Number.NaN,l=Number.isFinite(c)&&c>=0?n.querySelector(`[data-commentray-line="${String(c)}"]`):null,u=l?l.getBoundingClientRect().top:s+r.clientHeight;if(!(s<=e&&e<u))continue;let d=Math.max(1,u-s),h=L((e-s)/d,0,1),m=globalThis.matchMedia("(max-width: 767px)").matches?.2:.35;return h<m?null:i-1}return null}var wi=Math.max(320,1050);function vi(n){let e=performance.now()+wi;n.until=Math.max(n.until,e)}function Vr(n){return performance.now()<n.until}var Ei=200;function Li(n,e,t,r){let o=performance.now();!fn()||o-e.lastEchoSkipTraceAt<Ei||(e.lastEchoSkipTraceAt=o,T(`wire.${n}.flush-skipped`,{reason:"partner-echo",echoUntilMs:Math.round(t.until),[`${n}ScrollTop`]:r.scrollTop}))}function mr(n){let{axis:e,driverPane:t,state:r,syncingRef:o,ownEchoGate:i,partnerEchoGate:s,syncFromDriver:a}=n;return()=>{if(r.pendingRaf=0,Vr(i)){Li(e,r,i,t),r.lastSeenTop=t.scrollTop;return}if(o.current!=="none"){T(`wire.${e}.flush-skipped`,{reason:"sync-in-progress",syncing:o.current});return}let c=t.scrollTop,l=c-r.lastSeenTop;r.lastSeenTop=c,o.current=e,vi(s),T(`wire.${e}.driver`,{delta:l,[`${e}ScrollTop`]:c}),a(l),o.current="none"}}function fr(n){let{driverPane:e,state:t,syncingRef:r,ownEchoGate:o,flush:i}=n;e.addEventListener("scroll",()=>{if(Vr(o)){t.lastSeenTop=e.scrollTop,t.pendingRaf!==0&&(cancelAnimationFrame(t.pendingRaf),t.pendingRaf=0);return}if(r.current!=="none"){t.lastSeenTop=e.scrollTop;return}t.pendingRaf!==0&&cancelAnimationFrame(t.pendingRaf),t.pendingRaf=requestAnimationFrame(i)},{passive:!0})}function Ur(n,e,t,r){let o={current:"none"},i={until:0},s={until:0},a={lastSeenTop:n.scrollTop,pendingRaf:0,lastEchoSkipTraceAt:-1/0},c={lastSeenTop:e.scrollTop,pendingRaf:0,lastEchoSkipTraceAt:-1/0},l=mr({axis:"code",driverPane:n,state:a,syncingRef:o,ownEchoGate:i,partnerEchoGate:s,syncFromDriver:t}),u=mr({axis:"doc",driverPane:e,state:c,syncingRef:o,ownEchoGate:s,partnerEchoGate:i,syncFromDriver:r});fr({driverPane:n,state:a,syncingRef:o,ownEchoGate:i,flush:l}),fr({driverPane:e,state:c,syncingRef:o,ownEchoGate:s,flush:u})}function pr(n,e){let{codePane:t,docPane:r,getLinks:o,lineIdPrefix:i,sticky:s}=n,a=_(r),c=i(),l=Ir(t,r,o,c,s,n.allowProportionalMirror);Je(t,r,l);let u=_(r);T("code\u2192doc.apply",{driverDelta:e,lineIdPrefix:c,plan:ie(l),docScrollTopBefore:a,docScrollTopAfter:u,docDelta:u-a,codeScrollTop:t.scrollTop}),je({driverDelta:e,partnerBefore:a,partnerPane:r,axis:"code\u2192doc"})}function gr(n,e){let{codePane:t,docPane:r,getLinks:o,lineIdPrefix:i,sticky:s}=n,a=_(t),c=i(),l=Br(r,t,o,s,c,n.allowProportionalMirror);Xe(t,r,l,c);let u=_(t);T("doc\u2192code.apply",{driverDelta:e,lineIdPrefix:c,plan:oe(l),codeScrollTopBefore:a,codeScrollTopAfter:u,codeDelta:u-a,docScrollTop:r.scrollTop}),je({driverDelta:e,partnerBefore:a,partnerPane:t,axis:"doc\u2192code"})}function sn(n,e,t,r,o,i){let s=i?.allowProportionalMirror!==!1,a=null,c=null,l={sourceSticky:{lockedId:null},commentraySticky:{lockedId:null},linksKey:{current:""}},u={codePane:n,docPane:e,getLinks:t,lineIdPrefix:r,sticky:l,allowProportionalMirror:s},d=y=>pr(u,y),h=y=>gr(u,y),p=()=>{pr(u,0)},m=()=>{gr(u,0)},f=()=>{if(s&&o?.()===!0){a={k:"mirrorW",ratio:Le()};return}a=Br(e,n,t,l,r(),s)},g=()=>{if(!a)return;let y=a;a=null,y.k==="noop"&&y.skipProportionalFallbackOnFlip!==!0&&s&&(y=ln(e)),Xe(n,e,y,r())},S=()=>{c=Ir(n,e,t,r(),l,s)},b=()=>{if(!c)return;let y=c;c=null,y.k==="noop"&&s&&(y=un(n)),Je(n,e,y)};return Ur(n,e,d,h),{syncFromCodeToDoc:p,syncFromDocToCode:m,prepareMobileFlipToCode:f,finishMobileFlipToCode:g,prepareMobileFlipToDoc:S,finishMobileFlipToDoc:b}}function Mi(n,e){let t=null,r=null,o=h=>{let p=_(e),m=un(n);Je(n,e,m),T("code\u2192doc.apply",{mode:"proportional-shell",driverDelta:h,plan:ie(m),docScrollTopBefore:p,docScrollTopAfter:_(e),codeScrollTop:n.scrollTop}),je({driverDelta:h,partnerBefore:p,partnerPane:e,axis:"code\u2192doc"})},i=h=>{let p=_(n),m=ln(e);Xe(n,e,m),T("doc\u2192code.apply",{mode:"proportional-shell",driverDelta:h,plan:oe(m),codeScrollTopBefore:p,codeScrollTopAfter:_(n),docScrollTop:e.scrollTop}),je({driverDelta:h,partnerBefore:p,partnerPane:n,axis:"doc\u2192code"})},s=()=>{o(0)},a=()=>{i(0)},c=()=>{t=ln(e)},l=()=>{if(!t)return;let h=t;t=null,Xe(n,e,h)},u=()=>{r=un(n)},d=()=>{if(!r)return;let h=r;r=null,Je(n,e,h)};return Ur(n,e,o,i),{syncFromCodeToDoc:s,syncFromDocToCode:a,prepareMobileFlipToCode:c,finishMobileFlipToCode:l,prepareMobileFlipToDoc:u,finishMobileFlipToDoc:d}}function Yr(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function yr(n){return Yr(n)}function ki(n,e,t,r){if(e){let a=document.getElementById(`commentray-block-${e.id}`);if(!a)return Yr(t);let c=a.getBoundingClientRect().top-3;return r?An(n,t,a):c}let i=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];if(s&&(i=Math.min(i,s.getBoundingClientRect().bottom-4)),r){let a=t.getBoundingClientRect().top+4,c=Oe(n,t,null);i=Math.min(i,Math.max(a,c))}return i}function Qr(n,e){if(!n.startsWith(e))return null;let t=Number.parseInt(n.slice(e.length),10);return Number.isFinite(t)?t:null}function jr(n,e){let t=0,r=n.length-1,o=-1;for(;t<=r;){let i=t+r>>1;(n[i]?.line0??-1)>=e?(o=i,r=i-1):t=i+1}return o>=0?n[o]?.el??null:null}function Hi(n,e){let t=0,r=n.length-1,o=-1;for(;t<=r;){let i=t+r>>1;(n[i]?.line0??-1)<=e?(o=i,t=i+1):r=i-1}return o>=0?n[o]?.el??null:null}function xi(n){return Array.from(document.querySelectorAll(`[id^="${n}"]`)).map(e=>({line0:Qr(e.id,n),el:e})).filter(e=>e.line0!==null).sort((e,t)=>e.line0-t.line0)}function Ci(n,e,t,r){let o=()=>r();e.addEventListener("scroll",o,{passive:!0}),t.addEventListener("scroll",o,{passive:!0}),globalThis.addEventListener("resize",o);let i=new ResizeObserver(o);i.observe(n),i.observe(e),i.observe(t);let s=n.parentElement;s&&i.observe(s)}function Ai(n,e,t){let r=pn(e);return e.querySelector(".commentray-block-anchor")!==null&&r!==null?xn(n,r):Hn(n,t())}function Bi(n,e,t,r,o,i){let s=Ln(r()),a=Fe(s),c=e.getBoundingClientRect(),l=c.width,u=c.height;if(l<=0||u<=0||a.length===0){n.replaceChildren();return}let d=Ai(s,t,o),h=Wr();n.setAttribute("viewBox",`0 0 ${String(l)} ${String(u)}`),n.setAttribute("preserveAspectRatio","none");let p=[],m=Array.from(document.querySelectorAll(`[id^="${i}"]`)).map(f=>({line0:Qr(f.id,i),el:f})).filter(f=>f.line0!==null).sort((f,g)=>f.line0-g.line0);for(let f=0;f<a.length;f++){let g=a[f];if(!g)continue;let S=kn(s,g),b=zt(g.sourceStart),y=zt(g.sourceEnd),x=document.getElementById(`${i}${String(b)}`)??jr(m,b),C=document.getElementById(`${i}${String(y)}`)??Hi(m,y),E=document.getElementById(`commentray-block-${g.id}`);if(!x||!C||!E)continue;let H=ki(t,S,E,h),I=yr(x),X=yr(C),J=E.getBoundingClientRect().top+2,F=Math.max(H,J+4),ae=N(I,c.top,u),Sn=N(J,c.top,u),Tn=N(X,c.top,u),wn=N(F,c.top,u),nt=g.id===d?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",vn=`${nt} gutter__rays-path--trail`,rt=ge(0,ae.y,l,Sn.y,{tension:.38,clipStart:ae.clipped,clipEnd:Sn.clipped}),ot=ge(0,Tn.y,l,wn.y,{tension:.38,clipStart:Tn.clipped,clipEnd:wn.clipped}),co=rt.dotted?`<path class="${vn}" d="${rt.dotted}" />`:"",lo=ot.dotted?`<path class="${vn}" d="${ot.dotted}" />`:"";p.push(`<g class="gutter__rays-block" data-commentray-block="${B(g.id)}"><path class="${nt}" d="${rt.solid}" />`+co+`<path class="${nt}" d="${ot.solid}" />`+lo+"</g>")}n.innerHTML=p.join("")}function Ii(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:o,probeTopSourceLine1Based:i}=n,s=n.sourceLineIdPrefix??(()=>"code-line-"),a="http://www.w3.org/2000/svg",c=document.createElement("div");c.className="gutter__rays",c.setAttribute("aria-hidden","true");let l=document.createElementNS(a,"svg");c.appendChild(l),e.appendChild(c);let u=0;function d(){u===0&&(u=globalThis.requestAnimationFrame(()=>{u=0,Bi(l,e,r,o,i,s())}))}return Ci(e,t,r,d),d(),globalThis.requestAnimationFrame(()=>{d(),globalThis.requestAnimationFrame(d)}),d}function Pi(n){if(typeof n!="object"||n===null)return!1;let e=n;if(typeof e.sourcePath!="string"||typeof e.commentrayPath!="string"||e.staticBrowseUrl!==void 0&&typeof e.staticBrowseUrl!="string")return!1;let t=e.sourceOnGithub,r=e.commentrayOnGithub,o=typeof t=="string";return!(o!==(typeof r=="string")||!(typeof e.staticBrowseUrl=="string"&&e.staticBrowseUrl.trim().length>0)&&!o)}function gn(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)Pi(t)&&e.push(t);return e}function Ri(n){if(n.kind!=="commentrayLine"||typeof n.line!="number"||typeof n.text!="string")return null;let e=typeof n.sourcePath=="string"?n.sourcePath:"",t=typeof n.commentrayPath=="string"?n.commentrayPath:"";return{kind:"md",line:n.line,text:n.text,spPath:e,crPath:t}}function Di(n,e){if(n.kind!=="sourcePath"&&n.kind!=="commentrayPath")return null;let t=typeof n.sourcePath=="string"?n.sourcePath:"",r=typeof n.commentrayPath=="string"?n.commentrayPath:"",o=n.kind==="sourcePath"?t:r;return o?{kind:"path",line:e,text:o,spPath:t,crPath:r}:null}function Fi(n){if(!n||typeof n!="object")return[];let e=n.rows;if(!Array.isArray(e))return[];let t=[],r=0;for(let o of e){if(!o||typeof o!="object")continue;let i=o,s=Ri(i);if(s){t.push(s);continue}let a=Di(i,r);a&&(t.push(a),r+=1)}return t}function Kr(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(R(e));return gn(t)}catch{return[]}}function Ni(n,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=n;for(let o=0;o<t.length;o++){let i=t[o];if(i===void 0)continue;r.children.has(i)||r.children.set(i,{children:new Map,pairs:[]});let s=r.children.get(i);if(s===void 0)return;o===t.length-1&&s.pairs.push(e),r=s}}function Oi(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function _i(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function zi(n,e){let t=Oi(n.sourcePath);if(!e)return t;let r=_i(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function $i(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return Y(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function qi(n){return(n.staticBrowseUrl??"").trim().length>0?`${n.sourcePath} \u2014 open this pair in the site viewer`:(n.commentrayOnGithub??"").trim().length>0?`${n.sourcePath} \u2014 open companion commentray on the repository host`:n.sourcePath}function Gi(n){for(let e of n.querySelectorAll("a.tree-file-link"))e instanceof HTMLAnchorElement&&(e.classList.remove("tree-file-link--current"),e.removeAttribute("aria-current"))}function Wi(n,e,t){for(let r of n.querySelectorAll("a.tree-file-link")){if(!(r instanceof HTMLAnchorElement))continue;let o=r.getAttribute("data-pair-source-path")?.trim()??"",i=r.getAttribute("data-pair-commentray-path")?.trim()??"";if(Ut({sourcePath:o,commentrayPath:i},e,t)){r.classList.add("tree-file-link--current"),r.setAttribute("aria-current","page");break}}}function yn(){let n=document.getElementById("shell"),e=document.getElementById("documented-files-tree");if(!(n instanceof HTMLElement)||!(e instanceof HTMLElement))return;Gi(e);let t=n.getAttribute("data-commentray-pair-source-path")?.trim()??"",r=n.getAttribute("data-commentray-pair-commentray-path")?.trim()??"";t.length===0||r.length===0||Wi(e,t,r)}function Xr(n){let e=[...n.children.keys()].sort((r,o)=>r.localeCompare(o));if(e.length===0)return"";let t=[];for(let r of e){let o=n.children.get(r);if(o!==void 0){if(o.children.size>0){let i=Xr(o);t.push(`<li><div class="tree-dir">${B(r)}</div>${i}</li>`)}if(o.pairs.length>0){let i=o.pairs.length>1;for(let s of o.pairs){let a=B(zi(s,i)),c=B(qi(s)),l=B($i(s)),u=B(k(s.sourcePath)),d=B(k(s.commentrayPath)),p=(s.staticBrowseUrl?.trim()??"").length>0?"":' target="_blank" rel="noopener noreferrer"';t.push(`<li><div class="tree-file"><a class="tree-file-link" href="${l}" data-pair-source-path="${u}" data-pair-commentray-path="${d}"${p} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function Vi(n,e,t){if(e.length===0){n.innerHTML=t?'<p class="nav-rail__doc-hub-hint" role="status">No paths match this filter.</p>':'<p class="nav-rail__doc-hub-hint" role="status">No documented pairs in this export.</p>';return}let r={children:new Map,pairs:[]};for(let o of e)Ni(r,o);n.innerHTML=Xr(r),yn()}function Ui(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=Kr(e),t.length>0))return;if(n.length===0){t=[];return}let o=await fetch(n,{credentials:"same-origin"});if(!o.ok)throw new Error(`nav json ${String(o.status)}`);let i=await o.json();t=gn(i.documentedPairs)})()),await r,t??[])}function Yi(n){let e=n.querySelector(".nav-rail__doc-hub-inner");if(!(e instanceof HTMLElement))return()=>{};let t=e,r=globalThis.matchMedia("(max-width: 767px)");function o(){let s=n.querySelector("summary");return s instanceof HTMLElement?s:null}function i(){if(!n.open||!r.matches){t.style.removeProperty("position"),t.style.removeProperty("top"),t.style.removeProperty("left"),t.style.removeProperty("right"),t.style.removeProperty("width"),t.style.removeProperty("max-width"),t.style.removeProperty("max-height"),t.style.removeProperty("z-index");return}let s=o();if(!s)return;let a=s.getBoundingClientRect(),c=8;t.style.position="fixed",t.style.top=`${String(Math.round(a.bottom+4))}px`,t.style.left=`${String(Math.round(c))}px`,t.style.right=`${String(Math.round(c))}px`,t.style.width="auto",t.style.maxWidth="none",t.style.maxHeight="min(52vh, 400px)",t.style.zIndex="200"}return r.addEventListener("change",i),globalThis.addEventListener("resize",i),globalThis.addEventListener("scroll",i,!0),i}function Qi(){let n=document.getElementById("documented-files-filter");n instanceof HTMLInputElement&&n.focus({preventScroll:!0})}function ji(){let n=document.getElementById("documented-files-hub"),e=document.getElementById("documented-files-tree"),t=document.getElementById("documented-files-filter"),r=document.getElementById("shell");if(!(n instanceof HTMLDetailsElement)||!(e instanceof HTMLElement))return;let o=n,i=e,s=o.getAttribute("data-nav-json-url")?.trim()??"",a=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&a.length===0)return;let c=Yi(o),l=Ui(s,a),u=null;function d(){if(u===null)return;let m=t instanceof HTMLInputElement?t.value:"",f=Fn(u,m),g=m.trim().length>0;Vi(i,f,g&&u.length>0&&f.length===0)}async function h(){try{u=await l(),d()}catch{u=null,i.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}o.addEventListener("toggle",()=>{c(),o.open&&globalThis.requestAnimationFrame(()=>{c(),Qi()}),o.open&&h()});function p(m){if(!o.open||m.key!=="Escape")return;m.preventDefault(),o.open=!1;let f=o.querySelector("summary");f instanceof HTMLElement&&f.focus({preventScroll:!0})}document.addEventListener("keydown",p,!0),i.addEventListener("keydown",m=>{if(!o.open||m.isComposing)return;let f=m.target;if(!(f instanceof HTMLAnchorElement)||!f.classList.contains("tree-file-link"))return;let g=ur(i);if(g.length===0)return;let S=g.indexOf(f);if(!(S<0)){if(m.key==="ArrowDown"){S<g.length-1&&(g[S+1].focus({preventScroll:!0}),m.preventDefault());return}if(m.key==="ArrowUp"){if(S>0){g[S-1].focus({preventScroll:!0}),m.preventDefault();return}t instanceof HTMLInputElement&&(t.focus({preventScroll:!0}),m.preventDefault())}}}),t instanceof HTMLInputElement&&(t.addEventListener("input",()=>{!o.open||u===null||d()}),t.addEventListener("keydown",m=>{if(!o.open||m.isComposing||m.key!=="ArrowDown")return;let f=ur(i);f.length!==0&&(f[0].focus({preventScroll:!0}),m.preventDefault())}))}function Ki(n,e,t,r,o){let i=!1,s=o;function a(l){if(!i)return;let u=e.getBoundingClientRect(),d=l.clientX-u.left,h=L(d/u.width*100,15,85);s=h,t.style.flex=`0 0 ${h}%`,e.style.setProperty("--split-pct",`${String(h)}%`)}function c(){i=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect="",A(localStorage,n,String(s))}r.addEventListener("mousedown",l=>{l.preventDefault(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var Ze="commentray.codeCommentrayStatic.splitPct",Jr="commentray.codeCommentrayStatic.wrap",we="commentray.codeCommentrayStatic.dualMobilePane",Xi="commentray.codeCommentrayStatic.sourceMarkdownPaneMode",Ji="commentray.codeCommentrayStatic.pageBreaksEnabled",Me="(max-width: 767px)";function K(n){return n==="code"?"code":"doc"}function ve(){return globalThis.matchMedia(Me).matches}function et(n,e){if(e){n.setAttribute("data-mobile-single-pane","true");return}n.removeAttribute("data-mobile-single-pane")}function Zi(n){let e=document.getElementById("commentray-help-tour");e instanceof HTMLButtonElement&&e.addEventListener("click",()=>{Zt(n,ve,{force:!0})})}function z(n){return n.getAttribute("data-source-pane-mode")==="rendered-markdown"?"rendered-markdown":"source"}function es(n){let e=(n??"").trim().toLowerCase();return!(e==="0"||e==="false"||e==="off")}function ts(n){let e=es(D(localStorage,Ji));n.setAttribute("data-page-breaks-enabled",e?"true":"false")}function ns(n){let e=()=>{let t=Math.max(globalThis.innerHeight,document.documentElement?.clientHeight??0);if(!Number.isFinite(t)||t<=0)return;let r=Math.round(L(t*.72,260,820));n.style.setProperty("--commentray-page-break-min-height",`${String(r)}px`)};globalThis.addEventListener("resize",e,{passive:!0}),globalThis.addEventListener("orientationchange",e,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",e,{passive:!0}),e()}function br(n){let e=document.querySelector("label.toolbar-wrap-lines");e instanceof HTMLLabelElement&&(e.hidden=z(n)==="rendered-markdown")}function Se(n){return z(n)==="rendered-markdown"?"code-md-line-":"code-line-"}function rs(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||K(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&se(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function Zr(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},o=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{if(!t.matches){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?o():r()};globalThis.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i,{passive:!0}),t.addEventListener("change",i),globalThis.requestAnimationFrame(i)}function os(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},o=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{if(n.hidden||n.getClientRects().length===0){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?o():r()};globalThis.addEventListener("scroll",i,{passive:!0,signal:t}),globalThis.addEventListener("resize",i,{passive:!0,signal:t}),globalThis.requestAnimationFrame(i)}function Sr(n,e,t){let r=ve()&&K(n.getAttribute("data-dual-mobile-pane"))!=="code";e.hidden=r,r?(e.setAttribute("aria-hidden","true"),e.style.setProperty("display","none","important")):(e.removeAttribute("aria-hidden"),e.style.removeProperty("display")),t instanceof HTMLButtonElement&&(t.hidden=!0,t.classList.remove("is-visible"))}function is(n,e){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return null;let r=M(n)?n.getBoundingClientRect().top+n.clientTop+2:Math.max(0,n.getBoundingClientRect().top)+2;for(let s of t)if(s.getBoundingClientRect().bottom>r-.001){let c=/^(?:code-line-|code-md-line-)(\d+)$/.exec(s.id);return c?.[1]?Number.parseInt(c[1],10):null}let o=t[t.length-1];if(!o)return null;let i=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return i?.[1]?Number.parseInt(i[1],10):null}function ss(n,e,t,r,o,i){function s(){return Array.from(e.querySelectorAll('[data-source-markdown-body="true"]'))}function a(){let p=z(n)==="rendered-markdown",m=p?"markdown source":"rendered markdown",f=p?"rendered markdown":"markdown source",g=`Switch source pane to ${m}`,S=`Switch source pane to ${m} (currently ${f})`,b=y=>{y instanceof HTMLButtonElement&&(y.setAttribute("aria-pressed",p?"true":"false"),y.setAttribute("aria-label",g),y.title=S)};b(t),b(r)}a(),br(n),Sr(n,t,r);let c=()=>{Sr(n,t,r)};globalThis.addEventListener("resize",c,{passive:!0,signal:o}),globalThis.matchMedia(Me).addEventListener("change",c,{signal:o});let u=new MutationObserver(c);u.observe(n,{attributes:!0,attributeFilter:["data-dual-mobile-pane","data-source-pane-mode"]}),o.addEventListener("abort",()=>u.disconnect(),{once:!0});let d=()=>{let h=z(n),m=is(e,h==="rendered-markdown"?"code-md-line-":"code-line-"),f=h==="rendered-markdown"?"source":"rendered-markdown",g=f==="rendered-markdown"?"code-md-line-":"code-line-";n.setAttribute("data-source-pane-mode",f),A(localStorage,Xi,f),ve()&&K(n.getAttribute("data-dual-mobile-pane"))==="doc"&&(n.setAttribute("data-dual-mobile-pane","code"),A(localStorage,we,"code")),a(),br(n);let S=!ve()||M(e);if(m!==null&&S){let b=e.querySelector(`#${g}${String(m)}`);b instanceof HTMLElement&&mn(e,b,0)}if(f==="rendered-markdown")for(let b of s())se(b),Ee(b);i?.()};t.addEventListener("click",d,{signal:o}),r&&(r.addEventListener("click",d,{signal:o}),os(t,r,o))}function as(n,e,t,r){let o=globalThis.matchMedia(Me);function i(){return K(D(localStorage,we))}function s(){o.matches?(et(n,!0),n.setAttribute("data-dual-mobile-pane",i())):(et(n,!1),n.removeAttribute("data-dual-mobile-pane"))}let a=()=>{if(!o.matches)return;let l=K(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code",u=$().scrollTop;l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),A(localStorage,we,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{if(l==="code"){t.finishMobileFlipToCode();let d=$();if(u>5&&d.scrollTop<=1){let h=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=L(u,0,h)}}else t.finishMobileFlipToDoc()})}),l==="doc"&&rs(n,o)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),Zr(e,r,o)),o.addEventListener("change",s),s()}function eo(n,e,t,r,o){let i=globalThis.matchMedia(Me);function s(){return K(D(localStorage,we))}function a(){i.matches?(et(n,!0),n.setAttribute("data-dual-mobile-pane",s())):(et(n,!1),n.removeAttribute("data-dual-mobile-pane"))}let c=()=>{if(!i.matches)return;let u=K(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code";n.setAttribute("data-dual-mobile-pane",u),A(localStorage,we,u),u==="doc"&&queueMicrotask(()=>{requestAnimationFrame(()=>{se(n)})})};t.addEventListener("click",c),r&&(r.addEventListener("click",c),Zr(t,r,i)),i.addEventListener("change",a),a()}var Qe=null,hn=null;function cs(n){return n.getAttribute("data-stretch-buffer-sync")==="flow-synchronizer"}function ls(n){return Array.from(n.querySelectorAll("tbody tr.stretch-row--block[data-commentray-stretch-sync-id]")).filter(e=>(e.dataset.commentrayStretchSyncId?.trim()??"").length>0)}function us(n){let e=n.dataset.commentrayStretchSyncId?.trim()??"";if(e.length===0)return null;let t=n.querySelector(":scope > td.stretch-code"),r=n.querySelector(":scope > td.stretch-doc");return!(t instanceof HTMLTableCellElement)||!(r instanceof HTMLTableCellElement)?null:{id:e,codeRect:t.getBoundingClientRect(),docRect:r.getBoundingClientRect()}}function tt(n){if(!(n instanceof HTMLElement))return null;let e=n.getBoundingClientRect();if(e.width<=0||e.height<=0)return null;let t=globalThis.getComputedStyle(n);return t.display==="none"||t.visibility==="hidden"?null:e}function ds(n,e){let t=z(e)==="rendered-markdown"?".source-pane--rendered-md":".source-pane--code",r=n.querySelector(t);if(tt(r)!==null)return r;let o=n.querySelectorAll(".source-pane--code, .source-pane--rendered-md");for(let i of o)if(tt(i)!==null)return i;return null}function hs(n,e){let t=ds(n,e),r=tt(t);return r!==null?r.bottom:n.getBoundingClientRect().bottom}function ms(n){let e=n.querySelector(":scope .stretch-doc-inner"),t=tt(e);return t!==null?t.bottom:n.getBoundingClientRect().bottom}function fs(n,e){let t=n.getBoundingClientRect(),r=t.top+Math.min(Math.max(t.height*.18,24),120);for(let o of e){let i=o.getBoundingClientRect();if(i.top<=r&&i.bottom>=r)return o.dataset.commentrayStretchSyncId?.trim()??null}return e[0]?.dataset.commentrayStretchSyncId?.trim()??null}function ps(n,e,t,r){let o=ls(t),i=r.getBoundingClientRect(),s=i.width,a=i.height;if(s<=0||a<=0||o.length===0){n.replaceChildren();return}n.setAttribute("viewBox",`0 0 ${String(s)} ${String(a)}`),n.setAttribute("preserveAspectRatio","none");let c=fs(e,o),l=[];for(let u of o){let d=us(u);if(d===null)continue;let h=u.querySelector(":scope > td.stretch-code"),p=u.querySelector(":scope > td.stretch-doc");if(!(h instanceof HTMLTableCellElement)||!(p instanceof HTMLTableCellElement))continue;let m=hs(h,e),f=ms(p),g=N(d.codeRect.top+1,i.top,a),S=N(d.docRect.top+1,i.top,a),b=N(m-1,i.top,a),y=N(f-1,i.top,a),x=d.id===c?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",C=`${x} gutter__rays-path--trail`,E=ge(0,g.y,s,S.y,{tension:.38,clipStart:g.clipped,clipEnd:S.clipped}),H=ge(0,b.y,s,y.y,{tension:.38,clipStart:b.clipped,clipEnd:y.clipped}),I=E.dotted?`<path class="${C}" d="${E.dotted}" />`:"",X=H.dotted?`<path class="${C}" d="${H.dotted}" />`:"";l.push(`<g class="gutter__rays-block" data-commentray-block="${B(d.id)}"><path class="${x}" d="${E.solid}" />`+I+`<path class="${x}" d="${H.solid}" />`+X+"</g>")}n.innerHTML=l.join("")}function gs(n,e,t){t.querySelector(":scope > .gutter__rays")?.remove();let r="http://www.w3.org/2000/svg",o=document.createElement("div");o.className="gutter__rays",o.setAttribute("aria-hidden","true");let i=document.createElementNS(r,"svg");o.appendChild(i),t.appendChild(o);let s=0,a=()=>{s===0&&(s=globalThis.requestAnimationFrame(()=>{s=0,ps(i,n,e,t)}))},c=()=>a();n.addEventListener("scroll",c,{passive:!0}),globalThis.addEventListener("resize",c);let l=new ResizeObserver(c);return l.observe(n),l.observe(e),l.observe(t),a(),globalThis.requestAnimationFrame(()=>{a(),globalThis.requestAnimationFrame(a)}),{disconnect:()=>{s!==0&&globalThis.cancelAnimationFrame(s),n.removeEventListener("scroll",c),globalThis.removeEventListener("resize",c),l.disconnect(),o.remove()},request:a}}function ys(n,e){let t=document.getElementById("stretch-gutter");if(!(t instanceof HTMLElement))return;let r=Number.parseFloat(D(localStorage,Ze)??""),o=L(Number.isFinite(r)?r:50,15,85);n.style.setProperty("--stretch-code-pct",`${String(o)}%`);let i=!1,s=c=>{if(!i)return;let l=e.getBoundingClientRect();if(l.width<=0)return;let u=c.clientX-l.left,d=L(u/l.width*100,15,85);n.style.setProperty("--stretch-code-pct",`${String(d)}%`),A(localStorage,Ze,String(d)),hn?.request()},a=()=>{i&&(i=!1,document.body.style.cursor="",document.body.style.userSelect="",globalThis.removeEventListener("mousemove",s),globalThis.removeEventListener("mouseup",a))};t.addEventListener("mousedown",c=>{c.preventDefault(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",globalThis.addEventListener("mousemove",s),globalThis.addEventListener("mouseup",a)})}function to(n,e){e instanceof HTMLTableElement&&cs(n)?(Qe?.disconnect(),Qe=or(e)):(Qe?.disconnect(),Qe=null);let t=document.getElementById("wrap-lines");t&&Or(Jr,e,t,()=>{globalThis.dispatchEvent(new Event("resize"))});let r=document.getElementById("stretch-gutter");hn?.disconnect(),hn=e instanceof HTMLElement&&r instanceof HTMLElement?gs(n,e,r):null,ys(n,e)}function bs(n,e){if(n===null||typeof n!="object")return!1;let t=n;return typeof t.id!="string"||typeof t.docInnerHtmlB64!="string"?!1:e!=="stretch"?!0:typeof t.stretchSwapInnerB64=="string"&&t.stretchSwapInnerB64.trim().length>0}function no(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(R(e));if(!t||!Array.isArray(t.angles)||t.angles.length<2)return null;let r=t.layoutMode==="stretch"?"stretch":"dual";return t.angles.every(o=>bs(o,r))?{...t,layoutMode:r}:null}catch{return null}}function Ss(n,e){let t=e.stretchSwapInnerB64;if(t===void 0||t.trim().length===0)return;n.innerHTML=R(t);let r=document.getElementById("code-pane");if(r instanceof HTMLElement){to(n,r),bn(n,r,()=>{globalThis.dispatchEvent(new Event("resize"))});let a=document.getElementById("mobile-pane-flip"),c=document.getElementById("mobile-pane-flip-scroll");a instanceof HTMLButtonElement&&eo(n,r,a,c instanceof HTMLButtonElement?c:null,()=>{globalThis.dispatchEvent(new Event("resize"))})}n.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),n.setAttribute("data-raw-md-b64",e.rawMdB64),n.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let o=k(e.commentrayPathForSearch);o.length>0?n.setAttribute("data-commentray-pair-commentray-path",o):n.removeAttribute("data-commentray-pair-commentray-path");let i=document.getElementById("nav-rail-doc-path");if(i){let a=e.commentrayPathForSearch.trim();i.textContent=a.length>0?a:"\u2014",a.length>0?i.setAttribute("title",a):i.removeAttribute("title")}let s=e.staticBrowseUrl?.trim()??"";if(s.length>0){let a=Wt(s,globalThis.location.pathname,globalThis.location.origin);n.setAttribute("data-commentray-pair-browse-href",a)}else{let a=e.commentrayOnGithubUrl?.trim();a?n.setAttribute("data-commentray-pair-browse-href",a):n.removeAttribute("data-commentray-pair-browse-href")}yn(),ao(n),se(n),Ee(n),$().scrollTop=0}function Ts(n,e,t){if(e.layoutMode!=="stretch")return;let r=document.getElementById("angle-select");r&&r.addEventListener("change",()=>{let o=e.angles.find(i=>i.id===r.value);o&&(Ss(n,o),t?.(o))})}function ws(n,e){let t=ro();if(!t)return;let r=io(n,e),{searchInput:o,searchClear:i,searchResults:s}=t;Nr({scope:r.scope,filePathLabel:r.filePathLabel,mutable:r.mutable,rawCode:r.rawCode,searchInput:o,searchClear:i,searchResults:s,docScrollEl:n}),oo(n,r.pathInit.documentedPairs,r.indexState,r.mutable,r.rebuildSearcher,o);let a=document.getElementById("commentray-multi-angle-b64"),c=no(a);c?.layoutMode==="stretch"&&Ts(n,c,l=>{r.mutable.rawMd=R(l.rawMdB64),r.mutable.mdLines=r.mutable.rawMd.split(`
20
+ `),r.mutable.commentrayPathLabel=l.commentrayPathForSearch,r.rebuildSearcher(),o.value="",s.innerHTML="",s.hidden=!0})}function vs(){let n=document.getElementById("doc-pane"),e=document.getElementById("gutter"),t=document.getElementById("wrap-lines");if(!n||!e||!t)return null;let r=document.getElementById("doc-pane-body"),o=r instanceof HTMLElement?r:n;return{docBody:r,docScrollEl:o,gutter:e,wrapCb:t}}function ro(){let n=document.getElementById("search-q"),e=document.getElementById("search-clear"),t=document.getElementById("search-results");return!n||!e||!t?null:{searchInput:n,searchClear:e,searchResults:t}}function Es(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:o,pathRowsForOrdering:i,rawMd:s,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return cr(e,t,s,r,a);if(o.length>0)return o;let c=i.length>0?i:cr(e,t,s,r,a).filter(u=>u.kind==="path"),l=s.split(`
21
+ `).map((u,d)=>({kind:"md",line:d,text:u,spPath:r,crPath:a}));return[...c,...l]}function Ls(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let o=Kr(n.getAttribute("data-documented-pairs-b64")?.trim()??""),i=Nn(o),s=i.length>0?i.map(a=>a.text).join(`
21
22
  `):[t,r].filter(a=>a.trim().length>0).join(`
22
- `);return{documentedPairs:i,pathRowsForOrdering:o,pathBlobWide:s}}function yi(n,e){if(e.length===0)return n;if(n.length===0)return e;let t=new Map;for(let r of n){let i=(r.staticBrowseUrl??"").trim();i.length!==0&&t.set(w(r.commentrayPath),i)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let o=t.get(w(r.commentrayPath));return o!==void 0&&o.length>0?{...r,staticBrowseUrl:o}:r})}function bi(n){let e=n.getAttribute("data-nav-search-json-url")?.trim()??"";if(e.length===0)return"";try{return new URL(e,globalThis.location.href).href}catch{return e}}function Si(n,e,t,r,i,o){let s=bi(n);s.length!==0&&(async()=>{try{let a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=Nt(c.documentedPairs),u=yi(e,l);u.length>0&&(t.documentedPairs=u,r.documentedPairs=u);let h=$r(c);if(h.length===0)return;t.hubNavRows=h,t.pathRowsForOrdering=h.filter(d=>d.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(d=>d.text).join(`
23
- `),i(),o.value.trim().length>0&&o.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function wi(n){let{angle:e,docBody:t,mutable:r,rebuildSearcher:i,scrollLinksRef:o,shell:s,searchInput:a,searchResults:c,requestBlockRayRedraw:l}=n;t.innerHTML=D(e.docInnerHtmlB64),Ie(t),Pe(t),r.rawMd=D(e.rawMdB64),r.mdLines=r.rawMd.split(`
24
- `),r.commentrayPathLabel=e.commentrayPathForSearch,i(),o.current=Fn(e.scrollBlockLinksB64),s.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),s.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let u=w(e.commentrayPathForSearch);u.length>0?s.setAttribute("data-commentray-pair-commentray-path",u):s.removeAttribute("data-commentray-pair-commentray-path"),jn();let h=document.getElementById("nav-rail-doc-path");if(h){let f=e.commentrayPathForSearch.trim();h.textContent=f.length>0?f:"\u2014",f.length>0?h.setAttribute("title",f):h.removeAttribute("title")}let d=e.staticBrowseUrl?.trim()??"";if(d.length>0){let f=rn(d,globalThis.location.pathname,globalThis.location.origin);s.setAttribute("data-commentray-pair-browse-href",f)}else{let f=e.commentrayOnGithubUrl?.trim();f?s.setAttribute("data-commentray-pair-browse-href",f):s.removeAttribute("data-commentray-pair-browse-href")}a.value="",c.innerHTML="",c.hidden=!0,l?.(),globalThis.requestAnimationFrame(()=>{l?.(),globalThis.requestAnimationFrame(()=>{l?.()})})}function Ti(n){let{codePane:e,docScrollEl:t,docBody:r,shell:i,scrollLinksRef:o,multiPayload:s,mutable:a,rebuildSearcher:c,searchInput:l,searchResults:u,requestBlockRayRedraw:h}=n;if(s){let d=Mn(e,t,()=>o.current,()=>Be(i),()=>W(i)==="rendered-markdown"),f=document.getElementById("angle-select");return f&&r&&f.addEventListener("change",()=>{let m=s.angles.find(g=>g.id===f.value);m&&wi({angle:m,docBody:r,mutable:a,rebuildSearcher:c,scrollLinksRef:o,shell:i,searchInput:l,searchResults:u,requestBlockRayRedraw:h})}),d}return o.current.length>0?Mn(e,t,()=>o.current,()=>Be(i),()=>W(i)==="rendered-markdown"):Cr(e,t)}function vi(n,e){function t(i){let o=i.replace(/^#/,"").trim();if(o.length===0)return null;let s=o.split(/--|&/).map(a=>a.trim()).filter(a=>a.length>0);for(let a of s){let c=/^commentray-md-line-(\d+)$/.exec(a);if(!c?.[1])continue;let l=Number.parseInt(c[1],10);if(Number.isFinite(l))return l}return null}function r(){let i=t(globalThis.location.hash);i!==null&&Pn(n,i,e())}globalThis.addEventListener("hashchange",r),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(r)})}function Mi(n){if(W(n)!=="rendered-markdown")return;let e=document.getElementById("code-pane-markdown-body");e instanceof HTMLElement&&(Ie(e),Pe(e))}function Ei(n,e,t){let r=document.getElementById("source-markdown-pane-flip"),i=document.getElementById("source-markdown-pane-flip-scroll");r instanceof HTMLButtonElement&&(ui(n,e,r,i instanceof HTMLButtonElement?i:null,t),Mi(n))}function Li(n,e){let{rawCodeB64:t,rawMdB64:r}=Kt(n,e),i=D(t),o=D(r),a={current:Fn(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:u}=br(n),h=pi(n,c,l,u),d={hubNavRows:[],documentedPairs:h.documentedPairs,pathRowsForOrdering:h.pathRowsForOrdering},f={rawMd:o,mdLines:o.split(`
25
- `),commentrayPathLabel:u,searcher:bn([]),pathBlobWide:h.pathBlobWide,pathRowsForOrdering:d.pathRowsForOrdering,documentedPairs:d.documentedPairs};function m(){f.searcher=bn(gi({scope:c,rawCode:i,filePathLabel:l,hubNavRows:d.hubNavRows,pathRowsForOrdering:d.pathRowsForOrdering,rawMd:f.rawMd,commentrayPathLabel:f.commentrayPathLabel}))}return m(),{rawCode:i,rawMd:o,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:u,pathInit:h,indexState:d,mutable:f,rebuildSearcher:m}}function xi(n,e){let t=fi();if(!t)return;let{docBody:r,docScrollEl:i,gutter:o,wrapCb:s,searchInput:a,searchClear:c,searchResults:l}=t,u=Li(n,e);Pe(document),xr({scope:u.scope,filePathLabel:u.filePathLabel,mutable:u.mutable,rawCode:u.rawCode,searchInput:a,searchClear:c,searchResults:l,docScrollEl:i}),Si(n,u.pathInit.documentedPairs,u.indexState,u.mutable,u.rebuildSearcher,a);let h=parseFloat(F(localStorage,Ln)||"46"),d=v(Number.isFinite(h)?h:46,15,85);e.style.flex=`0 0 ${d}%`,n.style.setProperty("--split-pct",`${String(d)}%`);let f=document.getElementById("doc-pane"),m=f instanceof HTMLElement?f:null,g=document.getElementById("code-pane-markdown-body"),p={};Dn(Vn,e,s,()=>{p.request?.()},m,r,g instanceof HTMLElement?g:null),Zr(Ln,n,e,o,d);let S=document.getElementById("commentray-multi-angle-b64"),E=mi(S),k=E!==null||u.scrollLinksRef.current.length>0?Dr({gutter:o,codePane:e,docScrollEl:i,getLinks:()=>u.scrollLinksRef.current,probeTopSourceLine1Based:()=>On(e,Be(n)),sourceLineIdPrefix:()=>Be(n)}):void 0;p.request=k;let C=Ti({codePane:e,docScrollEl:i,docBody:r,shell:n,scrollLinksRef:u.scrollLinksRef,multiPayload:E,mutable:u.mutable,rebuildSearcher:u.rebuildSearcher,searchInput:a,searchResults:l,requestBlockRayRedraw:k}),T=document.getElementById("mobile-pane-flip"),L=document.getElementById("mobile-pane-flip-scroll");T instanceof HTMLButtonElement&&hi(n,T,C,L instanceof HTMLButtonElement?L:null),Ei(n,e,()=>{k?.()}),Ct(n,Kn),vi(i,()=>u.mutable.mdLines.length)}function ki(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function Hi(n,e){let t=ki(e);n.setAttribute("aria-label",`Color theme: ${t}. Left-click opens the menu. Right-click cycles System, Light, and Dark.`),n.title=`Appearance: ${t} \u2014 left-click menu, right-click cycle`}function Ci(){let n=document.querySelector(".toolbar-theme"),e=document.getElementById("commentray-theme-trigger"),t=document.getElementById("commentray-theme-menu");if(!n||!(e instanceof HTMLButtonElement)||!(t instanceof HTMLElement))return;let r=n,i=e,o=t,s=xe(F(localStorage,xt));kt(s);let a=!1;function c(){i.dataset.commentrayTriggerMode=s,i.setAttribute("aria-expanded",a?"true":"false"),Hi(i,s);for(let m of o.querySelectorAll("[data-commentray-theme-value]")){let g=xe(m.dataset.commentrayThemeValue??"");m.setAttribute("aria-checked",g===s?"true":"false")}}function l(){a=!0,o.removeAttribute("hidden"),c(),(o.querySelector('[role="menuitemradio"][aria-checked="true"]')??o.querySelector('[role="menuitemradio"]'))?.focus()}function u(){a=!1,o.setAttribute("hidden",""),c()}function h(m){s=m,B(localStorage,xt,m),kt(m),c()}i.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),a?u():l()}),i.addEventListener("contextmenu",m=>{m.preventDefault(),a&&u(),h(on(s))});for(let m of o.querySelectorAll("[data-commentray-theme-value]"))m.addEventListener("click",g=>{g.stopPropagation();let p=xe(m.dataset.commentrayThemeValue??"");h(p),u(),i.focus()});function d(m){if(!a)return;let g=m.target;g instanceof Node&&(r.contains(g)||u())}function f(m){!a||m.key!=="Escape"||(m.preventDefault(),m.stopPropagation(),u(),i.focus())}document.addEventListener("mousedown",d,!0),document.addEventListener("touchstart",d,!0),document.addEventListener("keydown",f,!0),c()}function Ai(n){let e=n.trim();if(e.length===0||/^(javascript|data):/i.test(e))return null;try{return new URL(e,globalThis.location.href).toString()}catch{return null}}function Bi(n){return n.split("/").filter(e=>e.length>0).map(e=>e.startsWith(".")?`%2E${encodeURIComponent(e.slice(1))}`:encodeURIComponent(e)).join("/")}function Pi(n){return(w(n).split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"").trim()}function Hn(n,e){return new URL(n,e).toString()}function Ii(n,e){return(n.getAttribute("data-layout")??"dual")!=="dual"||e.includes("/browse/")?!1:e.endsWith("/")||e.endsWith("/index.html")}function Ri(n,e){let t=w(n.getAttribute("data-commentray-pair-source-path")??"");if(t.length===0)return null;let r=Bi(t);if(r.length===0)return null;let i=document.getElementById("angle-select"),o=i instanceof HTMLSelectElement?i.value.trim():"",s=n.getAttribute("data-commentray-pair-commentray-path")??"",a=Pi(s),c=o.length>0?o:a;if(c.length===0)return null;let l=`${r}@${encodeURIComponent(c)}.html`,u=Ee(e);return u==="/"?`/browse/${l}`:`${u}/browse/${l}`}function Di(n,e){let t=n.getAttribute("data-nav-search-json-url")?.trim()??"";t.length>0&&n.setAttribute("data-nav-search-json-url",Hn(t,e));let r=document.getElementById("documented-files-hub");if(r instanceof HTMLElement){let i=r.getAttribute("data-nav-json-url")?.trim()??"";i.length>0&&r.setAttribute("data-nav-json-url",Hn(i,e))}}function Fi(n,e){let t=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";t.length>0&&Le(t)&&n.setAttribute("data-commentray-pair-browse-href",q(t,e,globalThis.location.origin))}function Ni(){let n=document.querySelector('a[aria-label="Documentation home"]');if(!(n instanceof HTMLAnchorElement))return;let e=Ee(globalThis.location.pathname),t=e==="/"?"/":`${e}/`;n.setAttribute("href",t)}function zi(){let n=document.getElementById("doc-pane");if(!(n instanceof HTMLElement))return null;let e=document.getElementById("doc-pane-body"),t=e instanceof HTMLElement?e:n;if(t.querySelectorAll(".commentray-block-anchor").length===0)return null;let i=Ft(t);return!Number.isFinite(i)||i<0?null:`commentray-md-line-${String(i)}`}function $i(){let n=document.getElementById("shell");if(!(n instanceof HTMLElement))return;let e=globalThis.location.pathname;if(Ni(),!Ii(n,e))return;let t=globalThis.location.href;Di(n,t),Fi(n,e);let i=(()=>{let o=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";if(o.length===0)return null;try{let s=new URL(o,globalThis.location.href);return s.origin!==globalThis.location.origin||!s.pathname.includes("/browse/")?null:s.pathname}catch{return null}})()??Ri(n,e);i!==null&&globalThis.history.replaceState(null,"",`${i}${globalThis.location.search}${globalThis.location.hash}`)}function Oi(){let n=[],e=i=>{let o=i.trim();o.length!==0&&(n.includes(o)||n.push(o))},t=document.getElementById("angle-select");if(t instanceof HTMLSelectElement){let i=t.value.trim();i.length>0&&e(`angle-${encodeURIComponent(i)}`)}let r=zi();return r&&e(r),n.length>0?`#${n.join("&")}`:""}function qi(n){let e=n.getAttribute("data-commentray-pair-browse-href")??"",r=(Le(e.trim())&&e.trim().length>0?q(e.trim(),globalThis.location.pathname,globalThis.location.origin):Ai(e))??globalThis.location.href,i=new URL(r,globalThis.location.href),o=Oi();return i.hash=o.length>0?o.slice(1):"",i.toString()}async function Wi(n){try{return await navigator.clipboard.writeText(n),!0}catch{let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px",document.body.appendChild(e),e.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(e)}}}function Gi(){let n=document.getElementById("shell"),e=document.getElementById("commentray-share-link");if(!(n instanceof HTMLElement)||!(e instanceof HTMLButtonElement))return;let t="Copy shareable permalink",r;e.addEventListener("click",()=>{(async()=>{let i=qi(n);await Wi(i)&&(e.dataset.copied="true",e.setAttribute("aria-label","Permalink copied"),e.title="Permalink copied",r!==void 0&&globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{delete e.dataset.copied,e.setAttribute("aria-label",t),e.title=t},1200))})()})}function Cn(){Gi(),Ci(),Xr();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if(ii(n),oi(n),ni(n),(n.getAttribute("data-layout")||"dual")==="stretch"){di(e);return}xi(n,e),$i()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Cn):Cn();})();
23
+ `);return{documentedPairs:o,pathRowsForOrdering:i,pathBlobWide:s}}function Ms(n,e){if(e.length===0)return n;if(n.length===0)return e;let t=new Map;for(let r of n){let o=(r.staticBrowseUrl??"").trim();o.length!==0&&t.set(k(r.commentrayPath),o)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let i=t.get(k(r.commentrayPath));return i!==void 0&&i.length>0?{...r,staticBrowseUrl:i}:r})}function ks(n){let e=n.getAttribute("data-nav-search-json-url")?.trim()??"";if(e.length===0)return"";try{return new URL(e,globalThis.location.href).href}catch{return e}}function oo(n,e,t,r,o,i){let s=ks(n);s.length!==0&&(async()=>{try{let a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=gn(c.documentedPairs),u=Ms(e,l);u.length>0&&(t.documentedPairs=u,r.documentedPairs=u);let d=Fi(c);if(d.length===0)return;t.hubNavRows=d,t.pathRowsForOrdering=d.filter(h=>h.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(h=>h.text).join(`
24
+ `),o(),i.value.trim().length>0&&i.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function Hs(n){let{angle:e,docBody:t,mutable:r,rebuildSearcher:o,scrollLinksRef:i,shell:s,searchInput:a,searchResults:c,requestBlockRayRedraw:l}=n;t.innerHTML=R(e.docInnerHtmlB64),se(t),Ee(t),r.rawMd=R(e.rawMdB64),r.mdLines=r.rawMd.split(`
25
+ `),r.commentrayPathLabel=e.commentrayPathForSearch,o(),i.current=_r(e.scrollBlockLinksB64),s.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),s.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let u=k(e.commentrayPathForSearch);u.length>0?s.setAttribute("data-commentray-pair-commentray-path",u):s.removeAttribute("data-commentray-pair-commentray-path"),yn();let d=document.getElementById("nav-rail-doc-path");if(d){let p=e.commentrayPathForSearch.trim();d.textContent=p.length>0?p:"\u2014",p.length>0?d.setAttribute("title",p):d.removeAttribute("title")}let h=e.staticBrowseUrl?.trim()??"";if(h.length>0){let p=Wt(h,globalThis.location.pathname,globalThis.location.origin);s.setAttribute("data-commentray-pair-browse-href",p)}else{let p=e.commentrayOnGithubUrl?.trim();p?s.setAttribute("data-commentray-pair-browse-href",p):s.removeAttribute("data-commentray-pair-browse-href")}a&&c&&(a.value="",c.innerHTML="",c.hidden=!0),ao(s),l?.(),globalThis.requestAnimationFrame(()=>{l?.(),globalThis.requestAnimationFrame(()=>{l?.()})})}function xs(n,e){let{codePane:t,docScrollEl:r,docBody:o,shell:i,scrollLinksRef:s,multiPayload:a,mutable:c,rebuildSearcher:l,searchInput:u,searchResults:d,requestBlockRayRedraw:h}=n;if(a){let p=sn(t,r,()=>s.current,()=>Se(i),()=>z(i)==="rendered-markdown",e),m=document.getElementById("angle-select");return m&&o&&m.addEventListener("change",()=>{let f=a.angles.find(g=>g.id===m.value);f&&Hs({angle:f,docBody:o,mutable:c,rebuildSearcher:l,scrollLinksRef:s,shell:i,searchInput:u,searchResults:d,requestBlockRayRedraw:h})}),p}return s.current.length>0?sn(t,r,()=>s.current,()=>Se(i),()=>z(i)==="rendered-markdown",e):e.allowProportionalMirror?Mi(t,r):sn(t,r,()=>[],()=>Se(i),()=>z(i)==="rendered-markdown",e)}function Cs(n){let t=$n(n.shell.getAttribute("data-scroll-sync-strategy"))==="block-snap-only"?{allowProportionalMirror:!1}:{allowProportionalMirror:!0};return xs(n,t)}function As(n,e){function t(o){let i=o.replace(/^#/,"").trim();if(i.length===0)return null;let s=i.split(/--|&/).map(a=>a.trim()).filter(a=>a.length>0);for(let a of s){let c=/^commentray-md-line-(\d+)$/.exec(a);if(!c?.[1])continue;let l=Number.parseInt(c[1],10);if(Number.isFinite(l))return l}return null}function r(){let o=t(globalThis.location.hash);o!==null&&Rr(n,o,e())}globalThis.addEventListener("hashchange",r),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(r)})}function Bs(n){if(z(n)!=="rendered-markdown")return;let e=document.getElementById("code-pane");if(e instanceof HTMLElement)for(let t of e.querySelectorAll('[data-source-markdown-body="true"]'))se(t),Ee(t)}var an=null;function bn(n,e,t){let r=document.getElementById("source-markdown-pane-flip"),o=document.getElementById("source-markdown-pane-flip-scroll");r instanceof HTMLButtonElement&&(an?.abort(),an=new AbortController,ss(n,e,r,o instanceof HTMLButtonElement?o:null,an.signal,t),Bs(n))}function io(n,e){let{rawCodeB64:t,rawMdB64:r}=In(n,e),o=R(t),i=R(r),a={current:_r(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:u}=di(n),d=Ls(n,c,l,u),h={hubNavRows:[],documentedPairs:d.documentedPairs,pathRowsForOrdering:d.pathRowsForOrdering},p={rawMd:i,mdLines:i.split(`
26
+ `),commentrayPathLabel:u,searcher:lr([]),pathBlobWide:d.pathBlobWide,pathRowsForOrdering:h.pathRowsForOrdering,documentedPairs:h.documentedPairs};function m(){p.searcher=lr(Es({scope:c,rawCode:o,filePathLabel:l,hubNavRows:h.hubNavRows,pathRowsForOrdering:h.pathRowsForOrdering,rawMd:p.rawMd,commentrayPathLabel:p.commentrayPathLabel}))}return m(),{rawCode:o,rawMd:i,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:u,pathInit:d,indexState:h,mutable:p,rebuildSearcher:m}}function Is(n,e){let t=vs();if(!t)return;let{docBody:r,docScrollEl:o,gutter:i,wrapCb:s}=t,a=ro(),c=io(n,e);if(Ee(document),a){let{searchInput:E,searchClear:H,searchResults:I}=a;Nr({scope:c.scope,filePathLabel:c.filePathLabel,mutable:c.mutable,rawCode:c.rawCode,searchInput:E,searchClear:H,searchResults:I,docScrollEl:o}),oo(n,c.pathInit.documentedPairs,c.indexState,c.mutable,c.rebuildSearcher,E)}let l=parseFloat(D(localStorage,Ze)||"46"),u=L(Number.isFinite(l)?l:46,15,85);e.style.flex=`0 0 ${u}%`,n.style.setProperty("--split-pct",`${String(u)}%`);let d=document.getElementById("doc-pane"),h=d instanceof HTMLElement?d:null,p=document.getElementById("code-pane-markdown-body"),m={};Or(Jr,e,s,()=>{m.request?.()},h,r,p instanceof HTMLElement?p:null),Ki(Ze,n,e,i,u);let f=document.getElementById("commentray-multi-angle-b64"),g=no(f),b=g!==null||c.scrollLinksRef.current.length>0?Ii({gutter:i,codePane:e,docScrollEl:o,getLinks:()=>c.scrollLinksRef.current,probeTopSourceLine1Based:()=>Gr(e,Se(n)),sourceLineIdPrefix:()=>Se(n)}):void 0;m.request=b;let y=Cs({codePane:e,docScrollEl:o,docBody:r,shell:n,scrollLinksRef:c.scrollLinksRef,multiPayload:g,mutable:c.mutable,rebuildSearcher:c.rebuildSearcher,searchInput:a?.searchInput,searchResults:a?.searchResults,requestBlockRayRedraw:b}),x=document.getElementById("mobile-pane-flip"),C=document.getElementById("mobile-pane-flip-scroll");x instanceof HTMLButtonElement&&as(n,x,y,C instanceof HTMLButtonElement?C:null),bn(n,e,()=>{b?.()}),Zt(n,ve),As(o,()=>c.mutable.mdLines.length)}function Ps(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function Rs(n,e){let t=Ps(e);n.setAttribute("aria-label",`Color theme: ${t}. Left-click opens the menu. Right-click cycles System, Light, and Dark.`),n.title=`Appearance: ${t} \u2014 left-click menu, right-click cycle`}function Ds(){let n=document.querySelector(".toolbar-theme"),e=document.getElementById("commentray-theme-trigger"),t=document.getElementById("commentray-theme-menu");if(!n||!(e instanceof HTMLButtonElement)||!(t instanceof HTMLElement))return;let r=n,o=e,i=t,s=qe(D(localStorage,Qt));jt(s);let a=!1;function c(){o.dataset.commentrayTriggerMode=s,o.setAttribute("aria-expanded",a?"true":"false"),Rs(o,s);for(let m of i.querySelectorAll("[data-commentray-theme-value]")){let f=qe(m.dataset.commentrayThemeValue??"");m.setAttribute("aria-checked",f===s?"true":"false")}}function l(){a=!0,i.removeAttribute("hidden"),c(),(i.querySelector('[role="menuitemradio"][aria-checked="true"]')??i.querySelector('[role="menuitemradio"]'))?.focus()}function u(){a=!1,i.setAttribute("hidden",""),c()}function d(m){s=m,A(localStorage,Qt,m),jt(m),c()}o.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),a?u():l()}),o.addEventListener("contextmenu",m=>{m.preventDefault(),a&&u(),d(_n(s))});for(let m of i.querySelectorAll("[data-commentray-theme-value]"))m.addEventListener("click",f=>{f.stopPropagation();let g=qe(m.dataset.commentrayThemeValue??"");d(g),u(),o.focus()});function h(m){if(!a)return;let f=m.target;f instanceof Node&&(r.contains(f)||u())}function p(m){!a||m.key!=="Escape"||(m.preventDefault(),m.stopPropagation(),u(),o.focus())}document.addEventListener("mousedown",h,!0),document.addEventListener("touchstart",h,!0),document.addEventListener("keydown",p,!0),c()}function Fs(n){let e=n.trim();if(e.length===0||/^(javascript|data):/i.test(e))return null;try{return new URL(e,globalThis.location.href).toString()}catch{return null}}function Tr(n,e){return new URL(n,e).toString()}function Ns(n,e){let t=n.getAttribute("data-nav-search-json-url")?.trim()??"";t.length>0&&n.setAttribute("data-nav-search-json-url",Tr(t,e));let r=document.getElementById("documented-files-hub");if(r instanceof HTMLElement){let o=r.getAttribute("data-nav-json-url")?.trim()??"";o.length>0&&r.setAttribute("data-nav-json-url",Tr(o,e))}}function Os(n,e){let t=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";t.length>0&&$e(t)&&n.setAttribute("data-commentray-pair-browse-href",Y(t,e,globalThis.location.origin))}function _s(){let n=document.getElementById("doc-pane");if(!(n instanceof HTMLElement))return null;let e=document.getElementById("doc-pane-body"),t=e instanceof HTMLElement?e:n;if(t.querySelectorAll(".commentray-block-anchor").length===0)return null;let o=pn(t);return o===null||!Number.isFinite(o)||o<0?null:`commentray-md-line-${String(o)}`}function zs(n){if((n.getAttribute("data-layout")??"dual")!=="dual")return;let e=globalThis.location.pathname,t=globalThis.location.href;Ns(n,t),Os(n,e)}function so(n){let t=(n.getAttribute("data-commentray-pair-browse-href")??"").trim();return($e(t)&&t.length>0?Y(t,globalThis.location.pathname,globalThis.location.origin):Fs(t))??globalThis.location.href}function $s(){let n=[],e=o=>{let i=o.trim();i.length!==0&&(n.includes(i)||n.push(i))},t=document.getElementById("angle-select");if(t instanceof HTMLSelectElement){let o=t.value.trim();o.length>0&&e(`angle-${encodeURIComponent(o)}`)}let r=_s();return r&&e(r),n.length>0?`#${n.join("&")}`:""}function qs(n){let e=new URL(so(n),globalThis.location.href),t=$s();return e.hash=t.length>0?t.slice(1):"",e.toString()}function ao(n){let e;try{e=new URL(so(n),globalThis.location.href)}catch{return}if(e.origin!==globalThis.location.origin)return;e.hash="";let t=new URL(globalThis.location.href);t.pathname===e.pathname&&t.search===e.search||globalThis.location.assign(e.toString())}async function Gs(n){try{return await navigator.clipboard.writeText(n),!0}catch{let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px",document.body.appendChild(e),e.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(e)}}}function Ws(){let n=document.getElementById("shell"),e=document.getElementById("commentray-share-link");if(!(n instanceof HTMLElement)||!(e instanceof HTMLButtonElement))return;let t="Copy shareable permalink",r;e.addEventListener("click",()=>{(async()=>{let o=qs(n);await Gs(o)&&(e.dataset.copied="true",e.setAttribute("aria-label","Permalink copied"),e.title="Permalink copied",r!==void 0&&globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{delete e.dataset.copied,e.setAttribute("aria-label",t),e.title=t},1200))})()})}function wr(){Xo(),Ws(),Ds(),ji();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if(ts(n),ns(n),Zi(n),(n.getAttribute("data-layout")||"dual")==="stretch"){to(n,e),ws(n,e),bn(n,e,()=>{globalThis.dispatchEvent(new Event("resize"))});let r=document.getElementById("mobile-pane-flip"),o=document.getElementById("mobile-pane-flip-scroll");r instanceof HTMLButtonElement&&eo(n,e,r,o instanceof HTMLButtonElement?o:null,()=>{globalThis.dispatchEvent(new Event("resize"))});return}Is(n,e),zs(n)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",wr):wr();})();