markon-core 0.15.14

markon core - Mark it on.
"use strict";(()=>{var i=window.__MARKON_I18N__?.t||(m=>m),f=m=>`${i("web.export.label")} (${m})`,A=()=>(window.MarkonTheme?.getResolved?.()||document.documentElement.getAttribute("data-theme"))==="dark"?"dark":"light",C=()=>`/_/css/github-markdown-${A()}.css`,w=".markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6";function L(m){let e=Array.from(document.querySelectorAll(w));return e.sort((t,n)=>{let o=parseInt(t.tagName.substring(1)),a=parseInt(n.tagName.substring(1));return m?a-o:o-a}),e}var M=m=>`markon-viewed-${m}`,T=m=>`markon-collapsed-${m}`,y=class{isSharedMode;ws;wsManager;filePath;viewedState;collapsedState;stateLoaded;enableViewed;allViewedCheckbox;updatingAllViewedCheckbox;revealSeq;noteFocusReveal;noteFocusRevealSeq;preserveExpansionOnNextSharedState;_wsMessageHandler;ready;constructor(e,t){this.isSharedMode=e,this.ws=t,this.wsManager=null;let n=document.querySelector('meta[name="file-path"]');this.filePath=n?n.getAttribute("content")??window.location.pathname:window.location.pathname,this.viewedState={},this.collapsedState={},this.stateLoaded=!1,this.allViewedCheckbox=null,this.updatingAllViewedCheckbox=!1,this._wsMessageHandler=null,this.noteFocusReveal=null,this.noteFocusRevealSeq=0,this.preserveExpansionOnNextSharedState=!1;let o=document.querySelector('meta[name="enable-viewed"]');this.enableViewed=o?o.getAttribute("content")==="true":!0,this.revealSeq=0,this.isSharedMode&&this.ws&&this.setupWebSocketListeners(),this.ready=this.init()}async init(){this.loadCollapsedState(),this.enableViewed&&await this.loadState(),this.injectCheckboxes(),this.updateExportNotesButtons(),document.addEventListener("markon:notes-count-changed",()=>this.updateExportNotesButtons()),this.enableViewed&&this.createToolbar(),this.applyViewedState(),this.setupEventListeners()}setupWebSocketListeners(){this.ws&&(this._wsMessageHandler&&this.ws.removeEventListener("message",this._wsMessageHandler),this._wsMessageHandler=e=>{try{let t=JSON.parse(e.data);if(t.type!=="viewed_state"||this.wsManager&&this.wsManager.isOwnEcho(t.op_id))return;this.viewedState=t.state??{},this.stateLoaded=!0,document.querySelector(".viewed-checkbox")&&(this.preserveExpansionOnNextSharedState?(this.preserveExpansionOnNextSharedState=!1,this.updateCheckboxes(),this.updateTocHighlights(),this.updateAllViewedCheckbox()):(this.updateCheckboxes(),this.applyViewedState()))}catch{}},this.ws.addEventListener("message",this._wsMessageHandler))}updateCheckboxes(){document.querySelectorAll(".viewed-checkbox").forEach(t=>{let n=t.dataset.headingId;n&&(t.checked=!!this.viewedState[n])})}injectCheckboxes(){document.querySelectorAll(w).forEach((t,n)=>{t.id||(t.id=`heading-${n}`);let o=t.id,a=[];this.enableViewed&&a.push({type:"viewed",create:()=>{let s=document.createElement("label");s.className="viewed-checkbox-label",s.title=i("web.viewed.mark");let c=document.createElement("input");c.type="checkbox",c.className="viewed-checkbox",c.dataset.headingId=o,c.tabIndex=-1,this.viewedState[o]&&(c.checked=!0);let l=document.createElement("span");return l.className="section-action viewed-text",l.textContent=i("web.viewed"),s.appendChild(c),s.appendChild(l),s}}),a.push({type:"print",create:()=>{let s=document.createElement("span");return s.className="section-action section-print-btn",s.textContent=i("web.viewed.print"),s.title=i("web.viewed.print.tip"),s.dataset.headingId=o,s}}),a.push({type:"export-notes",create:()=>{let s=document.createElement("span");return s.className="section-action section-export-notes",s.textContent=f(0),s.title=i("web.export.section.tip"),s.dataset.headingId=o,s}}),a.push({type:"toggle",create:()=>{let s=document.createElement("span");return s.className="section-action section-expand-toggle",s.textContent=i("web.viewed.collapse"),s.dataset.headingId=o,s}});let r=document.createElement("span");r.className="section-actions",a.forEach((s,c)=>{if(c>0){let h=document.createElement("span");h.className="section-action-separator",h.textContent=" | ",r.appendChild(h)}let l=s.create();r.appendChild(l)}),t.appendChild(r)})}getSectionContent(e){let t=parseInt(e.tagName.substring(1)),n=[],o=e.nextElementSibling;for(;o;){let a=o.tagName;if(a&&/^H[1-6]$/.test(a)&&parseInt(a.substring(1))<=t)break;n.push(o),o=o.nextElementSibling}return n}preserveExpansionForNextSharedState(){this.preserveExpansionOnNextSharedState=!0}hasCollapsedState(e){return Object.prototype.hasOwnProperty.call(this.collapsedState,e)}shouldCollapse(e){return this.hasCollapsedState(e)?!!this.collapsedState[e]:!!this.viewedState[e]}setCollapsedState(e,t){this.collapsedState[e]=t,this.saveCollapsedState()}revealNoteSource(e,t){if(this.noteFocusReveal?.annotationId===e)return;this.clearNoteSourceReveal();let n=this.collapsedHeadingsContaining(t);if(n.length===0)return;let o=String(++this.noteFocusRevealSeq);this.noteFocusReveal={annotationId:e,token:o,headings:n.map(a=>({id:a.id,wasCollapsed:a.classList.contains("section-collapsed")}))},n.forEach(a=>{a.dataset.markonNoteFocusReveal=o,this.expandSection(a.id,{animate:!1})})}clearNoteSourceReveal(e){let t=this.noteFocusReveal;t&&(e&&t.annotationId!==e||(this.noteFocusReveal=null,[...t.headings].reverse().forEach(({id:n,wasCollapsed:o})=>{let a=document.getElementById(n);!a||a.dataset.markonNoteFocusReveal!==t.token||(delete a.dataset.markonNoteFocusReveal,o&&this.collapseSection(n))})))}collapsedHeadingsContaining(e){return Array.from(document.querySelectorAll(w)).filter(t=>!t.id||!t.classList.contains("section-collapsed")?!1:this.getSectionContent(t).some(n=>n===e||n.contains(e)))}cancelNoteSourceRevealForHeading(e){let t=this.noteFocusReveal;!t||!t.headings.some(n=>n.id===e)||(t.headings.forEach(({id:n})=>{let o=document.getElementById(n);o?.dataset.markonNoteFocusReveal===t.token&&delete o.dataset.markonNoteFocusReveal}),this.noteFocusReveal=null)}cancelNoteSourceReveal(){let e=this.noteFocusReveal;e&&(e.headings.forEach(({id:t})=>{let n=document.getElementById(t);n?.dataset.markonNoteFocusReveal===e.token&&delete n.dataset.markonNoteFocusReveal}),this.noteFocusReveal=null)}collapseSection(e){let t=document.getElementById(e);if(!t)return;let n=this.getSectionContent(t);t.classList.add("section-collapsed"),n.forEach(o=>{o.classList.add("section-content-hidden"),o.classList.remove("section-content-temp-visible")}),this.ensureCollapsedPlaceholder(t,e),this.syncToggleBtn(t,!0)}syncToggleBtn(e,t){let n=e.querySelector(".section-expand-toggle");n&&(n.textContent=i(t?"web.viewed.expand":"web.viewed.collapse"))}ensureCollapsedPlaceholder(e,t){let n=e.nextElementSibling;if(n&&n.classList&&n.classList.contains("section-collapsed-placeholder"))return;let o=document.createElement("div");o.className="section-collapsed-placeholder",o.dataset.headingId=t,o.textContent=i("web.viewed.collapsed.hint"),o.addEventListener("click",()=>{this.cancelNoteSourceRevealForHeading(t),this.toggleTempExpand(t)}),e.insertAdjacentElement("afterend",o)}removeCollapsedPlaceholder(e){let t=e.nextElementSibling;t&&t.classList&&t.classList.contains("section-collapsed-placeholder")&&t.remove()}expandSection(e,t={}){let n=document.getElementById(e);if(!n)return;let o=this.getSectionContent(n);n.classList.remove("section-collapsed"),this.removeCollapsedPlaceholder(n),t.animate===!1?this.revealContent(o,{animate:!1}):(o.forEach(a=>{a.classList.contains("section-content-hidden")||a.classList.add("section-content-hidden")}),o.forEach(a=>{a.offsetHeight}),requestAnimationFrame(()=>{this.revealContent(o)})),this.syncToggleBtn(n,!1)}toggleTempExpand(e){this.toggleCollapse(e)}revealContent(e,t={}){if(t.animate===!1){e.forEach(n=>{n.classList.remove("section-content-hidden"),n.classList.remove("section-content-temp-visible"),delete n.dataset.markonRevealToken});return}e.forEach(n=>{let o=String(++this.revealSeq);n.dataset.markonRevealToken=o,n.classList.remove("section-content-hidden"),n.classList.add("section-content-temp-visible");let a=!1,r=c=>{a||c&&c.target!==n||c&&c.propertyName!=="opacity"||(a=!0,n.dataset.markonRevealToken===o&&(n.classList.remove("section-content-temp-visible"),delete n.dataset.markonRevealToken),n.removeEventListener("transitionend",r),window.clearTimeout(s))};n.addEventListener("transitionend",r);let s=window.setTimeout(()=>r(),450)})}async printSection(e){if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))return this.printSectionInNewWindow(e);let n=document.getElementById(e);if(!n){console.warn("[ViewedManager] printSection: heading not found:",e);return}let o=this.getSectionContent(n);if(!o||o.length===0){console.warn("[ViewedManager] printSection: no content found for heading:",e);return}let a=document.createElement("div");a.className="markdown-body";let r=n.cloneNode(!0);r.querySelectorAll(".section-actions, .viewed-checkbox-label, .section-action-separator, .section-print-btn, .section-expand-toggle").forEach(d=>d.remove()),a.appendChild(r),o.forEach(d=>{let p=d.cloneNode(!0);a.appendChild(p)});let s=document.createElement("iframe");s.style.position="fixed",s.style.left="-9999px",s.style.top="0",s.style.width="21cm",s.style.height="29.7cm",s.style.border="0",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s);let c=C(),l=s.contentDocument;if(!l){console.warn("[ViewedManager] printSection: iframe contentDocument unavailable");return}l.open(),l.write(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Print Section</title>
<link rel="stylesheet" href="${c}">
<link rel="stylesheet" href="/_/css/github-print.css">
<style>
  html, body { margin:0; padding:0; background: transparent !important; }
  /* Tweak page margins slightly to avoid leading blank page */
  @page { margin: 1.5cm 1.5cm 1.5cm 1.5cm; }
  .markdown-body { box-sizing: border-box; max-width: 980px; margin: 0 auto; padding: 16px; border: none; }
  /* Strip UI hierarchy boxes from print */
  .markdown-body .section,
  .markdown-body .section-box,
  .markdown-body .section-wrapper,
  .markdown-body .heading-container {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  /* Ensure first element never forces a break */
  .markdown-body > :first-child { page-break-before: auto !important; margin-top: 0 !important; }
  /* Diagram sizing overrides */
  .markon-diagram { overflow: visible !important; border: none !important; padding: 0 !important; margin: 12pt 0 !important; page-break-inside: avoid !important; }
  .markon-diagram svg { display: block; width: 100% !important; height: auto !important; max-width: 100% !important; }
  @media print { body { background: transparent !important; } }
</style>
</head><body><div class="markdown-body" id="root"></div></body></html>`),l.close(),await new Promise(d=>setTimeout(d,0));let h=l.getElementById("root");h&&h.appendChild(l.importNode(a,!0));let E=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),Array.from(l.querySelectorAll(".markon-diagram svg, svg")).forEach(p=>{try{p.removeAttribute("width"),p.removeAttribute("height"),p.style.width="100%",p.style.height="auto",p.setAttribute("preserveAspectRatio","xMidYMid meet")}catch{}});let g=E?100:2e3;if(await(async()=>{let p=Array.from(l.images||[]).map(u=>u.complete&&u.naturalWidth>0?Promise.resolve():new Promise(x=>{u.onload=u.onerror=()=>x(),setTimeout(()=>x(),g)}));await Promise.all(p)})(),l.fonts)try{await Promise.race([l.fonts.ready,new Promise(d=>setTimeout(d,g))])}catch{}await(async()=>{let d=Array.from(l.querySelectorAll('link[rel="stylesheet"]'));await Promise.all(d.map(p=>p.sheet?Promise.resolve():new Promise(u=>{p.onload=()=>u(),p.onerror=()=>u(),setTimeout(()=>u(),g)})))})();let N=E?50:300;await new Promise(d=>setTimeout(d,N));let k=!1,b=()=>{if(!k){k=!0;try{s.parentNode&&s.parentNode.removeChild(s)}catch{}}},v=s.contentWindow;v&&v.addEventListener("afterprint",b,{once:!0});let H=setTimeout(b,3e4);try{v?.focus(),v?.print()}catch(d){if(console.warn("[ViewedManager] printSection: print blocked or failed",d),clearTimeout(H),confirm(i("web.viewed.print.blocked")))try{v?.print()}catch{alert(i("web.viewed.print.allow"))}setTimeout(b,500)}}async printSectionInNewWindow(e){let t=document.getElementById(e);if(!t){console.warn("[ViewedManager] printSectionInNewWindow: heading not found:",e);return}let n=this.getSectionContent(t);if(!n||n.length===0){console.warn("[ViewedManager] printSectionInNewWindow: no content found for heading:",e);return}let o=window.open("about:blank","_blank");if(!o){alert(i("web.viewed.print.popup"));return}o.document.write(`<html><head><title>Loading...</title></head><body style="font-family: system-ui; padding: 40px; text-align: center;"><h2>${i("web.viewed.print.preparing")}</h2></body></html>`);let a=t.cloneNode(!0);a.querySelectorAll(".section-actions, .viewed-checkbox-label, .section-action-separator, .section-print-btn, .section-expand-toggle, .section-action").forEach(h=>h.remove());let r=n.map(h=>h.cloneNode(!0)),s=[a,...r].map(h=>h.outerHTML).join(`
`),l=`<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Print Section</title>
    <style>
        /* Inlined styles */
        ${await this.fetchPrintStyles()}

        /* Additional print-specific styles */
        body {
            margin: 0;
            padding: 20px;
            background: white;
        }
        .markdown-body {
            max-width: 980px;
            margin: 0 auto;
            background: white;
            color: black;
        }
    </style>
</head>
<body>
    <div class="markdown-body">
        ${s}
    </div>
    <script>
        // Auto-print for all devices after content loads
        window.addEventListener('load', function() {
            // Small delay to ensure styles are applied
            setTimeout(function() {
                window.print();
            }, 300);
        });
    <\/script>
</body>
</html>`;try{o.document.open(),o.document.write(l),o.document.close()}catch(h){console.error("[ViewedManager] printSectionInNewWindow: failed to write content",h),o.close(),alert(i("web.viewed.print.failed"))}}async fetchPrintStyles(){let e=[C(),"/_/css/github-print.css"];return(await Promise.all(e.map(async n=>{try{let o=await fetch(n);return o.ok?await o.text():(console.warn(`[ViewedManager] Failed to fetch ${n}`),"")}catch(o){return console.warn(`[ViewedManager] Error fetching ${n}:`,o),""}}))).join(`

`)}toggleCollapse(e){this.cancelNoteSourceRevealForHeading(e);let t=document.getElementById(e);if(t)if(t.classList.contains("section-collapsed")){let n=this.getSectionContent(t);t.classList.remove("section-collapsed"),this.removeCollapsedPlaceholder(t),this.revealContent(n),this.syncToggleBtn(t,!1),this.setCollapsedState(e,!1)}else this.collapseSection(e),this.setCollapsedState(e,!0)}toggleViewed(e,t){if(this.cancelNoteSourceRevealForHeading(e),this.viewedState[e]=t,this.collapsedState[e]=t,t){this.collapseSection(e);let n=document.getElementById(e);n&&this.getSectionContent(n).forEach(a=>{a.classList.remove("section-content-temp-visible")})}else this.expandSection(e);this.updateCheckboxes(),this.updateTocHighlights(),this.saveState(),this.saveCollapsedState(),this.updateAllViewedCheckbox()}sectionHeadingIds(){return Array.from(document.querySelectorAll(w)).map(e=>e.id).filter(e=>!!e)}headingIds(){return Array.from(document.querySelectorAll(".viewed-checkbox")).map(e=>e.dataset.headingId).filter(e=>!!e)}updateAllViewedCheckbox(){let e=this.headingIds(),t=e.length>0&&e.every(n=>this.viewedState[n]);this.allViewedCheckbox&&(this.updatingAllViewedCheckbox=!0,this.allViewedCheckbox.checked=t,this.updatingAllViewedCheckbox=!1)}async loadState(){if(this.isSharedMode)return new Promise(t=>{if(this.stateLoaded){t();return}let n=setTimeout(()=>{this.viewedState={},this.stateLoaded=!0,t()},500),o=setInterval(()=>{this.stateLoaded&&(clearTimeout(n),clearInterval(o),t())},50)});let e=localStorage.getItem(M(this.filePath));this.viewedState=e?JSON.parse(e):{},this.stateLoaded=!0}loadCollapsedState(){try{let e=localStorage.getItem(T(this.filePath));this.collapsedState=e?JSON.parse(e):{}}catch{this.collapsedState={}}}saveCollapsedState(){localStorage.setItem(T(this.filePath),JSON.stringify(this.collapsedState))}saveState(){if(this.isSharedMode){if(this.wsManager&&this.wsManager.isConnected()){this.wsManager.sendWithOpId({type:"update_viewed_state",state:this.viewedState});return}if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(JSON.stringify({type:"update_viewed_state",state:this.viewedState}));return}console.warn("[ViewedManager] Cannot save state - shared mode but no WebSocket connection");return}localStorage.setItem(M(this.filePath),JSON.stringify(this.viewedState))}applyViewedState(){this.sectionHeadingIds().forEach(e=>{this.shouldCollapse(e)?this.collapseSection(e):this.expandSection(e)}),this.updateTocHighlights(),this.updateAllViewedCheckbox()}setupEventListeners(){document.querySelectorAll(".viewed-checkbox").forEach(e=>{e.addEventListener("change",t=>{let n=t.target,o=n.dataset.headingId;o&&(this.cancelNoteSourceRevealForHeading(o),this.toggleViewed(o,n.checked))})}),document.querySelectorAll(".section-expand-toggle").forEach(e=>{e.addEventListener("click",t=>{t.stopPropagation();let o=t.target.dataset.headingId;o&&(this.cancelNoteSourceRevealForHeading(o),this.toggleTempExpand(o))})}),document.querySelectorAll(".section-print-btn").forEach(e=>{e.addEventListener("click",t=>{t.stopPropagation();let o=t.target.dataset.headingId;o&&this.printSection(o)})}),document.querySelectorAll(".section-export-notes").forEach(e=>{e.addEventListener("click",t=>{t.stopPropagation();let n=t.currentTarget;if(n.getAttribute("aria-disabled")==="true")return;let o=n.dataset.headingId;o&&window.markonExportNotes?.(n,o)})})}createToolbar(){let e=document.querySelector(".markdown-body h1");if(!e)return;let t=document.createElement("label");t.className="viewed-checkbox-label viewed-all-label",t.title=i("web.viewed.all.tip");let n=document.createElement("input");n.type="checkbox",n.className="viewed-checkbox viewed-all-checkbox",n.tabIndex=-1;let o=document.createElement("span");o.className="viewed-text",o.textContent=i("web.viewed.all"),t.appendChild(n),t.appendChild(o);let a=document.createElement("span");a.className="viewed-toolbar",a.appendChild(t),a.insertAdjacentHTML("beforeend",`
            <span class="viewed-toolbar-item"><span class="viewed-toolbar-separator">|</span><a class="btn-collapse-all">${i("web.viewed.collapseall")}</a></span>
            <span class="viewed-toolbar-item"><span class="viewed-toolbar-separator">|</span><a class="btn-expand-all">${i("web.viewed.expandall")}</a></span>
            <span class="viewed-toolbar-item"><span class="viewed-toolbar-separator">|</span><a class="btn-print-page">${i("web.viewed.print")}</a></span>
            <span class="viewed-toolbar-item"><span class="viewed-toolbar-separator">|</span><a class="btn-export-notes" title="${i("web.export.tip")}">${i("web.export.label")}</a></span>
        `),e.appendChild(a),this.allViewedCheckbox=n,this.updatingAllViewedCheckbox=!1,n.addEventListener("change",r=>{if(this.updatingAllViewedCheckbox)return;r.target.checked?this.markAllViewed():this.markAllUnviewed()}),a.querySelector(".btn-collapse-all")?.addEventListener("click",()=>this.collapseAll()),a.querySelector(".btn-expand-all")?.addEventListener("click",()=>this.expandAll()),a.querySelector(".btn-print-page")?.addEventListener("click",()=>{window.print()}),a.querySelector(".btn-export-notes")?.addEventListener("click",r=>{let s=r.currentTarget;if(s.getAttribute("aria-disabled")==="true"){r.preventDefault();return}window.markonExportNotes?.(s)}),this.updateExportNotesButtons()}updateExportNotesButtons(){let e=document.querySelector(".btn-export-notes");if(e){let t=Math.max(0,window.markonNotesCount?.()??0);e.textContent=f(t);let n=t===0;e.classList.toggle("is-disabled",n),e.setAttribute("aria-disabled",n?"true":"false"),n?e.setAttribute("tabindex","-1"):e.removeAttribute("tabindex")}document.querySelectorAll(".section-export-notes").forEach(t=>{let n=t.dataset.headingId,o=Math.max(0,n?window.markonNotesCount?.(n)??0:0);t.textContent=f(o);let a=o===0;t.classList.toggle("is-disabled",a),t.setAttribute("aria-disabled",a?"true":"false"),a?t.setAttribute("tabindex","-1"):t.removeAttribute("tabindex")})}markAllViewed(){this.cancelNoteSourceReveal(),this.sectionHeadingIds().forEach(e=>{this.viewedState[e]=!0,this.collapsedState[e]=!0,this.collapseSection(e)}),this.updateCheckboxes(),this.updateTocHighlights(),this.saveState(),this.saveCollapsedState(),this.allViewedCheckbox&&(this.updatingAllViewedCheckbox=!0,this.allViewedCheckbox.checked=!0,this.updatingAllViewedCheckbox=!1)}markAllUnviewed(){this.cancelNoteSourceReveal(),this.viewedState={},this.sectionHeadingIds().forEach(e=>{this.collapsedState[e]=!1}),this.updateCheckboxes(),this.applyViewedState(),this.updateTocHighlights(),this.saveState(),this.saveCollapsedState()}collapseAll(){this.cancelNoteSourceReveal(),L(!0).forEach(e=>{e.id&&(this.collapsedState[e.id]=!0,this.collapseSection(e.id))}),this.saveCollapsedState()}expandAll(){this.cancelNoteSourceReveal(),L(!1).forEach(e=>{e.id&&(this.collapsedState[e.id]=!1,e.classList.remove("section-collapsed"),this.removeCollapsedPlaceholder(e),this.syncToggleBtn(e,!1))}),document.querySelectorAll(".markdown-body .section-content-hidden, .markdown-body .section-content-temp-visible").forEach(e=>{e.classList.remove("section-content-hidden"),e.classList.remove("section-content-temp-visible"),delete e.dataset.markonRevealToken}),this.saveCollapsedState()}updateTocHighlights(){document.querySelectorAll(".toc-item").forEach(t=>{let n=t.querySelector("a");if(!n)return;let o=n.getAttribute("href");if(!o?.startsWith("#"))return;let a=o.substring(1);this.viewedState[a]?t.classList.add("viewed"):t.classList.remove("viewed")})}};function S(){if(document.querySelector(".markdown-body")){let m=window.isSharedAnnotationMode||!1,e=window.ws??null;window.viewedManager=new y(m,e);let t=()=>{document.dispatchEvent(new CustomEvent("markon:viewed-ready"))};window.viewedManager.ready.then(t,t)}}document.querySelector(".markdown-body")?S():document.readyState==="loading"?document.addEventListener("DOMContentLoaded",S):S();})();