10 lines
25 KiB
JavaScript
10 lines
25 KiB
JavaScript
/**
|
|
* Minified by jsDelivr using Terser v5.39.0.
|
|
* Original file: /npm/markmap-view@0.18.12/dist/browser/index.js
|
|
*
|
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
*/
|
|
!function(t,e){"use strict";const n=Math.random().toString(36).slice(2,8);let r=0;function i(){}function a(t,e){const n=(t,r)=>e(t,(()=>{var e;return null==(e=t.children)?void 0:e.map((e=>n(e,t)))}),r);return n(t)}function s(){const t={};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t}
|
|
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
const o="http://www.w3.org/1999/xlink",l={show:o,actuate:o,href:o};function h(t,e,...n){return function(t,e){let n;if("string"==typeof t)n=1;else{if("function"!=typeof t)throw new Error("Invalid VNode type");n=2}return{vtype:n,type:t,props:e}}(t,e=Object.assign({},e,{children:1===n.length?n[0]:n}))}function c(t){return t.children}const d={isSvg:!1};function p(t,e){Array.isArray(e)||(e=[e]),(e=e.filter(Boolean)).length&&t.append(...e)}const u={className:"class",labelFor:"for"};function g(t,e,n,r){if(e=u[e]||e,!0===n)t.setAttribute(e,"");else if(!1===n)t.removeAttribute(e);else{const i=r?l[e]:void 0;void 0!==i?t.setAttributeNS(i,e,n):t.setAttribute(e,n)}}function m(t,e){return Array.isArray(t)?t.map((t=>m(t,e))).reduce(((t,e)=>t.concat(e)),[]):f(t,e)}function f(t,e=d){if(null==t||"boolean"==typeof t)return null;if(t instanceof Node)return t;if(2===(null==(n=t)?void 0:n.vtype)){const{type:n,props:r}=t;if(n===c){const t=document.createDocumentFragment();if(r.children){p(t,m(r.children,e))}return t}return f(n(r),e)}var n;if((t=>"string"==typeof t||"number"==typeof t)(t))return document.createTextNode(`${t}`);if((t=>1===(null==t?void 0:t.vtype))(t)){let n;const{type:r,props:i}=t;if(e.isSvg||"svg"!==r||(e=Object.assign({},e,{isSvg:!0})),n=e.isSvg?document.createElementNS("http://www.w3.org/2000/svg",r):document.createElement(r),function(t,e,n){for(const r in e)if("key"!==r&&"children"!==r&&"ref"!==r)if("dangerouslySetInnerHTML"===r)t.innerHTML=e[r].__html;else if("innerHTML"===r||"textContent"===r||"innerText"===r||"value"===r&&["textarea","select"].includes(t.tagName)){const n=e[r];null!=n&&(t[r]=n)}else r.startsWith("on")?t[r.toLowerCase()]=e[r]:g(t,r,e[r],n.isSvg)}(n,i,e),i.children){let t=e;e.isSvg&&"foreignObject"===r&&(t=Object.assign({},t,{isSvg:!1}));const a=m(i.children,t);null!=a&&p(n,a)}const{ref:a}=i;return"function"==typeof a&&a(n),n}throw new Error("mount: Invalid Vnode!")}function v(...t){return f(h(...t))}const y=function(t){const e={};return function(...n){const r=`${n[0]}`;let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}((t=>{document.head.append(v("link",{rel:"preload",as:"script",href:t}))})),x={},k={};async function w(t,e){var n;const r="script"===t.type&&(null==(n=t.data)?void 0:n.src)||"";if(t.loaded||(t.loaded=x[r]),!t.loaded){const n=s();if(t.loaded=n.promise,"script"===t.type&&(document.head.append(v("script",{...t.data,onLoad:()=>n.resolve(),onError:n.reject})),r?x[r]=t.loaded:n.resolve()),"iife"===t.type){const{fn:r,getParams:i}=t.data;r(...(null==i?void 0:i(e))||[]),n.resolve()}}await t.loaded}const b="undefined"!=typeof navigator&&navigator.userAgent.includes("Macintosh"),z=e.scaleOrdinal(e.schemeCategory10),S=(t=1,e=3,n=2)=>r=>t+e/n**r.state.depth,E={autoFit:!1,duration:500,embedGlobalCSS:!0,fitRatio:.95,maxInitialScale:2,scrollForPan:b,initialExpandLevel:-1,zoom:!0,pan:!0,toggleRecursively:!1,color:t=>{var e;return z(`${(null==(e=t.state)?void 0:e.path)||""}`)},lineWidth:S(),maxWidth:0,nodeMinHeight:16,paddingX:8,spacingHorizontal:80,spacingVertical:5};function C(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return(e>>>0).toString(36)}function X(t){if("string"==typeof t){const e=t;t=t=>t.matches(e)}const e=t;return function(){let t=Array.from(this.childNodes);return e&&(t=t.filter((t=>e(t)))),t}}function A(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function j(t,e){var n,r,i,a,s,o=new M(t),l=+t.value&&(o.value=t.value),h=[o];for(null==e&&(e=R);n=h.pop();)if(l&&(n.value=+n.data.value),(i=e(n.data))&&(s=i.length))for(n.children=new Array(s),a=s-1;a>=0;--a)h.push(r=n.children[a]=new M(i[a])),r.parent=n,r.depth=n.depth+1;return o.eachBefore($)}function R(t){return t.children}function O(t){t.data=t.data.data}function $(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=j.prototype={constructor:M,count:function(){return this.eachAfter(A)},each:function(t){var e,n,r,i,a=this,s=[a];do{for(e=s.reverse(),s=[];a=e.pop();)if(t(a),n=a.children)for(r=0,i=n.length;r<i;++r)s.push(n[r])}while(s.length);return this},eachAfter:function(t){for(var e,n,r,i=this,a=[i],s=[];i=a.pop();)if(s.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n]);for(;i=s.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(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}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(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},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return j(this).eachBefore(O)}};const T={version:"2.1.2"},{version:H}=T,B=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function _(t){const e=Object.assign({},B,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function r(t){const e=a(function(){const t=i(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),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 e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return N(this),D(this),this}}}(),t,(t=>t.children));return e.update(),e.data}function i(){const t=n("nodeSize"),e=n("spacing");return class n extends j.prototype.constructor{constructor(t){super(t)}copy(){const t=a(this.constructor,this,(t=>t.children));return t.each((t=>t.data=t.data.data)),t}get size(){return t(this)}spacing(t){return e(this,t)}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 t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}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(((t,e)=>n.maxExtents(t,e.extents)),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function a(t,e,n){const r=(e,i)=>{const a=new t(e);Object.assign(a,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const s=n(e)||[];return a.children=0===s.length?null:s.map((t=>r(t,a))),a.children&&Object.assign(a,a.children.reduce(((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length})),a)),a};return r(e,null)}return Object.assign(r,{nodeSize(t){return arguments.length?(e.nodeSize=t,r):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,r):e.spacing},children(t){return arguments.length?(e.children=t,r):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return a(i(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",a=t+" ",{x:s,y:o}=n,l=e(n),h=n.children||[],c=0===h.length?" ":`,${i}children: [${a}${h.map(r(a)).join(a)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${s}, y: ${o}${c}},`};return r("\n")(t)}}),r}_.version=H;const N=(t,e=0)=>(t.y=e,(t.children||[]).reduce(((e,n)=>{const[r,i]=e;N(n,t.y+t.ySize);const a=(0===r?n.lExt:n.rExt).bottom;0!==r&&W(t,r,i);return[r+1,Z(a,r,i)]}),[0,null]),L(t),G(t),t),D=(t,e,n)=>{void 0===e&&(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((e=>D(e,r,t.x))),t},L=t=>{(t.children||[]).reduce(((t,e)=>{const[n,r]=t,i=n+e.shift,a=r+i+e.change;return e.relX+=a,[i,a]}),[0,0])},W=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let a=r,s=r.relX,o=i,l=i.relX,h=!0;for(;a&&o;){a.bottom>n.lowY&&(n=n.next);const r=s+a.prelim-(l+o.prelim)+a.xSize/2+o.xSize/2+a.spacing(o);(r>0||r<0&&h)&&(l+=r,F(i,r),P(t,e,n.index,r)),h=!1;const c=a.bottom,d=o.bottom;c<=d&&(a=V(a),a&&(s+=a.relX)),c>=d&&(o=I(o),o&&(l+=o.relX))}!a&&o?K(t,e,o,l):a&&!o&&Y(t,e,a,s)},F=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},P=(t,e,n,r)=>{const i=t.children[e],a=e-n;if(a>1){const e=r/a;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},I=t=>t.hasChildren?t.firstChild:t.lThr,V=t=>t.hasChildren?t.lastChild:t.rThr,K=(t,e,n,r)=>{const i=t.firstChild,a=i.lExt,s=t.children[e];a.lThr=n;const o=r-n.relX-i.lExtRelX;a.relX+=o,a.prelim-=o,i.lExt=s.lExt,i.lExtRelX=s.lExtRelX},Y=(t,e,n,r)=>{const i=t.children[e],a=i.rExt,s=t.children[e-1];a.rThr=n;const o=r-n.relX-i.rExtRelX;a.relX+=o,a.prelim-=o,i.rExt=s.rExt,i.rExtRelX=s.rExtRelX},G=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})}},Z=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}},q=".markmap {\n --markmap-max-width: 9999px;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n --markmap-circle-open-bg: #fff;\n --markmap-text-color: #333;\n --markmap-highlight-node-bg: #ff02;\n\n font: var(--markmap-font);\n color: var(--markmap-text-color);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign p {\n margin: 0;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign svg {\n fill: currentColor;\n }\n\n .markmap-foreign > div {\n width: var(--markmap-max-width);\n text-align: left;\n }\n\n .markmap-foreign > div > div {\n display: inline-block;\n }\n\n .markmap-highlight rect {\n fill: var(--markmap-highlight-node-bg);\n }\n\n.markmap-dark .markmap {\n --markmap-code-bg: #1a1b26;\n --markmap-code-color: #ddd;\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n",J=q,Q="g.markmap-node",U=e.linkHorizontal();function tt(t,n){return t[e.minIndex(t,n)]}function et(t){t.stopPropagation()}const nt=new class{constructor(){this.listeners=[]}tap(t){return this.listeners.push(t),()=>this.revoke(t)}revoke(t){const e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}revokeAll(){this.listeners.splice(0)}call(...t){for(const e of this.listeners)e(...t)}};class rt{constructor(t,i){this.options={...E},this._disposeList=[],this.handleZoom=t=>{const{transform:e}=t;this.g.attr("transform",e)},this.handlePan=t=>{t.preventDefault();const n=e.zoomTransform(this.svg.node()),r=n.translate(-t.deltaX/n.k,-t.deltaY/n.k);this.svg.call(this.zoom.transform,r)},this.handleClick=(t,e)=>{let n=this.options.toggleRecursively;(b?t.metaKey:t.ctrlKey)&&(n=!n),this.toggleNode(e,n)},this.ensureView=this.ensureVisible,this.svg=t.datum?t:e.select(t),this.styleNode=this.svg.append("style"),this.zoom=e.zoom().filter((t=>this.options.scrollForPan&&"wheel"===t.type?t.ctrlKey&&!t.button:!(t.ctrlKey&&"wheel"!==t.type||t.button))).on("zoom",this.handleZoom),this.setOptions(i),this.state={id:this.options.id||this.svg.attr("id")||(r+=1,`mm-${n}-${r}`),rect:{x1:0,y1:0,x2:0,y2:0}},this.g=this.svg.append("g"),this.g.append("g").attr("class","markmap-highlight"),this._observer=new ResizeObserver(function(t,e){const n={timer:0};function r(){n.timer&&(window.clearTimeout(n.timer),n.timer=0)}function i(){r(),n.args&&(n.result=t(...n.args))}return function(...t){return r(),n.args=t,n.timer=window.setTimeout(i,e),n.result}}((()=>{this.renderData()}),100)),this._disposeList.push(nt.tap((()=>{this.setData()})),(()=>this._observer.disconnect()))}getStyleContent(){const{style:t}=this.options,{id:e}=this.state,n="function"==typeof t?t(e):"";return[this.options.embedGlobalCSS&&q,n].filter(Boolean).join("\n")}updateStyle(){this.svg.attr("class",function(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach((t=>{t&&n.indexOf(t)<0&&n.push(t)})),n.join(" ")}(this.svg.attr("class"),"markmap",this.state.id));const t=this.getStyleContent();this.styleNode.text(t)}async toggleNode(t,e=!1){var n,r;const i=(null==(n=t.payload)?void 0:n.fold)?0:1;e?a(t,((t,e)=>{t.payload={...t.payload,fold:i},e()})):t.payload={...t.payload,fold:(null==(r=t.payload)?void 0:r.fold)?0:1},await this.renderData(t)}_initializeData(t){let e=0;const{color:n,initialExpandLevel:r}=this.options;let i=0,s=0;return a(t,((t,a,o)=>{var l,h,c,d;s+=1,t.children=null==(l=t.children)?void 0:l.map((t=>({...t}))),e+=1,t.state={...t.state,depth:s,id:e,rect:{x:0,y:0,width:0,height:0},size:[0,0]},t.state.key=[null==(h=null==o?void 0:o.state)?void 0:h.id,t.state.id].filter(Boolean).join(".")+C(t.content),t.state.path=[null==(c=null==o?void 0:o.state)?void 0:c.path,t.state.id].filter(Boolean).join("."),n(t);const p=2===(null==(d=t.payload)?void 0:d.fold);p?i+=1:(i||r>=0&&t.state.depth>=r)&&(t.payload={...t.payload,fold:1}),a(),p&&(i-=1),s-=1})),t}_relayout(){if(!this.state.data)return;this.g.selectAll(X(Q)).selectAll(X("foreignObject")).each((function(t){var e;const n=null==(e=this.firstChild)?void 0:e.firstChild,r=[n.scrollWidth,n.scrollHeight];t.state.size=r}));const{lineWidth:t,paddingX:n,spacingHorizontal:r,spacingVertical:i}=this.options,a=_({}).children((t=>{var e;if(!(null==(e=t.payload)?void 0:e.fold))return t.children})).nodeSize((t=>{const[e,i]=t.data.state.size;return[i,e+(e?2*n:0)+r]})).spacing(((e,n)=>(e.parent===n.parent?i:2*i)+t(e.data))),s=a.hierarchy(this.state.data);a(s);const o=s.descendants();o.forEach((t=>{t.data.state.rect={x:t.y,y:t.x-t.xSize/2,width:t.ySize-r,height:t.xSize}})),this.state.rect={x1:e.min(o,(t=>t.data.state.rect.x))||0,y1:e.min(o,(t=>t.data.state.rect.y))||0,x2:e.max(o,(t=>t.data.state.rect.x+t.data.state.rect.width))||0,y2:e.max(o,(t=>t.data.state.rect.y+t.data.state.rect.height))||0}}setOptions(t){this.options={...this.options,...t},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)}async setData(t,e){e&&this.setOptions(e),t&&(this.state.data=this._initializeData(t)),this.state.data&&(this.updateStyle(),await this.renderData())}async setHighlight(t){this.state.highlight=t||void 0,await this.renderData()}_getHighlightRect(t){const n=this.svg.node(),r=4/e.zoomTransform(n).k,i={...t.state.rect};return i.x-=r,i.y-=r,i.width+=2*r,i.height+=2*r,i}async renderData(t){const{paddingX:e,autoFit:n,color:r,maxWidth:i,lineWidth:s}=this.options,o=this.state.data;if(!o)return;const l={},h={},c=[];a(o,((t,e,n)=>{var r;(null==(r=t.payload)?void 0:r.fold)||e(),l[t.state.id]=t,n&&(h[t.state.id]=n.state.id),c.push(t)}));const d={},p={},u=t=>{t&&!d[t.state.id]&&a(t,((e,n)=>{d[e.state.id]=t.state.id,n()}))},g=t=>p[d[t.state.id]]||o.state.rect,m=t=>(l[d[t.state.id]]||o).state.rect;p[o.state.id]=o.state.rect,t&&u(t);let{highlight:f}=this.state;f&&!l[f.state.id]&&(f=void 0);let v=this.g.selectAll(X("g.markmap-highlight")).selectAll(X("rect")).data(f?[this._getHighlightRect(f)]:[]).join("rect").attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height));const y=this.g.selectAll(X(Q)).each((t=>{p[t.state.id]=t.state.rect})).data(c,(t=>t.state.key)),x=y.enter().append("g").attr("data-depth",(t=>t.state.depth)).attr("data-path",(t=>t.state.path)).each((t=>{u(l[h[t.state.id]])})),k=y.exit().each((t=>{u(l[h[t.state.id]])})),w=y.merge(x).attr("class",(t=>{var e;return["markmap-node",(null==(e=t.payload)?void 0:e.fold)&&"markmap-fold"].filter(Boolean).join(" ")})),b=w.selectAll(X("line")).data((t=>[t]),(t=>t.state.key)),z=b.enter().append("line").attr("stroke",(t=>r(t))).attr("stroke-width",0),S=b.merge(z),E=w.selectAll(X("circle")).data((t=>{var e;return(null==(e=t.children)?void 0:e.length)?[t]:[]}),(t=>t.state.key)),C=E.enter().append("circle").attr("stroke-width",0).attr("r",0).on("click",((t,e)=>this.handleClick(t,e))).on("mousedown",et).merge(E).attr("stroke",(t=>r(t))).attr("fill",(t=>{var e;return(null==(e=t.payload)?void 0:e.fold)&&t.children?r(t):"var(--markmap-circle-open-bg)"})),A=this._observer,j=w.selectAll(X("foreignObject")).data((t=>[t]),(t=>t.state.key)),R=j.enter().append("foreignObject").attr("class","markmap-foreign").attr("x",e).attr("y",0).style("opacity",0).on("mousedown",et).on("dblclick",et);R.append("xhtml:div").append("xhtml:div").html((t=>t.content)).attr("xmlns","http://www.w3.org/1999/xhtml"),R.each((function(){var t;const e=null==(t=this.firstChild)?void 0:t.firstChild;A.observe(e)}));const O=k.selectAll(X("foreignObject"));O.each((function(){var t;const e=null==(t=this.firstChild)?void 0:t.firstChild;A.unobserve(e)}));const $=R.merge(j),M=c.flatMap((t=>{var e;return(null==(e=t.payload)?void 0:e.fold)?[]:t.children.map((e=>({source:t,target:e})))})),T=this.g.selectAll(X("path.markmap-link")).data(M,(t=>t.target.state.key)),H=T.exit(),B=T.enter().insert("path","g").attr("class","markmap-link").attr("data-depth",(t=>t.target.state.depth)).attr("data-path",(t=>t.target.state.path)).attr("d",(t=>{const e=g(t.target),n=[e.x+e.width,e.y+e.height];return U({source:n,target:n})})).attr("stroke-width",0).merge(T);this.svg.style("--markmap-max-width",i?`${i}px`:null),await new Promise(requestAnimationFrame),this._relayout(),v=v.data(f?[this._getHighlightRect(f)]:[]).join("rect"),this.transition(v).attr("x",(t=>t.x)).attr("y",(t=>t.y)).attr("width",(t=>t.width)).attr("height",(t=>t.height)),x.attr("transform",(t=>{const e=g(t);return`translate(${e.x+e.width-t.state.rect.width},${e.y+e.height-t.state.rect.height})`})),this.transition(k).attr("transform",(t=>{const e=m(t);return`translate(${e.x+e.width-t.state.rect.width},${e.y+e.height-t.state.rect.height})`})).remove(),this.transition(w).attr("transform",(t=>`translate(${t.state.rect.x},${t.state.rect.y})`));const _=k.selectAll(X("line"));this.transition(_).attr("x1",(t=>t.state.rect.width)).attr("stroke-width",0),z.attr("x1",(t=>t.state.rect.width)).attr("x2",(t=>t.state.rect.width)),S.attr("y1",(t=>t.state.rect.height+s(t)/2)).attr("y2",(t=>t.state.rect.height+s(t)/2)),this.transition(S).attr("x1",-1).attr("x2",(t=>t.state.rect.width+2)).attr("stroke",(t=>r(t))).attr("stroke-width",s);const N=k.selectAll(X("circle"));this.transition(N).attr("r",0).attr("stroke-width",0),C.attr("cx",(t=>t.state.rect.width)).attr("cy",(t=>t.state.rect.height+s(t)/2)),this.transition(C).attr("r",6).attr("stroke-width","1.5"),this.transition(O).style("opacity",0),$.attr("width",(t=>Math.max(0,t.state.rect.width-2*e))).attr("height",(t=>t.state.rect.height)),this.transition($).style("opacity",1),this.transition(H).attr("d",(t=>{const e=m(t.target),n=[e.x+e.width,e.y+e.height+s(t.target)/2];return U({source:n,target:n})})).attr("stroke-width",0).remove(),this.transition(B).attr("stroke",(t=>r(t.target))).attr("stroke-width",(t=>s(t.target))).attr("d",(t=>{const e=t.source,n=t.target,r=[e.state.rect.x+e.state.rect.width,e.state.rect.y+e.state.rect.height+s(e)/2],i=[n.state.rect.x,n.state.rect.y+n.state.rect.height+s(n)/2];return U({source:r,target:i})})),n&&this.fit()}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}async fit(t=this.options.maxInitialScale){const n=this.svg.node(),{width:r,height:a}=n.getBoundingClientRect(),{fitRatio:s}=this.options,{x1:o,y1:l,x2:h,y2:c}=this.state.rect,d=h-o,p=c-l,u=Math.min(r/d*s,a/p*s,t),g=e.zoomIdentity.translate((r-d*u)/2-o*u,(a-p*u)/2-l*u).scale(u);return this.transition(this.svg).call(this.zoom.transform,g).end().catch(i)}findElement(t){let e;return this.g.selectAll(X(Q)).each((function(n){n===t&&(e={data:n,g:this})})),e}async ensureVisible(t,n){var r;const a=null==(r=this.findElement(t))?void 0:r.data;if(!a)return;const s=this.svg.node(),o=s.getBoundingClientRect(),l=e.zoomTransform(s),[h,c]=[a.state.rect.x,a.state.rect.x+a.state.rect.width+2].map((t=>t*l.k+l.x)),[d,p]=[a.state.rect.y,a.state.rect.y+a.state.rect.height].map((t=>t*l.k+l.y)),u={left:0,right:0,top:0,bottom:0,...n},g=[u.left-h,o.width-u.right-c],m=[u.top-d,o.height-u.bottom-p],f=g[0]*g[1]>0?tt(g,Math.abs)/l.k:0,v=m[0]*m[1]>0?tt(m,Math.abs)/l.k:0;if(f||v){const t=l.translate(f,v);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(i)}}async centerNode(t,n){var r;const a=null==(r=this.findElement(t))?void 0:r.data;if(!a)return;const s=this.svg.node(),o=s.getBoundingClientRect(),l=e.zoomTransform(s),h=(a.state.rect.x+a.state.rect.width/2)*l.k+l.x,c=(a.state.rect.y+a.state.rect.height/2)*l.k+l.y,d={left:0,right:0,top:0,bottom:0,...n},p=(d.left+o.width-d.right)/2,u=(d.top+o.height-d.bottom)/2,g=(p-h)/l.k,m=(u-c)/l.k;if(g||m){const t=l.translate(g,m);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(i)}}async rescale(t){const n=this.svg.node(),{width:r,height:a}=n.getBoundingClientRect(),s=r/2,o=a/2,l=e.zoomTransform(n),h=l.translate((s-l.x)*(1-t)/l.k,(o-l.y)*(1-t)/l.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,h).end().catch(i)}destroy(){this.svg.on(".zoom",null),this.svg.html(null),this._disposeList.forEach((t=>{t()}))}static create(t,e,n=null){const r=new rt(t,e);return n&&r.setData(n).then((()=>{r.fit()})),r}}t.Markmap=rt,t.childSelector=X,t.defaultColorFn=z,t.defaultOptions=E,t.deriveOptions=function(t){const n={},r={...t},{color:i,colorFreezeLevel:a,lineWidth:s}=r;if(1===(null==i?void 0:i.length)){const t=i[0];n.color=()=>t}else if(null==i?void 0:i.length){const t=e.scaleOrdinal(i);n.color=e=>t(`${e.state.path}`)}if(a){const t=n.color||E.color;n.color=e=>(e={...e,state:{...e.state,path:e.state.path.split(".").slice(0,a).join(".")}},t(e))}if(s){const t=Array.isArray(s)?s:[s,0,1];n.lineWidth=S(...t)}return["duration","fitRatio","initialExpandLevel","maxInitialScale","maxWidth","nodeMinHeight","paddingX","spacingHorizontal","spacingVertical"].forEach((t=>{const e=r[t];"number"==typeof e&&(n[t]=e)})),["zoom","pan"].forEach((t=>{const e=r[t];null!=e&&(n[t]=!!e)})),n},t.globalCSS=J,t.isMacintosh=b,t.lineWidthFactory=S,t.loadCSS=async function(t){await Promise.all(t.map((t=>async function(t){const e="stylesheet"===t.type&&t.data.href||"";if(t.loaded||(t.loaded=k[e]),!t.loaded){const n=s();t.loaded=n.promise,e&&(k[e]=t.loaded),"style"===t.type?(document.head.append(v("style",{textContent:t.data})),n.resolve()):e&&(document.head.append(v("link",{rel:"stylesheet",...t.data})),fetch(e).then((t=>{if(t.ok)return t.text();throw t})).then((()=>n.resolve()),n.reject))}await t.loaded}(t))))},t.loadJS=async function(t,e){t.forEach((t=>{var e;"script"===t.type&&(null==(e=t.data)?void 0:e.src)&&y(t.data.src)})),e={getMarkmap:()=>window.markmap,...e};for(const n of t)await w(n,e)},t.refreshHook=nt,t.simpleHash=C,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}(this.markmap=this.markmap||{},d3);
|
|
//# sourceMappingURL=/sm/110abf9063f6ee4fb04c8b1324a7593e2b618205c89e4a3ba636f91260ce2b5d.map
|