kakidash 0.2.0 → 0.2.2

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.
package/dist/kakidash.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class k{root;theme="default";constructor(e){this.root=e}findNode(e){return this.findNodeRecursive(this.root,e)}findNodeRecursive(e,t){if(e.id===t)return e;for(const i of e.children){const o=this.findNodeRecursive(i,t);if(o)return o}return null}moveNode(e,t){const i=this.findNode(e),o=this.findNode(t);if(!i||!o||i.isRoot||i.parentId===t||this.isDescendant(i,t))return!1;if(i.parentId){const s=this.findNode(i.parentId);s&&s.removeChild(e)}return o.addChild(i),!0}addSibling(e,t,i){const o=this.findNode(e);if(!o||!o.parentId)return!1;const s=this.findNode(o.parentId);if(!s)return!1;const n=s.children.findIndex(a=>a.id===e);if(n===-1)return!1;const d=i==="before"?n:n+1;return s.insertChild(t,d),!0}insertParent(e,t){const i=this.findNode(e);if(!i||!i.parentId)return!1;const o=this.findNode(i.parentId);if(!o)return!1;const s=o.children.findIndex(n=>n.id===e);return s===-1?!1:(o.removeChild(e),o.insertChild(t,s),t.addChild(i),!0)}isDescendant(e,t){if(e.id===t)return!0;for(const i of e.children)if(this.isDescendant(i,t))return!0;return!1}}class S{id;topic;children;style;parentId;isRoot;image;imageSize;layoutSide;isFolded;icon;customWidth;constructor(e,t,i=null,o=!1,s,n,d=!1,a,r,h){this.id=e,this.topic=t,this.children=[],this.style={fontSize:o?"24px":"16px"},this.parentId=i,this.isRoot=o,this.image=s,this.imageSize=r,this.layoutSide=n,this.isFolded=d,this.icon=a,this.customWidth=h}addChild(e){e.parentId=this.id,this.children.push(e)}insertChild(e,t){e.parentId=this.id,t>=0&&t<=this.children.length?this.children.splice(t,0,e):this.children.push(e)}removeChild(e){this.children=this.children.filter(t=>t.id!==e)}updateTopic(e){this.topic=e}}class M{past=[];future=[];maxHistorySize;constructor(e=10){this.maxHistorySize=e}push(e){this.past.push(e),this.past.length>this.maxHistorySize&&this.past.shift(),this.future=[]}undo(e){if(this.past.length===0)return null;const t=this.past.pop();return t?(this.future.push(e),t):null}get canUndo(){return this.past.length>0}redo(e){if(this.future.length===0)return null;const t=this.future.pop();return t?(this.past.push(e),this.past.length>this.maxHistorySize&&this.past.shift(),t):null}get canRedo(){return this.future.length>0}clear(){this.past=[],this.future=[]}}class B{mindMap;historyManager;idGenerator;constructor(e,t){this.mindMap=e,this.historyManager=new M(10),this.idGenerator=t}saveState(){this.historyManager.push(this.exportData())}undo(){const e=this.historyManager.undo(this.exportData());return e?(this.importData(e),!0):!1}redo(){const e=this.historyManager.redo(this.exportData());return e?(this.importData(e),!0):!1}get canUndo(){return this.historyManager.canUndo}get canRedo(){return this.historyManager.canRedo}addNode(e,t="New topic",i){const o=this.mindMap.findNode(e);if(!o)return null;this.saveState();const s=this.idGenerator.generate(),n=new S(s,t,null,!1,void 0,i,!1);return o.addChild(n),n}addImageNode(e,t,i,o){const s=this.mindMap.findNode(e);if(!s)return null;this.saveState();const n=this.idGenerator.generate(),d=i&&o?{width:i,height:o}:void 0,a=new S(n,"",e,!1,t,void 0,!1,void 0,d);return s.addChild(a),a}removeNode(e,t=!0){const i=this.mindMap.findNode(e);if(!i||i.isRoot||!i.parentId)return!1;const o=this.mindMap.findNode(i.parentId);return o?(t&&this.saveState(),o.removeChild(e),!0):!1}updateNodeTopic(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.updateTopic(t),!0):!1}updateNodeStyle(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.style={...i.style,...t},!0):!1}toggleNodeFold(e){const t=this.mindMap.findNode(e);return t?t.children.length===0&&!t.isFolded?!1:(this.saveState(),t.isFolded=!t.isFolded,!0):!1}setTheme(e){this.mindMap.theme!==e&&(this.saveState(),this.mindMap.theme=e)}updateNodeCustomWidth(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),i.customWidth=t,!0):!1}moveNode(e,t,i){const o=this.mindMap.findNode(e);if(o&&o.parentId===t)return i&&o.layoutSide!==i?(this.saveState(),o.layoutSide=i,!0):!1;if(!o)return!1;if(this.saveState(),this.mindMap.moveNode(e,t)){if(i){const s=this.mindMap.findNode(e);s&&(s.layoutSide=i)}return!0}return!1}addSibling(e,t,i="New topic"){const o=this.mindMap.findNode(e);if(!o||!o.parentId)return null;this.saveState();const s=this.idGenerator.generate(),n=new S(s,i);return this.mindMap.addSibling(e,n,t)?n:null}reorderNode(e,t,i){const o=this.mindMap.findNode(e),s=this.mindMap.findNode(t);if(!o||!s||!s.parentId||o.id===s.id||o.isRoot)return!1;const n=this.mindMap.findNode(s.parentId);if(!n)return!1;if(this.saveState(),o.parentId!==n.id){let r=n;for(;r.parentId;){if(r.id===o.id)return!1;if(!r.parentId)break;const h=this.mindMap.findNode(r.parentId);if(!h)break;r=h}}if(o.parentId&&o.parentId!==n.id){const r=this.mindMap.findNode(o.parentId);r&&r.removeChild(o.id),o.parentId=n.id}else o.parentId===n.id&&n.removeChild(o.id);const d=n.children.findIndex(r=>r.id===t);if(d===-1)return n.addChild(o),!0;const a=i==="before"?d:d+1;return n.insertChild(o,a),n.isRoot&&s.layoutSide&&(o.layoutSide=s.layoutSide),!0}insertNodeAsParent(e,t){const i=this.mindMap.findNode(e),o=this.mindMap.findNode(t);if(!i||!o||!o.parentId||i.id===o.id)return!1;const s=this.mindMap.findNode(o.parentId);if(!s)return!1;let n=s;for(;n;){if(n.id===i.id)return!1;if(!n.parentId)break;n=this.mindMap.findNode(n.parentId)}if(this.saveState(),i.parentId){const a=this.mindMap.findNode(i.parentId);a&&a.removeChild(i.id)}const d=s.children.findIndex(a=>a.id===t);return d===-1?!1:(s.isRoot&&o.layoutSide&&(i.layoutSide=o.layoutSide),s.removeChild(t),s.insertChild(i,d),i.parentId=s.id,i.addChild(o),!0)}insertParent(e,t="New topic"){const i=this.mindMap.findNode(e);if(!i||!i.parentId)return null;this.saveState();const o=this.idGenerator.generate(),s=new S(o,t);return this.mindMap.insertParent(e,s)?s:null}clipboard=null;copyNode(e){const t=this.mindMap.findNode(e);t&&(this.clipboard=this.deepCloneNode(t),navigator.clipboard&&navigator.clipboard.writeText(t.topic).catch(i=>{console.error("Failed to write to clipboard",i)}))}cutNode(e){const t=this.mindMap.findNode(e);t&&!t.isRoot&&t.parentId&&(this.copyNode(e),this.removeNode(e))}pasteNode(e){if(!this.clipboard)return null;const t=this.mindMap.findNode(e);if(!t)return null;this.saveState();const i=this.deepCloneNode(this.clipboard);return this.regenerateIds(i),t.addChild(i),i}deepCloneNode(e){const t=new S(e.id,e.topic,null,!1,e.image,e.layoutSide,e.isFolded,e.icon,e.imageSize&&{...e.imageSize});return t.style={...e.style},t.children=e.children.map(i=>this.deepCloneNode(i)),t.children.forEach(i=>i.parentId=t.id),t}updateNodeIcon(e,t){const i=this.mindMap.findNode(e);return i?(this.saveState(),t==="delete"?i.icon=void 0:i.icon=t,!0):!1}regenerateIds(e){e.id=this.idGenerator.generate(),e.children.forEach(t=>{t.parentId=e.id,this.regenerateIds(t)})}exportData(){const e=t=>({id:t.id,topic:t.topic,root:t.isRoot||void 0,children:t.children.length>0?t.children.map(e):void 0,style:Object.keys(t.style).length>0?t.style:void 0,image:t.image,layoutSide:t.layoutSide,isFolded:t.isFolded,icon:t.icon,imageSize:t.imageSize,customWidth:t.customWidth});return{nodeData:e(this.mindMap.root),theme:this.mindMap.theme}}searchNodes(e){if(!e)return[];const t=[],i=e.toLowerCase(),o=s=>{s.topic.toLowerCase().includes(i)&&t.push(s),s.children.forEach(o)};return o(this.mindMap.root),t}importData(e){const t=(i,o=null)=>{const s=!!i.root,n=new S(i.id,i.topic,o,s,i.image,i.layoutSide,i.isFolded||!1,i.icon,i.imageSize,i.customWidth);return i.style&&(n.style={...i.style}),i.children&&i.children.length>0&&i.children.forEach(d=>{const a=t(d,n.id);n.addChild(a)}),n};this.mindMap.root=t(e.nodeData),e.theme&&(this.mindMap.theme=e.theme)}}const I={blue_circle:{path:'<circle cx="12" cy="12" r="10" fill="#3498DB" />',color:"#3498DB",viewBox:"0 0 24 24"},red_circle:{path:'<circle cx="12" cy="12" r="10" fill="#E74C3C" />',color:"#E74C3C",viewBox:"0 0 24 24"},question:{path:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z" fill="#95A5A6" />',color:"#95A5A6",viewBox:"0 0 24 24"},important:{path:'<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z" fill="#F1C40F" />',color:"#F1C40F",viewBox:"0 0 24 24"},check:{path:'<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" fill="#2ECC71" />',color:"#2ECC71",viewBox:"0 0 24 24"},cross:{path:'<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" fill="#E74C3C" />',color:"#E74C3C",viewBox:"0 0 24 24"},flag:{path:'<path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z" fill="#E67E22" />',color:"#E67E22",viewBox:"0 0 24 24"},idea:{path:'<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" fill="#F39C12" />',color:"#F39C12",viewBox:"0 0 24 24"},warning:{path:'<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" fill="#E67E22" />',color:"#E67E22",viewBox:"0 0 24 24"},schedule:{path:'<path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z" fill="#3498DB" />',color:"#3498DB",viewBox:"0 0 24 24"}};class E{container;svg;nodeContainer;options;maxWidth=-1;constructor(e,t={}){this.container=e,this.container.style.position="relative",this.container.style.width="100%",this.container.style.height="100%",this.container.style.overflow="hidden",this.container.style.backgroundColor="var(--vscode-editor-background, transparent)",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="absolute",this.svg.style.top="0",this.svg.style.left="0",this.svg.style.width="100%",this.svg.style.height="100%",this.svg.style.zIndex="0",this.svg.style.pointerEvents="none",this.svg.style.overflow="visible",this.svg.style.transformOrigin="0 0",this.container.appendChild(this.svg),this.nodeContainer=document.createElement("div"),this.nodeContainer.style.position="absolute",this.nodeContainer.style.top="0",this.nodeContainer.style.left="0",this.nodeContainer.style.width="100%",this.nodeContainer.style.height="100%",this.nodeContainer.style.zIndex="1",this.nodeContainer.style.transformOrigin="0 0",this.container.appendChild(this.nodeContainer),this.options=t}render(e,t=null,i="Right"){this.svg.innerHTML="",this.nodeContainer.innerHTML="",this.renderNode(e.root,0,this.container.clientHeight/2,t,i,!0,void 0,e)}updateTransform(e,t,i=1){const o=`translate(${e}px, ${t}px) scale(${i})`;this.svg.style.transform=o,this.nodeContainer.style.transform=o}static RAINBOW_PALETTE=["#E74C3C","#3498DB","#2ECC71","#F1C40F","#9B59B6","#E67E22","#1ABC9C"];getThemeColor(e,t){if(t.theme==="colorful"){if(e.isRoot)return"#333";let i=e;for(;i.parentId&&i.parentId!==t.root.id;){const n=t.findNode(i.parentId);if(!n)break;i=n}const s=t.root.children.findIndex(n=>n.id===i.id);if(s!==-1)return E.RAINBOW_PALETTE[s%E.RAINBOW_PALETTE.length]}return"#ccc"}renderNode(e,t,i,o,s,n,d="right",a){const r=document.createElement("div");if(r.dataset.id=e.id,r.style.position="absolute",r.style.left=`${t}px`,r.style.top=`${i}px`,e.image){const y=document.createElement("img");y.src=e.image,e.imageSize?e.imageSize.width>150?(y.style.width="150px",y.style.height="auto"):(y.style.width=`${e.imageSize.width}px`,y.style.height=`${e.imageSize.height}px`):(y.style.maxWidth="150px",y.style.maxHeight="150px"),y.style.display="block",r.appendChild(y);const u=document.createElement("div");u.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--vscode-icon-foreground, #333)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>',u.style.position="absolute",u.style.bottom="5px",u.style.right="5px",u.style.backgroundColor="var(--vscode-editor-background, rgba(255, 255, 255, 0.9))",u.style.borderRadius="50%",u.style.width="24px",u.style.height="24px",u.style.display="flex",u.style.justifyContent="center",u.style.alignItems="center",u.style.cursor="pointer",u.title="Zoom Image",u.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",r.appendChild(u),u.addEventListener("click",f=>{f.stopPropagation(),this.showImageModal(e.image)}),r.style.padding="5px"}else{if(r.style.display="flex",r.style.alignItems="center",r.style.justifyContent=e.isRoot?"center":"flex-start",e.icon){const x=I[e.icon];if(x){const g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("viewBox",x.viewBox),g.setAttribute("width","20"),g.setAttribute("height","20"),g.style.width="20px",g.style.height="20px",g.style.marginRight="8px",g.style.flexShrink="0",g.innerHTML=x.path,r.appendChild(g)}else{const g=document.createElement("span");g.textContent=e.icon,g.style.marginRight="6px",g.style.fontSize="1.2em",r.appendChild(g)}}const y=document.createElement("span"),u=/(https?:\/\/[^\s]+)/g;e.topic.split(u).forEach(x=>{if(x.match(u)){const g=document.createElement("a");g.href=x,g.target="_blank",g.rel="noopener noreferrer",g.textContent=x,g.style.color="#3498DB",g.style.textDecoration="underline",g.style.cursor="pointer",g.addEventListener("mousedown",b=>b.stopPropagation()),g.addEventListener("click",b=>b.stopPropagation()),y.appendChild(g)}else y.appendChild(document.createTextNode(x))}),r.appendChild(y);const N=e.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);N!==void 0?(y.style.whiteSpace="pre-wrap",y.style.wordWrap="break-word",y.style.overflowWrap="anywhere",y.style.minWidth="0",r.style.maxWidth=`${N}px`,r.style.width="max-content"):y.style.whiteSpace="pre"}r.className="mindmap-node",e.isRoot||(r.draggable=!0),r.style.position="absolute",r.style.padding="8px 12px",e.image&&(r.style.padding="5px"),a?.theme==="custom"?e.isRoot?r.style.color="var(--mindmap-root-color, var(--vscode-editor-foreground, black))":r.style.color="var(--mindmap-child-color, var(--vscode-editor-foreground, black))":r.style.color="var(--vscode-editor-foreground, black)";const h=a?.theme||"default",p=a?this.getThemeColor(e,a):"#ccc";if(h==="simple"&&!e.isRoot)r.style.border="none";else if(h==="custom")if(e.isRoot){const y="2px solid var(--vscode-editor-foreground, #333)";r.style.border=`var(--mindmap-root-border, ${y})`}else r.style.border="var(--mindmap-child-border, 1px solid #ccc)";else h==="colorful"?r.style.border=`2px solid ${p}`:r.style.border="1px solid var(--vscode-editorGroup-border, #ccc)";r.style.borderRadius="4px",e.isRoot&&(r.style.fontSize="1.2em",r.style.fontWeight="bold",h!=="custom"&&(r.style.border="2px solid var(--vscode-editor-foreground, #333)")),e.style.color&&(r.style.color=e.style.color),e.style.fontSize&&(r.style.fontSize=e.style.fontSize),e.style.fontWeight&&(r.style.fontWeight=e.style.fontWeight),e.style.fontStyle&&(r.style.fontStyle=e.style.fontStyle),e.style.background?r.style.backgroundColor=e.style.background:h==="custom"?e.isRoot?r.style.backgroundColor="var(--mindmap-root-background, var(--vscode-editor-background, white))":r.style.backgroundColor="var(--mindmap-child-background, var(--vscode-editor-background, white))":r.style.backgroundColor="var(--vscode-editorWidget-background, var(--vscode-editor-background, white))";const{width:l}=this.measureNode(e);let c=t;if(d==="left"&&!n?c=t-l:n&&(c=t-l/2),r.style.left=`${c}px`,r.style.top=`${i}px`,r.style.transform="translate(0, -50%)",r.style.zIndex="10",r.style.cursor="default",r.style.userSelect="none",e.id===o&&(r.style.outline="2px solid var(--vscode-focusBorder, #007bff)",r.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))"),this.nodeContainer.appendChild(r),e.children.length===0)return;if(this.options.onToggleFold){const y=[];if(n&&s==="Both")y.push(c+l),y.push(c);else{let u=d==="right";n&&(s==="Left"?u=!1:u=!0),y.push(u?c+l:c)}y.forEach(u=>{const f=document.createElement("div");f.className="mindmap-toggle-btn",f.innerHTML=e.isFolded?"+":"-",f.style.position="absolute",f.style.width="16px",f.style.height="16px",f.style.fontSize="12px",f.style.lineHeight="14px",f.style.textAlign="center",f.style.borderRadius="50%",f.style.border="1px solid var(--vscode-widget-border, #999)",f.style.backgroundColor="var(--vscode-editor-background, #fff)",f.style.color="var(--vscode-editor-foreground, #000)",f.style.cursor="pointer",f.style.zIndex="11",f.style.userSelect="none";const N=0;f.style.left=`${u+N}px`,f.style.top=`${i}px`,f.style.transform="translate(-50%, -50%)",f.addEventListener("click",x=>{x.stopPropagation(),this.options.onToggleFold?.(e.id)}),this.nodeContainer.appendChild(f)})}if(e.isFolded)return;let m=[],v=[];n&&s==="Both"?e.children.forEach((y,u)=>{(y.layoutSide||(u%2===0?"right":"left"))==="right"?m.push(y):v.push(y)}):s==="Left"?v=e.children:s==="Right"?m=e.children:d==="left"?v=e.children:m=e.children,m.length>0&&this.renderChildrenStack(e,m,t,i,o,s,"right",l,a),v.length>0&&this.renderChildrenStack(e,v,t,i,o,s,"left",l,a)}renderChildrenStack(e,t,i,o,s,n,d,a,r){const h=t.reduce((m,v)=>m+this.getNodeHeight(v,r),0);let p=o-h/2;const l=80;let c=0;e.isRoot?c=d==="right"?i+a/2:i-a/2:d==="right"?c=i+a:(c=i,c=i-a),t.forEach(m=>{const v=this.getNodeHeight(m,r),y=p+v/2,u=d==="right"?c+l:c-l;this.renderNode(m,u,y,s,n,!1,d,r);const f=r?this.getThemeColor(m,r):"#ccc";this.drawConnection(c,o,u,y,f,r?.theme),p+=v})}getChildrenHeight(e,t){return e.children.reduce((i,o)=>i+this.getNodeHeight(o,t),0)}getNodeHeight(e,t){const{height:i}=this.measureNode(e,t),o=20;if(e.children.length===0||e.isFolded)return i+o;const s=this.getChildrenHeight(e,t);return Math.max(i+o,s)}measureNode(e,t){if(e.image)return e.imageSize?e.imageSize.width>150?{width:160,height:150*(e.imageSize.height/e.imageSize.width)+10}:{width:e.imageSize.width+10,height:e.imageSize.height+10}:{width:160,height:160};const i=document.createElement("div");if(i.className="mindmap-node",i.style.visibility="hidden",i.style.position="absolute",i.style.display="flex",i.style.alignItems="center",e.icon)if(I[e.icon]){const p=document.createElement("div");p.style.width="20px",p.style.height="20px",p.style.marginRight="8px",p.style.flexShrink="0",i.appendChild(p)}else{const p=document.createElement("span");p.textContent=e.icon,p.style.marginRight="6px",p.style.fontSize="1.2em",i.appendChild(p)}const o=document.createElement("span");o.textContent=e.topic,i.appendChild(o);const s=e.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);s!==void 0?(o.style.whiteSpace="pre-wrap",o.style.wordWrap="break-word",o.style.overflowWrap="anywhere",o.style.minWidth="0",i.style.maxWidth=`${s}px`,i.style.width="max-content"):o.style.whiteSpace="pre",i.style.padding="8px 12px";const n=t?.theme||"default",d=t?this.getThemeColor(e,t):"#ccc";if(n==="simple"&&!e.isRoot)i.style.border="none";else if(n==="custom")if(e.isRoot){const h="2px solid var(--vscode-editor-foreground, #333)";i.style.border=`var(--mindmap-root-border, ${h})`}else i.style.border="var(--mindmap-child-border, 1px solid #ccc)";else n==="colorful"?i.style.border=`2px solid ${d}`:i.style.border="1px solid var(--vscode-editorGroup-border, #ccc)";e.isRoot&&(i.style.fontSize="1.2em",i.style.fontWeight="bold",n!=="custom"&&(i.style.border="2px solid var(--vscode-editor-foreground, #333)")),e.style.color&&(i.style.color=e.style.color),e.style.fontSize&&(i.style.fontSize=e.style.fontSize),e.style.fontWeight&&(i.style.fontWeight=e.style.fontWeight),e.style.fontStyle&&(i.style.fontStyle=e.style.fontStyle),e.style.background&&(i.style.backgroundColor=e.style.background),this.nodeContainer.appendChild(i);const a=i.offsetWidth,r=i.offsetHeight;return this.nodeContainer.removeChild(i),{width:a||100,height:r||40}}drawConnection(e,t,i,o,s="#ccc",n="default"){const d=document.createElementNS("http://www.w3.org/2000/svg","path"),a=e+(i-e)/2,r=e+(i-e)/2,h=`M ${e} ${t} C ${a} ${t}, ${r} ${o}, ${i} ${o}`;d.setAttribute("d",h),n==="custom"?d.style.stroke=`var(--mindmap-connection-color, ${s})`:d.style.stroke=s,d.setAttribute("fill","none"),d.setAttribute("stroke-width","2"),this.svg.appendChild(d)}showImageModal(e){this.options.onImageZoom&&this.options.onImageZoom(!0);const t=document.createElement("div");t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100vw",t.style.height="100vh",t.style.backgroundColor="rgba(0,0,0,0.8)",t.style.zIndex="1000",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.cursor="zoom-out";const i=document.createElement("img");i.src=e,i.style.maxWidth="90%",i.style.maxHeight="90%",i.style.boxShadow="0 0 20px rgba(0,0,0,0.5)",t.appendChild(i),document.body.appendChild(t);let o;const s=()=>{document.body.contains(t)&&document.body.removeChild(t),o&&document.removeEventListener("keydown",o,!0),this.options.onImageZoom&&this.options.onImageZoom(!1),this.container.focus()};o=n=>{n.stopPropagation(),n.preventDefault(),s()},document.addEventListener("keydown",o,!0),t.addEventListener("click",()=>{s()})}}class w{container;editorEl;currentNodeId=null;onUpdate;static FONT_SIZES=[{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"24px",value:"24px"},{label:"32px",value:"32px"},{label:"48px",value:"48px"}];static PALETTE=["#000000","#E74C3C","#E67E22","#F1C40F","#2ECC71","#3498DB","#9B59B6"];constructor(e){this.container=e,this.editorEl=this.createEditor(),this.container.appendChild(this.editorEl),this.editorEl.addEventListener("mousedown",t=>t.stopPropagation()),this.editorEl.addEventListener("click",t=>t.stopPropagation()),this.editorEl.addEventListener("dblclick",t=>t.stopPropagation())}createEditor(){const e=document.createElement("div");e.className="style-editor",e.style.position="absolute",e.style.top="20px",e.style.right="20px",e.style.display="none",e.style.backgroundColor="white",e.style.border="1px solid #eee",e.style.borderRadius="8px",e.style.padding="8px",e.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",e.style.zIndex="2000",e.style.pointerEvents="auto",e.style.fontFamily="Arial, sans-serif",e.style.display="flex",e.style.flexDirection="column",e.style.gap="8px",e.style.margin="0",e.style.boxSizing="border-box",e.style.minWidth="220px";const t=document.createElement("div");t.style.display="flex",t.style.gap="8px",t.style.alignItems="center";const i=document.createElement("select");i.style.padding="4px 8px",i.style.borderRadius="4px",i.style.border="1px solid #ccc",i.style.fontSize="14px",i.style.flex="1",w.FONT_SIZES.forEach(h=>{const p=document.createElement("option");p.value=h.value,p.textContent=h.label,i.appendChild(p)}),i.onchange=h=>{this.currentNodeId&&this.onUpdate&&this.onUpdate(this.currentNodeId,{fontSize:h.target.value})},t.appendChild(i);const s=(h,p,l)=>{const c=document.createElement("button");return c.textContent=h,c.style.width="32px",c.style.height="32px",c.style.padding="0",c.style.display="flex",c.style.justifyContent="center",c.style.alignItems="center",c.style.border="1px solid #ddd",c.style.backgroundColor="#f5f5f5",c.style.borderRadius="4px",c.style.cursor="pointer",c.style.fontSize="14px",p&&(c.style[p]=p==="fontWeight"?"bold":"italic"),c.onclick=l,c},n=s("B","fontWeight",()=>{if(this.currentNodeId&&this.onUpdate){const h=n.classList.contains("active"),p=h?"normal":"bold";this.onUpdate(this.currentNodeId,{fontWeight:p}),this.updateButtonState(n,!h)}}),d=s("I","fontStyle",()=>{if(this.currentNodeId&&this.onUpdate){const h=d.classList.contains("active"),p=h?"normal":"italic";this.onUpdate(this.currentNodeId,{fontStyle:p}),this.updateButtonState(d,!h)}});t.appendChild(n),t.appendChild(d),e.appendChild(t);const a=document.createElement("div");a.style.display="flex",a.style.gap="4px",a.style.alignItems="center",a.style.justifyContent="space-between";const r=document.createElement("input");return r.type="color",r.style.width="24px",r.style.height="24px",r.style.border="1px solid #ccc",r.style.padding="0",r.style.backgroundColor="transparent",r.style.cursor="pointer",r.style.appearance="none",r.onchange=h=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:h.target.value}),this.updateActivePaletteItem(h.target.value))},w.PALETTE.forEach((h,p)=>{const l=document.createElement("div");l.className="color-swatch",l.dataset.color=h,l.textContent=(p+1).toString(),l.style.width="24px",l.style.height="24px",l.style.backgroundColor=h,l.style.borderRadius="4px",l.style.cursor="pointer",l.style.border="1px solid transparent",l.style.color=h==="#F1C40F"?"black":"white",l.style.fontSize="12px",l.style.fontWeight="bold",l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.onclick=()=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:h}),r.value=h,this.updateActivePaletteItem(h))},a.appendChild(l)}),a.appendChild(r),e.appendChild(a),e}updateActivePaletteItem(e){this.editorEl.querySelectorAll(".color-swatch").forEach(i=>{const o=i;o.dataset.color?.toLowerCase()===e.toLowerCase()?(o.style.border="2px solid #ccc",o.style.transform="scale(1.1)"):(o.style.border="1px solid transparent",o.style.transform="scale(1)")})}updateButtonState(e,t){t?(e.classList.add("active"),e.style.backgroundColor="#e0e0e0",e.style.borderColor="#999"):(e.classList.remove("active"),e.style.backgroundColor="#f5f5f5",e.style.borderColor="#ddd")}show(e,t){this.currentNodeId=e,this.editorEl.style.display="flex";const i=this.editorEl.querySelector("select");i.value=t.fontSize||"";const o=this.editorEl.querySelector('input[type="color"]'),s=t.color||"#000000";o.value=s,this.updateActivePaletteItem(s);const n=this.editorEl.querySelectorAll("button")[0];this.updateButtonState(n,t.fontWeight==="bold");const d=this.editorEl.querySelectorAll("button")[1];this.updateButtonState(d,t.fontStyle==="italic")}hide(){this.editorEl.style.display="none",this.currentNodeId=null}}class L{container;element;options;currentMode="Right";currentTheme="default";layoutButtons=new Map;themeButtons=new Map;constructor(e,t){this.container=e,this.options=t,this.element=document.createElement("div"),this.render()}render(){this.element.style.position="absolute",this.element.style.top="20px",this.element.style.left="20px",this.element.style.display="flex",this.element.style.flexDirection="column",this.element.style.backgroundColor="white",this.element.style.borderRadius="8px",this.element.style.boxShadow="0 2px 10px rgba(0,0,0,0.1)",this.element.style.padding="5px",this.element.style.zIndex="2000",this.element.style.gap="5px",this.element.style.pointerEvents="auto",this.element.addEventListener("click",e=>e.stopPropagation()),this.element.addEventListener("mousedown",e=>e.stopPropagation()),this.createLayoutButton("Right",this.getRightIcon()),this.createLayoutButton("Left",this.getLeftIcon()),this.createLayoutButton("Both",this.getBothIcon()),this.addSeparator(),this.createThemeButton("default",this.getThemeDefaultIcon()),this.createThemeButton("simple",this.getThemeSimpleIcon()),this.createThemeButton("colorful",this.getThemeColorfulIcon()),this.createThemeButton("custom",this.getThemeCustomIcon()),this.addSeparator(),this.createIconActionButton("Reset Zoom",this.getZoomResetIcon(),()=>{this.options.onZoomReset&&this.options.onZoomReset()}),this.addSeparator(),this.createIconActionButton("Shortcuts Help",this.getHelpIcon(),()=>{this.options.onShowShortcuts&&this.options.onShowShortcuts()}),this.container.appendChild(this.element),this.updateActiveButtons()}addSeparator(){const e=document.createElement("div");e.style.height="1px",e.style.backgroundColor="#ccc",e.style.margin="5px 2px",this.element.appendChild(e)}createLayoutButton(e,t){const i=document.createElement("button");i.innerHTML=t,this.styleButton(i),i.title=`Layout: ${e}`,i.addEventListener("click",()=>{this.setMode(e)}),this.element.appendChild(i),this.layoutButtons.set(e,i)}createThemeButton(e,t){const i=document.createElement("button");i.innerHTML=t,this.styleButton(i),i.title=`Theme: ${e}`,i.addEventListener("click",()=>{this.setTheme(e)}),this.element.appendChild(i),this.themeButtons.set(e,i)}createIconActionButton(e,t,i){const o=document.createElement("button");o.innerHTML=t,this.styleButton(o),o.title=e,o.addEventListener("click",i),this.element.appendChild(o)}styleButton(e){e.style.width="32px",e.style.height="32px",e.style.border="none",e.style.background="transparent",e.style.cursor="pointer",e.style.borderRadius="4px",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.color="#555"}updateActiveButtons(){this.layoutButtons.forEach((e,t)=>{t===this.currentMode?(e.style.backgroundColor="#e6f7ff",e.style.color="#007bff"):(e.style.backgroundColor="transparent",e.style.color="#555")}),this.themeButtons.forEach((e,t)=>{t===this.currentTheme?(e.style.backgroundColor="#e6f7ff",e.style.color="#007bff"):(e.style.backgroundColor="transparent",e.style.color="#555")})}setMode(e){this.currentMode!==e&&(this.currentMode=e,this.updateActiveButtons(),this.options.onLayoutChange(e))}setTheme(e){this.currentTheme!==e&&(this.currentTheme=e,this.updateActiveButtons(),this.options.onThemeChange(e))}getRightIcon(){return`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Wt{root;theme="default";constructor(t){this.root=t}findNode(t){return this.findNodeRecursive(this.root,t)}findNodeRecursive(t,e){if(t.id===e)return t;for(const i of t.children){const r=this.findNodeRecursive(i,e);if(r)return r}return null}moveNode(t,e){const i=this.findNode(t),r=this.findNode(e);if(!i||!r||i.isRoot||i.parentId===e||this.isDescendant(i,e))return!1;if(i.parentId){const n=this.findNode(i.parentId);n&&n.removeChild(t)}return r.addChild(i),!0}addSibling(t,e,i){const r=this.findNode(t);if(!r||!r.parentId)return!1;const n=this.findNode(r.parentId);if(!n)return!1;const o=n.children.findIndex(c=>c.id===t);if(o===-1)return!1;const s=i==="before"?o:o+1;return n.insertChild(e,s),!0}insertParent(t,e){const i=this.findNode(t);if(!i||!i.parentId)return!1;const r=this.findNode(i.parentId);if(!r)return!1;const n=r.children.findIndex(o=>o.id===t);return n===-1?!1:(r.removeChild(t),r.insertChild(e,n),e.addChild(i),!0)}isDescendant(t,e){if(t.id===e)return!0;for(const i of t.children)if(this.isDescendant(i,e))return!0;return!1}}class gt{id;topic;children;style;parentId;isRoot;image;imageSize;layoutSide;isFolded;icon;customWidth;constructor(t,e,i=null,r=!1,n,o,s=!1,c,g,f){this.id=t,this.topic=e,this.children=[],this.style={fontSize:r?"24px":"16px"},this.parentId=i,this.isRoot=r,this.image=n,this.imageSize=g,this.layoutSide=o,this.isFolded=s,this.icon=c,this.customWidth=f}addChild(t){t.parentId=this.id,this.children.push(t)}insertChild(t,e){t.parentId=this.id,e>=0&&e<=this.children.length?this.children.splice(e,0,t):this.children.push(t)}removeChild(t){this.children=this.children.filter(e=>e.id!==t)}updateTopic(t){this.topic=t}}class Ut{past=[];future=[];maxHistorySize;constructor(t=10){this.maxHistorySize=t}push(t){this.past.push(t),this.past.length>this.maxHistorySize&&this.past.shift(),this.future=[]}undo(t){if(this.past.length===0)return null;const e=this.past.pop();return e?(this.future.push(t),e):null}get canUndo(){return this.past.length>0}redo(t){if(this.future.length===0)return null;const e=this.future.pop();return e?(this.past.push(t),this.past.length>this.maxHistorySize&&this.past.shift(),e):null}get canRedo(){return this.future.length>0}clear(){this.past=[],this.future=[]}}class jt{mindMap;historyManager;idGenerator;constructor(t,e){this.mindMap=t,this.historyManager=new Ut(10),this.idGenerator=e}saveState(){this.historyManager.push(this.exportData())}undo(){const t=this.historyManager.undo(this.exportData());return t?(this.importData(t),!0):!1}redo(){const t=this.historyManager.redo(this.exportData());return t?(this.importData(t),!0):!1}get canUndo(){return this.historyManager.canUndo}get canRedo(){return this.historyManager.canRedo}addNode(t,e="New topic",i){const r=this.mindMap.findNode(t);if(!r)return null;this.saveState();const n=this.idGenerator.generate(),o=new gt(n,e,null,!1,void 0,i,!1);return r.addChild(o),o}addImageNode(t,e,i,r){const n=this.mindMap.findNode(t);if(!n)return null;this.saveState();const o=this.idGenerator.generate(),s=i&&r?{width:i,height:r}:void 0,c=new gt(o,"",t,!1,e,void 0,!1,void 0,s);return n.addChild(c),c}removeNode(t,e=!0){const i=this.mindMap.findNode(t);if(!i||i.isRoot||!i.parentId)return!1;const r=this.mindMap.findNode(i.parentId);return r?(e&&this.saveState(),r.removeChild(t),!0):!1}updateNodeTopic(t,e){const i=this.mindMap.findNode(t);return i?(this.saveState(),i.updateTopic(e),!0):!1}updateNodeStyle(t,e){const i=this.mindMap.findNode(t);return i?(this.saveState(),i.style={...i.style,...e},!0):!1}toggleNodeFold(t){const e=this.mindMap.findNode(t);return e?e.children.length===0&&!e.isFolded?!1:(this.saveState(),e.isFolded=!e.isFolded,!0):!1}setTheme(t){this.mindMap.theme!==t&&(this.saveState(),this.mindMap.theme=t)}updateNodeCustomWidth(t,e){const i=this.mindMap.findNode(t);return i?(this.saveState(),i.customWidth=e,!0):!1}moveNode(t,e,i){const r=this.mindMap.findNode(t);if(r&&r.parentId===e)return i&&r.layoutSide!==i?(this.saveState(),r.layoutSide=i,!0):!1;if(!r)return!1;if(this.saveState(),this.mindMap.moveNode(t,e)){if(i){const n=this.mindMap.findNode(t);n&&(n.layoutSide=i)}return!0}return!1}addSibling(t,e,i="New topic"){const r=this.mindMap.findNode(t);if(!r||!r.parentId)return null;this.saveState();const n=this.idGenerator.generate(),o=new gt(n,i);return this.mindMap.addSibling(t,o,e)?o:null}reorderNode(t,e,i){const r=this.mindMap.findNode(t),n=this.mindMap.findNode(e);if(!r||!n||!n.parentId||r.id===n.id||r.isRoot)return!1;const o=this.mindMap.findNode(n.parentId);if(!o)return!1;if(this.saveState(),r.parentId!==o.id){let g=o;for(;g.parentId;){if(g.id===r.id)return!1;if(!g.parentId)break;const f=this.mindMap.findNode(g.parentId);if(!f)break;g=f}}if(r.parentId&&r.parentId!==o.id){const g=this.mindMap.findNode(r.parentId);g&&g.removeChild(r.id),r.parentId=o.id}else r.parentId===o.id&&o.removeChild(r.id);const s=o.children.findIndex(g=>g.id===e);if(s===-1)return o.addChild(r),!0;const c=i==="before"?s:s+1;return o.insertChild(r,c),o.isRoot&&n.layoutSide&&(r.layoutSide=n.layoutSide),!0}insertNodeAsParent(t,e){const i=this.mindMap.findNode(t),r=this.mindMap.findNode(e);if(!i||!r||!r.parentId||i.id===r.id)return!1;const n=this.mindMap.findNode(r.parentId);if(!n)return!1;let o=n;for(;o;){if(o.id===i.id)return!1;if(!o.parentId)break;o=this.mindMap.findNode(o.parentId)}if(this.saveState(),i.parentId){const c=this.mindMap.findNode(i.parentId);c&&c.removeChild(i.id)}const s=n.children.findIndex(c=>c.id===e);return s===-1?!1:(n.isRoot&&r.layoutSide&&(i.layoutSide=r.layoutSide),n.removeChild(e),n.insertChild(i,s),i.parentId=n.id,i.addChild(r),!0)}insertParent(t,e="New topic"){const i=this.mindMap.findNode(t);if(!i||!i.parentId)return null;this.saveState();const r=this.idGenerator.generate(),n=new gt(r,e);return this.mindMap.insertParent(t,n)?n:null}clipboard=null;copyNode(t){const e=this.mindMap.findNode(t);e&&(this.clipboard=this.deepCloneNode(e),navigator.clipboard&&navigator.clipboard.writeText(e.topic).catch(i=>{console.error("Failed to write to clipboard",i)}))}cutNode(t){const e=this.mindMap.findNode(t);e&&!e.isRoot&&e.parentId&&(this.copyNode(t),this.removeNode(t))}pasteNode(t){if(!this.clipboard)return null;const e=this.mindMap.findNode(t);if(!e)return null;this.saveState();const i=this.deepCloneNode(this.clipboard);return this.regenerateIds(i),e.addChild(i),i}deepCloneNode(t){const e=new gt(t.id,t.topic,null,!1,t.image,t.layoutSide,t.isFolded,t.icon,t.imageSize&&{...t.imageSize});return e.style={...t.style},e.children=t.children.map(i=>this.deepCloneNode(i)),e.children.forEach(i=>i.parentId=e.id),e}updateNodeIcon(t,e){const i=this.mindMap.findNode(t);return i?(this.saveState(),e==="delete"?i.icon=void 0:i.icon=e,!0):!1}regenerateIds(t){t.id=this.idGenerator.generate(),t.children.forEach(e=>{e.parentId=t.id,this.regenerateIds(e)})}exportData(){const t=e=>({id:e.id,topic:e.topic,root:e.isRoot||void 0,children:e.children.length>0?e.children.map(t):void 0,style:Object.keys(e.style).length>0?e.style:void 0,image:e.image,layoutSide:e.layoutSide,isFolded:e.isFolded,icon:e.icon,imageSize:e.imageSize,customWidth:e.customWidth});return{nodeData:t(this.mindMap.root),theme:this.mindMap.theme}}searchNodes(t){if(!t)return[];const e=[],i=t.toLowerCase(),r=n=>{n.topic.toLowerCase().includes(i)&&e.push(n),n.children.forEach(r)};return r(this.mindMap.root),e}importData(t){const e=(i,r=null)=>{const n=!!i.root,o=new gt(i.id,i.topic,r,n,i.image,i.layoutSide,i.isFolded||!1,i.icon,i.imageSize,i.customWidth);return i.style&&(o.style={...i.style}),i.children&&i.children.length>0&&i.children.forEach(s=>{const c=e(s,o.id);o.addChild(c)}),o};this.mindMap.root=e(t.nodeData),t.theme&&(this.mindMap.theme=t.theme)}}const Nt={name:"default",isDark:!1,styles:{rootNode:{color:"var(--vscode-editor-foreground, black)",background:"var(--vscode-editorWidget-background, var(--vscode-editor-background, white))",border:"2px solid var(--vscode-editor-foreground, #333)",fontWeight:"bold",fontSize:"1.2em"},childNode:{color:"var(--vscode-editor-foreground, black)",background:"var(--vscode-editorWidget-background, var(--vscode-editor-background, white))",border:"1px solid var(--vscode-editorGroup-border, #ccc)"},connection:{color:"#ccc"},canvas:{background:"var(--vscode-editor-background, transparent)"}}},Ht={name:"simple",isDark:!1,styles:{rootNode:{color:"var(--vscode-editor-foreground, black)",background:"var(--vscode-editorWidget-background, var(--vscode-editor-background, white))",border:"2px solid var(--vscode-editor-foreground, #333)",fontWeight:"bold",fontSize:"1.2em"},childNode:{color:"var(--vscode-editor-foreground, black)",background:"var(--vscode-editorWidget-background, var(--vscode-editor-background, white))",border:"none"},connection:{color:"#ccc"},canvas:{background:"var(--vscode-editor-background, transparent)"}}},Dt=["#E74C3C","#3498DB","#2ECC71","#F1C40F","#9B59B6","#E67E22","#1ABC9C"],Zt={name:"colorful",isDark:!1,styles:{rootNode:{color:"var(--vscode-editor-foreground, black)",background:"var(--vscode-editorWidget-background, var(--vscode-editor-background, white))",border:"2px solid var(--vscode-editor-foreground, #333)",fontWeight:"bold",fontSize:"1.2em"},childNode:{color:"var(--vscode-editor-foreground, black)",background:"var(--vscode-editorWidget-background, var(--vscode-editor-background, white))",border:"2px solid var(--node-color)"},connection:{color:"var(--node-color)"},canvas:{background:"var(--vscode-editor-background, transparent)"}},getColor:it=>Dt[it%Dt.length]},Xt={name:"dark",isDark:!0,styles:{rootNode:{color:"#eee",background:"#333",border:"2px solid #555",fontWeight:"bold",fontSize:"1.2em"},childNode:{color:"#ddd",background:"#222",border:"1px solid #444"},connection:{color:"#555"},canvas:{background:"#1e1e1e"}}};class ct{static instance;themes=new Map;currentTheme=Nt;constructor(){this.registerTheme(Nt),this.registerTheme(Ht),this.registerTheme(Zt),this.registerTheme(Xt)}static getInstance(){return ct.instance||(ct.instance=new ct),ct.instance}registerTheme(t){this.themes.set(t.name,t)}getTheme(t){return this.themes.get(t)}getAvailableThemes(){return Array.from(this.themes.keys())}applyTheme(t,e){const i=this.getTheme(e);return i?(this.currentTheme=i,this.applyStyles(t,i),i):(console.warn(`Theme '${e}' not found. Falling back to default.`),this.currentTheme)}getCurrentTheme(){return this.currentTheme}setCustomTheme(t){const e=Nt.styles,i={name:"custom",isDark:!1,styles:{rootNode:{color:t.rootNode?.color||e.rootNode.color,background:t.rootNode?.background||e.rootNode.background,border:t.rootNode?.border||e.rootNode.border,fontSize:e.rootNode.fontSize,fontWeight:e.rootNode.fontWeight},childNode:{color:t.childNode?.color||e.childNode.color,background:t.childNode?.background||e.childNode.background,border:t.childNode?.border||e.childNode.border,fontSize:e.childNode.fontSize},connection:{color:t.connection?.color||e.connection.color},canvas:{background:t.canvas?.background||e.canvas.background}}};this.registerTheme(i)}applyStyles(t,e){const i=e.styles;t.style.setProperty("--mindmap-root-color",i.rootNode.color),t.style.setProperty("--mindmap-root-background",i.rootNode.background),t.style.setProperty("--mindmap-root-border",i.rootNode.border),i.rootNode.fontSize&&t.style.setProperty("--mindmap-root-font-size",i.rootNode.fontSize),i.rootNode.fontWeight&&t.style.setProperty("--mindmap-root-font-weight",i.rootNode.fontWeight),t.style.setProperty("--mindmap-child-color",i.childNode.color),t.style.setProperty("--mindmap-child-background",i.childNode.background),t.style.setProperty("--mindmap-child-border",i.childNode.border),i.childNode.fontSize&&t.style.setProperty("--mindmap-child-font-size",i.childNode.fontSize),t.style.setProperty("--mindmap-connection-color",i.connection.color),t.style.setProperty("--mindmap-canvas-background",i.canvas.background)}}const It={blue_circle:{path:'<circle cx="12" cy="12" r="10" fill="#3498DB" />',color:"#3498DB",viewBox:"0 0 24 24"},red_circle:{path:'<circle cx="12" cy="12" r="10" fill="#E74C3C" />',color:"#E74C3C",viewBox:"0 0 24 24"},question:{path:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z" fill="#95A5A6" />',color:"#95A5A6",viewBox:"0 0 24 24"},important:{path:'<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z" fill="#F1C40F" />',color:"#F1C40F",viewBox:"0 0 24 24"},check:{path:'<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" fill="#2ECC71" />',color:"#2ECC71",viewBox:"0 0 24 24"},cross:{path:'<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" fill="#E74C3C" />',color:"#E74C3C",viewBox:"0 0 24 24"},flag:{path:'<path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z" fill="#E67E22" />',color:"#E67E22",viewBox:"0 0 24 24"},idea:{path:'<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" fill="#F39C12" />',color:"#F39C12",viewBox:"0 0 24 24"},warning:{path:'<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" fill="#E67E22" />',color:"#E67E22",viewBox:"0 0 24 24"},schedule:{path:'<path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z" fill="#3498DB" />',color:"#3498DB",viewBox:"0 0 24 24"}};class Kt{container;svg;nodeContainer;options;maxWidth=-1;constructor(t,e={}){this.container=t,this.container.style.position="relative",this.container.style.width="100%",this.container.style.height="100%",this.container.style.overflow="hidden",this.container.style.backgroundColor="var(--vscode-editor-background, transparent)",this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.style.position="absolute",this.svg.style.top="0",this.svg.style.left="0",this.svg.style.width="100%",this.svg.style.height="100%",this.svg.style.zIndex="0",this.svg.style.pointerEvents="none",this.svg.style.overflow="visible",this.svg.style.transformOrigin="0 0",this.container.appendChild(this.svg),this.nodeContainer=document.createElement("div"),this.nodeContainer.style.position="absolute",this.nodeContainer.style.top="0",this.nodeContainer.style.left="0",this.nodeContainer.style.width="100%",this.nodeContainer.style.height="100%",this.nodeContainer.style.zIndex="1",this.nodeContainer.style.transformOrigin="0 0",this.container.appendChild(this.nodeContainer),this.options=e}render(t,e=null,i="Right"){this.svg.innerHTML="",this.nodeContainer.innerHTML="",this.renderNode(t.root,0,this.container.clientHeight/2,e,i,!0,void 0,t)}updateTransform(t,e,i=1){const r=`translate(${t}px, ${e}px) scale(${i})`;this.svg.style.transform=r,this.nodeContainer.style.transform=r}getThemeColor(t,e){const i=ct.getInstance().getCurrentTheme();if(i.getColor){if(t.isRoot)return"#333";let r=t;for(;r.parentId&&r.parentId!==e.root.id;){const s=e.findNode(r.parentId);if(!s)break;r=s}const o=e.root.children.findIndex(s=>s.id===r.id);if(o!==-1)return i.getColor(o,0)}return i.styles.connection.color}renderNode(t,e,i,r,n,o,s="right",c){const g=ct.getInstance().getCurrentTheme(),f=document.createElement("div");if(f.dataset.id=t.id,f.style.position="absolute",f.style.left=`${e}px`,f.style.top=`${i}px`,t.image){const m=document.createElement("img");m.src=t.image,t.imageSize?t.imageSize.width>150?(m.style.width="150px",m.style.height="auto"):(m.style.width=`${t.imageSize.width}px`,m.style.height=`${t.imageSize.height}px`):(m.style.maxWidth="150px",m.style.maxHeight="150px"),m.style.display="block",f.appendChild(m);const u=document.createElement("div");u.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--vscode-icon-foreground, #333)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line><line x1="11" y1="8" x2="11" y2="14"></line><line x1="8" y1="11" x2="14" y2="11"></line></svg>',u.style.position="absolute",u.style.bottom="5px",u.style.right="5px",u.style.backgroundColor="var(--vscode-editor-background, rgba(255, 255, 255, 0.9))",u.style.borderRadius="50%",u.style.width="24px",u.style.height="24px",u.style.display="flex",u.style.justifyContent="center",u.style.alignItems="center",u.style.cursor="pointer",u.title="Zoom Image",u.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",f.appendChild(u),u.addEventListener("click",v=>{v.stopPropagation(),this.showImageModal(t.image)}),f.style.padding="5px"}else{if(f.style.display="flex",f.style.alignItems="center",f.style.justifyContent=t.isRoot?"center":"flex-start",t.icon){const C=It[t.icon];if(C){const S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("viewBox",C.viewBox),S.setAttribute("width","20"),S.setAttribute("height","20"),S.style.width="20px",S.style.height="20px",S.style.marginRight="8px",S.style.flexShrink="0",S.innerHTML=C.path,f.appendChild(S)}else{const S=document.createElement("span");S.textContent=t.icon,S.style.marginRight="6px",S.style.fontSize="1.2em",f.appendChild(S)}}const m=document.createElement("span"),u=/(https?:\/\/[^\s]+)/g;t.topic.split(u).forEach(C=>{if(C.match(u)){const S=document.createElement("a");S.href=C,S.target="_blank",S.rel="noopener noreferrer",S.textContent=C,S.style.color="#3498DB",S.style.textDecoration="underline",S.style.cursor="pointer",S.addEventListener("mousedown",M=>M.stopPropagation()),S.addEventListener("click",M=>M.stopPropagation()),m.appendChild(S)}else m.appendChild(document.createTextNode(C))}),f.appendChild(m);const k=t.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);k!==void 0?(m.style.whiteSpace="pre-wrap",m.style.wordWrap="break-word",m.style.overflowWrap="anywhere",m.style.minWidth="0",f.style.maxWidth=`${k}px`,f.style.width="max-content"):m.style.whiteSpace="pre"}f.className="mindmap-node",t.isRoot||(f.draggable=!0),f.style.position="absolute",f.style.padding="8px 12px",t.image&&(f.style.padding="5px"),g.name==="custom"?t.isRoot?f.style.color="var(--mindmap-root-color, var(--vscode-editor-foreground, black))":f.style.color="var(--mindmap-child-color, var(--vscode-editor-foreground, black))":t.isRoot?f.style.color="var(--mindmap-root-color)":f.style.color="var(--mindmap-child-color)";const y=this.getThemeColor(t,c);if(g.name==="colorful")f.style.border=`2px solid ${y}`;else if(g.name==="custom")if(t.isRoot){const m="2px solid var(--vscode-editor-foreground, #333)";f.style.border=`var(--mindmap-root-border, ${m})`}else f.style.border="var(--mindmap-child-border, 1px solid #ccc)";else t.isRoot?f.style.border="var(--mindmap-root-border)":f.style.border="var(--mindmap-child-border)";f.style.borderRadius="4px",t.isRoot&&(f.style.fontSize="1.2em",f.style.fontWeight="bold",g.name!=="custom"&&(f.style.border="2px solid var(--vscode-editor-foreground, #333)")),t.style.color&&(f.style.color=t.style.color),t.style.fontSize&&(f.style.fontSize=t.style.fontSize),t.style.fontWeight&&(f.style.fontWeight=t.style.fontWeight),t.style.fontStyle&&(f.style.fontStyle=t.style.fontStyle),t.style.background?f.style.backgroundColor=t.style.background:g.name==="custom"?t.isRoot?f.style.backgroundColor="var(--mindmap-root-background, var(--vscode-editor-background, white))":f.style.backgroundColor="var(--mindmap-child-background, var(--vscode-editor-background, white))":t.isRoot?f.style.backgroundColor="var(--mindmap-root-background)":f.style.backgroundColor="var(--mindmap-child-background)";const{width:p}=this.measureNode(t);let d=e;if(s==="left"&&!o?d=e-p:o&&(d=e-p/2),f.style.left=`${d}px`,f.style.top=`${i}px`,f.style.transform="translate(0, -50%)",f.style.zIndex="10",f.style.cursor="default",f.style.userSelect="none",t.id===r&&(f.style.outline="2px solid var(--vscode-focusBorder, #007bff)",f.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))"),this.nodeContainer.appendChild(f),t.children.length===0)return;if(this.options.onToggleFold){const m=[];if(o&&n==="Both")m.push(d+p),m.push(d);else{let u=s==="right";o&&(n==="Left"?u=!1:u=!0),m.push(u?d+p:d)}m.forEach(u=>{const v=document.createElement("div");v.className="mindmap-toggle-btn",v.innerHTML=t.isFolded?"+":"-",v.style.position="absolute",v.style.width="16px",v.style.height="16px",v.style.fontSize="12px",v.style.lineHeight="14px",v.style.textAlign="center",v.style.borderRadius="50%",v.style.border="1px solid var(--vscode-widget-border, #999)",v.style.backgroundColor="var(--vscode-editor-background, #fff)",v.style.color="var(--vscode-editor-foreground, #000)",v.style.cursor="pointer",v.style.zIndex="11",v.style.userSelect="none";const k=0;v.style.left=`${u+k}px`,v.style.top=`${i}px`,v.style.transform="translate(-50%, -50%)",v.addEventListener("click",C=>{C.stopPropagation(),this.options.onToggleFold?.(t.id)}),this.nodeContainer.appendChild(v)})}if(t.isFolded)return;let w=[],h=[];o&&n==="Both"?t.children.forEach((m,u)=>{(m.layoutSide||(u%2===0?"right":"left"))==="right"?w.push(m):h.push(m)}):n==="Left"?h=t.children:n==="Right"?w=t.children:s==="left"?h=t.children:w=t.children,w.length>0&&this.renderChildrenStack(t,w,e,i,r,n,"right",p,c),h.length>0&&this.renderChildrenStack(t,h,e,i,r,n,"left",p,c)}renderChildrenStack(t,e,i,r,n,o,s,c,g){const f=e.reduce((w,h)=>w+this.getNodeHeight(h,g),0);let y=r-f/2;const p=80;let d=0;t.isRoot?d=s==="right"?i+c/2:i-c/2:s==="right"?d=i+c:(d=i,d=i-c),e.forEach(w=>{const h=this.getNodeHeight(w,g),m=y+h/2,u=s==="right"?d+p:d-p;this.renderNode(w,u,m,n,o,!1,s,g);const v=g?this.getThemeColor(w,g):"#ccc";this.drawConnection(d,r,u,m,v,g?.theme),y+=h})}getChildrenHeight(t,e){return t.children.reduce((i,r)=>i+this.getNodeHeight(r,e),0)}getNodeHeight(t,e){const{height:i}=this.measureNode(t,e),r=20;if(t.children.length===0||t.isFolded)return i+r;const n=this.getChildrenHeight(t,e);return Math.max(i+r,n)}measureNode(t,e){if(t.image)return t.imageSize?t.imageSize.width>150?{width:160,height:150*(t.imageSize.height/t.imageSize.width)+10}:{width:t.imageSize.width+10,height:t.imageSize.height+10}:{width:160,height:160};const i=document.createElement("div");if(i.className="mindmap-node",i.style.visibility="hidden",i.style.position="absolute",i.style.display="flex",i.style.alignItems="center",t.icon)if(It[t.icon]){const y=document.createElement("div");y.style.width="20px",y.style.height="20px",y.style.marginRight="8px",y.style.flexShrink="0",i.appendChild(y)}else{const y=document.createElement("span");y.textContent=t.icon,y.style.marginRight="6px",y.style.fontSize="1.2em",i.appendChild(y)}const r=document.createElement("span");r.textContent=t.topic,i.appendChild(r);const n=t.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);n!==void 0?(r.style.whiteSpace="pre-wrap",r.style.wordWrap="break-word",r.style.overflowWrap="anywhere",r.style.minWidth="0",i.style.maxWidth=`${n}px`,i.style.width="max-content"):r.style.whiteSpace="pre",i.style.padding="8px 12px";const o=ct.getInstance().getCurrentTheme(),s=e?this.getThemeColor(t,e):"#ccc";o.name==="colorful"?i.style.border=`2px solid ${s}`:o.name==="custom"?t.isRoot?i.style.border="var(--mindmap-root-border, 2px solid #333)":i.style.border="var(--mindmap-child-border, 1px solid #ccc)":t.isRoot?i.style.border="var(--mindmap-root-border)":i.style.border="var(--mindmap-child-border)",t.isRoot&&(i.style.fontSize="1.2em",i.style.fontWeight="bold",o.name!=="custom"&&(i.style.border="2px solid var(--vscode-editor-foreground, #333)")),t.style.color&&(i.style.color=t.style.color),t.style.fontSize&&(i.style.fontSize=t.style.fontSize),t.style.fontWeight&&(i.style.fontWeight=t.style.fontWeight),t.style.fontStyle&&(i.style.fontStyle=t.style.fontStyle),t.style.background&&(i.style.backgroundColor=t.style.background),this.nodeContainer.appendChild(i);const c=i.offsetWidth,g=i.offsetHeight;return this.nodeContainer.removeChild(i),{width:c||100,height:g||40}}drawConnection(t,e,i,r,n="#ccc",o="default"){const s=document.createElementNS("http://www.w3.org/2000/svg","path"),c=t+(i-t)/2,g=t+(i-t)/2,f=`M ${t} ${e} C ${c} ${e}, ${g} ${r}, ${i} ${r}`;s.setAttribute("d",f),o==="custom"?s.style.stroke=`var(--mindmap-connection-color, ${n})`:(s.style.stroke="var(--mindmap-connection-color, #ccc)",ct.getInstance().getCurrentTheme().name==="colorful"?s.style.stroke=n:s.style.stroke="var(--mindmap-connection-color)"),s.setAttribute("fill","none"),s.setAttribute("stroke-width","2"),this.svg.appendChild(s)}showImageModal(t){this.options.onImageZoom&&this.options.onImageZoom(!0);const e=document.createElement("div");e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.backgroundColor="rgba(0,0,0,0.8)",e.style.zIndex="1000",e.style.display="flex",e.style.justifyContent="center",e.style.alignItems="center",e.style.cursor="zoom-out";const i=document.createElement("img");i.src=t,i.style.maxWidth="90%",i.style.maxHeight="90%",i.style.boxShadow="0 0 20px rgba(0,0,0,0.5)",e.appendChild(i),document.body.appendChild(e);let r;const n=()=>{document.body.contains(e)&&document.body.removeChild(e),r&&document.removeEventListener("keydown",r,!0),this.options.onImageZoom&&this.options.onImageZoom(!1),this.container.focus()};r=o=>{o.stopPropagation(),o.preventDefault(),n()},document.addEventListener("keydown",r,!0),e.addEventListener("click",()=>{n()})}}class yt{container;editorEl;currentNodeId=null;onUpdate;static FONT_SIZES=[{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"24px",value:"24px"},{label:"32px",value:"32px"},{label:"48px",value:"48px"}];static PALETTE=["#000000","#E74C3C","#E67E22","#F1C40F","#2ECC71","#3498DB","#9B59B6"];constructor(t){this.container=t,this.editorEl=this.createEditor(),this.container.appendChild(this.editorEl),this.editorEl.addEventListener("mousedown",e=>e.stopPropagation()),this.editorEl.addEventListener("click",e=>e.stopPropagation()),this.editorEl.addEventListener("dblclick",e=>e.stopPropagation())}createEditor(){const t=document.createElement("div");t.className="style-editor",t.style.position="absolute",t.style.top="20px",t.style.right="20px",t.style.display="none",t.style.backgroundColor="white",t.style.border="1px solid #eee",t.style.borderRadius="8px",t.style.padding="8px",t.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",t.style.zIndex="2000",t.style.pointerEvents="auto",t.style.fontFamily="Arial, sans-serif",t.style.display="flex",t.style.flexDirection="column",t.style.gap="8px",t.style.margin="0",t.style.boxSizing="border-box",t.style.minWidth="220px";const e=document.createElement("div");e.style.display="flex",e.style.gap="8px",e.style.alignItems="center";const i=document.createElement("select");i.style.padding="4px 8px",i.style.borderRadius="4px",i.style.border="1px solid #ccc",i.style.fontSize="14px",i.style.flex="1",yt.FONT_SIZES.forEach(f=>{const y=document.createElement("option");y.value=f.value,y.textContent=f.label,i.appendChild(y)}),i.onchange=f=>{this.currentNodeId&&this.onUpdate&&this.onUpdate(this.currentNodeId,{fontSize:f.target.value})},e.appendChild(i);const n=(f,y,p)=>{const d=document.createElement("button");return d.textContent=f,d.style.width="32px",d.style.height="32px",d.style.padding="0",d.style.display="flex",d.style.justifyContent="center",d.style.alignItems="center",d.style.border="1px solid #ddd",d.style.backgroundColor="#f5f5f5",d.style.borderRadius="4px",d.style.cursor="pointer",d.style.fontSize="14px",y&&(d.style[y]=y==="fontWeight"?"bold":"italic"),d.onclick=p,d},o=n("B","fontWeight",()=>{if(this.currentNodeId&&this.onUpdate){const f=o.classList.contains("active"),y=f?"normal":"bold";this.onUpdate(this.currentNodeId,{fontWeight:y}),this.updateButtonState(o,!f)}}),s=n("I","fontStyle",()=>{if(this.currentNodeId&&this.onUpdate){const f=s.classList.contains("active"),y=f?"normal":"italic";this.onUpdate(this.currentNodeId,{fontStyle:y}),this.updateButtonState(s,!f)}});e.appendChild(o),e.appendChild(s),t.appendChild(e);const c=document.createElement("div");c.style.display="flex",c.style.gap="4px",c.style.alignItems="center",c.style.justifyContent="space-between";const g=document.createElement("input");return g.type="color",g.style.width="24px",g.style.height="24px",g.style.border="1px solid #ccc",g.style.padding="0",g.style.backgroundColor="transparent",g.style.cursor="pointer",g.style.appearance="none",g.onchange=f=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:f.target.value}),this.updateActivePaletteItem(f.target.value))},yt.PALETTE.forEach((f,y)=>{const p=document.createElement("div");p.className="color-swatch",p.dataset.color=f,p.textContent=(y+1).toString(),p.style.width="24px",p.style.height="24px",p.style.backgroundColor=f,p.style.borderRadius="4px",p.style.cursor="pointer",p.style.border="1px solid transparent",p.style.color=f==="#F1C40F"?"black":"white",p.style.fontSize="12px",p.style.fontWeight="bold",p.style.display="flex",p.style.justifyContent="center",p.style.alignItems="center",p.onclick=()=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:f}),g.value=f,this.updateActivePaletteItem(f))},c.appendChild(p)}),c.appendChild(g),t.appendChild(c),t}updateActivePaletteItem(t){this.editorEl.querySelectorAll(".color-swatch").forEach(i=>{const r=i;r.dataset.color?.toLowerCase()===t.toLowerCase()?(r.style.border="2px solid #ccc",r.style.transform="scale(1.1)"):(r.style.border="1px solid transparent",r.style.transform="scale(1)")})}updateButtonState(t,e){e?(t.classList.add("active"),t.style.backgroundColor="#e0e0e0",t.style.borderColor="#999"):(t.classList.remove("active"),t.style.backgroundColor="#f5f5f5",t.style.borderColor="#ddd")}show(t,e){this.currentNodeId=t,this.editorEl.style.display="flex";const i=this.editorEl.querySelector("select");i.value=e.fontSize||"";const r=this.editorEl.querySelector('input[type="color"]'),n=e.color||"#000000";r.value=n,this.updateActivePaletteItem(n);const o=this.editorEl.querySelectorAll("button")[0];this.updateButtonState(o,e.fontWeight==="bold");const s=this.editorEl.querySelectorAll("button")[1];this.updateButtonState(s,e.fontStyle==="italic")}hide(){this.editorEl.style.display="none",this.currentNodeId=null}}class Yt{container;element;options;currentMode="Right";currentTheme="default";layoutButtons=new Map;themeButtons=new Map;constructor(t,e){this.container=t,this.options=e,this.element=document.createElement("div"),this.render()}render(){this.element.style.position="absolute",this.element.style.top="20px",this.element.style.left="20px",this.element.style.display="flex",this.element.style.flexDirection="column",this.element.style.backgroundColor="white",this.element.style.borderRadius="8px",this.element.style.boxShadow="0 2px 10px rgba(0,0,0,0.1)",this.element.style.padding="5px",this.element.style.zIndex="2000",this.element.style.gap="5px",this.element.style.pointerEvents="auto",this.element.addEventListener("click",t=>t.stopPropagation()),this.element.addEventListener("mousedown",t=>t.stopPropagation()),this.createLayoutButton("Right",this.getRightIcon()),this.createLayoutButton("Left",this.getLeftIcon()),this.createLayoutButton("Both",this.getBothIcon()),this.addSeparator(),this.createThemeButton("default",this.getThemeDefaultIcon()),this.createThemeButton("simple",this.getThemeSimpleIcon()),this.createThemeButton("colorful",this.getThemeColorfulIcon()),this.createThemeButton("custom",this.getThemeCustomIcon()),this.addSeparator(),this.createIconActionButton("Reset Zoom",this.getZoomResetIcon(),()=>{this.options.onZoomReset&&this.options.onZoomReset()}),this.addSeparator(),this.createIconActionButton("Shortcuts Help",this.getHelpIcon(),()=>{this.options.onShowShortcuts&&this.options.onShowShortcuts()}),this.container.appendChild(this.element),this.updateActiveButtons()}addSeparator(){const t=document.createElement("div");t.style.height="1px",t.style.backgroundColor="#ccc",t.style.margin="5px 2px",this.element.appendChild(t)}createLayoutButton(t,e){const i=document.createElement("button");i.innerHTML=e,this.styleButton(i),i.title=`Layout: ${t}`,i.addEventListener("click",()=>{this.setMode(t)}),this.element.appendChild(i),this.layoutButtons.set(t,i)}createThemeButton(t,e){const i=document.createElement("button");i.innerHTML=e,this.styleButton(i),i.title=`Theme: ${t}`,i.addEventListener("click",()=>{this.setTheme(t)}),this.element.appendChild(i),this.themeButtons.set(t,i)}createIconActionButton(t,e,i){const r=document.createElement("button");r.innerHTML=e,this.styleButton(r),r.title=t,r.addEventListener("click",i),this.element.appendChild(r)}styleButton(t){t.style.width="32px",t.style.height="32px",t.style.border="none",t.style.background="transparent",t.style.cursor="pointer",t.style.borderRadius="4px",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.color="#555"}updateActiveButtons(){this.layoutButtons.forEach((t,e)=>{e===this.currentMode?(t.style.backgroundColor="#e6f7ff",t.style.color="#007bff"):(t.style.backgroundColor="transparent",t.style.color="#555")}),this.themeButtons.forEach((t,e)=>{e===this.currentTheme?(t.style.backgroundColor="#e6f7ff",t.style.color="#007bff"):(t.style.backgroundColor="transparent",t.style.color="#555")})}setMode(t){this.currentMode!==t&&(this.currentMode=t,this.updateActiveButtons(),this.options.onLayoutChange(t))}setTheme(t){this.currentTheme!==t&&(this.currentTheme=t,this.updateActiveButtons(),this.options.onThemeChange(t))}getRightIcon(){return`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
2
  <circle cx="5" cy="12" r="3"></circle>
3
3
  <path d="M8 12h8"></path>
4
4
  <path d="M8 12 L16 5"></path>
@@ -37,8 +37,8 @@
37
37
  <circle cx="12" cy="12" r="10"></circle>
38
38
  <path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path>
39
39
  <line x1="12" y1="17" x2="12.01" y2="17"></line>
40
- </svg>`}}const D={navUp:[{key:"ArrowUp"},{key:"k",ctrlKey:!1,metaKey:!1,altKey:!1}],navDown:[{key:"ArrowDown"},{key:"j",ctrlKey:!1,metaKey:!1,altKey:!1}],navLeft:[{key:"ArrowLeft"},{key:"h",ctrlKey:!1,metaKey:!1,altKey:!1}],navRight:[{key:"ArrowRight"},{key:"l",ctrlKey:!1,metaKey:!1,altKey:!1}],addChild:[{key:"Tab"},{key:"a"}],insertParent:[{key:"Tab",shiftKey:!0},{key:"a",shiftKey:!0}],addSibling:[{key:"Enter"}],addSiblingBefore:[{key:"Enter",shiftKey:!0}],deleteNode:[{key:"Delete"},{key:"Backspace"}],beginEdit:[{key:"i"},{key:" "},{key:"F2"}],copy:[{key:"c",ctrlKey:!0},{key:"c",metaKey:!0}],paste:[{key:"v",ctrlKey:!0},{key:"v",metaKey:!0}],cut:[{key:"x",ctrlKey:!0},{key:"x",metaKey:!0}],undo:[{key:"z",ctrlKey:!0},{key:"z",metaKey:!0}],redo:[{key:"Z",ctrlKey:!0,shiftKey:!0},{key:"Z",metaKey:!0,shiftKey:!0},{key:"y",ctrlKey:!0},{key:"y",metaKey:!0}],bold:[{key:"b",shiftKey:!0}],italic:[{key:"i",shiftKey:!0}],increaseFontSize:[{key:">",shiftKey:!0},{key:"."}],decreaseFontSize:[{key:"<",shiftKey:!0},{key:","}],zoomIn:[{key:"["}],zoomOut:[{key:"]"}],resetZoom:[{key:":"}],toggleFold:[{key:"f",ctrlKey:!1,metaKey:!1,altKey:!1}],selectColor1:[{key:"1"}],selectColor2:[{key:"2"}],selectColor3:[{key:"3"}],selectColor4:[{key:"4"}],selectColor5:[{key:"5"}],selectColor6:[{key:"6"}],selectColor7:[{key:"7"}],openCommandPalette:[{key:"m"}],increaseNodeWidth:[{key:"ArrowRight",shiftKey:!0}],decreaseNodeWidth:[{key:"ArrowLeft",shiftKey:!0}]};class T{container;maxWidth;options;constructor(e,t,i){this.container=e,this.maxWidth=t,this.options=i}setMaxWidth(e){this.maxWidth=e}startEditing(e,t){const i=e.textContent||"",o=this.createEditTextarea(e,i);let s=this.maxWidth;if(e.style.maxWidth){const h=parseInt(e.style.maxWidth,10);isNaN(h)||(s=h)}this.applyTextareaStyles(o,e,s);const n=e.style.outline,d=e.style.boxShadow;e.style.outline="none",e.style.boxShadow="none";const a=this.createSizeUpdater(o,e,s);a(),o.addEventListener("input",a);const r=this.createCleanupFunction(o,e,n,d);this.setupEditEventHandlers(o,t,i,r),e.parentElement?e.parentElement.appendChild(o):this.container.appendChild(o),o.focus({preventScroll:!0}),o.select()}createEditTextarea(e,t){const i=document.createElement("textarea");return i.value=t,i.style.position="absolute",i.style.top=e.style.top,i.style.left=e.style.left,i.style.transform=e.style.transform,this.container.scrollTop=0,this.container.scrollLeft=0,i.style.overflow="hidden",i.style.resize="none",i.style.minHeight="1em",i}applyTextareaStyles(e,t,i){const o=window.getComputedStyle(t);if(i!==-1){e.style.whiteSpace="pre-wrap",e.style.wordWrap="break-word",e.style.overflowWrap="anywhere";const s=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0),n=(parseFloat(o.borderLeftWidth)||0)+(parseFloat(o.borderRightWidth)||0),d=i+s+n;e.style.maxWidth=`${d}px`,e.style.width="max-content"}else e.style.whiteSpace="pre";e.style.font=o.font,e.style.padding=o.padding,e.style.boxSizing="border-box",e.style.backgroundColor=o.backgroundColor,e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.borderTop=o.borderTop,e.style.borderRight=o.borderRight,e.style.borderBottom=o.borderBottom,e.style.borderLeft=o.borderLeft,e.style.borderRadius=o.borderRadius,e.style.zIndex="100"}createSizeUpdater(e,t,i){const o=window.getComputedStyle(t);return()=>{const s=document.createElement("span");s.style.font=o.font,s.style.padding=o.padding,i!==-1?(s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflowWrap="anywhere",s.style.maxWidth=`${i}px`,s.style.width="max-content"):s.style.whiteSpace="pre",s.style.visibility="hidden",s.style.position="absolute",s.textContent=e.value||"",(e.value.endsWith(`
41
- `)||e.value==="")&&(s.textContent+="​"),document.body.appendChild(s);const n=s.offsetWidth+4,d=s.offsetHeight;e.style.width=Math.max(n,t.offsetWidth)+"px",e.style.height=Math.max(d,t.offsetHeight)+"px",document.body.removeChild(s)}}createCleanupFunction(e,t,i,o){return()=>{e.parentNode&&e.parentNode.contains(e)&&e.parentNode.removeChild(e),t.style.outline=i,t.style.boxShadow=o}}setupEditEventHandlers(e,t,i,o){let s=!1;const n=()=>{if(s)return;s=!0;const a=e.value;a!==i&&this.options.onUpdateNode&&this.options.onUpdateNode(t,a),o(),this.options.onEditEnd&&this.options.onEditEnd(t)},d=()=>{s||(s=!0,o(),this.options.onEditEnd&&this.options.onEditEnd(t))};e.addEventListener("blur",()=>{s||n()}),e.addEventListener("keydown",a=>{if(a.stopPropagation(),!a.isComposing)if(a.key==="Enter"){if(a.shiftKey)return;a.preventDefault(),n()}else a.key==="Escape"&&(a.preventDefault(),d())})}}class R{container;options;draggedNodeId=null;isReadOnly=!1;constructor(e,t){this.container=e,this.options=t,this.injectDragStyles()}setReadOnly(e){this.isReadOnly=e}injectDragStyles(){const e=document.createElement("style");e.textContent=`
40
+ </svg>`}}const Gt={navUp:[{key:"ArrowUp"},{key:"k",ctrlKey:!1,metaKey:!1,altKey:!1}],navDown:[{key:"ArrowDown"},{key:"j",ctrlKey:!1,metaKey:!1,altKey:!1}],navLeft:[{key:"ArrowLeft"},{key:"h",ctrlKey:!1,metaKey:!1,altKey:!1}],navRight:[{key:"ArrowRight"},{key:"l",ctrlKey:!1,metaKey:!1,altKey:!1}],addChild:[{key:"Tab"},{key:"a"}],insertParent:[{key:"Tab",shiftKey:!0},{key:"a",shiftKey:!0}],addSibling:[{key:"Enter"}],addSiblingBefore:[{key:"Enter",shiftKey:!0}],deleteNode:[{key:"Delete"},{key:"Backspace"},{key:"d"}],beginEdit:[{key:"i"},{key:" "},{key:"F2"}],copy:[{key:"c",ctrlKey:!0},{key:"c",metaKey:!0}],paste:[{key:"v",ctrlKey:!0},{key:"v",metaKey:!0}],cut:[{key:"x",ctrlKey:!0},{key:"x",metaKey:!0}],undo:[{key:"z",ctrlKey:!0},{key:"z",metaKey:!0}],redo:[{key:"Z",ctrlKey:!0,shiftKey:!0},{key:"Z",metaKey:!0,shiftKey:!0},{key:"y",ctrlKey:!0},{key:"y",metaKey:!0}],bold:[{key:"b",shiftKey:!0}],italic:[{key:"i",shiftKey:!0}],increaseFontSize:[{key:">",shiftKey:!0},{key:"."}],decreaseFontSize:[{key:"<",shiftKey:!0},{key:","}],zoomIn:[{key:"["}],zoomOut:[{key:"]"}],resetZoom:[{key:":"}],toggleFold:[{key:"f",ctrlKey:!1,metaKey:!1,altKey:!1}],selectColor1:[{key:"1"}],selectColor2:[{key:"2"}],selectColor3:[{key:"3"}],selectColor4:[{key:"4"}],selectColor5:[{key:"5"}],selectColor6:[{key:"6"}],selectColor7:[{key:"7"}],openCommandPalette:[{key:"m"}],increaseNodeWidth:[{key:"ArrowRight",shiftKey:!0}],decreaseNodeWidth:[{key:"ArrowLeft",shiftKey:!0}]};class $t{container;maxWidth;options;constructor(t,e,i){this.container=t,this.maxWidth=e,this.options=i}setMaxWidth(t){this.maxWidth=t}startEditing(t,e){const i=t.textContent||"",r=this.createEditTextarea(t,i);let n=this.maxWidth;if(t.style.maxWidth){const f=parseInt(t.style.maxWidth,10);isNaN(f)||(n=f)}this.applyTextareaStyles(r,t,n);const o=t.style.outline,s=t.style.boxShadow;t.style.outline="none",t.style.boxShadow="none";const c=this.createSizeUpdater(r,t,n);c(),r.addEventListener("input",c);const g=this.createCleanupFunction(r,t,o,s);this.setupEditEventHandlers(r,e,i,g),t.parentElement?t.parentElement.appendChild(r):this.container.appendChild(r),r.focus({preventScroll:!0}),r.select()}createEditTextarea(t,e){const i=document.createElement("textarea");return i.value=e,i.style.position="absolute",i.style.top=t.style.top,i.style.left=t.style.left,i.style.transform=t.style.transform,this.container.scrollTop=0,this.container.scrollLeft=0,i.style.overflow="hidden",i.style.resize="none",i.style.minHeight="1em",i}applyTextareaStyles(t,e,i){const r=window.getComputedStyle(e);if(i!==-1){t.style.whiteSpace="pre-wrap",t.style.wordWrap="break-word",t.style.overflowWrap="anywhere";const n=(parseFloat(r.paddingLeft)||0)+(parseFloat(r.paddingRight)||0),o=(parseFloat(r.borderLeftWidth)||0)+(parseFloat(r.borderRightWidth)||0),s=i+n+o;t.style.maxWidth=`${s}px`,t.style.width="max-content"}else t.style.whiteSpace="pre";t.style.font=r.font,t.style.padding=r.padding,t.style.boxSizing="border-box",t.style.backgroundColor=r.backgroundColor,t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.borderTop=r.borderTop,t.style.borderRight=r.borderRight,t.style.borderBottom=r.borderBottom,t.style.borderLeft=r.borderLeft,t.style.borderRadius=r.borderRadius,t.style.zIndex="100"}createSizeUpdater(t,e,i){const r=window.getComputedStyle(e);return()=>{const n=document.createElement("span");n.style.font=r.font,n.style.padding=r.padding,i!==-1?(n.style.whiteSpace="pre-wrap",n.style.wordWrap="break-word",n.style.overflowWrap="anywhere",n.style.maxWidth=`${i}px`,n.style.width="max-content"):n.style.whiteSpace="pre",n.style.visibility="hidden",n.style.position="absolute",n.textContent=t.value||"",(t.value.endsWith(`
41
+ `)||t.value==="")&&(n.textContent+="​"),document.body.appendChild(n);const o=n.offsetWidth+4,s=n.offsetHeight;t.style.width=Math.max(o,e.offsetWidth)+"px",t.style.height=Math.max(s,e.offsetHeight)+"px",document.body.removeChild(n)}}createCleanupFunction(t,e,i,r){return()=>{t.parentNode&&t.parentNode.contains(t)&&t.parentNode.removeChild(t),e.style.outline=i,e.style.boxShadow=r}}setupEditEventHandlers(t,e,i,r){let n=!1;const o=()=>{if(n)return;n=!0;const c=t.value;c!==i&&this.options.onUpdateNode&&this.options.onUpdateNode(e,c),r(),this.options.onEditEnd&&this.options.onEditEnd(e)},s=()=>{n||(n=!0,r(),this.options.onEditEnd&&this.options.onEditEnd(e))};t.addEventListener("blur",()=>{n||o()}),t.addEventListener("keydown",c=>{if(c.stopPropagation(),!c.isComposing)if(c.key==="Enter"){if(c.shiftKey)return;c.preventDefault(),o()}else c.key==="Escape"&&(c.preventDefault(),s())})}}class Jt{container;options;draggedNodeId=null;isReadOnly=!1;constructor(t,e){this.container=t,this.options=e,this.injectDragStyles()}setReadOnly(t){this.isReadOnly=t}injectDragStyles(){const t=document.createElement("style");t.textContent=`
42
42
  .mindmap-node.drag-over-top {
43
43
  border-top: 4px solid #007bff !important;
44
44
  }
@@ -51,4 +51,6 @@
51
51
  .mindmap-node.drag-over-right {
52
52
  border-right: 4px solid #007bff !important;
53
53
  }
54
- `,document.head.appendChild(e)}handleDragStart(e){const t=e;if(this.isReadOnly){t.preventDefault();return}const o=t.target.closest(".mindmap-node");o&&o.dataset.id&&(this.draggedNodeId=o.dataset.id,t.dataTransfer?.setData("text/plain",o.dataset.id),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}handleDragOver(e){const t=e;if(this.isReadOnly)return;t.preventDefault();const o=t.target.closest(".mindmap-node");if(o&&o.dataset.id&&this.draggedNodeId&&o.dataset.id!==this.draggedNodeId){const s=this.getDropPosition(t,o);o.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right"),o.classList.add(`drag-over-${s}`),t.dataTransfer&&(t.dataTransfer.dropEffect="move")}}handleDragLeave(e){const i=e.target.closest(".mindmap-node");i&&i.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}handleDrop(e){const t=e;t.preventDefault();const o=t.target.closest(".mindmap-node");if(this.container.querySelectorAll(".mindmap-node").forEach(s=>{s.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}),!this.isReadOnly){if(o&&o.dataset.id&&this.draggedNodeId){const s=o.dataset.id;if(this.draggedNodeId!==s){const n=this.getDropPosition(t,o);this.options.onDropNode(this.draggedNodeId,s,n)}}this.draggedNodeId=null}}handleDragEnd(){this.draggedNodeId=null,this.container.querySelectorAll(".mindmap-node").forEach(e=>{e.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")})}getDropPosition(e,t){const i=t.getBoundingClientRect(),o=e.clientX-i.left,s=e.clientY-i.top,n=i.width,d=i.height;return s<d*.25?"top":s>d*.75?"bottom":o<n*.25?"left":(o>n*.75,"right")}}class z{shortcuts;constructor(e){this.shortcuts=e}matches(e,t){const i=this.shortcuts[t];return i?i.some(o=>{const s=o.ctrlKey??!1,n=o.metaKey??!1,d=o.altKey??!1,a=o.shiftKey??!1;return e.ctrlKey!==s||e.metaKey!==n||e.altKey!==d||e.shiftKey!==a?!1:o.key.toLowerCase()===e.key.toLowerCase()}):!1}getAction(e){const t=Object.keys(this.shortcuts);for(const i of t)if(this.matches(e,i))return i}}class P{container;options;maxWidth=-1;selectedNodeId=null;isPanning=!1;lastMouseX=0;lastMouseY=0;isReadOnly=!1;shortcuts;nodeEditor;nodeDragger;shortcutManager;cleanupFns=[];constructor(e,t){this.container=e,this.container.tabIndex=0,this.container.style.outline="none",this.container.style.cursor="default",this.options=t,this.shortcuts={...D,...t.shortcuts},this.nodeEditor=new T(e,this.maxWidth,t),this.nodeDragger=new R(e,t),this.shortcutManager=new z(this.shortcuts),this.isReadOnly=!!t.allowReadOnly,this.nodeDragger.setReadOnly(this.isReadOnly),this.attachEvents()}getShortcuts(){return this.shortcuts}setReadOnly(e){this.isReadOnly=e,this.nodeDragger&&this.nodeDragger.setReadOnly(e),e&&this.nodeDragger&&this.nodeDragger.draggedNodeId&&(this.nodeDragger.draggedNodeId=null)}destroy(){this.cleanupFns.forEach(e=>e()),this.cleanupFns=[]}updateSelection(e){this.selectedNodeId=e}attachEvents(){const e=(o,s,n,d)=>{o.addEventListener(s,n,d),this.cleanupFns.push(()=>{typeof o.removeEventListener=="function"&&o.removeEventListener(s,n,d)})};e(this.container,"focus",()=>{}),e(this.container,"blur",()=>{}),e(this.container,"scroll",()=>{(this.container.scrollTop!==0||this.container.scrollLeft!==0)&&(this.container.scrollTop=0,this.container.scrollLeft=0)}),e(this.container,"click",o=>{const n=o.target.closest(".mindmap-node");n&&n.dataset.id?this.options.onNodeClick(n.dataset.id):this.options.onNodeClick(""),this.container.focus()}),e(this.container,"mousedown",o=>{const s=o,n=s.target;!n.closest(".mindmap-node")&&n.tagName!=="INPUT"&&(this.isPanning=!0,this.lastMouseX=s.clientX,this.lastMouseY=s.clientY,this.container.style.cursor="all-scroll")}),e(window,"mousemove",o=>{const s=o;if(this.isPanning){const n=s.clientX-this.lastMouseX,d=s.clientY-this.lastMouseY;this.lastMouseX=s.clientX,this.lastMouseY=s.clientY,this.options.onPan&&this.options.onPan(n,d)}});const t=()=>{this.isPanning&&(this.isPanning=!1,this.container.style.cursor="default")};e(window,"mouseup",t),e(window,"mouseleave",t),e(this.container,"wheel",o=>{const s=o;if(s.preventDefault(),s.ctrlKey||s.metaKey){this.options.onZoom&&this.options.onZoom(s.deltaY,s.clientX,s.clientY);return}let n=1;s.deltaMode===1?n=33:s.deltaMode===2&&(n=window.innerHeight);const d=-s.deltaX*n,a=-s.deltaY*n;this.options.onPan&&this.options.onPan(d,a)},{passive:!1}),e(document,"keydown",o=>{const s=o,n=s.target;if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable)return;if(this.shortcutManager.matches(s,"resetZoom")){s.preventDefault(),this.options.onZoomReset?.();return}if(this.shortcutManager.getAction(s)==="openCommandPalette"){s.preventDefault(),this.options.onToggleCommandPalette?.();return}if(!this.selectedNodeId){if(this.shortcutManager.matches(s,"navUp")||this.shortcutManager.matches(s,"navDown")||this.shortcutManager.matches(s,"navLeft")||this.shortcutManager.matches(s,"navRight")){s.preventDefault();let r=null,h=1/0;this.container.querySelectorAll(".mindmap-node").forEach(l=>{const c=l;if(!c.dataset.id)return;const m=c.getBoundingClientRect(),v=m.left+m.width/2,y=m.top+m.height/2,u=this.container.getBoundingClientRect(),f=u.left+u.width/2,N=u.top+u.height/2,x=Math.pow(v-f,2)+Math.pow(y-N,2);x<h&&(h=x,r=c.dataset.id)}),r&&this.options.onNodeClick(r)}return}const a=this.shortcutManager.getAction(s);a&&this.handleAction(a,s)}),e(document,"paste",o=>{const s=o;if(this.isReadOnly||!this.selectedNodeId)return;const n=s.clipboardData?.items;if(!n||n.length===0){this.options.onPasteNode?.(this.selectedNodeId);return}let d=!1;for(const a of n)if(a.type.startsWith("image/")){const r=a.getAsFile();if(r){const h=new FileReader;h.onload=p=>{if(p.target?.result&&this.options.onPasteImage&&this.selectedNodeId){const l=p.target.result,c=new Image;c.onload=()=>{this.selectedNodeId&&this.options.onPasteImage&&this.options.onPasteImage(this.selectedNodeId,l,c.naturalWidth,c.naturalHeight)},c.src=l}},h.readAsDataURL(r)}s.preventDefault(),d=!0;break}d||this.options.onPasteNode?.(this.selectedNodeId)});const i=(o,s,n)=>e(o,s,n);i(this.container,"dragstart",this.nodeDragger.handleDragStart.bind(this.nodeDragger)),i(this.container,"dragover",this.nodeDragger.handleDragOver.bind(this.nodeDragger)),i(this.container,"dragleave",this.nodeDragger.handleDragLeave.bind(this.nodeDragger)),i(this.container,"drop",this.nodeDragger.handleDrop.bind(this.nodeDragger)),i(this.container,"dragend",this.nodeDragger.handleDragEnd.bind(this.nodeDragger)),e(this.container,"dblclick",o=>{if(this.isReadOnly)return;const n=o.target.closest(".mindmap-node");n&&n.dataset.id&&this.startEditing(n,n.dataset.id)})}editNode(e){const t=this.container.querySelector(`.mindmap-node[data-id="${e}"]`);t&&this.startEditing(t,e)}get draggedNodeId(){return this.nodeDragger?this.nodeDragger.draggedNodeId:null}set draggedNodeId(e){this.nodeDragger&&(this.nodeDragger.draggedNodeId=e)}startEditing(e,t){this.nodeEditor.setMaxWidth(this.maxWidth),this.nodeEditor.startEditing(e,t)}handleAction(e,t){if(this.selectedNodeId){switch(e){case"copy":t.preventDefault(),this.options.onCopyNode?.(this.selectedNodeId);return;case"navUp":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Up");return;case"navDown":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Down");return;case"navRight":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Right");return;case"navLeft":t.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Left");return}if(!this.isReadOnly)switch(e){case"addChild":t.preventDefault(),this.options.onAddChild(this.selectedNodeId);break;case"insertParent":t.preventDefault(),this.options.onInsertParent?.(this.selectedNodeId);break;case"addSibling":t.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"after");break;case"addSiblingBefore":t.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"before");break;case"deleteNode":t.preventDefault(),this.options.onDeleteNode(this.selectedNodeId);break;case"beginEdit":t.preventDefault(),this.handleBeginEdit();break;case"zoomIn":if(t.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(-100,i.left+i.width/2,i.top+i.height/2)}break;case"zoomOut":if(t.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(100,i.left+i.width/2,i.top+i.height/2)}break;case"cut":t.preventDefault(),this.options.onCutNode?.(this.selectedNodeId);break;case"undo":t.preventDefault(),this.options.onUndo?.();break;case"redo":t.preventDefault(),this.options.onRedo?.();break;case"bold":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"bold"});break;case"italic":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"italic"});break;case"increaseFontSize":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"increaseSize"});break;case"decreaseFontSize":t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"decreaseSize"});break;case"toggleFold":t.preventDefault(),this.options.onToggleFold?.(this.selectedNodeId);break;case"openCommandPalette":t.preventDefault(),this.options.onToggleCommandPalette?.();break;case"increaseNodeWidth":t.preventDefault(),this.options.onUpdateNodeWidth?.(this.selectedNodeId,20);break;case"decreaseNodeWidth":t.preventDefault(),this.options.onUpdateNodeWidth?.(this.selectedNodeId,-20);break;default:if(e.startsWith("selectColor")){const i=parseInt(e.replace("selectColor",""),10)-1;isNaN(i)||(t.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"color",index:i}))}break}}}handleBeginEdit(){if(!this.selectedNodeId)return;const e=this.container.querySelector(`.mindmap-node[data-id="${this.selectedNodeId}"]`);if(e){const t=e.querySelector('[title="Zoom Image"]');if(t){t.click();return}if(e.querySelector("img"))return;this.startEditing(e,this.selectedNodeId)}}}class W{container;overlay;paletteEl;inputEl;resultListEl;options;results=[];selectedIndex=-1;mode="menu";MENU_COMMANDS=[{id:"search-nodes",topic:"> Search Nodes",type:"command"},{id:"icon",topic:"> Icon",type:"command"}];ICON_LIST=[{id:"delete",topic:"🗑️ Delete",type:"icon"},{id:"blue_circle",topic:"Good",type:"icon"},{id:"red_circle",topic:"Bad",type:"icon"},{id:"question",topic:"Question",type:"icon"},{id:"important",topic:"Important",type:"icon"},{id:"check",topic:"Check",type:"icon"},{id:"cross",topic:"Cross",type:"icon"},{id:"flag",topic:"Flag",type:"icon"},{id:"idea",topic:"Idea",type:"icon"},{id:"warning",topic:"Warning",type:"icon"},{id:"schedule",topic:"Schedule",type:"icon"}];constructor(e,t){this.container=e,this.options=t,this.overlay=this.createOverlay(),this.paletteEl=this.createPalette(),this.inputEl=this.paletteEl.querySelector("input"),this.resultListEl=this.paletteEl.querySelector("ul"),this.container.appendChild(this.overlay),this.container.appendChild(this.paletteEl)}createOverlay(){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.backgroundColor="rgba(0, 0, 0, 0.1)",e.style.zIndex="1999",e.style.display="none",e.addEventListener("click",()=>{this.close()}),e}createPalette(){const e=document.createElement("div");e.className="command-palette",e.style.position="absolute",e.style.top="20px",e.style.left="50%",e.style.transform="translateX(-50%)",e.style.width="400px",e.style.backgroundColor="white",e.style.borderRadius="8px",e.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",e.style.border="1px solid #eee",e.style.zIndex="2000",e.style.display="none",e.style.flexDirection="column",e.style.overflow="hidden",e.style.padding="8px",e.style.boxSizing="border-box",e.style.fontFamily="Arial, sans-serif";const t=document.createElement("input");t.type="text",t.placeholder="Type > to search commands...",t.style.width="100%",t.style.boxSizing="border-box",t.style.padding="4px 8px",t.style.height="32px",t.style.border="1px solid #ccc",t.style.borderRadius="4px",t.style.fontSize="14px",t.style.outline="none",t.style.marginBottom="0",t.addEventListener("input",o=>{const s=o.target.value;if(this.mode==="menu"){const n=this.MENU_COMMANDS.filter(d=>d.topic.toLowerCase().includes(s.toLowerCase()));this.renderList(n)}else if(this.mode==="icon"){const n=this.ICON_LIST.filter(d=>d.topic.toLowerCase().includes(s.toLowerCase()));this.renderList(n)}else this.options.onInput(s)}),t.addEventListener("keydown",o=>{o.key==="ArrowDown"?(o.preventDefault(),this.moveSelection(1)):o.key==="ArrowUp"?(o.preventDefault(),this.moveSelection(-1)):o.key==="Enter"?(o.preventDefault(),this.confirmSelection()):o.key==="Escape"?(o.preventDefault(),this.close()):o.key==="Backspace"&&this.inputEl.value===""&&(this.mode==="search"||this.mode==="icon")&&(this.mode="menu",this.inputEl.placeholder="Type to filter commands...",this.renderList(this.MENU_COMMANDS))});const i=document.createElement("ul");return i.style.listStyle="none",i.style.margin="8px 0 0 0",i.style.padding="0",i.style.maxHeight="300px",i.style.overflowY="auto",i.style.display="none",i.style.borderTop="1px solid #eee",e.appendChild(t),e.appendChild(i),e}show(){this.mode="menu",this.overlay.style.display="block",this.paletteEl.style.display="flex",this.inputEl.value="",this.inputEl.placeholder="Type to filter commands...",this.inputEl.focus(),this.renderList(this.MENU_COMMANDS)}close(){this.overlay.style.display="none",this.paletteEl.style.display="none",this.options.onClose(),this.mode="menu"}toggle(){this.paletteEl.style.display==="none"?this.show():this.close()}setResults(e){this.mode==="search"&&this.renderList(e.map(t=>({...t,type:"node"})))}renderList(e){if(this.results=e,this.resultListEl.innerHTML="",this.selectedIndex=-1,e.length===0){if(this.inputEl.value.trim()!==""&&(this.mode==="search"||this.mode==="icon")){const t=document.createElement("li");t.textContent="No results found",t.style.padding="8px",t.style.color="#999",t.style.fontSize="12px",t.style.textAlign="center",this.resultListEl.appendChild(t),this.resultListEl.style.display="block"}else this.mode==="menu"&&e.length===0?this.resultListEl.style.display="none":this.resultListEl.style.display="none";return}this.resultListEl.style.display="block",e.forEach((t,i)=>{const o=document.createElement("li");if(o.style.borderBottom="1px solid #f9f9f9",t.type==="icon"&&t.id!=="delete"){o.style.display="flex",o.style.alignItems="center";const s=I[t.id];if(s){const d=document.createElement("div");d.style.width="20px",d.style.height="20px",d.style.marginRight="8px",d.style.flexShrink="0",d.innerHTML=`<svg viewBox="${s.viewBox}" width="20" height="20">${s.path}</svg>`,o.appendChild(d)}const n=document.createElement("span");n.textContent=t.topic,o.appendChild(n)}else o.textContent=t.topic;o.addEventListener("mouseenter",()=>{this.setSelectedIndex(i)}),o.addEventListener("click",()=>{this.selectItem(t)}),this.resultListEl.appendChild(o)}),e.length>0&&this.setSelectedIndex(0)}selectItem(e){e.type==="command"?e.id==="search-nodes"?this.switchToSearchMode():e.id==="icon"&&this.switchToIconMode():e.type==="icon"?(this.options.onIconSelect(e.id),this.close()):(this.options.onSelect(e.id),this.close())}switchToSearchMode(){this.mode="search",this.inputEl.value="",this.inputEl.placeholder="Search nodes...",this.renderList([]),this.resultListEl.style.display="none",this.inputEl.focus()}switchToIconMode(){this.mode="icon",this.inputEl.value="",this.inputEl.placeholder="Select icon...",this.renderList(this.ICON_LIST),this.inputEl.focus()}moveSelection(e){if(this.results.length===0)return;const t=Math.max(0,Math.min(this.results.length-1,this.selectedIndex+e));this.setSelectedIndex(t),this.scrollToSelected()}setSelectedIndex(e){this.selectedIndex=e;const t=this.resultListEl.children;for(let i=0;i<t.length;i++){const o=t[i];i===e?(o.style.backgroundColor="#007acc",o.style.color="white"):(o.style.backgroundColor="transparent",o.style.color="black")}}scrollToSelected(){const e=this.resultListEl.children;this.selectedIndex>=0&&this.selectedIndex<e.length&&e[this.selectedIndex].scrollIntoView({block:"nearest"})}confirmSelection(){this.selectedIndex>=0&&this.selectedIndex<this.results.length&&this.selectItem(this.results[this.selectedIndex])}}class A{mindMap;service;renderer;eventBus;styleEditor;commandPalette;interactionHandler;layoutSwitcher;selectedNodeId=null;layoutMode="Right";panX=0;panY=0;targetPanX=0;targetPanY=0;scale=1;isBatching=!1;animationFrameId=null;maxWidth=-1;pendingNodeCreation=!1;savedCustomStyles={rootNode:{border:"2px solid #aeb6bf",background:"#ebf5fb",color:"#2e4053"},childNode:{border:"1px solid #d5d8dc",background:"#fdfefe",color:"#2c3e50"},connection:{color:"#abb2b9"}};constructor(e,t,i,o,s){this.mindMap=e,this.service=t,this.renderer=i,this.styleEditor=o,this.eventBus=s,this.commandPalette=new W(this.renderer.container,{onInput:n=>this.handleSearchInput(n),onSelect:n=>this.handleSearchResultSelect(n),onIconSelect:n=>this.handleIconSelect(n),onClose:()=>{this.interactionHandler&&this.interactionHandler.container.focus()}})}setInteractionHandler(e){this.interactionHandler=e}setLayoutSwitcher(e){this.layoutSwitcher=e}init(e){this.panX=e*.2,this.targetPanX=this.panX,this.startAnimationLoop(),this.render()}destroy(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}getData(){const e=this.service.exportData();return e.selectedId=this.selectedNodeId||void 0,e}loadData(e){try{this.service.importData(e),e.selectedId?this.selectNode(e.selectedId):this.selectNode(null),this.render(),this.eventBus.emit("model:load",e),e.theme&&this.setTheme(e.theme),this.eventBus.emit("model:change",void 0)}catch(t){console.error("Failed to load data",t)}}batch(e){this.isBatching=!0;try{e()}finally{this.isBatching=!1,this.render()}}getSelectedNodeId(){return this.selectedNodeId}addNode(e,t,i,o={emitChange:!0}){const s=this.service.addNode(e,t,i);return s&&(this.render(),this.eventBus.emit("node:add",{id:s.id,topic:s.topic}),o.emitChange&&this.eventBus.emit("model:change",void 0)),s}addSibling(e,t="after",i="New topic",o={emitChange:!0}){const s=this.mindMap.findNode(e);if(!s||!s.parentId)return null;const n=this.mindMap.findNode(s.parentId);n&&n.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(n);const d=this.service.addSibling(e,t,i);if(d){if(n&&n.isRoot&&this.layoutMode==="Both"){const a=s.layoutSide||(n.children.indexOf(s)%2===0?"right":"left");d.layoutSide=a}this.render(),this.eventBus.emit("node:add",{id:d.id,topic:d.topic}),o.emitChange&&this.eventBus.emit("model:change",void 0)}return d}insertParent(e,t="New topic",i={emitChange:!0}){const o=this.service.insertParent(e,t);return o&&(this.render(),this.eventBus.emit("node:add",{id:o.id,topic:o.topic}),i.emitChange&&this.eventBus.emit("model:change",void 0)),o}deleteNode(e){this.service.removeNode(e)&&(this.render(),this.eventBus.emit("node:remove",e),this.eventBus.emit("model:change",void 0))}updateNode(e,t){let i=!1;this.interactionHandler&&this.interactionHandler.isReadOnly||(t.topic!==void 0&&this.service.updateNodeTopic(e,t.topic)&&(i=!0),t.style!==void 0&&this.service.updateNodeStyle(e,t.style)&&(i=!0),t.icon!==void 0&&this.service.updateNodeIcon(e,t.icon)&&(i=!0),i&&(this.render(),t.topic!==void 0&&this.eventBus.emit("node:update",{id:e,topic:t.topic}),this.eventBus.emit("model:change",void 0),this.pendingNodeCreation&&(this.pendingNodeCreation=!1)))}updateNodeWidth(e,t){if(this.interactionHandler&&this.interactionHandler.isReadOnly)return;const i=this.mindMap.findNode(e);if(!i)return;let o=i.customWidth;o===void 0&&(o=this.renderer.measureNode(i,this.mindMap).width);let s=o+t;s<50&&(s=50),this.service.updateNodeCustomWidth(e,s)&&(this.render(),this.eventBus.emit("model:change",void 0))}addChildNode(e){const t=this.mindMap.findNode(e);t&&t.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(t);let i;if(this.layoutMode==="Both"&&t&&t.isRoot){let s=0,n=0;t.children.forEach((d,a)=>{(d.layoutSide||(a%2===0?"right":"left"))==="left"?s++:n++}),i=s<n?"left":"right"}this.pendingNodeCreation=!0;const o=this.addNode(e,"New topic",i,{emitChange:!1});o&&(this.selectNode(o.id),this.ensureNodeVisible(o.id,!1,!0),this.interactionHandler.editNode(o.id))}addSiblingNode(e,t="after"){this.pendingNodeCreation=!0;const i=this.addSibling(e,t,"New topic",{emitChange:!1});i&&(this.selectNode(i.id),this.ensureNodeVisible(i.id,!1,!0),this.interactionHandler.editNode(i.id))}insertParentNode(e){this.pendingNodeCreation=!0;const t=this.insertParent(e,"New topic",{emitChange:!1});t&&(this.selectNode(t.id),this.ensureNodeVisible(t.id,!1,!0),this.interactionHandler.editNode(t.id))}removeNode(e){const i=this.mindMap.findNode(e)?.parentId||null,o=this.selectedNodeId===e;this.deleteNode(e),o&&i&&this.selectNode(i)}selectNode(e){if(this.selectedNodeId!==e){if(this.selectedNodeId=e,this.interactionHandler&&this.interactionHandler.updateSelection(e),e){const t=this.mindMap.findNode(e);t&&(!t.image&&this.interactionHandler&&!this.interactionHandler.isReadOnly?this.styleEditor.show(e,t.style):this.styleEditor.hide())}else this.styleEditor.hide();this.render(),this.eventBus.emit("node:select",e)}}moveNode(e,t,i){const o=this.mindMap.findNode(t);if(o){if(i==="top"){if(o.isRoot)return;this.service.reorderNode(e,t,"before")}else if(i==="bottom"){if(o.isRoot)return;this.service.reorderNode(e,t,"after")}else if(o.isRoot){const s=i==="left"?"left":"right";this.service.moveNode(e,t,s)}else((this.getNodeDirection(o)==="right"?i==="right":i==="left")?"addChild":"insertParent")==="addChild"?this.service.moveNode(e,t):this.service.insertNodeAsParent(e,t);this.render(),this.eventBus.emit("node:move",{nodeId:e,newParentId:t,position:i}),this.eventBus.emit("model:change",void 0)}}updateNodeTopic(e,t){this.updateNode(e,{topic:t}),setTimeout(()=>this.ensureNodeVisible(e),0)}render(){this.isBatching||(this.renderer.render(this.mindMap,this.selectedNodeId,this.layoutMode),this.renderer.updateTransform(this.panX,this.panY,this.scale))}setLayoutMode(e){this.layoutMode=e,this.layoutSwitcher&&this.layoutSwitcher.setMode(e);const t=this.renderer.container.clientWidth;e==="Right"?this.panX=t*.2:e==="Left"?this.panX=t*.8:this.panX=t*.5,this.panY=0,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}getLayoutMode(){return this.layoutMode}setMaxNodeWidth(e){this.maxWidth=e,this.renderer.maxWidth=e,this.interactionHandler&&(this.interactionHandler.maxWidth=e),this.render()}getMaxNodeWidth(){return this.maxWidth}updateGlobalStyles(e){e.rootNode&&(this.savedCustomStyles.rootNode={...this.savedCustomStyles.rootNode,...e.rootNode}),e.childNode&&(this.savedCustomStyles.childNode={...this.savedCustomStyles.childNode,...e.childNode}),e.connection&&(this.savedCustomStyles.connection={...this.savedCustomStyles.connection,...e.connection}),e.canvas&&(this.savedCustomStyles.canvas={...this.savedCustomStyles.canvas,...e.canvas}),this.mindMap.theme==="custom"&&this.applyCustomStylesToDOM(this.savedCustomStyles)}setTheme(e){if(this.service.setTheme(e),this.layoutSwitcher&&this.layoutSwitcher.setTheme(e),e==="custom")this.applyCustomStylesToDOM(this.savedCustomStyles);else{const t=this.renderer.container;["--mindmap-root-border","--mindmap-root-background","--mindmap-root-color","--mindmap-child-border","--mindmap-child-background","--mindmap-child-color","--mindmap-connection-color","--mindmap-canvas-background"].forEach(o=>t.style.removeProperty(o)),t.style.backgroundColor="var(--vscode-editor-background, transparent)"}this.render(),this.eventBus.emit("model:change",void 0)}resetZoom(){const e=this.renderer.container.clientWidth/2,t=this.renderer.container.clientHeight/2,i=1;this.panX=e-(e-this.panX)*(i/this.scale),this.panY=t-(t-this.panY)*(i/this.scale),this.scale=i,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}panBoard(e,t){this.targetPanX+=e,this.targetPanY+=t}zoomBoard(e,t,i){const d=this.renderer.container.getBoundingClientRect(),a=t-d.left,r=i-d.top,h=Math.min(Math.max(this.scale*(1-e*.001),.1),5),p=a-(a-this.panX)*(h/this.scale),l=r-(r-this.panY)*(h/this.scale);this.panX=p,this.panY=l,this.targetPanX=p,this.targetPanY=l,this.scale=h,this.renderer.updateTransform(this.panX,this.panY,this.scale)}setReadOnly(e){this.interactionHandler&&this.interactionHandler.setReadOnly(e),e&&this.styleEditor.hide()}undo(){this.service.undo()&&(this.render(),this.eventBus.emit("model:change",void 0))}redo(){this.service.redo()&&(this.render(),this.eventBus.emit("model:change",void 0))}toggleFold(e){this.service.toggleNodeFold(e)&&(this.render(),this.eventBus.emit("model:change",void 0))}navigateNode(e,t){const i=this.mindMap.findNode(e);if(!i)return;let o;switch(t){case"Left":o=this.navigateLeft(i);break;case"Right":o=this.navigateRight(i);break;case"Up":o=this.navigateUp(i);break;case"Down":o=this.navigateDown(i);break}o&&this.selectNode(o),this.selectedNodeId&&this.selectedNodeId!==e&&setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0),0)}copyNode(e){this.service.copyNode(e)}pasteNode(e){const t=this.service.pasteNode(e);t&&(this.render(),this.selectNode(t.id),this.eventBus.emit("node:add",{id:t.id,topic:t.topic}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(t.id,!0),0))}cutNode(e){const t=this.mindMap.findNode(e);if(t){const i=t.parentId;this.service.cutNode(e),i&&this.selectNode(i),this.render(),this.eventBus.emit("node:remove",e),this.eventBus.emit("model:change",void 0)}}pasteImage(e,t,i,o){const s=this.service.addImageNode(e,t,i,o);s&&(this.render(),this.selectNode(s.id),this.eventBus.emit("node:add",{id:s.id,topic:""}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(s.id,!0),0))}onEditEnd(){this.pendingNodeCreation&&(this.pendingNodeCreation=!1,this.eventBus.emit("model:change",void 0))}onStyleAction(e,t){if(this.interactionHandler&&this.interactionHandler.isReadOnly)return;const i=this.mindMap.findNode(e);if(!i)return;const o=i.style||{};let s=null;if(t.type==="bold")s={fontWeight:o.fontWeight==="bold"?"normal":"bold"};else if(t.type==="italic")s={fontStyle:o.fontStyle==="italic"?"normal":"italic"};else if(t.type==="color")t.index>=0&&t.index<w.PALETTE.length&&(s={color:w.PALETTE[t.index]});else if(t.type==="increaseSize"||t.type==="decreaseSize"){const n=w.FONT_SIZES,d=o.fontSize||"";let a=n.findIndex(h=>h.value===d);a===-1&&(a=0);const r=t.type==="increaseSize"?Math.min(n.length-1,a+1):Math.max(0,a-1);r!==a&&(s={fontSize:n[r].value})}s&&this.service.updateNodeStyle(e,s)&&(this.render(),this.eventBus.emit("model:change",void 0),this.selectedNodeId===e&&this.styleEditor.show(e,{...o,...s}))}toggleCommandPalette(){this.interactionHandler&&this.interactionHandler.isReadOnly||this.commandPalette.toggle()}searchNodes(e){return this.service.searchNodes(e)}handleSearchInput(e){const t=this.service.searchNodes(e);this.commandPalette.setResults(t.map(i=>({id:i.id,topic:i.topic})))}handleSearchResultSelect(e){this.selectNode(e),setTimeout(()=>this.ensureNodeVisible(e,!0,!0),0)}handleIconSelect(e){this.selectedNodeId&&(this.service.updateNodeIcon(this.selectedNodeId,e),this.render(),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0,!0),0))}applyCustomStylesToDOM(e){const t={};e.rootNode?.border&&(t["--mindmap-root-border"]=e.rootNode.border),e.rootNode?.background&&(t["--mindmap-root-background"]=e.rootNode.background),e.rootNode?.color&&(t["--mindmap-root-color"]=e.rootNode.color),e.childNode?.border&&(t["--mindmap-child-border"]=e.childNode.border),e.childNode?.background&&(t["--mindmap-child-background"]=e.childNode.background),e.childNode?.color&&(t["--mindmap-child-color"]=e.childNode.color),e.connection?.color&&(t["--mindmap-connection-color"]=e.connection.color),e.canvas?.background&&(t["--mindmap-canvas-background"]=e.canvas.background);const i=this.renderer.container;Object.entries(t).forEach(([o,s])=>i.style.setProperty(o,s)),e.canvas?.background&&(i.style.backgroundColor="var(--mindmap-canvas-background, transparent)")}ensureExplicitLayoutSides(e){!e.isRoot||this.layoutMode!=="Both"||e.children.forEach((t,i)=>{t.layoutSide||(t.layoutSide=i%2===0?"right":"left")})}getNodeDirection(e){if(e.isRoot||this.layoutMode==="Right")return"right";if(this.layoutMode==="Left")return"left";let t=e;for(;t.parentId;){const i=this.mindMap.findNode(t.parentId);if(!i)break;if(i.isRoot)return t.layoutSide?t.layoutSide:i.children.findIndex(s=>s.id===t.id)%2===0?"right":"left";t=i}return"right"}startAnimationLoop(){let e=performance.now();const t=()=>{const i=performance.now(),o=(i-e)/1e3;e=i;const s=1-Math.exp(-8*o),n=this.targetPanX-this.panX,d=this.targetPanY-this.panY;Math.abs(n)>.1||Math.abs(d)>.1?(this.panX+=n*s,this.panY+=d*s,this.renderer.updateTransform(this.panX,this.panY,this.scale)):(this.panX!==this.targetPanX||this.panY!==this.targetPanY)&&(this.panX=this.targetPanX,this.panY=this.targetPanY,this.renderer.updateTransform(this.panX,this.panY,this.scale)),Number.isNaN(this.panX)&&(this.panX=0),Number.isNaN(this.panY)&&(this.panY=0),this.animationFrameId=requestAnimationFrame(t)};t()}ensureNodeVisible(e,t=!1,i=!1){const o=this.renderer.container.querySelector(`.mindmap-node[data-id="${e}"]`);if(!o)return;const s=o.getBoundingClientRect(),n=this.renderer.container.getBoundingClientRect(),d=50;let a=0,r=0;const h=s.left<n.left+d,p=s.right>n.right-d,l=s.top<n.top+d,c=s.bottom>n.bottom-d;if(t&&(h||p||l||c)){const m=s.left+s.width/2,v=s.top+s.height/2,y=n.left+n.width/2,u=n.top+n.height/2;a=y-m,r=u-v}else h?a=n.left+d-s.left:p&&(a=n.right-d-s.right),l?r=n.top+d-s.top:c&&(r=n.bottom-d-s.bottom);(a!==0||r!==0)&&(i?(this.panX+=a,this.panY+=r,this.targetPanX=this.panX,this.targetPanY=this.panY,this.renderer.updateTransform(this.panX,this.panY,this.scale)):this.panBoard(a,r))}navigateLeft(e){if(e.isRoot){if(this.layoutMode==="Left")return e.children.length>0?e.children[0].id:void 0;if(this.layoutMode==="Both"){const t=e.children.find((i,o)=>(i.layoutSide||(o%2!==0?"left":"right"))==="left");return t?t.id:void 0}}else if(e.parentId)return this.getNodeDirection(e)==="right"?e.parentId:e.children.length>0?e.children[0].id:void 0}navigateRight(e){if(e.isRoot){if(this.layoutMode==="Right")return e.children.length>0?e.children[0].id:void 0;if(this.layoutMode==="Both"){const t=e.children.find((i,o)=>(i.layoutSide||(o%2===0?"right":"left"))==="right");return t?t.id:void 0}}else if(e.parentId)return this.getNodeDirection(e)==="right"?e.children.length>0?e.children[0].id:void 0:e.parentId}navigateUp(e){if(e.parentId){const t=this.mindMap.findNode(e.parentId);if(t){const i=this.getNodeDirection(e),o=t.children.filter(n=>this.getNodeDirection(n)===i),s=o.findIndex(n=>n.id===e.id);if(s>0)return o[s-1].id}}}navigateDown(e){if(e.parentId){const t=this.mindMap.findNode(e.parentId);if(t){const i=this.getNodeDirection(e),o=t.children.filter(n=>this.getNodeDirection(n)===i),s=o.findIndex(n=>n.id===e.id);if(s!==-1&&s<o.length-1)return o[s+1].id}}}showShortcutModal(){if(!this.interactionHandler||typeof document>"u")return;const e=document.createElement("div");e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100vw",e.style.height="100vh",e.style.backgroundColor="rgba(0,0,0,0.5)",e.style.zIndex="3000",e.style.display="flex",e.style.justifyContent="center",e.style.alignItems="center",e.style.opacity="0",e.style.transition="opacity 0.2s";const t=document.createElement("div");t.style.backgroundColor="white",t.style.padding="20px",t.style.borderRadius="8px",t.style.boxShadow="0 4px 6px rgba(0,0,0,0.1)",t.style.maxWidth="600px",t.style.width="90%",t.style.maxHeight="90vh",t.style.overflowY="auto",t.style.position="relative";const i=document.createElement("h2");i.textContent="Keyboard Shortcuts",i.style.margin="0 0 15px 0",i.style.fontSize="1.5em",i.style.borderBottom="1px solid #eee",i.style.paddingBottom="10px",t.appendChild(i);const o=document.createElement("button");o.textContent="×",o.style.position="absolute",o.style.top="10px",o.style.right="15px",o.style.background="none",o.style.border="none",o.style.fontSize="24px",o.style.cursor="pointer",o.style.color="#999",o.addEventListener("click",()=>{d()}),t.appendChild(o);const s=this.interactionHandler.getShortcuts();[{title:"General",actions:[{action:"openCommandPalette",desc:"Open Command Palette",descJa:"コマンドパレットを開く"},{action:"navUp",desc:"Move Selection Up",descJa:"ノード間の移動 (上)"},{action:"navDown",desc:"Move Selection Down",descJa:"ノード間の移動 (下)"},{action:"navLeft",desc:"Move Selection Left",descJa:"ノード間の移動 (左)"},{action:"navRight",desc:"Move Selection Right",descJa:"ノード間の移動 (右)"},{action:"beginEdit",desc:"Start Editing (Zoom if Image)",descJa:"ノードの編集を開始 (画像の場合はズーム)"},{action:"addSibling",desc:"Add Sibling (Below)",descJa:"兄弟ノードを追加 (下)"},{action:"addSiblingBefore",desc:"Add Sibling (Above)",descJa:"兄弟ノードを追加 (上)"},{action:"addChild",desc:"Add Child",descJa:"子ノードを追加"},{action:"insertParent",desc:"Insert Parent",descJa:"親ノードを挿入"},{action:"deleteNode",desc:"Delete Node",descJa:"ノードを削除"},{action:"undo",desc:"Undo",descJa:"元に戻す (Undo)"},{action:"redo",desc:"Redo",descJa:"やり直し (Redo)"},{action:"copy",desc:"Copy",descJa:"コピー"},{action:"cut",desc:"Cut",descJa:"切り取り"},{action:"paste",desc:"Paste",descJa:"貼り付け (画像も可)"},{action:"toggleFold",desc:"Toggle Fold",descJa:"ノードの展開/折り畳み"},{action:"zoomIn",desc:"Canvas Zoom In",descJa:"キャンバス拡大"},{action:"zoomOut",desc:"Canvas Zoom Out",descJa:"キャンバス縮小"},{action:"resetZoom",desc:"Reset Zoom",descJa:"ズームリセット"},{key:"Drag (Canvas)",desc:"Pan Board",descJa:"画面のパン (移動)"},{key:"Wheel",desc:"Vertical Scroll",descJa:"上下スクロール (パン)"},{key:"Shift + Wheel",desc:"Horizontal Scroll",descJa:"左右スクロール (パン)"},{key:"Ctrl/Cmd + Wheel",desc:"Zoom",descJa:"ズームイン/アウト"}]},{title:"Editing (Text Input)",actions:[{key:"Enter",desc:"Confirm Edit",descJa:"編集を確定"},{key:"Shift + Enter",desc:"New Line",descJa:"改行"},{key:"Esc",desc:"Cancel Edit",descJa:"編集をキャンセル"}]},{title:"Styling (Selection)",actions:[{action:"bold",desc:"Toggle Bold",descJa:"太字 (Bold) 切り替え"},{action:"italic",desc:"Toggle Italic",descJa:"斜体 (Italic) 切り替え"},{action:"selectColor1",desc:"Color 1",descJa:"ノードの色を変更 (1)"},{action:"selectColor2",desc:"Color 2",descJa:"ノードの色を変更 (2)"},{action:"selectColor3",desc:"Color 3",descJa:"ノードの色を変更 (3)"},{action:"selectColor4",desc:"Color 4",descJa:"ノードの色を変更 (4)"},{action:"selectColor5",desc:"Color 5",descJa:"ノードの色を変更 (5)"},{action:"selectColor6",desc:"Color 6",descJa:"ノードの色を変更 (6)"},{action:"selectColor7",desc:"Color 7",descJa:"ノードの色を変更 (7)"},{action:"increaseFontSize",desc:"Increase Font Size",descJa:"フォントサイズ拡大"},{action:"decreaseFontSize",desc:"Decrease Font Size",descJa:"フォントサイズ縮小"}]}].forEach(r=>{const h=[];if(r.actions.forEach(y=>{let u="";const f=y;if(f.key)u=f.key;else if(f.action&&s[f.action]){const N=s[f.action];if(N&&N.length>0){const x=N.map(g=>{const b=[];return(g.ctrlKey||g.metaKey)&&b.push("Ctrl/Cmd"),g.altKey&&b.push("Alt"),g.shiftKey&&b.push("Shift"),g.key===" "?b.push("Space"):b.push(g.key),b.join(" + ")});u=[...new Set(x)].join(" / ")}}u&&h.push({key:u,desc:f.descJa||f.desc})}),h.length===0)return;const p=document.createElement("h3");p.textContent=r.title,p.style.marginTop="20px",p.style.marginBottom="10px",p.style.fontSize="1.2em",p.style.color="#333",p.style.borderBottom="1px solid #f0f0f0",t.appendChild(p);const l=document.createElement("table");l.style.width="100%",l.style.borderCollapse="collapse",l.style.fontSize="0.9em";const c=document.createElement("tr");c.style.borderBottom="2px solid #ddd";const m=document.createElement("th");m.textContent="Key",m.style.textAlign="center",m.style.padding="8px 0",m.style.width="40%",m.style.color="#666";const v=document.createElement("th");v.textContent="Description",v.style.textAlign="center",v.style.padding="8px 0",v.style.color="#666",c.appendChild(m),c.appendChild(v),l.appendChild(c),h.forEach(y=>{const u=document.createElement("tr");u.style.borderBottom="1px solid #f9f9f9";const f=document.createElement("td");f.textContent=y.key,f.style.padding="6px 0",f.style.fontWeight="bold",f.style.color="#555",f.style.minWidth="180px",f.style.textAlign="center";const N=document.createElement("td");N.textContent=y.desc,N.style.padding="6px 0",N.style.textAlign="left",N.style.color="#333",u.appendChild(f),u.appendChild(N),l.appendChild(u)}),t.appendChild(l)}),e.appendChild(t),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.opacity="1"});const d=()=>{e.style.opacity="0",setTimeout(()=>{document.body.contains(e)&&document.body.removeChild(e)},200),document.removeEventListener("keydown",a)},a=r=>{r.key==="Escape"&&d()};document.addEventListener("keydown",a),e.addEventListener("click",r=>{r.target===e&&d()})}}class H{listeners={};on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e]?.push(t)}addListener(e,t){this.on(e,t)}off(e,t){const i=this.listeners[e];i&&(this.listeners[e]=i.filter(o=>o!==t))}removeListener(e,t){this.off(e,t)}emit(e,t){this.listeners[e]?.forEach(i=>i(t))}}class F{generate(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2)}}class O extends H{mindMap;controller;constructor(e,t={}){super();const i=new S("root","Root Topic",null,!0);this.mindMap=new k(i);const o=new F,s=new B(this.mindMap,o),n=document.createElement("div");n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",n.style.zIndex="2000",window.getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.style.overscrollBehavior="none",e.style.touchAction="none",e.appendChild(n);const a=new w(n),r=new E(e,{onImageZoom:l=>this.controller.setReadOnly(l),onToggleFold:l=>this.controller.toggleFold(l)});this.controller=new A(this.mindMap,s,r,a,{emit:(l,c)=>this.emit(l,c)}),a.onUpdate=(l,c)=>{this.controller.updateNode(l,{style:c})};const h=new P(e,{onNodeClick:l=>this.controller.selectNode(l||null),onAddChild:l=>this.controller.addChildNode(l),onInsertParent:l=>this.controller.insertParentNode(l),onAddSibling:(l,c)=>this.controller.addSiblingNode(l,c),onDeleteNode:l=>this.controller.removeNode(l),onDropNode:(l,c,m)=>this.controller.moveNode(l,c,m),onUpdateNode:(l,c)=>this.controller.updateNodeTopic(l,c),onNavigate:(l,c)=>this.controller.navigateNode(l,c),onPan:(l,c)=>this.controller.panBoard(l,c),onCopyNode:l=>this.controller.copyNode(l),onPasteNode:l=>this.controller.pasteNode(l),onCutNode:l=>this.controller.cutNode(l),onPasteImage:(l,c,m,v)=>this.controller.pasteImage(l,c,m,v),onZoom:(l,c,m)=>this.controller.zoomBoard(l,c,m),onZoomReset:()=>this.controller.resetZoom(),onUndo:()=>this.controller.undo(),onRedo:()=>this.controller.redo(),onStyleAction:(l,c)=>this.controller.onStyleAction(l,c),onEditEnd:l=>this.controller.onEditEnd(),onToggleFold:l=>this.controller.toggleFold(l),onToggleCommandPalette:()=>this.controller.toggleCommandPalette(),onUpdateNodeWidth:(l,c)=>this.controller.updateNodeWidth(l,c),shortcuts:t.shortcuts});this.controller.setInteractionHandler(h);const p=new L(n,{onLayoutChange:l=>this.controller.setLayoutMode(l),onThemeChange:l=>this.controller.setTheme(l),onZoomReset:()=>this.controller.resetZoom(),onShowShortcuts:()=>this.controller.showShortcutModal()});this.controller.setLayoutSwitcher(p),t.maxNodeWidth!==void 0&&this.controller.setMaxNodeWidth(t.maxNodeWidth),t.customStyles&&this.controller.updateGlobalStyles(t.customStyles),this.controller.init(e.clientWidth)}addNode(e,t,i,o={emitChange:!0}){return this.controller.addNode(e,t,i,o)}addSibling(e,t="after",i="New topic",o={emitChange:!0}){return this.controller.addSibling(e,t,i,o)}insertParent(e,t="New topic",i={emitChange:!0}){return this.controller.insertParent(e,t,i)}deleteNode(e){this.controller.deleteNode(e)}updateNode(e,t){this.controller.updateNode(e,t)}undo(){this.controller.undo()}redo(){this.controller.redo()}toggleFold(e){this.controller.toggleFold(e)}toggleCommandPalette(){this.controller.toggleCommandPalette()}openCommandPalette(){this.controller.toggleCommandPalette()}searchNodes(e){return this.controller.searchNodes(e)}getSelectedNodeId(){return this.controller.selectedNodeId}updateNodeStyle(e,t){this.controller.updateNode(e,{style:t})}setTheme(e){this.controller.setTheme(e)}getMindMap(){return this.mindMap}getNode(e){return this.mindMap.findNode(e)||void 0}getRoot(){return this.mindMap.root}findNodes(e){const t=[],i=o=>{e(o)&&t.push(o),o.children.forEach(i)};return i(this.mindMap.root),t}setMaxNodeWidth(e){this.controller.setMaxNodeWidth(e)}getMaxNodeWidth(){return this.controller.getMaxNodeWidth()}updateGlobalStyles(e){this.controller.updateGlobalStyles(e)}setReadOnly(e){this.controller.setReadOnly(e)}destroy(){this.controller.destroy(),this.controller.interactionHandler?.destroy()}batch(e){this.controller.isBatching=!0;try{e()}finally{this.controller.isBatching=!1,this.controller.render()}}addChildNode(e){this.controller.addChildNode(e)}addSiblingNode(e,t="after"){this.controller.addSiblingNode(e,t)}insertParentNode(e){this.controller.insertParentNode(e)}removeNode(e){this.controller.removeNode(e)}moveNode(e,t,i){this.controller.moveNode(e,t,i)}updateNodeTopic(e,t){this.controller.updateNodeTopic(e,t)}selectNode(e){this.controller.selectNode(e)}panBoard(e,t){this.controller.panBoard(e,t)}zoomBoard(e,t,i){this.controller.zoomBoard(e,t,i)}resetZoom(){this.controller.resetZoom()}copyNode(e){this.controller.copyNode(e)}pasteNode(e){this.controller.pasteNode(e)}pasteImage(e,t,i,o){this.controller.pasteImage(e,t,i,o)}cutNode(e){this.controller.cutNode(e)}updateLayout(e){e==="Standard"?this.controller.setLayoutMode("Both"):this.controller.setLayoutMode(e)}setLayoutMode(e){this.controller.setLayoutMode(e)}getLayoutMode(){return this.controller.getLayoutMode()}navigateNode(e,t){this.controller.navigateNode(e,t)}getData(){return this.controller.getData()}loadData(e){this.controller.loadData(e)}getRootId(){return this.mindMap.root.id}}exports.Kakidash=O;
54
+ `,document.head.appendChild(t)}handleDragStart(t){const e=t;if(this.isReadOnly){e.preventDefault();return}const r=e.target.closest(".mindmap-node");r&&r.dataset.id&&(this.draggedNodeId=r.dataset.id,e.dataTransfer?.setData("text/plain",r.dataset.id),e.dataTransfer&&(e.dataTransfer.effectAllowed="move"))}handleDragOver(t){const e=t;if(this.isReadOnly)return;e.preventDefault();const r=e.target.closest(".mindmap-node");if(r&&r.dataset.id&&this.draggedNodeId&&r.dataset.id!==this.draggedNodeId){const n=this.getDropPosition(e,r);r.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right"),r.classList.add(`drag-over-${n}`),e.dataTransfer&&(e.dataTransfer.dropEffect="move")}}handleDragLeave(t){const i=t.target.closest(".mindmap-node");i&&i.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}handleDrop(t){const e=t;e.preventDefault();const r=e.target.closest(".mindmap-node");if(this.container.querySelectorAll(".mindmap-node").forEach(n=>{n.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}),!this.isReadOnly){if(r&&r.dataset.id&&this.draggedNodeId){const n=r.dataset.id;if(this.draggedNodeId!==n){const o=this.getDropPosition(e,r);this.options.onDropNode(this.draggedNodeId,n,o)}}this.draggedNodeId=null}}handleDragEnd(){this.draggedNodeId=null,this.container.querySelectorAll(".mindmap-node").forEach(t=>{t.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")})}getDropPosition(t,e){const i=e.getBoundingClientRect(),r=t.clientX-i.left,n=t.clientY-i.top,o=i.width,s=i.height;return n<s*.25?"top":n>s*.75?"bottom":r<o*.25?"left":(r>o*.75,"right")}}class Vt{shortcuts;constructor(t){this.shortcuts=t}matches(t,e){const i=this.shortcuts[e];return i?i.some(r=>{const n=r.ctrlKey??!1,o=r.metaKey??!1,s=r.altKey??!1,c=r.shiftKey??!1;return t.ctrlKey!==n||t.metaKey!==o||t.altKey!==s||t.shiftKey!==c?!1:r.key.toLowerCase()===t.key.toLowerCase()}):!1}getAction(t){const e=Object.keys(this.shortcuts);for(const i of e)if(this.matches(t,i))return i}}class qt{container;options;maxWidth=-1;selectedNodeId=null;isPanning=!1;lastMouseX=0;lastMouseY=0;isReadOnly=!1;shortcuts;nodeEditor;nodeDragger;shortcutManager;cleanupFns=[];constructor(t,e){this.container=t,this.container.tabIndex=0,this.container.style.outline="none",this.container.style.cursor="default",this.options=e,this.shortcuts={...Gt,...e.shortcuts},this.nodeEditor=new $t(t,this.maxWidth,e),this.nodeDragger=new Jt(t,e),this.shortcutManager=new Vt(this.shortcuts),this.isReadOnly=!!e.allowReadOnly,this.nodeDragger.setReadOnly(this.isReadOnly),this.attachEvents()}getShortcuts(){return this.shortcuts}setReadOnly(t){this.isReadOnly=t,this.nodeDragger&&this.nodeDragger.setReadOnly(t),t&&this.nodeDragger&&this.nodeDragger.draggedNodeId&&(this.nodeDragger.draggedNodeId=null)}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}updateSelection(t){this.selectedNodeId=t}attachEvents(){const t=(r,n,o,s)=>{r.addEventListener(n,o,s),this.cleanupFns.push(()=>{typeof r.removeEventListener=="function"&&r.removeEventListener(n,o,s)})};t(this.container,"focus",()=>{}),t(this.container,"blur",()=>{}),t(this.container,"scroll",()=>{(this.container.scrollTop!==0||this.container.scrollLeft!==0)&&(this.container.scrollTop=0,this.container.scrollLeft=0)}),t(this.container,"click",r=>{const o=r.target.closest(".mindmap-node");o&&o.dataset.id?this.options.onNodeClick(o.dataset.id):this.options.onNodeClick(""),this.container.focus()}),t(this.container,"mousedown",r=>{const n=r,o=n.target;!o.closest(".mindmap-node")&&o.tagName!=="INPUT"&&(this.isPanning=!0,this.lastMouseX=n.clientX,this.lastMouseY=n.clientY,this.container.style.cursor="all-scroll")}),t(window,"mousemove",r=>{const n=r;if(this.isPanning){const o=n.clientX-this.lastMouseX,s=n.clientY-this.lastMouseY;this.lastMouseX=n.clientX,this.lastMouseY=n.clientY,this.options.onPan&&this.options.onPan(o,s)}});const e=()=>{this.isPanning&&(this.isPanning=!1,this.container.style.cursor="default")};t(window,"mouseup",e),t(window,"mouseleave",e),t(this.container,"wheel",r=>{const n=r;if(n.preventDefault(),n.ctrlKey||n.metaKey){this.options.onZoom&&this.options.onZoom(n.deltaY,n.clientX,n.clientY);return}let o=1;n.deltaMode===1?o=33:n.deltaMode===2&&(o=window.innerHeight);const s=-n.deltaX*o,c=-n.deltaY*o;this.options.onPan&&this.options.onPan(s,c)},{passive:!1}),t(document,"keydown",r=>{const n=r,o=n.target;if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;if(this.shortcutManager.matches(n,"resetZoom")){n.preventDefault(),this.options.onZoomReset?.();return}if(this.shortcutManager.getAction(n)==="openCommandPalette"){n.preventDefault(),this.options.onToggleCommandPalette?.();return}if(!this.selectedNodeId){if(this.shortcutManager.matches(n,"navUp")||this.shortcutManager.matches(n,"navDown")||this.shortcutManager.matches(n,"navLeft")||this.shortcutManager.matches(n,"navRight")){n.preventDefault();let g=null,f=1/0;this.container.querySelectorAll(".mindmap-node").forEach(p=>{const d=p;if(!d.dataset.id)return;const w=d.getBoundingClientRect(),h=w.left+w.width/2,m=w.top+w.height/2,u=this.container.getBoundingClientRect(),v=u.left+u.width/2,k=u.top+u.height/2,C=Math.pow(h-v,2)+Math.pow(m-k,2);C<f&&(f=C,g=d.dataset.id)}),g&&this.options.onNodeClick(g)}return}const c=this.shortcutManager.getAction(n);c&&this.handleAction(c,n)}),t(document,"paste",r=>{const n=r;if(this.isReadOnly||!this.selectedNodeId)return;const o=n.clipboardData?.items;if(!o||o.length===0){this.options.onPasteNode?.(this.selectedNodeId);return}let s=!1;for(const c of o)if(c.type.startsWith("image/")){const g=c.getAsFile();if(g){const f=new FileReader;f.onload=y=>{if(y.target?.result&&this.options.onPasteImage&&this.selectedNodeId){const p=y.target.result,d=new Image;d.onload=()=>{this.selectedNodeId&&this.options.onPasteImage&&this.options.onPasteImage(this.selectedNodeId,p,d.naturalWidth,d.naturalHeight)},d.src=p}},f.readAsDataURL(g)}n.preventDefault(),s=!0;break}s||this.options.onPasteNode?.(this.selectedNodeId)});const i=(r,n,o)=>t(r,n,o);i(this.container,"dragstart",this.nodeDragger.handleDragStart.bind(this.nodeDragger)),i(this.container,"dragover",this.nodeDragger.handleDragOver.bind(this.nodeDragger)),i(this.container,"dragleave",this.nodeDragger.handleDragLeave.bind(this.nodeDragger)),i(this.container,"drop",this.nodeDragger.handleDrop.bind(this.nodeDragger)),i(this.container,"dragend",this.nodeDragger.handleDragEnd.bind(this.nodeDragger)),t(this.container,"dblclick",r=>{if(this.isReadOnly)return;const o=r.target.closest(".mindmap-node");o&&o.dataset.id&&this.startEditing(o,o.dataset.id)})}editNode(t){const e=this.container.querySelector(`.mindmap-node[data-id="${t}"]`);e&&this.startEditing(e,t)}get draggedNodeId(){return this.nodeDragger?this.nodeDragger.draggedNodeId:null}set draggedNodeId(t){this.nodeDragger&&(this.nodeDragger.draggedNodeId=t)}startEditing(t,e){this.nodeEditor.setMaxWidth(this.maxWidth),this.nodeEditor.startEditing(t,e)}handleAction(t,e){if(this.selectedNodeId){switch(t){case"copy":e.preventDefault(),this.options.onCopyNode?.(this.selectedNodeId);return;case"navUp":e.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Up");return;case"navDown":e.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Down");return;case"navRight":e.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Right");return;case"navLeft":e.preventDefault(),this.options.onNavigate?.(this.selectedNodeId,"Left");return}if(!this.isReadOnly)switch(t){case"addChild":e.preventDefault(),this.options.onAddChild(this.selectedNodeId);break;case"insertParent":e.preventDefault(),this.options.onInsertParent?.(this.selectedNodeId);break;case"addSibling":e.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"after");break;case"addSiblingBefore":e.preventDefault(),this.options.onAddSibling(this.selectedNodeId,"before");break;case"deleteNode":e.preventDefault(),this.options.onDeleteNode(this.selectedNodeId);break;case"beginEdit":e.preventDefault(),this.handleBeginEdit();break;case"zoomIn":if(e.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(-100,i.left+i.width/2,i.top+i.height/2)}break;case"zoomOut":if(e.preventDefault(),this.options.onZoom){const i=this.container.getBoundingClientRect();this.options.onZoom(100,i.left+i.width/2,i.top+i.height/2)}break;case"cut":e.preventDefault(),this.options.onCutNode?.(this.selectedNodeId);break;case"undo":e.preventDefault(),this.options.onUndo?.();break;case"redo":e.preventDefault(),this.options.onRedo?.();break;case"bold":e.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"bold"});break;case"italic":e.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"italic"});break;case"increaseFontSize":e.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"increaseSize"});break;case"decreaseFontSize":e.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"decreaseSize"});break;case"toggleFold":e.preventDefault(),this.options.onToggleFold?.(this.selectedNodeId);break;case"openCommandPalette":e.preventDefault(),this.options.onToggleCommandPalette?.();break;case"increaseNodeWidth":e.preventDefault(),this.options.onUpdateNodeWidth?.(this.selectedNodeId,20);break;case"decreaseNodeWidth":e.preventDefault(),this.options.onUpdateNodeWidth?.(this.selectedNodeId,-20);break;default:if(t.startsWith("selectColor")){const i=parseInt(t.replace("selectColor",""),10)-1;isNaN(i)||(e.preventDefault(),this.options.onStyleAction?.(this.selectedNodeId,{type:"color",index:i}))}break}}}handleBeginEdit(){if(!this.selectedNodeId)return;const t=this.container.querySelector(`.mindmap-node[data-id="${this.selectedNodeId}"]`);if(t){const e=t.querySelector('[title="Zoom Image"]');if(e){e.click();return}if(t.querySelector("img"))return;this.startEditing(t,this.selectedNodeId)}}}class Qt{container;overlay;paletteEl;inputEl;resultListEl;options;results=[];selectedIndex=-1;mode="menu";MENU_COMMANDS=[{id:"icon",topic:"> Icon",type:"command"},{id:"search-nodes",topic:"> Search Nodes",type:"command"},{id:"import",topic:"> Import",type:"command"},{id:"export",topic:"> Export",type:"command"}];IMPORT_COMMANDS=[{id:"import-xmind",topic:"> XMind (.xmind)",type:"command"}];EXPORT_COMMANDS=[{id:"export-png",topic:"> PNG Image (.png)",type:"command"},{id:"export-svg",topic:"> SVG Image (.svg)",type:"command"},{id:"export-markdown",topic:"> Markdown (.md)",type:"command"}];ICON_LIST=[{id:"delete",topic:"🗑️ Delete",type:"icon"},{id:"blue_circle",topic:"Good",type:"icon"},{id:"red_circle",topic:"Bad",type:"icon"},{id:"question",topic:"Question",type:"icon"},{id:"important",topic:"Important",type:"icon"},{id:"check",topic:"Check",type:"icon"},{id:"cross",topic:"Cross",type:"icon"},{id:"flag",topic:"Flag",type:"icon"},{id:"idea",topic:"Idea",type:"icon"},{id:"warning",topic:"Warning",type:"icon"},{id:"schedule",topic:"Schedule",type:"icon"}];constructor(t,e){this.container=t,this.options=e,this.overlay=this.createOverlay(),this.paletteEl=this.createPalette(),this.inputEl=this.paletteEl.querySelector("input"),this.resultListEl=this.paletteEl.querySelector("ul"),this.container.appendChild(this.overlay),this.container.appendChild(this.paletteEl)}createOverlay(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(0, 0, 0, 0.1)",t.style.zIndex="1999",t.style.display="none",t.addEventListener("click",()=>{this.close()}),t}createPalette(){const t=document.createElement("div");t.className="command-palette",t.style.position="absolute",t.style.top="20px",t.style.left="50%",t.style.transform="translateX(-50%)",t.style.width="400px",t.style.backgroundColor="white",t.style.borderRadius="8px",t.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)",t.style.border="1px solid #eee",t.style.zIndex="2000",t.style.display="none",t.style.flexDirection="column",t.style.overflow="hidden",t.style.padding="8px",t.style.boxSizing="border-box",t.style.fontFamily="Arial, sans-serif";const e=document.createElement("input");e.type="text",e.placeholder="Type > to search commands...",e.style.width="100%",e.style.boxSizing="border-box",e.style.padding="4px 8px",e.style.height="32px",e.style.border="1px solid #ccc",e.style.borderRadius="4px",e.style.fontSize="14px",e.style.outline="none",e.style.marginBottom="0",e.addEventListener("input",r=>{const n=r.target.value;if(this.mode==="menu"){const o=this.MENU_COMMANDS.filter(s=>s.topic.toLowerCase().includes(n.toLowerCase()));this.renderList(o)}else if(this.mode==="import"){const o=this.IMPORT_COMMANDS.filter(s=>s.topic.toLowerCase().includes(n.toLowerCase()));this.renderList(o)}else if(this.mode==="export"){const o=this.EXPORT_COMMANDS.filter(s=>s.topic.toLowerCase().includes(n.toLowerCase()));this.renderList(o)}else if(this.mode==="icon"){const o=this.ICON_LIST.filter(s=>s.topic.toLowerCase().includes(n.toLowerCase()));this.renderList(o)}else this.options.onInput(n)}),e.addEventListener("keydown",r=>{r.key==="ArrowDown"?(r.preventDefault(),this.moveSelection(1)):r.key==="ArrowUp"?(r.preventDefault(),this.moveSelection(-1)):r.key==="Enter"?(r.preventDefault(),this.confirmSelection()):r.key==="Escape"?(r.preventDefault(),this.close()):r.key==="Backspace"&&this.inputEl.value===""&&(this.mode==="search"||this.mode==="icon"||this.mode==="import"||this.mode==="export")&&(this.mode="menu",this.inputEl.placeholder="Type to filter commands...",this.renderList(this.MENU_COMMANDS))});const i=document.createElement("ul");return i.style.listStyle="none",i.style.margin="8px 0 0 0",i.style.padding="0",i.style.maxHeight="300px",i.style.overflowY="auto",i.style.display="none",i.style.borderTop="1px solid #eee",t.appendChild(e),t.appendChild(i),t}show(){this.mode="menu",this.overlay.style.display="block",this.paletteEl.style.display="flex",this.inputEl.value="",this.inputEl.placeholder="Type to filter commands...",this.inputEl.focus(),this.renderList(this.MENU_COMMANDS)}close(){this.overlay.style.display="none",this.paletteEl.style.display="none",this.options.onClose(),this.mode="menu"}toggle(){this.paletteEl.style.display==="none"?this.show():this.close()}setResults(t){this.mode==="search"&&this.renderList(t.map(e=>({...e,type:"node"})))}renderList(t){if(this.results=t,this.resultListEl.innerHTML="",this.selectedIndex=-1,t.length===0){if(this.inputEl.value.trim()!==""&&(this.mode==="search"||this.mode==="icon"||this.mode==="import"||this.mode==="export")){const e=document.createElement("li");e.textContent="No results found",e.style.padding="8px",e.style.color="#999",e.style.fontSize="12px",e.style.textAlign="center",this.resultListEl.appendChild(e),this.resultListEl.style.display="block"}else this.mode==="menu"&&t.length===0?this.resultListEl.style.display="none":this.resultListEl.style.display="none";return}this.resultListEl.style.display="block",t.forEach((e,i)=>{const r=document.createElement("li");if(r.style.borderBottom="1px solid #f9f9f9",e.type==="icon"&&e.id!=="delete"){r.style.display="flex",r.style.alignItems="center";const n=It[e.id];if(n){const s=document.createElement("div");s.style.width="20px",s.style.height="20px",s.style.marginRight="8px",s.style.flexShrink="0",s.innerHTML=`<svg viewBox="${n.viewBox}" width="20" height="20">${n.path}</svg>`,r.appendChild(s)}const o=document.createElement("span");o.textContent=e.topic,r.appendChild(o)}else r.textContent=e.topic;r.addEventListener("mouseenter",()=>{this.setSelectedIndex(i)}),r.addEventListener("click",()=>{this.selectItem(e)}),this.resultListEl.appendChild(r)}),t.length>0&&this.setSelectedIndex(0)}selectItem(t){t.type==="command"?t.id==="search-nodes"?this.switchToSearchMode():t.id==="icon"?this.switchToIconMode():t.id==="import"?this.switchToImportMode():t.id==="export"?this.switchToExportMode():t.id==="import-xmind"?(this.options.onCommandSelect("import-xmind"),this.close()):t.id==="export-png"?(this.options.onCommandSelect("export-png"),this.close()):t.id==="export-svg"?(this.options.onCommandSelect("export-svg"),this.close()):t.id==="export-markdown"&&(this.options.onCommandSelect("export-markdown"),this.close()):t.type==="icon"?(this.options.onIconSelect(t.id),this.close()):(this.options.onSelect(t.id),this.close())}switchToSearchMode(){this.mode="search",this.inputEl.value="",this.inputEl.placeholder="Search nodes...",this.renderList([]),this.resultListEl.style.display="none",this.inputEl.focus()}switchToIconMode(){this.mode="icon",this.inputEl.value="",this.inputEl.placeholder="Select icon...",this.renderList(this.ICON_LIST),this.inputEl.focus()}switchToImportMode(){this.mode="import",this.inputEl.value="",this.inputEl.placeholder="Select format...",this.renderList(this.IMPORT_COMMANDS),this.inputEl.focus()}switchToExportMode(){this.mode="export",this.inputEl.value="",this.inputEl.placeholder="Select format...",this.renderList(this.EXPORT_COMMANDS),this.inputEl.focus()}moveSelection(t){if(this.results.length===0)return;const e=Math.max(0,Math.min(this.results.length-1,this.selectedIndex+t));this.setSelectedIndex(e),this.scrollToSelected()}setSelectedIndex(t){this.selectedIndex=t;const e=this.resultListEl.children;for(let i=0;i<e.length;i++){const r=e[i];i===t?(r.style.backgroundColor="#007acc",r.style.color="white"):(r.style.backgroundColor="transparent",r.style.color="black")}}scrollToSelected(){const t=this.resultListEl.children;this.selectedIndex>=0&&this.selectedIndex<t.length&&t[this.selectedIndex].scrollIntoView({block:"nearest"})}confirmSelection(){this.selectedIndex>=0&&this.selectedIndex<this.results.length&&this.selectItem(this.results[this.selectedIndex])}}var kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function te(it){return it&&it.__esModule&&Object.prototype.hasOwnProperty.call(it,"default")?it.default:it}function St(it){throw new Error('Could not dynamically require "'+it+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Et={exports:{}};var Mt;function ee(){return Mt||(Mt=1,(function(it,t){(function(e){it.exports=e()})(function(){return(function e(i,r,n){function o(g,f){if(!r[g]){if(!i[g]){var y=typeof St=="function"&&St;if(!f&&y)return y(g,!0);if(s)return s(g,!0);var p=new Error("Cannot find module '"+g+"'");throw p.code="MODULE_NOT_FOUND",p}var d=r[g]={exports:{}};i[g][0].call(d.exports,function(w){var h=i[g][1][w];return o(h||w)},d,d.exports,e,i,r,n)}return r[g].exports}for(var s=typeof St=="function"&&St,c=0;c<n.length;c++)o(n[c]);return o})({1:[function(e,i,r){var n=e("./utils"),o=e("./support"),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var g,f,y,p,d,w,h,m=[],u=0,v=c.length,k=v,C=n.getTypeOf(c)!=="string";u<c.length;)k=v-u,y=C?(g=c[u++],f=u<v?c[u++]:0,u<v?c[u++]:0):(g=c.charCodeAt(u++),f=u<v?c.charCodeAt(u++):0,u<v?c.charCodeAt(u++):0),p=g>>2,d=(3&g)<<4|f>>4,w=1<k?(15&f)<<2|y>>6:64,h=2<k?63&y:64,m.push(s.charAt(p)+s.charAt(d)+s.charAt(w)+s.charAt(h));return m.join("")},r.decode=function(c){var g,f,y,p,d,w,h=0,m=0,u="data:";if(c.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var v,k=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===s.charAt(64)&&k--,c.charAt(c.length-2)===s.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=o.uint8array?new Uint8Array(0|k):new Array(0|k);h<c.length;)g=s.indexOf(c.charAt(h++))<<2|(p=s.indexOf(c.charAt(h++)))>>4,f=(15&p)<<4|(d=s.indexOf(c.charAt(h++)))>>2,y=(3&d)<<6|(w=s.indexOf(c.charAt(h++))),v[m++]=g,d!==64&&(v[m++]=f),w!==64&&(v[m++]=y);return v}},{"./support":30,"./utils":32}],2:[function(e,i,r){var n=e("./external"),o=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),c=e("./stream/DataLengthProbe");function g(f,y,p,d,w){this.compressedSize=f,this.uncompressedSize=y,this.crc32=p,this.compression=d,this.compressedContent=w}g.prototype={getContentWorker:function(){var f=new o(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),y=this;return f.on("end",function(){if(this.streamInfo.data_length!==y.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),f},getCompressedWorker:function(){return new o(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},g.createWorkerFrom=function(f,y,p){return f.pipe(new s).pipe(new c("uncompressedSize")).pipe(y.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",y)},i.exports=g},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,i,r){var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,i,r){var n=e("./utils"),o=(function(){for(var s,c=[],g=0;g<256;g++){s=g;for(var f=0;f<8;f++)s=1&s?3988292384^s>>>1:s>>>1;c[g]=s}return c})();i.exports=function(s,c){return s!==void 0&&s.length?n.getTypeOf(s)!=="string"?(function(g,f,y,p){var d=o,w=p+y;g^=-1;for(var h=p;h<w;h++)g=g>>>8^d[255&(g^f[h])];return-1^g})(0|c,s,s.length,0):(function(g,f,y,p){var d=o,w=p+y;g^=-1;for(var h=p;h<w;h++)g=g>>>8^d[255&(g^f.charCodeAt(h))];return-1^g})(0|c,s,s.length,0):0}},{"./utils":32}],5:[function(e,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,i,r){var n=null;n=typeof Promise<"u"?Promise:e("lie"),i.exports={Promise:n}},{lie:37}],7:[function(e,i,r){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=e("pako"),s=e("./utils"),c=e("./stream/GenericWorker"),g=n?"uint8array":"array";function f(y,p){c.call(this,"FlateWorker/"+y),this._pako=null,this._pakoAction=y,this._pakoOptions=p,this.meta={}}r.magic="\b\0",s.inherits(f,c),f.prototype.processChunk=function(y){this.meta=y.meta,this._pako===null&&this._createPako(),this._pako.push(s.transformTo(g,y.data),!1)},f.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},f.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},f.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var y=this;this._pako.onData=function(p){y.push({data:p,meta:y.meta})}},r.compressWorker=function(y){return new f("Deflate",y)},r.uncompressWorker=function(){return new f("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,i,r){function n(d,w){var h,m="";for(h=0;h<w;h++)m+=String.fromCharCode(255&d),d>>>=8;return m}function o(d,w,h,m,u,v){var k,C,S=d.file,M=d.compression,A=v!==g.utf8encode,F=s.transformTo("string",v(S.name)),T=s.transformTo("string",g.utf8encode(S.name)),H=S.comment,K=s.transformTo("string",v(H)),x=s.transformTo("string",g.utf8encode(H)),D=T.length!==S.name.length,l=x.length!==H.length,R="",V="",W="",Q=S.dir,U=S.date,q={crc32:0,compressedSize:0,uncompressedSize:0};w&&!h||(q.crc32=d.crc32,q.compressedSize=d.compressedSize,q.uncompressedSize=d.uncompressedSize);var z=0;w&&(z|=8),A||!D&&!l||(z|=2048);var I=0,J=0;Q&&(I|=16),u==="UNIX"?(J=798,I|=(function(X,ot){var dt=X;return X||(dt=ot?16893:33204),(65535&dt)<<16})(S.unixPermissions,Q)):(J=20,I|=(function(X){return 63&(X||0)})(S.dosPermissions)),k=U.getUTCHours(),k<<=6,k|=U.getUTCMinutes(),k<<=5,k|=U.getUTCSeconds()/2,C=U.getUTCFullYear()-1980,C<<=4,C|=U.getUTCMonth()+1,C<<=5,C|=U.getUTCDate(),D&&(V=n(1,1)+n(f(F),4)+T,R+="up"+n(V.length,2)+V),l&&(W=n(1,1)+n(f(K),4)+x,R+="uc"+n(W.length,2)+W);var Y="";return Y+=`
55
+ \0`,Y+=n(z,2),Y+=M.magic,Y+=n(k,2),Y+=n(C,2),Y+=n(q.crc32,4),Y+=n(q.compressedSize,4),Y+=n(q.uncompressedSize,4),Y+=n(F.length,2),Y+=n(R.length,2),{fileRecord:y.LOCAL_FILE_HEADER+Y+F+R,dirRecord:y.CENTRAL_FILE_HEADER+n(J,2)+Y+n(K.length,2)+"\0\0\0\0"+n(I,4)+n(m,4)+F+R+K}}var s=e("../utils"),c=e("../stream/GenericWorker"),g=e("../utf8"),f=e("../crc32"),y=e("../signature");function p(d,w,h,m){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=w,this.zipPlatform=h,this.encodeFileName=m,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(p,c),p.prototype.push=function(d){var w=d.meta.percent||0,h=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,c.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:h?(w+100*(h-m-1))/h:100}}))},p.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var w=this.streamFiles&&!d.file.dir;if(w){var h=o(d,w,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(d){this.accumulate=!1;var w=this.streamFiles&&!d.file.dir,h=o(d,w,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),w)this.push({data:(function(m){return y.DATA_DESCRIPTOR+n(m.crc32,4)+n(m.compressedSize,4)+n(m.uncompressedSize,4)})(d),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var d=this.bytesWritten,w=0;w<this.dirRecords.length;w++)this.push({data:this.dirRecords[w],meta:{percent:100}});var h=this.bytesWritten-d,m=(function(u,v,k,C,S){var M=s.transformTo("string",S(C));return y.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(u,2)+n(u,2)+n(v,4)+n(k,4)+n(M.length,2)+M})(this.dirRecords.length,h,d,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(d){this._sources.push(d);var w=this;return d.on("data",function(h){w.processChunk(h)}),d.on("end",function(){w.closedSource(w.previous.streamInfo),w._sources.length?w.prepareNextSource():w.end()}),d.on("error",function(h){w.error(h)}),this},p.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(d){var w=this._sources;if(!c.prototype.error.call(this,d))return!1;for(var h=0;h<w.length;h++)try{w[h].error(d)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var d=this._sources,w=0;w<d.length;w++)d[w].lock()},i.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,i,r){var n=e("../compressions"),o=e("./ZipFileWorker");r.generateWorker=function(s,c,g){var f=new o(c.streamFiles,g,c.platform,c.encodeFileName),y=0;try{s.forEach(function(p,d){y++;var w=(function(v,k){var C=v||k,S=n[C];if(!S)throw new Error(C+" is not a valid compression method !");return S})(d.options.compression,c.compression),h=d.options.compressionOptions||c.compressionOptions||{},m=d.dir,u=d.date;d._compressWorker(w,h).withStreamInfo("file",{name:p,dir:m,date:u,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(f)}),f.entriesCount=y}catch(p){f.error(p)}return f}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,i,r){function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new n;for(var s in this)typeof this[s]!="function"&&(o[s]=this[s]);return o}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.1",n.loadAsync=function(o,s){return new n().loadAsync(o,s)},n.external=e("./external"),i.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,i,r){var n=e("./utils"),o=e("./external"),s=e("./utf8"),c=e("./zipEntries"),g=e("./stream/Crc32Probe"),f=e("./nodejsUtils");function y(p){return new o.Promise(function(d,w){var h=p.decompressed.getContentWorker().pipe(new g);h.on("error",function(m){w(m)}).on("end",function(){h.streamInfo.crc32!==p.decompressed.crc32?w(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(p,d){var w=this;return d=n.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:s.utf8decode}),f.isNode&&f.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",p,!0,d.optimizedBinaryString,d.base64).then(function(h){var m=new c(d);return m.load(h),m}).then(function(h){var m=[o.Promise.resolve(h)],u=h.files;if(d.checkCRC32)for(var v=0;v<u.length;v++)m.push(y(u[v]));return o.Promise.all(m)}).then(function(h){for(var m=h.shift(),u=m.files,v=0;v<u.length;v++){var k=u[v],C=k.fileNameStr,S=n.resolve(k.fileNameStr);w.file(S,k.decompressed,{binary:!0,optimizedBinaryString:!0,date:k.date,dir:k.dir,comment:k.fileCommentStr.length?k.fileCommentStr:null,unixPermissions:k.unixPermissions,dosPermissions:k.dosPermissions,createFolders:d.createFolders}),k.dir||(w.file(S).unsafeOriginalName=C)}return m.zipComment.length&&(w.comment=m.zipComment),w})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,i,r){var n=e("../utils"),o=e("../stream/GenericWorker");function s(c,g){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(g)}n.inherits(s,o),s.prototype._bindStream=function(c){var g=this;(this._stream=c).pause(),c.on("data",function(f){g.push({data:f,meta:{percent:0}})}).on("error",function(f){g.isPaused?this.generatedError=f:g.error(f)}).on("end",function(){g.isPaused?g._upstreamEnded=!0:g.end()})},s.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,i,r){var n=e("readable-stream").Readable;function o(s,c,g){n.call(this,c),this._helper=s;var f=this;s.on("data",function(y,p){f.push(y)||f._helper.pause(),g&&g(p)}).on("error",function(y){f.emit("error",y)}).on("end",function(){f.push(null)})}e("../utils").inherits(o,n),o.prototype._read=function(){this._helper.resume()},i.exports=o},{"../utils":32,"readable-stream":16}],14:[function(e,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(n,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,o);if(typeof n=="number")throw new Error('The "data" argument must not be a number');return new Buffer(n,o)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var o=new Buffer(n);return o.fill(0),o},isBuffer:function(n){return Buffer.isBuffer(n)},isStream:function(n){return n&&typeof n.on=="function"&&typeof n.pause=="function"&&typeof n.resume=="function"}}},{}],15:[function(e,i,r){function n(S,M,A){var F,T=s.getTypeOf(M),H=s.extend(A||{},f);H.date=H.date||new Date,H.compression!==null&&(H.compression=H.compression.toUpperCase()),typeof H.unixPermissions=="string"&&(H.unixPermissions=parseInt(H.unixPermissions,8)),H.unixPermissions&&16384&H.unixPermissions&&(H.dir=!0),H.dosPermissions&&16&H.dosPermissions&&(H.dir=!0),H.dir&&(S=u(S)),H.createFolders&&(F=m(S))&&v.call(this,F,!0);var K=T==="string"&&H.binary===!1&&H.base64===!1;A&&A.binary!==void 0||(H.binary=!K),(M instanceof y&&M.uncompressedSize===0||H.dir||!M||M.length===0)&&(H.base64=!1,H.binary=!0,M="",H.compression="STORE",T="string");var x=null;x=M instanceof y||M instanceof c?M:w.isNode&&w.isStream(M)?new h(S,M):s.prepareContent(S,M,H.binary,H.optimizedBinaryString,H.base64);var D=new p(S,x,H);this.files[S]=D}var o=e("./utf8"),s=e("./utils"),c=e("./stream/GenericWorker"),g=e("./stream/StreamHelper"),f=e("./defaults"),y=e("./compressedObject"),p=e("./zipObject"),d=e("./generate"),w=e("./nodejsUtils"),h=e("./nodejs/NodejsStreamInputAdapter"),m=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var M=S.lastIndexOf("/");return 0<M?S.substring(0,M):""},u=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},v=function(S,M){return M=M!==void 0?M:f.createFolders,S=u(S),this.files[S]||n.call(this,S,null,{dir:!0,createFolders:M}),this.files[S]};function k(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var C={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var M,A,F;for(M in this.files)F=this.files[M],(A=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&S(A,F)},filter:function(S){var M=[];return this.forEach(function(A,F){S(A,F)&&M.push(F)}),M},file:function(S,M,A){if(arguments.length!==1)return S=this.root+S,n.call(this,S,M,A),this;if(k(S)){var F=S;return this.filter(function(H,K){return!K.dir&&F.test(H)})}var T=this.files[this.root+S];return T&&!T.dir?T:null},folder:function(S){if(!S)return this;if(k(S))return this.filter(function(T,H){return H.dir&&S.test(T)});var M=this.root+S,A=v.call(this,M),F=this.clone();return F.root=A.name,F},remove:function(S){S=this.root+S;var M=this.files[S];if(M||(S.slice(-1)!=="/"&&(S+="/"),M=this.files[S]),M&&!M.dir)delete this.files[S];else for(var A=this.filter(function(T,H){return H.name.slice(0,S.length)===S}),F=0;F<A.length;F++)delete this.files[A[F].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var M,A={};try{if((A=s.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");s.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var F=A.comment||this.comment||"";M=d.generateWorker(this,A,F)}catch(T){(M=new c("error")).error(T)}return new g(M,A.type||"string",A.mimeType)},generateAsync:function(S,M){return this.generateInternalStream(S).accumulate(M)},generateNodeStream:function(S,M){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(M)}};i.exports=C},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,i,r){i.exports=e("stream")},{stream:void 0}],17:[function(e,i,r){var n=e("./DataReader");function o(s){n.call(this,s);for(var c=0;c<this.data.length;c++)s[c]=255&s[c]}e("../utils").inherits(o,n),o.prototype.byteAt=function(s){return this.data[this.zero+s]},o.prototype.lastIndexOfSignature=function(s){for(var c=s.charCodeAt(0),g=s.charCodeAt(1),f=s.charCodeAt(2),y=s.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===g&&this.data[p+2]===f&&this.data[p+3]===y)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(s){var c=s.charCodeAt(0),g=s.charCodeAt(1),f=s.charCodeAt(2),y=s.charCodeAt(3),p=this.readData(4);return c===p[0]&&g===p[1]&&f===p[2]&&y===p[3]},o.prototype.readData=function(s){if(this.checkOffset(s),s===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+s);return this.index+=s,c},i.exports=o},{"../utils":32,"./DataReader":18}],18:[function(e,i,r){var n=e("../utils");function o(s){this.data=s,this.length=s.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(s){this.checkIndex(this.index+s)},checkIndex:function(s){if(this.length<this.zero+s||s<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+s+"). Corrupted zip ?")},setIndex:function(s){this.checkIndex(s),this.index=s},skip:function(s){this.setIndex(this.index+s)},byteAt:function(){},readInt:function(s){var c,g=0;for(this.checkOffset(s),c=this.index+s-1;c>=this.index;c--)g=(g<<8)+this.byteAt(c);return this.index+=s,g},readString:function(s){return n.transformTo("string",this.readData(s))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var s=this.readInt(4);return new Date(Date.UTC(1980+(s>>25&127),(s>>21&15)-1,s>>16&31,s>>11&31,s>>5&63,(31&s)<<1))}},i.exports=o},{"../utils":32}],19:[function(e,i,r){var n=e("./Uint8ArrayReader");function o(s){n.call(this,s)}e("../utils").inherits(o,n),o.prototype.readData=function(s){this.checkOffset(s);var c=this.data.slice(this.zero+this.index,this.zero+this.index+s);return this.index+=s,c},i.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,i,r){var n=e("./DataReader");function o(s){n.call(this,s)}e("../utils").inherits(o,n),o.prototype.byteAt=function(s){return this.data.charCodeAt(this.zero+s)},o.prototype.lastIndexOfSignature=function(s){return this.data.lastIndexOf(s)-this.zero},o.prototype.readAndCheckSignature=function(s){return s===this.readData(4)},o.prototype.readData=function(s){this.checkOffset(s);var c=this.data.slice(this.zero+this.index,this.zero+this.index+s);return this.index+=s,c},i.exports=o},{"../utils":32,"./DataReader":18}],21:[function(e,i,r){var n=e("./ArrayReader");function o(s){n.call(this,s)}e("../utils").inherits(o,n),o.prototype.readData=function(s){if(this.checkOffset(s),s===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+s);return this.index+=s,c},i.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(e,i,r){var n=e("../utils"),o=e("../support"),s=e("./ArrayReader"),c=e("./StringReader"),g=e("./NodeBufferReader"),f=e("./Uint8ArrayReader");i.exports=function(y){var p=n.getTypeOf(y);return n.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new g(y):o.uint8array?new f(n.transformTo("uint8array",y)):new s(n.transformTo("array",y)):new c(y)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,i,r){var n=e("./GenericWorker"),o=e("../utils");function s(c){n.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(s,n),s.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},i.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,i,r){var n=e("./GenericWorker"),o=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,i,r){var n=e("../utils"),o=e("./GenericWorker");function s(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}n.inherits(s,o),s.prototype.processChunk=function(c){if(c){var g=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=g+c.data.length}o.prototype.processChunk.call(this,c)},i.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,i,r){var n=e("../utils"),o=e("./GenericWorker");function s(c){o.call(this,"DataWorker");var g=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(f){g.dataIsReady=!0,g.data=f,g.max=f&&f.length||0,g.type=n.getTypeOf(f),g.isPaused||g._tickAndRepeat()},function(f){g.error(f)})}n.inherits(s,o),s.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,g=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,g);break;case"uint8array":c=this.data.subarray(this.index,g);break;case"array":case"nodebuffer":c=this.data.slice(this.index,g)}return this.index=g,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,i,r){function n(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,s){return this._listeners[o].push(s),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,s){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,s)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var s=this;return o.on("data",function(c){s.processChunk(c)}),o.on("end",function(){s.end()}),o.on("error",function(c){s.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,s){return this.extraStreamInfo[o]=s,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},i.exports=n},{}],29:[function(e,i,r){var n=e("../utils"),o=e("./ConvertWorker"),s=e("./GenericWorker"),c=e("../base64"),g=e("../support"),f=e("../external"),y=null;if(g.nodestream)try{y=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(w,h){return new f.Promise(function(m,u){var v=[],k=w._internalType,C=w._outputType,S=w._mimeType;w.on("data",function(M,A){v.push(M),h&&h(A)}).on("error",function(M){v=[],u(M)}).on("end",function(){try{var M=(function(A,F,T){switch(A){case"blob":return n.newBlob(n.transformTo("arraybuffer",F),T);case"base64":return c.encode(F);default:return n.transformTo(A,F)}})(C,(function(A,F){var T,H=0,K=null,x=0;for(T=0;T<F.length;T++)x+=F[T].length;switch(A){case"string":return F.join("");case"array":return Array.prototype.concat.apply([],F);case"uint8array":for(K=new Uint8Array(x),T=0;T<F.length;T++)K.set(F[T],H),H+=F[T].length;return K;case"nodebuffer":return Buffer.concat(F);default:throw new Error("concat : unsupported type '"+A+"'")}})(k,v),S);m(M)}catch(A){u(A)}v=[]}).resume()})}function d(w,h,m){var u=h;switch(h){case"blob":case"arraybuffer":u="uint8array";break;case"base64":u="string"}try{this._internalType=u,this._outputType=h,this._mimeType=m,n.checkSupport(u),this._worker=w.pipe(new o(u)),w.lock()}catch(v){this._worker=new s("error"),this._worker.error(v)}}d.prototype={accumulate:function(w){return p(this,w)},on:function(w,h){var m=this;return w==="data"?this._worker.on(w,function(u){h.call(m,u.data,u.meta)}):this._worker.on(w,function(){n.delay(h,arguments,m)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(w){if(n.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new y(this,{objectMode:this._outputType!=="nodebuffer"},w)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var n=new ArrayBuffer(0);try{r.blob=new Blob([n],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(n),r.blob=o.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(e,i,r){for(var n=e("./utils"),o=e("./support"),s=e("./nodejsUtils"),c=e("./stream/GenericWorker"),g=new Array(256),f=0;f<256;f++)g[f]=252<=f?6:248<=f?5:240<=f?4:224<=f?3:192<=f?2:1;g[254]=g[254]=1;function y(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}r.utf8encode=function(d){return o.nodebuffer?s.newBufferFrom(d,"utf-8"):(function(w){var h,m,u,v,k,C=w.length,S=0;for(v=0;v<C;v++)(64512&(m=w.charCodeAt(v)))==55296&&v+1<C&&(64512&(u=w.charCodeAt(v+1)))==56320&&(m=65536+(m-55296<<10)+(u-56320),v++),S+=m<128?1:m<2048?2:m<65536?3:4;for(h=o.uint8array?new Uint8Array(S):new Array(S),v=k=0;k<S;v++)(64512&(m=w.charCodeAt(v)))==55296&&v+1<C&&(64512&(u=w.charCodeAt(v+1)))==56320&&(m=65536+(m-55296<<10)+(u-56320),v++),m<128?h[k++]=m:(m<2048?h[k++]=192|m>>>6:(m<65536?h[k++]=224|m>>>12:(h[k++]=240|m>>>18,h[k++]=128|m>>>12&63),h[k++]=128|m>>>6&63),h[k++]=128|63&m);return h})(d)},r.utf8decode=function(d){return o.nodebuffer?n.transformTo("nodebuffer",d).toString("utf-8"):(function(w){var h,m,u,v,k=w.length,C=new Array(2*k);for(h=m=0;h<k;)if((u=w[h++])<128)C[m++]=u;else if(4<(v=g[u]))C[m++]=65533,h+=v-1;else{for(u&=v===2?31:v===3?15:7;1<v&&h<k;)u=u<<6|63&w[h++],v--;1<v?C[m++]=65533:u<65536?C[m++]=u:(u-=65536,C[m++]=55296|u>>10&1023,C[m++]=56320|1023&u)}return C.length!==m&&(C.subarray?C=C.subarray(0,m):C.length=m),n.applyFromCharCode(C)})(d=n.transformTo(o.uint8array?"uint8array":"array",d))},n.inherits(y,c),y.prototype.processChunk=function(d){var w=n.transformTo(o.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var h=w;(w=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),w.set(h,this.leftOver.length)}else w=this.leftOver.concat(w);this.leftOver=null}var m=(function(v,k){var C;for((k=k||v.length)>v.length&&(k=v.length),C=k-1;0<=C&&(192&v[C])==128;)C--;return C<0||C===0?k:C+g[v[C]]>k?C:k})(w),u=w;m!==w.length&&(o.uint8array?(u=w.subarray(0,m),this.leftOver=w.subarray(m,w.length)):(u=w.slice(0,m),this.leftOver=w.slice(m,w.length))),this.push({data:r.utf8decode(u),meta:d.meta})},y.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=y,n.inherits(p,c),p.prototype.processChunk=function(d){this.push({data:r.utf8encode(d.data),meta:d.meta})},r.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,i,r){var n=e("./support"),o=e("./base64"),s=e("./nodejsUtils"),c=e("./external");function g(h){return h}function f(h,m){for(var u=0;u<h.length;++u)m[u]=255&h.charCodeAt(u);return m}e("setimmediate"),r.newBlob=function(h,m){r.checkSupport("blob");try{return new Blob([h],{type:m})}catch{try{var u=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return u.append(h),u.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var y={stringifyByChunk:function(h,m,u){var v=[],k=0,C=h.length;if(C<=u)return String.fromCharCode.apply(null,h);for(;k<C;)m==="array"||m==="nodebuffer"?v.push(String.fromCharCode.apply(null,h.slice(k,Math.min(k+u,C)))):v.push(String.fromCharCode.apply(null,h.subarray(k,Math.min(k+u,C)))),k+=u;return v.join("")},stringifyByChar:function(h){for(var m="",u=0;u<h.length;u++)m+=String.fromCharCode(h[u]);return m},applyCanBeUsed:{uint8array:(function(){try{return n.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return n.nodebuffer&&String.fromCharCode.apply(null,s.allocBuffer(1)).length===1}catch{return!1}})()}};function p(h){var m=65536,u=r.getTypeOf(h),v=!0;if(u==="uint8array"?v=y.applyCanBeUsed.uint8array:u==="nodebuffer"&&(v=y.applyCanBeUsed.nodebuffer),v)for(;1<m;)try{return y.stringifyByChunk(h,u,m)}catch{m=Math.floor(m/2)}return y.stringifyByChar(h)}function d(h,m){for(var u=0;u<h.length;u++)m[u]=h[u];return m}r.applyFromCharCode=p;var w={};w.string={string:g,array:function(h){return f(h,new Array(h.length))},arraybuffer:function(h){return w.string.uint8array(h).buffer},uint8array:function(h){return f(h,new Uint8Array(h.length))},nodebuffer:function(h){return f(h,s.allocBuffer(h.length))}},w.array={string:p,array:g,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return s.newBufferFrom(h)}},w.arraybuffer={string:function(h){return p(new Uint8Array(h))},array:function(h){return d(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:g,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return s.newBufferFrom(new Uint8Array(h))}},w.uint8array={string:p,array:function(h){return d(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:g,nodebuffer:function(h){return s.newBufferFrom(h)}},w.nodebuffer={string:p,array:function(h){return d(h,new Array(h.length))},arraybuffer:function(h){return w.nodebuffer.uint8array(h).buffer},uint8array:function(h){return d(h,new Uint8Array(h.length))},nodebuffer:g},r.transformTo=function(h,m){if(m=m||"",!h)return m;r.checkSupport(h);var u=r.getTypeOf(m);return w[u][h](m)},r.resolve=function(h){for(var m=h.split("/"),u=[],v=0;v<m.length;v++){var k=m[v];k==="."||k===""&&v!==0&&v!==m.length-1||(k===".."?u.pop():u.push(k))}return u.join("/")},r.getTypeOf=function(h){return typeof h=="string"?"string":Object.prototype.toString.call(h)==="[object Array]"?"array":n.nodebuffer&&s.isBuffer(h)?"nodebuffer":n.uint8array&&h instanceof Uint8Array?"uint8array":n.arraybuffer&&h instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(h){if(!n[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(h){var m,u,v="";for(u=0;u<(h||"").length;u++)v+="\\x"+((m=h.charCodeAt(u))<16?"0":"")+m.toString(16).toUpperCase();return v},r.delay=function(h,m,u){setImmediate(function(){h.apply(u||null,m||[])})},r.inherits=function(h,m){function u(){}u.prototype=m.prototype,h.prototype=new u},r.extend=function(){var h,m,u={};for(h=0;h<arguments.length;h++)for(m in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],m)&&u[m]===void 0&&(u[m]=arguments[h][m]);return u},r.prepareContent=function(h,m,u,v,k){return c.Promise.resolve(m).then(function(C){return n.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-1)&&typeof FileReader<"u"?new c.Promise(function(S,M){var A=new FileReader;A.onload=function(F){S(F.target.result)},A.onerror=function(F){M(F.target.error)},A.readAsArrayBuffer(C)}):C}).then(function(C){var S=r.getTypeOf(C);return S?(S==="arraybuffer"?C=r.transformTo("uint8array",C):S==="string"&&(k?C=o.decode(C):u&&v!==!0&&(C=(function(M){return f(M,n.uint8array?new Uint8Array(M.length):new Array(M.length))})(C))),C):c.Promise.reject(new Error("Can't read the data of '"+h+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,i,r){var n=e("./reader/readerFor"),o=e("./utils"),s=e("./signature"),c=e("./zipEntry"),g=e("./support");function f(y){this.files=[],this.loadOptions=y}f.prototype={checkSignature:function(y){if(!this.reader.readAndCheckSignature(y)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(y)+")")}},isSignature:function(y,p){var d=this.reader.index;this.reader.setIndex(y);var w=this.reader.readString(4)===p;return this.reader.setIndex(d),w},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var y=this.reader.readData(this.zipCommentLength),p=g.uint8array?"uint8array":"array",d=o.transformTo(p,y);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var y,p,d,w=this.zip64EndOfCentralSize-44;0<w;)y=this.reader.readInt(2),p=this.reader.readInt(4),d=this.reader.readData(p),this.zip64ExtensibleData[y]={id:y,length:p,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var y,p;for(y=0;y<this.files.length;y++)p=this.files[y],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var y;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(y=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(y);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var y=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(y<0)throw this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(y);var p=y;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(y=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(y),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var w=p-d;if(0<w)this.isSignature(p,s.CENTRAL_FILE_HEADER)||(this.reader.zero=w);else if(w<0)throw new Error("Corrupted zip: missing "+Math.abs(w)+" bytes.")},prepareReader:function(y){this.reader=n(y)},load:function(y){this.prepareReader(y),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=f},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,i,r){var n=e("./reader/readerFor"),o=e("./utils"),s=e("./compressedObject"),c=e("./crc32"),g=e("./utf8"),f=e("./compressions"),y=e("./support");function p(d,w){this.options=d,this.loadOptions=w}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(d){var w,h;if(d.skip(22),this.fileNameLength=d.readInt(2),h=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(h),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((w=(function(m){for(var u in f)if(Object.prototype.hasOwnProperty.call(f,u)&&f[u].magic===m)return f[u];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new s(this.compressedSize,this.uncompressedSize,this.crc32,w,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var w=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(w),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),d==0&&(this.dosPermissions=63&this.externalFileAttributes),d==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=n(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var w,h,m,u=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<u;)w=d.readInt(2),h=d.readInt(2),m=d.readData(h),this.extraFields[w]={id:w,length:h,value:m};d.setIndex(u)},handleUTF8:function(){var d=y.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=g.utf8decode(this.fileName),this.fileCommentStr=g.utf8decode(this.fileComment);else{var w=this.findExtraFieldUnicodePath();if(w!==null)this.fileNameStr=w;else{var h=o.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var u=o.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(u)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var w=n(d.value);return w.readInt(1)!==1||c(this.fileName)!==w.readInt(4)?null:g.utf8decode(w.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var w=n(d.value);return w.readInt(1)!==1||c(this.fileComment)!==w.readInt(4)?null:g.utf8decode(w.readData(d.length-5))}return null}},i.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,i,r){function n(w,h,m){this.name=w,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=h,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var o=e("./stream/StreamHelper"),s=e("./stream/DataWorker"),c=e("./utf8"),g=e("./compressedObject"),f=e("./stream/GenericWorker");n.prototype={internalStream:function(w){var h=null,m="string";try{if(!w)throw new Error("No output type specified.");var u=(m=w.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),h=this._decompressWorker();var v=!this._dataBinary;v&&!u&&(h=h.pipe(new c.Utf8EncodeWorker)),!v&&u&&(h=h.pipe(new c.Utf8DecodeWorker))}catch(k){(h=new f("error")).error(k)}return new o(h,m,"")},async:function(w,h){return this.internalStream(w).accumulate(h)},nodeStream:function(w,h){return this.internalStream(w||"nodebuffer").toNodejsStream(h)},_compressWorker:function(w,h){if(this._data instanceof g&&this._data.compression.magic===w.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new c.Utf8EncodeWorker)),g.createWorkerFrom(m,w,h)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof f?this._data:new s(this._data)}};for(var y=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<y.length;d++)n.prototype[y[d]]=p;i.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,i,r){(function(n){var o,s,c=n.MutationObserver||n.WebKitMutationObserver;if(c){var g=0,f=new c(w),y=n.document.createTextNode("");f.observe(y,{characterData:!0}),o=function(){y.data=g=++g%2}}else if(n.setImmediate||n.MessageChannel===void 0)o="document"in n&&"onreadystatechange"in n.document.createElement("script")?function(){var h=n.document.createElement("script");h.onreadystatechange=function(){w(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},n.document.documentElement.appendChild(h)}:function(){setTimeout(w,0)};else{var p=new n.MessageChannel;p.port1.onmessage=w,o=function(){p.port2.postMessage(0)}}var d=[];function w(){var h,m;s=!0;for(var u=d.length;u;){for(m=d,d=[],h=-1;++h<u;)m[h]();u=d.length}s=!1}i.exports=function(h){d.push(h)!==1||s||o()}}).call(this,typeof kt<"u"?kt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,i,r){var n=e("immediate");function o(){}var s={},c=["REJECTED"],g=["FULFILLED"],f=["PENDING"];function y(u){if(typeof u!="function")throw new TypeError("resolver must be a function");this.state=f,this.queue=[],this.outcome=void 0,u!==o&&h(this,u)}function p(u,v,k){this.promise=u,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function d(u,v,k){n(function(){var C;try{C=v(k)}catch(S){return s.reject(u,S)}C===u?s.reject(u,new TypeError("Cannot resolve promise with itself")):s.resolve(u,C)})}function w(u){var v=u&&u.then;if(u&&(typeof u=="object"||typeof u=="function")&&typeof v=="function")return function(){v.apply(u,arguments)}}function h(u,v){var k=!1;function C(A){k||(k=!0,s.reject(u,A))}function S(A){k||(k=!0,s.resolve(u,A))}var M=m(function(){v(S,C)});M.status==="error"&&C(M.value)}function m(u,v){var k={};try{k.value=u(v),k.status="success"}catch(C){k.status="error",k.value=C}return k}(i.exports=y).prototype.finally=function(u){if(typeof u!="function")return this;var v=this.constructor;return this.then(function(k){return v.resolve(u()).then(function(){return k})},function(k){return v.resolve(u()).then(function(){throw k})})},y.prototype.catch=function(u){return this.then(null,u)},y.prototype.then=function(u,v){if(typeof u!="function"&&this.state===g||typeof v!="function"&&this.state===c)return this;var k=new this.constructor(o);return this.state!==f?d(k,this.state===g?u:v,this.outcome):this.queue.push(new p(k,u,v)),k},p.prototype.callFulfilled=function(u){s.resolve(this.promise,u)},p.prototype.otherCallFulfilled=function(u){d(this.promise,this.onFulfilled,u)},p.prototype.callRejected=function(u){s.reject(this.promise,u)},p.prototype.otherCallRejected=function(u){d(this.promise,this.onRejected,u)},s.resolve=function(u,v){var k=m(w,v);if(k.status==="error")return s.reject(u,k.value);var C=k.value;if(C)h(u,C);else{u.state=g,u.outcome=v;for(var S=-1,M=u.queue.length;++S<M;)u.queue[S].callFulfilled(v)}return u},s.reject=function(u,v){u.state=c,u.outcome=v;for(var k=-1,C=u.queue.length;++k<C;)u.queue[k].callRejected(v);return u},y.resolve=function(u){return u instanceof this?u:s.resolve(new this(o),u)},y.reject=function(u){var v=new this(o);return s.reject(v,u)},y.all=function(u){var v=this;if(Object.prototype.toString.call(u)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=u.length,C=!1;if(!k)return this.resolve([]);for(var S=new Array(k),M=0,A=-1,F=new this(o);++A<k;)T(u[A],A);return F;function T(H,K){v.resolve(H).then(function(x){S[K]=x,++M!==k||C||(C=!0,s.resolve(F,S))},function(x){C||(C=!0,s.reject(F,x))})}},y.race=function(u){var v=this;if(Object.prototype.toString.call(u)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=u.length,C=!1;if(!k)return this.resolve([]);for(var S=-1,M=new this(o);++S<k;)A=u[S],v.resolve(A).then(function(F){C||(C=!0,s.resolve(M,F))},function(F){C||(C=!0,s.reject(M,F))});var A;return M}},{immediate:36}],38:[function(e,i,r){var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),i.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,i,r){var n=e("./zlib/deflate"),o=e("./utils/common"),s=e("./utils/strings"),c=e("./zlib/messages"),g=e("./zlib/zstream"),f=Object.prototype.toString,y=0,p=-1,d=0,w=8;function h(u){if(!(this instanceof h))return new h(u);this.options=o.assign({level:p,method:w,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},u||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var k=n.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(k!==y)throw new Error(c[k]);if(v.header&&n.deflateSetHeader(this.strm,v.header),v.dictionary){var C;if(C=typeof v.dictionary=="string"?s.string2buf(v.dictionary):f.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(k=n.deflateSetDictionary(this.strm,C))!==y)throw new Error(c[k]);this._dict_set=!0}}function m(u,v){var k=new h(v);if(k.push(u,!0),k.err)throw k.msg||c[k.err];return k.result}h.prototype.push=function(u,v){var k,C,S=this.strm,M=this.options.chunkSize;if(this.ended)return!1;C=v===~~v?v:v===!0?4:0,typeof u=="string"?S.input=s.string2buf(u):f.call(u)==="[object ArrayBuffer]"?S.input=new Uint8Array(u):S.input=u,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new o.Buf8(M),S.next_out=0,S.avail_out=M),(k=n.deflate(S,C))!==1&&k!==y)return this.onEnd(k),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||C!==4&&C!==2)||(this.options.to==="string"?this.onData(s.buf2binstring(o.shrinkBuf(S.output,S.next_out))):this.onData(o.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&k!==1);return C===4?(k=n.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===y):C!==2||(this.onEnd(y),!(S.avail_out=0))},h.prototype.onData=function(u){this.chunks.push(u)},h.prototype.onEnd=function(u){u===y&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg},r.Deflate=h,r.deflate=m,r.deflateRaw=function(u,v){return(v=v||{}).raw=!0,m(u,v)},r.gzip=function(u,v){return(v=v||{}).gzip=!0,m(u,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,i,r){var n=e("./zlib/inflate"),o=e("./utils/common"),s=e("./utils/strings"),c=e("./zlib/constants"),g=e("./zlib/messages"),f=e("./zlib/zstream"),y=e("./zlib/gzheader"),p=Object.prototype.toString;function d(h){if(!(this instanceof d))return new d(h);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},h||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||h&&h.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f,this.strm.avail_out=0;var u=n.inflateInit2(this.strm,m.windowBits);if(u!==c.Z_OK)throw new Error(g[u]);this.header=new y,n.inflateGetHeader(this.strm,this.header)}function w(h,m){var u=new d(m);if(u.push(h,!0),u.err)throw u.msg||g[u.err];return u.result}d.prototype.push=function(h,m){var u,v,k,C,S,M,A=this.strm,F=this.options.chunkSize,T=this.options.dictionary,H=!1;if(this.ended)return!1;v=m===~~m?m:m===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof h=="string"?A.input=s.binstring2buf(h):p.call(h)==="[object ArrayBuffer]"?A.input=new Uint8Array(h):A.input=h,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new o.Buf8(F),A.next_out=0,A.avail_out=F),(u=n.inflate(A,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&T&&(M=typeof T=="string"?s.string2buf(T):p.call(T)==="[object ArrayBuffer]"?new Uint8Array(T):T,u=n.inflateSetDictionary(this.strm,M)),u===c.Z_BUF_ERROR&&H===!0&&(u=c.Z_OK,H=!1),u!==c.Z_STREAM_END&&u!==c.Z_OK)return this.onEnd(u),!(this.ended=!0);A.next_out&&(A.avail_out!==0&&u!==c.Z_STREAM_END&&(A.avail_in!==0||v!==c.Z_FINISH&&v!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=s.utf8border(A.output,A.next_out),C=A.next_out-k,S=s.buf2string(A.output,k),A.next_out=C,A.avail_out=F-C,C&&o.arraySet(A.output,A.output,k,C,0),this.onData(S)):this.onData(o.shrinkBuf(A.output,A.next_out)))),A.avail_in===0&&A.avail_out===0&&(H=!0)}while((0<A.avail_in||A.avail_out===0)&&u!==c.Z_STREAM_END);return u===c.Z_STREAM_END&&(v=c.Z_FINISH),v===c.Z_FINISH?(u=n.inflateEnd(this.strm),this.onEnd(u),this.ended=!0,u===c.Z_OK):v!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(A.avail_out=0))},d.prototype.onData=function(h){this.chunks.push(h)},d.prototype.onEnd=function(h){h===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},r.Inflate=d,r.inflate=w,r.inflateRaw=function(h,m){return(m=m||{}).raw=!0,w(h,m)},r.ungzip=w},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,i,r){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var g=Array.prototype.slice.call(arguments,1);g.length;){var f=g.shift();if(f){if(typeof f!="object")throw new TypeError(f+"must be non-object");for(var y in f)f.hasOwnProperty(y)&&(c[y]=f[y])}}return c},r.shrinkBuf=function(c,g){return c.length===g?c:c.subarray?c.subarray(0,g):(c.length=g,c)};var o={arraySet:function(c,g,f,y,p){if(g.subarray&&c.subarray)c.set(g.subarray(f,f+y),p);else for(var d=0;d<y;d++)c[p+d]=g[f+d]},flattenChunks:function(c){var g,f,y,p,d,w;for(g=y=0,f=c.length;g<f;g++)y+=c[g].length;for(w=new Uint8Array(y),g=p=0,f=c.length;g<f;g++)d=c[g],w.set(d,p),p+=d.length;return w}},s={arraySet:function(c,g,f,y,p){for(var d=0;d<y;d++)c[p+d]=g[f+d]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,o)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,s))},r.setTyped(n)},{}],42:[function(e,i,r){var n=e("./common"),o=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{s=!1}for(var c=new n.Buf8(256),g=0;g<256;g++)c[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;function f(y,p){if(p<65537&&(y.subarray&&s||!y.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(y,p));for(var d="",w=0;w<p;w++)d+=String.fromCharCode(y[w]);return d}c[254]=c[254]=1,r.string2buf=function(y){var p,d,w,h,m,u=y.length,v=0;for(h=0;h<u;h++)(64512&(d=y.charCodeAt(h)))==55296&&h+1<u&&(64512&(w=y.charCodeAt(h+1)))==56320&&(d=65536+(d-55296<<10)+(w-56320),h++),v+=d<128?1:d<2048?2:d<65536?3:4;for(p=new n.Buf8(v),h=m=0;m<v;h++)(64512&(d=y.charCodeAt(h)))==55296&&h+1<u&&(64512&(w=y.charCodeAt(h+1)))==56320&&(d=65536+(d-55296<<10)+(w-56320),h++),d<128?p[m++]=d:(d<2048?p[m++]=192|d>>>6:(d<65536?p[m++]=224|d>>>12:(p[m++]=240|d>>>18,p[m++]=128|d>>>12&63),p[m++]=128|d>>>6&63),p[m++]=128|63&d);return p},r.buf2binstring=function(y){return f(y,y.length)},r.binstring2buf=function(y){for(var p=new n.Buf8(y.length),d=0,w=p.length;d<w;d++)p[d]=y.charCodeAt(d);return p},r.buf2string=function(y,p){var d,w,h,m,u=p||y.length,v=new Array(2*u);for(d=w=0;d<u;)if((h=y[d++])<128)v[w++]=h;else if(4<(m=c[h]))v[w++]=65533,d+=m-1;else{for(h&=m===2?31:m===3?15:7;1<m&&d<u;)h=h<<6|63&y[d++],m--;1<m?v[w++]=65533:h<65536?v[w++]=h:(h-=65536,v[w++]=55296|h>>10&1023,v[w++]=56320|1023&h)}return f(v,w)},r.utf8border=function(y,p){var d;for((p=p||y.length)>y.length&&(p=y.length),d=p-1;0<=d&&(192&y[d])==128;)d--;return d<0||d===0?p:d+c[y[d]]>p?d:p}},{"./common":41}],43:[function(e,i,r){i.exports=function(n,o,s,c){for(var g=65535&n|0,f=n>>>16&65535|0,y=0;s!==0;){for(s-=y=2e3<s?2e3:s;f=f+(g=g+o[c++]|0)|0,--y;);g%=65521,f%=65521}return g|f<<16|0}},{}],44:[function(e,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,i,r){var n=(function(){for(var o,s=[],c=0;c<256;c++){o=c;for(var g=0;g<8;g++)o=1&o?3988292384^o>>>1:o>>>1;s[c]=o}return s})();i.exports=function(o,s,c,g){var f=n,y=g+c;o^=-1;for(var p=g;p<y;p++)o=o>>>8^f[255&(o^s[p])];return-1^o}},{}],46:[function(e,i,r){var n,o=e("../utils/common"),s=e("./trees"),c=e("./adler32"),g=e("./crc32"),f=e("./messages"),y=0,p=4,d=0,w=-2,h=-1,m=4,u=2,v=8,k=9,C=286,S=30,M=19,A=2*C+1,F=15,T=3,H=258,K=H+T+1,x=42,D=113,l=1,R=2,V=3,W=4;function Q(a,L){return a.msg=f[L],L}function U(a){return(a<<1)-(4<a?9:0)}function q(a){for(var L=a.length;0<=--L;)a[L]=0}function z(a){var L=a.state,B=L.pending;B>a.avail_out&&(B=a.avail_out),B!==0&&(o.arraySet(a.output,L.pending_buf,L.pending_out,B,a.next_out),a.next_out+=B,L.pending_out+=B,a.total_out+=B,a.avail_out-=B,L.pending-=B,L.pending===0&&(L.pending_out=0))}function I(a,L){s._tr_flush_block(a,0<=a.block_start?a.block_start:-1,a.strstart-a.block_start,L),a.block_start=a.strstart,z(a.strm)}function J(a,L){a.pending_buf[a.pending++]=L}function Y(a,L){a.pending_buf[a.pending++]=L>>>8&255,a.pending_buf[a.pending++]=255&L}function X(a,L){var B,_,b=a.max_chain_length,N=a.strstart,O=a.prev_length,P=a.nice_match,E=a.strstart>a.w_size-K?a.strstart-(a.w_size-K):0,j=a.window,G=a.w_mask,Z=a.prev,$=a.strstart+H,nt=j[N+O-1],et=j[N+O];a.prev_length>=a.good_match&&(b>>=2),P>a.lookahead&&(P=a.lookahead);do if(j[(B=L)+O]===et&&j[B+O-1]===nt&&j[B]===j[N]&&j[++B]===j[N+1]){N+=2,B++;do;while(j[++N]===j[++B]&&j[++N]===j[++B]&&j[++N]===j[++B]&&j[++N]===j[++B]&&j[++N]===j[++B]&&j[++N]===j[++B]&&j[++N]===j[++B]&&j[++N]===j[++B]&&N<$);if(_=H-($-N),N=$-H,O<_){if(a.match_start=L,P<=(O=_))break;nt=j[N+O-1],et=j[N+O]}}while((L=Z[L&G])>E&&--b!=0);return O<=a.lookahead?O:a.lookahead}function ot(a){var L,B,_,b,N,O,P,E,j,G,Z=a.w_size;do{if(b=a.window_size-a.lookahead-a.strstart,a.strstart>=Z+(Z-K)){for(o.arraySet(a.window,a.window,Z,Z,0),a.match_start-=Z,a.strstart-=Z,a.block_start-=Z,L=B=a.hash_size;_=a.head[--L],a.head[L]=Z<=_?_-Z:0,--B;);for(L=B=Z;_=a.prev[--L],a.prev[L]=Z<=_?_-Z:0,--B;);b+=Z}if(a.strm.avail_in===0)break;if(O=a.strm,P=a.window,E=a.strstart+a.lookahead,j=b,G=void 0,G=O.avail_in,j<G&&(G=j),B=G===0?0:(O.avail_in-=G,o.arraySet(P,O.input,O.next_in,G,E),O.state.wrap===1?O.adler=c(O.adler,P,G,E):O.state.wrap===2&&(O.adler=g(O.adler,P,G,E)),O.next_in+=G,O.total_in+=G,G),a.lookahead+=B,a.lookahead+a.insert>=T)for(N=a.strstart-a.insert,a.ins_h=a.window[N],a.ins_h=(a.ins_h<<a.hash_shift^a.window[N+1])&a.hash_mask;a.insert&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[N+T-1])&a.hash_mask,a.prev[N&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=N,N++,a.insert--,!(a.lookahead+a.insert<T)););}while(a.lookahead<K&&a.strm.avail_in!==0)}function dt(a,L){for(var B,_;;){if(a.lookahead<K){if(ot(a),a.lookahead<K&&L===y)return l;if(a.lookahead===0)break}if(B=0,a.lookahead>=T&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+T-1])&a.hash_mask,B=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),B!==0&&a.strstart-B<=a.w_size-K&&(a.match_length=X(a,B)),a.match_length>=T)if(_=s._tr_tally(a,a.strstart-a.match_start,a.match_length-T),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=T){for(a.match_length--;a.strstart++,a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+T-1])&a.hash_mask,B=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart,--a.match_length!=0;);a.strstart++}else a.strstart+=a.match_length,a.match_length=0,a.ins_h=a.window[a.strstart],a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+1])&a.hash_mask;else _=s._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++;if(_&&(I(a,!1),a.strm.avail_out===0))return l}return a.insert=a.strstart<T-1?a.strstart:T-1,L===p?(I(a,!0),a.strm.avail_out===0?V:W):a.last_lit&&(I(a,!1),a.strm.avail_out===0)?l:R}function tt(a,L){for(var B,_,b;;){if(a.lookahead<K){if(ot(a),a.lookahead<K&&L===y)return l;if(a.lookahead===0)break}if(B=0,a.lookahead>=T&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+T-1])&a.hash_mask,B=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),a.prev_length=a.match_length,a.prev_match=a.match_start,a.match_length=T-1,B!==0&&a.prev_length<a.max_lazy_match&&a.strstart-B<=a.w_size-K&&(a.match_length=X(a,B),a.match_length<=5&&(a.strategy===1||a.match_length===T&&4096<a.strstart-a.match_start)&&(a.match_length=T-1)),a.prev_length>=T&&a.match_length<=a.prev_length){for(b=a.strstart+a.lookahead-T,_=s._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-T),a.lookahead-=a.prev_length-1,a.prev_length-=2;++a.strstart<=b&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+T-1])&a.hash_mask,B=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),--a.prev_length!=0;);if(a.match_available=0,a.match_length=T-1,a.strstart++,_&&(I(a,!1),a.strm.avail_out===0))return l}else if(a.match_available){if((_=s._tr_tally(a,0,a.window[a.strstart-1]))&&I(a,!1),a.strstart++,a.lookahead--,a.strm.avail_out===0)return l}else a.match_available=1,a.strstart++,a.lookahead--}return a.match_available&&(_=s._tr_tally(a,0,a.window[a.strstart-1]),a.match_available=0),a.insert=a.strstart<T-1?a.strstart:T-1,L===p?(I(a,!0),a.strm.avail_out===0?V:W):a.last_lit&&(I(a,!1),a.strm.avail_out===0)?l:R}function rt(a,L,B,_,b){this.good_length=a,this.max_lazy=L,this.nice_length=B,this.max_chain=_,this.func=b}function lt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*A),this.dyn_dtree=new o.Buf16(2*(2*S+1)),this.bl_tree=new o.Buf16(2*(2*M+1)),q(this.dyn_ltree),q(this.dyn_dtree),q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(F+1),this.heap=new o.Buf16(2*C+1),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*C+1),q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function st(a){var L;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=u,(L=a.state).pending=0,L.pending_out=0,L.wrap<0&&(L.wrap=-L.wrap),L.status=L.wrap?x:D,a.adler=L.wrap===2?0:1,L.last_flush=y,s._tr_init(L),d):Q(a,w)}function ft(a){var L=st(a);return L===d&&(function(B){B.window_size=2*B.w_size,q(B.head),B.max_lazy_match=n[B.level].max_lazy,B.good_match=n[B.level].good_length,B.nice_match=n[B.level].nice_length,B.max_chain_length=n[B.level].max_chain,B.strstart=0,B.block_start=0,B.lookahead=0,B.insert=0,B.match_length=B.prev_length=T-1,B.match_available=0,B.ins_h=0})(a.state),L}function ut(a,L,B,_,b,N){if(!a)return w;var O=1;if(L===h&&(L=6),_<0?(O=0,_=-_):15<_&&(O=2,_-=16),b<1||k<b||B!==v||_<8||15<_||L<0||9<L||N<0||m<N)return Q(a,w);_===8&&(_=9);var P=new lt;return(a.state=P).strm=a,P.wrap=O,P.gzhead=null,P.w_bits=_,P.w_size=1<<P.w_bits,P.w_mask=P.w_size-1,P.hash_bits=b+7,P.hash_size=1<<P.hash_bits,P.hash_mask=P.hash_size-1,P.hash_shift=~~((P.hash_bits+T-1)/T),P.window=new o.Buf8(2*P.w_size),P.head=new o.Buf16(P.hash_size),P.prev=new o.Buf16(P.w_size),P.lit_bufsize=1<<b+6,P.pending_buf_size=4*P.lit_bufsize,P.pending_buf=new o.Buf8(P.pending_buf_size),P.d_buf=1*P.lit_bufsize,P.l_buf=3*P.lit_bufsize,P.level=L,P.strategy=N,P.method=B,ft(a)}n=[new rt(0,0,0,0,function(a,L){var B=65535;for(B>a.pending_buf_size-5&&(B=a.pending_buf_size-5);;){if(a.lookahead<=1){if(ot(a),a.lookahead===0&&L===y)return l;if(a.lookahead===0)break}a.strstart+=a.lookahead,a.lookahead=0;var _=a.block_start+B;if((a.strstart===0||a.strstart>=_)&&(a.lookahead=a.strstart-_,a.strstart=_,I(a,!1),a.strm.avail_out===0)||a.strstart-a.block_start>=a.w_size-K&&(I(a,!1),a.strm.avail_out===0))return l}return a.insert=0,L===p?(I(a,!0),a.strm.avail_out===0?V:W):(a.strstart>a.block_start&&(I(a,!1),a.strm.avail_out),l)}),new rt(4,4,8,4,dt),new rt(4,5,16,8,dt),new rt(4,6,32,32,dt),new rt(4,4,16,16,tt),new rt(8,16,32,32,tt),new rt(8,16,128,128,tt),new rt(8,32,128,256,tt),new rt(32,128,258,1024,tt),new rt(32,258,258,4096,tt)],r.deflateInit=function(a,L){return ut(a,L,v,15,8,0)},r.deflateInit2=ut,r.deflateReset=ft,r.deflateResetKeep=st,r.deflateSetHeader=function(a,L){return a&&a.state?a.state.wrap!==2?w:(a.state.gzhead=L,d):w},r.deflate=function(a,L){var B,_,b,N;if(!a||!a.state||5<L||L<0)return a?Q(a,w):w;if(_=a.state,!a.output||!a.input&&a.avail_in!==0||_.status===666&&L!==p)return Q(a,a.avail_out===0?-5:w);if(_.strm=a,B=_.last_flush,_.last_flush=L,_.status===x)if(_.wrap===2)a.adler=0,J(_,31),J(_,139),J(_,8),_.gzhead?(J(_,(_.gzhead.text?1:0)+(_.gzhead.hcrc?2:0)+(_.gzhead.extra?4:0)+(_.gzhead.name?8:0)+(_.gzhead.comment?16:0)),J(_,255&_.gzhead.time),J(_,_.gzhead.time>>8&255),J(_,_.gzhead.time>>16&255),J(_,_.gzhead.time>>24&255),J(_,_.level===9?2:2<=_.strategy||_.level<2?4:0),J(_,255&_.gzhead.os),_.gzhead.extra&&_.gzhead.extra.length&&(J(_,255&_.gzhead.extra.length),J(_,_.gzhead.extra.length>>8&255)),_.gzhead.hcrc&&(a.adler=g(a.adler,_.pending_buf,_.pending,0)),_.gzindex=0,_.status=69):(J(_,0),J(_,0),J(_,0),J(_,0),J(_,0),J(_,_.level===9?2:2<=_.strategy||_.level<2?4:0),J(_,3),_.status=D);else{var O=v+(_.w_bits-8<<4)<<8;O|=(2<=_.strategy||_.level<2?0:_.level<6?1:_.level===6?2:3)<<6,_.strstart!==0&&(O|=32),O+=31-O%31,_.status=D,Y(_,O),_.strstart!==0&&(Y(_,a.adler>>>16),Y(_,65535&a.adler)),a.adler=1}if(_.status===69)if(_.gzhead.extra){for(b=_.pending;_.gzindex<(65535&_.gzhead.extra.length)&&(_.pending!==_.pending_buf_size||(_.gzhead.hcrc&&_.pending>b&&(a.adler=g(a.adler,_.pending_buf,_.pending-b,b)),z(a),b=_.pending,_.pending!==_.pending_buf_size));)J(_,255&_.gzhead.extra[_.gzindex]),_.gzindex++;_.gzhead.hcrc&&_.pending>b&&(a.adler=g(a.adler,_.pending_buf,_.pending-b,b)),_.gzindex===_.gzhead.extra.length&&(_.gzindex=0,_.status=73)}else _.status=73;if(_.status===73)if(_.gzhead.name){b=_.pending;do{if(_.pending===_.pending_buf_size&&(_.gzhead.hcrc&&_.pending>b&&(a.adler=g(a.adler,_.pending_buf,_.pending-b,b)),z(a),b=_.pending,_.pending===_.pending_buf_size)){N=1;break}N=_.gzindex<_.gzhead.name.length?255&_.gzhead.name.charCodeAt(_.gzindex++):0,J(_,N)}while(N!==0);_.gzhead.hcrc&&_.pending>b&&(a.adler=g(a.adler,_.pending_buf,_.pending-b,b)),N===0&&(_.gzindex=0,_.status=91)}else _.status=91;if(_.status===91)if(_.gzhead.comment){b=_.pending;do{if(_.pending===_.pending_buf_size&&(_.gzhead.hcrc&&_.pending>b&&(a.adler=g(a.adler,_.pending_buf,_.pending-b,b)),z(a),b=_.pending,_.pending===_.pending_buf_size)){N=1;break}N=_.gzindex<_.gzhead.comment.length?255&_.gzhead.comment.charCodeAt(_.gzindex++):0,J(_,N)}while(N!==0);_.gzhead.hcrc&&_.pending>b&&(a.adler=g(a.adler,_.pending_buf,_.pending-b,b)),N===0&&(_.status=103)}else _.status=103;if(_.status===103&&(_.gzhead.hcrc?(_.pending+2>_.pending_buf_size&&z(a),_.pending+2<=_.pending_buf_size&&(J(_,255&a.adler),J(_,a.adler>>8&255),a.adler=0,_.status=D)):_.status=D),_.pending!==0){if(z(a),a.avail_out===0)return _.last_flush=-1,d}else if(a.avail_in===0&&U(L)<=U(B)&&L!==p)return Q(a,-5);if(_.status===666&&a.avail_in!==0)return Q(a,-5);if(a.avail_in!==0||_.lookahead!==0||L!==y&&_.status!==666){var P=_.strategy===2?(function(E,j){for(var G;;){if(E.lookahead===0&&(ot(E),E.lookahead===0)){if(j===y)return l;break}if(E.match_length=0,G=s._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++,G&&(I(E,!1),E.strm.avail_out===0))return l}return E.insert=0,j===p?(I(E,!0),E.strm.avail_out===0?V:W):E.last_lit&&(I(E,!1),E.strm.avail_out===0)?l:R})(_,L):_.strategy===3?(function(E,j){for(var G,Z,$,nt,et=E.window;;){if(E.lookahead<=H){if(ot(E),E.lookahead<=H&&j===y)return l;if(E.lookahead===0)break}if(E.match_length=0,E.lookahead>=T&&0<E.strstart&&(Z=et[$=E.strstart-1])===et[++$]&&Z===et[++$]&&Z===et[++$]){nt=E.strstart+H;do;while(Z===et[++$]&&Z===et[++$]&&Z===et[++$]&&Z===et[++$]&&Z===et[++$]&&Z===et[++$]&&Z===et[++$]&&Z===et[++$]&&$<nt);E.match_length=H-(nt-$),E.match_length>E.lookahead&&(E.match_length=E.lookahead)}if(E.match_length>=T?(G=s._tr_tally(E,1,E.match_length-T),E.lookahead-=E.match_length,E.strstart+=E.match_length,E.match_length=0):(G=s._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++),G&&(I(E,!1),E.strm.avail_out===0))return l}return E.insert=0,j===p?(I(E,!0),E.strm.avail_out===0?V:W):E.last_lit&&(I(E,!1),E.strm.avail_out===0)?l:R})(_,L):n[_.level].func(_,L);if(P!==V&&P!==W||(_.status=666),P===l||P===V)return a.avail_out===0&&(_.last_flush=-1),d;if(P===R&&(L===1?s._tr_align(_):L!==5&&(s._tr_stored_block(_,0,0,!1),L===3&&(q(_.head),_.lookahead===0&&(_.strstart=0,_.block_start=0,_.insert=0))),z(a),a.avail_out===0))return _.last_flush=-1,d}return L!==p?d:_.wrap<=0?1:(_.wrap===2?(J(_,255&a.adler),J(_,a.adler>>8&255),J(_,a.adler>>16&255),J(_,a.adler>>24&255),J(_,255&a.total_in),J(_,a.total_in>>8&255),J(_,a.total_in>>16&255),J(_,a.total_in>>24&255)):(Y(_,a.adler>>>16),Y(_,65535&a.adler)),z(a),0<_.wrap&&(_.wrap=-_.wrap),_.pending!==0?d:1)},r.deflateEnd=function(a){var L;return a&&a.state?(L=a.state.status)!==x&&L!==69&&L!==73&&L!==91&&L!==103&&L!==D&&L!==666?Q(a,w):(a.state=null,L===D?Q(a,-3):d):w},r.deflateSetDictionary=function(a,L){var B,_,b,N,O,P,E,j,G=L.length;if(!a||!a.state||(N=(B=a.state).wrap)===2||N===1&&B.status!==x||B.lookahead)return w;for(N===1&&(a.adler=c(a.adler,L,G,0)),B.wrap=0,G>=B.w_size&&(N===0&&(q(B.head),B.strstart=0,B.block_start=0,B.insert=0),j=new o.Buf8(B.w_size),o.arraySet(j,L,G-B.w_size,B.w_size,0),L=j,G=B.w_size),O=a.avail_in,P=a.next_in,E=a.input,a.avail_in=G,a.next_in=0,a.input=L,ot(B);B.lookahead>=T;){for(_=B.strstart,b=B.lookahead-(T-1);B.ins_h=(B.ins_h<<B.hash_shift^B.window[_+T-1])&B.hash_mask,B.prev[_&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=_,_++,--b;);B.strstart=_,B.lookahead=T-1,ot(B)}return B.strstart+=B.lookahead,B.block_start=B.strstart,B.insert=B.lookahead,B.lookahead=0,B.match_length=B.prev_length=T-1,B.match_available=0,a.next_in=P,a.input=E,a.avail_in=O,B.wrap=N,d},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,i,r){i.exports=function(n,o){var s,c,g,f,y,p,d,w,h,m,u,v,k,C,S,M,A,F,T,H,K,x,D,l,R;s=n.state,c=n.next_in,l=n.input,g=c+(n.avail_in-5),f=n.next_out,R=n.output,y=f-(o-n.avail_out),p=f+(n.avail_out-257),d=s.dmax,w=s.wsize,h=s.whave,m=s.wnext,u=s.window,v=s.hold,k=s.bits,C=s.lencode,S=s.distcode,M=(1<<s.lenbits)-1,A=(1<<s.distbits)-1;t:do{k<15&&(v+=l[c++]<<k,k+=8,v+=l[c++]<<k,k+=8),F=C[v&M];e:for(;;){if(v>>>=T=F>>>24,k-=T,(T=F>>>16&255)===0)R[f++]=65535&F;else{if(!(16&T)){if((64&T)==0){F=C[(65535&F)+(v&(1<<T)-1)];continue e}if(32&T){s.mode=12;break t}n.msg="invalid literal/length code",s.mode=30;break t}H=65535&F,(T&=15)&&(k<T&&(v+=l[c++]<<k,k+=8),H+=v&(1<<T)-1,v>>>=T,k-=T),k<15&&(v+=l[c++]<<k,k+=8,v+=l[c++]<<k,k+=8),F=S[v&A];i:for(;;){if(v>>>=T=F>>>24,k-=T,!(16&(T=F>>>16&255))){if((64&T)==0){F=S[(65535&F)+(v&(1<<T)-1)];continue i}n.msg="invalid distance code",s.mode=30;break t}if(K=65535&F,k<(T&=15)&&(v+=l[c++]<<k,(k+=8)<T&&(v+=l[c++]<<k,k+=8)),d<(K+=v&(1<<T)-1)){n.msg="invalid distance too far back",s.mode=30;break t}if(v>>>=T,k-=T,(T=f-y)<K){if(h<(T=K-T)&&s.sane){n.msg="invalid distance too far back",s.mode=30;break t}if(D=u,(x=0)===m){if(x+=w-T,T<H){for(H-=T;R[f++]=u[x++],--T;);x=f-K,D=R}}else if(m<T){if(x+=w+m-T,(T-=m)<H){for(H-=T;R[f++]=u[x++],--T;);if(x=0,m<H){for(H-=T=m;R[f++]=u[x++],--T;);x=f-K,D=R}}}else if(x+=m-T,T<H){for(H-=T;R[f++]=u[x++],--T;);x=f-K,D=R}for(;2<H;)R[f++]=D[x++],R[f++]=D[x++],R[f++]=D[x++],H-=3;H&&(R[f++]=D[x++],1<H&&(R[f++]=D[x++]))}else{for(x=f-K;R[f++]=R[x++],R[f++]=R[x++],R[f++]=R[x++],2<(H-=3););H&&(R[f++]=R[x++],1<H&&(R[f++]=R[x++]))}break}}break}}while(c<g&&f<p);c-=H=k>>3,v&=(1<<(k-=H<<3))-1,n.next_in=c,n.next_out=f,n.avail_in=c<g?g-c+5:5-(c-g),n.avail_out=f<p?p-f+257:257-(f-p),s.hold=v,s.bits=k}},{}],49:[function(e,i,r){var n=e("../utils/common"),o=e("./adler32"),s=e("./crc32"),c=e("./inffast"),g=e("./inftrees"),f=1,y=2,p=0,d=-2,w=1,h=852,m=592;function u(x){return(x>>>24&255)+(x>>>8&65280)+((65280&x)<<8)+((255&x)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(x){var D;return x&&x.state?(D=x.state,x.total_in=x.total_out=D.total=0,x.msg="",D.wrap&&(x.adler=1&D.wrap),D.mode=w,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new n.Buf32(h),D.distcode=D.distdyn=new n.Buf32(m),D.sane=1,D.back=-1,p):d}function C(x){var D;return x&&x.state?((D=x.state).wsize=0,D.whave=0,D.wnext=0,k(x)):d}function S(x,D){var l,R;return x&&x.state?(R=x.state,D<0?(l=0,D=-D):(l=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?d:(R.window!==null&&R.wbits!==D&&(R.window=null),R.wrap=l,R.wbits=D,C(x))):d}function M(x,D){var l,R;return x?(R=new v,(x.state=R).window=null,(l=S(x,D))!==p&&(x.state=null),l):d}var A,F,T=!0;function H(x){if(T){var D;for(A=new n.Buf32(512),F=new n.Buf32(32),D=0;D<144;)x.lens[D++]=8;for(;D<256;)x.lens[D++]=9;for(;D<280;)x.lens[D++]=7;for(;D<288;)x.lens[D++]=8;for(g(f,x.lens,0,288,A,0,x.work,{bits:9}),D=0;D<32;)x.lens[D++]=5;g(y,x.lens,0,32,F,0,x.work,{bits:5}),T=!1}x.lencode=A,x.lenbits=9,x.distcode=F,x.distbits=5}function K(x,D,l,R){var V,W=x.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new n.Buf8(W.wsize)),R>=W.wsize?(n.arraySet(W.window,D,l-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(R<(V=W.wsize-W.wnext)&&(V=R),n.arraySet(W.window,D,l-R,V,W.wnext),(R-=V)?(n.arraySet(W.window,D,l-R,R,0),W.wnext=R,W.whave=W.wsize):(W.wnext+=V,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=V))),0}r.inflateReset=C,r.inflateReset2=S,r.inflateResetKeep=k,r.inflateInit=function(x){return M(x,15)},r.inflateInit2=M,r.inflate=function(x,D){var l,R,V,W,Q,U,q,z,I,J,Y,X,ot,dt,tt,rt,lt,st,ft,ut,a,L,B,_,b=0,N=new n.Buf8(4),O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!x||!x.state||!x.output||!x.input&&x.avail_in!==0)return d;(l=x.state).mode===12&&(l.mode=13),Q=x.next_out,V=x.output,q=x.avail_out,W=x.next_in,R=x.input,U=x.avail_in,z=l.hold,I=l.bits,J=U,Y=q,L=p;t:for(;;)switch(l.mode){case w:if(l.wrap===0){l.mode=13;break}for(;I<16;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(2&l.wrap&&z===35615){N[l.check=0]=255&z,N[1]=z>>>8&255,l.check=s(l.check,N,2,0),I=z=0,l.mode=2;break}if(l.flags=0,l.head&&(l.head.done=!1),!(1&l.wrap)||(((255&z)<<8)+(z>>8))%31){x.msg="incorrect header check",l.mode=30;break}if((15&z)!=8){x.msg="unknown compression method",l.mode=30;break}if(I-=4,a=8+(15&(z>>>=4)),l.wbits===0)l.wbits=a;else if(a>l.wbits){x.msg="invalid window size",l.mode=30;break}l.dmax=1<<a,x.adler=l.check=1,l.mode=512&z?10:12,I=z=0;break;case 2:for(;I<16;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(l.flags=z,(255&l.flags)!=8){x.msg="unknown compression method",l.mode=30;break}if(57344&l.flags){x.msg="unknown header flags set",l.mode=30;break}l.head&&(l.head.text=z>>8&1),512&l.flags&&(N[0]=255&z,N[1]=z>>>8&255,l.check=s(l.check,N,2,0)),I=z=0,l.mode=3;case 3:for(;I<32;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}l.head&&(l.head.time=z),512&l.flags&&(N[0]=255&z,N[1]=z>>>8&255,N[2]=z>>>16&255,N[3]=z>>>24&255,l.check=s(l.check,N,4,0)),I=z=0,l.mode=4;case 4:for(;I<16;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}l.head&&(l.head.xflags=255&z,l.head.os=z>>8),512&l.flags&&(N[0]=255&z,N[1]=z>>>8&255,l.check=s(l.check,N,2,0)),I=z=0,l.mode=5;case 5:if(1024&l.flags){for(;I<16;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}l.length=z,l.head&&(l.head.extra_len=z),512&l.flags&&(N[0]=255&z,N[1]=z>>>8&255,l.check=s(l.check,N,2,0)),I=z=0}else l.head&&(l.head.extra=null);l.mode=6;case 6:if(1024&l.flags&&(U<(X=l.length)&&(X=U),X&&(l.head&&(a=l.head.extra_len-l.length,l.head.extra||(l.head.extra=new Array(l.head.extra_len)),n.arraySet(l.head.extra,R,W,X,a)),512&l.flags&&(l.check=s(l.check,R,X,W)),U-=X,W+=X,l.length-=X),l.length))break t;l.length=0,l.mode=7;case 7:if(2048&l.flags){if(U===0)break t;for(X=0;a=R[W+X++],l.head&&a&&l.length<65536&&(l.head.name+=String.fromCharCode(a)),a&&X<U;);if(512&l.flags&&(l.check=s(l.check,R,X,W)),U-=X,W+=X,a)break t}else l.head&&(l.head.name=null);l.length=0,l.mode=8;case 8:if(4096&l.flags){if(U===0)break t;for(X=0;a=R[W+X++],l.head&&a&&l.length<65536&&(l.head.comment+=String.fromCharCode(a)),a&&X<U;);if(512&l.flags&&(l.check=s(l.check,R,X,W)),U-=X,W+=X,a)break t}else l.head&&(l.head.comment=null);l.mode=9;case 9:if(512&l.flags){for(;I<16;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(z!==(65535&l.check)){x.msg="header crc mismatch",l.mode=30;break}I=z=0}l.head&&(l.head.hcrc=l.flags>>9&1,l.head.done=!0),x.adler=l.check=0,l.mode=12;break;case 10:for(;I<32;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}x.adler=l.check=u(z),I=z=0,l.mode=11;case 11:if(l.havedict===0)return x.next_out=Q,x.avail_out=q,x.next_in=W,x.avail_in=U,l.hold=z,l.bits=I,2;x.adler=l.check=1,l.mode=12;case 12:if(D===5||D===6)break t;case 13:if(l.last){z>>>=7&I,I-=7&I,l.mode=27;break}for(;I<3;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}switch(l.last=1&z,I-=1,3&(z>>>=1)){case 0:l.mode=14;break;case 1:if(H(l),l.mode=20,D!==6)break;z>>>=2,I-=2;break t;case 2:l.mode=17;break;case 3:x.msg="invalid block type",l.mode=30}z>>>=2,I-=2;break;case 14:for(z>>>=7&I,I-=7&I;I<32;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if((65535&z)!=(z>>>16^65535)){x.msg="invalid stored block lengths",l.mode=30;break}if(l.length=65535&z,I=z=0,l.mode=15,D===6)break t;case 15:l.mode=16;case 16:if(X=l.length){if(U<X&&(X=U),q<X&&(X=q),X===0)break t;n.arraySet(V,R,W,X,Q),U-=X,W+=X,q-=X,Q+=X,l.length-=X;break}l.mode=12;break;case 17:for(;I<14;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(l.nlen=257+(31&z),z>>>=5,I-=5,l.ndist=1+(31&z),z>>>=5,I-=5,l.ncode=4+(15&z),z>>>=4,I-=4,286<l.nlen||30<l.ndist){x.msg="too many length or distance symbols",l.mode=30;break}l.have=0,l.mode=18;case 18:for(;l.have<l.ncode;){for(;I<3;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}l.lens[O[l.have++]]=7&z,z>>>=3,I-=3}for(;l.have<19;)l.lens[O[l.have++]]=0;if(l.lencode=l.lendyn,l.lenbits=7,B={bits:l.lenbits},L=g(0,l.lens,0,19,l.lencode,0,l.work,B),l.lenbits=B.bits,L){x.msg="invalid code lengths set",l.mode=30;break}l.have=0,l.mode=19;case 19:for(;l.have<l.nlen+l.ndist;){for(;rt=(b=l.lencode[z&(1<<l.lenbits)-1])>>>16&255,lt=65535&b,!((tt=b>>>24)<=I);){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(lt<16)z>>>=tt,I-=tt,l.lens[l.have++]=lt;else{if(lt===16){for(_=tt+2;I<_;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(z>>>=tt,I-=tt,l.have===0){x.msg="invalid bit length repeat",l.mode=30;break}a=l.lens[l.have-1],X=3+(3&z),z>>>=2,I-=2}else if(lt===17){for(_=tt+3;I<_;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}I-=tt,a=0,X=3+(7&(z>>>=tt)),z>>>=3,I-=3}else{for(_=tt+7;I<_;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}I-=tt,a=0,X=11+(127&(z>>>=tt)),z>>>=7,I-=7}if(l.have+X>l.nlen+l.ndist){x.msg="invalid bit length repeat",l.mode=30;break}for(;X--;)l.lens[l.have++]=a}}if(l.mode===30)break;if(l.lens[256]===0){x.msg="invalid code -- missing end-of-block",l.mode=30;break}if(l.lenbits=9,B={bits:l.lenbits},L=g(f,l.lens,0,l.nlen,l.lencode,0,l.work,B),l.lenbits=B.bits,L){x.msg="invalid literal/lengths set",l.mode=30;break}if(l.distbits=6,l.distcode=l.distdyn,B={bits:l.distbits},L=g(y,l.lens,l.nlen,l.ndist,l.distcode,0,l.work,B),l.distbits=B.bits,L){x.msg="invalid distances set",l.mode=30;break}if(l.mode=20,D===6)break t;case 20:l.mode=21;case 21:if(6<=U&&258<=q){x.next_out=Q,x.avail_out=q,x.next_in=W,x.avail_in=U,l.hold=z,l.bits=I,c(x,Y),Q=x.next_out,V=x.output,q=x.avail_out,W=x.next_in,R=x.input,U=x.avail_in,z=l.hold,I=l.bits,l.mode===12&&(l.back=-1);break}for(l.back=0;rt=(b=l.lencode[z&(1<<l.lenbits)-1])>>>16&255,lt=65535&b,!((tt=b>>>24)<=I);){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(rt&&(240&rt)==0){for(st=tt,ft=rt,ut=lt;rt=(b=l.lencode[ut+((z&(1<<st+ft)-1)>>st)])>>>16&255,lt=65535&b,!(st+(tt=b>>>24)<=I);){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}z>>>=st,I-=st,l.back+=st}if(z>>>=tt,I-=tt,l.back+=tt,l.length=lt,rt===0){l.mode=26;break}if(32&rt){l.back=-1,l.mode=12;break}if(64&rt){x.msg="invalid literal/length code",l.mode=30;break}l.extra=15&rt,l.mode=22;case 22:if(l.extra){for(_=l.extra;I<_;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}l.length+=z&(1<<l.extra)-1,z>>>=l.extra,I-=l.extra,l.back+=l.extra}l.was=l.length,l.mode=23;case 23:for(;rt=(b=l.distcode[z&(1<<l.distbits)-1])>>>16&255,lt=65535&b,!((tt=b>>>24)<=I);){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if((240&rt)==0){for(st=tt,ft=rt,ut=lt;rt=(b=l.distcode[ut+((z&(1<<st+ft)-1)>>st)])>>>16&255,lt=65535&b,!(st+(tt=b>>>24)<=I);){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}z>>>=st,I-=st,l.back+=st}if(z>>>=tt,I-=tt,l.back+=tt,64&rt){x.msg="invalid distance code",l.mode=30;break}l.offset=lt,l.extra=15&rt,l.mode=24;case 24:if(l.extra){for(_=l.extra;I<_;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}l.offset+=z&(1<<l.extra)-1,z>>>=l.extra,I-=l.extra,l.back+=l.extra}if(l.offset>l.dmax){x.msg="invalid distance too far back",l.mode=30;break}l.mode=25;case 25:if(q===0)break t;if(X=Y-q,l.offset>X){if((X=l.offset-X)>l.whave&&l.sane){x.msg="invalid distance too far back",l.mode=30;break}ot=X>l.wnext?(X-=l.wnext,l.wsize-X):l.wnext-X,X>l.length&&(X=l.length),dt=l.window}else dt=V,ot=Q-l.offset,X=l.length;for(q<X&&(X=q),q-=X,l.length-=X;V[Q++]=dt[ot++],--X;);l.length===0&&(l.mode=21);break;case 26:if(q===0)break t;V[Q++]=l.length,q--,l.mode=21;break;case 27:if(l.wrap){for(;I<32;){if(U===0)break t;U--,z|=R[W++]<<I,I+=8}if(Y-=q,x.total_out+=Y,l.total+=Y,Y&&(x.adler=l.check=l.flags?s(l.check,V,Y,Q-Y):o(l.check,V,Y,Q-Y)),Y=q,(l.flags?z:u(z))!==l.check){x.msg="incorrect data check",l.mode=30;break}I=z=0}l.mode=28;case 28:if(l.wrap&&l.flags){for(;I<32;){if(U===0)break t;U--,z+=R[W++]<<I,I+=8}if(z!==(4294967295&l.total)){x.msg="incorrect length check",l.mode=30;break}I=z=0}l.mode=29;case 29:L=1;break t;case 30:L=-3;break t;case 31:return-4;default:return d}return x.next_out=Q,x.avail_out=q,x.next_in=W,x.avail_in=U,l.hold=z,l.bits=I,(l.wsize||Y!==x.avail_out&&l.mode<30&&(l.mode<27||D!==4))&&K(x,x.output,x.next_out,Y-x.avail_out)?(l.mode=31,-4):(J-=x.avail_in,Y-=x.avail_out,x.total_in+=J,x.total_out+=Y,l.total+=Y,l.wrap&&Y&&(x.adler=l.check=l.flags?s(l.check,V,Y,x.next_out-Y):o(l.check,V,Y,x.next_out-Y)),x.data_type=l.bits+(l.last?64:0)+(l.mode===12?128:0)+(l.mode===20||l.mode===15?256:0),(J==0&&Y===0||D===4)&&L===p&&(L=-5),L)},r.inflateEnd=function(x){if(!x||!x.state)return d;var D=x.state;return D.window&&(D.window=null),x.state=null,p},r.inflateGetHeader=function(x,D){var l;return x&&x.state?(2&(l=x.state).wrap)==0?d:((l.head=D).done=!1,p):d},r.inflateSetDictionary=function(x,D){var l,R=D.length;return x&&x.state?(l=x.state).wrap!==0&&l.mode!==11?d:l.mode===11&&o(1,D,R,0)!==l.check?-3:K(x,D,R,R)?(l.mode=31,-4):(l.havedict=1,p):d},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,i,r){var n=e("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],g=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(f,y,p,d,w,h,m,u){var v,k,C,S,M,A,F,T,H,K=u.bits,x=0,D=0,l=0,R=0,V=0,W=0,Q=0,U=0,q=0,z=0,I=null,J=0,Y=new n.Buf16(16),X=new n.Buf16(16),ot=null,dt=0;for(x=0;x<=15;x++)Y[x]=0;for(D=0;D<d;D++)Y[y[p+D]]++;for(V=K,R=15;1<=R&&Y[R]===0;R--);if(R<V&&(V=R),R===0)return w[h++]=20971520,w[h++]=20971520,u.bits=1,0;for(l=1;l<R&&Y[l]===0;l++);for(V<l&&(V=l),x=U=1;x<=15;x++)if(U<<=1,(U-=Y[x])<0)return-1;if(0<U&&(f===0||R!==1))return-1;for(X[1]=0,x=1;x<15;x++)X[x+1]=X[x]+Y[x];for(D=0;D<d;D++)y[p+D]!==0&&(m[X[y[p+D]]++]=D);if(A=f===0?(I=ot=m,19):f===1?(I=o,J-=257,ot=s,dt-=257,256):(I=c,ot=g,-1),x=l,M=h,Q=D=z=0,C=-1,S=(q=1<<(W=V))-1,f===1&&852<q||f===2&&592<q)return 1;for(;;){for(F=x-Q,H=m[D]<A?(T=0,m[D]):m[D]>A?(T=ot[dt+m[D]],I[J+m[D]]):(T=96,0),v=1<<x-Q,l=k=1<<W;w[M+(z>>Q)+(k-=v)]=F<<24|T<<16|H|0,k!==0;);for(v=1<<x-1;z&v;)v>>=1;if(v!==0?(z&=v-1,z+=v):z=0,D++,--Y[x]==0){if(x===R)break;x=y[p+m[D]]}if(V<x&&(z&S)!==C){for(Q===0&&(Q=V),M+=l,U=1<<(W=x-Q);W+Q<R&&!((U-=Y[W+Q])<=0);)W++,U<<=1;if(q+=1<<W,f===1&&852<q||f===2&&592<q)return 1;w[C=z&S]=V<<24|W<<16|M-h|0}}return z!==0&&(w[M+z]=x-Q<<24|64<<16|0),u.bits=V,0}},{"../utils/common":41}],51:[function(e,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,i,r){var n=e("../utils/common"),o=0,s=1;function c(b){for(var N=b.length;0<=--N;)b[N]=0}var g=0,f=29,y=256,p=y+1+f,d=30,w=19,h=2*p+1,m=15,u=16,v=7,k=256,C=16,S=17,M=18,A=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],H=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],K=new Array(2*(p+2));c(K);var x=new Array(2*d);c(x);var D=new Array(512);c(D);var l=new Array(256);c(l);var R=new Array(f);c(R);var V,W,Q,U=new Array(d);function q(b,N,O,P,E){this.static_tree=b,this.extra_bits=N,this.extra_base=O,this.elems=P,this.max_length=E,this.has_stree=b&&b.length}function z(b,N){this.dyn_tree=b,this.max_code=0,this.stat_desc=N}function I(b){return b<256?D[b]:D[256+(b>>>7)]}function J(b,N){b.pending_buf[b.pending++]=255&N,b.pending_buf[b.pending++]=N>>>8&255}function Y(b,N,O){b.bi_valid>u-O?(b.bi_buf|=N<<b.bi_valid&65535,J(b,b.bi_buf),b.bi_buf=N>>u-b.bi_valid,b.bi_valid+=O-u):(b.bi_buf|=N<<b.bi_valid&65535,b.bi_valid+=O)}function X(b,N,O){Y(b,O[2*N],O[2*N+1])}function ot(b,N){for(var O=0;O|=1&b,b>>>=1,O<<=1,0<--N;);return O>>>1}function dt(b,N,O){var P,E,j=new Array(m+1),G=0;for(P=1;P<=m;P++)j[P]=G=G+O[P-1]<<1;for(E=0;E<=N;E++){var Z=b[2*E+1];Z!==0&&(b[2*E]=ot(j[Z]++,Z))}}function tt(b){var N;for(N=0;N<p;N++)b.dyn_ltree[2*N]=0;for(N=0;N<d;N++)b.dyn_dtree[2*N]=0;for(N=0;N<w;N++)b.bl_tree[2*N]=0;b.dyn_ltree[2*k]=1,b.opt_len=b.static_len=0,b.last_lit=b.matches=0}function rt(b){8<b.bi_valid?J(b,b.bi_buf):0<b.bi_valid&&(b.pending_buf[b.pending++]=b.bi_buf),b.bi_buf=0,b.bi_valid=0}function lt(b,N,O,P){var E=2*N,j=2*O;return b[E]<b[j]||b[E]===b[j]&&P[N]<=P[O]}function st(b,N,O){for(var P=b.heap[O],E=O<<1;E<=b.heap_len&&(E<b.heap_len&&lt(N,b.heap[E+1],b.heap[E],b.depth)&&E++,!lt(N,P,b.heap[E],b.depth));)b.heap[O]=b.heap[E],O=E,E<<=1;b.heap[O]=P}function ft(b,N,O){var P,E,j,G,Z=0;if(b.last_lit!==0)for(;P=b.pending_buf[b.d_buf+2*Z]<<8|b.pending_buf[b.d_buf+2*Z+1],E=b.pending_buf[b.l_buf+Z],Z++,P===0?X(b,E,N):(X(b,(j=l[E])+y+1,N),(G=A[j])!==0&&Y(b,E-=R[j],G),X(b,j=I(--P),O),(G=F[j])!==0&&Y(b,P-=U[j],G)),Z<b.last_lit;);X(b,k,N)}function ut(b,N){var O,P,E,j=N.dyn_tree,G=N.stat_desc.static_tree,Z=N.stat_desc.has_stree,$=N.stat_desc.elems,nt=-1;for(b.heap_len=0,b.heap_max=h,O=0;O<$;O++)j[2*O]!==0?(b.heap[++b.heap_len]=nt=O,b.depth[O]=0):j[2*O+1]=0;for(;b.heap_len<2;)j[2*(E=b.heap[++b.heap_len]=nt<2?++nt:0)]=1,b.depth[E]=0,b.opt_len--,Z&&(b.static_len-=G[2*E+1]);for(N.max_code=nt,O=b.heap_len>>1;1<=O;O--)st(b,j,O);for(E=$;O=b.heap[1],b.heap[1]=b.heap[b.heap_len--],st(b,j,1),P=b.heap[1],b.heap[--b.heap_max]=O,b.heap[--b.heap_max]=P,j[2*E]=j[2*O]+j[2*P],b.depth[E]=(b.depth[O]>=b.depth[P]?b.depth[O]:b.depth[P])+1,j[2*O+1]=j[2*P+1]=E,b.heap[1]=E++,st(b,j,1),2<=b.heap_len;);b.heap[--b.heap_max]=b.heap[1],(function(et,ht){var vt,pt,bt,at,_t,Ct,mt=ht.dyn_tree,At=ht.max_code,Ot=ht.stat_desc.static_tree,Pt=ht.stat_desc.has_stree,Ft=ht.stat_desc.extra_bits,Tt=ht.stat_desc.extra_base,wt=ht.stat_desc.max_length,xt=0;for(at=0;at<=m;at++)et.bl_count[at]=0;for(mt[2*et.heap[et.heap_max]+1]=0,vt=et.heap_max+1;vt<h;vt++)wt<(at=mt[2*mt[2*(pt=et.heap[vt])+1]+1]+1)&&(at=wt,xt++),mt[2*pt+1]=at,At<pt||(et.bl_count[at]++,_t=0,Tt<=pt&&(_t=Ft[pt-Tt]),Ct=mt[2*pt],et.opt_len+=Ct*(at+_t),Pt&&(et.static_len+=Ct*(Ot[2*pt+1]+_t)));if(xt!==0){do{for(at=wt-1;et.bl_count[at]===0;)at--;et.bl_count[at]--,et.bl_count[at+1]+=2,et.bl_count[wt]--,xt-=2}while(0<xt);for(at=wt;at!==0;at--)for(pt=et.bl_count[at];pt!==0;)At<(bt=et.heap[--vt])||(mt[2*bt+1]!==at&&(et.opt_len+=(at-mt[2*bt+1])*mt[2*bt],mt[2*bt+1]=at),pt--)}})(b,N),dt(j,nt,b.bl_count)}function a(b,N,O){var P,E,j=-1,G=N[1],Z=0,$=7,nt=4;for(G===0&&($=138,nt=3),N[2*(O+1)+1]=65535,P=0;P<=O;P++)E=G,G=N[2*(P+1)+1],++Z<$&&E===G||(Z<nt?b.bl_tree[2*E]+=Z:E!==0?(E!==j&&b.bl_tree[2*E]++,b.bl_tree[2*C]++):Z<=10?b.bl_tree[2*S]++:b.bl_tree[2*M]++,j=E,nt=(Z=0)===G?($=138,3):E===G?($=6,3):($=7,4))}function L(b,N,O){var P,E,j=-1,G=N[1],Z=0,$=7,nt=4;for(G===0&&($=138,nt=3),P=0;P<=O;P++)if(E=G,G=N[2*(P+1)+1],!(++Z<$&&E===G)){if(Z<nt)for(;X(b,E,b.bl_tree),--Z!=0;);else E!==0?(E!==j&&(X(b,E,b.bl_tree),Z--),X(b,C,b.bl_tree),Y(b,Z-3,2)):Z<=10?(X(b,S,b.bl_tree),Y(b,Z-3,3)):(X(b,M,b.bl_tree),Y(b,Z-11,7));j=E,nt=(Z=0)===G?($=138,3):E===G?($=6,3):($=7,4)}}c(U);var B=!1;function _(b,N,O,P){Y(b,(g<<1)+(P?1:0),3),(function(E,j,G,Z){rt(E),J(E,G),J(E,~G),n.arraySet(E.pending_buf,E.window,j,G,E.pending),E.pending+=G})(b,N,O)}r._tr_init=function(b){B||((function(){var N,O,P,E,j,G=new Array(m+1);for(E=P=0;E<f-1;E++)for(R[E]=P,N=0;N<1<<A[E];N++)l[P++]=E;for(l[P-1]=E,E=j=0;E<16;E++)for(U[E]=j,N=0;N<1<<F[E];N++)D[j++]=E;for(j>>=7;E<d;E++)for(U[E]=j<<7,N=0;N<1<<F[E]-7;N++)D[256+j++]=E;for(O=0;O<=m;O++)G[O]=0;for(N=0;N<=143;)K[2*N+1]=8,N++,G[8]++;for(;N<=255;)K[2*N+1]=9,N++,G[9]++;for(;N<=279;)K[2*N+1]=7,N++,G[7]++;for(;N<=287;)K[2*N+1]=8,N++,G[8]++;for(dt(K,p+1,G),N=0;N<d;N++)x[2*N+1]=5,x[2*N]=ot(N,5);V=new q(K,A,y+1,p,m),W=new q(x,F,0,d,m),Q=new q(new Array(0),T,0,w,v)})(),B=!0),b.l_desc=new z(b.dyn_ltree,V),b.d_desc=new z(b.dyn_dtree,W),b.bl_desc=new z(b.bl_tree,Q),b.bi_buf=0,b.bi_valid=0,tt(b)},r._tr_stored_block=_,r._tr_flush_block=function(b,N,O,P){var E,j,G=0;0<b.level?(b.strm.data_type===2&&(b.strm.data_type=(function(Z){var $,nt=4093624447;for($=0;$<=31;$++,nt>>>=1)if(1&nt&&Z.dyn_ltree[2*$]!==0)return o;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return s;for($=32;$<y;$++)if(Z.dyn_ltree[2*$]!==0)return s;return o})(b)),ut(b,b.l_desc),ut(b,b.d_desc),G=(function(Z){var $;for(a(Z,Z.dyn_ltree,Z.l_desc.max_code),a(Z,Z.dyn_dtree,Z.d_desc.max_code),ut(Z,Z.bl_desc),$=w-1;3<=$&&Z.bl_tree[2*H[$]+1]===0;$--);return Z.opt_len+=3*($+1)+5+5+4,$})(b),E=b.opt_len+3+7>>>3,(j=b.static_len+3+7>>>3)<=E&&(E=j)):E=j=O+5,O+4<=E&&N!==-1?_(b,N,O,P):b.strategy===4||j===E?(Y(b,2+(P?1:0),3),ft(b,K,x)):(Y(b,4+(P?1:0),3),(function(Z,$,nt,et){var ht;for(Y(Z,$-257,5),Y(Z,nt-1,5),Y(Z,et-4,4),ht=0;ht<et;ht++)Y(Z,Z.bl_tree[2*H[ht]+1],3);L(Z,Z.dyn_ltree,$-1),L(Z,Z.dyn_dtree,nt-1)})(b,b.l_desc.max_code+1,b.d_desc.max_code+1,G+1),ft(b,b.dyn_ltree,b.dyn_dtree)),tt(b),P&&rt(b)},r._tr_tally=function(b,N,O){return b.pending_buf[b.d_buf+2*b.last_lit]=N>>>8&255,b.pending_buf[b.d_buf+2*b.last_lit+1]=255&N,b.pending_buf[b.l_buf+b.last_lit]=255&O,b.last_lit++,N===0?b.dyn_ltree[2*O]++:(b.matches++,N--,b.dyn_ltree[2*(l[O]+y+1)]++,b.dyn_dtree[2*I(N)]++),b.last_lit===b.lit_bufsize-1},r._tr_align=function(b){Y(b,2,3),X(b,k,K),(function(N){N.bi_valid===16?(J(N,N.bi_buf),N.bi_buf=0,N.bi_valid=0):8<=N.bi_valid&&(N.pending_buf[N.pending++]=255&N.bi_buf,N.bi_buf>>=8,N.bi_valid-=8)})(b)}},{"../utils/common":41}],53:[function(e,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,i,r){(function(n){(function(o,s){if(!o.setImmediate){var c,g,f,y,p=1,d={},w=!1,h=o.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(o);m=m&&m.setTimeout?m:o,c={}.toString.call(o.process)==="[object process]"?function(C){process.nextTick(function(){v(C)})}:(function(){if(o.postMessage&&!o.importScripts){var C=!0,S=o.onmessage;return o.onmessage=function(){C=!1},o.postMessage("","*"),o.onmessage=S,C}})()?(y="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",k,!1):o.attachEvent("onmessage",k),function(C){o.postMessage(y+C,"*")}):o.MessageChannel?((f=new MessageChannel).port1.onmessage=function(C){v(C.data)},function(C){f.port2.postMessage(C)}):h&&"onreadystatechange"in h.createElement("script")?(g=h.documentElement,function(C){var S=h.createElement("script");S.onreadystatechange=function(){v(C),S.onreadystatechange=null,g.removeChild(S),S=null},g.appendChild(S)}):function(C){setTimeout(v,0,C)},m.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var S=new Array(arguments.length-1),M=0;M<S.length;M++)S[M]=arguments[M+1];var A={callback:C,args:S};return d[p]=A,c(p),p++},m.clearImmediate=u}function u(C){delete d[C]}function v(C){if(w)setTimeout(v,0,C);else{var S=d[C];if(S){w=!0;try{(function(M){var A=M.callback,F=M.args;switch(F.length){case 0:A();break;case 1:A(F[0]);break;case 2:A(F[0],F[1]);break;case 3:A(F[0],F[1],F[2]);break;default:A.apply(s,F)}})(S)}finally{u(C),w=!1}}}}function k(C){C.source===o&&typeof C.data=="string"&&C.data.indexOf(y)===0&&v(+C.data.slice(y.length))}})(typeof self>"u"?n===void 0?this:n:self)}).call(this,typeof kt<"u"?kt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Et)),Et.exports}var ie=ee();const re=te(ie);class Lt{generate(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2)}}class zt{idGenerator;constructor(){this.idGenerator=new Lt}async extractMindMapData(t){const e=new re;try{const r=(await e.loadAsync(t)).file("content.json");if(!r)throw new Error("Invalid XMind file: content.json not found");const n=await r.async("text"),o=JSON.parse(n);if(!Array.isArray(o)||o.length===0)throw new Error("Invalid XMind file: No content found");const s=o[0];return{nodeData:await this.transformTopic(s.rootTopic,e,!0),theme:"default",direction:1}}catch(i){throw console.error("Failed to parse XMind file",i),new Error("Failed to import XMind file",{cause:i})}}async transformTopic(t,e,i=!1){const r=this.idGenerator.generate(),n=[];if(t.children&&t.children.attached)for(const s of t.children.attached)n.push(await this.transformTopic(s,e,!1));let o;if(t.image&&t.image.src&&t.image.src.startsWith("xap:")){const s=t.image.src.substring(4),c=e.file(s);if(c){const g=await c.async("base64"),f=s.split(".").pop()?.toLowerCase();let y="image/png";f==="jpg"||f==="jpeg"?y="image/jpeg":f==="svg"?y="image/svg+xml":f==="gif"&&(y="image/gif"),o=`data:${y};base64,${g}`}}if(t.title&&o){const s={id:r,topic:t.title,root:i,children:n},g={id:this.idGenerator.generate(),topic:"",image:o,children:[]};return s.children?.push(g),s}else return o?{id:r,topic:"",image:o,root:i,children:n}:{id:r,topic:t.title||"",root:i,children:n}}}class Bt{generate(t){const e=t.querySelectorAll("svg");let i=null;for(let K=0;K<e.length;K++){const x=e[K];if(x.style.zIndex==="0"&&x.style.position==="absolute"){i=x;break}}!i&&e.length>0&&e[0].parentElement===t&&(i=e[0]);const r=t.querySelectorAll("div");let n=null;for(let K=0;K<r.length;K++){const x=r[K];if(x.style.zIndex==="1"&&x.style.position==="absolute"){n=x;break}}if(!i||!n)throw new Error("Could not find mind map content layers.");let o=1/0,s=1/0,c=-1/0,g=-1/0;const f=n.children;if(f.length===0)o=0,s=0,c=800,g=600;else for(let K=0;K<f.length;K++){const x=f[K],D=parseFloat(x.style.left||"0"),l=parseFloat(x.style.top||"0"),R=x.offsetWidth,V=x.offsetHeight,W=l-V/2,Q=l+V/2;D<o&&(o=D),W<s&&(s=W),D+R>c&&(c=D+R),Q>g&&(g=Q)}const y=50;o-=y,s-=y,c+=y,g+=y;const p=c-o,d=g-s,w=window.getComputedStyle(t),h=["--mindmap-connection-color","--mindmap-root-color","--mindmap-child-color","--mindmap-root-border","--mindmap-child-border","--mindmap-root-background","--mindmap-child-background","--vscode-editor-foreground","--vscode-editor-background","--vscode-widget-border","--vscode-focusBorder"],m=[];h.forEach(K=>{const x=w.getPropertyValue(K).trim();x&&m.push(`${K}: ${x};`)});const u=m.join(" "),v=w.fontFamily,k=document.createElementNS("http://www.w3.org/2000/svg","svg");k.setAttribute("xmlns","http://www.w3.org/2000/svg"),k.setAttribute("width",p.toString()),k.setAttribute("height",d.toString()),k.setAttribute("viewBox",`0 0 ${p} ${d}`),k.style.cssText=u;const C=document.createElementNS("http://www.w3.org/2000/svg","rect");C.setAttribute("x","0"),C.setAttribute("y","0"),C.setAttribute("width",p.toString()),C.setAttribute("height",d.toString()),C.setAttribute("fill",w.backgroundColor||"#ffffff"),k.appendChild(C);const S=document.createElementNS("http://www.w3.org/2000/svg","g");S.setAttribute("transform",`translate(${-o}, ${-s})`),i.querySelectorAll("path").forEach(K=>{const x=K.cloneNode(!0),D=window.getComputedStyle(K);let l=D.stroke;(!l||l==="none")&&(l=K.style.stroke),(!l||l==="none")&&(l="#cccccc"),x.style.stroke=l;let R=D.strokeWidth;(!R||R==="0px"||R==="auto")&&(R=K.getAttribute("stroke-width")||"2px"),x.style.strokeWidth=R,x.style.fill="none",S.appendChild(x)});const A=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");A.setAttribute("x","0"),A.setAttribute("y","0"),A.setAttribute("width",(c+y).toString()),A.setAttribute("height",(g+y).toString()),A.style.overflow="visible";const F=document.createElement("div");F.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),F.style.cssText=`position: relative; width: 100%; height: 100%; font-family: ${v}; ${u}`;const T=n.children;for(let K=0;K<T.length;K++){const x=T[K].cloneNode(!0);F.appendChild(x)}return A.appendChild(F),S.appendChild(A),k.appendChild(S),new XMLSerializer().serializeToString(k)}}class Rt{async exportToSvg(t,e){try{const r=new Bt().generate(t),n=new Blob([r],{type:"image/svg+xml;charset=utf-8"});await this.saveFile(n,"mindmap.svg",[{description:"SVG File",accept:{"image/svg+xml":[".svg"]}}],e)}catch(i){i.name!=="AbortError"&&(console.error("Failed to export SVG:",i),alert("Failed to export SVG."))}}async exportToPng(t,e){try{const r=new Bt().generate(t),o=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(r)))}`;await new Promise((s,c)=>{const g=new Image;g.onload=()=>{try{const f=document.createElement("canvas");f.width=g.width,f.height=g.height;const y=f.getContext("2d");if(!y)throw new Error("Could not get canvas context");y.drawImage(g,0,0),f.toBlob(p=>{p?this.saveFile(p,"mindmap.png",[{description:"PNG Image",accept:{"image/png":[".png"]}}],e).then(()=>s()).catch(d=>c(d instanceof Error?d:new Error(String(d)))):c(new Error("Failed to generate PNG blob."))},"image/png")}catch(f){c(f instanceof Error?f:new Error(String(f)))}},g.onerror=()=>{c(new Error("Failed to load SVG for PNG conversion"))},g.src=o})}catch(i){i.name!=="AbortError"&&(console.error("Failed to export PNG:",i),alert("Failed to export PNG."))}}async showSavePicker(t){return typeof window.showSaveFilePicker!="function"?(alert("Your browser does not support the File System Access API required for saving files."),null):window.showSaveFilePicker(t)}async saveFile(t,e,i,r){if(r){const s=e.split(".").pop();await r.onExportFile(t,e,s);return}const n=await this.showSavePicker({suggestedName:e,types:i});if(!n)return;const o=await n.createWritable();await o.write(t),await o.close()}}class ne{async export(t,e){const i=this.generateMarkdown(t),r=new Blob([i],{type:"text/markdown;charset=utf-8"});await this.saveFile(r,"mindmap.md",e)}generateMarkdown(t){const e=t.root;if(!e)return"";const i=[];return this.processNode(e,0,i),i.join(`
56
+ `)}processNode(t,e,i){const r=this.getNodeText(t);if(e===0)i.push(`# ${r}`);else if(e===1)i.push(`## ${r}`);else{const n=" ".repeat(e-2);i.push(`${n}- ${r}`)}for(const n of t.children)this.processNode(n,e+1,i)}getNodeText(t){return t.image?"[image node]":t.topic}async saveFile(t,e,i){try{if(i){await i.onExportFile(t,e,"md");return}if(typeof window.showSaveFilePicker=="function"){const n=await(await window.showSaveFilePicker({suggestedName:e,types:[{description:"Markdown File",accept:{"text/markdown":[".md"]}}]})).createWritable();await n.write(t),await n.close()}else{const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}}catch(r){r.name!=="AbortError"&&(console.error("Failed to save file:",r),alert("Failed to save file."))}}}class oe{mindMap;service;renderer;eventBus;styleEditor;commandPalette;interactionHandler;layoutSwitcher;fileHandler;selectedNodeId=null;layoutMode="Right";panX=0;panY=0;targetPanX=0;targetPanY=0;scale=1;isBatching=!1;animationFrameId=null;maxWidth=-1;pendingNodeCreation=!1;savedCustomStyles={rootNode:{border:"2px solid #aeb6bf",background:"#ebf5fb",color:"#2e4053"},childNode:{border:"1px solid #d5d8dc",background:"#fdfefe",color:"#2c3e50"},connection:{color:"#abb2b9"}};constructor(t,e,i,r,n,o){this.mindMap=t,this.service=e,this.renderer=i,this.styleEditor=r,this.eventBus=n,this.fileHandler=o,this.commandPalette=new Qt(this.renderer.container,{onInput:s=>this.handleSearchInput(s),onSelect:s=>this.handleSearchResultSelect(s),onIconSelect:s=>this.handleIconSelect(s),onCommandSelect:s=>this.handleCommandSelect(s),onClose:()=>{this.interactionHandler&&this.interactionHandler.container.focus()}})}setInteractionHandler(t){this.interactionHandler=t}setLayoutSwitcher(t){this.layoutSwitcher=t}init(t){this.panX=t*.2,this.targetPanX=this.panX;const e=this.mindMap.theme;if(e==="custom"){const i=ct.getInstance();i.setCustomTheme(this.savedCustomStyles),i.applyTheme(this.renderer.container,"custom")}else ct.getInstance().applyTheme(this.renderer.container,e);this.startAnimationLoop(),this.render()}destroy(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}getData(){const t=this.service.exportData();return t.selectedId=this.selectedNodeId||void 0,t}loadData(t){try{this.service.importData(t),t.selectedId?this.selectNode(t.selectedId):this.selectNode(null),this.render(),this.eventBus.emit("model:load",t),t.theme&&this.setTheme(t.theme),this.eventBus.emit("model:change",void 0)}catch(e){console.error("Failed to load data",e)}}batch(t){this.isBatching=!0;try{t()}finally{this.isBatching=!1,this.render()}}getSelectedNodeId(){return this.selectedNodeId}addNode(t,e,i,r={emitChange:!0}){this.eventBus.emit("command",{name:"addNode",args:{parentId:t,topic:e,layoutSide:i}});const n=this.service.addNode(t,e,i);return n&&(this.render(),this.eventBus.emit("node:add",{id:n.id,topic:n.topic}),r.emitChange&&this.eventBus.emit("model:change",void 0)),n}addSibling(t,e="after",i="New topic",r={emitChange:!0}){this.eventBus.emit("command",{name:"addSibling",args:{referenceId:t,position:e,topic:i}});const n=this.mindMap.findNode(t);if(!n||!n.parentId)return null;const o=this.mindMap.findNode(n.parentId);o&&o.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(o);const s=this.service.addSibling(t,e,i);if(s){if(o&&o.isRoot&&this.layoutMode==="Both"){const c=n.layoutSide||(o.children.indexOf(n)%2===0?"right":"left");s.layoutSide=c}this.render(),this.eventBus.emit("node:add",{id:s.id,topic:s.topic}),r.emitChange&&this.eventBus.emit("model:change",void 0)}return s}insertParent(t,e="New topic",i={emitChange:!0}){this.eventBus.emit("command",{name:"insertParent",args:{targetId:t,topic:e}});const r=this.service.insertParent(t,e);return r&&(this.render(),this.eventBus.emit("node:add",{id:r.id,topic:r.topic}),i.emitChange&&this.eventBus.emit("model:change",void 0)),r}deleteNode(t){this.eventBus.emit("command",{name:"deleteNode",args:{nodeId:t}}),this.service.removeNode(t)&&(this.render(),this.eventBus.emit("node:remove",t),this.eventBus.emit("model:change",void 0))}updateNode(t,e){this.eventBus.emit("command",{name:"updateNode",args:{nodeId:t,updates:e}});let i=!1;this.interactionHandler&&this.interactionHandler.isReadOnly||(e.topic!==void 0&&this.service.updateNodeTopic(t,e.topic)&&(i=!0),e.style!==void 0&&this.service.updateNodeStyle(t,e.style)&&(i=!0),e.icon!==void 0&&this.service.updateNodeIcon(t,e.icon)&&(i=!0),i&&(this.render(),e.topic!==void 0&&this.eventBus.emit("node:update",{id:t,topic:e.topic}),this.eventBus.emit("model:change",void 0),this.pendingNodeCreation&&(this.pendingNodeCreation=!1)))}updateNodeWidth(t,e){if(this.eventBus.emit("command",{name:"updateNodeWidth",args:{nodeId:t,increment:e}}),this.interactionHandler&&this.interactionHandler.isReadOnly)return;const i=this.mindMap.findNode(t);if(!i)return;let r=i.customWidth;r===void 0&&(r=this.renderer.measureNode(i,this.mindMap).width);let n=r+e;n<50&&(n=50),this.service.updateNodeCustomWidth(t,n)&&(this.render(),this.eventBus.emit("model:change",void 0))}addChildNode(t){const e=this.mindMap.findNode(t);e&&e.isRoot&&this.layoutMode==="Both"&&this.ensureExplicitLayoutSides(e);let i;if(this.layoutMode==="Both"&&e&&e.isRoot){let n=0,o=0;e.children.forEach((s,c)=>{(s.layoutSide||(c%2===0?"right":"left"))==="left"?n++:o++}),i=n<o?"left":"right"}this.pendingNodeCreation=!0;const r=this.addNode(t,"New topic",i,{emitChange:!1});r&&(this.selectNode(r.id),this.ensureNodeVisible(r.id,!1,!0),this.interactionHandler.editNode(r.id))}addSiblingNode(t,e="after"){this.pendingNodeCreation=!0;const i=this.addSibling(t,e,"New topic",{emitChange:!1});i&&(this.selectNode(i.id),this.ensureNodeVisible(i.id,!1,!0),this.interactionHandler.editNode(i.id))}insertParentNode(t){this.pendingNodeCreation=!0;const e=this.insertParent(t,"New topic",{emitChange:!1});e&&(this.selectNode(e.id),this.ensureNodeVisible(e.id,!1,!0),this.interactionHandler.editNode(e.id))}removeNode(t){const i=this.mindMap.findNode(t)?.parentId||null,r=this.selectedNodeId===t;this.deleteNode(t),r&&i&&this.selectNode(i)}selectNode(t){if(this.selectedNodeId!==t){if(this.selectedNodeId=t,this.interactionHandler&&this.interactionHandler.updateSelection(t),t){const e=this.mindMap.findNode(t);e&&(!e.image&&this.interactionHandler&&!this.interactionHandler.isReadOnly?this.styleEditor.show(t,e.style):this.styleEditor.hide())}else this.styleEditor.hide();this.render(),this.eventBus.emit("node:select",t)}}moveNode(t,e,i){this.eventBus.emit("command",{name:"moveNode",args:{nodeId:t,targetId:e,position:i}});const r=this.mindMap.findNode(e);if(r){if(i==="top"){if(r.isRoot)return;this.service.reorderNode(t,e,"before")}else if(i==="bottom"){if(r.isRoot)return;this.service.reorderNode(t,e,"after")}else if(r.isRoot){const n=i==="left"?"left":"right";this.service.moveNode(t,e,n)}else((this.getNodeDirection(r)==="right"?i==="right":i==="left")?"addChild":"insertParent")==="addChild"?this.service.moveNode(t,e):this.service.insertNodeAsParent(t,e);this.render(),this.eventBus.emit("node:move",{nodeId:t,newParentId:e,position:i}),this.eventBus.emit("model:change",void 0)}}updateNodeTopic(t,e){this.updateNode(t,{topic:e}),setTimeout(()=>this.ensureNodeVisible(t),0)}render(){this.isBatching||(this.renderer.render(this.mindMap,this.selectedNodeId,this.layoutMode),this.renderer.updateTransform(this.panX,this.panY,this.scale))}setLayoutMode(t){this.eventBus.emit("command",{name:"setLayoutMode",args:{mode:t}}),this.layoutMode=t,this.layoutSwitcher&&this.layoutSwitcher.setMode(t);const e=this.renderer.container.clientWidth;t==="Right"?this.panX=e*.2:t==="Left"?this.panX=e*.8:this.panX=e*.5,this.panY=0,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}getLayoutMode(){return this.layoutMode}setMaxNodeWidth(t){this.maxWidth=t,this.renderer.maxWidth=t,this.interactionHandler&&(this.interactionHandler.maxWidth=t),this.render()}getMaxNodeWidth(){return this.maxWidth}updateGlobalStyles(t){if(this.eventBus.emit("command",{name:"updateGlobalStyles",args:{styles:t}}),t.rootNode&&(this.savedCustomStyles.rootNode={...this.savedCustomStyles.rootNode,...t.rootNode}),t.childNode&&(this.savedCustomStyles.childNode={...this.savedCustomStyles.childNode,...t.childNode}),t.connection&&(this.savedCustomStyles.connection={...this.savedCustomStyles.connection,...t.connection}),t.canvas&&(this.savedCustomStyles.canvas={...this.savedCustomStyles.canvas,...t.canvas}),this.mindMap.theme==="custom"){const e=ct.getInstance();e.setCustomTheme(this.savedCustomStyles),e.applyTheme(this.renderer.container,"custom")}}setTheme(t){this.eventBus.emit("command",{name:"setTheme",args:{theme:t}}),this.service.setTheme(t),this.layoutSwitcher&&this.layoutSwitcher.setTheme(t),t==="custom"&&ct.getInstance().setCustomTheme(this.savedCustomStyles),ct.getInstance().applyTheme(this.renderer.container,t),this.render(),this.eventBus.emit("model:change",void 0)}resetZoom(){const t=this.renderer.container.clientWidth/2,e=this.renderer.container.clientHeight/2,i=1;this.panX=t-(t-this.panX)*(i/this.scale),this.panY=e-(e-this.panY)*(i/this.scale),this.scale=i,this.targetPanX=this.panX,this.targetPanY=this.panY,this.render()}panBoard(t,e){this.targetPanX+=t,this.targetPanY+=e}zoomBoard(t,e,i){const s=this.renderer.container.getBoundingClientRect(),c=e-s.left,g=i-s.top,f=Math.min(Math.max(this.scale*(1-t*.001),.1),5),y=c-(c-this.panX)*(f/this.scale),p=g-(g-this.panY)*(f/this.scale);this.panX=y,this.panY=p,this.targetPanX=y,this.targetPanY=p,this.scale=f,this.renderer.updateTransform(this.panX,this.panY,this.scale)}setReadOnly(t){this.interactionHandler&&this.interactionHandler.setReadOnly(t),t&&this.styleEditor.hide()}undo(){this.service.undo()&&(this.eventBus.emit("command",{name:"undo"}),this.render(),this.eventBus.emit("model:change",void 0))}redo(){this.service.redo()&&(this.eventBus.emit("command",{name:"redo"}),this.render(),this.eventBus.emit("model:change",void 0))}toggleFold(t){this.service.toggleNodeFold(t)&&(this.eventBus.emit("command",{name:"toggleFold",args:{nodeId:t}}),this.render(),this.eventBus.emit("model:change",void 0))}navigateNode(t,e){const i=this.mindMap.findNode(t);if(!i)return;let r;switch(e){case"Left":r=this.navigateLeft(i);break;case"Right":r=this.navigateRight(i);break;case"Up":r=this.navigateUp(i);break;case"Down":r=this.navigateDown(i);break}r&&this.selectNode(r),this.selectedNodeId&&this.selectedNodeId!==t&&setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0),0)}copyNode(t){this.service.copyNode(t)}pasteNode(t){this.eventBus.emit("command",{name:"pasteNode",args:{parentId:t}});const e=this.service.pasteNode(t);e&&(this.render(),this.selectNode(e.id),this.eventBus.emit("node:add",{id:e.id,topic:e.topic}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(e.id,!0),0))}cutNode(t){this.eventBus.emit("command",{name:"cutNode",args:{nodeId:t}});const e=this.mindMap.findNode(t);if(e){const i=e.parentId;this.service.cutNode(t),i&&this.selectNode(i),this.render(),this.eventBus.emit("node:remove",t),this.eventBus.emit("model:change",void 0)}}pasteImage(t,e,i,r){this.eventBus.emit("command",{name:"pasteImage",args:{parentId:t,width:i,height:r}});const n=this.service.addImageNode(t,e,i,r);n&&(this.render(),this.selectNode(n.id),this.eventBus.emit("node:add",{id:n.id,topic:""}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(n.id,!0),0))}onEditEnd(){this.pendingNodeCreation&&(this.pendingNodeCreation=!1,this.eventBus.emit("model:change",void 0))}onStyleAction(t,e){if(this.interactionHandler&&this.interactionHandler.isReadOnly)return;const i=this.mindMap.findNode(t);if(!i)return;const r=i.style||{};let n=null;if(e.type==="bold")n={fontWeight:r.fontWeight==="bold"?"normal":"bold"};else if(e.type==="italic")n={fontStyle:r.fontStyle==="italic"?"normal":"italic"};else if(e.type==="color")e.index>=0&&e.index<yt.PALETTE.length&&(n={color:yt.PALETTE[e.index]});else if(e.type==="increaseSize"||e.type==="decreaseSize"){const o=yt.FONT_SIZES,s=r.fontSize||"";let c=o.findIndex(f=>f.value===s);c===-1&&(c=0);const g=e.type==="increaseSize"?Math.min(o.length-1,c+1):Math.max(0,c-1);g!==c&&(n={fontSize:o[g].value})}n&&this.service.updateNodeStyle(t,n)&&(this.render(),this.eventBus.emit("model:change",void 0),this.selectedNodeId===t&&this.styleEditor.show(t,{...r,...n}))}toggleCommandPalette(){this.interactionHandler&&this.interactionHandler.isReadOnly||this.commandPalette.toggle()}searchNodes(t){return this.service.searchNodes(t)}handleSearchInput(t){const e=this.service.searchNodes(t);this.commandPalette.setResults(e.map(i=>({id:i.id,topic:i.topic})))}handleSearchResultSelect(t){this.selectNode(t),setTimeout(()=>this.ensureNodeVisible(t,!0,!0),0)}handleIconSelect(t){this.selectedNodeId&&(this.service.updateNodeIcon(this.selectedNodeId,t),this.render(),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0,!0),0))}handleCommandSelect(t){t==="import-xmind"?this.importXMind():t==="export-png"?this.exportPng():t==="export-svg"?this.exportSvg():t==="export-markdown"&&this.exportMarkdown()}async exportPng(){this.eventBus.emit("command",{name:"exportPng"}),await new Rt().exportToPng(this.renderer.container,this.fileHandler)}async exportSvg(){this.eventBus.emit("command",{name:"exportSvg"}),await new Rt().exportToSvg(this.renderer.container,this.fileHandler)}async exportMarkdown(){this.eventBus.emit("command",{name:"exportMarkdown"}),await new ne().export(this.mindMap,this.fileHandler)}async importXMind(){if(this.eventBus.emit("command",{name:"importXMind"}),this.mindMap.root.children.length>0&&!window.confirm("Current mind map will be replaced. Continue?"))return;if(this.fileHandler){const e=await this.fileHandler.onImportFile("xmind");if(e)try{const i=new zt;let r;if(e instanceof ArrayBuffer)r=new File([e],"imported.xmind");else if(typeof e=="string")r=new File([e],"imported.xmind");else return;const n=await i.extractMindMapData(r);this.loadData(n)}catch(i){console.error(i),alert("Failed to import XMind file.")}return}const t=document.createElement("input");t.type="file",t.accept=".xmind",t.style.display="none",document.body.appendChild(t),t.onchange=async e=>{const r=e.target.files?.[0];if(r)try{const o=await new zt().extractMindMapData(r);this.loadData(o)}catch(n){console.error(n),alert("Failed to import XMind file.")}document.body.removeChild(t)},t.click()}ensureExplicitLayoutSides(t){!t.isRoot||this.layoutMode!=="Both"||t.children.forEach((e,i)=>{e.layoutSide||(e.layoutSide=i%2===0?"right":"left")})}getNodeDirection(t){if(t.isRoot||this.layoutMode==="Right")return"right";if(this.layoutMode==="Left")return"left";let e=t;for(;e.parentId;){const i=this.mindMap.findNode(e.parentId);if(!i)break;if(i.isRoot)return e.layoutSide?e.layoutSide:i.children.findIndex(n=>n.id===e.id)%2===0?"right":"left";e=i}return"right"}startAnimationLoop(){let t=performance.now();const e=()=>{const i=performance.now(),r=(i-t)/1e3;t=i;const n=1-Math.exp(-8*r),o=this.targetPanX-this.panX,s=this.targetPanY-this.panY;Math.abs(o)>.1||Math.abs(s)>.1?(this.panX+=o*n,this.panY+=s*n,this.renderer.updateTransform(this.panX,this.panY,this.scale)):(this.panX!==this.targetPanX||this.panY!==this.targetPanY)&&(this.panX=this.targetPanX,this.panY=this.targetPanY,this.renderer.updateTransform(this.panX,this.panY,this.scale)),Number.isNaN(this.panX)&&(this.panX=0),Number.isNaN(this.panY)&&(this.panY=0),this.animationFrameId=requestAnimationFrame(e)};e()}ensureNodeVisible(t,e=!1,i=!1){const r=this.renderer.container.querySelector(`.mindmap-node[data-id="${t}"]`);if(!r)return;const n=r.getBoundingClientRect(),o=this.renderer.container.getBoundingClientRect(),s=50;let c=0,g=0;const f=n.left<o.left+s,y=n.right>o.right-s,p=n.top<o.top+s,d=n.bottom>o.bottom-s;if(e&&(f||y||p||d)){const w=n.left+n.width/2,h=n.top+n.height/2,m=o.left+o.width/2,u=o.top+o.height/2;c=m-w,g=u-h}else f?c=o.left+s-n.left:y&&(c=o.right-s-n.right),p?g=o.top+s-n.top:d&&(g=o.bottom-s-n.bottom);(c!==0||g!==0)&&(i?(this.panX+=c,this.panY+=g,this.targetPanX=this.panX,this.targetPanY=this.panY,this.renderer.updateTransform(this.panX,this.panY,this.scale)):this.panBoard(c,g))}navigateLeft(t){if(t.isRoot){if(this.layoutMode==="Left")return t.children.length>0?t.children[0].id:void 0;if(this.layoutMode==="Both"){const e=t.children.find((i,r)=>(i.layoutSide||(r%2!==0?"left":"right"))==="left");return e?e.id:void 0}}else if(t.parentId)return this.getNodeDirection(t)==="right"?t.parentId:t.children.length>0?t.children[0].id:void 0}navigateRight(t){if(t.isRoot){if(this.layoutMode==="Right")return t.children.length>0?t.children[0].id:void 0;if(this.layoutMode==="Both"){const e=t.children.find((i,r)=>(i.layoutSide||(r%2===0?"right":"left"))==="right");return e?e.id:void 0}}else if(t.parentId)return this.getNodeDirection(t)==="right"?t.children.length>0?t.children[0].id:void 0:t.parentId}navigateUp(t){if(t.parentId){const e=this.mindMap.findNode(t.parentId);if(e){const i=this.getNodeDirection(t),r=e.children.filter(o=>this.getNodeDirection(o)===i),n=r.findIndex(o=>o.id===t.id);if(n>0)return r[n-1].id}}}navigateDown(t){if(t.parentId){const e=this.mindMap.findNode(t.parentId);if(e){const i=this.getNodeDirection(t),r=e.children.filter(o=>this.getNodeDirection(o)===i),n=r.findIndex(o=>o.id===t.id);if(n!==-1&&n<r.length-1)return r[n+1].id}}}showShortcutModal(){if(!this.interactionHandler||typeof document>"u")return;const t=document.createElement("div");t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="100vw",t.style.height="100vh",t.style.backgroundColor="rgba(0,0,0,0.5)",t.style.zIndex="3000",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.opacity="0",t.style.transition="opacity 0.2s";const e=document.createElement("div");e.style.backgroundColor="white",e.style.padding="20px",e.style.borderRadius="8px",e.style.boxShadow="0 4px 6px rgba(0,0,0,0.1)",e.style.maxWidth="600px",e.style.width="90%",e.style.maxHeight="90vh",e.style.overflowY="auto",e.style.position="relative";const i=document.createElement("h2");i.textContent="Keyboard Shortcuts",i.style.margin="0 0 15px 0",i.style.fontSize="1.5em",i.style.borderBottom="1px solid #eee",i.style.paddingBottom="10px",e.appendChild(i);const r=document.createElement("button");r.textContent="×",r.style.position="absolute",r.style.top="10px",r.style.right="15px",r.style.background="none",r.style.border="none",r.style.fontSize="24px",r.style.cursor="pointer",r.style.color="#999",r.addEventListener("click",()=>{s()}),e.appendChild(r);const n=this.interactionHandler.getShortcuts();[{title:"General",actions:[{action:"openCommandPalette",desc:"Open Command Palette",descJa:"コマンドパレットを開く"},{action:"navUp",desc:"Move Selection Up",descJa:"ノード間の移動 (上)"},{action:"navDown",desc:"Move Selection Down",descJa:"ノード間の移動 (下)"},{action:"navLeft",desc:"Move Selection Left",descJa:"ノード間の移動 (左)"},{action:"navRight",desc:"Move Selection Right",descJa:"ノード間の移動 (右)"},{action:"beginEdit",desc:"Start Editing (Zoom if Image)",descJa:"ノードの編集を開始 (画像の場合はズーム)"},{action:"addSibling",desc:"Add Sibling (Below)",descJa:"兄弟ノードを追加 (下)"},{action:"addSiblingBefore",desc:"Add Sibling (Above)",descJa:"兄弟ノードを追加 (上)"},{action:"addChild",desc:"Add Child",descJa:"子ノードを追加"},{action:"insertParent",desc:"Insert Parent",descJa:"親ノードを挿入"},{action:"deleteNode",desc:"Delete Node",descJa:"ノードを削除"},{action:"undo",desc:"Undo",descJa:"元に戻す (Undo)"},{action:"redo",desc:"Redo",descJa:"やり直し (Redo)"},{action:"copy",desc:"Copy",descJa:"コピー"},{action:"cut",desc:"Cut",descJa:"切り取り"},{action:"paste",desc:"Paste",descJa:"貼り付け (画像も可)"},{action:"toggleFold",desc:"Toggle Fold",descJa:"ノードの展開/折り畳み"},{action:"zoomIn",desc:"Canvas Zoom In",descJa:"キャンバス拡大"},{action:"zoomOut",desc:"Canvas Zoom Out",descJa:"キャンバス縮小"},{action:"resetZoom",desc:"Reset Zoom",descJa:"ズームリセット"},{key:"Drag (Canvas)",desc:"Pan Board",descJa:"画面のパン (移動)"},{key:"Wheel",desc:"Vertical Scroll",descJa:"上下スクロール (パン)"},{key:"Shift + Wheel",desc:"Horizontal Scroll",descJa:"左右スクロール (パン)"},{key:"Ctrl/Cmd + Wheel",desc:"Zoom",descJa:"ズームイン/アウト"}]},{title:"Editing (Text Input)",actions:[{key:"Enter",desc:"Confirm Edit",descJa:"編集を確定"},{key:"Shift + Enter",desc:"New Line",descJa:"改行"},{key:"Esc",desc:"Cancel Edit",descJa:"編集をキャンセル"}]},{title:"Styling (Selection)",actions:[{action:"bold",desc:"Toggle Bold",descJa:"太字 (Bold) 切り替え"},{action:"italic",desc:"Toggle Italic",descJa:"斜体 (Italic) 切り替え"},{action:"selectColor1",desc:"Color 1",descJa:"ノードの色を変更 (1)"},{action:"selectColor2",desc:"Color 2",descJa:"ノードの色を変更 (2)"},{action:"selectColor3",desc:"Color 3",descJa:"ノードの色を変更 (3)"},{action:"selectColor4",desc:"Color 4",descJa:"ノードの色を変更 (4)"},{action:"selectColor5",desc:"Color 5",descJa:"ノードの色を変更 (5)"},{action:"selectColor6",desc:"Color 6",descJa:"ノードの色を変更 (6)"},{action:"selectColor7",desc:"Color 7",descJa:"ノードの色を変更 (7)"},{action:"increaseFontSize",desc:"Increase Font Size",descJa:"フォントサイズ拡大"},{action:"decreaseFontSize",desc:"Decrease Font Size",descJa:"フォントサイズ縮小"}]}].forEach(g=>{const f=[];if(g.actions.forEach(m=>{let u="";const v=m;if(v.key)u=v.key;else if(v.action&&n[v.action]){const k=n[v.action];if(k&&k.length>0){const C=k.map(S=>{const M=[];return(S.ctrlKey||S.metaKey)&&M.push("Ctrl/Cmd"),S.altKey&&M.push("Alt"),S.shiftKey&&M.push("Shift"),S.key===" "?M.push("Space"):M.push(S.key),M.join(" + ")});u=[...new Set(C)].join(" / ")}}u&&f.push({key:u,desc:v.descJa||v.desc})}),f.length===0)return;const y=document.createElement("h3");y.textContent=g.title,y.style.marginTop="20px",y.style.marginBottom="10px",y.style.fontSize="1.2em",y.style.color="#333",y.style.borderBottom="1px solid #f0f0f0",e.appendChild(y);const p=document.createElement("table");p.style.width="100%",p.style.borderCollapse="collapse",p.style.fontSize="0.9em";const d=document.createElement("tr");d.style.borderBottom="2px solid #ddd";const w=document.createElement("th");w.textContent="Key",w.style.textAlign="center",w.style.padding="8px 0",w.style.width="40%",w.style.color="#666";const h=document.createElement("th");h.textContent="Description",h.style.textAlign="center",h.style.padding="8px 0",h.style.color="#666",d.appendChild(w),d.appendChild(h),p.appendChild(d),f.forEach(m=>{const u=document.createElement("tr");u.style.borderBottom="1px solid #f9f9f9";const v=document.createElement("td");v.textContent=m.key,v.style.padding="6px 0",v.style.fontWeight="bold",v.style.color="#555",v.style.minWidth="180px",v.style.textAlign="center";const k=document.createElement("td");k.textContent=m.desc,k.style.padding="6px 0",k.style.textAlign="left",k.style.color="#333",u.appendChild(v),u.appendChild(k),p.appendChild(u)}),e.appendChild(p)}),t.appendChild(e),document.body.appendChild(t),requestAnimationFrame(()=>{t.style.opacity="1"});const s=()=>{t.style.opacity="0",setTimeout(()=>{document.body.contains(t)&&document.body.removeChild(t)},200),document.removeEventListener("keydown",c)},c=g=>{g.key==="Escape"&&s()};document.addEventListener("keydown",c),t.addEventListener("click",g=>{g.target===t&&s()})}}class se{listeners={};on(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t]?.push(e)}addListener(t,e){this.on(t,e)}off(t,e){const i=this.listeners[t];i&&(this.listeners[t]=i.filter(r=>r!==e))}removeListener(t,e){this.off(t,e)}emit(t,e){this.listeners[t]?.forEach(i=>i(e))}}class ae extends se{mindMap;controller;constructor(t,e={}){super();const i=new gt("root","Root Topic",null,!0);this.mindMap=new Wt(i);const r=new Lt,n=new jt(this.mindMap,r),o=document.createElement("div");o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.pointerEvents="none",o.style.zIndex="2000",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.style.overscrollBehavior="none",t.style.touchAction="none",t.appendChild(o);const c=new yt(o),g=new Kt(t,{onImageZoom:p=>this.controller.setReadOnly(p),onToggleFold:p=>this.controller.toggleFold(p)});this.controller=new oe(this.mindMap,n,g,c,{emit:(p,d)=>this.emit(p,d)},e.fileHandler),c.onUpdate=(p,d)=>{this.controller.updateNode(p,{style:d})};const f=new qt(t,{onNodeClick:p=>this.controller.selectNode(p||null),onAddChild:p=>this.controller.addChildNode(p),onInsertParent:p=>this.controller.insertParentNode(p),onAddSibling:(p,d)=>this.controller.addSiblingNode(p,d),onDeleteNode:p=>this.controller.removeNode(p),onDropNode:(p,d,w)=>this.controller.moveNode(p,d,w),onUpdateNode:(p,d)=>this.controller.updateNodeTopic(p,d),onNavigate:(p,d)=>this.controller.navigateNode(p,d),onPan:(p,d)=>this.controller.panBoard(p,d),onCopyNode:p=>this.controller.copyNode(p),onPasteNode:p=>this.controller.pasteNode(p),onCutNode:p=>this.controller.cutNode(p),onPasteImage:(p,d,w,h)=>this.controller.pasteImage(p,d,w,h),onZoom:(p,d,w)=>this.controller.zoomBoard(p,d,w),onZoomReset:()=>this.controller.resetZoom(),onUndo:()=>this.controller.undo(),onRedo:()=>this.controller.redo(),onStyleAction:(p,d)=>this.controller.onStyleAction(p,d),onEditEnd:p=>this.controller.onEditEnd(),onToggleFold:p=>this.controller.toggleFold(p),onToggleCommandPalette:()=>this.controller.toggleCommandPalette(),onUpdateNodeWidth:(p,d)=>this.controller.updateNodeWidth(p,d),shortcuts:e.shortcuts});this.controller.setInteractionHandler(f);const y=new Yt(o,{onLayoutChange:p=>this.controller.setLayoutMode(p),onThemeChange:p=>this.controller.setTheme(p),onZoomReset:()=>this.controller.resetZoom(),onShowShortcuts:()=>this.controller.showShortcutModal()});this.controller.setLayoutSwitcher(y),e.maxNodeWidth!==void 0&&this.controller.setMaxNodeWidth(e.maxNodeWidth),e.customStyles&&this.controller.updateGlobalStyles(e.customStyles),this.controller.init(t.clientWidth)}addNode(t,e,i,r={emitChange:!0}){return this.controller.addNode(t,e,i,r)}addSibling(t,e="after",i="New topic",r={emitChange:!0}){return this.controller.addSibling(t,e,i,r)}insertParent(t,e="New topic",i={emitChange:!0}){return this.controller.insertParent(t,e,i)}deleteNode(t){this.controller.deleteNode(t)}updateNode(t,e){this.controller.updateNode(t,e)}undo(){this.controller.undo()}redo(){this.controller.redo()}toggleFold(t){this.controller.toggleFold(t)}toggleCommandPalette(){this.controller.toggleCommandPalette()}openCommandPalette(){this.controller.toggleCommandPalette()}searchNodes(t){return this.controller.searchNodes(t)}getSelectedNodeId(){return this.controller.selectedNodeId}updateNodeStyle(t,e){this.controller.updateNode(t,{style:e})}setTheme(t){this.controller.setTheme(t)}getMindMap(){return this.mindMap}getNode(t){return this.mindMap.findNode(t)||void 0}getRoot(){return this.mindMap.root}findNodes(t){const e=[],i=r=>{t(r)&&e.push(r),r.children.forEach(i)};return i(this.mindMap.root),e}setMaxNodeWidth(t){this.controller.setMaxNodeWidth(t)}getMaxNodeWidth(){return this.controller.getMaxNodeWidth()}updateGlobalStyles(t){this.controller.updateGlobalStyles(t)}setReadOnly(t){this.controller.setReadOnly(t)}destroy(){this.controller.destroy(),this.controller.interactionHandler?.destroy()}batch(t){this.controller.isBatching=!0;try{t()}finally{this.controller.isBatching=!1,this.controller.render()}}addChildNode(t){this.controller.addChildNode(t)}addSiblingNode(t,e="after"){this.controller.addSiblingNode(t,e)}insertParentNode(t){this.controller.insertParentNode(t)}removeNode(t){this.controller.removeNode(t)}moveNode(t,e,i){this.controller.moveNode(t,e,i)}updateNodeTopic(t,e){this.controller.updateNodeTopic(t,e)}selectNode(t){this.controller.selectNode(t)}panBoard(t,e){this.controller.panBoard(t,e)}zoomBoard(t,e,i){this.controller.zoomBoard(t,e,i)}resetZoom(){this.controller.resetZoom()}copyNode(t){this.controller.copyNode(t)}pasteNode(t){this.controller.pasteNode(t)}pasteImage(t,e,i,r){this.controller.pasteImage(t,e,i,r)}cutNode(t){this.controller.cutNode(t)}updateLayout(t){t==="Standard"?this.controller.setLayoutMode("Both"):this.controller.setLayoutMode(t)}setLayoutMode(t){this.controller.setLayoutMode(t)}getLayoutMode(){return this.controller.getLayoutMode()}navigateNode(t,e){this.controller.navigateNode(t,e)}getData(){return this.controller.getData()}loadData(t){this.controller.loadData(t)}getRootId(){return this.mindMap.root.id}}exports.Kakidash=ae;exports.Node=gt;exports.SvgGenerator=Bt;exports.XMindImporter=zt;