import{aX as Tt,aY as _t,aZ as O,a_ as At,a$ as Mt,b0 as Nt,b1 as G,b2 as Q,b3 as Ot,b4 as Pt,b5 as Lt,b6 as Bt,b7 as Ft}from"./vendor-CMAgGMFZ.js";const Rt="npm2url/dist/index.cjs",It={jsdelivr:t=>"https://cdn.jsdelivr.net/npm/".concat(t),unpkg:t=>"https://unpkg.com/".concat(t)};async function Dt(t,e){const n=await fetch(t,{signal:e});if(!n.ok)throw n;await n.text()}class Kt{constructor(){this.providers={...It},this.provider="jsdelivr"}async getFastestProvider(e=5e3,n=Rt){const r=new AbortController;let i=0;try{return await new Promise((s,o)=>{Promise.all(Object.entries(this.providers).map(async([l,c])=>{try{await Dt(c(n),r.signal),s(l)}catch(p){}})).then(()=>o(new Error("All providers failed"))),i=setTimeout(o,e,new Error("Timed out"))})}finally{r.abort(),clearTimeout(i)}}async findFastestProvider(e,n){return this.provider=await this.getFastestProvider(e,n),this.provider}setProvider(e,n){n?this.providers[e]=n:delete this.providers[e]}getFullUrl(e,n=this.provider){if(e.includes("://"))return e;const r=this.providers[n];if(!r)throw new Error("Provider ".concat(n," not found"));return r(e)}}class w{constructor(){this.listeners=[]}tap(e){return this.listeners.push(e),()=>this.revoke(e)}revoke(e){const n=this.listeners.indexOf(e);n>=0&&this.listeners.splice(n,1)}revokeAll(){this.listeners.splice(0)}call(...e){for(const n of this.listeners)n(...e)}}const Jt={"&":"&amp;","<":"&lt;",'"':"&quot;"};function tt(t){return t.replace(/[&<"]/g,e=>Jt[e])}function Ut(t){return t.replace(/<(\/script>)/g,"\\x3c$2")}function et(t,e){const n=e?Object.entries(e).map(([r,i])=>{if(!(i==null||i===!1))return r=" ".concat(tt(r)),i===!0?r:"".concat(r,'="').concat(tt(i),'"')}).filter(Boolean).join(""):"";return"<".concat(t).concat(n,">")}function Ht(t){return"</".concat(t,">")}function A(t,e,n){return e==null?et(t,n):et(t,n)+(e||"")+Ht(t)}function Yt(t,e){const n=e.map(r=>typeof r=="function"?r.toString():JSON.stringify(r!=null?r:null)).join(",");return"(".concat(t.toString(),")(").concat(n,")")}function Vt(t,e){return t.map(n=>{if(n.type==="script"){const{textContent:r,...i}=n.data;return A("script",r||"",i)}if(n.type==="iife"){const{fn:r,getParams:i}=n.data;return A("script",Ut(Yt(r,(i==null?void 0:i(e))||[])))}return""})}function Wt(t){return t.map(e=>e.type==="stylesheet"?A("link",null,{rel:"stylesheet",...e.data}):A("style",e.data))}const qt=Math.random().toString(36).slice(2,8);let nt=0;function Zt(){return nt+=1,"mm-".concat(qt,"-").concat(nt)}function $(){}function P(t,e){const n=(r,i)=>e(r,()=>{var s;(s=r.children)==null||s.forEach(o=>{n(o,r)})},i);n(t)}function Gt(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(r=>{r&&n.indexOf(r)<0&&n.push(r)}),n.join(" ")}function z(t){if(typeof t=="string"){const n=t;t=r=>r.tagName===n}const e=t;return function(){let r=Array.from(this.childNodes);return e&&(r=r.filter(i=>e(i))),r}}function Qt(t,e){return(...n)=>e(t,...n)}function te(){const t={};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}function ee(t){const e={};return function(...r){const i="".concat(r[0]);let s=e[i];return s||(s={value:t(...r)},e[i]=s),s.value}}/*! @gera2ld/jsx-dom v2.2.2 | ISC License */const ct=1,ht=2,ne="http://www.w3.org/2000/svg",L="http://www.w3.org/1999/xlink",re={show:L,actuate:L,href:L},ie=t=>typeof t=="string"||typeof t=="number",se=t=>(t==null?void 0:t.vtype)===ct,ae=t=>(t==null?void 0:t.vtype)===ht;function oe(t,e,...n){return e=Object.assign({},e,{children:n.length===1?n[0]:n}),le(t,e)}function le(t,e){let n;if(typeof t=="string")n=ct;else if(typeof t=="function")n=ht;else throw new Error("Invalid VNode type");return{vtype:n,type:t,props:e}}function ce(t){return t.children}const he={isSvg:!1};function rt(t,e){Array.isArray(e)||(e=[e]),e=e.filter(Boolean),e.length&&t.append(...e)}function de(t,e,n){for(const r in e)if(!(r==="key"||r==="children"||r==="ref"))if(r==="dangerouslySetInnerHTML")t.innerHTML=e[r].__html;else if(r==="innerHTML"||r==="textContent"||r==="innerText"||r==="value"&&["textarea","select"].includes(t.tagName)){const i=e[r];i!=null&&(t[r]=i)}else r.startsWith("on")?t[r.toLowerCase()]=e[r]:pe(t,r,e[r],n.isSvg)}const ue={className:"class",labelFor:"for"};function pe(t,e,n,r){if(e=ue[e]||e,n===!0)t.setAttribute(e,"");else if(n===!1)t.removeAttribute(e);else{const i=r?re[e]:void 0;i!==void 0?t.setAttributeNS(i,e,n):t.setAttribute(e,n)}}function fe(t){return t.reduce((e,n)=>e.concat(n),[])}function D(t,e){return Array.isArray(t)?fe(t.map(n=>D(n,e))):H(t,e)}function H(t,e=he){if(t==null||typeof t=="boolean")return null;if(t instanceof Node)return t;if(ae(t)){const{type:n,props:r}=t;if(n===ce){const s=document.createDocumentFragment();if(r.children){const o=D(r.children,e);rt(s,o)}return s}const i=n(r);return H(i,e)}if(ie(t))return document.createTextNode("".concat(t));if(se(t)){let n;const{type:r,props:i}=t;if(!e.isSvg&&r==="svg"&&(e=Object.assign({},e,{isSvg:!0})),e.isSvg?n=document.createElementNS(ne,r):n=document.createElement(r),de(n,i,e),i.children){let o=e;e.isSvg&&r==="foreignObject"&&(o=Object.assign({},o,{isSvg:!1}));const l=D(i.children,o);l!=null&&rt(n,l)}const{ref:s}=i;return typeof s=="function"&&s(n),n}throw new Error("mount: Invalid Vnode!")}function me(t){return H(t)}function dt(...t){return me(oe(...t))}const ge=ee(t=>{document.head.append(dt("link",{rel:"preload",as:"script",href:t}))}),it={};async function ye(t,e){var n;const r=t.type==="script"&&((n=t.data)==null?void 0:n.src)||"";if(t.loaded||(t.loaded=it[r]),!t.loaded){const i=te();if(t.loaded=i.promise,t.type==="script"&&(document.head.append(dt("script",{...t.data,onLoad:()=>i.resolve(),onError:i.reject})),r?it[r]=t.loaded:i.resolve()),t.type==="iife"){const{fn:s,getParams:o}=t.data;s(...(o==null?void 0:o(e))||[]),i.resolve()}}await t.loaded}async function ut(t,e){t.forEach(n=>{var r;n.type==="script"&&((r=n.data)!=null&&r.src)&&ge(n.data.src)}),e={getMarkmap:()=>window.markmap,...e};for(const n of t)await ye(n,e)}function N(t){return{type:"script",data:{src:t}}}function pt(t){return{type:"stylesheet",data:{href:t}}}/*! @gera2ld/jsx-dom v2.2.2 | ISC License */const ft=1,mt=2,ve="http://www.w3.org/2000/svg",B="http://www.w3.org/1999/xlink",xe={show:B,actuate:B,href:B},Se=t=>typeof t=="string"||typeof t=="number",be=t=>(t==null?void 0:t.vtype)===ft,we=t=>(t==null?void 0:t.vtype)===mt;function _(t,e){let n;if(typeof t=="string")n=ft;else if(typeof t=="function")n=mt;else throw new Error("Invalid VNode type");return{vtype:n,type:t,props:e}}function ke(t){return t.children}const ze={isSvg:!1};function st(t,e){Array.isArray(e)||(e=[e]),e=e.filter(Boolean),e.length&&t.append(...e)}function Ee(t,e,n){for(const r in e)if(!(r==="key"||r==="children"||r==="ref"))if(r==="dangerouslySetInnerHTML")t.innerHTML=e[r].__html;else if(r==="innerHTML"||r==="textContent"||r==="innerText"||r==="value"&&["textarea","select"].includes(t.tagName)){const i=e[r];i!=null&&(t[r]=i)}else r.startsWith("on")?t[r.toLowerCase()]=e[r]:$e(t,r,e[r],n.isSvg)}const je={className:"class",labelFor:"for"};function $e(t,e,n,r){if(e=je[e]||e,n===!0)t.setAttribute(e,"");else if(n===!1)t.removeAttribute(e);else{const i=r?xe[e]:void 0;i!==void 0?t.setAttributeNS(i,e,n):t.setAttribute(e,n)}}function Ce(t){return t.reduce((e,n)=>e.concat(n),[])}function K(t,e){return Array.isArray(t)?Ce(t.map(n=>K(n,e))):Y(t,e)}function Y(t,e=ze){if(t==null||typeof t=="boolean")return null;if(t instanceof Node)return t;if(we(t)){const{type:n,props:r}=t;if(n===ke){const s=document.createDocumentFragment();if(r.children){const o=K(r.children,e);st(s,o)}return s}const i=n(r);return Y(i,e)}if(Se(t))return document.createTextNode("".concat(t));if(be(t)){let n;const{type:r,props:i}=t;if(!e.isSvg&&r==="svg"&&(e=Object.assign({},e,{isSvg:!0})),e.isSvg?n=document.createElementNS(ve,r):n=document.createElement(r),Ee(n,i,e),i.children){let o=e;e.isSvg&&r==="foreignObject"&&(o=Object.assign({},o,{isSvg:!1}));const l=K(i.children,o);l!=null&&st(n,l)}const{ref:s}=i;return typeof s=="function"&&s(n),n}throw new Error("mount: Invalid Vnode!")}function F(t){return Y(t)}function Xe(t){var e=0,n=t.children,r=n&&n.length;if(!r)e=1;else for(;--r>=0;)e+=n[r].value;t.value=e}function Te(){return this.eachAfter(Xe)}function _e(t){var e=this,n,r=[e],i,s,o;do for(n=r.reverse(),r=[];e=n.pop();)if(t(e),i=e.children,i)for(s=0,o=i.length;s<o;++s)r.push(i[s]);while(r.length);return this}function Ae(t){for(var e=this,n=[e],r,i;e=n.pop();)if(t(e),r=e.children,r)for(i=r.length-1;i>=0;--i)n.push(r[i]);return this}function Me(t){for(var e=this,n=[e],r=[],i,s,o;e=n.pop();)if(r.push(e),i=e.children,i)for(s=0,o=i.length;s<o;++s)n.push(i[s]);for(;e=r.pop();)t(e);return this}function Ne(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})}function Oe(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function Pe(t){for(var e=this,n=Le(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r}function Le(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}function Be(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function Fe(){var t=[];return this.each(function(e){t.push(e)}),t}function Re(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function Ie(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e}function V(t,e){var n=new M(t),r=+t.value&&(n.value=t.value),i,s=[n],o,l,c,p;for(e==null&&(e=Ke);i=s.pop();)if(r&&(i.value=+i.data.value),(l=e(i.data))&&(p=l.length))for(i.children=new Array(p),c=p-1;c>=0;--c)s.push(o=i.children[c]=new M(l[c])),o.parent=i,o.depth=i.depth+1;return n.eachBefore(Ue)}function De(){return V(this).eachBefore(Je)}function Ke(t){return t.children}function Je(t){t.data=t.data.data}function Ue(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function M(t){this.data=t,this.depth=this.height=0,this.parent=null}M.prototype=V.prototype={constructor:M,count:Te,each:_e,eachAfter:Me,eachBefore:Ae,sum:Ne,sort:Oe,path:Pe,ancestors:Be,descendants:Fe,leaves:Re,links:Ie,copy:De};const He="d3-flextree",Ye="2.1.2",Ve="build/d3-flextree.js",We="index",qe={name:"Chris Maloney",url:"http://chrismaloney.org"},Ze="Flexible tree layout algorithm that allows for variable node sizes.",Ge=["d3","d3-module","layout","tree","hierarchy","d3-hierarchy","plugin","d3-plugin","infovis","visualization","2d"],Qe="https://github.com/klortho/d3-flextree",tn="WTFPL",en={type:"git",url:"https://github.com/klortho/d3-flextree.git"},nn={clean:"rm -rf build demo test","build:demo":"rollup -c --environment BUILD:demo","build:dev":"rollup -c --environment BUILD:dev","build:prod":"rollup -c --environment BUILD:prod","build:test":"rollup -c --environment BUILD:test",build:"rollup -c",lint:"eslint index.js src","test:main":"node test/bundle.js","test:browser":"node test/browser-tests.js",test:"npm-run-all test:*",prepare:"npm-run-all clean build lint test"},rn={"d3-hierarchy":"^1.1.5"},sn={"babel-plugin-external-helpers":"^6.22.0","babel-preset-es2015-rollup":"^3.0.0",d3:"^4.13.0","d3-selection-multi":"^1.0.1",eslint:"^4.19.1",jsdom:"^11.6.2","npm-run-all":"^4.1.2",rollup:"^0.55.3","rollup-plugin-babel":"^2.7.1","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-copy":"^0.2.3","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.2","rollup-plugin-uglify":"^3.0.0","uglify-es":"^3.3.9"},an={name:He,version:Ye,main:Ve,module:We,"jsnext:main":"index",author:qe,description:Ze,keywords:Ge,homepage:Qe,license:tn,repository:en,scripts:nn,dependencies:rn,devDependencies:sn},{version:on}=an,ln=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function yt(t){const e=Object.assign({},ln,t);function n(l){const c=e[l];return typeof c=="function"?c:()=>c}function r(l){const c=o(s(),l,p=>p.children);return c.update(),c.data}function i(){const l=n("nodeSize"),c=n("spacing");return class gt extends V.prototype.constructor{constructor(h){super(h)}copy(){const h=o(this.constructor,this,d=>d.children);return h.each(d=>d.data=d.data.data),h}get size(){return l(this)}spacing(h){return c(this,h)}get nodes(){return this.descendants()}get xSize(){return this.size[0]}get ySize(){return this.size[1]}get top(){return this.y}get bottom(){return this.y+this.ySize}get left(){return this.x-this.xSize/2}get right(){return this.x+this.xSize/2}get root(){const h=this.ancestors();return h[h.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return this.children===null}get firstChild(){return this.hasChildren?this.children[0]:null}get lastChild(){return this.hasChildren?this.children[this.numChildren-1]:null}get extents(){return(this.children||[]).reduce((h,d)=>gt.maxExtents(h,d.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(h,d){return{top:Math.min(h.top,d.top),bottom:Math.max(h.bottom,d.bottom),left:Math.min(h.left,d.left),right:Math.max(h.right,d.right)}}}}function s(){const l=i(),c=n("nodeSize"),p=n("spacing");return class extends l{constructor(h){super(h),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return c(this.data)}spacing(h){return p(this.data,h.data)}get x(){return this.data.x}set x(h){this.data.x=h}get y(){return this.data.y}set y(h){this.data.y=h}update(){return vt(this),xt(this),this}}}function o(l,c,p){const h=(d,m)=>{const u=new l(d);Object.assign(u,{parent:m,depth:m===null?0:m.depth+1,height:0,length:1});const y=p(d)||[];return u.children=y.length===0?null:y.map(x=>h(x,u)),u.children&&Object.assign(u,u.children.reduce((x,g)=>({height:Math.max(x.height,g.height+1),length:x.length+g.length}),u)),u};return h(c,null)}return Object.assign(r,{nodeSize(l){return arguments.length?(e.nodeSize=l,r):e.nodeSize},spacing(l){return arguments.length?(e.spacing=l,r):e.spacing},children(l){return arguments.length?(e.children=l,r):e.children},hierarchy(l,c){const p=typeof c>"u"?e.children:c;return o(i(),l,p)},dump(l){const c=n("nodeSize"),p=h=>d=>{const m=h+"  ",u=h+"    ",{x:y,y:x}=d,g=c(d),v=d.children||[],b=v.length===0?" ":",".concat(m,"children: [").concat(u).concat(v.map(p(u)).join(u)).concat(m,"],").concat(h);return"{ size: [".concat(g.join(", "),"],").concat(m,"x: ").concat(y,", y: ").concat(x).concat(b,"},")};return p("\n")(l)}}),r}yt.version=on;const vt=(t,e=0)=>(t.y=e,(t.children||[]).reduce((n,r)=>{const[i,s]=n;vt(r,t.y+t.ySize);const o=(i===0?r.lExt:r.rExt).bottom;i!==0&&hn(t,i,s);const l=vn(o,i,s);return[i+1,l]},[0,null]),cn(t),yn(t),t),xt=(t,e,n)=>{typeof e>"u"&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(i=>xt(i,r,t.x)),t},cn=t=>{(t.children||[]).reduce((e,n)=>{const[r,i]=e,s=r+n.shift,o=i+s+n.change;return n.relX+=o,[s,o]},[0,0])},hn=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,o=r.relX,l=i,c=i.relX,p=!0;for(;s&&l;){s.bottom>n.lowY&&(n=n.next);const h=o+s.prelim-(c+l.prelim)+s.xSize/2+l.xSize/2+s.spacing(l);(h>0||h<0&&p)&&(c+=h,dn(i,h),un(t,e,n.index,h)),p=!1;const d=s.bottom,m=l.bottom;d<=m&&(s=fn(s),s&&(o+=s.relX)),d>=m&&(l=pn(l),l&&(c+=l.relX))}!s&&l?mn(t,e,l,c):s&&!l&&gn(t,e,s,o)},dn=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},un=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const o=r/s;t.children[n+1].shift+=o,i.shift-=o,i.change-=r-o}},pn=t=>t.hasChildren?t.firstChild:t.lThr,fn=t=>t.hasChildren?t.lastChild:t.rThr,mn=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,o=t.children[e];s.lThr=n;const l=r-n.relX-i.lExtRelX;s.relX+=l,s.prelim-=l,i.lExt=o.lExt,i.lExtRelX=o.lExtRelX},gn=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,o=t.children[e-1];s.rThr=n;const l=r-n.relX-i.rExtRelX;s.relX+=l,s.prelim-=l,i.rExt=o.rExt,i.rExtRelX=o.rExtRelX},yn=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},vn=(t,e,n)=>{for(;n!==null&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}},xn=".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:#555;background-color:#f0f0f0;border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}",Sn=".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}";function at(t){const e=t.data;return Math.max(4-2*e.depth,1.5)}function ot(t,e){const n=Pt(t,e);return t[n]}function R(t){t.stopPropagation()}function bn(){return{transformHtml:new w}}const wn=new w,kn=Tt(_t),St=typeof navigator<"u"&&navigator.userAgent.includes("Macintosh"),bt=class J{constructor(e,n){this.options=J.defaultOptions,this.revokers=[],this.handleZoom=r=>{const{transform:i}=r;this.g.attr("transform",i)},this.handlePan=r=>{r.preventDefault();const i=O(this.svg.node()),s=i.translate(-r.deltaX/i.k,-r.deltaY/i.k);this.svg.call(this.zoom.transform,s)},this.handleClick=(r,i)=>{let s=this.options.toggleRecursively;(St?r.metaKey:r.ctrlKey)&&(s=!s),this.toggleNode(i.data,s)},this.viewHooks=bn(),this.svg=e.datum?e:At(e),this.styleNode=this.svg.append("style"),this.zoom=Mt().filter(r=>this.options.scrollForPan&&r.type==="wheel"?r.ctrlKey&&!r.button:(!r.ctrlKey||r.type==="wheel")&&!r.button).on("zoom",this.handleZoom),this.setOptions(n),this.state={id:this.options.id||this.svg.attr("id")||Zt(),minX:0,maxX:0,minY:0,maxY:0},this.g=this.svg.append("g"),this.revokers.push(wn.tap(()=>{this.setData()}))}getStyleContent(){const{style:e}=this.options,{id:n}=this.state,r=typeof e=="function"?e(n):"";return[this.options.embedGlobalCSS&&xn,r].filter(Boolean).join("\n")}updateStyle(){this.svg.attr("class",Gt(this.svg.attr("class"),"markmap",this.state.id));const e=this.getStyleContent();this.styleNode.text(e)}toggleNode(e,n=!1){var r,i;const s=(r=e.payload)!=null&&r.fold?0:1;n?P(e,(o,l)=>{o.payload={...o.payload,fold:s},l()}):e.payload={...e.payload,fold:(i=e.payload)!=null&&i.fold?0:1},this.renderData(e)}initializeData(e){let n=0;const{color:r,nodeMinHeight:i,maxWidth:s,initialExpandLevel:o}=this.options,{id:l}=this.state,c=F(_("div",{className:"markmap-container markmap ".concat(l,"-g")})),p=F(_("style",{children:[this.getStyleContent(),Sn].join("\n")}));document.body.append(c,p);const h=s?"max-width: ".concat(s,"px"):"";let d=0;P(e,(u,y,x)=>{var g,v,b;u.children=(g=u.children)==null?void 0:g.map(E=>({...E})),n+=1;const k=F(_("div",{className:"markmap-foreign",style:h,children:_("div",{dangerouslySetInnerHTML:{__html:u.content}})}));c.append(k),u.state={...u.state,id:n,el:k.firstChild},u.state.path=[(v=x==null?void 0:x.state)==null?void 0:v.path,u.state.id].filter(Boolean).join("."),r(u);const C=((b=u.payload)==null?void 0:b.fold)===2;C?d+=1:(d||o>=0&&u.depth>=o)&&(u.payload={...u.payload,fold:1}),y(),C&&(d-=1)});const m=Array.from(c.childNodes).map(u=>u.firstChild);this.viewHooks.transformHtml.call(this,m),m.forEach(u=>{var y;(y=u.parentNode)==null||y.append(u.cloneNode(!0))}),P(e,(u,y,x)=>{var g;const v=u.state,b=v.el.getBoundingClientRect();u.content=v.el.innerHTML,v.size=[Math.ceil(b.width)+1,Math.max(Math.ceil(b.height),i)],v.key=[(g=x==null?void 0:x.state)==null?void 0:g.id,v.id].filter(Boolean).join(".")+u.content,y()}),c.remove(),p.remove()}setOptions(e){this.options={...this.options,...e},this.options.zoom?this.svg.call(this.zoom):this.svg.on(".zoom",null),this.options.pan?this.svg.on("wheel",this.handlePan):this.svg.on("wheel",null)}setData(e,n){n&&this.setOptions(n),e&&(this.state.data=e),this.state.data&&(this.initializeData(this.state.data),this.updateStyle(),this.renderData())}renderData(e){var q,Z;if(!this.state.data)return;const{spacingHorizontal:n,paddingX:r,spacingVertical:i,autoFit:s,color:o}=this.options,l=yt({}).children(a=>{var f;if(!((f=a.payload)!=null&&f.fold))return a.children}).nodeSize(a=>{const[f,S]=a.data.state.size;return[S,f+(f?r*2:0)+n]}).spacing((a,f)=>a.parent===f.parent?i:i*2),c=l.hierarchy(this.state.data);l(c);const p=c.descendants().reverse(),h=c.links(),d=Nt(),m=G(p,a=>a.x-a.xSize/2),u=Q(p,a=>a.x+a.xSize/2),y=G(p,a=>a.y),x=Q(p,a=>a.y+a.ySize-n);Object.assign(this.state,{minX:m,maxX:u,minY:y,maxY:x}),s&&this.fit();const g=e&&p.find(a=>a.data===e)||c,v=(q=g.data.state.x0)!=null?q:g.x,b=(Z=g.data.state.y0)!=null?Z:g.y,k=this.g.selectAll(z("g")).data(p,a=>a.data.state.key),C=k.enter().append("g").attr("data-depth",a=>a.data.depth).attr("data-path",a=>a.data.state.path).attr("transform",a=>"translate(".concat(b+g.ySize-a.ySize,",").concat(v+g.xSize/2-a.xSize,")")),E=this.transition(k.exit());E.select("line").attr("x1",a=>a.ySize-n).attr("x2",a=>a.ySize-n),E.select("foreignObject").style("opacity",0),E.attr("transform",a=>"translate(".concat(g.y+g.ySize-a.ySize,",").concat(g.x+g.xSize/2-a.xSize,")")).remove();const X=k.merge(C).attr("class",a=>{var f;return["markmap-node",((f=a.data.payload)==null?void 0:f.fold)&&"markmap-fold"].filter(Boolean).join(" ")});this.transition(X).attr("transform",a=>"translate(".concat(a.y,",").concat(a.x-a.xSize/2,")"));const Et=X.selectAll(z("line")).data(a=>[a],a=>a.data.state.key).join(a=>a.append("line").attr("x1",f=>f.ySize-n).attr("x2",f=>f.ySize-n),a=>a,a=>a.remove());this.transition(Et).attr("x1",-1).attr("x2",a=>a.ySize-n+2).attr("y1",a=>a.xSize).attr("y2",a=>a.xSize).attr("stroke",a=>o(a.data)).attr("stroke-width",at);const jt=X.selectAll(z("circle")).data(a=>{var f;return(f=a.data.children)!=null&&f.length?[a]:[]},a=>a.data.state.key).join(a=>a.append("circle").attr("stroke-width","1.5").attr("cx",f=>f.ySize-n).attr("cy",f=>f.xSize).attr("r",0).on("click",(f,S)=>this.handleClick(f,S)).on("mousedown",R),a=>a,a=>a.remove());this.transition(jt).attr("r",6).attr("cx",a=>a.ySize-n).attr("cy",a=>a.xSize).attr("stroke",a=>o(a.data)).attr("fill",a=>{var f;return(f=a.data.payload)!=null&&f.fold&&a.data.children?o(a.data):"#fff"});const $t=X.selectAll(z("foreignObject")).data(a=>[a],a=>a.data.state.key).join(a=>{const f=a.append("foreignObject").attr("class","markmap-foreign").attr("x",r).attr("y",0).style("opacity",0).on("mousedown",R).on("dblclick",R);return f.append("xhtml:div").select(function(S){const T=S.data.state.el.cloneNode(!0);return this.replaceWith(T),T}).attr("xmlns","http://www.w3.org/1999/xhtml"),f},a=>a,a=>a.remove()).attr("width",a=>Math.max(0,a.ySize-n-r*2)).attr("height",a=>a.xSize);this.transition($t).style("opacity",1);const Ct=this.g.selectAll(z("path")).data(h,a=>a.target.data.state.key).join(a=>{const f=[b+g.ySize-n,v+g.xSize/2];return a.insert("path","g").attr("class","markmap-link").attr("data-depth",S=>S.target.data.depth).attr("data-path",S=>S.target.data.state.path).attr("d",d({source:f,target:f}))},a=>a,a=>{const f=[g.y+g.ySize-n,g.x+g.xSize/2];return this.transition(a).attr("d",d({source:f,target:f})).remove()});this.transition(Ct).attr("stroke",a=>o(a.target.data)).attr("stroke-width",a=>at(a.target)).attr("d",a=>{const f=a.source,S=a.target,T=[f.y+f.ySize-n,f.x+f.xSize/2],Xt=[S.y,S.x+S.xSize/2];return d({source:T,target:Xt})}),p.forEach(a=>{a.data.state.x0=a.x,a.data.state.y0=a.y})}transition(e){const{duration:n}=this.options;return e.transition().duration(n)}async fit(){const e=this.svg.node(),{width:n,height:r}=e.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:o,minY:l,maxY:c}=this.state,p=c-l,h=o-s,d=Math.min(n/p*i,r/h*i,2),m=Ot.translate((n-p*d)/2-l*d,(r-h*d)/2-s*d).scale(d);return this.transition(this.svg).call(this.zoom.transform,m).end().catch($)}async ensureView(e,n){let r;if(this.g.selectAll(z("g")).each(function(v){v.data===e&&(r=v)}),!r)return;const i=this.svg.node(),{spacingHorizontal:s}=this.options,o=i.getBoundingClientRect(),l=O(i),[c,p]=[r.y,r.y+r.ySize-s+2].map(v=>v*l.k+l.x),[h,d]=[r.x-r.xSize/2,r.x+r.xSize/2].map(v=>v*l.k+l.y),m={left:0,right:0,top:0,bottom:0,...n},u=[m.left-c,o.width-m.right-p],y=[m.top-h,o.height-m.bottom-d],x=u[0]*u[1]>0?ot(u,Math.abs)/l.k:0,g=y[0]*y[1]>0?ot(y,Math.abs)/l.k:0;if(x||g){const v=l.translate(x,g);return this.transition(this.svg).call(this.zoom.transform,v).end().catch($)}}async rescale(e){const n=this.svg.node(),{width:r,height:i}=n.getBoundingClientRect(),s=r/2,o=i/2,l=O(n),c=l.translate((s-l.x)*(1-e)/l.k,(o-l.y)*(1-e)/l.k).scale(e);return this.transition(this.svg).call(this.zoom.transform,c).end().catch($)}destroy(){this.svg.on(".zoom",null),this.svg.html(null),this.revokers.forEach(e=>{e()})}static create(e,n,r=null){const i=new J(e,n);return r&&(i.setData(r),i.fit()),i}};bt.defaultOptions={autoFit:!1,color:t=>{var e;return kn("".concat(((e=t.state)==null?void 0:e.path)||""))},duration:500,embedGlobalCSS:!0,fitRatio:.95,maxWidth:0,nodeMinHeight:16,paddingX:8,scrollForPan:St,spacingHorizontal:80,spacingVertical:5,initialExpandLevel:-1,zoom:!0,pan:!0,toggleRecursively:!1};let Jn=bt;const zn='<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<meta name="viewport" content="width=device-width, initial-scale=1.0">\n<meta http-equiv="X-UA-Compatible" content="ie=edge">\n<title>Markmap</title>\n<style>\n* {\n  margin: 0;\n  padding: 0;\n}\n#mindmap {\n  display: block;\n  width: 100vw;\n  height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id="mindmap"></svg>\n<!--JS-->\n</body>\n</html>\n',En=["d3@7.8.5/dist/d3.min.js","markmap-view@0.15.8/dist/browser/index.js"],I="katex",jn=["katex@0.16.8/dist/katex.min.js"].map(t=>N(t)),wt=N("webfontloader@1.6.28/webfontloader.js");wt.data.defer=!0;const $n=["katex@0.16.8/dist/katex.min.css"].map(t=>pt(t)),Cn={versions:{katex:"0.16.8",webfontloader:"1.6.28"},preloadScripts:jn,scripts:[{type:"iife",data:{fn:t=>{window.WebFontConfig={custom:{families:["KaTeX_AMS","KaTeX_Caligraphic:n4,n7","KaTeX_Fraktur:n4,n7","KaTeX_Main:n4,n7,i4,i7","KaTeX_Math:i4,i7","KaTeX_Script","KaTeX_SansSerif:n4,n7,i4","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4","KaTeX_Typewriter"]},active:()=>{t().refreshHook.call()}}},getParams({getMarkmap:t}){return[t]}}},wt],styles:$n};function Xn(t,e,n){return t.map(r=>{if(typeof r=="string"&&!r.includes("://")){r.startsWith("npm:")||(r="npm:".concat(r));const i=4+e.length;r.startsWith("npm:".concat(e,"/"))&&(r="".concat(r.slice(0,i),"@").concat(n).concat(r.slice(i)))}return r})}function W(t,e){return e.type==="script"&&e.data.src?{...e,data:{...e.data,src:t.getFullUrl(e.data.src)}}:e}function Tn(t,e){return e.type==="stylesheet"&&e.data.href?{...e,data:{...e.data,href:t.getFullUrl(e.data.href)}}:e}function _n(t){return{transformer:t,parser:new w,beforeParse:new w,afterParse:new w,htmltag:new w,retransform:new w}}const j={name:I,config:Cn,transform(t){var e,n,r,i;let s;const o=((n=(e=j.config)==null?void 0:e.preloadScripts)==null?void 0:n.map(h=>W(t.transformer.urlBuilder,h)))||[],l=()=>(s||(s=ut(o)),s),c=(h,d)=>{const{katex:m}=window;return m?m.renderToString(h,{displayMode:d,throwOnError:!1}):(l().then(()=>{t.retransform.call()}),h)};let p=$;return t.parser.tap(h=>{h.use(Bt),h.renderer.rules.katex=(d,m)=>(p(),c(d[m].content,!!d[m].block))}),t.beforeParse.tap((h,d)=>{p=()=>{d.features[I]=!0}}),t.afterParse.tap((h,d)=>{var m;const u=(m=d.frontmatter)==null?void 0:m.markmap;u&&["extraJs","extraCss"].forEach(y=>{var x,g;const v=u[y];v&&(u[y]=Xn(v,I,((g=(x=j.config)==null?void 0:x.versions)==null?void 0:g.katex)||""))})}),{styles:(r=j.config)==null?void 0:r.styles,scripts:(i=j.config)==null?void 0:i.scripts}}},An="frontmatter",Mn={name:An,transform(t){return t.beforeParse.tap((e,n)=>{const{content:r}=n;if(!/^---\r?\n/.test(r))return;const i=/\n---\r?\n/.exec(r);if(!i)return;const s=r.slice(4,i.index);let o;try{o=Ft.load(s),o!=null&&o.markmap&&(o.markmap=Nn(o.markmap))}catch(l){return}n.frontmatter=o,n.content=r.slice(i.index+i[0].length),n.contentLineOffset=r.slice(0,i.index).split("\n").length+1}),{}}};function Nn(t){if(t)return["color","extraJs","extraCss"].forEach(e=>{t[e]!=null&&(t[e]=On(t[e]))}),["duration","maxWidth","initialExpandLevel"].forEach(e=>{t[e]!=null&&(t[e]=Pn(t[e]))}),t}function On(t){let e;return typeof t=="string"?e=[t]:Array.isArray(t)&&(e=t.filter(n=>n&&typeof n=="string")),e!=null&&e.length?e:void 0}function Pn(t){if(!isNaN(+t))return+t}const Ln="npmUrl",Bn={name:Ln,transform(t){return t.afterParse.tap((e,n)=>{const{frontmatter:r}=n,i=r==null?void 0:r.markmap;i&&["extraJs","extraCss"].forEach(s=>{const o=i[s];o&&(i[s]=o.map(l=>l.startsWith("npm:")?t.transformer.urlBuilder.getFullUrl(l.slice(4)):l))})}),{}}},lt="hljs",Fn=["@highlightjs/cdn-assets@11.8.0/highlight.min.js"].map(t=>N(t)),Rn=["@highlightjs/cdn-assets@11.8.0/styles/default.min.css"].map(t=>pt(t)),In={versions:{hljs:"11.8.0"},preloadScripts:Fn,styles:Rn},U={name:lt,config:In,transform(t){var e,n,r;let i;const s=((n=(e=U.config)==null?void 0:e.preloadScripts)==null?void 0:n.map(c=>W(t.transformer.urlBuilder,c)))||[],o=()=>(i||(i=ut(s)),i);let l=$;return t.parser.tap(c=>{c.set({highlight:(p,h)=>{l();const{hljs:d}=window;return d?d.highlightAuto(p,h?[h]:void 0).value:(o().then(()=>{t.retransform.call()}),p)}})}),t.beforeParse.tap((c,p)=>{l=()=>{p.features[lt]=!0}}),{styles:(r=U.config)==null?void 0:r.styles}}},Dn=[Mn,j,U,Bn];function kt(t){var r;var e,n;if(t.type==="heading")t.children=t.children.filter(i=>i.type!=="paragraph");else if(t.type==="list_item")t.children=t.children.filter(i=>["paragraph","fence"].includes(i.type)?(t.content||(t.content=i.content,t.payload={...t.payload,...i.payload}),!1):!0),((e=t.payload)==null?void 0:e.index)!=null&&(t.content="".concat(t.payload.index,". ").concat(t.content));else if(t.type==="ordered_list"){let i=(r=(n=t.payload)==null?void 0:n.startIndex)!=null?r:1;t.children.forEach(s=>{s.type==="list_item"&&(s.payload={...s.payload,index:i},i+=1)})}t.children.length>0&&(t.children.forEach(i=>kt(i)),t.children.length===1&&!t.children[0].content&&(t.children=t.children[0].children))}function zt(t,e=0){t.depth=e,t.children.forEach(n=>{zt(n,e+1)})}class Un{constructor(e=Dn){this.assetsMap={},this.urlBuilder=new Kt,this.hooks=_n(this),this.plugins=e.map(i=>typeof i=="function"?i():i);const n={};for(const{name:i,transform:s}of this.plugins)n[i]=s(this.hooks);this.assetsMap=n;const r=new Lt("full",{html:!0,breaks:!0,maxNesting:1/0});r.renderer.rules.htmltag=Qt(r.renderer.rules.htmltag,(i,...s)=>{const o=i(...s);return this.hooks.htmltag.call({args:s,result:o}),o}),this.md=r,this.hooks.parser.call(r)}buildTree(e){const{md:n}=this,r={type:"root",depth:0,content:"",children:[],payload:{}},i=[r];let s=0;for(const o of e){const l={};o.lines&&(l.lines=o.lines);let c=i[i.length-1];if(o.type.endsWith("_open")){const p=o.type.slice(0,-5);if(p==="heading")for(s=o.hLevel;(c==null?void 0:c.depth)>=s;)i.pop(),c=i[i.length-1];else s=Math.max(s,(c==null?void 0:c.depth)||0)+1,p==="ordered_list"&&(l.startIndex=o.order);const h={type:p,depth:s,payload:l,content:"",children:[]};c.children.push(h),i.push(h)}else if(c){if(o.type==="".concat(c.type,"_close"))c.type==="heading"?s=c.depth:(i.pop(),s=0);else if(o.type==="inline"){const p=this.hooks.htmltag.tap(d=>{var m;const u=(m=d.result)==null?void 0:m.match(/^<!--([\s\S]*?)-->$/),y=u==null?void 0:u[1].trim().split(" ");(y==null?void 0:y[0])==="fold"&&(c.payload={...c.payload,fold:["all","recursively"].includes(y[1])?2:1},d.result="")}),h=n.renderer.render([o],n.options,{});p(),c.content="".concat(c.content||"").concat(h)}else if(o.type==="fence"){const p=n.renderer.render([o],n.options,{});c.children.push({type:o.type,depth:s+1,content:p,children:[],payload:l})}}else continue}return r}transform(e){var n;const r={content:e,features:{},contentLineOffset:0};this.hooks.beforeParse.call(this.md,r);const i=this.md.parse(r.content,{});this.hooks.afterParse.call(this.md,r);let s=this.buildTree(i);return kt(s),((n=s.children)==null?void 0:n.length)===1&&(s=s.children[0]),zt(s),{...r,root:s}}getAssets(e){const n=[],r=[];e!=null||(e=this.plugins.map(i=>i.name));for(const i of e.map(s=>this.assetsMap[s]))i&&(i.styles&&n.push(...i.styles),i.scripts&&r.push(...i.scripts));return{styles:n.map(i=>Tn(this.urlBuilder,i)),scripts:r.map(i=>W(this.urlBuilder,i))}}getUsedAssets(e){const n=this.plugins.map(r=>r.name).filter(r=>e[r]);return this.getAssets(n)}fillTemplate(e,n,r){var h;r={...r},(h=r.baseJs)!=null||(r.baseJs=En.map(d=>this.urlBuilder.getFullUrl(d)).map(d=>N(d)));const{scripts:i,styles:s}=n,o=[...s?Wt(s):[]],l={getMarkmap:()=>window.markmap,getOptions:r.getOptions,jsonOptions:r.jsonOptions,root:e},c=[...Vt([...r.baseJs,...i||[],{type:"iife",data:{fn:(d,m,u,y)=>{const x=d();window.mm=x.Markmap.create("svg#mindmap",(m||x.deriveOptions)(y),u)},getParams:({getMarkmap:d,getOptions:m,root:u,jsonOptions:y})=>[d,m,u,y]}}],l)];return zn.replace("<!--CSS-->",()=>o.join("")).replace("<!--JS-->",()=>c.join(""))}}export{Jn as F,Un as T};
