kakidash 0.3.0 → 0.3.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.
@@ -1,5 +1,7 @@
1
- (function(ft,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(ft=typeof globalThis<"u"?globalThis:ft||self,bt(ft.kakidash={}))})(this,(function(ft){"use strict";class bt{root;theme="default";nodeIndex=new Map;constructor(t){this.root=t,this.rebuildIndex()}rebuildIndex(){this.nodeIndex.clear(),this.indexSubtree(this.root)}indexSubtree(t){this.nodeIndex.set(t.id,t);for(const e of t.children)this.indexSubtree(e)}registerNode(t){this.indexSubtree(t)}unregisterNode(t){this.removeFromIndex(t)}removeFromIndex(t){this.nodeIndex.delete(t.id);for(const e of t.children)this.removeFromIndex(e)}findNode(t){return this.nodeIndex.get(t)??null}moveNode(t,e){const i=this.findNode(t),n=this.findNode(e);if(!i||!n||i.isRoot||i.parentId===e||this.isDescendant(i,e))return!1;if(i.parentId){const r=this.findNode(i.parentId);r&&r.removeChild(t)}return n.addChild(i),!0}addSibling(t,e,i){const n=this.findNode(t);if(!n||!n.parentId)return!1;const r=this.findNode(n.parentId);if(!r)return!1;const s=r.children.findIndex(l=>l.id===t);if(s===-1)return!1;const o=i==="before"?s:s+1;return r.insertChild(e,o),this.registerNode(e),!0}insertParent(t,e){const i=this.findNode(t);if(!i||!i.parentId)return!1;const n=this.findNode(i.parentId);if(!n)return!1;const r=n.children.findIndex(s=>s.id===t);return r===-1?!1:(n.removeChild(t),n.insertChild(e,r),e.addChild(i),this.registerNode(e),!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 yt{id;topic;children;style;parentId;isRoot;image;imageSize;icon;presentation;constructor(t,e,i=null,n=!1,r,s,o=!1,l,g,b){this.id=t,this.topic=e,this.children=[],this.style={fontSize:n?"24px":"16px"},this.parentId=i,this.isRoot=n,this.image=r,this.imageSize=g,this.icon=l,this.presentation={isFolded:o,layoutSide:s,customWidth:b}}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 Wt{mindMap;idGenerator;constructor(t,e){this.mindMap=t,this.idGenerator=e}addNode(t,e="New topic",i){const n=this.mindMap.findNode(t);if(!n)return null;const r=this.idGenerator.generate(),s=new yt(r,e,null,!1,void 0,i,!1);return n.addChild(s),this.mindMap.registerNode(s),s}addImageNode(t,e,i,n){const r=this.mindMap.findNode(t);if(!r)return null;const s=this.idGenerator.generate(),o=i&&n?{width:i,height:n}:void 0,l=new yt(s,"",t,!1,e,void 0,!1,void 0,o);return r.addChild(l),this.mindMap.registerNode(l),l}removeNode(t){const e=this.mindMap.findNode(t);if(!e||e.isRoot||!e.parentId)return!1;const i=this.mindMap.findNode(e.parentId);return i?(i.removeChild(t),this.mindMap.unregisterNode(e),!0):!1}removeNodes(t){if(t.length===0)return!1;for(const i of t){const n=this.mindMap.findNode(i);if(!n||n.isRoot)return!1}let e=!1;return t.forEach(i=>{this.removeNode(i)&&(e=!0)}),e}updateNodeTopic(t,e){const i=this.mindMap.findNode(t);return i?(i.updateTopic(e),!0):!1}updateNodeStyle(t,e){const i=this.mindMap.findNode(t);return i?(i.style={...i.style,...e},!0):!1}updateNodesStyle(t,e){if(t.length===0)return!1;let i=!1;return t.forEach(n=>{const r=this.mindMap.findNode(n);r&&(r.style={...r.style,...e},i=!0)}),i}toggleNodeFold(t){const e=this.mindMap.findNode(t);return e?e.children.length===0&&!e.presentation.isFolded?!1:(e.presentation.isFolded=!e.presentation.isFolded,!0):!1}setTheme(t){this.mindMap.theme!==t&&(this.mindMap.theme=t)}updateNodeCustomWidth(t,e){const i=this.mindMap.findNode(t);return i?(i.presentation.customWidth=e,!0):!1}moveNode(t,e,i){const n=this.mindMap.findNode(t);if(n&&n.parentId===e)return i&&n.presentation.layoutSide!==i?(n.presentation.layoutSide=i,!0):!1;if(!n)return!1;if(this.mindMap.moveNode(t,e)){if(i){const r=this.mindMap.findNode(t);r&&(r.presentation.layoutSide=i)}return!0}return!1}addSibling(t,e,i="New topic"){const n=this.mindMap.findNode(t);if(!n||!n.parentId)return null;const r=this.idGenerator.generate(),s=new yt(r,i);return this.mindMap.addSibling(t,s,e)?s:null}reorderNode(t,e,i){const n=this.mindMap.findNode(t),r=this.mindMap.findNode(e);if(!n||!r||!r.parentId||n.id===r.id||n.isRoot)return!1;const s=this.mindMap.findNode(r.parentId);if(!s)return!1;if(n.parentId!==s.id){let g=s;for(;g.parentId;){if(g.id===n.id)return!1;if(!g.parentId)break;const b=this.mindMap.findNode(g.parentId);if(!b)break;g=b}}if(n.parentId&&n.parentId!==s.id){const g=this.mindMap.findNode(n.parentId);g&&(g.removeChild(n.id),this.mindMap.unregisterNode(n)),n.parentId=s.id}else n.parentId===s.id&&(s.removeChild(n.id),this.mindMap.unregisterNode(n));const o=s.children.findIndex(g=>g.id===e);if(o===-1)return s.addChild(n),this.mindMap.registerNode(n),!0;const l=i==="before"?o:o+1;return s.insertChild(n,l),this.mindMap.registerNode(n),s.isRoot&&r.presentation.layoutSide&&(n.presentation.layoutSide=r.presentation.layoutSide),!0}insertNodeAsParent(t,e){const i=this.mindMap.findNode(t),n=this.mindMap.findNode(e);if(!i||!n||!n.parentId||i.id===n.id)return!1;const r=this.mindMap.findNode(n.parentId);if(!r)return!1;let s=r;for(;s;){if(s.id===i.id)return!1;if(!s.parentId)break;s=this.mindMap.findNode(s.parentId)}if(i.parentId){const l=this.mindMap.findNode(i.parentId);l&&(l.removeChild(i.id),this.mindMap.unregisterNode(i))}const o=r.children.findIndex(l=>l.id===e);return o===-1?!1:(r.isRoot&&n.presentation.layoutSide&&(i.presentation.layoutSide=n.presentation.layoutSide),r.removeChild(e),this.mindMap.unregisterNode(n),r.insertChild(i,o),this.mindMap.registerNode(i),i.parentId=r.id,i.addChild(n),this.mindMap.registerNode(n),!0)}insertParent(t,e="New topic"){const i=this.mindMap.findNode(t);if(!i||!i.parentId)return null;const n=this.idGenerator.generate(),r=new yt(n,e);return this.mindMap.insertParent(t,r)?r:null}updateNodeIcon(t,e){const i=this.mindMap.findNode(t);return i?(e==="delete"?i.icon=void 0:i.icon=e,!0):!1}addExistingNodes(t,e){const i=this.mindMap.findNode(t);return i?(e.forEach(n=>{i.addChild(n),this.mindMap.registerNode(n)}),!0):!1}exportData(){const t=i=>({id:i.id,topic:i.topic,root:i.isRoot||void 0,children:i.children.length>0?i.children.map(t):void 0,style:Object.keys(i.style).length>0?i.style:void 0,image:i.image,layoutSide:i.presentation.layoutSide,isFolded:i.presentation.isFolded,icon:i.icon,imageSize:i.imageSize,customWidth:i.presentation.customWidth});return{nodeData:t(this.mindMap.root),theme:this.mindMap.theme}}importData(t){const e=(i,n=null)=>{const r=!!i.root,s=new yt(i.id,i.topic,n,r,i.image,i.layoutSide,i.isFolded||!1,i.icon,i.imageSize,i.customWidth);return i.style&&(s.style={...i.style}),i.children&&i.children.length>0&&i.children.forEach(o=>{const l=e(o,s.id);s.addChild(l)}),s};this.mindMap.root=e(t.nodeData),this.mindMap.rebuildIndex(),t.theme&&(this.mindMap.theme=t.theme)}}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{historyManager;constructor(t=10){this.historyManager=new Ut(t)}saveState(t){this.historyManager.push(t)}undo(t){return this.historyManager.undo(t)}redo(t){return this.historyManager.redo(t)}get canUndo(){return this.historyManager.canUndo}get canRedo(){return this.historyManager.canRedo}}class Ht{constructor(t,e){this.mindMap=t,this.idGenerator=e}clipboard=[];copyNodes(t){this.clipboard=[];const e=[],i=new Set(t),n=[];t.forEach(r=>{let s=!1;const o=this.mindMap.findNode(r);if(o){let l=o.parentId?this.mindMap.findNode(o.parentId):null;for(;l;){if(i.has(l.id)){s=!0;break}l=l.parentId?this.mindMap.findNode(l.parentId):null}}s||n.push(r)}),n.forEach(r=>{const s=this.mindMap.findNode(r);s&&(this.clipboard.push(this.deepCloneNode(s)),e.push(s.topic))}),typeof navigator<"u"&&navigator.clipboard&&e.length>0&&navigator.clipboard.writeText(e.join(`
2
- `)).catch(r=>{console.error("Failed to write to clipboard",r)})}getClipboardNodes(){return this.clipboard}createPastedNodes(t){if(this.clipboard.length===0)return[];if(!this.mindMap.findNode(t))return[];const i=[];return this.clipboard.forEach(n=>{const r=this.deepCloneNode(n);this.regenerateIds(r),i.push(r)}),i}deepCloneNode(t){const e=new yt(t.id,t.topic,null,!1,t.image,t.presentation.layoutSide,t.presentation.isFolded,t.icon,t.imageSize&&{...t.imageSize},t.presentation.customWidth);return e.style={...t.style},e.children=t.children.map(i=>this.deepCloneNode(i)),e.children.forEach(i=>i.parentId=e.id),e}regenerateIds(t){t.id=this.idGenerator.generate(),t.children.forEach(e=>{e.parentId=t.id,this.regenerateIds(e)})}}class Zt{constructor(t){this.mindMap=t}searchNodes(t){if(!t)return[];const e=[],i=t.toLowerCase(),n=r=>{r.topic.toLowerCase().includes(i)&&e.push(r),r.children.forEach(n)};return n(this.mindMap.root),e}}const Et={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)"}}},Kt={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)"}}},At=["#E74C3C","#3498DB","#2ECC71","#F1C40F","#9B59B6","#E67E22","#1ABC9C"],Xt={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:Q=>At[Q%At.length]},Yt={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=Et;constructor(){this.registerTheme(Et),this.registerTheme(Kt),this.registerTheme(Xt),this.registerTheme(Yt)}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=Et.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"},num_0_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">0</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_1_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">1</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_2_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">2</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_3_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">3</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_4_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">4</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_5_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">5</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_6_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">6</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_7_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">7</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_8_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">8</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_9_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">9</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_0_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">0</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_1_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">1</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_2_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">2</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_3_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">3</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_4_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">4</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_5_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">5</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_6_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">6</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_7_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">7</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_8_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">8</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_9_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">9</text>',color:"#E74C3C",viewBox:"0 0 24 24"}};class Gt{container;svg;nodeContainer;options;maxWidth=-1;measureCache=new Map;nodeElementMap=new Map;previousSelectedIds=new Set;mindMap;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}renderFromLayout(t,e,i,n="Right"){this.mindMap=e,this.svg.innerHTML="",this.nodeContainer.innerHTML="",this.measureCache.clear(),this.nodeElementMap.clear(),this.previousSelectedIds.clear(),t.connections.forEach(r=>{const s=e.findNode(r.toNodeId),o=s?this.getThemeColor(s,e):"#ccc";this.drawConnection(r.fromX,r.fromY,r.toX,r.toY,o,e.theme)}),t.nodes.forEach(r=>{const s=e.findNode(r.nodeId);s&&this.renderNodeElement(s,r.x,r.y,r.width,r.direction,i,n,e)}),this.previousSelectedIds=new Set(i)}updateTransform(t,e,i=1){const n=`translate(${t}px, ${e}px) scale(${i})`;this.svg.style.transform=n,this.nodeContainer.style.transform=n}getThemeColor(t,e){const i=ct.getInstance().getCurrentTheme();if(i.getColor){if(t.isRoot)return"#333";let n=t,r=0;for(;n.parentId&&n.parentId!==e.root.id;){const l=e.findNode(n.parentId);if(!l)break;n=l,r++}const o=e.root.children.findIndex(l=>l.id===n.id);if(o!==-1)return i.getColor(o,r)}return i.styles?.connection?.color||"#ccc"}renderNodeElement(t,e,i,n,r,s,o,l){const g=t.isRoot,b=ct.getInstance().getCurrentTheme(),u=document.createElement("div");if(u.dataset.id=t.id,u.style.position="absolute",u.style.left=`${e}px`,u.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",u.appendChild(m);const h=document.createElement("div");h.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>',h.style.position="absolute",h.style.bottom="5px",h.style.right="5px",h.style.backgroundColor="var(--vscode-editor-background, rgba(255, 255, 255, 0.9))",h.style.borderRadius="50%",h.style.width="24px",h.style.height="24px",h.style.display="flex",h.style.justifyContent="center",h.style.alignItems="center",h.style.cursor="pointer",h.title="Zoom Image",h.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",u.appendChild(h),h.addEventListener("click",p=>{p.stopPropagation(),this.showImageModal(t.image)}),u.style.padding="5px"}else{if(u.style.display="flex",u.style.alignItems="center",u.style.justifyContent=t.isRoot?"center":"flex-start",t.icon){const w=It[t.icon];if(w){const _=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("viewBox",w.viewBox),_.setAttribute("width","20"),_.setAttribute("height","20"),_.style.width="20px",_.style.height="20px",_.style.marginRight="8px",_.style.flexShrink="0",_.innerHTML=w.path,u.appendChild(_)}else{const _=document.createElement("span");_.textContent=t.icon,_.style.marginRight="6px",_.style.fontSize="1.2em",u.appendChild(_)}}const m=document.createElement("span"),h=/(https?:\/\/[^\s]+)/g;t.topic.split(h).forEach(w=>{if(w.match(h)){const _=document.createElement("a");_.href=w,_.target="_blank",_.rel="noopener noreferrer",_.textContent=w,_.style.color="#3498DB",_.style.textDecoration="underline",_.style.cursor="pointer",_.addEventListener("mousedown",C=>C.stopPropagation()),_.addEventListener("click",C=>C.stopPropagation()),m.appendChild(_)}else m.appendChild(document.createTextNode(w))}),u.appendChild(m);const f=t.presentation.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);f!==void 0?(m.style.whiteSpace="pre-wrap",m.style.wordWrap="break-word",m.style.overflowWrap="anywhere",m.style.minWidth="0",u.style.maxWidth=`${f}px`,u.style.width="max-content"):m.style.whiteSpace="pre"}u.className="mindmap-node",u.style.position="absolute",u.style.touchAction="none",u.style.padding="8px 12px",t.image&&(u.style.padding="5px"),b.name==="custom"?t.isRoot?u.style.color="var(--mindmap-root-color, var(--vscode-editor-foreground, black))":u.style.color="var(--mindmap-child-color, var(--vscode-editor-foreground, black))":t.isRoot?u.style.color="var(--mindmap-root-color)":u.style.color="var(--mindmap-child-color)";const y=this.getThemeColor(t,l);if(u.style.setProperty("--node-color",y),b.name==="colorful")t.isRoot?u.style.border="2px solid var(--vscode-editor-foreground, #333)":u.style.border=`2px solid ${y}`;else if(b.name==="custom")if(t.isRoot){const m="2px solid var(--vscode-editor-foreground, #333)";u.style.border=`var(--mindmap-root-border, ${m})`}else u.style.border="var(--mindmap-child-border, 1px solid #ccc)";else t.isRoot?u.style.border="var(--mindmap-root-border)":u.style.border="var(--mindmap-child-border)";if(u.style.borderRadius="4px",t.isRoot&&(u.style.fontSize="1.2em",u.style.fontWeight="bold",b.name!=="custom"&&(u.style.border="2px solid var(--vscode-editor-foreground, #333)")),t.style.color&&(u.style.color=t.style.color),t.style.fontSize&&(u.style.fontSize=t.style.fontSize),t.style.fontWeight&&(u.style.fontWeight=t.style.fontWeight),t.style.fontStyle&&(u.style.fontStyle=t.style.fontStyle),t.style.textDecoration&&(u.style.textDecoration=t.style.textDecoration),t.style.background)u.style.backgroundColor=t.style.background;else if(b.name==="custom")t.isRoot?u.style.backgroundColor="var(--mindmap-root-background, var(--vscode-editor-background, white))":u.style.backgroundColor="var(--mindmap-child-background, var(--vscode-editor-background, white))";else if(t.isRoot)u.style.backgroundColor="var(--mindmap-root-background)";else{const m=b.name==="colorful"?"var(--vscode-editor-background, white)":"inherit";u.style.backgroundColor=`var(--mindmap-child-background, ${m})`}let c=e;if(r==="left"&&!g?c=e-n:g&&(c=e-n/2),u.style.left=`${c}px`,u.style.top=`${i}px`,u.style.transform="translate(0, -50%)",u.style.zIndex="10",u.style.cursor="default",u.style.userSelect="none",s.has(t.id)&&(u.style.outline="2px solid var(--vscode-focusBorder, #007bff)",u.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))",u.dataset.selected="true"),this.nodeContainer.appendChild(u),this.nodeElementMap.set(t.id,u),t.children.length!==0&&this.options.onToggleFold){const m=[];if(g&&o==="Both")m.push(c+n),m.push(c);else{let h=r==="right";g&&(o==="Left"?h=!1:h=!0),m.push(h?c+n:c)}m.forEach(h=>{const p=document.createElement("div");p.className="mindmap-toggle-btn",p.innerHTML=t.presentation.isFolded?"+":"-",p.style.position="absolute",p.style.width="16px",p.style.height="16px",p.style.fontSize="12px",p.style.lineHeight="14px",p.style.textAlign="center",p.style.borderRadius="50%",p.style.border="1px solid var(--vscode-widget-border, #999)",p.style.backgroundColor="var(--vscode-editor-background, #fff)",p.style.color="var(--vscode-editor-foreground, #000)",p.style.cursor="pointer",p.style.zIndex="11",p.style.userSelect="none";const f=0;p.style.left=`${h+f}px`,p.style.top=`${i}px`,p.style.transform="translate(-50%, -50%)",p.addEventListener("click",w=>{w.stopPropagation(),this.options.onToggleFold?.(t.id)}),this.nodeContainer.appendChild(p)})}}measureNode(t,e){if(this.measureCache.has(t.id))return this.measureCache.get(t.id);if(t.image){if(t.imageSize){if(t.imageSize.width>150){const m={width:160,height:150*(t.imageSize.height/t.imageSize.width)+10};return this.measureCache.set(t.id,m),m}const y={width:t.imageSize.width+10,height:t.imageSize.height+10};return this.measureCache.set(t.id,y),y}const u={width:160,height:160};return this.measureCache.set(t.id,u),u}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 n=document.createElement("span");n.textContent=t.topic,i.appendChild(n);const r=t.presentation.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);r!==void 0?(n.style.whiteSpace="pre-wrap",n.style.wordWrap="break-word",n.style.overflowWrap="anywhere",n.style.minWidth="0",i.style.maxWidth=`${r}px`,i.style.width="max-content"):n.style.whiteSpace="pre",i.style.padding="8px 12px";const s=ct.getInstance().getCurrentTheme(),o=e?this.getThemeColor(t,e):"#ccc";i.style.setProperty("--node-color",o),s.name==="colorful"?t.isRoot?i.style.border="2px solid var(--vscode-editor-foreground, #333)":i.style.border=`2px solid ${o}`:s.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",s.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.textDecoration&&(i.style.textDecoration=t.style.textDecoration),t.style.background&&(i.style.backgroundColor=t.style.background),this.nodeContainer.appendChild(i);const l=i.offsetWidth,g=i.offsetHeight;this.nodeContainer.removeChild(i);const b={width:l||100,height:g||40};return this.measureCache.set(t.id,b),b}drawConnection(t,e,i,n,r="#ccc",s="default"){const o=document.createElementNS("http://www.w3.org/2000/svg","path"),l=t+(i-t)/2,g=t+(i-t)/2,b=`M ${t} ${e} C ${l} ${e}, ${g} ${n}, ${i} ${n}`;if(o.setAttribute("d",b),s==="custom")o.style.stroke=`var(--mindmap-connection-color, ${r})`;else{o.style.stroke="var(--mindmap-connection-color, #ccc)";const u=ct.getInstance().getCurrentTheme();if(u.name==="colorful"||s==="colorful")o.setAttribute("stroke",r),o.style.stroke=r;else{o.style.stroke="var(--mindmap-connection-color)";const y=u.styles?.connection?.color||r;o.setAttribute("stroke",y)}}o.setAttribute("fill","none"),o.setAttribute("stroke-width","2"),this.svg.appendChild(o)}zoomNode(t){const e=this.mindMap?.findNode(t);e&&e.image&&this.showImageModal(e.image)}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 n;const r=()=>{document.body.contains(e)&&document.body.removeChild(e),n&&document.removeEventListener("keydown",n,!0),this.options.onImageZoom&&this.options.onImageZoom(!1),this.container.focus()};n=s=>{s.stopPropagation(),s.preventDefault(),r()},document.addEventListener("keydown",n,!0),e.addEventListener("click",()=>{r()})}getNodeElement(t){return this.nodeElementMap.get(t)}updateSelection(t){for(const e of this.previousSelectedIds)if(!t.has(e)){const i=this.nodeElementMap.get(e);i&&(i.style.outline="",i.style.boxShadow="",delete i.dataset.selected)}for(const e of t){const i=this.nodeElementMap.get(e);i&&(i.style.outline="2px solid var(--vscode-focusBorder, #007bff)",i.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))",i.dataset.selected="true")}this.previousSelectedIds=new Set(t)}}class vt{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",vt.FONT_SIZES.forEach(u=>{const y=document.createElement("option");y.value=u.value,y.textContent=u.label,i.appendChild(y)}),i.onchange=u=>{this.currentNodeId&&this.onUpdate&&this.onUpdate(this.currentNodeId,{fontSize:u.target.value})},e.appendChild(i);const r=(u,y,c)=>{const m=document.createElement("button");return m.textContent=u,m.style.width="32px",m.style.height="32px",m.style.padding="0",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.border="1px solid #ddd",m.style.backgroundColor="#f5f5f5",m.style.borderRadius="4px",m.style.cursor="pointer",m.style.fontSize="14px",y&&(m.style[y]=y==="fontWeight"?"bold":y==="fontStyle"?"italic":"line-through"),m.onclick=c,m},s=r("B","fontWeight",()=>{if(this.currentNodeId&&this.onUpdate){const u=s.classList.contains("active"),y=u?"normal":"bold";this.onUpdate(this.currentNodeId,{fontWeight:y}),this.updateButtonState(s,!u)}}),o=r("I","fontStyle",()=>{if(this.currentNodeId&&this.onUpdate){const u=o.classList.contains("active"),y=u?"normal":"italic";this.onUpdate(this.currentNodeId,{fontStyle:y}),this.updateButtonState(o,!u)}}),l=r("S","textDecoration",()=>{if(this.currentNodeId&&this.onUpdate){const u=l.classList.contains("active"),y=u?"none":"line-through";this.onUpdate(this.currentNodeId,{textDecoration:y}),this.updateButtonState(l,!u)}});e.appendChild(s),e.appendChild(o),e.appendChild(l),t.appendChild(e);const g=document.createElement("div");g.style.display="flex",g.style.gap="4px",g.style.alignItems="center",g.style.justifyContent="space-between";const b=document.createElement("input");return b.type="color",b.style.width="24px",b.style.height="24px",b.style.border="1px solid #ccc",b.style.padding="0",b.style.backgroundColor="transparent",b.style.cursor="pointer",b.style.appearance="none",b.onchange=u=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:u.target.value}),this.updateActivePaletteItem(u.target.value))},vt.PALETTE.forEach((u,y)=>{const c=document.createElement("div");c.className="color-swatch",c.dataset.color=u,c.textContent=(y+1).toString(),c.style.width="24px",c.style.height="24px",c.style.backgroundColor=u,c.style.borderRadius="4px",c.style.cursor="pointer",c.style.border="1px solid transparent",c.style.color=u==="#F1C40F"?"black":"white",c.style.fontSize="12px",c.style.fontWeight="bold",c.style.display="flex",c.style.justifyContent="center",c.style.alignItems="center",c.onclick=()=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:u}),b.value=u,this.updateActivePaletteItem(u))},g.appendChild(c)}),g.appendChild(b),t.appendChild(g),t}updateActivePaletteItem(t){this.editorEl.querySelectorAll(".color-swatch").forEach(i=>{const n=i;n.dataset.color?.toLowerCase()===t.toLowerCase()?(n.style.border="2px solid #ccc",n.style.transform="scale(1.1)"):(n.style.border="1px solid transparent",n.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 n=this.editorEl.querySelector('input[type="color"]'),r=e.color||"#000000";n.value=r,this.updateActivePaletteItem(r);const s=this.editorEl.querySelectorAll("button")[0];s&&this.updateButtonState(s,e.fontWeight==="bold");const o=this.editorEl.querySelectorAll("button")[1];o&&this.updateButtonState(o,e.fontStyle==="italic");const l=this.editorEl.querySelectorAll("button")[2];l&&this.updateButtonState(l,e.textDecoration==="line-through")}hide(){this.editorEl.style.display="none",this.currentNodeId=null}}class $t{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("Help",this.getHelpIcon(),()=>{this.options.onShowHelp&&this.options.onShowHelp()}),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 n=document.createElement("button");n.innerHTML=e,this.styleButton(n),n.title=t,n.addEventListener("click",i),this.element.appendChild(n)}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))}getIconDescriptions(t){return t==="ja"?[{id:"right",desc:"右配置: すべてのノードをルートの右側に配置します。"},{id:"left",desc:"左配置: すべてのノードをルートの左側に配置します。"},{id:"both",desc:"左右配置: ノードをルートの両側にバランスよく配置します。"},{id:"default",desc:"デフォルトテーマ: 枠線のある標準的なデザインです。"},{id:"simple",desc:"シンプルテーマ: 枠線のない、箇条書きのようなシンプルなスタイルです。"},{id:"colorful",desc:"カラフルテーマ: 枝ごとに色分けしたデザインです。"},{id:"custom",desc:"カスタムテーマ: カスタムスタイルを適用します。"},{id:"resetZoom",desc:"ズームリセット: ズームをリセットして中央に移動します。"},{id:"help",desc:"ヘルプ: このヘルプ画面を表示します。"}]:[{id:"right",desc:"Right: All nodes are placed on the right side of the root."},{id:"left",desc:"Left: All nodes are placed on the left side of the root."},{id:"both",desc:"Both: Nodes are balanced on both sides of the root."},{id:"default",desc:"Default Theme: Standard design with borders."},{id:"simple",desc:"Simple Theme: Minimal style without borders, like bullet points."},{id:"colorful",desc:"Colorful Theme: Color-coded design for each branch."},{id:"custom",desc:"Custom Theme: Your custom styles are applied."},{id:"resetZoom",desc:"Reset Zoom: Resets zoom and centers the view."},{id:"help",desc:"Help: Shows this help screen."}]}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
+ (function(ft,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(ft=typeof globalThis<"u"?globalThis:ft||self,bt(ft.kakidash={}))})(this,(function(ft){"use strict";class bt{root;theme="default";nodeIndex=new Map;constructor(t){this.root=t,this.rebuildIndex()}rebuildIndex(){this.nodeIndex.clear(),this.indexSubtree(this.root)}indexSubtree(t){this.nodeIndex.set(t.id,t);for(const e of t.children)this.indexSubtree(e)}registerNode(t){this.indexSubtree(t)}unregisterNode(t){this.removeFromIndex(t)}removeFromIndex(t){this.nodeIndex.delete(t.id);for(const e of t.children)this.removeFromIndex(e)}findNode(t){return this.nodeIndex.get(t)??null}moveNode(t,e){const i=this.findNode(t),n=this.findNode(e);if(!i||!n||i.isRoot||i.parentId===e||this.isDescendant(i,e))return!1;if(i.parentId){const r=this.findNode(i.parentId);r&&r.removeChild(t)}return n.addChild(i),!0}addSibling(t,e,i){const n=this.findNode(t);if(!n||!n.parentId)return!1;const r=this.findNode(n.parentId);if(!r)return!1;const s=r.children.findIndex(l=>l.id===t);if(s===-1)return!1;const o=i==="before"?s:s+1;return r.insertChild(e,o),this.registerNode(e),!0}insertParent(t,e){const i=this.findNode(t);if(!i||!i.parentId)return!1;const n=this.findNode(i.parentId);if(!n)return!1;const r=n.children.findIndex(s=>s.id===t);return r===-1?!1:(n.removeChild(t),n.insertChild(e,r),e.addChild(i),this.registerNode(e),!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;icon;presentation;constructor(t,e,i=null,n=!1,r,s,o=!1,l,g,w){this.id=t,this.topic=e,this.children=[],this.style={fontSize:n?"24px":"16px"},this.parentId=i,this.isRoot=n,this.image=r,this.imageSize=g,this.icon=l,this.presentation={isFolded:o,layoutSide:s,customWidth:w}}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 Wt{mindMap;idGenerator;constructor(t,e){this.mindMap=t,this.idGenerator=e}addNode(t,e="New topic",i){const n=this.mindMap.findNode(t);if(!n)return null;const r=this.idGenerator.generate(),s=new gt(r,e,null,!1,void 0,i,!1);return n.addChild(s),this.mindMap.registerNode(s),s}addImageNode(t,e,i,n){const r=this.mindMap.findNode(t);if(!r)return null;const s=this.idGenerator.generate(),o=i&&n?{width:i,height:n}:void 0,l=new gt(s,"",t,!1,e,void 0,!1,void 0,o);return r.addChild(l),this.mindMap.registerNode(l),l}removeNode(t){const e=this.mindMap.findNode(t);if(!e||e.isRoot||!e.parentId)return!1;const i=this.mindMap.findNode(e.parentId);return i?(i.removeChild(t),this.mindMap.unregisterNode(e),!0):!1}removeNodes(t){if(t.length===0)return!1;for(const i of t){const n=this.mindMap.findNode(i);if(!n||n.isRoot)return!1}let e=!1;return t.forEach(i=>{this.removeNode(i)&&(e=!0)}),e}updateNodeTopic(t,e){const i=this.mindMap.findNode(t);return i?(i.updateTopic(e),!0):!1}updateNodeStyle(t,e){const i=this.mindMap.findNode(t);return i?(i.style={...i.style,...e},!0):!1}updateNodesStyle(t,e){if(t.length===0)return!1;let i=!1;return t.forEach(n=>{const r=this.mindMap.findNode(n);r&&(r.style={...r.style,...e},i=!0)}),i}toggleNodeFold(t){const e=this.mindMap.findNode(t);return e?e.children.length===0&&!e.presentation.isFolded?!1:(e.presentation.isFolded=!e.presentation.isFolded,!0):!1}setTheme(t){this.mindMap.theme!==t&&(this.mindMap.theme=t)}updateNodeCustomWidth(t,e){const i=this.mindMap.findNode(t);return i?(i.presentation.customWidth=e,!0):!1}moveNode(t,e,i){const n=this.mindMap.findNode(t);if(n&&n.parentId===e)return i&&n.presentation.layoutSide!==i?(n.presentation.layoutSide=i,!0):!1;if(!n)return!1;if(this.mindMap.moveNode(t,e)){if(i){const r=this.mindMap.findNode(t);r&&(r.presentation.layoutSide=i)}return!0}return!1}addSibling(t,e,i="New topic"){const n=this.mindMap.findNode(t);if(!n||!n.parentId)return null;const r=this.idGenerator.generate(),s=new gt(r,i);return this.mindMap.addSibling(t,s,e)?s:null}reorderNode(t,e,i){const n=this.mindMap.findNode(t),r=this.mindMap.findNode(e);if(!n||!r||!r.parentId||n.id===r.id||n.isRoot)return!1;const s=this.mindMap.findNode(r.parentId);if(!s)return!1;if(n.parentId!==s.id){let g=s;for(;g.parentId;){if(g.id===n.id)return!1;if(!g.parentId)break;const w=this.mindMap.findNode(g.parentId);if(!w)break;g=w}}if(n.parentId&&n.parentId!==s.id){const g=this.mindMap.findNode(n.parentId);g&&(g.removeChild(n.id),this.mindMap.unregisterNode(n)),n.parentId=s.id}else n.parentId===s.id&&(s.removeChild(n.id),this.mindMap.unregisterNode(n));const o=s.children.findIndex(g=>g.id===e);if(o===-1)return s.addChild(n),this.mindMap.registerNode(n),!0;const l=i==="before"?o:o+1;return s.insertChild(n,l),this.mindMap.registerNode(n),s.isRoot&&r.presentation.layoutSide&&(n.presentation.layoutSide=r.presentation.layoutSide),!0}insertNodeAsParent(t,e){const i=this.mindMap.findNode(t),n=this.mindMap.findNode(e);if(!i||!n||!n.parentId||i.id===n.id)return!1;const r=this.mindMap.findNode(n.parentId);if(!r)return!1;let s=r;for(;s;){if(s.id===i.id)return!1;if(!s.parentId)break;s=this.mindMap.findNode(s.parentId)}if(i.parentId){const l=this.mindMap.findNode(i.parentId);l&&(l.removeChild(i.id),this.mindMap.unregisterNode(i))}const o=r.children.findIndex(l=>l.id===e);return o===-1?!1:(r.isRoot&&n.presentation.layoutSide&&(i.presentation.layoutSide=n.presentation.layoutSide),r.removeChild(e),this.mindMap.unregisterNode(n),r.insertChild(i,o),this.mindMap.registerNode(i),i.parentId=r.id,i.addChild(n),this.mindMap.registerNode(n),!0)}insertParent(t,e="New topic"){const i=this.mindMap.findNode(t);if(!i||!i.parentId)return null;const n=this.idGenerator.generate(),r=new gt(n,e);return this.mindMap.insertParent(t,r)?r:null}updateNodeIcon(t,e){const i=this.mindMap.findNode(t);return i?(e==="delete"?i.icon=void 0:i.icon=e,!0):!1}addExistingNodes(t,e){const i=this.mindMap.findNode(t);return i?(e.forEach(n=>{i.addChild(n),this.mindMap.registerNode(n)}),!0):!1}exportData(){const t=i=>({id:i.id,topic:i.topic,root:i.isRoot||void 0,children:i.children.length>0?i.children.map(t):void 0,style:Object.keys(i.style).length>0?i.style:void 0,image:i.image,layoutSide:i.presentation.layoutSide,isFolded:i.presentation.isFolded,icon:i.icon,imageSize:i.imageSize,customWidth:i.presentation.customWidth});return{nodeData:t(this.mindMap.root),theme:this.mindMap.theme}}importData(t){const e=(i,n=null)=>{const r=!!i.root,s=new gt(i.id,i.topic,n,r,i.image,i.layoutSide,i.isFolded||!1,i.icon,i.imageSize,i.customWidth);return i.style&&(s.style={...i.style}),i.children&&i.children.length>0&&i.children.forEach(o=>{const l=e(o,s.id);s.addChild(l)}),s};this.mindMap.root=e(t.nodeData),this.mindMap.rebuildIndex(),t.theme&&(this.mindMap.theme=t.theme)}}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{historyManager;constructor(t=10){this.historyManager=new Ut(t)}saveState(t){this.historyManager.push(t)}undo(t){return this.historyManager.undo(t)}redo(t){return this.historyManager.redo(t)}get canUndo(){return this.historyManager.canUndo}get canRedo(){return this.historyManager.canRedo}}class Ht{constructor(t,e){this.mindMap=t,this.idGenerator=e}clipboard=[];copyNodes(t){this.clipboard=[];const e=[],i=new Set(t),n=[];t.forEach(r=>{let s=!1;const o=this.mindMap.findNode(r);if(o){let l=o.parentId?this.mindMap.findNode(o.parentId):null;for(;l;){if(i.has(l.id)){s=!0;break}l=l.parentId?this.mindMap.findNode(l.parentId):null}}s||n.push(r)}),n.forEach(r=>{const s=this.mindMap.findNode(r);s&&(this.clipboard.push(this.deepCloneNode(s)),e.push(s.topic))}),typeof navigator<"u"&&navigator.clipboard&&e.length>0&&navigator.clipboard.writeText(e.join(`
2
+ `)).catch(r=>{console.error("Failed to write to clipboard",r)})}getClipboardNodes(){return this.clipboard}createPastedNodes(t,e){if(!this.mindMap.findNode(t))return[];let n=!1;if(this.clipboard.length>0&&e!==void 0){const s=this.clipboard.map(l=>l.topic).join(`
3
+ `),o=e.replace(/\r\n/g,`
4
+ `);s===o&&(n=!0)}else this.clipboard.length>0&&e===void 0&&(n=!0);const r=[];if(!n&&e){const s=this.idGenerator.generate(),o=new gt(s,e);r.push(o)}else this.clipboard.length>0&&this.clipboard.forEach(s=>{const o=this.deepCloneNode(s);this.regenerateIds(o),r.push(o)});return r}deepCloneNode(t){const e=new gt(t.id,t.topic,null,!1,t.image,t.presentation.layoutSide,t.presentation.isFolded,t.icon,t.imageSize&&{...t.imageSize},t.presentation.customWidth);return e.style={...t.style},e.children=t.children.map(i=>this.deepCloneNode(i)),e.children.forEach(i=>i.parentId=e.id),e}regenerateIds(t){t.id=this.idGenerator.generate(),t.children.forEach(e=>{e.parentId=t.id,this.regenerateIds(e)})}}class Zt{constructor(t){this.mindMap=t}searchNodes(t){if(!t)return[];const e=[],i=t.toLowerCase(),n=r=>{r.topic.toLowerCase().includes(i)&&e.push(r),r.children.forEach(n)};return n(this.mindMap.root),e}}const Et={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)"}}},Kt={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)"}}},At=["#E74C3C","#3498DB","#2ECC71","#F1C40F","#9B59B6","#E67E22","#1ABC9C"],Xt={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:Q=>At[Q%At.length]},Yt={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=Et;constructor(){this.registerTheme(Et),this.registerTheme(Kt),this.registerTheme(Xt),this.registerTheme(Yt)}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=Et.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"},num_0_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">0</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_1_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">1</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_2_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">2</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_3_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">3</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_4_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">4</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_5_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">5</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_6_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">6</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_7_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">7</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_8_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">8</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_9_blue:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#3498DB" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">9</text>',color:"#3498DB",viewBox:"0 0 24 24"},num_0_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">0</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_1_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">1</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_2_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">2</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_3_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">3</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_4_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">4</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_5_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">5</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_6_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">6</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_7_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">7</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_8_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">8</text>',color:"#E74C3C",viewBox:"0 0 24 24"},num_9_red:{path:'<rect x="2" y="2" width="20" height="20" rx="4" ry="4" fill="#E74C3C" /><text x="12" y="16.5" font-family="sans-serif" font-size="14" font-weight="bold" fill="white" text-anchor="middle">9</text>',color:"#E74C3C",viewBox:"0 0 24 24"}};class Gt{container;svg;nodeContainer;options;maxWidth=-1;measureCache=new Map;nodeElementMap=new Map;previousSelectedIds=new Set;mindMap;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}renderFromLayout(t,e,i,n="Right"){this.mindMap=e,this.svg.innerHTML="",this.nodeContainer.innerHTML="",this.measureCache.clear(),this.nodeElementMap.clear(),this.previousSelectedIds.clear(),t.connections.forEach(r=>{const s=e.findNode(r.toNodeId),o=s?this.getThemeColor(s,e):"#ccc";this.drawConnection(r.fromX,r.fromY,r.toX,r.toY,o,e.theme)}),t.nodes.forEach(r=>{const s=e.findNode(r.nodeId);s&&this.renderNodeElement(s,r.x,r.y,r.width,r.direction,i,n,e)}),this.previousSelectedIds=new Set(i)}updateTransform(t,e,i=1){const n=`translate(${t}px, ${e}px) scale(${i})`;this.svg.style.transform=n,this.nodeContainer.style.transform=n}getThemeColor(t,e){const i=ct.getInstance().getCurrentTheme();if(i.getColor){if(t.isRoot)return"#333";let n=t,r=0;for(;n.parentId&&n.parentId!==e.root.id;){const l=e.findNode(n.parentId);if(!l)break;n=l,r++}const o=e.root.children.findIndex(l=>l.id===n.id);if(o!==-1)return i.getColor(o,r)}return i.styles?.connection?.color||"#ccc"}renderNodeElement(t,e,i,n,r,s,o,l){const g=t.isRoot,w=ct.getInstance().getCurrentTheme(),u=document.createElement("div");if(u.dataset.id=t.id,u.style.position="absolute",u.style.left=`${e}px`,u.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",u.appendChild(m);const h=document.createElement("div");h.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>',h.style.position="absolute",h.style.bottom="5px",h.style.right="5px",h.style.backgroundColor="var(--vscode-editor-background, rgba(255, 255, 255, 0.9))",h.style.borderRadius="50%",h.style.width="24px",h.style.height="24px",h.style.display="flex",h.style.justifyContent="center",h.style.alignItems="center",h.style.cursor="pointer",h.title="Zoom Image",h.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",u.appendChild(h),h.addEventListener("click",p=>{p.stopPropagation(),this.showImageModal(t.image)}),u.style.padding="5px"}else{if(u.style.display="flex",u.style.alignItems="center",u.style.justifyContent=t.isRoot?"center":"flex-start",t.icon){const b=It[t.icon];if(b){const _=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("viewBox",b.viewBox),_.setAttribute("width","20"),_.setAttribute("height","20"),_.style.width="20px",_.style.height="20px",_.style.marginRight="8px",_.style.flexShrink="0",_.innerHTML=b.path,u.appendChild(_)}else{const _=document.createElement("span");_.textContent=t.icon,_.style.marginRight="6px",_.style.fontSize="1.2em",u.appendChild(_)}}const m=document.createElement("span"),h=/(https?:\/\/[^\s]+)/g;t.topic.split(h).forEach(b=>{if(b.match(h)){const _=document.createElement("a");_.href=b,_.target="_blank",_.rel="noopener noreferrer",_.textContent=b,_.style.color="#3498DB",_.style.textDecoration="underline",_.style.cursor="pointer",_.addEventListener("mousedown",C=>C.stopPropagation()),_.addEventListener("click",C=>C.stopPropagation()),m.appendChild(_)}else m.appendChild(document.createTextNode(b))}),u.appendChild(m);const f=t.presentation.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);f!==void 0?(m.style.whiteSpace="pre-wrap",m.style.wordWrap="break-word",m.style.overflowWrap="anywhere",m.style.minWidth="0",u.style.maxWidth=`${f}px`,u.style.width="max-content"):m.style.whiteSpace="pre"}u.className="mindmap-node",u.style.position="absolute",u.style.touchAction="none",u.style.padding="8px 12px",t.image&&(u.style.padding="5px"),w.name==="custom"?t.isRoot?u.style.color="var(--mindmap-root-color, var(--vscode-editor-foreground, black))":u.style.color="var(--mindmap-child-color, var(--vscode-editor-foreground, black))":t.isRoot?u.style.color="var(--mindmap-root-color)":u.style.color="var(--mindmap-child-color)";const y=this.getThemeColor(t,l);if(u.style.setProperty("--node-color",y),w.name==="colorful")t.isRoot?u.style.border="2px solid var(--vscode-editor-foreground, #333)":u.style.border=`2px solid ${y}`;else if(w.name==="custom")if(t.isRoot){const m="2px solid var(--vscode-editor-foreground, #333)";u.style.border=`var(--mindmap-root-border, ${m})`}else u.style.border="var(--mindmap-child-border, 1px solid #ccc)";else t.isRoot?u.style.border="var(--mindmap-root-border)":u.style.border="var(--mindmap-child-border)";if(u.style.borderRadius="4px",t.isRoot&&(u.style.fontSize="1.2em",u.style.fontWeight="bold",w.name!=="custom"&&(u.style.border="2px solid var(--vscode-editor-foreground, #333)")),t.style.color&&(u.style.color=t.style.color),t.style.fontSize&&(u.style.fontSize=t.style.fontSize),t.style.fontWeight&&(u.style.fontWeight=t.style.fontWeight),t.style.fontStyle&&(u.style.fontStyle=t.style.fontStyle),t.style.textDecoration&&(u.style.textDecoration=t.style.textDecoration),t.style.background)u.style.backgroundColor=t.style.background;else if(w.name==="custom")t.isRoot?u.style.backgroundColor="var(--mindmap-root-background, var(--vscode-editor-background, white))":u.style.backgroundColor="var(--mindmap-child-background, var(--vscode-editor-background, white))";else if(t.isRoot)u.style.backgroundColor="var(--mindmap-root-background)";else{const m=w.name==="colorful"?"var(--vscode-editor-background, white)":"inherit";u.style.backgroundColor=`var(--mindmap-child-background, ${m})`}let c=e;if(r==="left"&&!g?c=e-n:g&&(c=e-n/2),u.style.left=`${c}px`,u.style.top=`${i}px`,u.style.transform="translate(0, -50%)",u.style.zIndex="10",u.style.cursor="default",u.style.userSelect="none",s.has(t.id)&&(u.style.outline="2px solid var(--vscode-focusBorder, #007bff)",u.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))",u.dataset.selected="true"),this.nodeContainer.appendChild(u),this.nodeElementMap.set(t.id,u),t.children.length!==0&&this.options.onToggleFold){const m=[];if(g&&o==="Both")m.push(c+n),m.push(c);else{let h=r==="right";g&&(o==="Left"?h=!1:h=!0),m.push(h?c+n:c)}m.forEach(h=>{const p=document.createElement("div");p.className="mindmap-toggle-btn",p.innerHTML=t.presentation.isFolded?"+":"-",p.style.position="absolute",p.style.width="16px",p.style.height="16px",p.style.fontSize="12px",p.style.lineHeight="14px",p.style.textAlign="center",p.style.borderRadius="50%",p.style.border="1px solid var(--vscode-widget-border, #999)",p.style.backgroundColor="var(--vscode-editor-background, #fff)",p.style.color="var(--vscode-editor-foreground, #000)",p.style.cursor="pointer",p.style.zIndex="11",p.style.userSelect="none";const f=0;p.style.left=`${h+f}px`,p.style.top=`${i}px`,p.style.transform="translate(-50%, -50%)",p.addEventListener("click",b=>{b.stopPropagation(),this.options.onToggleFold?.(t.id)}),this.nodeContainer.appendChild(p)})}}measureNode(t,e){if(this.measureCache.has(t.id))return this.measureCache.get(t.id);if(t.image){if(t.imageSize){if(t.imageSize.width>150){const m={width:160,height:150*(t.imageSize.height/t.imageSize.width)+10};return this.measureCache.set(t.id,m),m}const y={width:t.imageSize.width+10,height:t.imageSize.height+10};return this.measureCache.set(t.id,y),y}const u={width:160,height:160};return this.measureCache.set(t.id,u),u}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 n=document.createElement("span");n.textContent=t.topic,i.appendChild(n);const r=t.presentation.customWidth??(this.maxWidth!==-1?this.maxWidth:void 0);r!==void 0?(n.style.whiteSpace="pre-wrap",n.style.wordWrap="break-word",n.style.overflowWrap="anywhere",n.style.minWidth="0",i.style.maxWidth=`${r}px`,i.style.width="max-content"):n.style.whiteSpace="pre",i.style.padding="8px 12px";const s=ct.getInstance().getCurrentTheme(),o=e?this.getThemeColor(t,e):"#ccc";i.style.setProperty("--node-color",o),s.name==="colorful"?t.isRoot?i.style.border="2px solid var(--vscode-editor-foreground, #333)":i.style.border=`2px solid ${o}`:s.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",s.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.textDecoration&&(i.style.textDecoration=t.style.textDecoration),t.style.background&&(i.style.backgroundColor=t.style.background),this.nodeContainer.appendChild(i);const l=i.offsetWidth,g=i.offsetHeight;this.nodeContainer.removeChild(i);const w={width:l||100,height:g||40};return this.measureCache.set(t.id,w),w}drawConnection(t,e,i,n,r="#ccc",s="default"){const o=document.createElementNS("http://www.w3.org/2000/svg","path"),l=t+(i-t)/2,g=t+(i-t)/2,w=`M ${t} ${e} C ${l} ${e}, ${g} ${n}, ${i} ${n}`;if(o.setAttribute("d",w),s==="custom")o.style.stroke=`var(--mindmap-connection-color, ${r})`;else{o.style.stroke="var(--mindmap-connection-color, #ccc)";const u=ct.getInstance().getCurrentTheme();if(u.name==="colorful"||s==="colorful")o.setAttribute("stroke",r),o.style.stroke=r;else{o.style.stroke="var(--mindmap-connection-color)";const y=u.styles?.connection?.color||r;o.setAttribute("stroke",y)}}o.setAttribute("fill","none"),o.setAttribute("stroke-width","2"),this.svg.appendChild(o)}zoomNode(t){const e=this.mindMap?.findNode(t);e&&e.image&&this.showImageModal(e.image)}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 n;const r=()=>{document.body.contains(e)&&document.body.removeChild(e),n&&document.removeEventListener("keydown",n,!0),this.options.onImageZoom&&this.options.onImageZoom(!1),this.container.focus()};n=s=>{s.stopPropagation(),s.preventDefault(),r()},document.addEventListener("keydown",n,!0),e.addEventListener("click",()=>{r()})}getNodeElement(t){return this.nodeElementMap.get(t)}updateSelection(t){for(const e of this.previousSelectedIds)if(!t.has(e)){const i=this.nodeElementMap.get(e);i&&(i.style.outline="",i.style.boxShadow="",delete i.dataset.selected)}for(const e of t){const i=this.nodeElementMap.get(e);i&&(i.style.outline="2px solid var(--vscode-focusBorder, #007bff)",i.style.boxShadow="0 0 5px var(--vscode-focusBorder, rgba(0, 123, 255, 0.5))",i.dataset.selected="true")}this.previousSelectedIds=new Set(t)}}class vt{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",vt.FONT_SIZES.forEach(u=>{const y=document.createElement("option");y.value=u.value,y.textContent=u.label,i.appendChild(y)}),i.onchange=u=>{this.currentNodeId&&this.onUpdate&&this.onUpdate(this.currentNodeId,{fontSize:u.target.value})},e.appendChild(i);const r=(u,y,c)=>{const m=document.createElement("button");return m.textContent=u,m.style.width="32px",m.style.height="32px",m.style.padding="0",m.style.display="flex",m.style.justifyContent="center",m.style.alignItems="center",m.style.border="1px solid #ddd",m.style.backgroundColor="#f5f5f5",m.style.borderRadius="4px",m.style.cursor="pointer",m.style.fontSize="14px",y&&(m.style[y]=y==="fontWeight"?"bold":y==="fontStyle"?"italic":"line-through"),m.onclick=c,m},s=r("B","fontWeight",()=>{if(this.currentNodeId&&this.onUpdate){const u=s.classList.contains("active"),y=u?"normal":"bold";this.onUpdate(this.currentNodeId,{fontWeight:y}),this.updateButtonState(s,!u)}}),o=r("I","fontStyle",()=>{if(this.currentNodeId&&this.onUpdate){const u=o.classList.contains("active"),y=u?"normal":"italic";this.onUpdate(this.currentNodeId,{fontStyle:y}),this.updateButtonState(o,!u)}}),l=r("S","textDecoration",()=>{if(this.currentNodeId&&this.onUpdate){const u=l.classList.contains("active"),y=u?"none":"line-through";this.onUpdate(this.currentNodeId,{textDecoration:y}),this.updateButtonState(l,!u)}});e.appendChild(s),e.appendChild(o),e.appendChild(l),t.appendChild(e);const g=document.createElement("div");g.style.display="flex",g.style.gap="4px",g.style.alignItems="center",g.style.justifyContent="space-between";const w=document.createElement("input");return w.type="color",w.style.width="24px",w.style.height="24px",w.style.border="1px solid #ccc",w.style.padding="0",w.style.backgroundColor="transparent",w.style.cursor="pointer",w.style.appearance="none",w.onchange=u=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:u.target.value}),this.updateActivePaletteItem(u.target.value))},vt.PALETTE.forEach((u,y)=>{const c=document.createElement("div");c.className="color-swatch",c.dataset.color=u,c.textContent=(y+1).toString(),c.style.width="24px",c.style.height="24px",c.style.backgroundColor=u,c.style.borderRadius="4px",c.style.cursor="pointer",c.style.border="1px solid transparent",c.style.color=u==="#F1C40F"?"black":"white",c.style.fontSize="12px",c.style.fontWeight="bold",c.style.display="flex",c.style.justifyContent="center",c.style.alignItems="center",c.onclick=()=>{this.currentNodeId&&this.onUpdate&&(this.onUpdate(this.currentNodeId,{color:u}),w.value=u,this.updateActivePaletteItem(u))},g.appendChild(c)}),g.appendChild(w),t.appendChild(g),t}updateActivePaletteItem(t){this.editorEl.querySelectorAll(".color-swatch").forEach(i=>{const n=i;n.dataset.color?.toLowerCase()===t.toLowerCase()?(n.style.border="2px solid #ccc",n.style.transform="scale(1.1)"):(n.style.border="1px solid transparent",n.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 n=this.editorEl.querySelector('input[type="color"]'),r=e.color||"#000000";n.value=r,this.updateActivePaletteItem(r);const s=this.editorEl.querySelectorAll("button")[0];s&&this.updateButtonState(s,e.fontWeight==="bold");const o=this.editorEl.querySelectorAll("button")[1];o&&this.updateButtonState(o,e.fontStyle==="italic");const l=this.editorEl.querySelectorAll("button")[2];l&&this.updateButtonState(l,e.textDecoration==="line-through")}hide(){this.editorEl.style.display="none",this.currentNodeId=null}}class $t{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("Help",this.getHelpIcon(),()=>{this.options.onShowHelp&&this.options.onShowHelp()}),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 n=document.createElement("button");n.innerHTML=e,this.styleButton(n),n.title=t,n.addEventListener("click",i),this.element.appendChild(n)}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))}getIconDescriptions(t){return t==="ja"?[{id:"right",desc:"右配置: すべてのノードをルートの右側に配置します。"},{id:"left",desc:"左配置: すべてのノードをルートの左側に配置します。"},{id:"both",desc:"左右配置: ノードをルートの両側にバランスよく配置します。"},{id:"default",desc:"デフォルトテーマ: 枠線のある標準的なデザインです。"},{id:"simple",desc:"シンプルテーマ: 枠線のない、箇条書きのようなシンプルなスタイルです。"},{id:"colorful",desc:"カラフルテーマ: 枝ごとに色分けしたデザインです。"},{id:"custom",desc:"カスタムテーマ: カスタムスタイルを適用します。"},{id:"resetZoom",desc:"ズームリセット: ズームをリセットして中央に移動します。"},{id:"help",desc:"ヘルプ: このヘルプ画面を表示します。"}]:[{id:"right",desc:"Right: All nodes are placed on the right side of the root."},{id:"left",desc:"Left: All nodes are placed on the left side of the root."},{id:"both",desc:"Both: Nodes are balanced on both sides of the root."},{id:"default",desc:"Default Theme: Standard design with borders."},{id:"simple",desc:"Simple Theme: Minimal style without borders, like bullet points."},{id:"colorful",desc:"Colorful Theme: Color-coded design for each branch."},{id:"custom",desc:"Custom Theme: Your custom styles are applied."},{id:"resetZoom",desc:"Reset Zoom: Resets zoom and centers the view."},{id:"help",desc:"Help: Shows this help screen."}]}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">
3
5
  <circle cx="5" cy="12" r="3"></circle>
4
6
  <path d="M8 12h8"></path>
5
7
  <path d="M8 12 L16 5"></path>
@@ -38,7 +40,7 @@
38
40
  <circle cx="12" cy="12" r="10"></circle>
39
41
  <path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path>
40
42
  <line x1="12" y1="17" x2="12.01" y2="17"></line>
41
- </svg>`}}const Vt={navUp:[{key:"ArrowUp"},{key:"k"},{key:"ArrowUp",shiftKey:!0},{key:"k",shiftKey:!0}],navDown:[{key:"ArrowDown"},{key:"j"},{key:"ArrowDown",shiftKey:!0},{key:"j",shiftKey:!0}],navLeft:[{key:"ArrowLeft"},{key:"h"},{key:"ArrowLeft",shiftKey:!0},{key:"h",shiftKey:!0}],navRight:[{key:"ArrowRight"},{key:"l"},{key:"ArrowRight",shiftKey:!0},{key:"l",shiftKey:!0}],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}],strikethrough:[{key:"x",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,altKey:!0}],decreaseNodeWidth:[{key:"ArrowLeft",shiftKey:!0,altKey:!0}]};class Jt{shortcuts;constructor(t){this.shortcuts=t}matches(t,e){const i=this.shortcuts[e];return i?i.some(n=>{const r=n.ctrlKey??!1,s=n.metaKey??!1,o=n.altKey??!1,l=n.shiftKey??!1;return t.ctrlKey!==r||t.metaKey!==s||t.altKey!==o||t.shiftKey!==l?!1:n.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{commandBus;container;shortcutManager;isReadOnly=!1;shortcuts;getSelectedNodeId;cleanupFns=[];constructor(t,e){this.commandBus=t.commandBus,this.container=t.container,this.shortcuts={...Vt,...t.shortcuts},this.shortcutManager=new Jt(this.shortcuts),this.getSelectedNodeId=e,this.attachEvents()}getShortcuts(){return this.shortcuts}setReadOnly(t){this.isReadOnly=t}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}attachEvents(){const t=e=>{if(console.log(`[KeyboardShortcutHandler] RAW KEYDOWN: ${e.key}`),this.isReadOnly)return;const i=e,n=i.target;if(console.log(`[KeyboardShortcutHandler] Target: ${n?n.tagName:"unknown"}`),n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))return;const r=this.getSelectedNodeId();if(console.log(`[KeyboardShortcutHandler] Selected ID: ${r}`),!r){if(this.shortcutManager.matches(i,"navUp")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Up"});return}if(this.shortcutManager.matches(i,"navDown")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Down"});return}if(this.shortcutManager.matches(i,"navLeft")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Left"});return}if(this.shortcutManager.matches(i,"navRight")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Right"});return}}const s=this.shortcutManager.getAction(i);s&&this.handleAction(s,i,r)};document.addEventListener("keydown",t),this.cleanupFns.push(()=>{document.removeEventListener("keydown",t)})}handleAction(t,e,i){switch(t){case"undo":e.preventDefault(),this.commandBus.dispatch({type:"undo"});return;case"redo":e.preventDefault(),this.commandBus.dispatch({type:"redo"});return;case"zoomIn":{e.preventDefault();const n=this.container.getBoundingClientRect();this.commandBus.dispatch({type:"zoom",delta:-100,x:n.left+n.width/2,y:n.top+n.height/2});return}case"zoomOut":{e.preventDefault();const n=this.container.getBoundingClientRect();this.commandBus.dispatch({type:"zoom",delta:100,x:n.left+n.width/2,y:n.top+n.height/2});return}case"resetZoom":e.preventDefault(),this.commandBus.dispatch({type:"zoomReset"});return;case"openCommandPalette":e.preventDefault(),this.commandBus.dispatch({type:"toggleCommandPalette"});return}if(i){switch(t){case"copy":e.preventDefault(),this.commandBus.dispatch({type:"copyNode",nodeId:i});return;case"paste":this.commandBus.dispatch({type:"pasteNode",parentId:i});return;case"navUp":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Up",extendSelection:e.shiftKey});return;case"navDown":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Down",extendSelection:e.shiftKey});return;case"navRight":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Right",extendSelection:e.shiftKey});return;case"navLeft":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Left",extendSelection:e.shiftKey});return}if(!this.isReadOnly)switch(t){case"addChild":e.preventDefault(),this.commandBus.dispatch({type:"addNode",parentId:i});break;case"insertParent":e.preventDefault(),this.commandBus.dispatch({type:"insertParent",nodeId:i});break;case"addSibling":e.preventDefault(),this.commandBus.dispatch({type:"addSibling",nodeId:i,position:"after"});break;case"addSiblingBefore":e.preventDefault(),this.commandBus.dispatch({type:"addSibling",nodeId:i,position:"before"});break;case"deleteNode":e.preventDefault(),this.commandBus.dispatch({type:"deleteNode",nodeId:i});break;case"beginEdit":e.preventDefault(),console.log(`[KeyboardShortcutHandler] beginEdit triggered for ${i}`),this.commandBus.dispatch({type:"editNode",nodeId:i});break;case"cut":e.preventDefault(),this.commandBus.dispatch({type:"cutNode",nodeId:i});break;case"bold":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"bold"}});break;case"italic":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"italic"}});break;case"strikethrough":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"strikethrough"}});break;case"increaseFontSize":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"increaseSize"}});break;case"decreaseFontSize":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"decreaseSize"}});break;case"toggleFold":e.preventDefault(),this.commandBus.dispatch({type:"toggleFold",nodeId:i});break;case"increaseNodeWidth":e.preventDefault(),this.commandBus.dispatch({type:"updateNodeWidth",nodeId:i,increment:20});break;case"decreaseNodeWidth":e.preventDefault(),this.commandBus.dispatch({type:"updateNodeWidth",nodeId:i,increment:-20});break;default:if(t.startsWith("selectColor")){const n=parseInt(t.replace("selectColor",""),10)-1;isNaN(n)||(e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"color",index:n}}))}break}}}}class Qt{commandBus;container;isPanning=!1;lastMouseX=0;lastMouseY=0;cleanupFns=[];constructor(t){this.commandBus=t.commandBus,this.container=t.container,this.attachEvents()}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}attachEvents(){this.container.addEventListener("mousedown",this.handleMouseDown),this.cleanupFns.push(()=>{this.container.removeEventListener("mousedown",this.handleMouseDown)}),window.addEventListener("mousemove",this.handleMouseMove),this.cleanupFns.push(()=>{window.removeEventListener("mousemove",this.handleMouseMove)}),window.addEventListener("mouseup",this.stopPanning),this.cleanupFns.push(()=>{window.removeEventListener("mouseup",this.stopPanning)}),window.addEventListener("mouseleave",this.stopPanning),this.cleanupFns.push(()=>{window.removeEventListener("mouseleave",this.stopPanning)}),this.container.addEventListener("wheel",this.handleWheel,{passive:!1}),this.cleanupFns.push(()=>{this.container.removeEventListener("wheel",this.handleWheel)})}handleMouseDown=t=>{const e=t.target;!e.closest(".mindmap-node")&&e.tagName!=="INPUT"&&(this.isPanning=!0,this.lastMouseX=t.clientX,this.lastMouseY=t.clientY,this.container.style.cursor="all-scroll")};handleMouseMove=t=>{if(this.isPanning){const e=t.clientX-this.lastMouseX,i=t.clientY-this.lastMouseY;this.lastMouseX=t.clientX,this.lastMouseY=t.clientY,this.commandBus.dispatch({type:"pan",dx:e,dy:i})}};stopPanning=()=>{this.isPanning&&(this.isPanning=!1,this.container.style.cursor="default")};handleWheel=t=>{if(t.preventDefault(),t.ctrlKey||t.metaKey){this.commandBus.dispatch({type:"zoom",delta:t.deltaY,x:t.clientX,y:t.clientY});return}let e=1;t.deltaMode===1?e=33:t.deltaMode===2&&(e=window.innerHeight);const i=-t.deltaX*e,n=-t.deltaY*e;this.commandBus.dispatch({type:"pan",dx:i,dy:n})}}class te{commandBus;container;draggedNodeId=null;isReadOnly=!1;ghostElement=null;cleanupFns=[];constructor(t){this.commandBus=t.commandBus,this.container=t.container,this.injectDragStyles(),this.attachEvents()}setReadOnly(t){this.isReadOnly=t}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}injectDragStyles(){if(!document.getElementById("drag-drop-styles")){const t=document.createElement("style");t.id="drag-drop-styles",t.textContent=`
43
+ </svg>`}}const Vt={navUp:[{key:"ArrowUp"},{key:"k"},{key:"ArrowUp",shiftKey:!0},{key:"k",shiftKey:!0}],navDown:[{key:"ArrowDown"},{key:"j"},{key:"ArrowDown",shiftKey:!0},{key:"j",shiftKey:!0}],navLeft:[{key:"ArrowLeft"},{key:"h"},{key:"ArrowLeft",shiftKey:!0},{key:"h",shiftKey:!0}],navRight:[{key:"ArrowRight"},{key:"l"},{key:"ArrowRight",shiftKey:!0},{key:"l",shiftKey:!0}],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}],strikethrough:[{key:"x",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,altKey:!0}],decreaseNodeWidth:[{key:"ArrowLeft",shiftKey:!0,altKey:!0}]};class Jt{shortcuts;constructor(t){this.shortcuts=t}matches(t,e){const i=this.shortcuts[e];return i?i.some(n=>{const r=n.ctrlKey??!1,s=n.metaKey??!1,o=n.altKey??!1,l=n.shiftKey??!1;return t.ctrlKey!==r||t.metaKey!==s||t.altKey!==o||t.shiftKey!==l?!1:n.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{commandBus;container;shortcutManager;isReadOnly=!1;shortcuts;getSelectedNodeId;cleanupFns=[];constructor(t,e){this.commandBus=t.commandBus,this.container=t.container,this.shortcuts={...Vt,...t.shortcuts},this.shortcutManager=new Jt(this.shortcuts),this.getSelectedNodeId=e,this.attachEvents()}getShortcuts(){return this.shortcuts}setReadOnly(t){this.isReadOnly=t}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}attachEvents(){const t=e=>{if(console.log(`[KeyboardShortcutHandler] RAW KEYDOWN: ${e.key}`),this.isReadOnly)return;const i=e,n=i.target;if(console.log(`[KeyboardShortcutHandler] Target: ${n?n.tagName:"unknown"}`),n&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))return;const r=this.getSelectedNodeId();if(console.log(`[KeyboardShortcutHandler] Selected ID: ${r}`),!r){if(this.shortcutManager.matches(i,"navUp")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Up"});return}if(this.shortcutManager.matches(i,"navDown")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Down"});return}if(this.shortcutManager.matches(i,"navLeft")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Left"});return}if(this.shortcutManager.matches(i,"navRight")){i.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:null,direction:"Right"});return}}const s=this.shortcutManager.getAction(i);s&&this.handleAction(s,i,r)};document.addEventListener("keydown",t),this.cleanupFns.push(()=>{document.removeEventListener("keydown",t)})}handleAction(t,e,i){switch(t){case"undo":e.preventDefault(),this.commandBus.dispatch({type:"undo"});return;case"redo":e.preventDefault(),this.commandBus.dispatch({type:"redo"});return;case"zoomIn":{e.preventDefault();const n=this.container.getBoundingClientRect();this.commandBus.dispatch({type:"zoom",delta:-100,x:n.left+n.width/2,y:n.top+n.height/2});return}case"zoomOut":{e.preventDefault();const n=this.container.getBoundingClientRect();this.commandBus.dispatch({type:"zoom",delta:100,x:n.left+n.width/2,y:n.top+n.height/2});return}case"resetZoom":e.preventDefault(),this.commandBus.dispatch({type:"zoomReset"});return;case"openCommandPalette":e.preventDefault(),this.commandBus.dispatch({type:"toggleCommandPalette"});return}if(i){switch(t){case"copy":e.preventDefault(),this.commandBus.dispatch({type:"copyNode",nodeId:i});return;case"paste":if((e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="v")return;e.preventDefault(),this.commandBus.dispatch({type:"pasteNode",parentId:i});return;case"navUp":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Up",extendSelection:e.shiftKey});return;case"navDown":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Down",extendSelection:e.shiftKey});return;case"navRight":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Right",extendSelection:e.shiftKey});return;case"navLeft":e.preventDefault(),this.commandBus.dispatch({type:"navigate",nodeId:i,direction:"Left",extendSelection:e.shiftKey});return}if(!this.isReadOnly)switch(t){case"addChild":e.preventDefault(),this.commandBus.dispatch({type:"addNode",parentId:i});break;case"insertParent":e.preventDefault(),this.commandBus.dispatch({type:"insertParent",nodeId:i});break;case"addSibling":e.preventDefault(),this.commandBus.dispatch({type:"addSibling",nodeId:i,position:"after"});break;case"addSiblingBefore":e.preventDefault(),this.commandBus.dispatch({type:"addSibling",nodeId:i,position:"before"});break;case"deleteNode":e.preventDefault(),this.commandBus.dispatch({type:"deleteNode",nodeId:i});break;case"beginEdit":e.preventDefault(),console.log(`[KeyboardShortcutHandler] beginEdit triggered for ${i}`),this.commandBus.dispatch({type:"editNode",nodeId:i});break;case"cut":e.preventDefault(),this.commandBus.dispatch({type:"cutNode",nodeId:i});break;case"bold":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"bold"}});break;case"italic":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"italic"}});break;case"strikethrough":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"strikethrough"}});break;case"increaseFontSize":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"increaseSize"}});break;case"decreaseFontSize":e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"decreaseSize"}});break;case"toggleFold":e.preventDefault(),this.commandBus.dispatch({type:"toggleFold",nodeId:i});break;case"increaseNodeWidth":e.preventDefault(),this.commandBus.dispatch({type:"updateNodeWidth",nodeId:i,increment:20});break;case"decreaseNodeWidth":e.preventDefault(),this.commandBus.dispatch({type:"updateNodeWidth",nodeId:i,increment:-20});break;default:if(t.startsWith("selectColor")){const n=parseInt(t.replace("selectColor",""),10)-1;isNaN(n)||(e.preventDefault(),this.commandBus.dispatch({type:"styleAction",nodeId:i,action:{type:"color",index:n}}))}break}}}}class Qt{commandBus;container;isPanning=!1;lastMouseX=0;lastMouseY=0;cleanupFns=[];constructor(t){this.commandBus=t.commandBus,this.container=t.container,this.attachEvents()}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}attachEvents(){this.container.addEventListener("mousedown",this.handleMouseDown),this.cleanupFns.push(()=>{this.container.removeEventListener("mousedown",this.handleMouseDown)}),window.addEventListener("mousemove",this.handleMouseMove),this.cleanupFns.push(()=>{window.removeEventListener("mousemove",this.handleMouseMove)}),window.addEventListener("mouseup",this.stopPanning),this.cleanupFns.push(()=>{window.removeEventListener("mouseup",this.stopPanning)}),window.addEventListener("mouseleave",this.stopPanning),this.cleanupFns.push(()=>{window.removeEventListener("mouseleave",this.stopPanning)}),this.container.addEventListener("wheel",this.handleWheel,{passive:!1}),this.cleanupFns.push(()=>{this.container.removeEventListener("wheel",this.handleWheel)})}handleMouseDown=t=>{const e=t.target;!e.closest(".mindmap-node")&&e.tagName!=="INPUT"&&(this.isPanning=!0,this.lastMouseX=t.clientX,this.lastMouseY=t.clientY,this.container.style.cursor="all-scroll")};handleMouseMove=t=>{if(this.isPanning){const e=t.clientX-this.lastMouseX,i=t.clientY-this.lastMouseY;this.lastMouseX=t.clientX,this.lastMouseY=t.clientY,this.commandBus.dispatch({type:"pan",dx:e,dy:i})}};stopPanning=()=>{this.isPanning&&(this.isPanning=!1,this.container.style.cursor="default")};handleWheel=t=>{if(t.preventDefault(),t.ctrlKey||t.metaKey){this.commandBus.dispatch({type:"zoom",delta:t.deltaY,x:t.clientX,y:t.clientY});return}let e=1;t.deltaMode===1?e=33:t.deltaMode===2&&(e=window.innerHeight);const i=-t.deltaX*e,n=-t.deltaY*e;this.commandBus.dispatch({type:"pan",dx:i,dy:n})}}class te{commandBus;container;draggedNodeId=null;isReadOnly=!1;ghostElement=null;isDragging=!1;startPosition=null;DRAG_THRESHOLD=5;cleanupFns=[];constructor(t){this.commandBus=t.commandBus,this.container=t.container,this.injectDragStyles(),this.attachEvents()}setReadOnly(t){this.isReadOnly=t}destroy(){this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}injectDragStyles(){if(!document.getElementById("drag-drop-styles")){const t=document.createElement("style");t.id="drag-drop-styles",t.textContent=`
42
44
  .mindmap-node.drag-over-top {
43
45
  border-top: 4px solid #007bff !important;
44
46
  }
@@ -51,7 +53,7 @@
51
53
  .mindmap-node.drag-over-right {
52
54
  border-right: 4px solid #007bff !important;
53
55
  }
54
- `,document.head.appendChild(t),this.cleanupFns.push(()=>{const e=document.getElementById("drag-drop-styles");e&&e.remove()})}}attachEvents(){const t=n=>this.handlePointerDown(n),e=n=>this.handlePointerMove(n),i=n=>this.handlePointerUp(n);this.container.addEventListener("pointerdown",t),this.cleanupFns.push(()=>this.container.removeEventListener("pointerdown",t)),this.container.addEventListener("pointermove",e),this.cleanupFns.push(()=>this.container.removeEventListener("pointermove",e)),this.container.addEventListener("pointerup",i),this.cleanupFns.push(()=>this.container.removeEventListener("pointerup",i)),this.container.addEventListener("pointercancel",i),this.cleanupFns.push(()=>this.container.removeEventListener("pointercancel",i))}handlePointerDown=t=>{const e=t;if(this.isReadOnly)return;const n=e.target.closest(".mindmap-node");n&&n.dataset.id&&(this.draggedNodeId=n.dataset.id,n.setPointerCapture(e.pointerId),this.ghostElement=n.cloneNode(!0),this.ghostElement.classList.add("kakidash-drag-ghost"),this.ghostElement.style.position="fixed",this.ghostElement.style.pointerEvents="none",this.ghostElement.style.opacity="0.7",this.ghostElement.style.zIndex="9999",this.ghostElement.style.margin="0",this.ghostElement.style.left=`${e.clientX}px`,this.ghostElement.style.top=`${e.clientY}px`,this.ghostElement.style.transform="translate(-50%, -50%)",document.body.appendChild(this.ghostElement))};handlePointerMove=t=>{const e=t;if(this.isReadOnly||!this.draggedNodeId)return;this.ghostElement&&(this.ghostElement.style.left=`${e.clientX}px`,this.ghostElement.style.top=`${e.clientY}px`);const i=document.elementFromPoint(e.clientX,e.clientY);if(!i)return;const n=i.closest(".mindmap-node");if(this.container.querySelectorAll(".mindmap-node").forEach(r=>{r.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}),n&&n.dataset.id&&n.dataset.id!==this.draggedNodeId){const r=this.getDropPosition(e,n);n.classList.add(`drag-over-${r}`)}};handlePointerUp=t=>{const e=t;if(this.ghostElement&&(this.ghostElement.remove(),this.ghostElement=null),this.draggedNodeId){const n=e.target;n.hasPointerCapture&&n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId)}let i=null;if(this.draggedNodeId){const n=document.elementFromPoint(e.clientX,e.clientY);n&&(i=n.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){this.draggedNodeId=null;return}if(i&&i.dataset.id&&this.draggedNodeId){const n=i.dataset.id;if(this.draggedNodeId!==n){const r=this.getDropPosition(e,i);this.commandBus.dispatch({type:"dropNode",draggedId:this.draggedNodeId,targetId:n,position:r})}}this.draggedNodeId=null};getDropPosition(t,e){const i=e.getBoundingClientRect(),n=t.clientX-i.left,r=t.clientY-i.top,s=i.width,o=i.height;return r<o*.25?"top":r>o*.75?"bottom":n<s*.25?"left":(n>s*.75,"right")}}class ee{container;maxWidth;commandBus;constructor(t,e,i){this.container=t,this.maxWidth=e,this.commandBus=i}setMaxWidth(t){this.maxWidth=t}startEditing(t,e){console.log(`[NodeEditor] startEditing called for ${e}`);const i=t.textContent||"",n=this.createEditTextarea(t,i);let r=this.maxWidth;if(t.style.maxWidth){const b=parseInt(t.style.maxWidth,10);isNaN(b)||(r=b)}this.applyTextareaStyles(n,t,r);const s=t.style.outline,o=t.style.boxShadow;t.style.outline="none",t.style.boxShadow="none";const l=this.createSizeUpdater(n,t,r);l(),n.addEventListener("input",l);const g=this.createCleanupFunction(n,t,s,o);this.setupEditEventHandlers(n,e,i,g),t.parentElement?t.parentElement.appendChild(n):this.container.appendChild(n),n.focus({preventScroll:!0}),n.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 n=window.getComputedStyle(e);if(i!==-1){t.style.whiteSpace="pre-wrap",t.style.wordWrap="break-word",t.style.overflowWrap="anywhere";const r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),s=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.borderRightWidth)||0),o=i+r+s;t.style.maxWidth=`${o}px`,t.style.width="max-content"}else t.style.whiteSpace="pre";t.style.font=n.font,t.style.padding=n.padding,t.style.boxSizing="border-box",t.style.backgroundColor=n.backgroundColor,t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.borderTop=n.borderTop,t.style.borderRight=n.borderRight,t.style.borderBottom=n.borderBottom,t.style.borderLeft=n.borderLeft,t.style.borderRadius=n.borderRadius,t.style.zIndex="100"}createSizeUpdater(t,e,i){const n=window.getComputedStyle(e);return()=>{const r=document.createElement("span");r.style.font=n.font,r.style.padding=n.padding,i!==-1?(r.style.whiteSpace="pre-wrap",r.style.wordWrap="break-word",r.style.overflowWrap="anywhere",r.style.maxWidth=`${i}px`,r.style.width="max-content"):r.style.whiteSpace="pre",r.style.visibility="hidden",r.style.position="absolute",r.textContent=t.value||"",(t.value.endsWith(`
55
- `)||t.value==="")&&(r.textContent+="​"),document.body&&document.body.appendChild(r);const s=r.offsetWidth+4,o=r.offsetHeight;t.style.width=Math.max(s,e.offsetWidth)+"px",t.style.height=Math.max(o,e.offsetHeight)+"px",r.parentNode&&r.parentNode.removeChild(r)}}createCleanupFunction(t,e,i,n){return()=>{t.parentNode&&t.parentNode.contains(t)&&t.parentNode.removeChild(t),e.style.outline=i,e.style.boxShadow=n}}setupEditEventHandlers(t,e,i,n){let r=!1;const s=()=>{if(r)return;r=!0;const l=t.value;l!==i&&this.commandBus.dispatch({type:"updateNode",nodeId:e,topic:l}),n(),this.commandBus.dispatch({type:"editEnd",nodeId:e})},o=()=>{r||(r=!0,n(),this.commandBus.dispatch({type:"editEnd",nodeId:e}))};t.addEventListener("blur",()=>{r||s()}),t.addEventListener("keydown",l=>{if(l.stopPropagation(),!l.isComposing)if(l.key==="Enter"){if(l.shiftKey)return;l.preventDefault(),s()}else l.key==="Escape"&&(l.preventDefault(),o())})}}class ie{container;commandBus;mindMap;options;keyboardHandler;zoomPanHandler;dragDropHandler;nodeEditor;cleanupFns=[];isReadOnly=!1;_maxWidth=-1;_getNodeElement;_zoomNode;getSelectedNodeId;constructor(t){this.container=t.container,this.commandBus=t.commandBus,this.mindMap=t.mindMap,this.options=t.options,this._getNodeElement=t.getNodeElement,this._zoomNode=t.zoomNode,this.getSelectedNodeId=t.getSelectedNodeId,this.container.tabIndex=0,this.container.style.outline="none",this.container.style.cursor="default",this.isReadOnly=!!t.options.allowReadOnly,this.keyboardHandler=new qt({commandBus:this.commandBus,container:this.container,shortcuts:this.options.shortcuts},t.getSelectedNodeId),this.zoomPanHandler=new Qt({commandBus:this.commandBus,container:this.container}),this.dragDropHandler=new te({commandBus:this.commandBus,container:this.container}),this.dragDropHandler.setReadOnly(this.isReadOnly),this.nodeEditor=new ee(this.container,this._maxWidth,this.commandBus),this.attachEvents()}get isReadOnlyState(){return this.isReadOnly}getShortcuts(){return this.keyboardHandler.getShortcuts()}setReadOnly(t){this.isReadOnly=t,this.dragDropHandler.setReadOnly(t)}focus(){this.container.focus()}set maxWidth(t){this._maxWidth=t,this.nodeEditor.setMaxWidth(t)}get maxWidth(){return this._maxWidth}editNode(t){const e=this.getNodeElement(t);e&&this.startEditing(e,t)}getNodeElement(t){return this._getNodeElement(t)}zoomNode(t){this._zoomNode(t)}updateSelection(t){}destroy(){this.keyboardHandler.destroy(),this.zoomPanHandler.destroy(),this.dragDropHandler.destroy(),this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}attachEvents(){const t=(e,i,n,r)=>{e.addEventListener(i,n,r),this.cleanupFns.push(()=>{e.removeEventListener(i,n,r)})};t(this.container,"scroll",()=>{(this.container.scrollTop!==0||this.container.scrollLeft!==0)&&(this.container.scrollTop=0,this.container.scrollLeft=0)}),t(this.container,"click",e=>{const n=e.target.closest(".mindmap-node");n&&n.dataset.id?this.commandBus.dispatch({type:"selectNode",nodeId:n.dataset.id,extendSelection:e.shiftKey}):this.commandBus.dispatch({type:"selectNode",nodeId:null}),this.container.focus()}),t(this.container,"dblclick",e=>{if(this.isReadOnly)return;const n=e.target.closest(".mindmap-node");n&&n.dataset.id&&this.startEditing(n,n.dataset.id)}),t(this.container,"contextmenu",e=>{}),t(this.container,"paste",e=>{if(this.isReadOnly)return;const i=this.getSelectedNodeId();if(!i)return;const n=e.clipboardData;if(!n)return;const r=n.items;for(const s of Array.from(r))if(s.type.startsWith("image/")){e.preventDefault();const o=s.getAsFile();if(o){const l=new FileReader;l.onload=g=>{const b=g.target?.result,u=new Image;u.onload=()=>{this.commandBus.dispatch({type:"pasteImage",parentId:i,imageData:b,width:u.width,height:u.height})},u.src=b},l.readAsDataURL(o)}}}),this.commandBus.on("editNode",e=>{this.editNode(e.nodeId)})}startEditing(t,e){const i=this.mindMap?.findNode(e);if(i&&i.image){this.zoomNode(e);return}this.nodeEditor.startEditing(t,e)}}class ne{handlers=new Map;on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){const i=this.handlers.get(t);i&&(i.delete(e),i.size===0&&this.handlers.delete(t))}dispatch(t){const e=this.handlers.get(t.type);e&&e.forEach(i=>i(t))}destroy(){this.handlers.clear()}}class re{measureFn;heightCache=new Map;constructor(t){this.measureFn=t}calculate(t,e){this.heightCache.clear();const i={nodes:[],connections:[]},{width:n,height:r}=this.measureNode(t);if(i.nodes.push({nodeId:t.id,x:0,y:0,width:n,height:r,direction:"right",isRoot:!0}),t.presentation?.isFolded||t.children.length===0)return i;let s=[],o=[];return e==="Both"?t.children.forEach((l,g)=>{(l.presentation?.layoutSide||(g%2===0?"right":"left"))==="right"?s.push(l):o.push(l)}):e==="Left"?o=t.children:s=t.children,s.length>0&&this.calculateChildrenStack(t,s,0,0,e,"right",n,i),o.length>0&&this.calculateChildrenStack(t,o,0,0,e,"left",n,i),i}calculateChildrenStack(t,e,i,n,r,s,o,l){const g=e.reduce((c,m)=>c+this.getNodeHeight(m),0);let b=n-g/2;const u=80;let y=0;t.isRoot?y=s==="right"?i+o/2:i-o/2:s==="right"?y=i+o:y=i-o,e.forEach(c=>{const m=this.getNodeHeight(c),h=b+m/2,p=s==="right"?y+u:y-u,{width:f,height:w}=this.measureNode(c);if(l.nodes.push({nodeId:c.id,x:p,y:h,width:f,height:w,direction:s,isRoot:!1}),l.connections.push({fromX:y,fromY:n,toX:p,toY:h,toNodeId:c.id}),!c.presentation?.isFolded&&c.children.length>0){const _=s;let C=[],S=[];_==="left"?S=c.children:C=c.children,C.length>0&&this.calculateChildrenStack(c,C,p,h,r,"right",f,l),S.length>0&&this.calculateChildrenStack(c,S,p,h,r,"left",f,l)}b+=m})}getChildrenHeight(t){return t.children.reduce((e,i)=>e+this.getNodeHeight(i),0)}getNodeHeight(t){if(this.heightCache.has(t.id))return this.heightCache.get(t.id);const{height:e}=this.measureNode(t),i=20;if(t.children.length===0||t.presentation?.isFolded){const s=e+i;return this.heightCache.set(t.id,s),s}const n=this.getChildrenHeight(t),r=Math.max(e+i,n);return this.heightCache.set(t.id,r),r}measureNode(t){return this.measureFn(t)}}class se{container;overlay;paletteEl;inputEl;resultListEl;options;customCommands=[];results=[];selectedIndex=-1;mode="menu";menuCommands=[];ALL_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"},{id:"num_0_blue",topic:"0-blue",type:"icon"},{id:"num_1_blue",topic:"1-blue",type:"icon"},{id:"num_2_blue",topic:"2-blue",type:"icon"},{id:"num_3_blue",topic:"3-blue",type:"icon"},{id:"num_4_blue",topic:"4-blue",type:"icon"},{id:"num_5_blue",topic:"5-blue",type:"icon"},{id:"num_6_blue",topic:"6-blue",type:"icon"},{id:"num_7_blue",topic:"7-blue",type:"icon"},{id:"num_8_blue",topic:"8-blue",type:"icon"},{id:"num_9_blue",topic:"9-blue",type:"icon"},{id:"num_0_red",topic:"0-red",type:"icon"},{id:"num_1_red",topic:"1-red",type:"icon"},{id:"num_2_red",topic:"2-red",type:"icon"},{id:"num_3_red",topic:"3-red",type:"icon"},{id:"num_4_red",topic:"4-red",type:"icon"},{id:"num_5_red",topic:"5-red",type:"icon"},{id:"num_6_red",topic:"6-red",type:"icon"},{id:"num_7_red",topic:"7-red",type:"icon"},{id:"num_8_red",topic:"8-red",type:"icon"},{id:"num_9_red",topic:"9-red",type:"icon"}];constructor(t,e){this.container=t,this.options=e;const i=e.disabledFeatures||[];this.menuCommands=this.ALL_MENU_COMMANDS.filter(n=>!(n.id==="icon"&&i.includes("icon")||n.id==="search-nodes"&&i.includes("search")||n.id==="import"&&i.includes("import")||n.id==="export"&&i.includes("export"))),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",n=>{const r=n.target.value;if(this.mode==="menu")this.renderList(this.getMenuResults(r));else if(this.mode==="import"){const s=this.IMPORT_COMMANDS.filter(o=>o.topic.toLowerCase().includes(r.toLowerCase()));this.renderList(s)}else if(this.mode==="export"){const s=this.EXPORT_COMMANDS.filter(o=>o.topic.toLowerCase().includes(r.toLowerCase()));this.renderList(s)}else if(this.mode==="icon"){const s=this.ICON_LIST.filter(o=>o.topic.toLowerCase().includes(r.toLowerCase()));this.renderList(s)}else this.options.onInput(r)}),e.addEventListener("keydown",n=>{n.key==="ArrowDown"?(n.preventDefault(),this.moveSelection(1)):n.key==="ArrowUp"?(n.preventDefault(),this.moveSelection(-1)):n.key==="Enter"?(n.preventDefault(),this.confirmSelection()):n.key==="Escape"?(n.preventDefault(),this.close()):n.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.getMenuResults()))});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.getMenuResults())}addCustomCommand(t){this.customCommands.push(t)}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"})))}getMenuResults(t=""){const e=t.toLowerCase().trim(),i=this.menuCommands.filter(r=>r.topic.toLowerCase().includes(e)),n=this.customCommands.filter(r=>r.topic.toLowerCase().includes(e));return[...i,...n.map(r=>({...r,type:"custom"}))]}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 n=document.createElement("li");if(n.style.borderBottom="1px solid #f9f9f9",e.type==="icon"&&e.id!=="delete"){n.style.display="flex",n.style.alignItems="center";const r=It[e.id];if(r){const o=document.createElement("div");o.style.width="20px",o.style.height="20px",o.style.marginRight="8px",o.style.flexShrink="0",o.innerHTML=`<svg viewBox="${r.viewBox}" width="20" height="20">${r.path}</svg>`,n.appendChild(o)}const s=document.createElement("span");s.textContent=e.topic,n.appendChild(s)}else n.textContent=e.topic;n.addEventListener("mouseenter",()=>{this.setSelectedIndex(i)}),n.addEventListener("click",()=>{this.selectItem(e)}),this.resultListEl.appendChild(n)}),t.length>0&&this.setSelectedIndex(0)}selectItem(t){if(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());else if(t.type==="custom"){const e=this.customCommands.find(i=>i.id===t.id);if(e){const i=this.options.getSelectedNodeId?this.options.getSelectedNodeId():null;e.execute(i)}this.close()}else 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 n=e[i];i===t?(n.style.backgroundColor="#007acc",n.style.color="white"):(n.style.backgroundColor="transparent",n.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])}}class oe{constructor(){}show(t,e,i){if(typeof document>"u")return;const n=document.createElement("div");n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100vw",n.style.height="100vh",n.style.backgroundColor="rgba(0,0,0,0.5)",n.style.zIndex="3000",n.style.display="flex",n.style.justifyContent="center",n.style.alignItems="center",n.style.opacity="0",n.style.transition="opacity 0.2s";const r=document.createElement("div");r.style.backgroundColor="white",r.style.padding="20px",r.style.borderRadius="8px",r.style.boxShadow="0 4px 6px rgba(0,0,0,0.1)",r.style.maxWidth="600px",r.style.width="90%",r.style.maxHeight="90vh",r.style.overflowY="auto",r.style.position="relative";const s=document.createElement("h2");s.textContent=e==="ja"?"ヘルプ":"Help",s.style.margin="0 0 15px 0",s.style.fontSize="1.5em",s.style.borderBottom="1px solid #eee",s.style.paddingBottom="10px",r.appendChild(s);const o=document.createElement("button");if(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",()=>{g()}),r.appendChild(o),i){const u=document.createElement("h3");u.textContent=e==="ja"?"ツールバーアイコン":"Toolbar Icons",u.style.marginTop="10px",u.style.marginBottom="10px",u.style.fontSize="1.2em",u.style.color="#333",u.style.borderBottom="1px solid #f0f0f0",r.appendChild(u);const y=document.createElement("table");y.style.width="100%",y.style.borderCollapse="collapse",y.style.fontSize="0.9em",y.style.marginBottom="20px",i.getIconDescriptions(e).forEach(m=>{const h=document.createElement("tr");h.style.borderBottom="1px solid #f9f9f9";const p=document.createElement("td");p.style.padding="8px",p.style.width="40px",p.style.textAlign="center";let f="";switch(m.id){case"right":f=i.getRightIcon();break;case"left":f=i.getLeftIcon();break;case"both":f=i.getBothIcon();break;case"default":f=i.getThemeDefaultIcon();break;case"simple":f=i.getThemeSimpleIcon();break;case"colorful":f=i.getThemeColorfulIcon();break;case"custom":f=i.getThemeCustomIcon();break;case"resetZoom":f=i.getZoomResetIcon();break;case"help":f=i.getHelpIcon();break}const w=document.createElement("div");w.style.width="24px",w.style.height="24px",w.style.display="flex",w.style.alignItems="center",w.style.justifyContent="center",w.style.color="#555",w.innerHTML=f,p.appendChild(w);const _=document.createElement("td");_.textContent=m.desc,_.style.padding="8px",_.style.textAlign="left",_.style.color="#333",h.appendChild(p),h.appendChild(_),y.appendChild(h)}),r.appendChild(y)}[{title:e==="ja"?"一般":"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:e==="ja"?"編集 (テキスト入力)":"Editing (Text Input)",actions:[{key:"Enter",desc:"Confirm Edit",descJa:"編集を確定"},{key:"Shift + Enter",desc:"New Line",descJa:"改行"},{key:"Esc",desc:"Cancel Edit",descJa:"編集をキャンセル"}]},{title:e==="ja"?"スタイリング (選択中)":"Styling (Selection)",actions:[{action:"bold",desc:"Toggle Bold",descJa:"太字 (Bold) 切り替え"},{action:"italic",desc:"Toggle Italic",descJa:"斜体 (Italic) 切り替え"},{action:"strikethrough",desc:"Toggle Strikethrough",descJa:"取り消し線 (Strikethrough) 切り替え"},{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(u=>{const y=[];if(u.actions.forEach(w=>{let _="";const C=w;if(C.key)_=C.key;else if(C.action&&t[C.action]){const S=t[C.action];if(S&&S.length>0){const z=S.map(B=>{const O=[];return(B.ctrlKey||B.metaKey)&&O.push("Ctrl/Cmd"),B.altKey&&O.push("Alt"),B.shiftKey&&O.push("Shift"),B.key===" "?O.push("Space"):O.push(B.key),O.join(" + ")});_=[...new Set(z)].join(" / ")}}_&&y.push({key:_,desc:e==="ja"&&C.descJa||C.desc})}),y.length===0)return;const c=document.createElement("h3");c.textContent=u.title,c.style.marginTop="20px",c.style.marginBottom="10px",c.style.fontSize="1.2em",c.style.color="#333",c.style.borderBottom="1px solid #f0f0f0",r.appendChild(c);const m=document.createElement("table");m.style.width="100%",m.style.borderCollapse="collapse",m.style.fontSize="0.9em";const h=document.createElement("tr");h.style.borderBottom="2px solid #ddd";const p=document.createElement("th");p.textContent=e==="ja"?"キー":"Key",p.style.textAlign="center",p.style.padding="8px 0",p.style.width="40%",p.style.color="#666";const f=document.createElement("th");f.textContent=e==="ja"?"説明":"Description",f.style.textAlign="center",f.style.padding="8px 0",f.style.color="#666",h.appendChild(p),h.appendChild(f),m.appendChild(h),y.forEach(w=>{const _=document.createElement("tr");_.style.borderBottom="1px solid #f9f9f9";const C=document.createElement("td");C.textContent=w.key,C.style.padding="6px 0",C.style.fontWeight="bold",C.style.color="#555",C.style.minWidth="180px",C.style.textAlign="center";const S=document.createElement("td");S.textContent=w.desc,S.style.padding="6px 0",S.style.textAlign="left",S.style.color="#333",_.appendChild(C),_.appendChild(S),m.appendChild(_)}),r.appendChild(m)}),n.appendChild(r),document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1"});const g=()=>{n.style.opacity="0",setTimeout(()=>{document.body.contains(n)&&document.body.removeChild(n)},200),document.removeEventListener("keydown",b)},b=u=>{u.key==="Escape"&&g()};document.addEventListener("keydown",b),n.addEventListener("click",u=>{u.target===n&&g()})}}class ae{mindMap;service;renderer;eventBus;styleEditor;commandPalette;locale;interactionOrchestrator;layoutSwitcher;fileIOService;themeService;commandBus;historyService;clipboardService;searchService;viewportService;navigationService;anchorNodeId=null;selectedNodeId=null;selectedNodeIds=new Set;layoutMode="Right";isBatching=!1;maxWidth=-1;pendingNodeCreation=!1;constructor(t){this.mindMap=t.mindMap,this.service=t.service,this.renderer=t.renderer,this.styleEditor=t.styleEditor,this.eventBus=t.eventBus,this.fileIOService=t.fileIOService,this.themeService=t.themeService,this.historyService=t.historyService,this.clipboardService=t.clipboardService,this.searchService=t.searchService,this.viewportService=t.viewportService,this.navigationService=t.navigationService,this.locale=t.locale??"en",this.commandBus=t.commandBus,this.commandPalette=new se(this.renderer.container,{onInput:e=>this.handleSearchInput(e),onSelect:e=>this.handleSearchResultSelect(e),onIconSelect:e=>this.handleIconSelect(e),onCommandSelect:e=>this.handleCommandSelect(e),onClose:()=>{this.interactionOrchestrator&&this.interactionOrchestrator.focus()},getSelectedNodeId:()=>this.selectedNodeId,disabledFeatures:t.commandPaletteFeatures}),this.subscribeToCommands(),this.subscribeToModel()}subscribeToModel(){this.eventBus.on("model:change",()=>{this.render()})}subscribeToCommands(){const t=this.commandBus;t.on("addNode",e=>this.addChildNode(e.parentId)),t.on("addSibling",e=>this.addSiblingNode(e.nodeId,e.position)),t.on("deleteNode",e=>this.removeNode(e.nodeId)),t.on("insertParent",e=>this.insertParentNode(e.nodeId)),t.on("dropNode",e=>this.moveNode(e.draggedId,e.targetId,e.position)),t.on("updateNode",e=>this.updateNodeTopic(e.nodeId,e.topic)),t.on("navigate",e=>this.navigateNode(e.nodeId,e.direction,e.extendSelection)),t.on("pan",e=>this.panBoard(e.dx,e.dy)),t.on("zoom",e=>this.zoomBoard(e.delta,e.x,e.y)),t.on("zoomReset",()=>this.resetZoom()),t.on("copyNode",e=>this.copyNode(e.nodeId)),t.on("pasteNode",e=>this.pasteNode(e.parentId)),t.on("cutNode",e=>this.cutNode(e.nodeId)),t.on("pasteImage",e=>this.pasteImage(e.parentId,e.imageData,e.width,e.height)),t.on("undo",()=>this.undo()),t.on("redo",()=>this.redo()),t.on("styleAction",e=>this.onStyleAction(e.nodeId,e.action)),t.on("toggleFold",e=>this.toggleFold(e.nodeId)),t.on("toggleCommandPalette",()=>this.toggleCommandPalette()),t.on("updateNodeWidth",e=>this.updateNodeWidth(e.nodeId,e.increment)),t.on("setTheme",e=>this.setTheme(e.theme)),t.on("setLayoutMode",e=>this.setLayoutMode(e.mode)),t.on("editEnd",()=>this.onEditEnd()),t.on("selectNode",e=>{e.extendSelection&&e.nodeId?this.selectRangeTo(e.nodeId):this.selectNode(e.nodeId)})}setInteractionOrchestrator(t){this.interactionOrchestrator=t}setLayoutSwitcher(t){this.layoutSwitcher=t,this.themeService.setLayoutSwitcher(t)}init(t,e){this.viewportService.setInitialPan(t*.2,e/2),this.themeService.applyInitialTheme(),this.viewportService.startAnimationLoop(),this.render()}destroy(){this.viewportService.destroy()}getData(){const t=this.service.exportData();return t.selectedId=this.selectedNodeId||void 0,t.selectedIds=Array.from(this.selectedNodeIds),t}loadData(t){try{this.service.importData(t),this.render(),this.restoreSelection(t),this.eventBus.emit("model:load",t),t.theme&&this.setTheme(t.theme,{saveState:!1,emitChange:!1}),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}getSelectedNodeIds(){return Array.from(this.selectedNodeIds)}getIdsToActOn(t){return this.selectedNodeIds.has(t)?Array.from(this.selectedNodeIds):[t]}saveState(){if(this.isBatching)return;const t=this.getData();this.historyService.saveState(t)}addNode(t,e,i,n={emitChange:!0}){n.emitChange&&this.saveState(),this.eventBus.emit("command",{name:"addNode",args:{parentId:t,topic:e,layoutSide:i}});const r=this.service.addNode(t,e,i);return r&&(this.render(),this.eventBus.emit("node:add",{id:r.id,topic:r.topic}),n.emitChange&&this.eventBus.emit("model:change",void 0)),r}addSibling(t,e="after",i="New topic",n={emitChange:!0}){n.emitChange&&this.saveState(),this.eventBus.emit("command",{name:"addSibling",args:{referenceId:t,position:e,topic:i}});const r=this.mindMap.findNode(t);if(!r||!r.parentId)return null;const s=this.mindMap.findNode(r.parentId);s&&s.isRoot&&this.layoutMode==="Both"&&this.navigationService.ensureExplicitLayoutSides(s);const o=this.service.addSibling(t,e,i);if(o){if(s&&s.isRoot&&this.layoutMode==="Both"){const l=r.presentation.layoutSide||(s.children.indexOf(r)%2===0?"right":"left");o.presentation.layoutSide=l}this.render(),this.eventBus.emit("node:add",{id:o.id,topic:o.topic}),n.emitChange&&this.eventBus.emit("model:change",void 0)}return o}insertParent(t,e="New topic",i={emitChange:!0}){i.emitChange&&this.saveState(),this.eventBus.emit("command",{name:"insertParent",args:{targetId:t,topic:e}});const n=this.service.insertParent(t,e);return n&&(this.render(),this.eventBus.emit("node:add",{id:n.id,topic:n.topic}),i.emitChange&&this.eventBus.emit("model:change",void 0)),n}deleteNode(t){this.saveState(),this.eventBus.emit("command",{name:"deleteNode",args:{nodeId:t}});const e=this.getIdsToActOn(t);e.length>1?this.service.removeNodes(e)&&(this.render(),e.forEach(i=>this.eventBus.emit("node:remove",i)),this.eventBus.emit("model:change",void 0)):this.service.removeNode(t)&&(this.render(),this.eventBus.emit("node:remove",t),this.eventBus.emit("model:change",void 0))}updateNode(t,e){if(this.saveState(),this.eventBus.emit("command",{name:"updateNode",args:{nodeId:t,updates:e}}),this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState)return;let i=!1;const n=this.getIdsToActOn(t);if(e.topic!==void 0&&this.service.updateNodeTopic(t,e.topic)&&(i=!0),e.style!==void 0&&this.service.updateNodesStyle(n,e.style)&&(i=!0),e.icon!==void 0){let r=!1;n.forEach(s=>{this.service.updateNodeIcon(s,e.icon)&&(r=!0)}),r&&(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.saveState(),this.eventBus.emit("command",{name:"updateNodeWidth",args:{nodeId:t,increment:e}}),this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState)return;const i=this.mindMap.findNode(t);if(!i)return;let n=i.presentation.customWidth;n===void 0&&(n=this.renderer.measureNode(i,this.mindMap).width);let r=n+e;r<50&&(r=50),this.service.updateNodeCustomWidth(t,r)&&(this.render(),this.eventBus.emit("model:change",void 0))}addChildNode(t){const e=this.mindMap.findNode(t);e&&e.isRoot&&this.layoutMode==="Both"&&this.navigationService.ensureExplicitLayoutSides(e);let i;if(this.layoutMode==="Both"&&e&&e.isRoot){let r=0,s=0;e.children.forEach((o,l)=>{(o.presentation.layoutSide||(l%2===0?"right":"left"))==="left"?r++:s++}),i=r<s?"left":"right"}this.pendingNodeCreation=!0;const n=this.addNode(t,"New topic",i,{emitChange:!1});n&&(this.selectNode(n.id),this.ensureNodeVisible(n.id,!1,!0),this.interactionOrchestrator.editNode(n.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.interactionOrchestrator.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.interactionOrchestrator.editNode(e.id))}removeNode(t){const e=this.getIdsToActOn(t),i=this.findTargetIdAfterRemoval(t,e);this.deleteNode(t),this.selectNode(i)}selectNode(t){this.anchorNodeId=null,!(this.selectedNodeId===t&&this.selectedNodeIds.size===1&&t&&this.selectedNodeIds.has(t))&&(t===null&&this.selectedNodeId===null&&this.selectedNodeIds.size===0||(this.selectedNodeId=t,this.selectedNodeIds.clear(),t&&this.selectedNodeIds.add(t),this.updateSelectionState()))}selectNodes(t){this.selectedNodeIds=new Set(t),this.selectedNodeId=t.length>0?t[t.length-1]:null,this.updateSelectionState()}updateSelectionState(){const t=this.selectedNodeId;if(this.interactionOrchestrator&&this.interactionOrchestrator.updateSelection(t),t){const e=this.mindMap.findNode(t);e&&(!e.image&&this.interactionOrchestrator&&!this.interactionOrchestrator.isReadOnlyState?this.styleEditor.show(t,e.style):this.styleEditor.hide())}else this.styleEditor.hide();this.renderSelection(),this.eventBus.emit("node:select",t),this.eventBus.emit("selection:change",Array.from(this.selectedNodeIds))}restoreSelection(t){t.selectedIds&&t.selectedIds.length>0?(this.selectNodes(t.selectedIds),this.ensureNodeVisible(t.selectedIds[0],!0,!0)):t.selectedId?(this.selectNode(t.selectedId),this.ensureNodeVisible(t.selectedId,!0,!0)):(this.selectNode(null),this.ensureNodeVisible(this.mindMap.root.id,!0,!0))}findTargetIdAfterRemoval(t,e){const i=this.mindMap.findNode(t);if(i){let n=i;for(;n&&n.parentId;){if(!e.includes(n.parentId))return n.parentId;n=this.mindMap.findNode(n.parentId)}}return this.mindMap.root.id}moveNode(t,e,i){this.saveState(),this.eventBus.emit("command",{name:"moveNode",args:{nodeId:t,targetId:e,position:i}});const n=this.mindMap.findNode(e);if(n){if(i==="top"){if(n.isRoot)return;this.service.reorderNode(t,e,"before")}else if(i==="bottom"){if(n.isRoot)return;this.service.reorderNode(t,e,"after")}else if(n.isRoot){const r=i==="left"?"left":"right";this.service.moveNode(t,e,r)}else((this.navigationService.getNodeDirection(n)==="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(){if(this.isBatching)return;const e=new re(n=>this.renderer.measureNode(n,this.mindMap)).calculate(this.mindMap.root,this.layoutMode);let i;this.selectedNodeIds instanceof Set?i=this.selectedNodeIds:Array.isArray(this.selectedNodeIds)?i=new Set(this.selectedNodeIds):typeof this.selectedNodeIds=="string"?i=new Set([this.selectedNodeIds]):i=new Set,this.renderer.renderFromLayout(e,this.mindMap,i,this.layoutMode),this.viewportService.applyTransform()}renderSelection(){this.isBatching||(this.renderer.updateSelection(this.selectedNodeIds),this.viewportService.applyTransform())}setLayoutMode(t){this.eventBus.emit("command",{name:"setLayoutMode",args:{mode:t}}),this.layoutMode=t,this.navigationService.setLayoutMode(t),this.layoutSwitcher&&this.layoutSwitcher.setMode(t);const e=this.renderer.container.clientWidth,i=this.renderer.container.clientHeight;t==="Right"?this.viewportService.setInitialPan(e*.2,i/2):t==="Left"?this.viewportService.setInitialPan(e*.8,i/2):this.viewportService.setInitialPan(e*.5,i/2),this.render(),this.selectedNodeId?this.ensureNodeVisible(this.selectedNodeId,!0,!0):this.ensureNodeVisible(this.mindMap.root.id,!0,!0)}getLayoutMode(){return this.layoutMode}setMaxNodeWidth(t){this.maxWidth=t,this.renderer.maxWidth=t,this.interactionOrchestrator&&(this.interactionOrchestrator.maxWidth=t),this.render()}getMaxNodeWidth(){return this.maxWidth}updateGlobalStyles(t){this.themeService.updateGlobalStyles(t)}setTheme(t,e={saveState:!0,emitChange:!0}){this.themeService.setTheme(t,e)}resetZoom(){this.viewportService.resetZoom(),this.render()}panBoard(t,e){this.viewportService.pan(t,e)}zoomBoard(t,e,i){this.viewportService.zoom(t,e,i)}setReadOnly(t){this.interactionOrchestrator&&this.interactionOrchestrator.setReadOnly(t),t&&this.styleEditor.hide()}undo(){const t=this.getData(),e=this.historyService.undo(t);e&&(this.eventBus.emit("command",{name:"undo"}),this.loadData(e),this.render(),this.eventBus.emit("model:change",void 0))}redo(){const t=this.getData(),e=this.historyService.redo(t);e&&(this.eventBus.emit("command",{name:"redo"}),this.loadData(e),this.render(),this.eventBus.emit("model:change",void 0))}toggleFold(t){this.saveState(),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,i=!1){if(!t){this.selectNode(this.mindMap.root.id);return}if(!this.mindMap.findNode(t))return;const r=this.navigationService.navigate(t,e);r&&(i?this.selectRange(t,r):this.selectNode(r)),this.selectedNodeId&&this.selectedNodeId!==t&&setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0),0)}selectRangeTo(t){this.selectedNodeId?this.selectRange(this.selectedNodeId,t):this.selectNode(t)}selectRange(t,e){this.anchorNodeId||(this.anchorNodeId=t);const i=this.mindMap.findNode(this.anchorNodeId),n=this.mindMap.findNode(e);if(!i||!n)return;if(i.parentId&&i.parentId===n.parentId){const s=this.mindMap.findNode(i.parentId);if(s){const o=s.children.findIndex(g=>g.id===i.id),l=s.children.findIndex(g=>g.id===n.id);if(o!==-1&&l!==-1){const g=Math.min(o,l),b=Math.max(o,l),u=s.children.slice(g,b+1).map(y=>y.id);this.selectNodes(u),this.selectedNodeId=e,this.updateSelectionState();return}}}const r=new Set(this.selectedNodeIds);r.add(e),this.selectNodes(Array.from(r)),this.selectedNodeId=e,this.updateSelectionState()}copyNode(t){const e=this.getIdsToActOn(t);e.length>1?this.clipboardService.copyNodes(e):this.clipboardService.copyNodes([t])}pasteNode(t){this.saveState(),this.eventBus.emit("command",{name:"pasteNode",args:{parentId:t}});const e=this.clipboardService.createPastedNodes(t),i=e.length>0?e[0]:null;e.length>0&&this.service.addExistingNodes(t,e),i&&(this.render(),this.selectNode(i.id),this.eventBus.emit("node:add",{id:i.id,topic:i.topic}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(i.id,!0),0))}cutNode(t){this.saveState(),this.eventBus.emit("command",{name:"cutNode",args:{nodeId:t}});const e=this.getIdsToActOn(t),i=this.findTargetIdAfterRemoval(t,e);e.length>1?(this.clipboardService.copyNodes(e),this.service.removeNodes(e)):(this.clipboardService.copyNodes([t]),this.service.removeNode(t)),this.selectNode(i),this.render(),e.forEach(n=>this.eventBus.emit("node:remove",n)),this.eventBus.emit("model:change",void 0)}pasteImage(t,e,i,n){this.saveState(),this.eventBus.emit("command",{name:"pasteImage",args:{parentId:t,width:i,height:n}});const r=this.service.addImageNode(t,e,i,n);r&&(this.render(),this.selectNode(r.id),this.eventBus.emit("node:add",{id:r.id,topic:""}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(r.id,!0),0))}onEditEnd(){this.pendingNodeCreation&&(this.pendingNodeCreation=!1,this.eventBus.emit("model:change",void 0))}onStyleAction(t,e){if(this.saveState(),this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState)return;const i=this.mindMap.findNode(t);if(!i)return;const n=i.style||{};let r=null;if(e.type==="bold")r={fontWeight:n.fontWeight==="bold"?"normal":"bold"};else if(e.type==="italic")r={fontStyle:n.fontStyle==="italic"?"normal":"italic"};else if(e.type==="strikethrough")r={textDecoration:n.textDecoration==="line-through"?"none":"line-through"};else if(e.type==="color")e.index>=0&&e.index<vt.PALETTE.length&&(r={color:vt.PALETTE[e.index]});else if(e.type==="increaseSize"||e.type==="decreaseSize"){const s=vt.FONT_SIZES,o=n.fontSize||"";let l=s.findIndex(b=>b.value===o);l===-1&&(l=0);const g=e.type==="increaseSize"?Math.min(s.length-1,l+1):Math.max(0,l-1);g!==l&&(r={fontSize:s[g].value})}if(r){const s=this.getIdsToActOn(t);this.service.updateNodesStyle(s,r)&&(this.render(),this.eventBus.emit("model:change",void 0),this.selectedNodeId===t&&this.styleEditor.show(t,{...n,...r}))}}toggleCommandPalette(){this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState||this.commandPalette.toggle()}registerCommand(t){this.commandPalette.addCustomCommand(t)}searchNodes(t){return this.searchService.searchNodes(t)}handleSearchInput(t){const e=this.searchService.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.fileIOService.importXMind().then(e=>{e&&this.loadData(e)}):t==="export-png"?this.fileIOService.exportPng():t==="export-svg"?this.fileIOService.exportSvg():t==="export-markdown"&&this.fileIOService.exportMarkdown()}ensureNodeVisible(t,e=!1,i=!1){this.viewportService.ensureNodeVisible(t,e,i)}showHelpModal(){if(!this.interactionOrchestrator||typeof document>"u")return;new oe().show(this.interactionOrchestrator.getShortcuts(),this.locale,this.layoutSwitcher)}}class de{panX=0;panY=0;targetPanX=0;targetPanY=0;scale=1;animationFrameId=null;renderer;constructor(t){this.renderer=t}getScale(){return this.scale}getPan(){return{x:this.panX,y:this.panY}}getTargetPan(){return{x:this.targetPanX,y:this.targetPanY}}setInitialPan(t,e){this.panX=t,this.panY=e,this.targetPanX=t,this.targetPanY=e}pan(t,e){this.targetPanX+=t,this.targetPanY+=e}zoom(t,e,i){const o=this.renderer.container.getBoundingClientRect(),l=e-o.left,g=i-o.top,b=Math.min(Math.max(this.scale*(1-t*.001),.1),5),u=l-(l-this.panX)*(b/this.scale),y=g-(g-this.panY)*(b/this.scale);this.panX=u,this.panY=y,this.targetPanX=u,this.targetPanY=y,this.scale=b,this.renderer.updateTransform(this.panX,this.panY,this.scale)}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}applyTransform(){this.renderer.updateTransform(this.panX,this.panY,this.scale)}ensureNodeVisible(t,e=!1,i=!1){const n=this.renderer.container.querySelector(`.mindmap-node[data-id="${t}"]`);if(!n)return;const r=n.getBoundingClientRect(),s=this.renderer.container.getBoundingClientRect(),o=50;let l=0,g=0;const b=r.left<s.left+o,u=r.right>s.right-o,y=r.top<s.top+o,c=r.bottom>s.bottom-o;if(e&&(b||u||y||c)){const m=r.left+r.width/2,h=r.top+r.height/2,p=s.left+s.width/2,f=s.top+s.height/2;l=p-m,g=f-h}else b?l=s.left+o-r.left:u&&(l=s.right-o-r.right),y?g=s.top+o-r.top:c&&(g=s.bottom-o-r.bottom);(l!==0||g!==0)&&(i?(this.panX+=l,this.panY+=g,this.targetPanX=this.panX,this.targetPanY=this.panY,this.renderer.updateTransform(this.panX,this.panY,this.scale)):this.pan(l,g))}startAnimationLoop(){let t=performance.now();const e=()=>{const i=performance.now(),n=(i-t)/1e3;t=i;const r=1-Math.exp(-8*n),s=this.targetPanX-this.panX,o=this.targetPanY-this.panY;Math.abs(s)>.1||Math.abs(o)>.1?(this.panX+=s*r,this.panY+=o*r,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()}destroy(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}}class le{mindMap;layoutMode="Right";constructor(t){this.mindMap=t}setLayoutMode(t){this.layoutMode=t}getLayoutMode(){return this.layoutMode}navigate(t,e){const i=this.mindMap.findNode(t);if(i)switch(e){case"Left":return this.navigateLeft(i);case"Right":return this.navigateRight(i);case"Up":return this.navigateUp(i);case"Down":return this.navigateDown(i)}}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.presentation.layoutSide?e.presentation.layoutSide:i.children.findIndex(r=>r.id===e.id)%2===0?"right":"left";e=i}return"right"}ensureExplicitLayoutSides(t){!t.isRoot||this.layoutMode!=="Both"||t.children.forEach((e,i)=>{e.presentation.layoutSide||(e.presentation.layoutSide=i%2===0?"right":"left")})}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,n)=>(i.presentation.layoutSide||(n%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,n)=>(i.presentation.layoutSide||(n%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),n=e.children.filter(s=>this.getNodeDirection(s)===i),r=n.findIndex(s=>s.id===t.id);if(r>0)return n[r-1].id}}}navigateDown(t){if(t.parentId){const e=this.mindMap.findNode(t.parentId);if(e){const i=this.getNodeDirection(t),n=e.children.filter(s=>this.getNodeDirection(s)===i),r=n.findIndex(s=>s.id===t.id);if(r!==-1&&r<n.length-1)return n[r+1].id}}}}class Bt{generate(t){const e=t.querySelectorAll("svg");let i=null;for(let X=0;X<e.length;X++){const k=e[X];if(k.style.zIndex==="0"&&k.style.position==="absolute"){i=k;break}}!i&&e.length>0&&e[0].parentElement===t&&(i=e[0]);const n=t.querySelectorAll("div");let r=null;for(let X=0;X<n.length;X++){const k=n[X];if(k.style.zIndex==="1"&&k.style.position==="absolute"){r=k;break}}if(!i||!r)throw new Error("Could not find mind map content layers.");let s=1/0,o=1/0,l=-1/0,g=-1/0;const b=r.children;if(b.length===0)s=0,o=0,l=800,g=600;else for(let X=0;X<b.length;X++){const k=b[X],D=parseFloat(k.style.left||"0"),d=parseFloat(k.style.top||"0"),R=k.offsetWidth,J=k.offsetHeight,W=d-J/2,tt=d+J/2;D<s&&(s=D),W<o&&(o=W),D+R>l&&(l=D+R),tt>g&&(g=tt)}const u=50;s-=u,o-=u,l+=u,g+=u;const y=l-s,c=g-o,m=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"],p=[];h.forEach(X=>{const k=m.getPropertyValue(X).trim();k&&p.push(`${X}: ${k};`)});const f=p.join(" "),w=m.fontFamily,_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("xmlns","http://www.w3.org/2000/svg"),_.setAttribute("width",y.toString()),_.setAttribute("height",c.toString()),_.setAttribute("viewBox",`0 0 ${y} ${c}`),_.style.cssText=f;const C=document.createElementNS("http://www.w3.org/2000/svg","rect");C.setAttribute("x","0"),C.setAttribute("y","0"),C.setAttribute("width",y.toString()),C.setAttribute("height",c.toString()),C.setAttribute("fill",m.backgroundColor||"#ffffff"),_.appendChild(C);const S=document.createElementNS("http://www.w3.org/2000/svg","g");S.setAttribute("transform",`translate(${-s}, ${-o})`),i.querySelectorAll("path").forEach(X=>{const k=X.cloneNode(!0),D=window.getComputedStyle(X);let d=D.stroke;(!d||d==="none")&&(d=X.style.stroke),(!d||d==="none")&&(d="#cccccc"),k.style.stroke=d;let R=D.strokeWidth;(!R||R==="0px"||R==="auto")&&(R=X.getAttribute("stroke-width")||"2px"),k.style.strokeWidth=R,k.style.fill="none",S.appendChild(k)});const B=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");B.setAttribute("x","0"),B.setAttribute("y","0"),B.setAttribute("width",(l+u).toString()),B.setAttribute("height",(g+u).toString()),B.style.overflow="visible";const O=document.createElement("div");O.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),O.style.cssText=`position: relative; width: 100%; height: 100%; font-family: ${w}; ${f}`;const A=r.children;for(let X=0;X<A.length;X++){const k=A[X].cloneNode(!0);O.appendChild(k)}return B.appendChild(O),S.appendChild(B),_.appendChild(S),new XMLSerializer().serializeToString(_)}}class Dt{async exportToSvg(t,e){try{const n=new Bt().generate(t),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"});await this.saveFile(r,"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 n=new Bt().generate(t),s=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(n)))}`;await new Promise((o,l)=>{const g=new Image;g.onload=()=>{try{const b=document.createElement("canvas");b.width=g.width,b.height=g.height;const u=b.getContext("2d");if(!u)throw new Error("Could not get canvas context");u.drawImage(g,0,0),b.toBlob(y=>{y?this.saveFile(y,"mindmap.png",[{description:"PNG Image",accept:{"image/png":[".png"]}}],e).then(()=>o()).catch(c=>l(c instanceof Error?c:new Error(String(c)))):l(new Error("Failed to generate PNG blob."))},"image/png")}catch(b){l(b instanceof Error?b:new Error(String(b)))}},g.onerror=()=>{l(new Error("Failed to load SVG for PNG conversion"))},g.src=s})}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,n){if(n){const o=e.split(".").pop();await n.onExportFile(t,e,o);return}const r=await this.showSavePicker({suggestedName:e,types:i});if(!r)return;const s=await r.createWritable();await s.write(t),await s.close()}}class ce{async export(t,e){const i=this.generateMarkdown(t),n=new Blob([i],{type:"text/markdown;charset=utf-8"});await this.saveFile(n,"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 n=this.getNodeText(t);if(e===0)i.push(`# ${n}`);else if(e===1)i.push(`## ${n}`);else{const r=" ".repeat(e-2);i.push(`${r}- ${n}`)}for(const r of t.children)this.processNode(r,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 r=await(await window.showSaveFilePicker({suggestedName:e,types:[{description:"Markdown File",accept:{"text/markdown":[".md"]}}]})).createWritable();await r.write(t),await r.close()}else{const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}}catch(n){n.name!=="AbortError"&&(console.error("Failed to save file:",n),alert("Failed to save file."))}}}var St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function he(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}function kt(Q){throw new Error('Could not dynamically require "'+Q+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zt={exports:{}};var Rt;function ue(){return Rt||(Rt=1,(function(Q,t){(function(e){Q.exports=e()})(function(){return(function e(i,n,r){function s(g,b){if(!n[g]){if(!i[g]){var u=typeof kt=="function"&&kt;if(!b&&u)return u(g,!0);if(o)return o(g,!0);var y=new Error("Cannot find module '"+g+"'");throw y.code="MODULE_NOT_FOUND",y}var c=n[g]={exports:{}};i[g][0].call(c.exports,function(m){var h=i[g][1][m];return s(h||m)},c,c.exports,e,i,n,r)}return n[g].exports}for(var o=typeof kt=="function"&&kt,l=0;l<r.length;l++)s(r[l]);return s})({1:[function(e,i,n){var r=e("./utils"),s=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(l){for(var g,b,u,y,c,m,h,p=[],f=0,w=l.length,_=w,C=r.getTypeOf(l)!=="string";f<l.length;)_=w-f,u=C?(g=l[f++],b=f<w?l[f++]:0,f<w?l[f++]:0):(g=l.charCodeAt(f++),b=f<w?l.charCodeAt(f++):0,f<w?l.charCodeAt(f++):0),y=g>>2,c=(3&g)<<4|b>>4,m=1<_?(15&b)<<2|u>>6:64,h=2<_?63&u:64,p.push(o.charAt(y)+o.charAt(c)+o.charAt(m)+o.charAt(h));return p.join("")},n.decode=function(l){var g,b,u,y,c,m,h=0,p=0,f="data:";if(l.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var w,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&_--,l.charAt(l.length-2)===o.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=s.uint8array?new Uint8Array(0|_):new Array(0|_);h<l.length;)g=o.indexOf(l.charAt(h++))<<2|(y=o.indexOf(l.charAt(h++)))>>4,b=(15&y)<<4|(c=o.indexOf(l.charAt(h++)))>>2,u=(3&c)<<6|(m=o.indexOf(l.charAt(h++))),w[p++]=g,c!==64&&(w[p++]=b),m!==64&&(w[p++]=u);return w}},{"./support":30,"./utils":32}],2:[function(e,i,n){var r=e("./external"),s=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function g(b,u,y,c,m){this.compressedSize=b,this.uncompressedSize=u,this.crc32=y,this.compression=c,this.compressedContent=m}g.prototype={getContentWorker:function(){var b=new s(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return b.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),b},getCompressedWorker:function(){return new s(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},g.createWorkerFrom=function(b,u,y){return b.pipe(new o).pipe(new l("uncompressedSize")).pipe(u.compressWorker(y)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},i.exports=g},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,i,n){var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,i,n){var r=e("./utils"),s=(function(){for(var o,l=[],g=0;g<256;g++){o=g;for(var b=0;b<8;b++)o=1&o?3988292384^o>>>1:o>>>1;l[g]=o}return l})();i.exports=function(o,l){return o!==void 0&&o.length?r.getTypeOf(o)!=="string"?(function(g,b,u,y){var c=s,m=y+u;g^=-1;for(var h=y;h<m;h++)g=g>>>8^c[255&(g^b[h])];return-1^g})(0|l,o,o.length,0):(function(g,b,u,y){var c=s,m=y+u;g^=-1;for(var h=y;h<m;h++)g=g>>>8^c[255&(g^b.charCodeAt(h))];return-1^g})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(e,i,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,i,n){var r=null;r=typeof Promise<"u"?Promise:e("lie"),i.exports={Promise:r}},{lie:37}],7:[function(e,i,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=e("pako"),o=e("./utils"),l=e("./stream/GenericWorker"),g=r?"uint8array":"array";function b(u,y){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=y,this.meta={}}n.magic="\b\0",o.inherits(b,l),b.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(g,u.data),!1)},b.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},b.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},b.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(y){u.push({data:y,meta:u.meta})}},n.compressWorker=function(u){return new b("Deflate",u)},n.uncompressWorker=function(){return new b("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,i,n){function r(c,m){var h,p="";for(h=0;h<m;h++)p+=String.fromCharCode(255&c),c>>>=8;return p}function s(c,m,h,p,f,w){var _,C,S=c.file,z=c.compression,B=w!==g.utf8encode,O=o.transformTo("string",w(S.name)),A=o.transformTo("string",g.utf8encode(S.name)),H=S.comment,X=o.transformTo("string",w(H)),k=o.transformTo("string",g.utf8encode(H)),D=A.length!==S.name.length,d=k.length!==H.length,R="",J="",W="",tt=S.dir,U=S.date,q={crc32:0,compressedSize:0,uncompressedSize:0};m&&!h||(q.crc32=c.crc32,q.compressedSize=c.compressedSize,q.uncompressedSize=c.uncompressedSize);var M=0;m&&(M|=8),B||!D&&!d||(M|=2048);var I=0,V=0;tt&&(I|=16),f==="UNIX"?(V=798,I|=(function(K,st){var lt=K;return K||(lt=st?16893:33204),(65535&lt)<<16})(S.unixPermissions,tt)):(V=20,I|=(function(K){return 63&(K||0)})(S.dosPermissions)),_=U.getUTCHours(),_<<=6,_|=U.getUTCMinutes(),_<<=5,_|=U.getUTCSeconds()/2,C=U.getUTCFullYear()-1980,C<<=4,C|=U.getUTCMonth()+1,C<<=5,C|=U.getUTCDate(),D&&(J=r(1,1)+r(b(O),4)+A,R+="up"+r(J.length,2)+J),d&&(W=r(1,1)+r(b(X),4)+k,R+="uc"+r(W.length,2)+W);var Y="";return Y+=`
57
- \0`,Y+=r(M,2),Y+=z.magic,Y+=r(_,2),Y+=r(C,2),Y+=r(q.crc32,4),Y+=r(q.compressedSize,4),Y+=r(q.uncompressedSize,4),Y+=r(O.length,2),Y+=r(R.length,2),{fileRecord:u.LOCAL_FILE_HEADER+Y+O+R,dirRecord:u.CENTRAL_FILE_HEADER+r(V,2)+Y+r(X.length,2)+"\0\0\0\0"+r(I,4)+r(p,4)+O+R+X}}var o=e("../utils"),l=e("../stream/GenericWorker"),g=e("../utf8"),b=e("../crc32"),u=e("../signature");function y(c,m,h,p){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=h,this.encodeFileName=p,this.streamFiles=c,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(y,l),y.prototype.push=function(c){var m=c.meta.percent||0,h=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(c):(this.bytesWritten+=c.data.length,l.prototype.push.call(this,{data:c.data,meta:{currentFile:this.currentFile,percent:h?(m+100*(h-p-1))/h:100}}))},y.prototype.openedSource=function(c){this.currentSourceOffset=this.bytesWritten,this.currentFile=c.file.name;var m=this.streamFiles&&!c.file.dir;if(m){var h=s(c,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(c){this.accumulate=!1;var m=this.streamFiles&&!c.file.dir,h=s(c,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),m)this.push({data:(function(p){return u.DATA_DESCRIPTOR+r(p.crc32,4)+r(p.compressedSize,4)+r(p.uncompressedSize,4)})(c),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var c=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var h=this.bytesWritten-c,p=(function(f,w,_,C,S){var z=o.transformTo("string",S(C));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(f,2)+r(f,2)+r(w,4)+r(_,4)+r(z.length,2)+z})(this.dirRecords.length,h,c,this.zipComment,this.encodeFileName);this.push({data:p,meta:{percent:100}})},y.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},y.prototype.registerPrevious=function(c){this._sources.push(c);var m=this;return c.on("data",function(h){m.processChunk(h)}),c.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),c.on("error",function(h){m.error(h)}),this},y.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},y.prototype.error=function(c){var m=this._sources;if(!l.prototype.error.call(this,c))return!1;for(var h=0;h<m.length;h++)try{m[h].error(c)}catch{}return!0},y.prototype.lock=function(){l.prototype.lock.call(this);for(var c=this._sources,m=0;m<c.length;m++)c[m].lock()},i.exports=y},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,i,n){var r=e("../compressions"),s=e("./ZipFileWorker");n.generateWorker=function(o,l,g){var b=new s(l.streamFiles,g,l.platform,l.encodeFileName),u=0;try{o.forEach(function(y,c){u++;var m=(function(w,_){var C=w||_,S=r[C];if(!S)throw new Error(C+" is not a valid compression method !");return S})(c.options.compression,l.compression),h=c.options.compressionOptions||l.compressionOptions||{},p=c.dir,f=c.date;c._compressWorker(m,h).withStreamInfo("file",{name:y,dir:p,date:f,comment:c.comment||"",unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions}).pipe(b)}),b.entriesCount=u}catch(y){b.error(y)}return b}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,i,n){function r(){if(!(this instanceof r))return new r;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 s=new r;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.1",r.loadAsync=function(s,o){return new r().loadAsync(s,o)},r.external=e("./external"),i.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,i,n){var r=e("./utils"),s=e("./external"),o=e("./utf8"),l=e("./zipEntries"),g=e("./stream/Crc32Probe"),b=e("./nodejsUtils");function u(y){return new s.Promise(function(c,m){var h=y.decompressed.getContentWorker().pipe(new g);h.on("error",function(p){m(p)}).on("end",function(){h.streamInfo.crc32!==y.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):c()}).resume()})}i.exports=function(y,c){var m=this;return c=r.extend(c||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),b.isNode&&b.isStream(y)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",y,!0,c.optimizedBinaryString,c.base64).then(function(h){var p=new l(c);return p.load(h),p}).then(function(h){var p=[s.Promise.resolve(h)],f=h.files;if(c.checkCRC32)for(var w=0;w<f.length;w++)p.push(u(f[w]));return s.Promise.all(p)}).then(function(h){for(var p=h.shift(),f=p.files,w=0;w<f.length;w++){var _=f[w],C=_.fileNameStr,S=r.resolve(_.fileNameStr);m.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:c.createFolders}),_.dir||(m.file(S).unsafeOriginalName=C)}return p.zipComment.length&&(m.comment=p.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,i,n){var r=e("../utils"),s=e("../stream/GenericWorker");function o(l,g){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(g)}r.inherits(o,s),o.prototype._bindStream=function(l){var g=this;(this._stream=l).pause(),l.on("data",function(b){g.push({data:b,meta:{percent:0}})}).on("error",function(b){g.isPaused?this.generatedError=b:g.error(b)}).on("end",function(){g.isPaused?g._upstreamEnded=!0:g.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,i,n){var r=e("readable-stream").Readable;function s(o,l,g){r.call(this,l),this._helper=o;var b=this;o.on("data",function(u,y){b.push(u)||b._helper.pause(),g&&g(y)}).on("error",function(u){b.emit("error",u)}).on("end",function(){b.push(null)})}e("../utils").inherits(s,r),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(e,i,n){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,s);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,s)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var s=new Buffer(r);return s.fill(0),s},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(e,i,n){function r(S,z,B){var O,A=o.getTypeOf(z),H=o.extend(B||{},b);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=f(S)),H.createFolders&&(O=p(S))&&w.call(this,O,!0);var X=A==="string"&&H.binary===!1&&H.base64===!1;B&&B.binary!==void 0||(H.binary=!X),(z instanceof u&&z.uncompressedSize===0||H.dir||!z||z.length===0)&&(H.base64=!1,H.binary=!0,z="",H.compression="STORE",A="string");var k=null;k=z instanceof u||z instanceof l?z:m.isNode&&m.isStream(z)?new h(S,z):o.prepareContent(S,z,H.binary,H.optimizedBinaryString,H.base64);var D=new y(S,k,H);this.files[S]=D}var s=e("./utf8"),o=e("./utils"),l=e("./stream/GenericWorker"),g=e("./stream/StreamHelper"),b=e("./defaults"),u=e("./compressedObject"),y=e("./zipObject"),c=e("./generate"),m=e("./nodejsUtils"),h=e("./nodejs/NodejsStreamInputAdapter"),p=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var z=S.lastIndexOf("/");return 0<z?S.substring(0,z):""},f=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},w=function(S,z){return z=z!==void 0?z:b.createFolders,S=f(S),this.files[S]||r.call(this,S,null,{dir:!0,createFolders:z}),this.files[S]};function _(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 z,B,O;for(z in this.files)O=this.files[z],(B=z.slice(this.root.length,z.length))&&z.slice(0,this.root.length)===this.root&&S(B,O)},filter:function(S){var z=[];return this.forEach(function(B,O){S(B,O)&&z.push(O)}),z},file:function(S,z,B){if(arguments.length!==1)return S=this.root+S,r.call(this,S,z,B),this;if(_(S)){var O=S;return this.filter(function(H,X){return!X.dir&&O.test(H)})}var A=this.files[this.root+S];return A&&!A.dir?A:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(A,H){return H.dir&&S.test(A)});var z=this.root+S,B=w.call(this,z),O=this.clone();return O.root=B.name,O},remove:function(S){S=this.root+S;var z=this.files[S];if(z||(S.slice(-1)!=="/"&&(S+="/"),z=this.files[S]),z&&!z.dir)delete this.files[S];else for(var B=this.filter(function(A,H){return H.name.slice(0,S.length)===S}),O=0;O<B.length;O++)delete this.files[B[O].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 z,B={};try{if((B=o.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=B.type.toLowerCase(),B.compression=B.compression.toUpperCase(),B.type==="binarystring"&&(B.type="string"),!B.type)throw new Error("No output type specified.");o.checkSupport(B.type),B.platform!=="darwin"&&B.platform!=="freebsd"&&B.platform!=="linux"&&B.platform!=="sunos"||(B.platform="UNIX"),B.platform==="win32"&&(B.platform="DOS");var O=B.comment||this.comment||"";z=c.generateWorker(this,B,O)}catch(A){(z=new l("error")).error(A)}return new g(z,B.type||"string",B.mimeType)},generateAsync:function(S,z){return this.generateInternalStream(S).accumulate(z)},generateNodeStream:function(S,z){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(z)}};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,n){i.exports=e("stream")},{stream:void 0}],17:[function(e,i,n){var r=e("./DataReader");function s(o){r.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}e("../utils").inherits(s,r),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),g=o.charCodeAt(1),b=o.charCodeAt(2),u=o.charCodeAt(3),y=this.length-4;0<=y;--y)if(this.data[y]===l&&this.data[y+1]===g&&this.data[y+2]===b&&this.data[y+3]===u)return y-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),g=o.charCodeAt(1),b=o.charCodeAt(2),u=o.charCodeAt(3),y=this.readData(4);return l===y[0]&&g===y[1]&&b===y[2]&&u===y[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(e,i,n){var r=e("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,g=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)g=(g<<8)+this.byteAt(l);return this.index+=o,g},readString:function(o){return r.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=s},{"../utils":32}],19:[function(e,i,n){var r=e("./Uint8ArrayReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,i,n){var r=e("./DataReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(e,i,n){var r=e("./ArrayReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(e,i,n){var r=e("../utils"),s=e("../support"),o=e("./ArrayReader"),l=e("./StringReader"),g=e("./NodeBufferReader"),b=e("./Uint8ArrayReader");i.exports=function(u){var y=r.getTypeOf(u);return r.checkSupport(y),y!=="string"||s.uint8array?y==="nodebuffer"?new g(u):s.uint8array?new b(r.transformTo("uint8array",u)):new o(r.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,i,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,i,n){var r=e("./GenericWorker"),s=e("../utils");function o(l){r.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(o,r),o.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,i,n){var r=e("./GenericWorker"),s=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,i,n){var r=e("../utils"),s=e("./GenericWorker");function o(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}r.inherits(o,s),o.prototype.processChunk=function(l){if(l){var g=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=g+l.data.length}s.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,i,n){var r=e("../utils"),s=e("./GenericWorker");function o(l){s.call(this,"DataWorker");var g=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(b){g.dataIsReady=!0,g.data=b,g.max=b&&b.length||0,g.type=r.getTypeOf(b),g.isPaused||g._tickAndRepeat()},function(b){g.error(b)})}r.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,g=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,g);break;case"uint8array":l=this.data.subarray(this.index,g);break;case"array":case"nodebuffer":l=this.data.slice(this.index,g)}return this.index=g,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,i,n){function r(s){this.name=s||"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}r.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(l){o.processChunk(l)}),s.on("end",function(){o.end()}),s.on("error",function(l){o.error(l)}),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 s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},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 s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=r},{}],29:[function(e,i,n){var r=e("../utils"),s=e("./ConvertWorker"),o=e("./GenericWorker"),l=e("../base64"),g=e("../support"),b=e("../external"),u=null;if(g.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(m,h){return new b.Promise(function(p,f){var w=[],_=m._internalType,C=m._outputType,S=m._mimeType;m.on("data",function(z,B){w.push(z),h&&h(B)}).on("error",function(z){w=[],f(z)}).on("end",function(){try{var z=(function(B,O,A){switch(B){case"blob":return r.newBlob(r.transformTo("arraybuffer",O),A);case"base64":return l.encode(O);default:return r.transformTo(B,O)}})(C,(function(B,O){var A,H=0,X=null,k=0;for(A=0;A<O.length;A++)k+=O[A].length;switch(B){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(X=new Uint8Array(k),A=0;A<O.length;A++)X.set(O[A],H),H+=O[A].length;return X;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+B+"'")}})(_,w),S);p(z)}catch(B){f(B)}w=[]}).resume()})}function c(m,h,p){var f=h;switch(h){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=h,this._mimeType=p,r.checkSupport(f),this._worker=m.pipe(new s(f)),m.lock()}catch(w){this._worker=new o("error"),this._worker.error(w)}}c.prototype={accumulate:function(m){return y(this,m)},on:function(m,h){var p=this;return m==="data"?this._worker.on(m,function(f){h.call(p,f.data,f.meta)}):this._worker.on(m,function(){r.delay(h,arguments,p)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},m)}},i.exports=c},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,i,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",n.nodebuffer=typeof Buffer<"u",n.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(r),n.blob=s.getBlob("application/zip").size===0}catch{n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,i,n){for(var r=e("./utils"),s=e("./support"),o=e("./nodejsUtils"),l=e("./stream/GenericWorker"),g=new Array(256),b=0;b<256;b++)g[b]=252<=b?6:248<=b?5:240<=b?4:224<=b?3:192<=b?2:1;g[254]=g[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function y(){l.call(this,"utf-8 encode")}n.utf8encode=function(c){return s.nodebuffer?o.newBufferFrom(c,"utf-8"):(function(m){var h,p,f,w,_,C=m.length,S=0;for(w=0;w<C;w++)(64512&(p=m.charCodeAt(w)))==55296&&w+1<C&&(64512&(f=m.charCodeAt(w+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),w++),S+=p<128?1:p<2048?2:p<65536?3:4;for(h=s.uint8array?new Uint8Array(S):new Array(S),w=_=0;_<S;w++)(64512&(p=m.charCodeAt(w)))==55296&&w+1<C&&(64512&(f=m.charCodeAt(w+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),w++),p<128?h[_++]=p:(p<2048?h[_++]=192|p>>>6:(p<65536?h[_++]=224|p>>>12:(h[_++]=240|p>>>18,h[_++]=128|p>>>12&63),h[_++]=128|p>>>6&63),h[_++]=128|63&p);return h})(c)},n.utf8decode=function(c){return s.nodebuffer?r.transformTo("nodebuffer",c).toString("utf-8"):(function(m){var h,p,f,w,_=m.length,C=new Array(2*_);for(h=p=0;h<_;)if((f=m[h++])<128)C[p++]=f;else if(4<(w=g[f]))C[p++]=65533,h+=w-1;else{for(f&=w===2?31:w===3?15:7;1<w&&h<_;)f=f<<6|63&m[h++],w--;1<w?C[p++]=65533:f<65536?C[p++]=f:(f-=65536,C[p++]=55296|f>>10&1023,C[p++]=56320|1023&f)}return C.length!==p&&(C.subarray?C=C.subarray(0,p):C.length=p),r.applyFromCharCode(C)})(c=r.transformTo(s.uint8array?"uint8array":"array",c))},r.inherits(u,l),u.prototype.processChunk=function(c){var m=r.transformTo(s.uint8array?"uint8array":"array",c.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var h=m;(m=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),m.set(h,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var p=(function(w,_){var C;for((_=_||w.length)>w.length&&(_=w.length),C=_-1;0<=C&&(192&w[C])==128;)C--;return C<0||C===0?_:C+g[w[C]]>_?C:_})(m),f=m;p!==m.length&&(s.uint8array?(f=m.subarray(0,p),this.leftOver=m.subarray(p,m.length)):(f=m.slice(0,p),this.leftOver=m.slice(p,m.length))),this.push({data:n.utf8decode(f),meta:c.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=u,r.inherits(y,l),y.prototype.processChunk=function(c){this.push({data:n.utf8encode(c.data),meta:c.meta})},n.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,i,n){var r=e("./support"),s=e("./base64"),o=e("./nodejsUtils"),l=e("./external");function g(h){return h}function b(h,p){for(var f=0;f<h.length;++f)p[f]=255&h.charCodeAt(f);return p}e("setimmediate"),n.newBlob=function(h,p){n.checkSupport("blob");try{return new Blob([h],{type:p})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(h),f.getBlob(p)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(h,p,f){var w=[],_=0,C=h.length;if(C<=f)return String.fromCharCode.apply(null,h);for(;_<C;)p==="array"||p==="nodebuffer"?w.push(String.fromCharCode.apply(null,h.slice(_,Math.min(_+f,C)))):w.push(String.fromCharCode.apply(null,h.subarray(_,Math.min(_+f,C)))),_+=f;return w.join("")},stringifyByChar:function(h){for(var p="",f=0;f<h.length;f++)p+=String.fromCharCode(h[f]);return p},applyCanBeUsed:{uint8array:(function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function y(h){var p=65536,f=n.getTypeOf(h),w=!0;if(f==="uint8array"?w=u.applyCanBeUsed.uint8array:f==="nodebuffer"&&(w=u.applyCanBeUsed.nodebuffer),w)for(;1<p;)try{return u.stringifyByChunk(h,f,p)}catch{p=Math.floor(p/2)}return u.stringifyByChar(h)}function c(h,p){for(var f=0;f<h.length;f++)p[f]=h[f];return p}n.applyFromCharCode=y;var m={};m.string={string:g,array:function(h){return b(h,new Array(h.length))},arraybuffer:function(h){return m.string.uint8array(h).buffer},uint8array:function(h){return b(h,new Uint8Array(h.length))},nodebuffer:function(h){return b(h,o.allocBuffer(h.length))}},m.array={string:y,array:g,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return o.newBufferFrom(h)}},m.arraybuffer={string:function(h){return y(new Uint8Array(h))},array:function(h){return c(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:g,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return o.newBufferFrom(new Uint8Array(h))}},m.uint8array={string:y,array:function(h){return c(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:g,nodebuffer:function(h){return o.newBufferFrom(h)}},m.nodebuffer={string:y,array:function(h){return c(h,new Array(h.length))},arraybuffer:function(h){return m.nodebuffer.uint8array(h).buffer},uint8array:function(h){return c(h,new Uint8Array(h.length))},nodebuffer:g},n.transformTo=function(h,p){if(p=p||"",!h)return p;n.checkSupport(h);var f=n.getTypeOf(p);return m[f][h](p)},n.resolve=function(h){for(var p=h.split("/"),f=[],w=0;w<p.length;w++){var _=p[w];_==="."||_===""&&w!==0&&w!==p.length-1||(_===".."?f.pop():f.push(_))}return f.join("/")},n.getTypeOf=function(h){return typeof h=="string"?"string":Object.prototype.toString.call(h)==="[object Array]"?"array":r.nodebuffer&&o.isBuffer(h)?"nodebuffer":r.uint8array&&h instanceof Uint8Array?"uint8array":r.arraybuffer&&h instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(h){if(!r[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(h){var p,f,w="";for(f=0;f<(h||"").length;f++)w+="\\x"+((p=h.charCodeAt(f))<16?"0":"")+p.toString(16).toUpperCase();return w},n.delay=function(h,p,f){setImmediate(function(){h.apply(f||null,p||[])})},n.inherits=function(h,p){function f(){}f.prototype=p.prototype,h.prototype=new f},n.extend=function(){var h,p,f={};for(h=0;h<arguments.length;h++)for(p in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],p)&&f[p]===void 0&&(f[p]=arguments[h][p]);return f},n.prepareContent=function(h,p,f,w,_){return l.Promise.resolve(p).then(function(C){return r.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-1)&&typeof FileReader<"u"?new l.Promise(function(S,z){var B=new FileReader;B.onload=function(O){S(O.target.result)},B.onerror=function(O){z(O.target.error)},B.readAsArrayBuffer(C)}):C}).then(function(C){var S=n.getTypeOf(C);return S?(S==="arraybuffer"?C=n.transformTo("uint8array",C):S==="string"&&(_?C=s.decode(C):f&&w!==!0&&(C=(function(z){return b(z,r.uint8array?new Uint8Array(z.length):new Array(z.length))})(C))),C):l.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,n){var r=e("./reader/readerFor"),s=e("./utils"),o=e("./signature"),l=e("./zipEntry"),g=e("./support");function b(u){this.files=[],this.loadOptions=u}b.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var y=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(y)+", expected "+s.pretty(u)+")")}},isSignature:function(u,y){var c=this.reader.index;this.reader.setIndex(u);var m=this.reader.readString(4)===y;return this.reader.setIndex(c),m},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 u=this.reader.readData(this.zipCommentLength),y=g.uint8array?"uint8array":"array",c=s.transformTo(y,u);this.zipComment=this.loadOptions.decodeFileName(c)},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 u,y,c,m=this.zip64EndOfCentralSize-44;0<m;)u=this.reader.readInt(2),y=this.reader.readInt(4),c=this.reader.readData(y),this.zip64ExtensibleData[u]={id:u,length:y,value:c}},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 u,y;for(u=0;u<this.files.length;u++)y=this.files[u],this.reader.setIndex(y.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),y.readLocalPart(this.reader),y.handleUTF8(),y.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);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 u=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,o.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(u);var y=u;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.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(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var c=this.centralDirOffset+this.centralDirSize;this.zip64&&(c+=20,c+=12+this.zip64EndOfCentralSize);var m=y-c;if(0<m)this.isSignature(y,o.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(u){this.reader=r(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=b},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,i,n){var r=e("./reader/readerFor"),s=e("./utils"),o=e("./compressedObject"),l=e("./crc32"),g=e("./utf8"),b=e("./compressions"),u=e("./support");function y(c,m){this.options=c,this.loadOptions=m}y.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(c){var m,h;if(c.skip(22),this.fileNameLength=c.readInt(2),h=c.readInt(2),this.fileName=c.readData(this.fileNameLength),c.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((m=(function(p){for(var f in b)if(Object.prototype.hasOwnProperty.call(b,f)&&b[f].magic===p)return b[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,m,c.readData(this.compressedSize))},readCentralPart:function(c){this.versionMadeBy=c.readInt(2),c.skip(2),this.bitFlag=c.readInt(2),this.compressionMethod=c.readString(2),this.date=c.readDate(),this.crc32=c.readInt(4),this.compressedSize=c.readInt(4),this.uncompressedSize=c.readInt(4);var m=c.readInt(2);if(this.extraFieldsLength=c.readInt(2),this.fileCommentLength=c.readInt(2),this.diskNumberStart=c.readInt(2),this.internalFileAttributes=c.readInt(2),this.externalFileAttributes=c.readInt(4),this.localHeaderOffset=c.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");c.skip(m),this.readExtraFields(c),this.parseZIP64ExtraField(c),this.fileComment=c.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var c=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),c==0&&(this.dosPermissions=63&this.externalFileAttributes),c==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var c=r(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=c.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=c.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=c.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=c.readInt(4))}},readExtraFields:function(c){var m,h,p,f=c.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});c.index+4<f;)m=c.readInt(2),h=c.readInt(2),p=c.readData(h),this.extraFields[m]={id:m,length:h,value:p};c.setIndex(f)},handleUTF8:function(){var c=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=g.utf8decode(this.fileName),this.fileCommentStr=g.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var h=s.transformTo(c,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var p=this.findExtraFieldUnicodeComment();if(p!==null)this.fileCommentStr=p;else{var f=s.transformTo(c,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var c=this.extraFields[28789];if(c){var m=r(c.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:g.utf8decode(m.readData(c.length-5))}return null},findExtraFieldUnicodeComment:function(){var c=this.extraFields[25461];if(c){var m=r(c.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:g.utf8decode(m.readData(c.length-5))}return null}},i.exports=y},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,i,n){function r(m,h,p){this.name=m,this.dir=p.dir,this.date=p.date,this.comment=p.comment,this.unixPermissions=p.unixPermissions,this.dosPermissions=p.dosPermissions,this._data=h,this._dataBinary=p.binary,this.options={compression:p.compression,compressionOptions:p.compressionOptions}}var s=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),l=e("./utf8"),g=e("./compressedObject"),b=e("./stream/GenericWorker");r.prototype={internalStream:function(m){var h=null,p="string";try{if(!m)throw new Error("No output type specified.");var f=(p=m.toLowerCase())==="string"||p==="text";p!=="binarystring"&&p!=="text"||(p="string"),h=this._decompressWorker();var w=!this._dataBinary;w&&!f&&(h=h.pipe(new l.Utf8EncodeWorker)),!w&&f&&(h=h.pipe(new l.Utf8DecodeWorker))}catch(_){(h=new b("error")).error(_)}return new s(h,p,"")},async:function(m,h){return this.internalStream(m).accumulate(h)},nodeStream:function(m,h){return this.internalStream(m||"nodebuffer").toNodejsStream(h)},_compressWorker:function(m,h){if(this._data instanceof g&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var p=this._decompressWorker();return this._dataBinary||(p=p.pipe(new l.Utf8EncodeWorker)),g.createWorkerFrom(p,m,h)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof b?this._data:new o(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],y=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},c=0;c<u.length;c++)r.prototype[u[c]]=y;i.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,i,n){(function(r){var s,o,l=r.MutationObserver||r.WebKitMutationObserver;if(l){var g=0,b=new l(m),u=r.document.createTextNode("");b.observe(u,{characterData:!0}),s=function(){u.data=g=++g%2}}else if(r.setImmediate||r.MessageChannel===void 0)s="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var h=r.document.createElement("script");h.onreadystatechange=function(){m(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},r.document.documentElement.appendChild(h)}:function(){setTimeout(m,0)};else{var y=new r.MessageChannel;y.port1.onmessage=m,s=function(){y.port2.postMessage(0)}}var c=[];function m(){var h,p;o=!0;for(var f=c.length;f;){for(p=c,c=[],h=-1;++h<f;)p[h]();f=c.length}o=!1}i.exports=function(h){c.push(h)!==1||o||s()}}).call(this,typeof St<"u"?St:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,i,n){var r=e("immediate");function s(){}var o={},l=["REJECTED"],g=["FULFILLED"],b=["PENDING"];function u(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=b,this.queue=[],this.outcome=void 0,f!==s&&h(this,f)}function y(f,w,_){this.promise=f,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function c(f,w,_){r(function(){var C;try{C=w(_)}catch(S){return o.reject(f,S)}C===f?o.reject(f,new TypeError("Cannot resolve promise with itself")):o.resolve(f,C)})}function m(f){var w=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof w=="function")return function(){w.apply(f,arguments)}}function h(f,w){var _=!1;function C(B){_||(_=!0,o.reject(f,B))}function S(B){_||(_=!0,o.resolve(f,B))}var z=p(function(){w(S,C)});z.status==="error"&&C(z.value)}function p(f,w){var _={};try{_.value=f(w),_.status="success"}catch(C){_.status="error",_.value=C}return _}(i.exports=u).prototype.finally=function(f){if(typeof f!="function")return this;var w=this.constructor;return this.then(function(_){return w.resolve(f()).then(function(){return _})},function(_){return w.resolve(f()).then(function(){throw _})})},u.prototype.catch=function(f){return this.then(null,f)},u.prototype.then=function(f,w){if(typeof f!="function"&&this.state===g||typeof w!="function"&&this.state===l)return this;var _=new this.constructor(s);return this.state!==b?c(_,this.state===g?f:w,this.outcome):this.queue.push(new y(_,f,w)),_},y.prototype.callFulfilled=function(f){o.resolve(this.promise,f)},y.prototype.otherCallFulfilled=function(f){c(this.promise,this.onFulfilled,f)},y.prototype.callRejected=function(f){o.reject(this.promise,f)},y.prototype.otherCallRejected=function(f){c(this.promise,this.onRejected,f)},o.resolve=function(f,w){var _=p(m,w);if(_.status==="error")return o.reject(f,_.value);var C=_.value;if(C)h(f,C);else{f.state=g,f.outcome=w;for(var S=-1,z=f.queue.length;++S<z;)f.queue[S].callFulfilled(w)}return f},o.reject=function(f,w){f.state=l,f.outcome=w;for(var _=-1,C=f.queue.length;++_<C;)f.queue[_].callRejected(w);return f},u.resolve=function(f){return f instanceof this?f:o.resolve(new this(s),f)},u.reject=function(f){var w=new this(s);return o.reject(w,f)},u.all=function(f){var w=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=f.length,C=!1;if(!_)return this.resolve([]);for(var S=new Array(_),z=0,B=-1,O=new this(s);++B<_;)A(f[B],B);return O;function A(H,X){w.resolve(H).then(function(k){S[X]=k,++z!==_||C||(C=!0,o.resolve(O,S))},function(k){C||(C=!0,o.reject(O,k))})}},u.race=function(f){var w=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=f.length,C=!1;if(!_)return this.resolve([]);for(var S=-1,z=new this(s);++S<_;)B=f[S],w.resolve(B).then(function(O){C||(C=!0,o.resolve(z,O))},function(O){C||(C=!0,o.reject(z,O))});var B;return z}},{immediate:36}],38:[function(e,i,n){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),i.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,i,n){var r=e("./zlib/deflate"),s=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/messages"),g=e("./zlib/zstream"),b=Object.prototype.toString,u=0,y=-1,c=0,m=8;function h(f){if(!(this instanceof h))return new h(f);this.options=s.assign({level:y,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:c,to:""},f||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var _=r.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(_!==u)throw new Error(l[_]);if(w.header&&r.deflateSetHeader(this.strm,w.header),w.dictionary){var C;if(C=typeof w.dictionary=="string"?o.string2buf(w.dictionary):b.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(_=r.deflateSetDictionary(this.strm,C))!==u)throw new Error(l[_]);this._dict_set=!0}}function p(f,w){var _=new h(w);if(_.push(f,!0),_.err)throw _.msg||l[_.err];return _.result}h.prototype.push=function(f,w){var _,C,S=this.strm,z=this.options.chunkSize;if(this.ended)return!1;C=w===~~w?w:w===!0?4:0,typeof f=="string"?S.input=o.string2buf(f):b.call(f)==="[object ArrayBuffer]"?S.input=new Uint8Array(f):S.input=f,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new s.Buf8(z),S.next_out=0,S.avail_out=z),(_=r.deflate(S,C))!==1&&_!==u)return this.onEnd(_),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||C!==4&&C!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(S.output,S.next_out))):this.onData(s.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&_!==1);return C===4?(_=r.deflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===u):C!==2||(this.onEnd(u),!(S.avail_out=0))},h.prototype.onData=function(f){this.chunks.push(f)},h.prototype.onEnd=function(f){f===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},n.Deflate=h,n.deflate=p,n.deflateRaw=function(f,w){return(w=w||{}).raw=!0,p(f,w)},n.gzip=function(f,w){return(w=w||{}).gzip=!0,p(f,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,i,n){var r=e("./zlib/inflate"),s=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/constants"),g=e("./zlib/messages"),b=e("./zlib/zstream"),u=e("./zlib/gzheader"),y=Object.prototype.toString;function c(h){if(!(this instanceof c))return new c(h);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},h||{});var p=this.options;p.raw&&0<=p.windowBits&&p.windowBits<16&&(p.windowBits=-p.windowBits,p.windowBits===0&&(p.windowBits=-15)),!(0<=p.windowBits&&p.windowBits<16)||h&&h.windowBits||(p.windowBits+=32),15<p.windowBits&&p.windowBits<48&&(15&p.windowBits)==0&&(p.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new b,this.strm.avail_out=0;var f=r.inflateInit2(this.strm,p.windowBits);if(f!==l.Z_OK)throw new Error(g[f]);this.header=new u,r.inflateGetHeader(this.strm,this.header)}function m(h,p){var f=new c(p);if(f.push(h,!0),f.err)throw f.msg||g[f.err];return f.result}c.prototype.push=function(h,p){var f,w,_,C,S,z,B=this.strm,O=this.options.chunkSize,A=this.options.dictionary,H=!1;if(this.ended)return!1;w=p===~~p?p:p===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof h=="string"?B.input=o.binstring2buf(h):y.call(h)==="[object ArrayBuffer]"?B.input=new Uint8Array(h):B.input=h,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new s.Buf8(O),B.next_out=0,B.avail_out=O),(f=r.inflate(B,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&A&&(z=typeof A=="string"?o.string2buf(A):y.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,f=r.inflateSetDictionary(this.strm,z)),f===l.Z_BUF_ERROR&&H===!0&&(f=l.Z_OK,H=!1),f!==l.Z_STREAM_END&&f!==l.Z_OK)return this.onEnd(f),!(this.ended=!0);B.next_out&&(B.avail_out!==0&&f!==l.Z_STREAM_END&&(B.avail_in!==0||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=o.utf8border(B.output,B.next_out),C=B.next_out-_,S=o.buf2string(B.output,_),B.next_out=C,B.avail_out=O-C,C&&s.arraySet(B.output,B.output,_,C,0),this.onData(S)):this.onData(s.shrinkBuf(B.output,B.next_out)))),B.avail_in===0&&B.avail_out===0&&(H=!0)}while((0<B.avail_in||B.avail_out===0)&&f!==l.Z_STREAM_END);return f===l.Z_STREAM_END&&(w=l.Z_FINISH),w===l.Z_FINISH?(f=r.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(B.avail_out=0))},c.prototype.onData=function(h){this.chunks.push(h)},c.prototype.onEnd=function(h){h===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},n.Inflate=c,n.inflate=m,n.inflateRaw=function(h,p){return(p=p||{}).raw=!0,m(h,p)},n.ungzip=m},{"./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,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";n.assign=function(l){for(var g=Array.prototype.slice.call(arguments,1);g.length;){var b=g.shift();if(b){if(typeof b!="object")throw new TypeError(b+"must be non-object");for(var u in b)b.hasOwnProperty(u)&&(l[u]=b[u])}}return l},n.shrinkBuf=function(l,g){return l.length===g?l:l.subarray?l.subarray(0,g):(l.length=g,l)};var s={arraySet:function(l,g,b,u,y){if(g.subarray&&l.subarray)l.set(g.subarray(b,b+u),y);else for(var c=0;c<u;c++)l[y+c]=g[b+c]},flattenChunks:function(l){var g,b,u,y,c,m;for(g=u=0,b=l.length;g<b;g++)u+=l[g].length;for(m=new Uint8Array(u),g=y=0,b=l.length;g<b;g++)c=l[g],m.set(c,y),y+=c.length;return m}},o={arraySet:function(l,g,b,u,y){for(var c=0;c<u;c++)l[y+c]=g[b+c]},flattenChunks:function(l){return[].concat.apply([],l)}};n.setTyped=function(l){l?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,s)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(r)},{}],42:[function(e,i,n){var r=e("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new r.Buf8(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;function b(u,y){if(y<65537&&(u.subarray&&o||!u.subarray&&s))return String.fromCharCode.apply(null,r.shrinkBuf(u,y));for(var c="",m=0;m<y;m++)c+=String.fromCharCode(u[m]);return c}l[254]=l[254]=1,n.string2buf=function(u){var y,c,m,h,p,f=u.length,w=0;for(h=0;h<f;h++)(64512&(c=u.charCodeAt(h)))==55296&&h+1<f&&(64512&(m=u.charCodeAt(h+1)))==56320&&(c=65536+(c-55296<<10)+(m-56320),h++),w+=c<128?1:c<2048?2:c<65536?3:4;for(y=new r.Buf8(w),h=p=0;p<w;h++)(64512&(c=u.charCodeAt(h)))==55296&&h+1<f&&(64512&(m=u.charCodeAt(h+1)))==56320&&(c=65536+(c-55296<<10)+(m-56320),h++),c<128?y[p++]=c:(c<2048?y[p++]=192|c>>>6:(c<65536?y[p++]=224|c>>>12:(y[p++]=240|c>>>18,y[p++]=128|c>>>12&63),y[p++]=128|c>>>6&63),y[p++]=128|63&c);return y},n.buf2binstring=function(u){return b(u,u.length)},n.binstring2buf=function(u){for(var y=new r.Buf8(u.length),c=0,m=y.length;c<m;c++)y[c]=u.charCodeAt(c);return y},n.buf2string=function(u,y){var c,m,h,p,f=y||u.length,w=new Array(2*f);for(c=m=0;c<f;)if((h=u[c++])<128)w[m++]=h;else if(4<(p=l[h]))w[m++]=65533,c+=p-1;else{for(h&=p===2?31:p===3?15:7;1<p&&c<f;)h=h<<6|63&u[c++],p--;1<p?w[m++]=65533:h<65536?w[m++]=h:(h-=65536,w[m++]=55296|h>>10&1023,w[m++]=56320|1023&h)}return b(w,m)},n.utf8border=function(u,y){var c;for((y=y||u.length)>u.length&&(y=u.length),c=y-1;0<=c&&(192&u[c])==128;)c--;return c<0||c===0?y:c+l[u[c]]>y?c:y}},{"./common":41}],43:[function(e,i,n){i.exports=function(r,s,o,l){for(var g=65535&r|0,b=r>>>16&65535|0,u=0;o!==0;){for(o-=u=2e3<o?2e3:o;b=b+(g=g+s[l++]|0)|0,--u;);g%=65521,b%=65521}return g|b<<16|0}},{}],44:[function(e,i,n){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,n){var r=(function(){for(var s,o=[],l=0;l<256;l++){s=l;for(var g=0;g<8;g++)s=1&s?3988292384^s>>>1:s>>>1;o[l]=s}return o})();i.exports=function(s,o,l,g){var b=r,u=g+l;s^=-1;for(var y=g;y<u;y++)s=s>>>8^b[255&(s^o[y])];return-1^s}},{}],46:[function(e,i,n){var r,s=e("../utils/common"),o=e("./trees"),l=e("./adler32"),g=e("./crc32"),b=e("./messages"),u=0,y=4,c=0,m=-2,h=-1,p=4,f=2,w=8,_=9,C=286,S=30,z=19,B=2*C+1,O=15,A=3,H=258,X=H+A+1,k=42,D=113,d=1,R=2,J=3,W=4;function tt(a,L){return a.msg=b[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 M(a){var L=a.state,T=L.pending;T>a.avail_out&&(T=a.avail_out),T!==0&&(s.arraySet(a.output,L.pending_buf,L.pending_out,T,a.next_out),a.next_out+=T,L.pending_out+=T,a.total_out+=T,a.avail_out-=T,L.pending-=T,L.pending===0&&(L.pending_out=0))}function I(a,L){o._tr_flush_block(a,0<=a.block_start?a.block_start:-1,a.strstart-a.block_start,L),a.block_start=a.strstart,M(a.strm)}function V(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 K(a,L){var T,x,v=a.max_chain_length,N=a.strstart,P=a.prev_length,F=a.nice_match,E=a.strstart>a.w_size-X?a.strstart-(a.w_size-X):0,j=a.window,G=a.w_mask,Z=a.prev,$=a.strstart+H,rt=j[N+P-1],it=j[N+P];a.prev_length>=a.good_match&&(v>>=2),F>a.lookahead&&(F=a.lookahead);do if(j[(T=L)+P]===it&&j[T+P-1]===rt&&j[T]===j[N]&&j[++T]===j[N+1]){N+=2,T++;do;while(j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&N<$);if(x=H-($-N),N=$-H,P<x){if(a.match_start=L,F<=(P=x))break;rt=j[N+P-1],it=j[N+P]}}while((L=Z[L&G])>E&&--v!=0);return P<=a.lookahead?P:a.lookahead}function st(a){var L,T,x,v,N,P,F,E,j,G,Z=a.w_size;do{if(v=a.window_size-a.lookahead-a.strstart,a.strstart>=Z+(Z-X)){for(s.arraySet(a.window,a.window,Z,Z,0),a.match_start-=Z,a.strstart-=Z,a.block_start-=Z,L=T=a.hash_size;x=a.head[--L],a.head[L]=Z<=x?x-Z:0,--T;);for(L=T=Z;x=a.prev[--L],a.prev[L]=Z<=x?x-Z:0,--T;);v+=Z}if(a.strm.avail_in===0)break;if(P=a.strm,F=a.window,E=a.strstart+a.lookahead,j=v,G=void 0,G=P.avail_in,j<G&&(G=j),T=G===0?0:(P.avail_in-=G,s.arraySet(F,P.input,P.next_in,G,E),P.state.wrap===1?P.adler=l(P.adler,F,G,E):P.state.wrap===2&&(P.adler=g(P.adler,F,G,E)),P.next_in+=G,P.total_in+=G,G),a.lookahead+=T,a.lookahead+a.insert>=A)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+A-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<A)););}while(a.lookahead<X&&a.strm.avail_in!==0)}function lt(a,L){for(var T,x;;){if(a.lookahead<X){if(st(a),a.lookahead<X&&L===u)return d;if(a.lookahead===0)break}if(T=0,a.lookahead>=A&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),T!==0&&a.strstart-T<=a.w_size-X&&(a.match_length=K(a,T)),a.match_length>=A)if(x=o._tr_tally(a,a.strstart-a.match_start,a.match_length-A),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=A){for(a.match_length--;a.strstart++,a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=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 x=o._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++;if(x&&(I(a,!1),a.strm.avail_out===0))return d}return a.insert=a.strstart<A-1?a.strstart:A-1,L===y?(I(a,!0),a.strm.avail_out===0?J:W):a.last_lit&&(I(a,!1),a.strm.avail_out===0)?d:R}function et(a,L){for(var T,x,v;;){if(a.lookahead<X){if(st(a),a.lookahead<X&&L===u)return d;if(a.lookahead===0)break}if(T=0,a.lookahead>=A&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=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=A-1,T!==0&&a.prev_length<a.max_lazy_match&&a.strstart-T<=a.w_size-X&&(a.match_length=K(a,T),a.match_length<=5&&(a.strategy===1||a.match_length===A&&4096<a.strstart-a.match_start)&&(a.match_length=A-1)),a.prev_length>=A&&a.match_length<=a.prev_length){for(v=a.strstart+a.lookahead-A,x=o._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-A),a.lookahead-=a.prev_length-1,a.prev_length-=2;++a.strstart<=v&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=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=A-1,a.strstart++,x&&(I(a,!1),a.strm.avail_out===0))return d}else if(a.match_available){if((x=o._tr_tally(a,0,a.window[a.strstart-1]))&&I(a,!1),a.strstart++,a.lookahead--,a.strm.avail_out===0)return d}else a.match_available=1,a.strstart++,a.lookahead--}return a.match_available&&(x=o._tr_tally(a,0,a.window[a.strstart-1]),a.match_available=0),a.insert=a.strstart<A-1?a.strstart:A-1,L===y?(I(a,!0),a.strm.avail_out===0?J:W):a.last_lit&&(I(a,!1),a.strm.avail_out===0)?d:R}function nt(a,L,T,x,v){this.good_length=a,this.max_lazy=L,this.nice_length=T,this.max_chain=x,this.func=v}function dt(){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=w,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 s.Buf16(2*B),this.dyn_dtree=new s.Buf16(2*(2*S+1)),this.bl_tree=new s.Buf16(2*(2*z+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 s.Buf16(O+1),this.heap=new s.Buf16(2*C+1),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.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 ot(a){var L;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=f,(L=a.state).pending=0,L.pending_out=0,L.wrap<0&&(L.wrap=-L.wrap),L.status=L.wrap?k:D,a.adler=L.wrap===2?0:1,L.last_flush=u,o._tr_init(L),c):tt(a,m)}function pt(a){var L=ot(a);return L===c&&(function(T){T.window_size=2*T.w_size,q(T.head),T.max_lazy_match=r[T.level].max_lazy,T.good_match=r[T.level].good_length,T.nice_match=r[T.level].nice_length,T.max_chain_length=r[T.level].max_chain,T.strstart=0,T.block_start=0,T.lookahead=0,T.insert=0,T.match_length=T.prev_length=A-1,T.match_available=0,T.ins_h=0})(a.state),L}function ut(a,L,T,x,v,N){if(!a)return m;var P=1;if(L===h&&(L=6),x<0?(P=0,x=-x):15<x&&(P=2,x-=16),v<1||_<v||T!==w||x<8||15<x||L<0||9<L||N<0||p<N)return tt(a,m);x===8&&(x=9);var F=new dt;return(a.state=F).strm=a,F.wrap=P,F.gzhead=null,F.w_bits=x,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=v+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+A-1)/A),F.window=new s.Buf8(2*F.w_size),F.head=new s.Buf16(F.hash_size),F.prev=new s.Buf16(F.w_size),F.lit_bufsize=1<<v+6,F.pending_buf_size=4*F.lit_bufsize,F.pending_buf=new s.Buf8(F.pending_buf_size),F.d_buf=1*F.lit_bufsize,F.l_buf=3*F.lit_bufsize,F.level=L,F.strategy=N,F.method=T,pt(a)}r=[new nt(0,0,0,0,function(a,L){var T=65535;for(T>a.pending_buf_size-5&&(T=a.pending_buf_size-5);;){if(a.lookahead<=1){if(st(a),a.lookahead===0&&L===u)return d;if(a.lookahead===0)break}a.strstart+=a.lookahead,a.lookahead=0;var x=a.block_start+T;if((a.strstart===0||a.strstart>=x)&&(a.lookahead=a.strstart-x,a.strstart=x,I(a,!1),a.strm.avail_out===0)||a.strstart-a.block_start>=a.w_size-X&&(I(a,!1),a.strm.avail_out===0))return d}return a.insert=0,L===y?(I(a,!0),a.strm.avail_out===0?J:W):(a.strstart>a.block_start&&(I(a,!1),a.strm.avail_out),d)}),new nt(4,4,8,4,lt),new nt(4,5,16,8,lt),new nt(4,6,32,32,lt),new nt(4,4,16,16,et),new nt(8,16,32,32,et),new nt(8,16,128,128,et),new nt(8,32,128,256,et),new nt(32,128,258,1024,et),new nt(32,258,258,4096,et)],n.deflateInit=function(a,L){return ut(a,L,w,15,8,0)},n.deflateInit2=ut,n.deflateReset=pt,n.deflateResetKeep=ot,n.deflateSetHeader=function(a,L){return a&&a.state?a.state.wrap!==2?m:(a.state.gzhead=L,c):m},n.deflate=function(a,L){var T,x,v,N;if(!a||!a.state||5<L||L<0)return a?tt(a,m):m;if(x=a.state,!a.output||!a.input&&a.avail_in!==0||x.status===666&&L!==y)return tt(a,a.avail_out===0?-5:m);if(x.strm=a,T=x.last_flush,x.last_flush=L,x.status===k)if(x.wrap===2)a.adler=0,V(x,31),V(x,139),V(x,8),x.gzhead?(V(x,(x.gzhead.text?1:0)+(x.gzhead.hcrc?2:0)+(x.gzhead.extra?4:0)+(x.gzhead.name?8:0)+(x.gzhead.comment?16:0)),V(x,255&x.gzhead.time),V(x,x.gzhead.time>>8&255),V(x,x.gzhead.time>>16&255),V(x,x.gzhead.time>>24&255),V(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),V(x,255&x.gzhead.os),x.gzhead.extra&&x.gzhead.extra.length&&(V(x,255&x.gzhead.extra.length),V(x,x.gzhead.extra.length>>8&255)),x.gzhead.hcrc&&(a.adler=g(a.adler,x.pending_buf,x.pending,0)),x.gzindex=0,x.status=69):(V(x,0),V(x,0),V(x,0),V(x,0),V(x,0),V(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),V(x,3),x.status=D);else{var P=w+(x.w_bits-8<<4)<<8;P|=(2<=x.strategy||x.level<2?0:x.level<6?1:x.level===6?2:3)<<6,x.strstart!==0&&(P|=32),P+=31-P%31,x.status=D,Y(x,P),x.strstart!==0&&(Y(x,a.adler>>>16),Y(x,65535&a.adler)),a.adler=1}if(x.status===69)if(x.gzhead.extra){for(v=x.pending;x.gzindex<(65535&x.gzhead.extra.length)&&(x.pending!==x.pending_buf_size||(x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),M(a),v=x.pending,x.pending!==x.pending_buf_size));)V(x,255&x.gzhead.extra[x.gzindex]),x.gzindex++;x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),x.gzindex===x.gzhead.extra.length&&(x.gzindex=0,x.status=73)}else x.status=73;if(x.status===73)if(x.gzhead.name){v=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),M(a),v=x.pending,x.pending===x.pending_buf_size)){N=1;break}N=x.gzindex<x.gzhead.name.length?255&x.gzhead.name.charCodeAt(x.gzindex++):0,V(x,N)}while(N!==0);x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),N===0&&(x.gzindex=0,x.status=91)}else x.status=91;if(x.status===91)if(x.gzhead.comment){v=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),M(a),v=x.pending,x.pending===x.pending_buf_size)){N=1;break}N=x.gzindex<x.gzhead.comment.length?255&x.gzhead.comment.charCodeAt(x.gzindex++):0,V(x,N)}while(N!==0);x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),N===0&&(x.status=103)}else x.status=103;if(x.status===103&&(x.gzhead.hcrc?(x.pending+2>x.pending_buf_size&&M(a),x.pending+2<=x.pending_buf_size&&(V(x,255&a.adler),V(x,a.adler>>8&255),a.adler=0,x.status=D)):x.status=D),x.pending!==0){if(M(a),a.avail_out===0)return x.last_flush=-1,c}else if(a.avail_in===0&&U(L)<=U(T)&&L!==y)return tt(a,-5);if(x.status===666&&a.avail_in!==0)return tt(a,-5);if(a.avail_in!==0||x.lookahead!==0||L!==u&&x.status!==666){var F=x.strategy===2?(function(E,j){for(var G;;){if(E.lookahead===0&&(st(E),E.lookahead===0)){if(j===u)return d;break}if(E.match_length=0,G=o._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++,G&&(I(E,!1),E.strm.avail_out===0))return d}return E.insert=0,j===y?(I(E,!0),E.strm.avail_out===0?J:W):E.last_lit&&(I(E,!1),E.strm.avail_out===0)?d:R})(x,L):x.strategy===3?(function(E,j){for(var G,Z,$,rt,it=E.window;;){if(E.lookahead<=H){if(st(E),E.lookahead<=H&&j===u)return d;if(E.lookahead===0)break}if(E.match_length=0,E.lookahead>=A&&0<E.strstart&&(Z=it[$=E.strstart-1])===it[++$]&&Z===it[++$]&&Z===it[++$]){rt=E.strstart+H;do;while(Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&$<rt);E.match_length=H-(rt-$),E.match_length>E.lookahead&&(E.match_length=E.lookahead)}if(E.match_length>=A?(G=o._tr_tally(E,1,E.match_length-A),E.lookahead-=E.match_length,E.strstart+=E.match_length,E.match_length=0):(G=o._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++),G&&(I(E,!1),E.strm.avail_out===0))return d}return E.insert=0,j===y?(I(E,!0),E.strm.avail_out===0?J:W):E.last_lit&&(I(E,!1),E.strm.avail_out===0)?d:R})(x,L):r[x.level].func(x,L);if(F!==J&&F!==W||(x.status=666),F===d||F===J)return a.avail_out===0&&(x.last_flush=-1),c;if(F===R&&(L===1?o._tr_align(x):L!==5&&(o._tr_stored_block(x,0,0,!1),L===3&&(q(x.head),x.lookahead===0&&(x.strstart=0,x.block_start=0,x.insert=0))),M(a),a.avail_out===0))return x.last_flush=-1,c}return L!==y?c:x.wrap<=0?1:(x.wrap===2?(V(x,255&a.adler),V(x,a.adler>>8&255),V(x,a.adler>>16&255),V(x,a.adler>>24&255),V(x,255&a.total_in),V(x,a.total_in>>8&255),V(x,a.total_in>>16&255),V(x,a.total_in>>24&255)):(Y(x,a.adler>>>16),Y(x,65535&a.adler)),M(a),0<x.wrap&&(x.wrap=-x.wrap),x.pending!==0?c:1)},n.deflateEnd=function(a){var L;return a&&a.state?(L=a.state.status)!==k&&L!==69&&L!==73&&L!==91&&L!==103&&L!==D&&L!==666?tt(a,m):(a.state=null,L===D?tt(a,-3):c):m},n.deflateSetDictionary=function(a,L){var T,x,v,N,P,F,E,j,G=L.length;if(!a||!a.state||(N=(T=a.state).wrap)===2||N===1&&T.status!==k||T.lookahead)return m;for(N===1&&(a.adler=l(a.adler,L,G,0)),T.wrap=0,G>=T.w_size&&(N===0&&(q(T.head),T.strstart=0,T.block_start=0,T.insert=0),j=new s.Buf8(T.w_size),s.arraySet(j,L,G-T.w_size,T.w_size,0),L=j,G=T.w_size),P=a.avail_in,F=a.next_in,E=a.input,a.avail_in=G,a.next_in=0,a.input=L,st(T);T.lookahead>=A;){for(x=T.strstart,v=T.lookahead-(A-1);T.ins_h=(T.ins_h<<T.hash_shift^T.window[x+A-1])&T.hash_mask,T.prev[x&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=x,x++,--v;);T.strstart=x,T.lookahead=A-1,st(T)}return T.strstart+=T.lookahead,T.block_start=T.strstart,T.insert=T.lookahead,T.lookahead=0,T.match_length=T.prev_length=A-1,T.match_available=0,a.next_in=F,a.input=E,a.avail_in=P,T.wrap=N,c},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,i,n){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,n){i.exports=function(r,s){var o,l,g,b,u,y,c,m,h,p,f,w,_,C,S,z,B,O,A,H,X,k,D,d,R;o=r.state,l=r.next_in,d=r.input,g=l+(r.avail_in-5),b=r.next_out,R=r.output,u=b-(s-r.avail_out),y=b+(r.avail_out-257),c=o.dmax,m=o.wsize,h=o.whave,p=o.wnext,f=o.window,w=o.hold,_=o.bits,C=o.lencode,S=o.distcode,z=(1<<o.lenbits)-1,B=(1<<o.distbits)-1;t:do{_<15&&(w+=d[l++]<<_,_+=8,w+=d[l++]<<_,_+=8),O=C[w&z];e:for(;;){if(w>>>=A=O>>>24,_-=A,(A=O>>>16&255)===0)R[b++]=65535&O;else{if(!(16&A)){if((64&A)==0){O=C[(65535&O)+(w&(1<<A)-1)];continue e}if(32&A){o.mode=12;break t}r.msg="invalid literal/length code",o.mode=30;break t}H=65535&O,(A&=15)&&(_<A&&(w+=d[l++]<<_,_+=8),H+=w&(1<<A)-1,w>>>=A,_-=A),_<15&&(w+=d[l++]<<_,_+=8,w+=d[l++]<<_,_+=8),O=S[w&B];i:for(;;){if(w>>>=A=O>>>24,_-=A,!(16&(A=O>>>16&255))){if((64&A)==0){O=S[(65535&O)+(w&(1<<A)-1)];continue i}r.msg="invalid distance code",o.mode=30;break t}if(X=65535&O,_<(A&=15)&&(w+=d[l++]<<_,(_+=8)<A&&(w+=d[l++]<<_,_+=8)),c<(X+=w&(1<<A)-1)){r.msg="invalid distance too far back",o.mode=30;break t}if(w>>>=A,_-=A,(A=b-u)<X){if(h<(A=X-A)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break t}if(D=f,(k=0)===p){if(k+=m-A,A<H){for(H-=A;R[b++]=f[k++],--A;);k=b-X,D=R}}else if(p<A){if(k+=m+p-A,(A-=p)<H){for(H-=A;R[b++]=f[k++],--A;);if(k=0,p<H){for(H-=A=p;R[b++]=f[k++],--A;);k=b-X,D=R}}}else if(k+=p-A,A<H){for(H-=A;R[b++]=f[k++],--A;);k=b-X,D=R}for(;2<H;)R[b++]=D[k++],R[b++]=D[k++],R[b++]=D[k++],H-=3;H&&(R[b++]=D[k++],1<H&&(R[b++]=D[k++]))}else{for(k=b-X;R[b++]=R[k++],R[b++]=R[k++],R[b++]=R[k++],2<(H-=3););H&&(R[b++]=R[k++],1<H&&(R[b++]=R[k++]))}break}}break}}while(l<g&&b<y);l-=H=_>>3,w&=(1<<(_-=H<<3))-1,r.next_in=l,r.next_out=b,r.avail_in=l<g?g-l+5:5-(l-g),r.avail_out=b<y?y-b+257:257-(b-y),o.hold=w,o.bits=_}},{}],49:[function(e,i,n){var r=e("../utils/common"),s=e("./adler32"),o=e("./crc32"),l=e("./inffast"),g=e("./inftrees"),b=1,u=2,y=0,c=-2,m=1,h=852,p=592;function f(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function w(){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 r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(k){var D;return k&&k.state?(D=k.state,k.total_in=k.total_out=D.total=0,k.msg="",D.wrap&&(k.adler=1&D.wrap),D.mode=m,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new r.Buf32(h),D.distcode=D.distdyn=new r.Buf32(p),D.sane=1,D.back=-1,y):c}function C(k){var D;return k&&k.state?((D=k.state).wsize=0,D.whave=0,D.wnext=0,_(k)):c}function S(k,D){var d,R;return k&&k.state?(R=k.state,D<0?(d=0,D=-D):(d=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?c:(R.window!==null&&R.wbits!==D&&(R.window=null),R.wrap=d,R.wbits=D,C(k))):c}function z(k,D){var d,R;return k?(R=new w,(k.state=R).window=null,(d=S(k,D))!==y&&(k.state=null),d):c}var B,O,A=!0;function H(k){if(A){var D;for(B=new r.Buf32(512),O=new r.Buf32(32),D=0;D<144;)k.lens[D++]=8;for(;D<256;)k.lens[D++]=9;for(;D<280;)k.lens[D++]=7;for(;D<288;)k.lens[D++]=8;for(g(b,k.lens,0,288,B,0,k.work,{bits:9}),D=0;D<32;)k.lens[D++]=5;g(u,k.lens,0,32,O,0,k.work,{bits:5}),A=!1}k.lencode=B,k.lenbits=9,k.distcode=O,k.distbits=5}function X(k,D,d,R){var J,W=k.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new r.Buf8(W.wsize)),R>=W.wsize?(r.arraySet(W.window,D,d-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(R<(J=W.wsize-W.wnext)&&(J=R),r.arraySet(W.window,D,d-R,J,W.wnext),(R-=J)?(r.arraySet(W.window,D,d-R,R,0),W.wnext=R,W.whave=W.wsize):(W.wnext+=J,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=J))),0}n.inflateReset=C,n.inflateReset2=S,n.inflateResetKeep=_,n.inflateInit=function(k){return z(k,15)},n.inflateInit2=z,n.inflate=function(k,D){var d,R,J,W,tt,U,q,M,I,V,Y,K,st,lt,et,nt,dt,ot,pt,ut,a,L,T,x,v=0,N=new r.Buf8(4),P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return c;(d=k.state).mode===12&&(d.mode=13),tt=k.next_out,J=k.output,q=k.avail_out,W=k.next_in,R=k.input,U=k.avail_in,M=d.hold,I=d.bits,V=U,Y=q,L=y;t:for(;;)switch(d.mode){case m:if(d.wrap===0){d.mode=13;break}for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(2&d.wrap&&M===35615){N[d.check=0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0),I=M=0,d.mode=2;break}if(d.flags=0,d.head&&(d.head.done=!1),!(1&d.wrap)||(((255&M)<<8)+(M>>8))%31){k.msg="incorrect header check",d.mode=30;break}if((15&M)!=8){k.msg="unknown compression method",d.mode=30;break}if(I-=4,a=8+(15&(M>>>=4)),d.wbits===0)d.wbits=a;else if(a>d.wbits){k.msg="invalid window size",d.mode=30;break}d.dmax=1<<a,k.adler=d.check=1,d.mode=512&M?10:12,I=M=0;break;case 2:for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(d.flags=M,(255&d.flags)!=8){k.msg="unknown compression method",d.mode=30;break}if(57344&d.flags){k.msg="unknown header flags set",d.mode=30;break}d.head&&(d.head.text=M>>8&1),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0)),I=M=0,d.mode=3;case 3:for(;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.head&&(d.head.time=M),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,N[2]=M>>>16&255,N[3]=M>>>24&255,d.check=o(d.check,N,4,0)),I=M=0,d.mode=4;case 4:for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.head&&(d.head.xflags=255&M,d.head.os=M>>8),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0)),I=M=0,d.mode=5;case 5:if(1024&d.flags){for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.length=M,d.head&&(d.head.extra_len=M),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0)),I=M=0}else d.head&&(d.head.extra=null);d.mode=6;case 6:if(1024&d.flags&&(U<(K=d.length)&&(K=U),K&&(d.head&&(a=d.head.extra_len-d.length,d.head.extra||(d.head.extra=new Array(d.head.extra_len)),r.arraySet(d.head.extra,R,W,K,a)),512&d.flags&&(d.check=o(d.check,R,K,W)),U-=K,W+=K,d.length-=K),d.length))break t;d.length=0,d.mode=7;case 7:if(2048&d.flags){if(U===0)break t;for(K=0;a=R[W+K++],d.head&&a&&d.length<65536&&(d.head.name+=String.fromCharCode(a)),a&&K<U;);if(512&d.flags&&(d.check=o(d.check,R,K,W)),U-=K,W+=K,a)break t}else d.head&&(d.head.name=null);d.length=0,d.mode=8;case 8:if(4096&d.flags){if(U===0)break t;for(K=0;a=R[W+K++],d.head&&a&&d.length<65536&&(d.head.comment+=String.fromCharCode(a)),a&&K<U;);if(512&d.flags&&(d.check=o(d.check,R,K,W)),U-=K,W+=K,a)break t}else d.head&&(d.head.comment=null);d.mode=9;case 9:if(512&d.flags){for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(M!==(65535&d.check)){k.msg="header crc mismatch",d.mode=30;break}I=M=0}d.head&&(d.head.hcrc=d.flags>>9&1,d.head.done=!0),k.adler=d.check=0,d.mode=12;break;case 10:for(;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}k.adler=d.check=f(M),I=M=0,d.mode=11;case 11:if(d.havedict===0)return k.next_out=tt,k.avail_out=q,k.next_in=W,k.avail_in=U,d.hold=M,d.bits=I,2;k.adler=d.check=1,d.mode=12;case 12:if(D===5||D===6)break t;case 13:if(d.last){M>>>=7&I,I-=7&I,d.mode=27;break}for(;I<3;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}switch(d.last=1&M,I-=1,3&(M>>>=1)){case 0:d.mode=14;break;case 1:if(H(d),d.mode=20,D!==6)break;M>>>=2,I-=2;break t;case 2:d.mode=17;break;case 3:k.msg="invalid block type",d.mode=30}M>>>=2,I-=2;break;case 14:for(M>>>=7&I,I-=7&I;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if((65535&M)!=(M>>>16^65535)){k.msg="invalid stored block lengths",d.mode=30;break}if(d.length=65535&M,I=M=0,d.mode=15,D===6)break t;case 15:d.mode=16;case 16:if(K=d.length){if(U<K&&(K=U),q<K&&(K=q),K===0)break t;r.arraySet(J,R,W,K,tt),U-=K,W+=K,q-=K,tt+=K,d.length-=K;break}d.mode=12;break;case 17:for(;I<14;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(d.nlen=257+(31&M),M>>>=5,I-=5,d.ndist=1+(31&M),M>>>=5,I-=5,d.ncode=4+(15&M),M>>>=4,I-=4,286<d.nlen||30<d.ndist){k.msg="too many length or distance symbols",d.mode=30;break}d.have=0,d.mode=18;case 18:for(;d.have<d.ncode;){for(;I<3;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.lens[P[d.have++]]=7&M,M>>>=3,I-=3}for(;d.have<19;)d.lens[P[d.have++]]=0;if(d.lencode=d.lendyn,d.lenbits=7,T={bits:d.lenbits},L=g(0,d.lens,0,19,d.lencode,0,d.work,T),d.lenbits=T.bits,L){k.msg="invalid code lengths set",d.mode=30;break}d.have=0,d.mode=19;case 19:for(;d.have<d.nlen+d.ndist;){for(;nt=(v=d.lencode[M&(1<<d.lenbits)-1])>>>16&255,dt=65535&v,!((et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(dt<16)M>>>=et,I-=et,d.lens[d.have++]=dt;else{if(dt===16){for(x=et+2;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(M>>>=et,I-=et,d.have===0){k.msg="invalid bit length repeat",d.mode=30;break}a=d.lens[d.have-1],K=3+(3&M),M>>>=2,I-=2}else if(dt===17){for(x=et+3;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}I-=et,a=0,K=3+(7&(M>>>=et)),M>>>=3,I-=3}else{for(x=et+7;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}I-=et,a=0,K=11+(127&(M>>>=et)),M>>>=7,I-=7}if(d.have+K>d.nlen+d.ndist){k.msg="invalid bit length repeat",d.mode=30;break}for(;K--;)d.lens[d.have++]=a}}if(d.mode===30)break;if(d.lens[256]===0){k.msg="invalid code -- missing end-of-block",d.mode=30;break}if(d.lenbits=9,T={bits:d.lenbits},L=g(b,d.lens,0,d.nlen,d.lencode,0,d.work,T),d.lenbits=T.bits,L){k.msg="invalid literal/lengths set",d.mode=30;break}if(d.distbits=6,d.distcode=d.distdyn,T={bits:d.distbits},L=g(u,d.lens,d.nlen,d.ndist,d.distcode,0,d.work,T),d.distbits=T.bits,L){k.msg="invalid distances set",d.mode=30;break}if(d.mode=20,D===6)break t;case 20:d.mode=21;case 21:if(6<=U&&258<=q){k.next_out=tt,k.avail_out=q,k.next_in=W,k.avail_in=U,d.hold=M,d.bits=I,l(k,Y),tt=k.next_out,J=k.output,q=k.avail_out,W=k.next_in,R=k.input,U=k.avail_in,M=d.hold,I=d.bits,d.mode===12&&(d.back=-1);break}for(d.back=0;nt=(v=d.lencode[M&(1<<d.lenbits)-1])>>>16&255,dt=65535&v,!((et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(nt&&(240&nt)==0){for(ot=et,pt=nt,ut=dt;nt=(v=d.lencode[ut+((M&(1<<ot+pt)-1)>>ot)])>>>16&255,dt=65535&v,!(ot+(et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}M>>>=ot,I-=ot,d.back+=ot}if(M>>>=et,I-=et,d.back+=et,d.length=dt,nt===0){d.mode=26;break}if(32&nt){d.back=-1,d.mode=12;break}if(64&nt){k.msg="invalid literal/length code",d.mode=30;break}d.extra=15&nt,d.mode=22;case 22:if(d.extra){for(x=d.extra;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.length+=M&(1<<d.extra)-1,M>>>=d.extra,I-=d.extra,d.back+=d.extra}d.was=d.length,d.mode=23;case 23:for(;nt=(v=d.distcode[M&(1<<d.distbits)-1])>>>16&255,dt=65535&v,!((et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if((240&nt)==0){for(ot=et,pt=nt,ut=dt;nt=(v=d.distcode[ut+((M&(1<<ot+pt)-1)>>ot)])>>>16&255,dt=65535&v,!(ot+(et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}M>>>=ot,I-=ot,d.back+=ot}if(M>>>=et,I-=et,d.back+=et,64&nt){k.msg="invalid distance code",d.mode=30;break}d.offset=dt,d.extra=15&nt,d.mode=24;case 24:if(d.extra){for(x=d.extra;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.offset+=M&(1<<d.extra)-1,M>>>=d.extra,I-=d.extra,d.back+=d.extra}if(d.offset>d.dmax){k.msg="invalid distance too far back",d.mode=30;break}d.mode=25;case 25:if(q===0)break t;if(K=Y-q,d.offset>K){if((K=d.offset-K)>d.whave&&d.sane){k.msg="invalid distance too far back",d.mode=30;break}st=K>d.wnext?(K-=d.wnext,d.wsize-K):d.wnext-K,K>d.length&&(K=d.length),lt=d.window}else lt=J,st=tt-d.offset,K=d.length;for(q<K&&(K=q),q-=K,d.length-=K;J[tt++]=lt[st++],--K;);d.length===0&&(d.mode=21);break;case 26:if(q===0)break t;J[tt++]=d.length,q--,d.mode=21;break;case 27:if(d.wrap){for(;I<32;){if(U===0)break t;U--,M|=R[W++]<<I,I+=8}if(Y-=q,k.total_out+=Y,d.total+=Y,Y&&(k.adler=d.check=d.flags?o(d.check,J,Y,tt-Y):s(d.check,J,Y,tt-Y)),Y=q,(d.flags?M:f(M))!==d.check){k.msg="incorrect data check",d.mode=30;break}I=M=0}d.mode=28;case 28:if(d.wrap&&d.flags){for(;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(M!==(4294967295&d.total)){k.msg="incorrect length check",d.mode=30;break}I=M=0}d.mode=29;case 29:L=1;break t;case 30:L=-3;break t;case 31:return-4;default:return c}return k.next_out=tt,k.avail_out=q,k.next_in=W,k.avail_in=U,d.hold=M,d.bits=I,(d.wsize||Y!==k.avail_out&&d.mode<30&&(d.mode<27||D!==4))&&X(k,k.output,k.next_out,Y-k.avail_out)?(d.mode=31,-4):(V-=k.avail_in,Y-=k.avail_out,k.total_in+=V,k.total_out+=Y,d.total+=Y,d.wrap&&Y&&(k.adler=d.check=d.flags?o(d.check,J,Y,k.next_out-Y):s(d.check,J,Y,k.next_out-Y)),k.data_type=d.bits+(d.last?64:0)+(d.mode===12?128:0)+(d.mode===20||d.mode===15?256:0),(V==0&&Y===0||D===4)&&L===y&&(L=-5),L)},n.inflateEnd=function(k){if(!k||!k.state)return c;var D=k.state;return D.window&&(D.window=null),k.state=null,y},n.inflateGetHeader=function(k,D){var d;return k&&k.state?(2&(d=k.state).wrap)==0?c:((d.head=D).done=!1,y):c},n.inflateSetDictionary=function(k,D){var d,R=D.length;return k&&k.state?(d=k.state).wrap!==0&&d.mode!==11?c:d.mode===11&&s(1,D,R,0)!==d.check?-3:X(k,D,R,R)?(d.mode=31,-4):(d.havedict=1,y):c},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,i,n){var r=e("../utils/common"),s=[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],o=[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],l=[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(b,u,y,c,m,h,p,f){var w,_,C,S,z,B,O,A,H,X=f.bits,k=0,D=0,d=0,R=0,J=0,W=0,tt=0,U=0,q=0,M=0,I=null,V=0,Y=new r.Buf16(16),K=new r.Buf16(16),st=null,lt=0;for(k=0;k<=15;k++)Y[k]=0;for(D=0;D<c;D++)Y[u[y+D]]++;for(J=X,R=15;1<=R&&Y[R]===0;R--);if(R<J&&(J=R),R===0)return m[h++]=20971520,m[h++]=20971520,f.bits=1,0;for(d=1;d<R&&Y[d]===0;d++);for(J<d&&(J=d),k=U=1;k<=15;k++)if(U<<=1,(U-=Y[k])<0)return-1;if(0<U&&(b===0||R!==1))return-1;for(K[1]=0,k=1;k<15;k++)K[k+1]=K[k]+Y[k];for(D=0;D<c;D++)u[y+D]!==0&&(p[K[u[y+D]]++]=D);if(B=b===0?(I=st=p,19):b===1?(I=s,V-=257,st=o,lt-=257,256):(I=l,st=g,-1),k=d,z=h,tt=D=M=0,C=-1,S=(q=1<<(W=J))-1,b===1&&852<q||b===2&&592<q)return 1;for(;;){for(O=k-tt,H=p[D]<B?(A=0,p[D]):p[D]>B?(A=st[lt+p[D]],I[V+p[D]]):(A=96,0),w=1<<k-tt,d=_=1<<W;m[z+(M>>tt)+(_-=w)]=O<<24|A<<16|H|0,_!==0;);for(w=1<<k-1;M&w;)w>>=1;if(w!==0?(M&=w-1,M+=w):M=0,D++,--Y[k]==0){if(k===R)break;k=u[y+p[D]]}if(J<k&&(M&S)!==C){for(tt===0&&(tt=J),z+=d,U=1<<(W=k-tt);W+tt<R&&!((U-=Y[W+tt])<=0);)W++,U<<=1;if(q+=1<<W,b===1&&852<q||b===2&&592<q)return 1;m[C=M&S]=J<<24|W<<16|z-h|0}}return M!==0&&(m[z+M]=k-tt<<24|64<<16|0),f.bits=J,0}},{"../utils/common":41}],51:[function(e,i,n){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,n){var r=e("../utils/common"),s=0,o=1;function l(v){for(var N=v.length;0<=--N;)v[N]=0}var g=0,b=29,u=256,y=u+1+b,c=30,m=19,h=2*y+1,p=15,f=16,w=7,_=256,C=16,S=17,z=18,B=[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],O=[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],A=[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],X=new Array(2*(y+2));l(X);var k=new Array(2*c);l(k);var D=new Array(512);l(D);var d=new Array(256);l(d);var R=new Array(b);l(R);var J,W,tt,U=new Array(c);function q(v,N,P,F,E){this.static_tree=v,this.extra_bits=N,this.extra_base=P,this.elems=F,this.max_length=E,this.has_stree=v&&v.length}function M(v,N){this.dyn_tree=v,this.max_code=0,this.stat_desc=N}function I(v){return v<256?D[v]:D[256+(v>>>7)]}function V(v,N){v.pending_buf[v.pending++]=255&N,v.pending_buf[v.pending++]=N>>>8&255}function Y(v,N,P){v.bi_valid>f-P?(v.bi_buf|=N<<v.bi_valid&65535,V(v,v.bi_buf),v.bi_buf=N>>f-v.bi_valid,v.bi_valid+=P-f):(v.bi_buf|=N<<v.bi_valid&65535,v.bi_valid+=P)}function K(v,N,P){Y(v,P[2*N],P[2*N+1])}function st(v,N){for(var P=0;P|=1&v,v>>>=1,P<<=1,0<--N;);return P>>>1}function lt(v,N,P){var F,E,j=new Array(p+1),G=0;for(F=1;F<=p;F++)j[F]=G=G+P[F-1]<<1;for(E=0;E<=N;E++){var Z=v[2*E+1];Z!==0&&(v[2*E]=st(j[Z]++,Z))}}function et(v){var N;for(N=0;N<y;N++)v.dyn_ltree[2*N]=0;for(N=0;N<c;N++)v.dyn_dtree[2*N]=0;for(N=0;N<m;N++)v.bl_tree[2*N]=0;v.dyn_ltree[2*_]=1,v.opt_len=v.static_len=0,v.last_lit=v.matches=0}function nt(v){8<v.bi_valid?V(v,v.bi_buf):0<v.bi_valid&&(v.pending_buf[v.pending++]=v.bi_buf),v.bi_buf=0,v.bi_valid=0}function dt(v,N,P,F){var E=2*N,j=2*P;return v[E]<v[j]||v[E]===v[j]&&F[N]<=F[P]}function ot(v,N,P){for(var F=v.heap[P],E=P<<1;E<=v.heap_len&&(E<v.heap_len&&dt(N,v.heap[E+1],v.heap[E],v.depth)&&E++,!dt(N,F,v.heap[E],v.depth));)v.heap[P]=v.heap[E],P=E,E<<=1;v.heap[P]=F}function pt(v,N,P){var F,E,j,G,Z=0;if(v.last_lit!==0)for(;F=v.pending_buf[v.d_buf+2*Z]<<8|v.pending_buf[v.d_buf+2*Z+1],E=v.pending_buf[v.l_buf+Z],Z++,F===0?K(v,E,N):(K(v,(j=d[E])+u+1,N),(G=B[j])!==0&&Y(v,E-=R[j],G),K(v,j=I(--F),P),(G=O[j])!==0&&Y(v,F-=U[j],G)),Z<v.last_lit;);K(v,_,N)}function ut(v,N){var P,F,E,j=N.dyn_tree,G=N.stat_desc.static_tree,Z=N.stat_desc.has_stree,$=N.stat_desc.elems,rt=-1;for(v.heap_len=0,v.heap_max=h,P=0;P<$;P++)j[2*P]!==0?(v.heap[++v.heap_len]=rt=P,v.depth[P]=0):j[2*P+1]=0;for(;v.heap_len<2;)j[2*(E=v.heap[++v.heap_len]=rt<2?++rt:0)]=1,v.depth[E]=0,v.opt_len--,Z&&(v.static_len-=G[2*E+1]);for(N.max_code=rt,P=v.heap_len>>1;1<=P;P--)ot(v,j,P);for(E=$;P=v.heap[1],v.heap[1]=v.heap[v.heap_len--],ot(v,j,1),F=v.heap[1],v.heap[--v.heap_max]=P,v.heap[--v.heap_max]=F,j[2*E]=j[2*P]+j[2*F],v.depth[E]=(v.depth[P]>=v.depth[F]?v.depth[P]:v.depth[F])+1,j[2*P+1]=j[2*F+1]=E,v.heap[1]=E++,ot(v,j,1),2<=v.heap_len;);v.heap[--v.heap_max]=v.heap[1],(function(it,ht){var wt,mt,xt,at,Ct,Tt,gt=ht.dyn_tree,Pt=ht.max_code,ve=ht.stat_desc.static_tree,be=ht.stat_desc.has_stree,we=ht.stat_desc.extra_bits,Ft=ht.stat_desc.extra_base,_t=ht.stat_desc.max_length,Nt=0;for(at=0;at<=p;at++)it.bl_count[at]=0;for(gt[2*it.heap[it.heap_max]+1]=0,wt=it.heap_max+1;wt<h;wt++)_t<(at=gt[2*gt[2*(mt=it.heap[wt])+1]+1]+1)&&(at=_t,Nt++),gt[2*mt+1]=at,Pt<mt||(it.bl_count[at]++,Ct=0,Ft<=mt&&(Ct=we[mt-Ft]),Tt=gt[2*mt],it.opt_len+=Tt*(at+Ct),be&&(it.static_len+=Tt*(ve[2*mt+1]+Ct)));if(Nt!==0){do{for(at=_t-1;it.bl_count[at]===0;)at--;it.bl_count[at]--,it.bl_count[at+1]+=2,it.bl_count[_t]--,Nt-=2}while(0<Nt);for(at=_t;at!==0;at--)for(mt=it.bl_count[at];mt!==0;)Pt<(xt=it.heap[--wt])||(gt[2*xt+1]!==at&&(it.opt_len+=(at-gt[2*xt+1])*gt[2*xt],gt[2*xt+1]=at),mt--)}})(v,N),lt(j,rt,v.bl_count)}function a(v,N,P){var F,E,j=-1,G=N[1],Z=0,$=7,rt=4;for(G===0&&($=138,rt=3),N[2*(P+1)+1]=65535,F=0;F<=P;F++)E=G,G=N[2*(F+1)+1],++Z<$&&E===G||(Z<rt?v.bl_tree[2*E]+=Z:E!==0?(E!==j&&v.bl_tree[2*E]++,v.bl_tree[2*C]++):Z<=10?v.bl_tree[2*S]++:v.bl_tree[2*z]++,j=E,rt=(Z=0)===G?($=138,3):E===G?($=6,3):($=7,4))}function L(v,N,P){var F,E,j=-1,G=N[1],Z=0,$=7,rt=4;for(G===0&&($=138,rt=3),F=0;F<=P;F++)if(E=G,G=N[2*(F+1)+1],!(++Z<$&&E===G)){if(Z<rt)for(;K(v,E,v.bl_tree),--Z!=0;);else E!==0?(E!==j&&(K(v,E,v.bl_tree),Z--),K(v,C,v.bl_tree),Y(v,Z-3,2)):Z<=10?(K(v,S,v.bl_tree),Y(v,Z-3,3)):(K(v,z,v.bl_tree),Y(v,Z-11,7));j=E,rt=(Z=0)===G?($=138,3):E===G?($=6,3):($=7,4)}}l(U);var T=!1;function x(v,N,P,F){Y(v,(g<<1)+(F?1:0),3),(function(E,j,G,Z){nt(E),V(E,G),V(E,~G),r.arraySet(E.pending_buf,E.window,j,G,E.pending),E.pending+=G})(v,N,P)}n._tr_init=function(v){T||((function(){var N,P,F,E,j,G=new Array(p+1);for(E=F=0;E<b-1;E++)for(R[E]=F,N=0;N<1<<B[E];N++)d[F++]=E;for(d[F-1]=E,E=j=0;E<16;E++)for(U[E]=j,N=0;N<1<<O[E];N++)D[j++]=E;for(j>>=7;E<c;E++)for(U[E]=j<<7,N=0;N<1<<O[E]-7;N++)D[256+j++]=E;for(P=0;P<=p;P++)G[P]=0;for(N=0;N<=143;)X[2*N+1]=8,N++,G[8]++;for(;N<=255;)X[2*N+1]=9,N++,G[9]++;for(;N<=279;)X[2*N+1]=7,N++,G[7]++;for(;N<=287;)X[2*N+1]=8,N++,G[8]++;for(lt(X,y+1,G),N=0;N<c;N++)k[2*N+1]=5,k[2*N]=st(N,5);J=new q(X,B,u+1,y,p),W=new q(k,O,0,c,p),tt=new q(new Array(0),A,0,m,w)})(),T=!0),v.l_desc=new M(v.dyn_ltree,J),v.d_desc=new M(v.dyn_dtree,W),v.bl_desc=new M(v.bl_tree,tt),v.bi_buf=0,v.bi_valid=0,et(v)},n._tr_stored_block=x,n._tr_flush_block=function(v,N,P,F){var E,j,G=0;0<v.level?(v.strm.data_type===2&&(v.strm.data_type=(function(Z){var $,rt=4093624447;for($=0;$<=31;$++,rt>>>=1)if(1&rt&&Z.dyn_ltree[2*$]!==0)return s;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return o;for($=32;$<u;$++)if(Z.dyn_ltree[2*$]!==0)return o;return s})(v)),ut(v,v.l_desc),ut(v,v.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),$=m-1;3<=$&&Z.bl_tree[2*H[$]+1]===0;$--);return Z.opt_len+=3*($+1)+5+5+4,$})(v),E=v.opt_len+3+7>>>3,(j=v.static_len+3+7>>>3)<=E&&(E=j)):E=j=P+5,P+4<=E&&N!==-1?x(v,N,P,F):v.strategy===4||j===E?(Y(v,2+(F?1:0),3),pt(v,X,k)):(Y(v,4+(F?1:0),3),(function(Z,$,rt,it){var ht;for(Y(Z,$-257,5),Y(Z,rt-1,5),Y(Z,it-4,4),ht=0;ht<it;ht++)Y(Z,Z.bl_tree[2*H[ht]+1],3);L(Z,Z.dyn_ltree,$-1),L(Z,Z.dyn_dtree,rt-1)})(v,v.l_desc.max_code+1,v.d_desc.max_code+1,G+1),pt(v,v.dyn_ltree,v.dyn_dtree)),et(v),F&&nt(v)},n._tr_tally=function(v,N,P){return v.pending_buf[v.d_buf+2*v.last_lit]=N>>>8&255,v.pending_buf[v.d_buf+2*v.last_lit+1]=255&N,v.pending_buf[v.l_buf+v.last_lit]=255&P,v.last_lit++,N===0?v.dyn_ltree[2*P]++:(v.matches++,N--,v.dyn_ltree[2*(d[P]+u+1)]++,v.dyn_dtree[2*I(N)]++),v.last_lit===v.lit_bufsize-1},n._tr_align=function(v){Y(v,2,3),K(v,_,X),(function(N){N.bi_valid===16?(V(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)})(v)}},{"../utils/common":41}],53:[function(e,i,n){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,n){(function(r){(function(s,o){if(!s.setImmediate){var l,g,b,u,y=1,c={},m=!1,h=s.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(s);p=p&&p.setTimeout?p:s,l={}.toString.call(s.process)==="[object process]"?function(C){process.nextTick(function(){w(C)})}:(function(){if(s.postMessage&&!s.importScripts){var C=!0,S=s.onmessage;return s.onmessage=function(){C=!1},s.postMessage("","*"),s.onmessage=S,C}})()?(u="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",_,!1):s.attachEvent("onmessage",_),function(C){s.postMessage(u+C,"*")}):s.MessageChannel?((b=new MessageChannel).port1.onmessage=function(C){w(C.data)},function(C){b.port2.postMessage(C)}):h&&"onreadystatechange"in h.createElement("script")?(g=h.documentElement,function(C){var S=h.createElement("script");S.onreadystatechange=function(){w(C),S.onreadystatechange=null,g.removeChild(S),S=null},g.appendChild(S)}):function(C){setTimeout(w,0,C)},p.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var S=new Array(arguments.length-1),z=0;z<S.length;z++)S[z]=arguments[z+1];var B={callback:C,args:S};return c[y]=B,l(y),y++},p.clearImmediate=f}function f(C){delete c[C]}function w(C){if(m)setTimeout(w,0,C);else{var S=c[C];if(S){m=!0;try{(function(z){var B=z.callback,O=z.args;switch(O.length){case 0:B();break;case 1:B(O[0]);break;case 2:B(O[0],O[1]);break;case 3:B(O[0],O[1],O[2]);break;default:B.apply(o,O)}})(S)}finally{f(C),m=!1}}}}function _(C){C.source===s&&typeof C.data=="string"&&C.data.indexOf(u)===0&&w(+C.data.slice(u.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof St<"u"?St:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(zt)),zt.exports}var fe=ue();const pe=he(fe);class Lt{generate(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2)}}class Mt{idGenerator;constructor(){this.idGenerator=new Lt}async extractMindMapData(t){const e=new pe;try{const n=(await e.loadAsync(t)).file("content.json");if(!n)throw new Error("Invalid XMind file: content.json not found");const r=await n.async("text"),s=JSON.parse(r);if(!Array.isArray(s)||s.length===0)throw new Error("Invalid XMind file: No content found");const o=s[0];return{nodeData:await this.transformTopic(o.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 n=this.idGenerator.generate(),r=[];if(t.children&&t.children.attached)for(const o of t.children.attached)r.push(await this.transformTopic(o,e,!1));let s;if(t.image&&t.image.src&&t.image.src.startsWith("xap:")){const o=t.image.src.substring(4),l=e.file(o);if(l){const g=await l.async("base64"),b=o.split(".").pop()?.toLowerCase();let u="image/png";b==="jpg"||b==="jpeg"?u="image/jpeg":b==="svg"?u="image/svg+xml":b==="gif"&&(u="image/gif"),s=`data:${u};base64,${g}`}}if(t.title&&s){const o={id:n,topic:t.title,root:i,children:r},g={id:this.idGenerator.generate(),topic:"",image:s,children:[]};return o.children?.push(g),o}else return s?{id:n,topic:"",image:s,root:i,children:r}:{id:n,topic:t.title||"",root:i,children:r}}}class me{mindMap;renderer;eventBus;fileHandler;constructor(t){this.mindMap=t.mindMap,this.renderer=t.renderer,this.eventBus=t.eventBus,this.fileHandler=t.fileHandler}async exportPng(){this.eventBus.emit("command",{name:"exportPng"}),await new Dt().exportToPng(this.renderer.container,this.fileHandler)}async exportSvg(){this.eventBus.emit("command",{name:"exportSvg"}),await new Dt().exportToSvg(this.renderer.container,this.fileHandler)}async exportMarkdown(){this.eventBus.emit("command",{name:"exportMarkdown"}),await new ce().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 null;if(this.fileHandler){const t=await this.fileHandler.onImportFile("xmind");if(t)try{const e=new Mt;let i;if(t instanceof ArrayBuffer)i=new File([t],"imported.xmind");else if(typeof t=="string")i=new File([t],"imported.xmind");else return null;return await e.extractMindMapData(i)}catch(e){return console.error(e),alert("Failed to import XMind file."),null}return null}return new Promise(t=>{const e=document.createElement("input");e.type="file",e.accept=".xmind",e.style.display="none",document.body.appendChild(e),e.onchange=async i=>{const r=i.target.files?.[0];if(r)try{const o=await new Mt().extractMindMapData(r);t(o)}catch(s){console.error(s),alert("Failed to import XMind file."),t(null)}else t(null);document.body.removeChild(e)},e.click()})}}class ge{mindMap;service;renderer;eventBus;layoutSwitcher;savedCustomStyles={rootNode:{border:"2px solid #aeb6bf",background:"#ebf5fb",color:"#2e4053"},childNode:{border:"1px solid #d5d8dc",background:"#fdfefe",color:"#2c3e50"},canvas:{background:"#ffffff"},connection:{color:"#abb2b9"}};constructor(t){this.mindMap=t.mindMap,this.service=t.service,this.renderer=t.renderer,this.eventBus=t.eventBus}setLayoutSwitcher(t){this.layoutSwitcher=t}applyInitialTheme(){const t=this.mindMap.theme;if(t==="custom"){const e=ct.getInstance();e.setCustomTheme(this.savedCustomStyles),e.applyTheme(this.renderer.container,"custom")}else ct.getInstance().applyTheme(this.renderer.container,t)}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")}this.eventBus.emit("theme:changed",this.mindMap.theme),this.eventBus.emit("model:change","updateGlobalStyles")}setTheme(t,e={}){const{saveState:i=!0,emitChange:n=!0}=e;if(n&&this.eventBus.emit("command",{name:"setTheme",args:{theme:t}}),this.service.setTheme(t),this.layoutSwitcher&&this.layoutSwitcher.setTheme(t),t==="custom"){const r=ct.getInstance();r.setCustomTheme(this.savedCustomStyles),r.applyTheme(this.renderer.container,"custom")}else ct.getInstance().applyTheme(this.renderer.container,t);this.eventBus.emit("theme:changed",t),i&&this.eventBus.emit("model:change","setTheme")}getSavedCustomStyles(){return this.savedCustomStyles}}class Ot{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(n=>n!==e))}removeListener(t,e){this.off(t,e)}emit(t,e){this.listeners[t]?.forEach(i=>i(e))}}class ye extends Ot{mindMap;controller;interactionOrchestrator;commandBus;constructor(t,e={}){super();const i=new yt("root","Root Topic",null,!0);this.mindMap=new bt(i);const n=new Lt,r=new Wt(this.mindMap,n),s=new jt(10),o=new Ht(this.mindMap,n),l=new Zt(this.mindMap),g=document.createElement("div");g.style.position="absolute",g.style.top="0",g.style.left="0",g.style.width="100%",g.style.height="100%",g.style.pointerEvents="none",g.style.zIndex="2000",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.style.overscrollBehavior="none",t.style.touchAction="none",t.appendChild(g);const u=new vt(g),y=new Gt(t,{onImageZoom:S=>this.controller.setReadOnly(S),onToggleFold:S=>this.controller.toggleFold(S)});let c="en";typeof navigator<"u"&&navigator.language&&navigator.language.startsWith("ja")&&(c="ja");const m=new de(y),h=new le(this.mindMap),p={emit:(S,z)=>this.emit(S,z),on:(S,z)=>this.on(S,z),off:(S,z)=>this.off(S,z)},f=new me({mindMap:this.mindMap,renderer:y,eventBus:p,fileHandler:e.fileHandler}),w=new ge({mindMap:this.mindMap,service:r,renderer:y,eventBus:p}),_=new ne;this.controller=new ae({mindMap:this.mindMap,service:r,renderer:y,styleEditor:u,eventBus:p,historyService:s,clipboardService:o,searchService:l,viewportService:m,navigationService:h,fileIOService:f,themeService:w,commandBus:_,locale:e.locale||c,commandPaletteFeatures:e.disabledCommandPaletteFeatures}),u.onUpdate=(S,z)=>{this.controller.updateNode(S,{style:z})},this.interactionOrchestrator=new ie({container:t,commandBus:_,mindMap:this.mindMap,getSelectedNodeId:()=>this.controller.getSelectedNodeId(),getNodeElement:S=>y.getNodeElement(S),zoomNode:S=>y.zoomNode(S),options:{...e,onNodeClick:(S,z)=>{z&&S?this.controller.selectRangeTo(S):this.controller.selectNode(S||null)},onAddChild:S=>this.controller.addChildNode(S),onInsertParent:S=>this.controller.insertParentNode(S),onAddSibling:(S,z)=>this.controller.addSiblingNode(S,z),onDeleteNode:S=>this.controller.removeNode(S),onDropNode:(S,z,B)=>this.controller.moveNode(S,z,B),onUpdateNode:(S,z)=>this.controller.updateNodeTopic(S,z),onNavigate:(S,z,B)=>this.controller.navigateNode(S,z,B),onPan:(S,z)=>this.controller.panBoard(S,z),onCopyNode:S=>this.controller.copyNode(S),onPasteNode:S=>this.controller.pasteNode(S),onCutNode:S=>this.controller.cutNode(S),onPasteImage:(S,z,B,O)=>this.controller.pasteImage(S,z,B,O),onZoom:(S,z,B)=>this.controller.zoomBoard(S,z,B),onZoomReset:()=>this.controller.resetZoom(),onUndo:()=>this.controller.undo(),onRedo:()=>this.controller.redo(),onStyleAction:(S,z)=>this.controller.onStyleAction(S,z),onEditEnd:S=>this.controller.onEditEnd(),onToggleFold:S=>this.controller.toggleFold(S),onToggleCommandPalette:()=>this.controller.toggleCommandPalette(),onUpdateNodeWidth:(S,z)=>this.controller.updateNodeWidth(S,z)}}),this.commandBus=_,this.controller.setInteractionOrchestrator(this.interactionOrchestrator);const C=new $t(g,{onLayoutChange:S=>this.controller.setLayoutMode(S),onThemeChange:S=>this.controller.setTheme(S),onZoomReset:()=>this.controller.resetZoom(),onShowHelp:()=>this.controller.showHelpModal()});this.controller.setLayoutSwitcher(C),e.maxNodeWidth!==void 0&&this.controller.setMaxNodeWidth(e.maxNodeWidth),e.customStyles&&this.controller.updateGlobalStyles(e.customStyles),this.controller.init(t.clientWidth,t.clientHeight)}addNode(t,e,i,n={emitChange:!0}){return this.controller.addNode(t,e,i,n)}addSibling(t,e="after",i="New topic",n={emitChange:!0}){return this.controller.addSibling(t,e,i,n)}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()}registerCommand(t){this.controller.registerCommand(t)}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=n=>{t(n)&&e.push(n),n.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,n){this.controller.pasteImage(t,e,i,n)}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}}ft.Kakidash=ye,ft.Node=yt,ft.SvgGenerator=Bt,ft.TypedEventEmitter=Ot,ft.XMindImporter=Mt,Object.defineProperty(ft,Symbol.toStringTag,{value:"Module"})}));
56
+ `,document.head.appendChild(t),this.cleanupFns.push(()=>{const e=document.getElementById("drag-drop-styles");e&&e.remove()})}}attachEvents(){const t=n=>this.handlePointerDown(n),e=n=>this.handlePointerMove(n),i=n=>this.handlePointerUp(n);this.container.addEventListener("pointerdown",t),this.cleanupFns.push(()=>this.container.removeEventListener("pointerdown",t)),this.container.addEventListener("pointermove",e),this.cleanupFns.push(()=>this.container.removeEventListener("pointermove",e)),this.container.addEventListener("pointerup",i),this.cleanupFns.push(()=>this.container.removeEventListener("pointerup",i)),this.container.addEventListener("pointercancel",i),this.cleanupFns.push(()=>this.container.removeEventListener("pointercancel",i))}handlePointerDown=t=>{const e=t;if(this.isReadOnly)return;const n=e.target.closest(".mindmap-node");n&&n.dataset.id&&(this.draggedNodeId=n.dataset.id,this.startPosition={x:e.clientX,y:e.clientY},this.isDragging=!1,n.setPointerCapture(e.pointerId))};handlePointerMove=t=>{const e=t;if(this.isReadOnly||!this.draggedNodeId)return;if(!this.isDragging&&this.startPosition){const r=e.clientX-this.startPosition.x,s=e.clientY-this.startPosition.y;if(Math.sqrt(r*r+s*s)>=this.DRAG_THRESHOLD)this.isDragging=!0,this.createGhostElement(e);else return}this.ghostElement&&(this.ghostElement.style.left=`${e.clientX}px`,this.ghostElement.style.top=`${e.clientY}px`);const i=document.elementFromPoint(e.clientX,e.clientY);if(!i)return;const n=i.closest(".mindmap-node");if(this.container.querySelectorAll(".mindmap-node").forEach(r=>{r.classList.remove("drag-over-top","drag-over-bottom","drag-over-left","drag-over-right")}),n&&n.dataset.id&&n.dataset.id!==this.draggedNodeId){const r=this.getDropPosition(e,n);n.classList.add(`drag-over-${r}`)}};handlePointerUp=t=>{const e=t;if(this.ghostElement&&(this.ghostElement.remove(),this.ghostElement=null),this.draggedNodeId){const n=e.target;n.hasPointerCapture&&n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId)}let i=null;if(this.draggedNodeId&&this.isDragging){const n=document.elementFromPoint(e.clientX,e.clientY);n&&(i=n.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){this.draggedNodeId=null,this.isDragging=!1,this.startPosition=null;return}if(i&&i.dataset.id&&this.draggedNodeId&&this.isDragging){const n=i.dataset.id;if(this.draggedNodeId!==n){const r=this.getDropPosition(e,i);this.commandBus.dispatch({type:"dropNode",draggedId:this.draggedNodeId,targetId:n,position:r})}}this.draggedNodeId=null,this.isDragging=!1,this.startPosition=null};createGhostElement(t){if(!this.draggedNodeId)return;const e=this.container.querySelector(`[data-id="${this.draggedNodeId}"]`);e&&(this.ghostElement=e.cloneNode(!0),this.ghostElement.classList.add("kakidash-drag-ghost"),this.ghostElement.style.position="fixed",this.ghostElement.style.pointerEvents="none",this.ghostElement.style.opacity="0.7",this.ghostElement.style.zIndex="9999",this.ghostElement.style.margin="0",this.ghostElement.style.left=`${t.clientX}px`,this.ghostElement.style.top=`${t.clientY}px`,this.ghostElement.style.transform="translate(-50%, -50%)",document.body.appendChild(this.ghostElement))}getDropPosition(t,e){const i=e.getBoundingClientRect(),n=t.clientX-i.left,r=t.clientY-i.top,s=i.width,o=i.height;return r<o*.25?"top":r>o*.75?"bottom":n<s*.25?"left":(n>s*.75,"right")}}class ee{container;maxWidth;commandBus;constructor(t,e,i){this.container=t,this.maxWidth=e,this.commandBus=i}setMaxWidth(t){this.maxWidth=t}startEditing(t,e){console.log(`[NodeEditor] startEditing called for ${e}`);const i=t.textContent||"",n=this.createEditTextarea(t,i);let r=this.maxWidth;if(t.style.maxWidth){const w=parseInt(t.style.maxWidth,10);isNaN(w)||(r=w)}this.applyTextareaStyles(n,t,r);const s=t.style.outline,o=t.style.boxShadow;t.style.outline="none",t.style.boxShadow="none";const l=this.createSizeUpdater(n,t,r);l(),n.addEventListener("input",l);const g=this.createCleanupFunction(n,t,s,o);this.setupEditEventHandlers(n,e,i,g),t.parentElement?t.parentElement.appendChild(n):this.container.appendChild(n),n.focus({preventScroll:!0}),n.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 n=window.getComputedStyle(e);if(i!==-1){t.style.whiteSpace="pre-wrap",t.style.wordWrap="break-word",t.style.overflowWrap="anywhere";const r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),s=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.borderRightWidth)||0),o=i+r+s;t.style.maxWidth=`${o}px`,t.style.width="max-content"}else t.style.whiteSpace="pre";t.style.font=n.font,t.style.padding=n.padding,t.style.boxSizing="border-box",t.style.backgroundColor=n.backgroundColor,t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.borderTop=n.borderTop,t.style.borderRight=n.borderRight,t.style.borderBottom=n.borderBottom,t.style.borderLeft=n.borderLeft,t.style.borderRadius=n.borderRadius,t.style.zIndex="100"}createSizeUpdater(t,e,i){const n=window.getComputedStyle(e);return()=>{const r=document.createElement("span");r.style.font=n.font,r.style.padding=n.padding,i!==-1?(r.style.whiteSpace="pre-wrap",r.style.wordWrap="break-word",r.style.overflowWrap="anywhere",r.style.maxWidth=`${i}px`,r.style.width="max-content"):r.style.whiteSpace="pre",r.style.visibility="hidden",r.style.position="absolute",r.textContent=t.value||"",(t.value.endsWith(`
57
+ `)||t.value==="")&&(r.textContent+="​"),document.body&&document.body.appendChild(r);const s=r.offsetWidth+4,o=r.offsetHeight;t.style.width=Math.max(s,e.offsetWidth)+"px",t.style.height=Math.max(o,e.offsetHeight)+"px",r.parentNode&&r.parentNode.removeChild(r)}}createCleanupFunction(t,e,i,n){return()=>{t.parentNode&&t.parentNode.contains(t)&&t.parentNode.removeChild(t),e.style.outline=i,e.style.boxShadow=n}}setupEditEventHandlers(t,e,i,n){let r=!1;const s=()=>{if(r)return;r=!0;const l=t.value;l!==i&&this.commandBus.dispatch({type:"updateNode",nodeId:e,topic:l}),n(),this.commandBus.dispatch({type:"editEnd",nodeId:e})},o=()=>{r||(r=!0,n(),this.commandBus.dispatch({type:"editEnd",nodeId:e}))};t.addEventListener("blur",()=>{r||s()}),t.addEventListener("keydown",l=>{if(l.stopPropagation(),!l.isComposing)if(l.key==="Enter"){if(l.shiftKey)return;l.preventDefault(),s()}else l.key==="Escape"&&(l.preventDefault(),o())})}}class ie{container;commandBus;mindMap;options;keyboardHandler;zoomPanHandler;dragDropHandler;nodeEditor;cleanupFns=[];isReadOnly=!1;_maxWidth=-1;_getNodeElement;_zoomNode;getSelectedNodeId;constructor(t){this.container=t.container,this.commandBus=t.commandBus,this.mindMap=t.mindMap,this.options=t.options,this._getNodeElement=t.getNodeElement,this._zoomNode=t.zoomNode,this.getSelectedNodeId=t.getSelectedNodeId,this.container.tabIndex=0,this.container.style.outline="none",this.container.style.cursor="default",this.isReadOnly=!!t.options.allowReadOnly,this.keyboardHandler=new qt({commandBus:this.commandBus,container:this.container,shortcuts:this.options.shortcuts},t.getSelectedNodeId),this.zoomPanHandler=new Qt({commandBus:this.commandBus,container:this.container}),this.dragDropHandler=new te({commandBus:this.commandBus,container:this.container}),this.dragDropHandler.setReadOnly(this.isReadOnly),this.nodeEditor=new ee(this.container,this._maxWidth,this.commandBus),this.attachEvents()}get isReadOnlyState(){return this.isReadOnly}getShortcuts(){return this.keyboardHandler.getShortcuts()}setReadOnly(t){this.isReadOnly=t,this.dragDropHandler.setReadOnly(t)}focus(){this.container.focus()}set maxWidth(t){this._maxWidth=t,this.nodeEditor.setMaxWidth(t)}get maxWidth(){return this._maxWidth}editNode(t){const e=this.getNodeElement(t);e&&this.startEditing(e,t)}getNodeElement(t){return this._getNodeElement(t)}zoomNode(t){this._zoomNode(t)}updateSelection(t){}destroy(){this.keyboardHandler.destroy(),this.zoomPanHandler.destroy(),this.dragDropHandler.destroy(),this.cleanupFns.forEach(t=>t()),this.cleanupFns=[]}attachEvents(){const t=(e,i,n,r)=>{e.addEventListener(i,n,r),this.cleanupFns.push(()=>{e.removeEventListener(i,n,r)})};t(this.container,"scroll",()=>{(this.container.scrollTop!==0||this.container.scrollLeft!==0)&&(this.container.scrollTop=0,this.container.scrollLeft=0)}),t(this.container,"click",e=>{const n=e.target.closest(".mindmap-node");n&&n.dataset.id?this.commandBus.dispatch({type:"selectNode",nodeId:n.dataset.id,extendSelection:e.shiftKey}):this.commandBus.dispatch({type:"selectNode",nodeId:null}),this.container.focus()}),t(this.container,"dblclick",e=>{if(this.isReadOnly)return;const n=e.target.closest(".mindmap-node");n&&n.dataset.id&&this.startEditing(n,n.dataset.id)}),t(this.container,"contextmenu",e=>{}),t(this.container,"paste",e=>{if(this.isReadOnly)return;const i=this.getSelectedNodeId();if(!i)return;const n=e.clipboardData;if(!n)return;const r=n.items;let s=!1;for(const o of Array.from(r))if(o.type.startsWith("image/")){s=!0,e.preventDefault();const l=o.getAsFile();if(l){const g=new FileReader;g.onload=w=>{const u=w.target?.result,y=new Image;y.onload=()=>{this.commandBus.dispatch({type:"pasteImage",parentId:i,imageData:u,width:y.width,height:y.height})},y.src=u},g.readAsDataURL(l)}}if(!s){const o=n.getData("text/plain");o?(e.preventDefault(),this.commandBus.dispatch({type:"pasteNode",parentId:i,text:o})):(e.preventDefault(),this.commandBus.dispatch({type:"pasteNode",parentId:i}))}}),this.commandBus.on("editNode",e=>{this.editNode(e.nodeId)})}startEditing(t,e){const i=this.mindMap?.findNode(e);if(i&&i.image){this.zoomNode(e);return}this.nodeEditor.startEditing(t,e)}}class ne{handlers=new Map;on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){const i=this.handlers.get(t);i&&(i.delete(e),i.size===0&&this.handlers.delete(t))}dispatch(t){const e=this.handlers.get(t.type);e&&e.forEach(i=>i(t))}destroy(){this.handlers.clear()}}class re{measureFn;heightCache=new Map;constructor(t){this.measureFn=t}calculate(t,e){this.heightCache.clear();const i={nodes:[],connections:[]},{width:n,height:r}=this.measureNode(t);if(i.nodes.push({nodeId:t.id,x:0,y:0,width:n,height:r,direction:"right",isRoot:!0}),t.presentation?.isFolded||t.children.length===0)return i;let s=[],o=[];return e==="Both"?t.children.forEach((l,g)=>{(l.presentation?.layoutSide||(g%2===0?"right":"left"))==="right"?s.push(l):o.push(l)}):e==="Left"?o=t.children:s=t.children,s.length>0&&this.calculateChildrenStack(t,s,0,0,e,"right",n,i),o.length>0&&this.calculateChildrenStack(t,o,0,0,e,"left",n,i),i}calculateChildrenStack(t,e,i,n,r,s,o,l){const g=e.reduce((c,m)=>c+this.getNodeHeight(m),0);let w=n-g/2;const u=80;let y=0;t.isRoot?y=s==="right"?i+o/2:i-o/2:s==="right"?y=i+o:y=i-o,e.forEach(c=>{const m=this.getNodeHeight(c),h=w+m/2,p=s==="right"?y+u:y-u,{width:f,height:b}=this.measureNode(c);if(l.nodes.push({nodeId:c.id,x:p,y:h,width:f,height:b,direction:s,isRoot:!1}),l.connections.push({fromX:y,fromY:n,toX:p,toY:h,toNodeId:c.id}),!c.presentation?.isFolded&&c.children.length>0){const _=s;let C=[],S=[];_==="left"?S=c.children:C=c.children,C.length>0&&this.calculateChildrenStack(c,C,p,h,r,"right",f,l),S.length>0&&this.calculateChildrenStack(c,S,p,h,r,"left",f,l)}w+=m})}getChildrenHeight(t){return t.children.reduce((e,i)=>e+this.getNodeHeight(i),0)}getNodeHeight(t){if(this.heightCache.has(t.id))return this.heightCache.get(t.id);const{height:e}=this.measureNode(t),i=20;if(t.children.length===0||t.presentation?.isFolded){const s=e+i;return this.heightCache.set(t.id,s),s}const n=this.getChildrenHeight(t),r=Math.max(e+i,n);return this.heightCache.set(t.id,r),r}measureNode(t){return this.measureFn(t)}}class se{container;overlay;paletteEl;inputEl;resultListEl;options;customCommands=[];results=[];selectedIndex=-1;mode="menu";menuCommands=[];ALL_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"},{id:"num_0_blue",topic:"0-blue",type:"icon"},{id:"num_1_blue",topic:"1-blue",type:"icon"},{id:"num_2_blue",topic:"2-blue",type:"icon"},{id:"num_3_blue",topic:"3-blue",type:"icon"},{id:"num_4_blue",topic:"4-blue",type:"icon"},{id:"num_5_blue",topic:"5-blue",type:"icon"},{id:"num_6_blue",topic:"6-blue",type:"icon"},{id:"num_7_blue",topic:"7-blue",type:"icon"},{id:"num_8_blue",topic:"8-blue",type:"icon"},{id:"num_9_blue",topic:"9-blue",type:"icon"},{id:"num_0_red",topic:"0-red",type:"icon"},{id:"num_1_red",topic:"1-red",type:"icon"},{id:"num_2_red",topic:"2-red",type:"icon"},{id:"num_3_red",topic:"3-red",type:"icon"},{id:"num_4_red",topic:"4-red",type:"icon"},{id:"num_5_red",topic:"5-red",type:"icon"},{id:"num_6_red",topic:"6-red",type:"icon"},{id:"num_7_red",topic:"7-red",type:"icon"},{id:"num_8_red",topic:"8-red",type:"icon"},{id:"num_9_red",topic:"9-red",type:"icon"}];constructor(t,e){this.container=t,this.options=e;const i=e.disabledFeatures||[];this.menuCommands=this.ALL_MENU_COMMANDS.filter(n=>!(n.id==="icon"&&i.includes("icon")||n.id==="search-nodes"&&i.includes("search")||n.id==="import"&&i.includes("import")||n.id==="export"&&i.includes("export"))),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",n=>{const r=n.target.value;if(this.mode==="menu")this.renderList(this.getMenuResults(r));else if(this.mode==="import"){const s=this.IMPORT_COMMANDS.filter(o=>o.topic.toLowerCase().includes(r.toLowerCase()));this.renderList(s)}else if(this.mode==="export"){const s=this.EXPORT_COMMANDS.filter(o=>o.topic.toLowerCase().includes(r.toLowerCase()));this.renderList(s)}else if(this.mode==="icon"){const s=this.ICON_LIST.filter(o=>o.topic.toLowerCase().includes(r.toLowerCase()));this.renderList(s)}else this.options.onInput(r)}),e.addEventListener("keydown",n=>{n.key==="ArrowDown"?(n.preventDefault(),this.moveSelection(1)):n.key==="ArrowUp"?(n.preventDefault(),this.moveSelection(-1)):n.key==="Enter"?(n.preventDefault(),this.confirmSelection()):n.key==="Escape"?(n.preventDefault(),this.close()):n.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.getMenuResults()))});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.getMenuResults())}addCustomCommand(t){this.customCommands.push(t)}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"})))}getMenuResults(t=""){const e=t.toLowerCase().trim(),i=this.menuCommands.filter(r=>r.topic.toLowerCase().includes(e)),n=this.customCommands.filter(r=>r.topic.toLowerCase().includes(e));return[...i,...n.map(r=>({...r,type:"custom"}))]}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 n=document.createElement("li");if(n.style.borderBottom="1px solid #f9f9f9",e.type==="icon"&&e.id!=="delete"){n.style.display="flex",n.style.alignItems="center";const r=It[e.id];if(r){const o=document.createElement("div");o.style.width="20px",o.style.height="20px",o.style.marginRight="8px",o.style.flexShrink="0",o.innerHTML=`<svg viewBox="${r.viewBox}" width="20" height="20">${r.path}</svg>`,n.appendChild(o)}const s=document.createElement("span");s.textContent=e.topic,n.appendChild(s)}else n.textContent=e.topic;n.addEventListener("mouseenter",()=>{this.setSelectedIndex(i)}),n.addEventListener("click",()=>{this.selectItem(e)}),this.resultListEl.appendChild(n)}),t.length>0&&this.setSelectedIndex(0)}selectItem(t){if(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());else if(t.type==="custom"){const e=this.customCommands.find(i=>i.id===t.id);if(e){const i=this.options.getSelectedNodeId?this.options.getSelectedNodeId():null;e.execute(i)}this.close()}else 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 n=e[i];i===t?(n.style.backgroundColor="#007acc",n.style.color="white"):(n.style.backgroundColor="transparent",n.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])}}class oe{constructor(){}show(t,e,i){if(typeof document>"u")return;const n=document.createElement("div");n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100vw",n.style.height="100vh",n.style.backgroundColor="rgba(0,0,0,0.5)",n.style.zIndex="3000",n.style.display="flex",n.style.justifyContent="center",n.style.alignItems="center",n.style.opacity="0",n.style.transition="opacity 0.2s";const r=document.createElement("div");r.style.backgroundColor="white",r.style.padding="20px",r.style.borderRadius="8px",r.style.boxShadow="0 4px 6px rgba(0,0,0,0.1)",r.style.maxWidth="600px",r.style.width="90%",r.style.maxHeight="90vh",r.style.overflowY="auto",r.style.position="relative";const s=document.createElement("h2");s.textContent=e==="ja"?"ヘルプ":"Help",s.style.margin="0 0 15px 0",s.style.fontSize="1.5em",s.style.borderBottom="1px solid #eee",s.style.paddingBottom="10px",r.appendChild(s);const o=document.createElement("button");if(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",()=>{g()}),r.appendChild(o),i){const u=document.createElement("h3");u.textContent=e==="ja"?"ツールバーアイコン":"Toolbar Icons",u.style.marginTop="10px",u.style.marginBottom="10px",u.style.fontSize="1.2em",u.style.color="#333",u.style.borderBottom="1px solid #f0f0f0",r.appendChild(u);const y=document.createElement("table");y.style.width="100%",y.style.borderCollapse="collapse",y.style.fontSize="0.9em",y.style.marginBottom="20px",i.getIconDescriptions(e).forEach(m=>{const h=document.createElement("tr");h.style.borderBottom="1px solid #f9f9f9";const p=document.createElement("td");p.style.padding="8px",p.style.width="40px",p.style.textAlign="center";let f="";switch(m.id){case"right":f=i.getRightIcon();break;case"left":f=i.getLeftIcon();break;case"both":f=i.getBothIcon();break;case"default":f=i.getThemeDefaultIcon();break;case"simple":f=i.getThemeSimpleIcon();break;case"colorful":f=i.getThemeColorfulIcon();break;case"custom":f=i.getThemeCustomIcon();break;case"resetZoom":f=i.getZoomResetIcon();break;case"help":f=i.getHelpIcon();break}const b=document.createElement("div");b.style.width="24px",b.style.height="24px",b.style.display="flex",b.style.alignItems="center",b.style.justifyContent="center",b.style.color="#555",b.innerHTML=f,p.appendChild(b);const _=document.createElement("td");_.textContent=m.desc,_.style.padding="8px",_.style.textAlign="left",_.style.color="#333",h.appendChild(p),h.appendChild(_),y.appendChild(h)}),r.appendChild(y)}[{title:e==="ja"?"一般":"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:e==="ja"?"編集 (テキスト入力)":"Editing (Text Input)",actions:[{key:"Enter",desc:"Confirm Edit",descJa:"編集を確定"},{key:"Shift + Enter",desc:"New Line",descJa:"改行"},{key:"Esc",desc:"Cancel Edit",descJa:"編集をキャンセル"}]},{title:e==="ja"?"スタイリング (選択中)":"Styling (Selection)",actions:[{action:"bold",desc:"Toggle Bold",descJa:"太字 (Bold) 切り替え"},{action:"italic",desc:"Toggle Italic",descJa:"斜体 (Italic) 切り替え"},{action:"strikethrough",desc:"Toggle Strikethrough",descJa:"取り消し線 (Strikethrough) 切り替え"},{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(u=>{const y=[];if(u.actions.forEach(b=>{let _="";const C=b;if(C.key)_=C.key;else if(C.action&&t[C.action]){const S=t[C.action];if(S&&S.length>0){const z=S.map(B=>{const O=[];return(B.ctrlKey||B.metaKey)&&O.push("Ctrl/Cmd"),B.altKey&&O.push("Alt"),B.shiftKey&&O.push("Shift"),B.key===" "?O.push("Space"):O.push(B.key),O.join(" + ")});_=[...new Set(z)].join(" / ")}}_&&y.push({key:_,desc:e==="ja"&&C.descJa||C.desc})}),y.length===0)return;const c=document.createElement("h3");c.textContent=u.title,c.style.marginTop="20px",c.style.marginBottom="10px",c.style.fontSize="1.2em",c.style.color="#333",c.style.borderBottom="1px solid #f0f0f0",r.appendChild(c);const m=document.createElement("table");m.style.width="100%",m.style.borderCollapse="collapse",m.style.fontSize="0.9em";const h=document.createElement("tr");h.style.borderBottom="2px solid #ddd";const p=document.createElement("th");p.textContent=e==="ja"?"キー":"Key",p.style.textAlign="center",p.style.padding="8px 0",p.style.width="40%",p.style.color="#666";const f=document.createElement("th");f.textContent=e==="ja"?"説明":"Description",f.style.textAlign="center",f.style.padding="8px 0",f.style.color="#666",h.appendChild(p),h.appendChild(f),m.appendChild(h),y.forEach(b=>{const _=document.createElement("tr");_.style.borderBottom="1px solid #f9f9f9";const C=document.createElement("td");C.textContent=b.key,C.style.padding="6px 0",C.style.fontWeight="bold",C.style.color="#555",C.style.minWidth="180px",C.style.textAlign="center";const S=document.createElement("td");S.textContent=b.desc,S.style.padding="6px 0",S.style.textAlign="left",S.style.color="#333",_.appendChild(C),_.appendChild(S),m.appendChild(_)}),r.appendChild(m)}),n.appendChild(r),document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1"});const g=()=>{n.style.opacity="0",setTimeout(()=>{document.body.contains(n)&&document.body.removeChild(n)},200),document.removeEventListener("keydown",w)},w=u=>{u.key==="Escape"&&g()};document.addEventListener("keydown",w),n.addEventListener("click",u=>{u.target===n&&g()})}}class ae{mindMap;service;renderer;eventBus;styleEditor;commandPalette;locale;interactionOrchestrator;layoutSwitcher;fileIOService;themeService;commandBus;historyService;clipboardService;searchService;viewportService;navigationService;anchorNodeId=null;selectedNodeId=null;selectedNodeIds=new Set;layoutMode="Right";isBatching=!1;maxWidth=-1;pendingNodeCreation=!1;constructor(t){this.mindMap=t.mindMap,this.service=t.service,this.renderer=t.renderer,this.styleEditor=t.styleEditor,this.eventBus=t.eventBus,this.fileIOService=t.fileIOService,this.themeService=t.themeService,this.historyService=t.historyService,this.clipboardService=t.clipboardService,this.searchService=t.searchService,this.viewportService=t.viewportService,this.navigationService=t.navigationService,this.locale=t.locale??"en",this.commandBus=t.commandBus,this.commandPalette=new se(this.renderer.container,{onInput:e=>this.handleSearchInput(e),onSelect:e=>this.handleSearchResultSelect(e),onIconSelect:e=>this.handleIconSelect(e),onCommandSelect:e=>this.handleCommandSelect(e),onClose:()=>{this.interactionOrchestrator&&this.interactionOrchestrator.focus()},getSelectedNodeId:()=>this.selectedNodeId,disabledFeatures:t.commandPaletteFeatures}),this.subscribeToCommands(),this.subscribeToModel()}subscribeToModel(){this.eventBus.on("model:change",()=>{this.render()})}subscribeToCommands(){const t=this.commandBus;t.on("addNode",e=>this.addChildNode(e.parentId)),t.on("addSibling",e=>this.addSiblingNode(e.nodeId,e.position)),t.on("deleteNode",e=>this.removeNode(e.nodeId)),t.on("insertParent",e=>this.insertParentNode(e.nodeId)),t.on("dropNode",e=>this.moveNode(e.draggedId,e.targetId,e.position)),t.on("updateNode",e=>this.updateNodeTopic(e.nodeId,e.topic)),t.on("navigate",e=>this.navigateNode(e.nodeId,e.direction,e.extendSelection)),t.on("pan",e=>this.panBoard(e.dx,e.dy)),t.on("zoom",e=>this.zoomBoard(e.delta,e.x,e.y)),t.on("zoomReset",()=>this.resetZoom()),t.on("copyNode",e=>this.copyNode(e.nodeId)),t.on("pasteNode",e=>this.pasteNode(e.parentId,e.text)),t.on("cutNode",e=>this.cutNode(e.nodeId)),t.on("pasteImage",e=>this.pasteImage(e.parentId,e.imageData,e.width,e.height)),t.on("undo",()=>this.undo()),t.on("redo",()=>this.redo()),t.on("styleAction",e=>this.onStyleAction(e.nodeId,e.action)),t.on("toggleFold",e=>this.toggleFold(e.nodeId)),t.on("toggleCommandPalette",()=>this.toggleCommandPalette()),t.on("updateNodeWidth",e=>this.updateNodeWidth(e.nodeId,e.increment)),t.on("setTheme",e=>this.setTheme(e.theme)),t.on("setLayoutMode",e=>this.setLayoutMode(e.mode)),t.on("editEnd",()=>this.onEditEnd()),t.on("selectNode",e=>{e.extendSelection&&e.nodeId?this.selectRangeTo(e.nodeId):this.selectNode(e.nodeId)})}setInteractionOrchestrator(t){this.interactionOrchestrator=t}setLayoutSwitcher(t){this.layoutSwitcher=t,this.themeService.setLayoutSwitcher(t)}init(t,e){this.viewportService.setInitialPan(t*.2,e/2),this.themeService.applyInitialTheme(),this.viewportService.startAnimationLoop(),this.render()}destroy(){this.viewportService.destroy()}getData(){const t=this.service.exportData();return t.selectedId=this.selectedNodeId||void 0,t.selectedIds=Array.from(this.selectedNodeIds),t}loadData(t){try{this.service.importData(t),this.render(),this.restoreSelection(t),this.eventBus.emit("model:load",t),t.theme&&this.setTheme(t.theme,{saveState:!1,emitChange:!1}),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}getSelectedNodeIds(){return Array.from(this.selectedNodeIds)}getIdsToActOn(t){return this.selectedNodeIds.has(t)?Array.from(this.selectedNodeIds):[t]}saveState(){if(this.isBatching)return;const t=this.getData();this.historyService.saveState(t)}addNode(t,e,i,n={emitChange:!0}){n.emitChange&&this.saveState(),this.eventBus.emit("command",{name:"addNode",args:{parentId:t,topic:e,layoutSide:i}});const r=this.service.addNode(t,e,i);return r&&(this.render(),this.eventBus.emit("node:add",{id:r.id,topic:r.topic}),n.emitChange&&this.eventBus.emit("model:change",void 0)),r}addSibling(t,e="after",i="New topic",n={emitChange:!0}){n.emitChange&&this.saveState(),this.eventBus.emit("command",{name:"addSibling",args:{referenceId:t,position:e,topic:i}});const r=this.mindMap.findNode(t);if(!r||!r.parentId)return null;const s=this.mindMap.findNode(r.parentId);s&&s.isRoot&&this.layoutMode==="Both"&&this.navigationService.ensureExplicitLayoutSides(s);const o=this.service.addSibling(t,e,i);if(o){if(s&&s.isRoot&&this.layoutMode==="Both"){const l=r.presentation.layoutSide||(s.children.indexOf(r)%2===0?"right":"left");o.presentation.layoutSide=l}this.render(),this.eventBus.emit("node:add",{id:o.id,topic:o.topic}),n.emitChange&&this.eventBus.emit("model:change",void 0)}return o}insertParent(t,e="New topic",i={emitChange:!0}){i.emitChange&&this.saveState(),this.eventBus.emit("command",{name:"insertParent",args:{targetId:t,topic:e}});const n=this.service.insertParent(t,e);return n&&(this.render(),this.eventBus.emit("node:add",{id:n.id,topic:n.topic}),i.emitChange&&this.eventBus.emit("model:change",void 0)),n}deleteNode(t){this.saveState(),this.eventBus.emit("command",{name:"deleteNode",args:{nodeId:t}});const e=this.getIdsToActOn(t);e.length>1?this.service.removeNodes(e)&&(this.render(),e.forEach(i=>this.eventBus.emit("node:remove",i)),this.eventBus.emit("model:change",void 0)):this.service.removeNode(t)&&(this.render(),this.eventBus.emit("node:remove",t),this.eventBus.emit("model:change",void 0))}updateNode(t,e){if(this.saveState(),this.eventBus.emit("command",{name:"updateNode",args:{nodeId:t,updates:e}}),this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState)return;let i=!1;const n=this.getIdsToActOn(t);if(e.topic!==void 0&&this.service.updateNodeTopic(t,e.topic)&&(i=!0),e.style!==void 0&&this.service.updateNodesStyle(n,e.style)&&(i=!0),e.icon!==void 0){let r=!1;n.forEach(s=>{this.service.updateNodeIcon(s,e.icon)&&(r=!0)}),r&&(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.saveState(),this.eventBus.emit("command",{name:"updateNodeWidth",args:{nodeId:t,increment:e}}),this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState)return;const i=this.mindMap.findNode(t);if(!i)return;let n=i.presentation.customWidth;n===void 0&&(n=this.renderer.measureNode(i,this.mindMap).width);let r=n+e;r<50&&(r=50),this.service.updateNodeCustomWidth(t,r)&&(this.render(),this.eventBus.emit("model:change",void 0))}addChildNode(t){const e=this.mindMap.findNode(t);e&&e.isRoot&&this.layoutMode==="Both"&&this.navigationService.ensureExplicitLayoutSides(e);let i;if(this.layoutMode==="Both"&&e&&e.isRoot){let r=0,s=0;e.children.forEach((o,l)=>{(o.presentation.layoutSide||(l%2===0?"right":"left"))==="left"?r++:s++}),i=r<s?"left":"right"}this.pendingNodeCreation=!0;const n=this.addNode(t,"New topic",i,{emitChange:!1});n&&(this.selectNode(n.id),this.ensureNodeVisible(n.id,!1,!0),this.interactionOrchestrator.editNode(n.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.interactionOrchestrator.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.interactionOrchestrator.editNode(e.id))}removeNode(t){const e=this.getIdsToActOn(t),i=this.findTargetIdAfterRemoval(t,e);this.deleteNode(t),this.selectNode(i)}selectNode(t){this.anchorNodeId=null,!(this.selectedNodeId===t&&this.selectedNodeIds.size===1&&t&&this.selectedNodeIds.has(t))&&(t===null&&this.selectedNodeId===null&&this.selectedNodeIds.size===0||(this.selectedNodeId=t,this.selectedNodeIds.clear(),t&&this.selectedNodeIds.add(t),this.updateSelectionState()))}selectNodes(t){this.selectedNodeIds=new Set(t),this.selectedNodeId=t.length>0?t[t.length-1]:null,this.updateSelectionState()}updateSelectionState(){const t=this.selectedNodeId;if(this.interactionOrchestrator&&this.interactionOrchestrator.updateSelection(t),t){const e=this.mindMap.findNode(t);e&&(!e.image&&this.interactionOrchestrator&&!this.interactionOrchestrator.isReadOnlyState?this.styleEditor.show(t,e.style):this.styleEditor.hide())}else this.styleEditor.hide();this.renderSelection(),this.eventBus.emit("node:select",t),this.eventBus.emit("selection:change",Array.from(this.selectedNodeIds))}restoreSelection(t){t.selectedIds&&t.selectedIds.length>0?(this.selectNodes(t.selectedIds),this.ensureNodeVisible(t.selectedIds[0],!0,!0)):t.selectedId?(this.selectNode(t.selectedId),this.ensureNodeVisible(t.selectedId,!0,!0)):(this.selectNode(null),this.ensureNodeVisible(this.mindMap.root.id,!0,!0))}findTargetIdAfterRemoval(t,e){const i=this.mindMap.findNode(t);if(i){let n=i;for(;n&&n.parentId;){if(!e.includes(n.parentId))return n.parentId;n=this.mindMap.findNode(n.parentId)}}return this.mindMap.root.id}moveNode(t,e,i){this.saveState(),this.eventBus.emit("command",{name:"moveNode",args:{nodeId:t,targetId:e,position:i}});const n=this.mindMap.findNode(e);if(n){if(i==="top"){if(n.isRoot)return;this.service.reorderNode(t,e,"before")}else if(i==="bottom"){if(n.isRoot)return;this.service.reorderNode(t,e,"after")}else if(n.isRoot){const r=i==="left"?"left":"right";this.service.moveNode(t,e,r)}else((this.navigationService.getNodeDirection(n)==="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(){if(this.isBatching)return;const e=new re(n=>this.renderer.measureNode(n,this.mindMap)).calculate(this.mindMap.root,this.layoutMode);let i;this.selectedNodeIds instanceof Set?i=this.selectedNodeIds:Array.isArray(this.selectedNodeIds)?i=new Set(this.selectedNodeIds):typeof this.selectedNodeIds=="string"?i=new Set([this.selectedNodeIds]):i=new Set,this.renderer.renderFromLayout(e,this.mindMap,i,this.layoutMode),this.viewportService.applyTransform()}renderSelection(){this.isBatching||(this.renderer.updateSelection(this.selectedNodeIds),this.viewportService.applyTransform())}setLayoutMode(t){this.eventBus.emit("command",{name:"setLayoutMode",args:{mode:t}}),this.layoutMode=t,this.navigationService.setLayoutMode(t),this.layoutSwitcher&&this.layoutSwitcher.setMode(t);const e=this.renderer.container.clientWidth,i=this.renderer.container.clientHeight;t==="Right"?this.viewportService.setInitialPan(e*.2,i/2):t==="Left"?this.viewportService.setInitialPan(e*.8,i/2):this.viewportService.setInitialPan(e*.5,i/2),this.render(),this.selectedNodeId?this.ensureNodeVisible(this.selectedNodeId,!0,!0):this.ensureNodeVisible(this.mindMap.root.id,!0,!0)}getLayoutMode(){return this.layoutMode}setMaxNodeWidth(t){this.maxWidth=t,this.renderer.maxWidth=t,this.interactionOrchestrator&&(this.interactionOrchestrator.maxWidth=t),this.render()}getMaxNodeWidth(){return this.maxWidth}updateGlobalStyles(t){this.themeService.updateGlobalStyles(t)}setTheme(t,e={saveState:!0,emitChange:!0}){this.themeService.setTheme(t,e)}resetZoom(){this.viewportService.resetZoom(),this.render()}panBoard(t,e){this.viewportService.pan(t,e)}zoomBoard(t,e,i){this.viewportService.zoom(t,e,i)}setReadOnly(t){this.interactionOrchestrator&&this.interactionOrchestrator.setReadOnly(t),t&&this.styleEditor.hide()}undo(){const t=this.getData(),e=this.historyService.undo(t);e&&(this.eventBus.emit("command",{name:"undo"}),this.loadData(e),this.render(),this.eventBus.emit("model:change",void 0))}redo(){const t=this.getData(),e=this.historyService.redo(t);e&&(this.eventBus.emit("command",{name:"redo"}),this.loadData(e),this.render(),this.eventBus.emit("model:change",void 0))}toggleFold(t){this.saveState(),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,i=!1){if(!t){this.selectNode(this.mindMap.root.id);return}if(!this.mindMap.findNode(t))return;const r=this.navigationService.navigate(t,e);r&&(i?this.selectRange(t,r):this.selectNode(r)),this.selectedNodeId&&this.selectedNodeId!==t&&setTimeout(()=>this.ensureNodeVisible(this.selectedNodeId,!0),0)}selectRangeTo(t){this.selectedNodeId?this.selectRange(this.selectedNodeId,t):this.selectNode(t)}selectRange(t,e){this.anchorNodeId||(this.anchorNodeId=t);const i=this.mindMap.findNode(this.anchorNodeId),n=this.mindMap.findNode(e);if(!i||!n)return;if(i.parentId&&i.parentId===n.parentId){const s=this.mindMap.findNode(i.parentId);if(s){const o=s.children.findIndex(g=>g.id===i.id),l=s.children.findIndex(g=>g.id===n.id);if(o!==-1&&l!==-1){const g=Math.min(o,l),w=Math.max(o,l),u=s.children.slice(g,w+1).map(y=>y.id);this.selectNodes(u),this.selectedNodeId=e,this.updateSelectionState();return}}}const r=new Set(this.selectedNodeIds);r.add(e),this.selectNodes(Array.from(r)),this.selectedNodeId=e,this.updateSelectionState()}copyNode(t){const e=this.getIdsToActOn(t);e.length>1?this.clipboardService.copyNodes(e):this.clipboardService.copyNodes([t])}pasteNode(t,e){this.saveState(),this.eventBus.emit("command",{name:"pasteNode",args:{parentId:t,text:e}});const i=this.clipboardService.createPastedNodes(t,e),n=i.length>0?i[0]:null;i.length>0&&this.service.addExistingNodes(t,i),n&&(this.render(),this.selectNode(n.id),this.eventBus.emit("node:add",{id:n.id,topic:n.topic}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(n.id,!0),0))}cutNode(t){this.saveState(),this.eventBus.emit("command",{name:"cutNode",args:{nodeId:t}});const e=this.getIdsToActOn(t),i=this.findTargetIdAfterRemoval(t,e);e.length>1?(this.clipboardService.copyNodes(e),this.service.removeNodes(e)):(this.clipboardService.copyNodes([t]),this.service.removeNode(t)),this.selectNode(i),this.render(),e.forEach(n=>this.eventBus.emit("node:remove",n)),this.eventBus.emit("model:change",void 0)}pasteImage(t,e,i,n){this.saveState(),this.eventBus.emit("command",{name:"pasteImage",args:{parentId:t,width:i,height:n}});const r=this.service.addImageNode(t,e,i,n);r&&(this.render(),this.selectNode(r.id),this.eventBus.emit("node:add",{id:r.id,topic:""}),this.eventBus.emit("model:change",void 0),setTimeout(()=>this.ensureNodeVisible(r.id,!0),0))}onEditEnd(){this.pendingNodeCreation&&(this.pendingNodeCreation=!1,this.eventBus.emit("model:change",void 0))}onStyleAction(t,e){if(this.saveState(),this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState)return;const i=this.mindMap.findNode(t);if(!i)return;const n=i.style||{};let r=null;if(e.type==="bold")r={fontWeight:n.fontWeight==="bold"?"normal":"bold"};else if(e.type==="italic")r={fontStyle:n.fontStyle==="italic"?"normal":"italic"};else if(e.type==="strikethrough")r={textDecoration:n.textDecoration==="line-through"?"none":"line-through"};else if(e.type==="color")e.index>=0&&e.index<vt.PALETTE.length&&(r={color:vt.PALETTE[e.index]});else if(e.type==="increaseSize"||e.type==="decreaseSize"){const s=vt.FONT_SIZES,o=n.fontSize||"";let l=s.findIndex(w=>w.value===o);l===-1&&(l=0);const g=e.type==="increaseSize"?Math.min(s.length-1,l+1):Math.max(0,l-1);g!==l&&(r={fontSize:s[g].value})}if(r){const s=this.getIdsToActOn(t);this.service.updateNodesStyle(s,r)&&(this.render(),this.eventBus.emit("model:change",void 0),this.selectedNodeId===t&&this.styleEditor.show(t,{...n,...r}))}}toggleCommandPalette(){this.interactionOrchestrator&&this.interactionOrchestrator.isReadOnlyState||this.commandPalette.toggle()}registerCommand(t){this.commandPalette.addCustomCommand(t)}searchNodes(t){return this.searchService.searchNodes(t)}handleSearchInput(t){const e=this.searchService.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.fileIOService.importXMind().then(e=>{e&&this.loadData(e)}):t==="export-png"?this.fileIOService.exportPng():t==="export-svg"?this.fileIOService.exportSvg():t==="export-markdown"&&this.fileIOService.exportMarkdown()}ensureNodeVisible(t,e=!1,i=!1){this.viewportService.ensureNodeVisible(t,e,i)}showHelpModal(){if(!this.interactionOrchestrator||typeof document>"u")return;new oe().show(this.interactionOrchestrator.getShortcuts(),this.locale,this.layoutSwitcher)}}class de{panX=0;panY=0;targetPanX=0;targetPanY=0;scale=1;animationFrameId=null;renderer;constructor(t){this.renderer=t}getScale(){return this.scale}getPan(){return{x:this.panX,y:this.panY}}getTargetPan(){return{x:this.targetPanX,y:this.targetPanY}}setInitialPan(t,e){this.panX=t,this.panY=e,this.targetPanX=t,this.targetPanY=e}pan(t,e){this.targetPanX+=t,this.targetPanY+=e}zoom(t,e,i){const o=this.renderer.container.getBoundingClientRect(),l=e-o.left,g=i-o.top,w=Math.min(Math.max(this.scale*(1-t*.001),.1),5),u=l-(l-this.panX)*(w/this.scale),y=g-(g-this.panY)*(w/this.scale);this.panX=u,this.panY=y,this.targetPanX=u,this.targetPanY=y,this.scale=w,this.renderer.updateTransform(this.panX,this.panY,this.scale)}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}applyTransform(){this.renderer.updateTransform(this.panX,this.panY,this.scale)}ensureNodeVisible(t,e=!1,i=!1){const n=this.renderer.container.querySelector(`.mindmap-node[data-id="${t}"]`);if(!n)return;const r=n.getBoundingClientRect(),s=this.renderer.container.getBoundingClientRect(),o=50;let l=0,g=0;const w=r.left<s.left+o,u=r.right>s.right-o,y=r.top<s.top+o,c=r.bottom>s.bottom-o;if(e&&(w||u||y||c)){const m=r.left+r.width/2,h=r.top+r.height/2,p=s.left+s.width/2,f=s.top+s.height/2;l=p-m,g=f-h}else w?l=s.left+o-r.left:u&&(l=s.right-o-r.right),y?g=s.top+o-r.top:c&&(g=s.bottom-o-r.bottom);(l!==0||g!==0)&&(i?(this.panX+=l,this.panY+=g,this.targetPanX=this.panX,this.targetPanY=this.panY,this.renderer.updateTransform(this.panX,this.panY,this.scale)):this.pan(l,g))}startAnimationLoop(){let t=performance.now();const e=()=>{const i=performance.now(),n=(i-t)/1e3;t=i;const r=1-Math.exp(-8*n),s=this.targetPanX-this.panX,o=this.targetPanY-this.panY;Math.abs(s)>.1||Math.abs(o)>.1?(this.panX+=s*r,this.panY+=o*r,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()}destroy(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}}class le{mindMap;layoutMode="Right";constructor(t){this.mindMap=t}setLayoutMode(t){this.layoutMode=t}getLayoutMode(){return this.layoutMode}navigate(t,e){const i=this.mindMap.findNode(t);if(i)switch(e){case"Left":return this.navigateLeft(i);case"Right":return this.navigateRight(i);case"Up":return this.navigateUp(i);case"Down":return this.navigateDown(i)}}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.presentation.layoutSide?e.presentation.layoutSide:i.children.findIndex(r=>r.id===e.id)%2===0?"right":"left";e=i}return"right"}ensureExplicitLayoutSides(t){!t.isRoot||this.layoutMode!=="Both"||t.children.forEach((e,i)=>{e.presentation.layoutSide||(e.presentation.layoutSide=i%2===0?"right":"left")})}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,n)=>(i.presentation.layoutSide||(n%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,n)=>(i.presentation.layoutSide||(n%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),n=e.children.filter(s=>this.getNodeDirection(s)===i),r=n.findIndex(s=>s.id===t.id);if(r>0)return n[r-1].id}}}navigateDown(t){if(t.parentId){const e=this.mindMap.findNode(t.parentId);if(e){const i=this.getNodeDirection(t),n=e.children.filter(s=>this.getNodeDirection(s)===i),r=n.findIndex(s=>s.id===t.id);if(r!==-1&&r<n.length-1)return n[r+1].id}}}}class Bt{generate(t){const e=t.querySelectorAll("svg");let i=null;for(let X=0;X<e.length;X++){const k=e[X];if(k.style.zIndex==="0"&&k.style.position==="absolute"){i=k;break}}!i&&e.length>0&&e[0].parentElement===t&&(i=e[0]);const n=t.querySelectorAll("div");let r=null;for(let X=0;X<n.length;X++){const k=n[X];if(k.style.zIndex==="1"&&k.style.position==="absolute"){r=k;break}}if(!i||!r)throw new Error("Could not find mind map content layers.");let s=1/0,o=1/0,l=-1/0,g=-1/0;const w=r.children;if(w.length===0)s=0,o=0,l=800,g=600;else for(let X=0;X<w.length;X++){const k=w[X],D=parseFloat(k.style.left||"0"),d=parseFloat(k.style.top||"0"),R=k.offsetWidth,J=k.offsetHeight,W=d-J/2,tt=d+J/2;D<s&&(s=D),W<o&&(o=W),D+R>l&&(l=D+R),tt>g&&(g=tt)}const u=50;s-=u,o-=u,l+=u,g+=u;const y=l-s,c=g-o,m=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"],p=[];h.forEach(X=>{const k=m.getPropertyValue(X).trim();k&&p.push(`${X}: ${k};`)});const f=p.join(" "),b=m.fontFamily,_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("xmlns","http://www.w3.org/2000/svg"),_.setAttribute("width",y.toString()),_.setAttribute("height",c.toString()),_.setAttribute("viewBox",`0 0 ${y} ${c}`),_.style.cssText=f;const C=document.createElementNS("http://www.w3.org/2000/svg","rect");C.setAttribute("x","0"),C.setAttribute("y","0"),C.setAttribute("width",y.toString()),C.setAttribute("height",c.toString()),C.setAttribute("fill",m.backgroundColor||"#ffffff"),_.appendChild(C);const S=document.createElementNS("http://www.w3.org/2000/svg","g");S.setAttribute("transform",`translate(${-s}, ${-o})`),i.querySelectorAll("path").forEach(X=>{const k=X.cloneNode(!0),D=window.getComputedStyle(X);let d=D.stroke;(!d||d==="none")&&(d=X.style.stroke),(!d||d==="none")&&(d="#cccccc"),k.style.stroke=d;let R=D.strokeWidth;(!R||R==="0px"||R==="auto")&&(R=X.getAttribute("stroke-width")||"2px"),k.style.strokeWidth=R,k.style.fill="none",S.appendChild(k)});const B=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");B.setAttribute("x","0"),B.setAttribute("y","0"),B.setAttribute("width",(l+u).toString()),B.setAttribute("height",(g+u).toString()),B.style.overflow="visible";const O=document.createElement("div");O.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),O.style.cssText=`position: relative; width: 100%; height: 100%; font-family: ${b}; ${f}`;const A=r.children;for(let X=0;X<A.length;X++){const k=A[X].cloneNode(!0);O.appendChild(k)}return B.appendChild(O),S.appendChild(B),_.appendChild(S),new XMLSerializer().serializeToString(_)}}class Dt{async exportToSvg(t,e){try{const n=new Bt().generate(t),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"});await this.saveFile(r,"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 n=new Bt().generate(t),s=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(n)))}`;await new Promise((o,l)=>{const g=new Image;g.onload=()=>{try{const w=document.createElement("canvas");w.width=g.width,w.height=g.height;const u=w.getContext("2d");if(!u)throw new Error("Could not get canvas context");u.drawImage(g,0,0),w.toBlob(y=>{y?this.saveFile(y,"mindmap.png",[{description:"PNG Image",accept:{"image/png":[".png"]}}],e).then(()=>o()).catch(c=>l(c instanceof Error?c:new Error(String(c)))):l(new Error("Failed to generate PNG blob."))},"image/png")}catch(w){l(w instanceof Error?w:new Error(String(w)))}},g.onerror=()=>{l(new Error("Failed to load SVG for PNG conversion"))},g.src=s})}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,n){if(n){const o=e.split(".").pop();await n.onExportFile(t,e,o);return}const r=await this.showSavePicker({suggestedName:e,types:i});if(!r)return;const s=await r.createWritable();await s.write(t),await s.close()}}class ce{async export(t,e){const i=this.generateMarkdown(t),n=new Blob([i],{type:"text/markdown;charset=utf-8"});await this.saveFile(n,"mindmap.md",e)}generateMarkdown(t){const e=t.root;if(!e)return"";const i=[];return this.processNode(e,0,i),i.join(`
58
+ `)}processNode(t,e,i){const n=this.getNodeText(t);if(e===0)i.push(`# ${n}`);else if(e===1)i.push(`## ${n}`);else{const r=" ".repeat(e-2);i.push(`${r}- ${n}`)}for(const r of t.children)this.processNode(r,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 r=await(await window.showSaveFilePicker({suggestedName:e,types:[{description:"Markdown File",accept:{"text/markdown":[".md"]}}]})).createWritable();await r.write(t),await r.close()}else{const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}}catch(n){n.name!=="AbortError"&&(console.error("Failed to save file:",n),alert("Failed to save file."))}}}var St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function he(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}function kt(Q){throw new Error('Could not dynamically require "'+Q+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zt={exports:{}};var Rt;function ue(){return Rt||(Rt=1,(function(Q,t){(function(e){Q.exports=e()})(function(){return(function e(i,n,r){function s(g,w){if(!n[g]){if(!i[g]){var u=typeof kt=="function"&&kt;if(!w&&u)return u(g,!0);if(o)return o(g,!0);var y=new Error("Cannot find module '"+g+"'");throw y.code="MODULE_NOT_FOUND",y}var c=n[g]={exports:{}};i[g][0].call(c.exports,function(m){var h=i[g][1][m];return s(h||m)},c,c.exports,e,i,n,r)}return n[g].exports}for(var o=typeof kt=="function"&&kt,l=0;l<r.length;l++)s(r[l]);return s})({1:[function(e,i,n){var r=e("./utils"),s=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(l){for(var g,w,u,y,c,m,h,p=[],f=0,b=l.length,_=b,C=r.getTypeOf(l)!=="string";f<l.length;)_=b-f,u=C?(g=l[f++],w=f<b?l[f++]:0,f<b?l[f++]:0):(g=l.charCodeAt(f++),w=f<b?l.charCodeAt(f++):0,f<b?l.charCodeAt(f++):0),y=g>>2,c=(3&g)<<4|w>>4,m=1<_?(15&w)<<2|u>>6:64,h=2<_?63&u:64,p.push(o.charAt(y)+o.charAt(c)+o.charAt(m)+o.charAt(h));return p.join("")},n.decode=function(l){var g,w,u,y,c,m,h=0,p=0,f="data:";if(l.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var b,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&_--,l.charAt(l.length-2)===o.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=s.uint8array?new Uint8Array(0|_):new Array(0|_);h<l.length;)g=o.indexOf(l.charAt(h++))<<2|(y=o.indexOf(l.charAt(h++)))>>4,w=(15&y)<<4|(c=o.indexOf(l.charAt(h++)))>>2,u=(3&c)<<6|(m=o.indexOf(l.charAt(h++))),b[p++]=g,c!==64&&(b[p++]=w),m!==64&&(b[p++]=u);return b}},{"./support":30,"./utils":32}],2:[function(e,i,n){var r=e("./external"),s=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function g(w,u,y,c,m){this.compressedSize=w,this.uncompressedSize=u,this.crc32=y,this.compression=c,this.compressedContent=m}g.prototype={getContentWorker:function(){var w=new s(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return w.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),w},getCompressedWorker:function(){return new s(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},g.createWorkerFrom=function(w,u,y){return w.pipe(new o).pipe(new l("uncompressedSize")).pipe(u.compressWorker(y)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},i.exports=g},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,i,n){var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,i,n){var r=e("./utils"),s=(function(){for(var o,l=[],g=0;g<256;g++){o=g;for(var w=0;w<8;w++)o=1&o?3988292384^o>>>1:o>>>1;l[g]=o}return l})();i.exports=function(o,l){return o!==void 0&&o.length?r.getTypeOf(o)!=="string"?(function(g,w,u,y){var c=s,m=y+u;g^=-1;for(var h=y;h<m;h++)g=g>>>8^c[255&(g^w[h])];return-1^g})(0|l,o,o.length,0):(function(g,w,u,y){var c=s,m=y+u;g^=-1;for(var h=y;h<m;h++)g=g>>>8^c[255&(g^w.charCodeAt(h))];return-1^g})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(e,i,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,i,n){var r=null;r=typeof Promise<"u"?Promise:e("lie"),i.exports={Promise:r}},{lie:37}],7:[function(e,i,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=e("pako"),o=e("./utils"),l=e("./stream/GenericWorker"),g=r?"uint8array":"array";function w(u,y){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=y,this.meta={}}n.magic="\b\0",o.inherits(w,l),w.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(g,u.data),!1)},w.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},w.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},w.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(y){u.push({data:y,meta:u.meta})}},n.compressWorker=function(u){return new w("Deflate",u)},n.uncompressWorker=function(){return new w("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,i,n){function r(c,m){var h,p="";for(h=0;h<m;h++)p+=String.fromCharCode(255&c),c>>>=8;return p}function s(c,m,h,p,f,b){var _,C,S=c.file,z=c.compression,B=b!==g.utf8encode,O=o.transformTo("string",b(S.name)),A=o.transformTo("string",g.utf8encode(S.name)),H=S.comment,X=o.transformTo("string",b(H)),k=o.transformTo("string",g.utf8encode(H)),D=A.length!==S.name.length,d=k.length!==H.length,R="",J="",W="",tt=S.dir,U=S.date,q={crc32:0,compressedSize:0,uncompressedSize:0};m&&!h||(q.crc32=c.crc32,q.compressedSize=c.compressedSize,q.uncompressedSize=c.uncompressedSize);var M=0;m&&(M|=8),B||!D&&!d||(M|=2048);var I=0,V=0;tt&&(I|=16),f==="UNIX"?(V=798,I|=(function(K,st){var lt=K;return K||(lt=st?16893:33204),(65535&lt)<<16})(S.unixPermissions,tt)):(V=20,I|=(function(K){return 63&(K||0)})(S.dosPermissions)),_=U.getUTCHours(),_<<=6,_|=U.getUTCMinutes(),_<<=5,_|=U.getUTCSeconds()/2,C=U.getUTCFullYear()-1980,C<<=4,C|=U.getUTCMonth()+1,C<<=5,C|=U.getUTCDate(),D&&(J=r(1,1)+r(w(O),4)+A,R+="up"+r(J.length,2)+J),d&&(W=r(1,1)+r(w(X),4)+k,R+="uc"+r(W.length,2)+W);var Y="";return Y+=`
59
+ \0`,Y+=r(M,2),Y+=z.magic,Y+=r(_,2),Y+=r(C,2),Y+=r(q.crc32,4),Y+=r(q.compressedSize,4),Y+=r(q.uncompressedSize,4),Y+=r(O.length,2),Y+=r(R.length,2),{fileRecord:u.LOCAL_FILE_HEADER+Y+O+R,dirRecord:u.CENTRAL_FILE_HEADER+r(V,2)+Y+r(X.length,2)+"\0\0\0\0"+r(I,4)+r(p,4)+O+R+X}}var o=e("../utils"),l=e("../stream/GenericWorker"),g=e("../utf8"),w=e("../crc32"),u=e("../signature");function y(c,m,h,p){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=h,this.encodeFileName=p,this.streamFiles=c,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(y,l),y.prototype.push=function(c){var m=c.meta.percent||0,h=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(c):(this.bytesWritten+=c.data.length,l.prototype.push.call(this,{data:c.data,meta:{currentFile:this.currentFile,percent:h?(m+100*(h-p-1))/h:100}}))},y.prototype.openedSource=function(c){this.currentSourceOffset=this.bytesWritten,this.currentFile=c.file.name;var m=this.streamFiles&&!c.file.dir;if(m){var h=s(c,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:h.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(c){this.accumulate=!1;var m=this.streamFiles&&!c.file.dir,h=s(c,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(h.dirRecord),m)this.push({data:(function(p){return u.DATA_DESCRIPTOR+r(p.crc32,4)+r(p.compressedSize,4)+r(p.uncompressedSize,4)})(c),meta:{percent:100}});else for(this.push({data:h.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var c=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var h=this.bytesWritten-c,p=(function(f,b,_,C,S){var z=o.transformTo("string",S(C));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(f,2)+r(f,2)+r(b,4)+r(_,4)+r(z.length,2)+z})(this.dirRecords.length,h,c,this.zipComment,this.encodeFileName);this.push({data:p,meta:{percent:100}})},y.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},y.prototype.registerPrevious=function(c){this._sources.push(c);var m=this;return c.on("data",function(h){m.processChunk(h)}),c.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),c.on("error",function(h){m.error(h)}),this},y.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},y.prototype.error=function(c){var m=this._sources;if(!l.prototype.error.call(this,c))return!1;for(var h=0;h<m.length;h++)try{m[h].error(c)}catch{}return!0},y.prototype.lock=function(){l.prototype.lock.call(this);for(var c=this._sources,m=0;m<c.length;m++)c[m].lock()},i.exports=y},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,i,n){var r=e("../compressions"),s=e("./ZipFileWorker");n.generateWorker=function(o,l,g){var w=new s(l.streamFiles,g,l.platform,l.encodeFileName),u=0;try{o.forEach(function(y,c){u++;var m=(function(b,_){var C=b||_,S=r[C];if(!S)throw new Error(C+" is not a valid compression method !");return S})(c.options.compression,l.compression),h=c.options.compressionOptions||l.compressionOptions||{},p=c.dir,f=c.date;c._compressWorker(m,h).withStreamInfo("file",{name:y,dir:p,date:f,comment:c.comment||"",unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions}).pipe(w)}),w.entriesCount=u}catch(y){w.error(y)}return w}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,i,n){function r(){if(!(this instanceof r))return new r;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 s=new r;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.1",r.loadAsync=function(s,o){return new r().loadAsync(s,o)},r.external=e("./external"),i.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,i,n){var r=e("./utils"),s=e("./external"),o=e("./utf8"),l=e("./zipEntries"),g=e("./stream/Crc32Probe"),w=e("./nodejsUtils");function u(y){return new s.Promise(function(c,m){var h=y.decompressed.getContentWorker().pipe(new g);h.on("error",function(p){m(p)}).on("end",function(){h.streamInfo.crc32!==y.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):c()}).resume()})}i.exports=function(y,c){var m=this;return c=r.extend(c||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),w.isNode&&w.isStream(y)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",y,!0,c.optimizedBinaryString,c.base64).then(function(h){var p=new l(c);return p.load(h),p}).then(function(h){var p=[s.Promise.resolve(h)],f=h.files;if(c.checkCRC32)for(var b=0;b<f.length;b++)p.push(u(f[b]));return s.Promise.all(p)}).then(function(h){for(var p=h.shift(),f=p.files,b=0;b<f.length;b++){var _=f[b],C=_.fileNameStr,S=r.resolve(_.fileNameStr);m.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:c.createFolders}),_.dir||(m.file(S).unsafeOriginalName=C)}return p.zipComment.length&&(m.comment=p.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,i,n){var r=e("../utils"),s=e("../stream/GenericWorker");function o(l,g){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(g)}r.inherits(o,s),o.prototype._bindStream=function(l){var g=this;(this._stream=l).pause(),l.on("data",function(w){g.push({data:w,meta:{percent:0}})}).on("error",function(w){g.isPaused?this.generatedError=w:g.error(w)}).on("end",function(){g.isPaused?g._upstreamEnded=!0:g.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,i,n){var r=e("readable-stream").Readable;function s(o,l,g){r.call(this,l),this._helper=o;var w=this;o.on("data",function(u,y){w.push(u)||w._helper.pause(),g&&g(y)}).on("error",function(u){w.emit("error",u)}).on("end",function(){w.push(null)})}e("../utils").inherits(s,r),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(e,i,n){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,s);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,s)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var s=new Buffer(r);return s.fill(0),s},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(e,i,n){function r(S,z,B){var O,A=o.getTypeOf(z),H=o.extend(B||{},w);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=f(S)),H.createFolders&&(O=p(S))&&b.call(this,O,!0);var X=A==="string"&&H.binary===!1&&H.base64===!1;B&&B.binary!==void 0||(H.binary=!X),(z instanceof u&&z.uncompressedSize===0||H.dir||!z||z.length===0)&&(H.base64=!1,H.binary=!0,z="",H.compression="STORE",A="string");var k=null;k=z instanceof u||z instanceof l?z:m.isNode&&m.isStream(z)?new h(S,z):o.prepareContent(S,z,H.binary,H.optimizedBinaryString,H.base64);var D=new y(S,k,H);this.files[S]=D}var s=e("./utf8"),o=e("./utils"),l=e("./stream/GenericWorker"),g=e("./stream/StreamHelper"),w=e("./defaults"),u=e("./compressedObject"),y=e("./zipObject"),c=e("./generate"),m=e("./nodejsUtils"),h=e("./nodejs/NodejsStreamInputAdapter"),p=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var z=S.lastIndexOf("/");return 0<z?S.substring(0,z):""},f=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},b=function(S,z){return z=z!==void 0?z:w.createFolders,S=f(S),this.files[S]||r.call(this,S,null,{dir:!0,createFolders:z}),this.files[S]};function _(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 z,B,O;for(z in this.files)O=this.files[z],(B=z.slice(this.root.length,z.length))&&z.slice(0,this.root.length)===this.root&&S(B,O)},filter:function(S){var z=[];return this.forEach(function(B,O){S(B,O)&&z.push(O)}),z},file:function(S,z,B){if(arguments.length!==1)return S=this.root+S,r.call(this,S,z,B),this;if(_(S)){var O=S;return this.filter(function(H,X){return!X.dir&&O.test(H)})}var A=this.files[this.root+S];return A&&!A.dir?A:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(A,H){return H.dir&&S.test(A)});var z=this.root+S,B=b.call(this,z),O=this.clone();return O.root=B.name,O},remove:function(S){S=this.root+S;var z=this.files[S];if(z||(S.slice(-1)!=="/"&&(S+="/"),z=this.files[S]),z&&!z.dir)delete this.files[S];else for(var B=this.filter(function(A,H){return H.name.slice(0,S.length)===S}),O=0;O<B.length;O++)delete this.files[B[O].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 z,B={};try{if((B=o.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=B.type.toLowerCase(),B.compression=B.compression.toUpperCase(),B.type==="binarystring"&&(B.type="string"),!B.type)throw new Error("No output type specified.");o.checkSupport(B.type),B.platform!=="darwin"&&B.platform!=="freebsd"&&B.platform!=="linux"&&B.platform!=="sunos"||(B.platform="UNIX"),B.platform==="win32"&&(B.platform="DOS");var O=B.comment||this.comment||"";z=c.generateWorker(this,B,O)}catch(A){(z=new l("error")).error(A)}return new g(z,B.type||"string",B.mimeType)},generateAsync:function(S,z){return this.generateInternalStream(S).accumulate(z)},generateNodeStream:function(S,z){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(z)}};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,n){i.exports=e("stream")},{stream:void 0}],17:[function(e,i,n){var r=e("./DataReader");function s(o){r.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}e("../utils").inherits(s,r),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),g=o.charCodeAt(1),w=o.charCodeAt(2),u=o.charCodeAt(3),y=this.length-4;0<=y;--y)if(this.data[y]===l&&this.data[y+1]===g&&this.data[y+2]===w&&this.data[y+3]===u)return y-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),g=o.charCodeAt(1),w=o.charCodeAt(2),u=o.charCodeAt(3),y=this.readData(4);return l===y[0]&&g===y[1]&&w===y[2]&&u===y[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(e,i,n){var r=e("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,g=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)g=(g<<8)+this.byteAt(l);return this.index+=o,g},readString:function(o){return r.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=s},{"../utils":32}],19:[function(e,i,n){var r=e("./Uint8ArrayReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,i,n){var r=e("./DataReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(e,i,n){var r=e("./ArrayReader");function s(o){r.call(this,o)}e("../utils").inherits(s,r),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(e,i,n){var r=e("../utils"),s=e("../support"),o=e("./ArrayReader"),l=e("./StringReader"),g=e("./NodeBufferReader"),w=e("./Uint8ArrayReader");i.exports=function(u){var y=r.getTypeOf(u);return r.checkSupport(y),y!=="string"||s.uint8array?y==="nodebuffer"?new g(u):s.uint8array?new w(r.transformTo("uint8array",u)):new o(r.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,i,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,i,n){var r=e("./GenericWorker"),s=e("../utils");function o(l){r.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(o,r),o.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,i,n){var r=e("./GenericWorker"),s=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,i,n){var r=e("../utils"),s=e("./GenericWorker");function o(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}r.inherits(o,s),o.prototype.processChunk=function(l){if(l){var g=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=g+l.data.length}s.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,i,n){var r=e("../utils"),s=e("./GenericWorker");function o(l){s.call(this,"DataWorker");var g=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(w){g.dataIsReady=!0,g.data=w,g.max=w&&w.length||0,g.type=r.getTypeOf(w),g.isPaused||g._tickAndRepeat()},function(w){g.error(w)})}r.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,g=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,g);break;case"uint8array":l=this.data.subarray(this.index,g);break;case"array":case"nodebuffer":l=this.data.slice(this.index,g)}return this.index=g,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,i,n){function r(s){this.name=s||"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}r.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(l){o.processChunk(l)}),s.on("end",function(){o.end()}),s.on("error",function(l){o.error(l)}),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 s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},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 s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=r},{}],29:[function(e,i,n){var r=e("../utils"),s=e("./ConvertWorker"),o=e("./GenericWorker"),l=e("../base64"),g=e("../support"),w=e("../external"),u=null;if(g.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(m,h){return new w.Promise(function(p,f){var b=[],_=m._internalType,C=m._outputType,S=m._mimeType;m.on("data",function(z,B){b.push(z),h&&h(B)}).on("error",function(z){b=[],f(z)}).on("end",function(){try{var z=(function(B,O,A){switch(B){case"blob":return r.newBlob(r.transformTo("arraybuffer",O),A);case"base64":return l.encode(O);default:return r.transformTo(B,O)}})(C,(function(B,O){var A,H=0,X=null,k=0;for(A=0;A<O.length;A++)k+=O[A].length;switch(B){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(X=new Uint8Array(k),A=0;A<O.length;A++)X.set(O[A],H),H+=O[A].length;return X;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+B+"'")}})(_,b),S);p(z)}catch(B){f(B)}b=[]}).resume()})}function c(m,h,p){var f=h;switch(h){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=h,this._mimeType=p,r.checkSupport(f),this._worker=m.pipe(new s(f)),m.lock()}catch(b){this._worker=new o("error"),this._worker.error(b)}}c.prototype={accumulate:function(m){return y(this,m)},on:function(m,h){var p=this;return m==="data"?this._worker.on(m,function(f){h.call(p,f.data,f.meta)}):this._worker.on(m,function(){r.delay(h,arguments,p)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},m)}},i.exports=c},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,i,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",n.nodebuffer=typeof Buffer<"u",n.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(r),n.blob=s.getBlob("application/zip").size===0}catch{n.blob=!1}}}try{n.nodestream=!!e("readable-stream").Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,i,n){for(var r=e("./utils"),s=e("./support"),o=e("./nodejsUtils"),l=e("./stream/GenericWorker"),g=new Array(256),w=0;w<256;w++)g[w]=252<=w?6:248<=w?5:240<=w?4:224<=w?3:192<=w?2:1;g[254]=g[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function y(){l.call(this,"utf-8 encode")}n.utf8encode=function(c){return s.nodebuffer?o.newBufferFrom(c,"utf-8"):(function(m){var h,p,f,b,_,C=m.length,S=0;for(b=0;b<C;b++)(64512&(p=m.charCodeAt(b)))==55296&&b+1<C&&(64512&(f=m.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),b++),S+=p<128?1:p<2048?2:p<65536?3:4;for(h=s.uint8array?new Uint8Array(S):new Array(S),b=_=0;_<S;b++)(64512&(p=m.charCodeAt(b)))==55296&&b+1<C&&(64512&(f=m.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),b++),p<128?h[_++]=p:(p<2048?h[_++]=192|p>>>6:(p<65536?h[_++]=224|p>>>12:(h[_++]=240|p>>>18,h[_++]=128|p>>>12&63),h[_++]=128|p>>>6&63),h[_++]=128|63&p);return h})(c)},n.utf8decode=function(c){return s.nodebuffer?r.transformTo("nodebuffer",c).toString("utf-8"):(function(m){var h,p,f,b,_=m.length,C=new Array(2*_);for(h=p=0;h<_;)if((f=m[h++])<128)C[p++]=f;else if(4<(b=g[f]))C[p++]=65533,h+=b-1;else{for(f&=b===2?31:b===3?15:7;1<b&&h<_;)f=f<<6|63&m[h++],b--;1<b?C[p++]=65533:f<65536?C[p++]=f:(f-=65536,C[p++]=55296|f>>10&1023,C[p++]=56320|1023&f)}return C.length!==p&&(C.subarray?C=C.subarray(0,p):C.length=p),r.applyFromCharCode(C)})(c=r.transformTo(s.uint8array?"uint8array":"array",c))},r.inherits(u,l),u.prototype.processChunk=function(c){var m=r.transformTo(s.uint8array?"uint8array":"array",c.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var h=m;(m=new Uint8Array(h.length+this.leftOver.length)).set(this.leftOver,0),m.set(h,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var p=(function(b,_){var C;for((_=_||b.length)>b.length&&(_=b.length),C=_-1;0<=C&&(192&b[C])==128;)C--;return C<0||C===0?_:C+g[b[C]]>_?C:_})(m),f=m;p!==m.length&&(s.uint8array?(f=m.subarray(0,p),this.leftOver=m.subarray(p,m.length)):(f=m.slice(0,p),this.leftOver=m.slice(p,m.length))),this.push({data:n.utf8decode(f),meta:c.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=u,r.inherits(y,l),y.prototype.processChunk=function(c){this.push({data:n.utf8encode(c.data),meta:c.meta})},n.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,i,n){var r=e("./support"),s=e("./base64"),o=e("./nodejsUtils"),l=e("./external");function g(h){return h}function w(h,p){for(var f=0;f<h.length;++f)p[f]=255&h.charCodeAt(f);return p}e("setimmediate"),n.newBlob=function(h,p){n.checkSupport("blob");try{return new Blob([h],{type:p})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(h),f.getBlob(p)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(h,p,f){var b=[],_=0,C=h.length;if(C<=f)return String.fromCharCode.apply(null,h);for(;_<C;)p==="array"||p==="nodebuffer"?b.push(String.fromCharCode.apply(null,h.slice(_,Math.min(_+f,C)))):b.push(String.fromCharCode.apply(null,h.subarray(_,Math.min(_+f,C)))),_+=f;return b.join("")},stringifyByChar:function(h){for(var p="",f=0;f<h.length;f++)p+=String.fromCharCode(h[f]);return p},applyCanBeUsed:{uint8array:(function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function y(h){var p=65536,f=n.getTypeOf(h),b=!0;if(f==="uint8array"?b=u.applyCanBeUsed.uint8array:f==="nodebuffer"&&(b=u.applyCanBeUsed.nodebuffer),b)for(;1<p;)try{return u.stringifyByChunk(h,f,p)}catch{p=Math.floor(p/2)}return u.stringifyByChar(h)}function c(h,p){for(var f=0;f<h.length;f++)p[f]=h[f];return p}n.applyFromCharCode=y;var m={};m.string={string:g,array:function(h){return w(h,new Array(h.length))},arraybuffer:function(h){return m.string.uint8array(h).buffer},uint8array:function(h){return w(h,new Uint8Array(h.length))},nodebuffer:function(h){return w(h,o.allocBuffer(h.length))}},m.array={string:y,array:g,arraybuffer:function(h){return new Uint8Array(h).buffer},uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return o.newBufferFrom(h)}},m.arraybuffer={string:function(h){return y(new Uint8Array(h))},array:function(h){return c(new Uint8Array(h),new Array(h.byteLength))},arraybuffer:g,uint8array:function(h){return new Uint8Array(h)},nodebuffer:function(h){return o.newBufferFrom(new Uint8Array(h))}},m.uint8array={string:y,array:function(h){return c(h,new Array(h.length))},arraybuffer:function(h){return h.buffer},uint8array:g,nodebuffer:function(h){return o.newBufferFrom(h)}},m.nodebuffer={string:y,array:function(h){return c(h,new Array(h.length))},arraybuffer:function(h){return m.nodebuffer.uint8array(h).buffer},uint8array:function(h){return c(h,new Uint8Array(h.length))},nodebuffer:g},n.transformTo=function(h,p){if(p=p||"",!h)return p;n.checkSupport(h);var f=n.getTypeOf(p);return m[f][h](p)},n.resolve=function(h){for(var p=h.split("/"),f=[],b=0;b<p.length;b++){var _=p[b];_==="."||_===""&&b!==0&&b!==p.length-1||(_===".."?f.pop():f.push(_))}return f.join("/")},n.getTypeOf=function(h){return typeof h=="string"?"string":Object.prototype.toString.call(h)==="[object Array]"?"array":r.nodebuffer&&o.isBuffer(h)?"nodebuffer":r.uint8array&&h instanceof Uint8Array?"uint8array":r.arraybuffer&&h instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(h){if(!r[h.toLowerCase()])throw new Error(h+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(h){var p,f,b="";for(f=0;f<(h||"").length;f++)b+="\\x"+((p=h.charCodeAt(f))<16?"0":"")+p.toString(16).toUpperCase();return b},n.delay=function(h,p,f){setImmediate(function(){h.apply(f||null,p||[])})},n.inherits=function(h,p){function f(){}f.prototype=p.prototype,h.prototype=new f},n.extend=function(){var h,p,f={};for(h=0;h<arguments.length;h++)for(p in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],p)&&f[p]===void 0&&(f[p]=arguments[h][p]);return f},n.prepareContent=function(h,p,f,b,_){return l.Promise.resolve(p).then(function(C){return r.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-1)&&typeof FileReader<"u"?new l.Promise(function(S,z){var B=new FileReader;B.onload=function(O){S(O.target.result)},B.onerror=function(O){z(O.target.error)},B.readAsArrayBuffer(C)}):C}).then(function(C){var S=n.getTypeOf(C);return S?(S==="arraybuffer"?C=n.transformTo("uint8array",C):S==="string"&&(_?C=s.decode(C):f&&b!==!0&&(C=(function(z){return w(z,r.uint8array?new Uint8Array(z.length):new Array(z.length))})(C))),C):l.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,n){var r=e("./reader/readerFor"),s=e("./utils"),o=e("./signature"),l=e("./zipEntry"),g=e("./support");function w(u){this.files=[],this.loadOptions=u}w.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var y=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(y)+", expected "+s.pretty(u)+")")}},isSignature:function(u,y){var c=this.reader.index;this.reader.setIndex(u);var m=this.reader.readString(4)===y;return this.reader.setIndex(c),m},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 u=this.reader.readData(this.zipCommentLength),y=g.uint8array?"uint8array":"array",c=s.transformTo(y,u);this.zipComment=this.loadOptions.decodeFileName(c)},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 u,y,c,m=this.zip64EndOfCentralSize-44;0<m;)u=this.reader.readInt(2),y=this.reader.readInt(4),c=this.reader.readData(y),this.zip64ExtensibleData[u]={id:u,length:y,value:c}},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 u,y;for(u=0;u<this.files.length;u++)y=this.files[u],this.reader.setIndex(y.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),y.readLocalPart(this.reader),y.handleUTF8(),y.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);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 u=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,o.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(u);var y=u;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.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(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var c=this.centralDirOffset+this.centralDirSize;this.zip64&&(c+=20,c+=12+this.zip64EndOfCentralSize);var m=y-c;if(0<m)this.isSignature(y,o.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(u){this.reader=r(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=w},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,i,n){var r=e("./reader/readerFor"),s=e("./utils"),o=e("./compressedObject"),l=e("./crc32"),g=e("./utf8"),w=e("./compressions"),u=e("./support");function y(c,m){this.options=c,this.loadOptions=m}y.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(c){var m,h;if(c.skip(22),this.fileNameLength=c.readInt(2),h=c.readInt(2),this.fileName=c.readData(this.fileNameLength),c.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((m=(function(p){for(var f in w)if(Object.prototype.hasOwnProperty.call(w,f)&&w[f].magic===p)return w[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,m,c.readData(this.compressedSize))},readCentralPart:function(c){this.versionMadeBy=c.readInt(2),c.skip(2),this.bitFlag=c.readInt(2),this.compressionMethod=c.readString(2),this.date=c.readDate(),this.crc32=c.readInt(4),this.compressedSize=c.readInt(4),this.uncompressedSize=c.readInt(4);var m=c.readInt(2);if(this.extraFieldsLength=c.readInt(2),this.fileCommentLength=c.readInt(2),this.diskNumberStart=c.readInt(2),this.internalFileAttributes=c.readInt(2),this.externalFileAttributes=c.readInt(4),this.localHeaderOffset=c.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");c.skip(m),this.readExtraFields(c),this.parseZIP64ExtraField(c),this.fileComment=c.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var c=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),c==0&&(this.dosPermissions=63&this.externalFileAttributes),c==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var c=r(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=c.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=c.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=c.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=c.readInt(4))}},readExtraFields:function(c){var m,h,p,f=c.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});c.index+4<f;)m=c.readInt(2),h=c.readInt(2),p=c.readData(h),this.extraFields[m]={id:m,length:h,value:p};c.setIndex(f)},handleUTF8:function(){var c=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=g.utf8decode(this.fileName),this.fileCommentStr=g.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var h=s.transformTo(c,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(h)}var p=this.findExtraFieldUnicodeComment();if(p!==null)this.fileCommentStr=p;else{var f=s.transformTo(c,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var c=this.extraFields[28789];if(c){var m=r(c.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:g.utf8decode(m.readData(c.length-5))}return null},findExtraFieldUnicodeComment:function(){var c=this.extraFields[25461];if(c){var m=r(c.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:g.utf8decode(m.readData(c.length-5))}return null}},i.exports=y},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,i,n){function r(m,h,p){this.name=m,this.dir=p.dir,this.date=p.date,this.comment=p.comment,this.unixPermissions=p.unixPermissions,this.dosPermissions=p.dosPermissions,this._data=h,this._dataBinary=p.binary,this.options={compression:p.compression,compressionOptions:p.compressionOptions}}var s=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),l=e("./utf8"),g=e("./compressedObject"),w=e("./stream/GenericWorker");r.prototype={internalStream:function(m){var h=null,p="string";try{if(!m)throw new Error("No output type specified.");var f=(p=m.toLowerCase())==="string"||p==="text";p!=="binarystring"&&p!=="text"||(p="string"),h=this._decompressWorker();var b=!this._dataBinary;b&&!f&&(h=h.pipe(new l.Utf8EncodeWorker)),!b&&f&&(h=h.pipe(new l.Utf8DecodeWorker))}catch(_){(h=new w("error")).error(_)}return new s(h,p,"")},async:function(m,h){return this.internalStream(m).accumulate(h)},nodeStream:function(m,h){return this.internalStream(m||"nodebuffer").toNodejsStream(h)},_compressWorker:function(m,h){if(this._data instanceof g&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var p=this._decompressWorker();return this._dataBinary||(p=p.pipe(new l.Utf8EncodeWorker)),g.createWorkerFrom(p,m,h)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof w?this._data:new o(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],y=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},c=0;c<u.length;c++)r.prototype[u[c]]=y;i.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,i,n){(function(r){var s,o,l=r.MutationObserver||r.WebKitMutationObserver;if(l){var g=0,w=new l(m),u=r.document.createTextNode("");w.observe(u,{characterData:!0}),s=function(){u.data=g=++g%2}}else if(r.setImmediate||r.MessageChannel===void 0)s="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var h=r.document.createElement("script");h.onreadystatechange=function(){m(),h.onreadystatechange=null,h.parentNode.removeChild(h),h=null},r.document.documentElement.appendChild(h)}:function(){setTimeout(m,0)};else{var y=new r.MessageChannel;y.port1.onmessage=m,s=function(){y.port2.postMessage(0)}}var c=[];function m(){var h,p;o=!0;for(var f=c.length;f;){for(p=c,c=[],h=-1;++h<f;)p[h]();f=c.length}o=!1}i.exports=function(h){c.push(h)!==1||o||s()}}).call(this,typeof St<"u"?St:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,i,n){var r=e("immediate");function s(){}var o={},l=["REJECTED"],g=["FULFILLED"],w=["PENDING"];function u(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=w,this.queue=[],this.outcome=void 0,f!==s&&h(this,f)}function y(f,b,_){this.promise=f,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function c(f,b,_){r(function(){var C;try{C=b(_)}catch(S){return o.reject(f,S)}C===f?o.reject(f,new TypeError("Cannot resolve promise with itself")):o.resolve(f,C)})}function m(f){var b=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof b=="function")return function(){b.apply(f,arguments)}}function h(f,b){var _=!1;function C(B){_||(_=!0,o.reject(f,B))}function S(B){_||(_=!0,o.resolve(f,B))}var z=p(function(){b(S,C)});z.status==="error"&&C(z.value)}function p(f,b){var _={};try{_.value=f(b),_.status="success"}catch(C){_.status="error",_.value=C}return _}(i.exports=u).prototype.finally=function(f){if(typeof f!="function")return this;var b=this.constructor;return this.then(function(_){return b.resolve(f()).then(function(){return _})},function(_){return b.resolve(f()).then(function(){throw _})})},u.prototype.catch=function(f){return this.then(null,f)},u.prototype.then=function(f,b){if(typeof f!="function"&&this.state===g||typeof b!="function"&&this.state===l)return this;var _=new this.constructor(s);return this.state!==w?c(_,this.state===g?f:b,this.outcome):this.queue.push(new y(_,f,b)),_},y.prototype.callFulfilled=function(f){o.resolve(this.promise,f)},y.prototype.otherCallFulfilled=function(f){c(this.promise,this.onFulfilled,f)},y.prototype.callRejected=function(f){o.reject(this.promise,f)},y.prototype.otherCallRejected=function(f){c(this.promise,this.onRejected,f)},o.resolve=function(f,b){var _=p(m,b);if(_.status==="error")return o.reject(f,_.value);var C=_.value;if(C)h(f,C);else{f.state=g,f.outcome=b;for(var S=-1,z=f.queue.length;++S<z;)f.queue[S].callFulfilled(b)}return f},o.reject=function(f,b){f.state=l,f.outcome=b;for(var _=-1,C=f.queue.length;++_<C;)f.queue[_].callRejected(b);return f},u.resolve=function(f){return f instanceof this?f:o.resolve(new this(s),f)},u.reject=function(f){var b=new this(s);return o.reject(b,f)},u.all=function(f){var b=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=f.length,C=!1;if(!_)return this.resolve([]);for(var S=new Array(_),z=0,B=-1,O=new this(s);++B<_;)A(f[B],B);return O;function A(H,X){b.resolve(H).then(function(k){S[X]=k,++z!==_||C||(C=!0,o.resolve(O,S))},function(k){C||(C=!0,o.reject(O,k))})}},u.race=function(f){var b=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=f.length,C=!1;if(!_)return this.resolve([]);for(var S=-1,z=new this(s);++S<_;)B=f[S],b.resolve(B).then(function(O){C||(C=!0,o.resolve(z,O))},function(O){C||(C=!0,o.reject(z,O))});var B;return z}},{immediate:36}],38:[function(e,i,n){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),i.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,i,n){var r=e("./zlib/deflate"),s=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/messages"),g=e("./zlib/zstream"),w=Object.prototype.toString,u=0,y=-1,c=0,m=8;function h(f){if(!(this instanceof h))return new h(f);this.options=s.assign({level:y,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:c,to:""},f||{});var b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var _=r.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(_!==u)throw new Error(l[_]);if(b.header&&r.deflateSetHeader(this.strm,b.header),b.dictionary){var C;if(C=typeof b.dictionary=="string"?o.string2buf(b.dictionary):w.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(_=r.deflateSetDictionary(this.strm,C))!==u)throw new Error(l[_]);this._dict_set=!0}}function p(f,b){var _=new h(b);if(_.push(f,!0),_.err)throw _.msg||l[_.err];return _.result}h.prototype.push=function(f,b){var _,C,S=this.strm,z=this.options.chunkSize;if(this.ended)return!1;C=b===~~b?b:b===!0?4:0,typeof f=="string"?S.input=o.string2buf(f):w.call(f)==="[object ArrayBuffer]"?S.input=new Uint8Array(f):S.input=f,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new s.Buf8(z),S.next_out=0,S.avail_out=z),(_=r.deflate(S,C))!==1&&_!==u)return this.onEnd(_),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||C!==4&&C!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(S.output,S.next_out))):this.onData(s.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&_!==1);return C===4?(_=r.deflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===u):C!==2||(this.onEnd(u),!(S.avail_out=0))},h.prototype.onData=function(f){this.chunks.push(f)},h.prototype.onEnd=function(f){f===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},n.Deflate=h,n.deflate=p,n.deflateRaw=function(f,b){return(b=b||{}).raw=!0,p(f,b)},n.gzip=function(f,b){return(b=b||{}).gzip=!0,p(f,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,i,n){var r=e("./zlib/inflate"),s=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/constants"),g=e("./zlib/messages"),w=e("./zlib/zstream"),u=e("./zlib/gzheader"),y=Object.prototype.toString;function c(h){if(!(this instanceof c))return new c(h);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},h||{});var p=this.options;p.raw&&0<=p.windowBits&&p.windowBits<16&&(p.windowBits=-p.windowBits,p.windowBits===0&&(p.windowBits=-15)),!(0<=p.windowBits&&p.windowBits<16)||h&&h.windowBits||(p.windowBits+=32),15<p.windowBits&&p.windowBits<48&&(15&p.windowBits)==0&&(p.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new w,this.strm.avail_out=0;var f=r.inflateInit2(this.strm,p.windowBits);if(f!==l.Z_OK)throw new Error(g[f]);this.header=new u,r.inflateGetHeader(this.strm,this.header)}function m(h,p){var f=new c(p);if(f.push(h,!0),f.err)throw f.msg||g[f.err];return f.result}c.prototype.push=function(h,p){var f,b,_,C,S,z,B=this.strm,O=this.options.chunkSize,A=this.options.dictionary,H=!1;if(this.ended)return!1;b=p===~~p?p:p===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof h=="string"?B.input=o.binstring2buf(h):y.call(h)==="[object ArrayBuffer]"?B.input=new Uint8Array(h):B.input=h,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new s.Buf8(O),B.next_out=0,B.avail_out=O),(f=r.inflate(B,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&A&&(z=typeof A=="string"?o.string2buf(A):y.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,f=r.inflateSetDictionary(this.strm,z)),f===l.Z_BUF_ERROR&&H===!0&&(f=l.Z_OK,H=!1),f!==l.Z_STREAM_END&&f!==l.Z_OK)return this.onEnd(f),!(this.ended=!0);B.next_out&&(B.avail_out!==0&&f!==l.Z_STREAM_END&&(B.avail_in!==0||b!==l.Z_FINISH&&b!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=o.utf8border(B.output,B.next_out),C=B.next_out-_,S=o.buf2string(B.output,_),B.next_out=C,B.avail_out=O-C,C&&s.arraySet(B.output,B.output,_,C,0),this.onData(S)):this.onData(s.shrinkBuf(B.output,B.next_out)))),B.avail_in===0&&B.avail_out===0&&(H=!0)}while((0<B.avail_in||B.avail_out===0)&&f!==l.Z_STREAM_END);return f===l.Z_STREAM_END&&(b=l.Z_FINISH),b===l.Z_FINISH?(f=r.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l.Z_OK):b!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(B.avail_out=0))},c.prototype.onData=function(h){this.chunks.push(h)},c.prototype.onEnd=function(h){h===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=h,this.msg=this.strm.msg},n.Inflate=c,n.inflate=m,n.inflateRaw=function(h,p){return(p=p||{}).raw=!0,m(h,p)},n.ungzip=m},{"./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,n){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";n.assign=function(l){for(var g=Array.prototype.slice.call(arguments,1);g.length;){var w=g.shift();if(w){if(typeof w!="object")throw new TypeError(w+"must be non-object");for(var u in w)w.hasOwnProperty(u)&&(l[u]=w[u])}}return l},n.shrinkBuf=function(l,g){return l.length===g?l:l.subarray?l.subarray(0,g):(l.length=g,l)};var s={arraySet:function(l,g,w,u,y){if(g.subarray&&l.subarray)l.set(g.subarray(w,w+u),y);else for(var c=0;c<u;c++)l[y+c]=g[w+c]},flattenChunks:function(l){var g,w,u,y,c,m;for(g=u=0,w=l.length;g<w;g++)u+=l[g].length;for(m=new Uint8Array(u),g=y=0,w=l.length;g<w;g++)c=l[g],m.set(c,y),y+=c.length;return m}},o={arraySet:function(l,g,w,u,y){for(var c=0;c<u;c++)l[y+c]=g[w+c]},flattenChunks:function(l){return[].concat.apply([],l)}};n.setTyped=function(l){l?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,s)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(r)},{}],42:[function(e,i,n){var r=e("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new r.Buf8(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;function w(u,y){if(y<65537&&(u.subarray&&o||!u.subarray&&s))return String.fromCharCode.apply(null,r.shrinkBuf(u,y));for(var c="",m=0;m<y;m++)c+=String.fromCharCode(u[m]);return c}l[254]=l[254]=1,n.string2buf=function(u){var y,c,m,h,p,f=u.length,b=0;for(h=0;h<f;h++)(64512&(c=u.charCodeAt(h)))==55296&&h+1<f&&(64512&(m=u.charCodeAt(h+1)))==56320&&(c=65536+(c-55296<<10)+(m-56320),h++),b+=c<128?1:c<2048?2:c<65536?3:4;for(y=new r.Buf8(b),h=p=0;p<b;h++)(64512&(c=u.charCodeAt(h)))==55296&&h+1<f&&(64512&(m=u.charCodeAt(h+1)))==56320&&(c=65536+(c-55296<<10)+(m-56320),h++),c<128?y[p++]=c:(c<2048?y[p++]=192|c>>>6:(c<65536?y[p++]=224|c>>>12:(y[p++]=240|c>>>18,y[p++]=128|c>>>12&63),y[p++]=128|c>>>6&63),y[p++]=128|63&c);return y},n.buf2binstring=function(u){return w(u,u.length)},n.binstring2buf=function(u){for(var y=new r.Buf8(u.length),c=0,m=y.length;c<m;c++)y[c]=u.charCodeAt(c);return y},n.buf2string=function(u,y){var c,m,h,p,f=y||u.length,b=new Array(2*f);for(c=m=0;c<f;)if((h=u[c++])<128)b[m++]=h;else if(4<(p=l[h]))b[m++]=65533,c+=p-1;else{for(h&=p===2?31:p===3?15:7;1<p&&c<f;)h=h<<6|63&u[c++],p--;1<p?b[m++]=65533:h<65536?b[m++]=h:(h-=65536,b[m++]=55296|h>>10&1023,b[m++]=56320|1023&h)}return w(b,m)},n.utf8border=function(u,y){var c;for((y=y||u.length)>u.length&&(y=u.length),c=y-1;0<=c&&(192&u[c])==128;)c--;return c<0||c===0?y:c+l[u[c]]>y?c:y}},{"./common":41}],43:[function(e,i,n){i.exports=function(r,s,o,l){for(var g=65535&r|0,w=r>>>16&65535|0,u=0;o!==0;){for(o-=u=2e3<o?2e3:o;w=w+(g=g+s[l++]|0)|0,--u;);g%=65521,w%=65521}return g|w<<16|0}},{}],44:[function(e,i,n){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,n){var r=(function(){for(var s,o=[],l=0;l<256;l++){s=l;for(var g=0;g<8;g++)s=1&s?3988292384^s>>>1:s>>>1;o[l]=s}return o})();i.exports=function(s,o,l,g){var w=r,u=g+l;s^=-1;for(var y=g;y<u;y++)s=s>>>8^w[255&(s^o[y])];return-1^s}},{}],46:[function(e,i,n){var r,s=e("../utils/common"),o=e("./trees"),l=e("./adler32"),g=e("./crc32"),w=e("./messages"),u=0,y=4,c=0,m=-2,h=-1,p=4,f=2,b=8,_=9,C=286,S=30,z=19,B=2*C+1,O=15,A=3,H=258,X=H+A+1,k=42,D=113,d=1,R=2,J=3,W=4;function tt(a,L){return a.msg=w[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 M(a){var L=a.state,T=L.pending;T>a.avail_out&&(T=a.avail_out),T!==0&&(s.arraySet(a.output,L.pending_buf,L.pending_out,T,a.next_out),a.next_out+=T,L.pending_out+=T,a.total_out+=T,a.avail_out-=T,L.pending-=T,L.pending===0&&(L.pending_out=0))}function I(a,L){o._tr_flush_block(a,0<=a.block_start?a.block_start:-1,a.strstart-a.block_start,L),a.block_start=a.strstart,M(a.strm)}function V(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 K(a,L){var T,x,v=a.max_chain_length,N=a.strstart,P=a.prev_length,F=a.nice_match,E=a.strstart>a.w_size-X?a.strstart-(a.w_size-X):0,j=a.window,G=a.w_mask,Z=a.prev,$=a.strstart+H,rt=j[N+P-1],it=j[N+P];a.prev_length>=a.good_match&&(v>>=2),F>a.lookahead&&(F=a.lookahead);do if(j[(T=L)+P]===it&&j[T+P-1]===rt&&j[T]===j[N]&&j[++T]===j[N+1]){N+=2,T++;do;while(j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&j[++N]===j[++T]&&N<$);if(x=H-($-N),N=$-H,P<x){if(a.match_start=L,F<=(P=x))break;rt=j[N+P-1],it=j[N+P]}}while((L=Z[L&G])>E&&--v!=0);return P<=a.lookahead?P:a.lookahead}function st(a){var L,T,x,v,N,P,F,E,j,G,Z=a.w_size;do{if(v=a.window_size-a.lookahead-a.strstart,a.strstart>=Z+(Z-X)){for(s.arraySet(a.window,a.window,Z,Z,0),a.match_start-=Z,a.strstart-=Z,a.block_start-=Z,L=T=a.hash_size;x=a.head[--L],a.head[L]=Z<=x?x-Z:0,--T;);for(L=T=Z;x=a.prev[--L],a.prev[L]=Z<=x?x-Z:0,--T;);v+=Z}if(a.strm.avail_in===0)break;if(P=a.strm,F=a.window,E=a.strstart+a.lookahead,j=v,G=void 0,G=P.avail_in,j<G&&(G=j),T=G===0?0:(P.avail_in-=G,s.arraySet(F,P.input,P.next_in,G,E),P.state.wrap===1?P.adler=l(P.adler,F,G,E):P.state.wrap===2&&(P.adler=g(P.adler,F,G,E)),P.next_in+=G,P.total_in+=G,G),a.lookahead+=T,a.lookahead+a.insert>=A)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+A-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<A)););}while(a.lookahead<X&&a.strm.avail_in!==0)}function lt(a,L){for(var T,x;;){if(a.lookahead<X){if(st(a),a.lookahead<X&&L===u)return d;if(a.lookahead===0)break}if(T=0,a.lookahead>=A&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),T!==0&&a.strstart-T<=a.w_size-X&&(a.match_length=K(a,T)),a.match_length>=A)if(x=o._tr_tally(a,a.strstart-a.match_start,a.match_length-A),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=A){for(a.match_length--;a.strstart++,a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=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 x=o._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++;if(x&&(I(a,!1),a.strm.avail_out===0))return d}return a.insert=a.strstart<A-1?a.strstart:A-1,L===y?(I(a,!0),a.strm.avail_out===0?J:W):a.last_lit&&(I(a,!1),a.strm.avail_out===0)?d:R}function et(a,L){for(var T,x,v;;){if(a.lookahead<X){if(st(a),a.lookahead<X&&L===u)return d;if(a.lookahead===0)break}if(T=0,a.lookahead>=A&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=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=A-1,T!==0&&a.prev_length<a.max_lazy_match&&a.strstart-T<=a.w_size-X&&(a.match_length=K(a,T),a.match_length<=5&&(a.strategy===1||a.match_length===A&&4096<a.strstart-a.match_start)&&(a.match_length=A-1)),a.prev_length>=A&&a.match_length<=a.prev_length){for(v=a.strstart+a.lookahead-A,x=o._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-A),a.lookahead-=a.prev_length-1,a.prev_length-=2;++a.strstart<=v&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+A-1])&a.hash_mask,T=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=A-1,a.strstart++,x&&(I(a,!1),a.strm.avail_out===0))return d}else if(a.match_available){if((x=o._tr_tally(a,0,a.window[a.strstart-1]))&&I(a,!1),a.strstart++,a.lookahead--,a.strm.avail_out===0)return d}else a.match_available=1,a.strstart++,a.lookahead--}return a.match_available&&(x=o._tr_tally(a,0,a.window[a.strstart-1]),a.match_available=0),a.insert=a.strstart<A-1?a.strstart:A-1,L===y?(I(a,!0),a.strm.avail_out===0?J:W):a.last_lit&&(I(a,!1),a.strm.avail_out===0)?d:R}function nt(a,L,T,x,v){this.good_length=a,this.max_lazy=L,this.nice_length=T,this.max_chain=x,this.func=v}function dt(){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=b,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 s.Buf16(2*B),this.dyn_dtree=new s.Buf16(2*(2*S+1)),this.bl_tree=new s.Buf16(2*(2*z+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 s.Buf16(O+1),this.heap=new s.Buf16(2*C+1),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.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 ot(a){var L;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=f,(L=a.state).pending=0,L.pending_out=0,L.wrap<0&&(L.wrap=-L.wrap),L.status=L.wrap?k:D,a.adler=L.wrap===2?0:1,L.last_flush=u,o._tr_init(L),c):tt(a,m)}function pt(a){var L=ot(a);return L===c&&(function(T){T.window_size=2*T.w_size,q(T.head),T.max_lazy_match=r[T.level].max_lazy,T.good_match=r[T.level].good_length,T.nice_match=r[T.level].nice_length,T.max_chain_length=r[T.level].max_chain,T.strstart=0,T.block_start=0,T.lookahead=0,T.insert=0,T.match_length=T.prev_length=A-1,T.match_available=0,T.ins_h=0})(a.state),L}function ut(a,L,T,x,v,N){if(!a)return m;var P=1;if(L===h&&(L=6),x<0?(P=0,x=-x):15<x&&(P=2,x-=16),v<1||_<v||T!==b||x<8||15<x||L<0||9<L||N<0||p<N)return tt(a,m);x===8&&(x=9);var F=new dt;return(a.state=F).strm=a,F.wrap=P,F.gzhead=null,F.w_bits=x,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=v+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+A-1)/A),F.window=new s.Buf8(2*F.w_size),F.head=new s.Buf16(F.hash_size),F.prev=new s.Buf16(F.w_size),F.lit_bufsize=1<<v+6,F.pending_buf_size=4*F.lit_bufsize,F.pending_buf=new s.Buf8(F.pending_buf_size),F.d_buf=1*F.lit_bufsize,F.l_buf=3*F.lit_bufsize,F.level=L,F.strategy=N,F.method=T,pt(a)}r=[new nt(0,0,0,0,function(a,L){var T=65535;for(T>a.pending_buf_size-5&&(T=a.pending_buf_size-5);;){if(a.lookahead<=1){if(st(a),a.lookahead===0&&L===u)return d;if(a.lookahead===0)break}a.strstart+=a.lookahead,a.lookahead=0;var x=a.block_start+T;if((a.strstart===0||a.strstart>=x)&&(a.lookahead=a.strstart-x,a.strstart=x,I(a,!1),a.strm.avail_out===0)||a.strstart-a.block_start>=a.w_size-X&&(I(a,!1),a.strm.avail_out===0))return d}return a.insert=0,L===y?(I(a,!0),a.strm.avail_out===0?J:W):(a.strstart>a.block_start&&(I(a,!1),a.strm.avail_out),d)}),new nt(4,4,8,4,lt),new nt(4,5,16,8,lt),new nt(4,6,32,32,lt),new nt(4,4,16,16,et),new nt(8,16,32,32,et),new nt(8,16,128,128,et),new nt(8,32,128,256,et),new nt(32,128,258,1024,et),new nt(32,258,258,4096,et)],n.deflateInit=function(a,L){return ut(a,L,b,15,8,0)},n.deflateInit2=ut,n.deflateReset=pt,n.deflateResetKeep=ot,n.deflateSetHeader=function(a,L){return a&&a.state?a.state.wrap!==2?m:(a.state.gzhead=L,c):m},n.deflate=function(a,L){var T,x,v,N;if(!a||!a.state||5<L||L<0)return a?tt(a,m):m;if(x=a.state,!a.output||!a.input&&a.avail_in!==0||x.status===666&&L!==y)return tt(a,a.avail_out===0?-5:m);if(x.strm=a,T=x.last_flush,x.last_flush=L,x.status===k)if(x.wrap===2)a.adler=0,V(x,31),V(x,139),V(x,8),x.gzhead?(V(x,(x.gzhead.text?1:0)+(x.gzhead.hcrc?2:0)+(x.gzhead.extra?4:0)+(x.gzhead.name?8:0)+(x.gzhead.comment?16:0)),V(x,255&x.gzhead.time),V(x,x.gzhead.time>>8&255),V(x,x.gzhead.time>>16&255),V(x,x.gzhead.time>>24&255),V(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),V(x,255&x.gzhead.os),x.gzhead.extra&&x.gzhead.extra.length&&(V(x,255&x.gzhead.extra.length),V(x,x.gzhead.extra.length>>8&255)),x.gzhead.hcrc&&(a.adler=g(a.adler,x.pending_buf,x.pending,0)),x.gzindex=0,x.status=69):(V(x,0),V(x,0),V(x,0),V(x,0),V(x,0),V(x,x.level===9?2:2<=x.strategy||x.level<2?4:0),V(x,3),x.status=D);else{var P=b+(x.w_bits-8<<4)<<8;P|=(2<=x.strategy||x.level<2?0:x.level<6?1:x.level===6?2:3)<<6,x.strstart!==0&&(P|=32),P+=31-P%31,x.status=D,Y(x,P),x.strstart!==0&&(Y(x,a.adler>>>16),Y(x,65535&a.adler)),a.adler=1}if(x.status===69)if(x.gzhead.extra){for(v=x.pending;x.gzindex<(65535&x.gzhead.extra.length)&&(x.pending!==x.pending_buf_size||(x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),M(a),v=x.pending,x.pending!==x.pending_buf_size));)V(x,255&x.gzhead.extra[x.gzindex]),x.gzindex++;x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),x.gzindex===x.gzhead.extra.length&&(x.gzindex=0,x.status=73)}else x.status=73;if(x.status===73)if(x.gzhead.name){v=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),M(a),v=x.pending,x.pending===x.pending_buf_size)){N=1;break}N=x.gzindex<x.gzhead.name.length?255&x.gzhead.name.charCodeAt(x.gzindex++):0,V(x,N)}while(N!==0);x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),N===0&&(x.gzindex=0,x.status=91)}else x.status=91;if(x.status===91)if(x.gzhead.comment){v=x.pending;do{if(x.pending===x.pending_buf_size&&(x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),M(a),v=x.pending,x.pending===x.pending_buf_size)){N=1;break}N=x.gzindex<x.gzhead.comment.length?255&x.gzhead.comment.charCodeAt(x.gzindex++):0,V(x,N)}while(N!==0);x.gzhead.hcrc&&x.pending>v&&(a.adler=g(a.adler,x.pending_buf,x.pending-v,v)),N===0&&(x.status=103)}else x.status=103;if(x.status===103&&(x.gzhead.hcrc?(x.pending+2>x.pending_buf_size&&M(a),x.pending+2<=x.pending_buf_size&&(V(x,255&a.adler),V(x,a.adler>>8&255),a.adler=0,x.status=D)):x.status=D),x.pending!==0){if(M(a),a.avail_out===0)return x.last_flush=-1,c}else if(a.avail_in===0&&U(L)<=U(T)&&L!==y)return tt(a,-5);if(x.status===666&&a.avail_in!==0)return tt(a,-5);if(a.avail_in!==0||x.lookahead!==0||L!==u&&x.status!==666){var F=x.strategy===2?(function(E,j){for(var G;;){if(E.lookahead===0&&(st(E),E.lookahead===0)){if(j===u)return d;break}if(E.match_length=0,G=o._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++,G&&(I(E,!1),E.strm.avail_out===0))return d}return E.insert=0,j===y?(I(E,!0),E.strm.avail_out===0?J:W):E.last_lit&&(I(E,!1),E.strm.avail_out===0)?d:R})(x,L):x.strategy===3?(function(E,j){for(var G,Z,$,rt,it=E.window;;){if(E.lookahead<=H){if(st(E),E.lookahead<=H&&j===u)return d;if(E.lookahead===0)break}if(E.match_length=0,E.lookahead>=A&&0<E.strstart&&(Z=it[$=E.strstart-1])===it[++$]&&Z===it[++$]&&Z===it[++$]){rt=E.strstart+H;do;while(Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&Z===it[++$]&&$<rt);E.match_length=H-(rt-$),E.match_length>E.lookahead&&(E.match_length=E.lookahead)}if(E.match_length>=A?(G=o._tr_tally(E,1,E.match_length-A),E.lookahead-=E.match_length,E.strstart+=E.match_length,E.match_length=0):(G=o._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++),G&&(I(E,!1),E.strm.avail_out===0))return d}return E.insert=0,j===y?(I(E,!0),E.strm.avail_out===0?J:W):E.last_lit&&(I(E,!1),E.strm.avail_out===0)?d:R})(x,L):r[x.level].func(x,L);if(F!==J&&F!==W||(x.status=666),F===d||F===J)return a.avail_out===0&&(x.last_flush=-1),c;if(F===R&&(L===1?o._tr_align(x):L!==5&&(o._tr_stored_block(x,0,0,!1),L===3&&(q(x.head),x.lookahead===0&&(x.strstart=0,x.block_start=0,x.insert=0))),M(a),a.avail_out===0))return x.last_flush=-1,c}return L!==y?c:x.wrap<=0?1:(x.wrap===2?(V(x,255&a.adler),V(x,a.adler>>8&255),V(x,a.adler>>16&255),V(x,a.adler>>24&255),V(x,255&a.total_in),V(x,a.total_in>>8&255),V(x,a.total_in>>16&255),V(x,a.total_in>>24&255)):(Y(x,a.adler>>>16),Y(x,65535&a.adler)),M(a),0<x.wrap&&(x.wrap=-x.wrap),x.pending!==0?c:1)},n.deflateEnd=function(a){var L;return a&&a.state?(L=a.state.status)!==k&&L!==69&&L!==73&&L!==91&&L!==103&&L!==D&&L!==666?tt(a,m):(a.state=null,L===D?tt(a,-3):c):m},n.deflateSetDictionary=function(a,L){var T,x,v,N,P,F,E,j,G=L.length;if(!a||!a.state||(N=(T=a.state).wrap)===2||N===1&&T.status!==k||T.lookahead)return m;for(N===1&&(a.adler=l(a.adler,L,G,0)),T.wrap=0,G>=T.w_size&&(N===0&&(q(T.head),T.strstart=0,T.block_start=0,T.insert=0),j=new s.Buf8(T.w_size),s.arraySet(j,L,G-T.w_size,T.w_size,0),L=j,G=T.w_size),P=a.avail_in,F=a.next_in,E=a.input,a.avail_in=G,a.next_in=0,a.input=L,st(T);T.lookahead>=A;){for(x=T.strstart,v=T.lookahead-(A-1);T.ins_h=(T.ins_h<<T.hash_shift^T.window[x+A-1])&T.hash_mask,T.prev[x&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=x,x++,--v;);T.strstart=x,T.lookahead=A-1,st(T)}return T.strstart+=T.lookahead,T.block_start=T.strstart,T.insert=T.lookahead,T.lookahead=0,T.match_length=T.prev_length=A-1,T.match_available=0,a.next_in=F,a.input=E,a.avail_in=P,T.wrap=N,c},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,i,n){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,n){i.exports=function(r,s){var o,l,g,w,u,y,c,m,h,p,f,b,_,C,S,z,B,O,A,H,X,k,D,d,R;o=r.state,l=r.next_in,d=r.input,g=l+(r.avail_in-5),w=r.next_out,R=r.output,u=w-(s-r.avail_out),y=w+(r.avail_out-257),c=o.dmax,m=o.wsize,h=o.whave,p=o.wnext,f=o.window,b=o.hold,_=o.bits,C=o.lencode,S=o.distcode,z=(1<<o.lenbits)-1,B=(1<<o.distbits)-1;t:do{_<15&&(b+=d[l++]<<_,_+=8,b+=d[l++]<<_,_+=8),O=C[b&z];e:for(;;){if(b>>>=A=O>>>24,_-=A,(A=O>>>16&255)===0)R[w++]=65535&O;else{if(!(16&A)){if((64&A)==0){O=C[(65535&O)+(b&(1<<A)-1)];continue e}if(32&A){o.mode=12;break t}r.msg="invalid literal/length code",o.mode=30;break t}H=65535&O,(A&=15)&&(_<A&&(b+=d[l++]<<_,_+=8),H+=b&(1<<A)-1,b>>>=A,_-=A),_<15&&(b+=d[l++]<<_,_+=8,b+=d[l++]<<_,_+=8),O=S[b&B];i:for(;;){if(b>>>=A=O>>>24,_-=A,!(16&(A=O>>>16&255))){if((64&A)==0){O=S[(65535&O)+(b&(1<<A)-1)];continue i}r.msg="invalid distance code",o.mode=30;break t}if(X=65535&O,_<(A&=15)&&(b+=d[l++]<<_,(_+=8)<A&&(b+=d[l++]<<_,_+=8)),c<(X+=b&(1<<A)-1)){r.msg="invalid distance too far back",o.mode=30;break t}if(b>>>=A,_-=A,(A=w-u)<X){if(h<(A=X-A)&&o.sane){r.msg="invalid distance too far back",o.mode=30;break t}if(D=f,(k=0)===p){if(k+=m-A,A<H){for(H-=A;R[w++]=f[k++],--A;);k=w-X,D=R}}else if(p<A){if(k+=m+p-A,(A-=p)<H){for(H-=A;R[w++]=f[k++],--A;);if(k=0,p<H){for(H-=A=p;R[w++]=f[k++],--A;);k=w-X,D=R}}}else if(k+=p-A,A<H){for(H-=A;R[w++]=f[k++],--A;);k=w-X,D=R}for(;2<H;)R[w++]=D[k++],R[w++]=D[k++],R[w++]=D[k++],H-=3;H&&(R[w++]=D[k++],1<H&&(R[w++]=D[k++]))}else{for(k=w-X;R[w++]=R[k++],R[w++]=R[k++],R[w++]=R[k++],2<(H-=3););H&&(R[w++]=R[k++],1<H&&(R[w++]=R[k++]))}break}}break}}while(l<g&&w<y);l-=H=_>>3,b&=(1<<(_-=H<<3))-1,r.next_in=l,r.next_out=w,r.avail_in=l<g?g-l+5:5-(l-g),r.avail_out=w<y?y-w+257:257-(w-y),o.hold=b,o.bits=_}},{}],49:[function(e,i,n){var r=e("../utils/common"),s=e("./adler32"),o=e("./crc32"),l=e("./inffast"),g=e("./inftrees"),w=1,u=2,y=0,c=-2,m=1,h=852,p=592;function f(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function b(){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 r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(k){var D;return k&&k.state?(D=k.state,k.total_in=k.total_out=D.total=0,k.msg="",D.wrap&&(k.adler=1&D.wrap),D.mode=m,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new r.Buf32(h),D.distcode=D.distdyn=new r.Buf32(p),D.sane=1,D.back=-1,y):c}function C(k){var D;return k&&k.state?((D=k.state).wsize=0,D.whave=0,D.wnext=0,_(k)):c}function S(k,D){var d,R;return k&&k.state?(R=k.state,D<0?(d=0,D=-D):(d=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?c:(R.window!==null&&R.wbits!==D&&(R.window=null),R.wrap=d,R.wbits=D,C(k))):c}function z(k,D){var d,R;return k?(R=new b,(k.state=R).window=null,(d=S(k,D))!==y&&(k.state=null),d):c}var B,O,A=!0;function H(k){if(A){var D;for(B=new r.Buf32(512),O=new r.Buf32(32),D=0;D<144;)k.lens[D++]=8;for(;D<256;)k.lens[D++]=9;for(;D<280;)k.lens[D++]=7;for(;D<288;)k.lens[D++]=8;for(g(w,k.lens,0,288,B,0,k.work,{bits:9}),D=0;D<32;)k.lens[D++]=5;g(u,k.lens,0,32,O,0,k.work,{bits:5}),A=!1}k.lencode=B,k.lenbits=9,k.distcode=O,k.distbits=5}function X(k,D,d,R){var J,W=k.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new r.Buf8(W.wsize)),R>=W.wsize?(r.arraySet(W.window,D,d-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(R<(J=W.wsize-W.wnext)&&(J=R),r.arraySet(W.window,D,d-R,J,W.wnext),(R-=J)?(r.arraySet(W.window,D,d-R,R,0),W.wnext=R,W.whave=W.wsize):(W.wnext+=J,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=J))),0}n.inflateReset=C,n.inflateReset2=S,n.inflateResetKeep=_,n.inflateInit=function(k){return z(k,15)},n.inflateInit2=z,n.inflate=function(k,D){var d,R,J,W,tt,U,q,M,I,V,Y,K,st,lt,et,nt,dt,ot,pt,ut,a,L,T,x,v=0,N=new r.Buf8(4),P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return c;(d=k.state).mode===12&&(d.mode=13),tt=k.next_out,J=k.output,q=k.avail_out,W=k.next_in,R=k.input,U=k.avail_in,M=d.hold,I=d.bits,V=U,Y=q,L=y;t:for(;;)switch(d.mode){case m:if(d.wrap===0){d.mode=13;break}for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(2&d.wrap&&M===35615){N[d.check=0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0),I=M=0,d.mode=2;break}if(d.flags=0,d.head&&(d.head.done=!1),!(1&d.wrap)||(((255&M)<<8)+(M>>8))%31){k.msg="incorrect header check",d.mode=30;break}if((15&M)!=8){k.msg="unknown compression method",d.mode=30;break}if(I-=4,a=8+(15&(M>>>=4)),d.wbits===0)d.wbits=a;else if(a>d.wbits){k.msg="invalid window size",d.mode=30;break}d.dmax=1<<a,k.adler=d.check=1,d.mode=512&M?10:12,I=M=0;break;case 2:for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(d.flags=M,(255&d.flags)!=8){k.msg="unknown compression method",d.mode=30;break}if(57344&d.flags){k.msg="unknown header flags set",d.mode=30;break}d.head&&(d.head.text=M>>8&1),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0)),I=M=0,d.mode=3;case 3:for(;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.head&&(d.head.time=M),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,N[2]=M>>>16&255,N[3]=M>>>24&255,d.check=o(d.check,N,4,0)),I=M=0,d.mode=4;case 4:for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.head&&(d.head.xflags=255&M,d.head.os=M>>8),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0)),I=M=0,d.mode=5;case 5:if(1024&d.flags){for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.length=M,d.head&&(d.head.extra_len=M),512&d.flags&&(N[0]=255&M,N[1]=M>>>8&255,d.check=o(d.check,N,2,0)),I=M=0}else d.head&&(d.head.extra=null);d.mode=6;case 6:if(1024&d.flags&&(U<(K=d.length)&&(K=U),K&&(d.head&&(a=d.head.extra_len-d.length,d.head.extra||(d.head.extra=new Array(d.head.extra_len)),r.arraySet(d.head.extra,R,W,K,a)),512&d.flags&&(d.check=o(d.check,R,K,W)),U-=K,W+=K,d.length-=K),d.length))break t;d.length=0,d.mode=7;case 7:if(2048&d.flags){if(U===0)break t;for(K=0;a=R[W+K++],d.head&&a&&d.length<65536&&(d.head.name+=String.fromCharCode(a)),a&&K<U;);if(512&d.flags&&(d.check=o(d.check,R,K,W)),U-=K,W+=K,a)break t}else d.head&&(d.head.name=null);d.length=0,d.mode=8;case 8:if(4096&d.flags){if(U===0)break t;for(K=0;a=R[W+K++],d.head&&a&&d.length<65536&&(d.head.comment+=String.fromCharCode(a)),a&&K<U;);if(512&d.flags&&(d.check=o(d.check,R,K,W)),U-=K,W+=K,a)break t}else d.head&&(d.head.comment=null);d.mode=9;case 9:if(512&d.flags){for(;I<16;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(M!==(65535&d.check)){k.msg="header crc mismatch",d.mode=30;break}I=M=0}d.head&&(d.head.hcrc=d.flags>>9&1,d.head.done=!0),k.adler=d.check=0,d.mode=12;break;case 10:for(;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}k.adler=d.check=f(M),I=M=0,d.mode=11;case 11:if(d.havedict===0)return k.next_out=tt,k.avail_out=q,k.next_in=W,k.avail_in=U,d.hold=M,d.bits=I,2;k.adler=d.check=1,d.mode=12;case 12:if(D===5||D===6)break t;case 13:if(d.last){M>>>=7&I,I-=7&I,d.mode=27;break}for(;I<3;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}switch(d.last=1&M,I-=1,3&(M>>>=1)){case 0:d.mode=14;break;case 1:if(H(d),d.mode=20,D!==6)break;M>>>=2,I-=2;break t;case 2:d.mode=17;break;case 3:k.msg="invalid block type",d.mode=30}M>>>=2,I-=2;break;case 14:for(M>>>=7&I,I-=7&I;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if((65535&M)!=(M>>>16^65535)){k.msg="invalid stored block lengths",d.mode=30;break}if(d.length=65535&M,I=M=0,d.mode=15,D===6)break t;case 15:d.mode=16;case 16:if(K=d.length){if(U<K&&(K=U),q<K&&(K=q),K===0)break t;r.arraySet(J,R,W,K,tt),U-=K,W+=K,q-=K,tt+=K,d.length-=K;break}d.mode=12;break;case 17:for(;I<14;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(d.nlen=257+(31&M),M>>>=5,I-=5,d.ndist=1+(31&M),M>>>=5,I-=5,d.ncode=4+(15&M),M>>>=4,I-=4,286<d.nlen||30<d.ndist){k.msg="too many length or distance symbols",d.mode=30;break}d.have=0,d.mode=18;case 18:for(;d.have<d.ncode;){for(;I<3;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.lens[P[d.have++]]=7&M,M>>>=3,I-=3}for(;d.have<19;)d.lens[P[d.have++]]=0;if(d.lencode=d.lendyn,d.lenbits=7,T={bits:d.lenbits},L=g(0,d.lens,0,19,d.lencode,0,d.work,T),d.lenbits=T.bits,L){k.msg="invalid code lengths set",d.mode=30;break}d.have=0,d.mode=19;case 19:for(;d.have<d.nlen+d.ndist;){for(;nt=(v=d.lencode[M&(1<<d.lenbits)-1])>>>16&255,dt=65535&v,!((et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(dt<16)M>>>=et,I-=et,d.lens[d.have++]=dt;else{if(dt===16){for(x=et+2;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(M>>>=et,I-=et,d.have===0){k.msg="invalid bit length repeat",d.mode=30;break}a=d.lens[d.have-1],K=3+(3&M),M>>>=2,I-=2}else if(dt===17){for(x=et+3;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}I-=et,a=0,K=3+(7&(M>>>=et)),M>>>=3,I-=3}else{for(x=et+7;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}I-=et,a=0,K=11+(127&(M>>>=et)),M>>>=7,I-=7}if(d.have+K>d.nlen+d.ndist){k.msg="invalid bit length repeat",d.mode=30;break}for(;K--;)d.lens[d.have++]=a}}if(d.mode===30)break;if(d.lens[256]===0){k.msg="invalid code -- missing end-of-block",d.mode=30;break}if(d.lenbits=9,T={bits:d.lenbits},L=g(w,d.lens,0,d.nlen,d.lencode,0,d.work,T),d.lenbits=T.bits,L){k.msg="invalid literal/lengths set",d.mode=30;break}if(d.distbits=6,d.distcode=d.distdyn,T={bits:d.distbits},L=g(u,d.lens,d.nlen,d.ndist,d.distcode,0,d.work,T),d.distbits=T.bits,L){k.msg="invalid distances set",d.mode=30;break}if(d.mode=20,D===6)break t;case 20:d.mode=21;case 21:if(6<=U&&258<=q){k.next_out=tt,k.avail_out=q,k.next_in=W,k.avail_in=U,d.hold=M,d.bits=I,l(k,Y),tt=k.next_out,J=k.output,q=k.avail_out,W=k.next_in,R=k.input,U=k.avail_in,M=d.hold,I=d.bits,d.mode===12&&(d.back=-1);break}for(d.back=0;nt=(v=d.lencode[M&(1<<d.lenbits)-1])>>>16&255,dt=65535&v,!((et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(nt&&(240&nt)==0){for(ot=et,pt=nt,ut=dt;nt=(v=d.lencode[ut+((M&(1<<ot+pt)-1)>>ot)])>>>16&255,dt=65535&v,!(ot+(et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}M>>>=ot,I-=ot,d.back+=ot}if(M>>>=et,I-=et,d.back+=et,d.length=dt,nt===0){d.mode=26;break}if(32&nt){d.back=-1,d.mode=12;break}if(64&nt){k.msg="invalid literal/length code",d.mode=30;break}d.extra=15&nt,d.mode=22;case 22:if(d.extra){for(x=d.extra;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.length+=M&(1<<d.extra)-1,M>>>=d.extra,I-=d.extra,d.back+=d.extra}d.was=d.length,d.mode=23;case 23:for(;nt=(v=d.distcode[M&(1<<d.distbits)-1])>>>16&255,dt=65535&v,!((et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if((240&nt)==0){for(ot=et,pt=nt,ut=dt;nt=(v=d.distcode[ut+((M&(1<<ot+pt)-1)>>ot)])>>>16&255,dt=65535&v,!(ot+(et=v>>>24)<=I);){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}M>>>=ot,I-=ot,d.back+=ot}if(M>>>=et,I-=et,d.back+=et,64&nt){k.msg="invalid distance code",d.mode=30;break}d.offset=dt,d.extra=15&nt,d.mode=24;case 24:if(d.extra){for(x=d.extra;I<x;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}d.offset+=M&(1<<d.extra)-1,M>>>=d.extra,I-=d.extra,d.back+=d.extra}if(d.offset>d.dmax){k.msg="invalid distance too far back",d.mode=30;break}d.mode=25;case 25:if(q===0)break t;if(K=Y-q,d.offset>K){if((K=d.offset-K)>d.whave&&d.sane){k.msg="invalid distance too far back",d.mode=30;break}st=K>d.wnext?(K-=d.wnext,d.wsize-K):d.wnext-K,K>d.length&&(K=d.length),lt=d.window}else lt=J,st=tt-d.offset,K=d.length;for(q<K&&(K=q),q-=K,d.length-=K;J[tt++]=lt[st++],--K;);d.length===0&&(d.mode=21);break;case 26:if(q===0)break t;J[tt++]=d.length,q--,d.mode=21;break;case 27:if(d.wrap){for(;I<32;){if(U===0)break t;U--,M|=R[W++]<<I,I+=8}if(Y-=q,k.total_out+=Y,d.total+=Y,Y&&(k.adler=d.check=d.flags?o(d.check,J,Y,tt-Y):s(d.check,J,Y,tt-Y)),Y=q,(d.flags?M:f(M))!==d.check){k.msg="incorrect data check",d.mode=30;break}I=M=0}d.mode=28;case 28:if(d.wrap&&d.flags){for(;I<32;){if(U===0)break t;U--,M+=R[W++]<<I,I+=8}if(M!==(4294967295&d.total)){k.msg="incorrect length check",d.mode=30;break}I=M=0}d.mode=29;case 29:L=1;break t;case 30:L=-3;break t;case 31:return-4;default:return c}return k.next_out=tt,k.avail_out=q,k.next_in=W,k.avail_in=U,d.hold=M,d.bits=I,(d.wsize||Y!==k.avail_out&&d.mode<30&&(d.mode<27||D!==4))&&X(k,k.output,k.next_out,Y-k.avail_out)?(d.mode=31,-4):(V-=k.avail_in,Y-=k.avail_out,k.total_in+=V,k.total_out+=Y,d.total+=Y,d.wrap&&Y&&(k.adler=d.check=d.flags?o(d.check,J,Y,k.next_out-Y):s(d.check,J,Y,k.next_out-Y)),k.data_type=d.bits+(d.last?64:0)+(d.mode===12?128:0)+(d.mode===20||d.mode===15?256:0),(V==0&&Y===0||D===4)&&L===y&&(L=-5),L)},n.inflateEnd=function(k){if(!k||!k.state)return c;var D=k.state;return D.window&&(D.window=null),k.state=null,y},n.inflateGetHeader=function(k,D){var d;return k&&k.state?(2&(d=k.state).wrap)==0?c:((d.head=D).done=!1,y):c},n.inflateSetDictionary=function(k,D){var d,R=D.length;return k&&k.state?(d=k.state).wrap!==0&&d.mode!==11?c:d.mode===11&&s(1,D,R,0)!==d.check?-3:X(k,D,R,R)?(d.mode=31,-4):(d.havedict=1,y):c},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,i,n){var r=e("../utils/common"),s=[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],o=[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],l=[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(w,u,y,c,m,h,p,f){var b,_,C,S,z,B,O,A,H,X=f.bits,k=0,D=0,d=0,R=0,J=0,W=0,tt=0,U=0,q=0,M=0,I=null,V=0,Y=new r.Buf16(16),K=new r.Buf16(16),st=null,lt=0;for(k=0;k<=15;k++)Y[k]=0;for(D=0;D<c;D++)Y[u[y+D]]++;for(J=X,R=15;1<=R&&Y[R]===0;R--);if(R<J&&(J=R),R===0)return m[h++]=20971520,m[h++]=20971520,f.bits=1,0;for(d=1;d<R&&Y[d]===0;d++);for(J<d&&(J=d),k=U=1;k<=15;k++)if(U<<=1,(U-=Y[k])<0)return-1;if(0<U&&(w===0||R!==1))return-1;for(K[1]=0,k=1;k<15;k++)K[k+1]=K[k]+Y[k];for(D=0;D<c;D++)u[y+D]!==0&&(p[K[u[y+D]]++]=D);if(B=w===0?(I=st=p,19):w===1?(I=s,V-=257,st=o,lt-=257,256):(I=l,st=g,-1),k=d,z=h,tt=D=M=0,C=-1,S=(q=1<<(W=J))-1,w===1&&852<q||w===2&&592<q)return 1;for(;;){for(O=k-tt,H=p[D]<B?(A=0,p[D]):p[D]>B?(A=st[lt+p[D]],I[V+p[D]]):(A=96,0),b=1<<k-tt,d=_=1<<W;m[z+(M>>tt)+(_-=b)]=O<<24|A<<16|H|0,_!==0;);for(b=1<<k-1;M&b;)b>>=1;if(b!==0?(M&=b-1,M+=b):M=0,D++,--Y[k]==0){if(k===R)break;k=u[y+p[D]]}if(J<k&&(M&S)!==C){for(tt===0&&(tt=J),z+=d,U=1<<(W=k-tt);W+tt<R&&!((U-=Y[W+tt])<=0);)W++,U<<=1;if(q+=1<<W,w===1&&852<q||w===2&&592<q)return 1;m[C=M&S]=J<<24|W<<16|z-h|0}}return M!==0&&(m[z+M]=k-tt<<24|64<<16|0),f.bits=J,0}},{"../utils/common":41}],51:[function(e,i,n){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,n){var r=e("../utils/common"),s=0,o=1;function l(v){for(var N=v.length;0<=--N;)v[N]=0}var g=0,w=29,u=256,y=u+1+w,c=30,m=19,h=2*y+1,p=15,f=16,b=7,_=256,C=16,S=17,z=18,B=[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],O=[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],A=[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],X=new Array(2*(y+2));l(X);var k=new Array(2*c);l(k);var D=new Array(512);l(D);var d=new Array(256);l(d);var R=new Array(w);l(R);var J,W,tt,U=new Array(c);function q(v,N,P,F,E){this.static_tree=v,this.extra_bits=N,this.extra_base=P,this.elems=F,this.max_length=E,this.has_stree=v&&v.length}function M(v,N){this.dyn_tree=v,this.max_code=0,this.stat_desc=N}function I(v){return v<256?D[v]:D[256+(v>>>7)]}function V(v,N){v.pending_buf[v.pending++]=255&N,v.pending_buf[v.pending++]=N>>>8&255}function Y(v,N,P){v.bi_valid>f-P?(v.bi_buf|=N<<v.bi_valid&65535,V(v,v.bi_buf),v.bi_buf=N>>f-v.bi_valid,v.bi_valid+=P-f):(v.bi_buf|=N<<v.bi_valid&65535,v.bi_valid+=P)}function K(v,N,P){Y(v,P[2*N],P[2*N+1])}function st(v,N){for(var P=0;P|=1&v,v>>>=1,P<<=1,0<--N;);return P>>>1}function lt(v,N,P){var F,E,j=new Array(p+1),G=0;for(F=1;F<=p;F++)j[F]=G=G+P[F-1]<<1;for(E=0;E<=N;E++){var Z=v[2*E+1];Z!==0&&(v[2*E]=st(j[Z]++,Z))}}function et(v){var N;for(N=0;N<y;N++)v.dyn_ltree[2*N]=0;for(N=0;N<c;N++)v.dyn_dtree[2*N]=0;for(N=0;N<m;N++)v.bl_tree[2*N]=0;v.dyn_ltree[2*_]=1,v.opt_len=v.static_len=0,v.last_lit=v.matches=0}function nt(v){8<v.bi_valid?V(v,v.bi_buf):0<v.bi_valid&&(v.pending_buf[v.pending++]=v.bi_buf),v.bi_buf=0,v.bi_valid=0}function dt(v,N,P,F){var E=2*N,j=2*P;return v[E]<v[j]||v[E]===v[j]&&F[N]<=F[P]}function ot(v,N,P){for(var F=v.heap[P],E=P<<1;E<=v.heap_len&&(E<v.heap_len&&dt(N,v.heap[E+1],v.heap[E],v.depth)&&E++,!dt(N,F,v.heap[E],v.depth));)v.heap[P]=v.heap[E],P=E,E<<=1;v.heap[P]=F}function pt(v,N,P){var F,E,j,G,Z=0;if(v.last_lit!==0)for(;F=v.pending_buf[v.d_buf+2*Z]<<8|v.pending_buf[v.d_buf+2*Z+1],E=v.pending_buf[v.l_buf+Z],Z++,F===0?K(v,E,N):(K(v,(j=d[E])+u+1,N),(G=B[j])!==0&&Y(v,E-=R[j],G),K(v,j=I(--F),P),(G=O[j])!==0&&Y(v,F-=U[j],G)),Z<v.last_lit;);K(v,_,N)}function ut(v,N){var P,F,E,j=N.dyn_tree,G=N.stat_desc.static_tree,Z=N.stat_desc.has_stree,$=N.stat_desc.elems,rt=-1;for(v.heap_len=0,v.heap_max=h,P=0;P<$;P++)j[2*P]!==0?(v.heap[++v.heap_len]=rt=P,v.depth[P]=0):j[2*P+1]=0;for(;v.heap_len<2;)j[2*(E=v.heap[++v.heap_len]=rt<2?++rt:0)]=1,v.depth[E]=0,v.opt_len--,Z&&(v.static_len-=G[2*E+1]);for(N.max_code=rt,P=v.heap_len>>1;1<=P;P--)ot(v,j,P);for(E=$;P=v.heap[1],v.heap[1]=v.heap[v.heap_len--],ot(v,j,1),F=v.heap[1],v.heap[--v.heap_max]=P,v.heap[--v.heap_max]=F,j[2*E]=j[2*P]+j[2*F],v.depth[E]=(v.depth[P]>=v.depth[F]?v.depth[P]:v.depth[F])+1,j[2*P+1]=j[2*F+1]=E,v.heap[1]=E++,ot(v,j,1),2<=v.heap_len;);v.heap[--v.heap_max]=v.heap[1],(function(it,ht){var wt,mt,xt,at,Ct,Tt,yt=ht.dyn_tree,Pt=ht.max_code,ve=ht.stat_desc.static_tree,be=ht.stat_desc.has_stree,we=ht.stat_desc.extra_bits,Ft=ht.stat_desc.extra_base,_t=ht.stat_desc.max_length,Nt=0;for(at=0;at<=p;at++)it.bl_count[at]=0;for(yt[2*it.heap[it.heap_max]+1]=0,wt=it.heap_max+1;wt<h;wt++)_t<(at=yt[2*yt[2*(mt=it.heap[wt])+1]+1]+1)&&(at=_t,Nt++),yt[2*mt+1]=at,Pt<mt||(it.bl_count[at]++,Ct=0,Ft<=mt&&(Ct=we[mt-Ft]),Tt=yt[2*mt],it.opt_len+=Tt*(at+Ct),be&&(it.static_len+=Tt*(ve[2*mt+1]+Ct)));if(Nt!==0){do{for(at=_t-1;it.bl_count[at]===0;)at--;it.bl_count[at]--,it.bl_count[at+1]+=2,it.bl_count[_t]--,Nt-=2}while(0<Nt);for(at=_t;at!==0;at--)for(mt=it.bl_count[at];mt!==0;)Pt<(xt=it.heap[--wt])||(yt[2*xt+1]!==at&&(it.opt_len+=(at-yt[2*xt+1])*yt[2*xt],yt[2*xt+1]=at),mt--)}})(v,N),lt(j,rt,v.bl_count)}function a(v,N,P){var F,E,j=-1,G=N[1],Z=0,$=7,rt=4;for(G===0&&($=138,rt=3),N[2*(P+1)+1]=65535,F=0;F<=P;F++)E=G,G=N[2*(F+1)+1],++Z<$&&E===G||(Z<rt?v.bl_tree[2*E]+=Z:E!==0?(E!==j&&v.bl_tree[2*E]++,v.bl_tree[2*C]++):Z<=10?v.bl_tree[2*S]++:v.bl_tree[2*z]++,j=E,rt=(Z=0)===G?($=138,3):E===G?($=6,3):($=7,4))}function L(v,N,P){var F,E,j=-1,G=N[1],Z=0,$=7,rt=4;for(G===0&&($=138,rt=3),F=0;F<=P;F++)if(E=G,G=N[2*(F+1)+1],!(++Z<$&&E===G)){if(Z<rt)for(;K(v,E,v.bl_tree),--Z!=0;);else E!==0?(E!==j&&(K(v,E,v.bl_tree),Z--),K(v,C,v.bl_tree),Y(v,Z-3,2)):Z<=10?(K(v,S,v.bl_tree),Y(v,Z-3,3)):(K(v,z,v.bl_tree),Y(v,Z-11,7));j=E,rt=(Z=0)===G?($=138,3):E===G?($=6,3):($=7,4)}}l(U);var T=!1;function x(v,N,P,F){Y(v,(g<<1)+(F?1:0),3),(function(E,j,G,Z){nt(E),V(E,G),V(E,~G),r.arraySet(E.pending_buf,E.window,j,G,E.pending),E.pending+=G})(v,N,P)}n._tr_init=function(v){T||((function(){var N,P,F,E,j,G=new Array(p+1);for(E=F=0;E<w-1;E++)for(R[E]=F,N=0;N<1<<B[E];N++)d[F++]=E;for(d[F-1]=E,E=j=0;E<16;E++)for(U[E]=j,N=0;N<1<<O[E];N++)D[j++]=E;for(j>>=7;E<c;E++)for(U[E]=j<<7,N=0;N<1<<O[E]-7;N++)D[256+j++]=E;for(P=0;P<=p;P++)G[P]=0;for(N=0;N<=143;)X[2*N+1]=8,N++,G[8]++;for(;N<=255;)X[2*N+1]=9,N++,G[9]++;for(;N<=279;)X[2*N+1]=7,N++,G[7]++;for(;N<=287;)X[2*N+1]=8,N++,G[8]++;for(lt(X,y+1,G),N=0;N<c;N++)k[2*N+1]=5,k[2*N]=st(N,5);J=new q(X,B,u+1,y,p),W=new q(k,O,0,c,p),tt=new q(new Array(0),A,0,m,b)})(),T=!0),v.l_desc=new M(v.dyn_ltree,J),v.d_desc=new M(v.dyn_dtree,W),v.bl_desc=new M(v.bl_tree,tt),v.bi_buf=0,v.bi_valid=0,et(v)},n._tr_stored_block=x,n._tr_flush_block=function(v,N,P,F){var E,j,G=0;0<v.level?(v.strm.data_type===2&&(v.strm.data_type=(function(Z){var $,rt=4093624447;for($=0;$<=31;$++,rt>>>=1)if(1&rt&&Z.dyn_ltree[2*$]!==0)return s;if(Z.dyn_ltree[18]!==0||Z.dyn_ltree[20]!==0||Z.dyn_ltree[26]!==0)return o;for($=32;$<u;$++)if(Z.dyn_ltree[2*$]!==0)return o;return s})(v)),ut(v,v.l_desc),ut(v,v.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),$=m-1;3<=$&&Z.bl_tree[2*H[$]+1]===0;$--);return Z.opt_len+=3*($+1)+5+5+4,$})(v),E=v.opt_len+3+7>>>3,(j=v.static_len+3+7>>>3)<=E&&(E=j)):E=j=P+5,P+4<=E&&N!==-1?x(v,N,P,F):v.strategy===4||j===E?(Y(v,2+(F?1:0),3),pt(v,X,k)):(Y(v,4+(F?1:0),3),(function(Z,$,rt,it){var ht;for(Y(Z,$-257,5),Y(Z,rt-1,5),Y(Z,it-4,4),ht=0;ht<it;ht++)Y(Z,Z.bl_tree[2*H[ht]+1],3);L(Z,Z.dyn_ltree,$-1),L(Z,Z.dyn_dtree,rt-1)})(v,v.l_desc.max_code+1,v.d_desc.max_code+1,G+1),pt(v,v.dyn_ltree,v.dyn_dtree)),et(v),F&&nt(v)},n._tr_tally=function(v,N,P){return v.pending_buf[v.d_buf+2*v.last_lit]=N>>>8&255,v.pending_buf[v.d_buf+2*v.last_lit+1]=255&N,v.pending_buf[v.l_buf+v.last_lit]=255&P,v.last_lit++,N===0?v.dyn_ltree[2*P]++:(v.matches++,N--,v.dyn_ltree[2*(d[P]+u+1)]++,v.dyn_dtree[2*I(N)]++),v.last_lit===v.lit_bufsize-1},n._tr_align=function(v){Y(v,2,3),K(v,_,X),(function(N){N.bi_valid===16?(V(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)})(v)}},{"../utils/common":41}],53:[function(e,i,n){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,n){(function(r){(function(s,o){if(!s.setImmediate){var l,g,w,u,y=1,c={},m=!1,h=s.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(s);p=p&&p.setTimeout?p:s,l={}.toString.call(s.process)==="[object process]"?function(C){process.nextTick(function(){b(C)})}:(function(){if(s.postMessage&&!s.importScripts){var C=!0,S=s.onmessage;return s.onmessage=function(){C=!1},s.postMessage("","*"),s.onmessage=S,C}})()?(u="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",_,!1):s.attachEvent("onmessage",_),function(C){s.postMessage(u+C,"*")}):s.MessageChannel?((w=new MessageChannel).port1.onmessage=function(C){b(C.data)},function(C){w.port2.postMessage(C)}):h&&"onreadystatechange"in h.createElement("script")?(g=h.documentElement,function(C){var S=h.createElement("script");S.onreadystatechange=function(){b(C),S.onreadystatechange=null,g.removeChild(S),S=null},g.appendChild(S)}):function(C){setTimeout(b,0,C)},p.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var S=new Array(arguments.length-1),z=0;z<S.length;z++)S[z]=arguments[z+1];var B={callback:C,args:S};return c[y]=B,l(y),y++},p.clearImmediate=f}function f(C){delete c[C]}function b(C){if(m)setTimeout(b,0,C);else{var S=c[C];if(S){m=!0;try{(function(z){var B=z.callback,O=z.args;switch(O.length){case 0:B();break;case 1:B(O[0]);break;case 2:B(O[0],O[1]);break;case 3:B(O[0],O[1],O[2]);break;default:B.apply(o,O)}})(S)}finally{f(C),m=!1}}}}function _(C){C.source===s&&typeof C.data=="string"&&C.data.indexOf(u)===0&&b(+C.data.slice(u.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof St<"u"?St:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(zt)),zt.exports}var fe=ue();const pe=he(fe);class Lt{generate(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).substr(2)}}class Mt{idGenerator;constructor(){this.idGenerator=new Lt}async extractMindMapData(t){const e=new pe;try{const n=(await e.loadAsync(t)).file("content.json");if(!n)throw new Error("Invalid XMind file: content.json not found");const r=await n.async("text"),s=JSON.parse(r);if(!Array.isArray(s)||s.length===0)throw new Error("Invalid XMind file: No content found");const o=s[0];return{nodeData:await this.transformTopic(o.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 n=this.idGenerator.generate(),r=[];if(t.children&&t.children.attached)for(const o of t.children.attached)r.push(await this.transformTopic(o,e,!1));let s;if(t.image&&t.image.src&&t.image.src.startsWith("xap:")){const o=t.image.src.substring(4),l=e.file(o);if(l){const g=await l.async("base64"),w=o.split(".").pop()?.toLowerCase();let u="image/png";w==="jpg"||w==="jpeg"?u="image/jpeg":w==="svg"?u="image/svg+xml":w==="gif"&&(u="image/gif"),s=`data:${u};base64,${g}`}}if(t.title&&s){const o={id:n,topic:t.title,root:i,children:r},g={id:this.idGenerator.generate(),topic:"",image:s,children:[]};return o.children?.push(g),o}else return s?{id:n,topic:"",image:s,root:i,children:r}:{id:n,topic:t.title||"",root:i,children:r}}}class me{mindMap;renderer;eventBus;fileHandler;constructor(t){this.mindMap=t.mindMap,this.renderer=t.renderer,this.eventBus=t.eventBus,this.fileHandler=t.fileHandler}async exportPng(){this.eventBus.emit("command",{name:"exportPng"}),await new Dt().exportToPng(this.renderer.container,this.fileHandler)}async exportSvg(){this.eventBus.emit("command",{name:"exportSvg"}),await new Dt().exportToSvg(this.renderer.container,this.fileHandler)}async exportMarkdown(){this.eventBus.emit("command",{name:"exportMarkdown"}),await new ce().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 null;if(this.fileHandler){const t=await this.fileHandler.onImportFile("xmind");if(t)try{const e=new Mt;let i;if(t instanceof ArrayBuffer)i=new File([t],"imported.xmind");else if(typeof t=="string")i=new File([t],"imported.xmind");else return null;return await e.extractMindMapData(i)}catch(e){return console.error(e),alert("Failed to import XMind file."),null}return null}return new Promise(t=>{const e=document.createElement("input");e.type="file",e.accept=".xmind",e.style.display="none",document.body.appendChild(e),e.onchange=async i=>{const r=i.target.files?.[0];if(r)try{const o=await new Mt().extractMindMapData(r);t(o)}catch(s){console.error(s),alert("Failed to import XMind file."),t(null)}else t(null);document.body.removeChild(e)},e.click()})}}class ge{mindMap;service;renderer;eventBus;layoutSwitcher;savedCustomStyles={rootNode:{border:"2px solid #aeb6bf",background:"#ebf5fb",color:"#2e4053"},childNode:{border:"1px solid #d5d8dc",background:"#fdfefe",color:"#2c3e50"},canvas:{background:"#ffffff"},connection:{color:"#abb2b9"}};constructor(t){this.mindMap=t.mindMap,this.service=t.service,this.renderer=t.renderer,this.eventBus=t.eventBus}setLayoutSwitcher(t){this.layoutSwitcher=t}applyInitialTheme(){const t=this.mindMap.theme;if(t==="custom"){const e=ct.getInstance();e.setCustomTheme(this.savedCustomStyles),e.applyTheme(this.renderer.container,"custom")}else ct.getInstance().applyTheme(this.renderer.container,t)}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")}this.eventBus.emit("theme:changed",this.mindMap.theme),this.eventBus.emit("model:change","updateGlobalStyles")}setTheme(t,e={}){const{saveState:i=!0,emitChange:n=!0}=e;if(n&&this.eventBus.emit("command",{name:"setTheme",args:{theme:t}}),this.service.setTheme(t),this.layoutSwitcher&&this.layoutSwitcher.setTheme(t),t==="custom"){const r=ct.getInstance();r.setCustomTheme(this.savedCustomStyles),r.applyTheme(this.renderer.container,"custom")}else ct.getInstance().applyTheme(this.renderer.container,t);this.eventBus.emit("theme:changed",t),i&&this.eventBus.emit("model:change","setTheme")}getSavedCustomStyles(){return this.savedCustomStyles}}class Ot{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(n=>n!==e))}removeListener(t,e){this.off(t,e)}emit(t,e){this.listeners[t]?.forEach(i=>i(e))}}class ye extends Ot{mindMap;controller;interactionOrchestrator;commandBus;constructor(t,e={}){super();const i=new gt("root","Root Topic",null,!0);this.mindMap=new bt(i);const n=new Lt,r=new Wt(this.mindMap,n),s=new jt(10),o=new Ht(this.mindMap,n),l=new Zt(this.mindMap),g=document.createElement("div");g.style.position="absolute",g.style.top="0",g.style.left="0",g.style.width="100%",g.style.height="100%",g.style.pointerEvents="none",g.style.zIndex="2000",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.style.overscrollBehavior="none",t.style.touchAction="none",t.appendChild(g);const u=new vt(g),y=new Gt(t,{onImageZoom:S=>this.controller.setReadOnly(S),onToggleFold:S=>this.controller.toggleFold(S)});let c="en";typeof navigator<"u"&&navigator.language&&navigator.language.startsWith("ja")&&(c="ja");const m=new de(y),h=new le(this.mindMap),p={emit:(S,z)=>this.emit(S,z),on:(S,z)=>this.on(S,z),off:(S,z)=>this.off(S,z)},f=new me({mindMap:this.mindMap,renderer:y,eventBus:p,fileHandler:e.fileHandler}),b=new ge({mindMap:this.mindMap,service:r,renderer:y,eventBus:p}),_=new ne;this.controller=new ae({mindMap:this.mindMap,service:r,renderer:y,styleEditor:u,eventBus:p,historyService:s,clipboardService:o,searchService:l,viewportService:m,navigationService:h,fileIOService:f,themeService:b,commandBus:_,locale:e.locale||c,commandPaletteFeatures:e.disabledCommandPaletteFeatures}),u.onUpdate=(S,z)=>{this.controller.updateNode(S,{style:z})},this.interactionOrchestrator=new ie({container:t,commandBus:_,mindMap:this.mindMap,getSelectedNodeId:()=>this.controller.getSelectedNodeId(),getNodeElement:S=>y.getNodeElement(S),zoomNode:S=>y.zoomNode(S),options:{...e,onNodeClick:(S,z)=>{z&&S?this.controller.selectRangeTo(S):this.controller.selectNode(S||null)},onAddChild:S=>this.controller.addChildNode(S),onInsertParent:S=>this.controller.insertParentNode(S),onAddSibling:(S,z)=>this.controller.addSiblingNode(S,z),onDeleteNode:S=>this.controller.removeNode(S),onDropNode:(S,z,B)=>this.controller.moveNode(S,z,B),onUpdateNode:(S,z)=>this.controller.updateNodeTopic(S,z),onNavigate:(S,z,B)=>this.controller.navigateNode(S,z,B),onPan:(S,z)=>this.controller.panBoard(S,z),onCopyNode:S=>this.controller.copyNode(S),onPasteNode:S=>this.controller.pasteNode(S),onCutNode:S=>this.controller.cutNode(S),onPasteImage:(S,z,B,O)=>this.controller.pasteImage(S,z,B,O),onZoom:(S,z,B)=>this.controller.zoomBoard(S,z,B),onZoomReset:()=>this.controller.resetZoom(),onUndo:()=>this.controller.undo(),onRedo:()=>this.controller.redo(),onStyleAction:(S,z)=>this.controller.onStyleAction(S,z),onEditEnd:S=>this.controller.onEditEnd(),onToggleFold:S=>this.controller.toggleFold(S),onToggleCommandPalette:()=>this.controller.toggleCommandPalette(),onUpdateNodeWidth:(S,z)=>this.controller.updateNodeWidth(S,z)}}),this.commandBus=_,this.controller.setInteractionOrchestrator(this.interactionOrchestrator);const C=new $t(g,{onLayoutChange:S=>this.controller.setLayoutMode(S),onThemeChange:S=>this.controller.setTheme(S),onZoomReset:()=>this.controller.resetZoom(),onShowHelp:()=>this.controller.showHelpModal()});this.controller.setLayoutSwitcher(C),e.maxNodeWidth!==void 0&&this.controller.setMaxNodeWidth(e.maxNodeWidth),e.customStyles&&this.controller.updateGlobalStyles(e.customStyles),this.controller.init(t.clientWidth,t.clientHeight)}addNode(t,e,i,n={emitChange:!0}){return this.controller.addNode(t,e,i,n)}addSibling(t,e="after",i="New topic",n={emitChange:!0}){return this.controller.addSibling(t,e,i,n)}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()}registerCommand(t){this.controller.registerCommand(t)}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=n=>{t(n)&&e.push(n),n.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,n){this.controller.pasteImage(t,e,i,n)}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}}ft.Kakidash=ye,ft.Node=gt,ft.SvgGenerator=Bt,ft.TypedEventEmitter=Ot,ft.XMindImporter=Mt,Object.defineProperty(ft,Symbol.toStringTag,{value:"Module"})}));