h&&(h=S.offsetWidth+A)}let v,g;const u=m+10,b=f+10,x=(u+b)/2,E=e.theme.cssVar["--color"];d===j.LHS?(v=De(`M ${p+10} ${u} c -5 0 -10 5 -10 10 L ${p} ${b-10} c 0 5 5 10 10 10 M ${p} ${x} h -10`,E),g=He(i,p-20,x+6,"end",E)):(v=De(`M ${h-10} ${u} c 5 0 10 5 10 10 L ${h} ${b-10} c 0 5 -5 10 -10 10 M ${h} ${x} h 10`,E),g=He(i,h+20,x+6,"start",E));const y=Pn("s-"+o);return y.appendChild(v),y.appendChild(g),y.summaryObj=t,e.summarySvg.appendChild(y),y},Yn=function(){let e=[];this.currentNode?e=[this.currentNode]:this.currentNodes&&(e=this.currentNodes);const{parent:t,start:n,end:o}=$n(e),i={id:q(),parent:t,start:n,end:o,text:"summary"},r=Ne(this,i);this.summaries.push(i),this.editSummary(r),this.bus.fire("operation",{name:"createSummary",obj:i})},Fn=function(e){const t=q(),n={...e,id:t};Ne(this,n),this.summaries.push(n),this.bus.fire("operation",{name:"createSummary",obj:n})},Wn=function(e){var t;const n=this.summaries.findIndex(o=>o.id===e);n>-1&&(this.summaries.splice(n,1),(t=document.querySelector("#s-"+e))==null||t.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:e}})},Vn=function(e){const t=e.children[1].getBBox(),n=6,o=3,i=document.createElementNS("http://www.w3.org/2000/svg","rect");w(i,{x:t.x-n+"",y:t.y-n+"",width:t.width+n*2+"",height:t.height+n*2+"",rx:o+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),e.appendChild(i),this.currentSummary=e},qn=function(){var e,t;(t=(e=this.currentSummary)==null?void 0:e.querySelector("rect"))==null||t.remove(),this.currentSummary=null},Kn=function(){this.summarySvg.innerHTML="",this.summaries.forEach(e=>{try{Ne(this,e)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},Un=function(e){if(!e)return;const t=e.childNodes[1];Re(this,t,n=>{var o;const i=e.summaryObj,r=((o=n.textContent)==null?void 0:o.trim())||"";r===""?i.text=origin:i.text=r,n.remove(),r!==origin&&(t.innerHTML=i.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:i}))})},Zn=Object.freeze(Object.defineProperty({__proto__:null,createSummary:Yn,createSummaryFrom:Fn,editSummary:Un,removeSummary:Wn,renderSummary:Kn,selectSummary:Vn,unselectSummary:qn},Symbol.toStringTag,{value:"Module"})),z="http://www.w3.org/2000/svg";function Jn(e,t){const n=document.createElementNS(z,"svg");return w(n,{version:"1.1",xmlns:z,height:e,width:t}),n}function Gn(e,t){return(parseInt(e)-parseInt(t))/2}function Xn(e,t,n,o){const i=document.createElementNS(z,"g");let r="";return e.text?r=e.text.textContent:r=e.childNodes[0].textContent,r.split(`
`).forEach((s,a)=>{const l=document.createElementNS(z,"text");w(l,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+Gn(t.lineHeight,t.fontSize)*(a+1)+parseFloat(t.fontSize)*(a+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),l.innerHTML=s,i.appendChild(l)}),i}function Qn(e,t,n,o){var i;let r="";(i=e.nodeObj)!=null&&i.dangerouslySetInnerHTML?r=e.nodeObj.dangerouslySetInnerHTML:e.text?r=e.text.textContent:r=e.childNodes[0].textContent;const s=document.createElementNS(z,"foreignObject");w(s,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const a=document.createElement("div");return w(a,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`}),a.innerHTML=r,s.appendChild(a),s}function eo(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),r=document.createElementNS(z,"rect");return w(r,{x:o+"",y:i+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),r}function ne(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:i,offsetTop:r}=P(e.nodes,t),s=document.createElementNS(z,"rect");w(s,{x:i+"",y:r+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const a=document.createElementNS(z,"g");a.appendChild(s);let l;return n?l=Qn(t,o,i,r):l=Xn(t,o,i,r),a.appendChild(l),a}function to(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),r=document.createElementNS(z,"a"),s=document.createElementNS(z,"text");return w(s,{x:o+"",y:i+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),s.innerHTML=t.textContent,r.appendChild(s),r.setAttribute("href",t.href),r}function no(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:i}=P(e.nodes,t),r=document.createElementNS(z,"image");return w(r,{x:o+"",y:i+"",width:n.width+"",height:n.height+"",href:t.src}),r}const oe=100,oo='',io=(e,t=!1)=>{var n,o,i;const r=e.nodes,s=r.offsetHeight+oe*2,a=r.offsetWidth+oe*2,l=Jn(s+"px",a+"px"),c=document.createElementNS(z,"svg"),d=document.createElementNS(z,"rect");w(d,{x:"0",y:"0",width:`${a}`,height:`${s}`,fill:e.theme.cssVar["--bgcolor"]}),l.appendChild(d),r.querySelectorAll(".subLines").forEach(f=>{const v=f.cloneNode(!0),{offsetLeft:g,offsetTop:u}=P(r,f.parentElement);v.setAttribute("x",`${g}`),v.setAttribute("y",`${u}`),c.appendChild(v)});const p=(n=r.querySelector(".lines"))==null?void 0:n.cloneNode(!0);p&&c.appendChild(p);const h=(o=r.querySelector(".topiclinks"))==null?void 0:o.cloneNode(!0);h&&c.appendChild(h);const m=(i=r.querySelector(".summary"))==null?void 0:i.cloneNode(!0);return m&&c.appendChild(m),r.querySelectorAll("me-tpc").forEach(f=>{f.nodeObj.dangerouslySetInnerHTML?c.appendChild(ne(e,f,!t)):(c.appendChild(eo(e,f)),c.appendChild(ne(e,f.text,!t)))}),r.querySelectorAll(".tags > span").forEach(f=>{c.appendChild(ne(e,f))}),r.querySelectorAll(".icons > span").forEach(f=>{c.appendChild(ne(e,f))}),r.querySelectorAll(".hyper-link").forEach(f=>{c.appendChild(to(e,f))}),r.querySelectorAll("img").forEach(f=>{c.appendChild(no(e,f))}),w(c,{x:oe+"",y:oe+"",overflow:"visible"}),l.appendChild(c),l},ro=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin",""),oo+e.outerHTML);function so(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=i=>{t(i.target.result)},o.onerror=i=>{n(i)},o.readAsDataURL(e)})}const ao=function(e=!1,t){const n=io(this,e),o=ro(n,t);return new Blob([o],{type:"image/svg+xml"})},lo=async function(e=!1,t){const n=this.exportSvg(e,t),o=await so(n);return new Promise((i,r)=>{const s=new Image;s.setAttribute("crossOrigin","anonymous"),s.onload=()=>{const a=document.createElement("canvas");a.width=s.width,a.height=s.height,a.getContext("2d").drawImage(s,0,0),a.toBlob(i,"image/png",1)},s.src=o,s.onerror=r})},co=Object.freeze(Object.defineProperty({__proto__:null,exportPng:lo,exportSvg:ao},Symbol.toStringTag,{value:"Module"}));function ho(e,t){return async function(...n){const o=this.before[t];o&&!await o.apply(this,n)||e.apply(this,n)}}const Ie=Object.keys(Je),et={};for(let e=0;e