@synclineapi/mdx-editor 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +320 -140
- package/dist/core/config/EditorConfig.d.ts +5 -0
- package/dist/core/config/defaults.d.ts +33 -0
- package/dist/core/config/index.d.ts +2 -0
- package/dist/core/dom/editor-pane.d.ts +7 -0
- package/dist/core/dom/editor-root.d.ts +8 -0
- package/dist/core/dom/index.d.ts +11 -0
- package/dist/core/dom/preview-pane.d.ts +5 -0
- package/dist/core/dom/skip-link.d.ts +1 -0
- package/dist/core/dom/status-bar.d.ts +13 -0
- package/dist/core/dom/toolbar-dom.d.ts +5 -0
- package/dist/core/editor.d.ts +99 -6
- package/dist/core/mdx-themes.d.ts +3 -0
- package/dist/core/platform.d.ts +31 -0
- package/dist/core/plugin-manager.d.ts +1 -24
- package/dist/core/plugins/PluginContext.d.ts +24 -0
- package/dist/core/plugins/PluginManager.d.ts +33 -0
- package/dist/core/plugins/index.d.ts +3 -0
- package/dist/core/renderer/CodeRenderer.d.ts +4 -0
- package/dist/core/renderer/ListRenderer.d.ts +5 -0
- package/dist/core/renderer/MarkdownRenderer.d.ts +7 -0
- package/dist/core/renderer/MdxValidator.d.ts +3 -0
- package/dist/core/renderer/Renderer.d.ts +10 -0
- package/dist/core/renderer/TableRenderer.d.ts +4 -0
- package/dist/core/renderer/index.d.ts +7 -0
- package/dist/core/renderer/sanitize.d.ts +1 -0
- package/dist/core/renderer.d.ts +6 -28
- package/dist/core/toolbar.d.ts +1 -0
- package/dist/core/types.d.ts +72 -2
- package/dist/core/ui/AutocompleteController.d.ts +58 -0
- package/dist/core/ui/DropdownController.d.ts +8 -0
- package/dist/core/ui/FindReplaceController.d.ts +60 -0
- package/dist/core/ui/LineNumberController.d.ts +218 -0
- package/dist/core/ui/ModeController.d.ts +9 -0
- package/dist/core/ui/PreviewController.d.ts +13 -0
- package/dist/core/ui/ResponsiveController.d.ts +30 -0
- package/dist/core/ui/SplitterController.d.ts +31 -0
- package/dist/core/ui/StatusBarController.d.ts +16 -0
- package/dist/core/ui/ThemeController.d.ts +8 -0
- package/dist/core/ui/ToolbarController.d.ts +10 -0
- package/dist/core/ui/UIController.d.ts +43 -0
- package/dist/core/ui/index.d.ts +12 -0
- package/dist/index.d.ts +28 -1
- package/dist/plugins/basic-formatting/index.d.ts +1 -0
- package/dist/plugins/callouts/index.d.ts +1 -0
- package/dist/plugins/diagrams/index.d.ts +1 -0
- package/dist/plugins/index.d.ts +1 -11
- package/dist/plugins/layout/index.d.ts +3 -0
- package/dist/plugins/lists/index.d.ts +1 -0
- package/dist/plugins/media/index.d.ts +2 -0
- package/dist/plugins/utilities/index.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist/syncline-mdx-editor.js +8468 -1812
- package/dist/syncline-mdx-editor.umd.cjs +958 -87
- package/package.json +6 -12
|
@@ -1,22 +1,767 @@
|
|
|
1
|
-
(function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.SynclineMDXEditor={},m.hljs))})(this,function(m,v){"use strict";class S{constructor(){this.listeners=new Map}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var o;(o=this.listeners.get(e))==null||o.delete(t)}emit(e,t){var o;(o=this.listeners.get(e))==null||o.forEach(i=>{try{i(t)}catch(s){console.error(`[SynclineMDX] Error in event handler for "${e}":`,s)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class T{constructor(e,t){this.editorApi=e,this.plugins=new Map,this.toolbarItems=new Map,this.shortcuts=[],this.renderers=[],this.parsers=[],this.styleElements=[],this.events=t}async register(e){if(this.plugins.has(e.name)){console.warn(`[SynclineMDX] Plugin "${e.name}" is already registered.`);return}if(e.dependencies){for(const t of e.dependencies)if(!this.plugins.has(t))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${t}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const t of e.toolbarItems)this.toolbarItems.set(t.id,t);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((t,o)=>(o.priority??0)-(t.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((t,o)=>(o.priority??0)-(t.priority??0))),e.styles&&this.injectStyles(e.styles),e.init&&await e.init(this.createContext()),this.events.emit("plugin-registered",e.name)}unregister(e){const t=this.plugins.get(e);if(t){if(t.destroy&&t.destroy(this.createContext()),t.toolbarItems)for(const o of t.toolbarItems)this.toolbarItems.delete(o.id);if(t.shortcuts&&(this.shortcuts=this.shortcuts.filter(o=>!t.shortcuts.some(i=>i.key===o.key))),t.renderers){const o=new Set(t.renderers.map(i=>i.name));this.renderers=this.renderers.filter(i=>!o.has(i.name))}if(t.parsers){const o=new Set(t.parsers.map(i=>i.name));this.parsers=this.parsers.filter(i=>!o.has(i.name))}this.plugins.delete(e),this.events.emit("plugin-removed",e)}}getToolbarItem(e){return this.toolbarItems.get(e)}getAllToolbarItems(){return this.toolbarItems}getShortcuts(){return this.shortcuts}getRenderers(){return this.renderers}getParsers(){return this.parsers}hasPlugin(e){return this.plugins.has(e)}createContext(){return{editor:this.editorApi,registerToolbarItem:e=>this.toolbarItems.set(e.id,e),registerShortcut:e=>this.shortcuts.push(e),registerRenderer:e=>{this.renderers.push(e),this.renderers.sort((t,o)=>(o.priority??0)-(t.priority??0))},registerParser:e=>{this.parsers.push(e),this.parsers.sort((t,o)=>(o.priority??0)-(t.priority??0))},injectStyles:e=>this.injectStyles(e),emit:(e,t)=>this.events.emit(e,t),on:(e,t)=>this.events.on(e,t),off:(e,t)=>this.events.off(e,t)}}injectStyles(e){const t=document.createElement("style");t.setAttribute("data-syncline-mdx","plugin"),t.textContent=e,document.head.appendChild(t),this.styleElements.push(t)}destroy(){for(const[e]of this.plugins)this.unregister(e);for(const e of this.styleElements)e.remove();this.styleElements=[]}}class E{constructor(e,t,o,i){this.config=e,this.pluginManager=t,this.editorApi=o,this.events=i,this.activeDropdown=null,this.documentClickHandler=s=>{this.activeDropdown&&!this.activeDropdown.contains(s.target)&&this.closeDropdowns()}}render(e){this.el=document.createElement("div"),this.el.className="smdx-toolbar";for(const t of this.config){const o=document.createElement("div");o.className="smdx-toolbar-row",this.renderRow(t,o),this.el.appendChild(o)}return e.appendChild(this.el),document.addEventListener("click",this.documentClickHandler),this.el}renderRow(e,t){for(const o of e)typeof o=="string"?o==="|"?this.renderDivider(t):this.renderItem(o,t):"type"in o&&o.type==="divider"?this.renderDivider(t):"type"in o&&o.type==="group"&&this.renderGroup(o,t)}renderDivider(e){const t=document.createElement("span");t.className="smdx-toolbar-divider",e.appendChild(t)}renderItem(e,t){const o=this.pluginManager.getToolbarItem(e);if(o)if(o.children&&o.children.length>0)this.renderDropdownItem(o,t);else{const i=this.createButton(o);t.appendChild(i)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const o=document.createElement("div");o.className="smdx-toolbar-group";for(const i of e.items)typeof i=="string"?this.renderItem(i,o):this.renderGroup(i,o);t.appendChild(o)}}renderDropdownGroup(e,t){const o=document.createElement("div");o.className="smdx-toolbar-dropdown";const i=document.createElement("button");i.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",i.type="button",i.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label||""}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,i.title=e.label||"",i.setAttribute("aria-label",e.label||"Dropdown"),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded","false");const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu",s.setAttribute("role","menu"),s.style.display="none";for(const n of e.items)if(typeof n=="string"){const a=this.pluginManager.getToolbarItem(n);if(!a)continue;if(a.children&&a.children.length>0)this.renderSubmenu(a,s);else{const d=this.createMenuButton(a);s.appendChild(d)}}else{const a=document.createElement("div");if(a.className="smdx-toolbar-dropdown-section",n.label){const d=document.createElement("div");d.className="smdx-toolbar-dropdown-section-label",d.textContent=n.label,a.appendChild(d)}for(const d of n.items)if(typeof d=="string"){const l=this.pluginManager.getToolbarItem(d);if(l)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const c=this.createMenuButton(l);a.appendChild(c)}}s.appendChild(a)}i.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,o)}),o.appendChild(i),o.appendChild(s),t.appendChild(o)}renderDropdownItem(e,t){const o=document.createElement("div");o.className="smdx-toolbar-dropdown";const i=document.createElement("button");i.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",i.type="button",i.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,i.title=e.tooltip||e.label,i.setAttribute("aria-label",e.tooltip||e.label),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-expanded","false");const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu",s.setAttribute("role","menu"),s.style.display="none";for(const n of e.children)if(n.children&&n.children.length>0)this.renderSubmenu(n,s);else{const a=this.createMenuButton(n);s.appendChild(a)}i.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,o)}),o.appendChild(i),o.appendChild(s),t.appendChild(o)}renderSubmenu(e,t){const o=document.createElement("div");o.className="smdx-toolbar-submenu";const i=document.createElement("button");i.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",i.type="button",i.innerHTML=`${e.icon||""}<span>${e.label}</span><svg class="smdx-submenu-arrow" width="6" height="10" viewBox="0 0 6 10"><path d="M1 1l4 4-4 4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const s=document.createElement("div");s.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",s.style.display="none";for(const c of e.children)if(c.children&&c.children.length>0)this.renderSubmenu(c,s);else{const h=this.createMenuButton(c);s.appendChild(h)}const n=()=>{const c=o.getBoundingClientRect();s.style.left=`${c.right}px`,s.style.top=`${c.top}px`,requestAnimationFrame(()=>{const h=s.getBoundingClientRect();h.right>window.innerWidth&&(s.style.left=`${c.left-h.width}px`),h.bottom>window.innerHeight&&(s.style.top=`${window.innerHeight-h.height-8}px`)})};let a=null;const d=()=>{a&&(clearTimeout(a),a=null),s.style.display="",n()},l=()=>{a&&clearTimeout(a),a=setTimeout(()=>{s.style.display="none",a=null},120)};i.addEventListener("mouseenter",d),s.addEventListener("mouseenter",d),o.addEventListener("mouseleave",l),s.addEventListener("mouseleave",l),o.appendChild(i),o.appendChild(s),t.appendChild(o)}createButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-btn${e.className?" "+e.className:""}`,t.type="button",t.tabIndex=0,t.title=e.tooltip||e.label,t.setAttribute("aria-label",e.tooltip||e.label),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,e.shortcutLabel&&(t.title+=` (${e.shortcutLabel})`),t.addEventListener("click",o=>{o.preventDefault(),this.executeAction(e)}),e.render&&e.render(t,this.getActionContext()),t}createMenuButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-menu-btn${e.className?" "+e.className:""}`,t.type="button",t.setAttribute("role","menuitem"),t.dataset.toolbarId=e.id,t.innerHTML=`${e.icon||""}<span>${e.label}</span>${e.shortcutLabel?`<span class="smdx-shortcut-label">${e.shortcutLabel}</span>`:""}`,t.addEventListener("click",o=>{o.preventDefault(),this.closeDropdowns(),this.executeAction(e)}),t}executeAction(e){var o;const t=this.getActionContext();(o=e.isDisabled)!=null&&o.call(e,t)||(e.action(t),this.events.emit("toolbar-action",e.id))}getActionContext(){return{editor:this.editorApi,selection:this.editorApi.getSelection()}}toggleDropdown(e,t){if(e.style.display==="none"){this.closeDropdowns(),e.style.display="",this.activeDropdown=t;const o=t.querySelector(".smdx-toolbar-dropdown-trigger");o==null||o.setAttribute("aria-expanded","true")}else{e.style.display="none";const o=t.querySelector(".smdx-toolbar-dropdown-trigger");o==null||o.setAttribute("aria-expanded","false"),this.activeDropdown=null}}closeDropdowns(){var e,t;(e=this.el)==null||e.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(o=>{o.style.display="none"}),(t=this.el)==null||t.querySelectorAll('[aria-expanded="true"]').forEach(o=>{o.setAttribute("aria-expanded","false")}),this.activeDropdown=null}updateActiveStates(){var t;const e=this.getActionContext();(t=this.el)==null||t.querySelectorAll("[data-toolbar-id]").forEach(o=>{const i=o.dataset.toolbarId,s=this.pluginManager.getToolbarItem(i);s!=null&&s.isActive&&o.classList.toggle("smdx-active",s.isActive(e)),s!=null&&s.isDisabled&&(o.disabled=s.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const Ce=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),$e=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function Se(r){return $e.some(e=>r.startsWith(e))}const L=/^on/i,Te=/^\s*javascript\s*:/i;function Ee(r){if(typeof document>"u")return r;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${r}</body>`,"text/html"),o=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),i=[];let s=o.currentNode;for(;s;){if(s.nodeType===Node.ELEMENT_NODE){const n=s,a=n.tagName.toLowerCase();if(Ce.has(a))i.push(n);else if(a==="iframe"){const d=n.getAttribute("src")||"";if(!Se(d))i.push(n);else{const l=[];for(const c of Array.from(n.attributes))L.test(c.name)&&l.push(c.name);for(const c of l)n.removeAttribute(c)}}else{const d=[];for(const l of Array.from(n.attributes))(L.test(l.name)||(l.name==="href"||l.name==="src"||l.name==="action")&&Te.test(l.value))&&d.push(l.name);for(const l of d)n.removeAttribute(l)}}s=o.nextNode()}for(const n of i)n.remove();return t.body.innerHTML}class M{constructor(){this.renderers=[],this.parsers=[]}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const o=this.validateMdxTags(e),i=[];t=t.replace(/`([^`\n]+)`/g,(s,n)=>{const a=i.length;return i.push(n),`%%INLINECODE_${a}%%`}),t=this.applyParsers(t),t=this.applyRenderers(t);for(let s=0;s<i.length;s++)t=t.replace(`%%INLINECODE_${s}%%`,`\`${i[s]}\``);return t=this.renderMarkdown(t),o.length>0&&(t=o.map(n=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">⚠</span> ${this.escapeHtml(n)}</div>`).join("")+t),Ee(t)}applyParsers(e){let t=e;for(const o of this.parsers)t=t.replace(o.pattern,(...i)=>{const s=i;return o.transform(s)});return t}applyRenderers(e){let t=e;for(const o of this.renderers)t=t.replace(o.pattern,(i,...s)=>{const n={};return s.length>0&&(n.content=s[0]||""),o.render(i,n)});return t}renderMarkdown(e){let t=e;const o=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(s,n,a,d)=>{const l=o.length,c={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",py:"Python",python:"Python",java:"Java",rb:"Ruby",ruby:"Ruby",go:"Go",rust:"Rust",rs:"Rust",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",swift:"Swift",kt:"Kotlin",kotlin:"Kotlin",scala:"Scala",sh:"Shell",bash:"Bash",zsh:"Zsh",sql:"SQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",md:"Markdown",markdown:"Markdown",graphql:"GraphQL",dart:"Dart",r:"R",lua:"Lua",perl:"Perl",text:"Text",txt:"Text"};let h;const u=d.trimEnd();try{n&&v.getLanguage(n)?h=v.highlight(u,{language:n}).value:h=v.highlightAuto(u).value}catch{h=this.escapeHtml(u)}const x=n?c[n.toLowerCase()]||n.charAt(0).toUpperCase()+n.slice(1):"",g=x?`<span class="smdx-code-lang">${x}</span>`:"",b=a?`<span class="smdx-code-filename"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>${this.escapeHtml(a)}</span>`:"",y='<button class="smdx-copy-btn" data-copy-btn="true" title="Copy code" aria-label="Copy code"><svg class="smdx-copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg><svg class="smdx-check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></button>',k=x||a,w=k?`<div class="smdx-code-header">${g}${b}${y}</div>`:"";return o.push(`<div class="smdx-code-block${k?" smdx-has-header":""}">${w}<pre><code class="hljs language-${n||"text"}">${h}</code></pre>${k?"":y}</div>`),`%%CODEBLOCK_${l}%%`}),t=t.replace(/`([^`]+)`/g,(s,n)=>`<code class="smdx-inline-code">${this.escapeHtml(n)}</code>`);const i=s=>s.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(s,n)=>`<h6 id="${i(n)}">${n}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(s,n)=>`<h5 id="${i(n)}">${n}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(s,n)=>`<h4 id="${i(n)}">${n}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(s,n)=>`<h3 id="${i(n)}">${n}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(s,n)=>`<h2 id="${i(n)}">${n}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(s,n)=>`<h1 id="${i(n)}">${n}</h1>`),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/^>\s+(.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^- \[x\]\s+(.+)$/gm,'<div class="smdx-task"><input type="checkbox" checked disabled /><span>$1</span></div>'),t=t.replace(/^- \[ \]\s+(.+)$/gm,'<div class="smdx-task"><input type="checkbox" disabled /><span>$1</span></div>'),t=t.replace(/^[-*]\s+(.+)$/gm,'<li class="smdx-ul-item">$1</li>'),t=t.replace(/((?:<li class="smdx-ul-item">.*<\/li>\n?)+)/g,"<ul>$1</ul>"),t=t.replace(/^\d+\.\s+(.+)$/gm,'<li class="smdx-ol-item">$1</li>'),t=t.replace(/((?:<li class="smdx-ol-item">.*<\/li>\n?)+)/g,"<ol>$1</ol>"),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="smdx-image"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=this.renderTables(t),t=t.replace(/ {2,}$/gm,"<br/>"),t=t.replace(/^(?!\s*<[a-zA-Z/!]|\s*%%)(.*\S.*)$/gm,"<p>$1</p>"),t=t.replace(/<p>\s*<\/p>/g,"");for(let s=0;s<o.length;s++)t=t.replace(`%%CODEBLOCK_${s}%%`,o[s]);return t}renderTables(e){const t=/(?:^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)*))/gm;return e.replace(t,(o,i,s,n)=>{const a=this.parseTableRow(i),d=n.trim().split(`
|
|
2
|
-
`).filter(Boolean).map(
|
|
3
|
-
`)
|
|
4
|
-
|
|
5
|
-
`),d=n.length>0
|
|
6
|
-
`),l=(a?`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
`).length}applyTheme(e){for(const[t,o]of Object.entries(e))this.root.style.setProperty(t.startsWith("--")?t:`--smdx-${t}`,o)}}const p={heading:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M4 6v12M20 6v12"/></svg>',h1:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H1</text></svg>',h2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H2</text></svg>',h3:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H3</text></svg>',h4:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H4</text></svg>',h5:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H5</text></svg>',h6:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H6</text></svg>',bold:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6zM6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"/></svg>',italic:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>',strikethrough:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 4H9a3 3 0 00-3 3v0a3 3 0 003 3h6a3 3 0 013 3v0a3 3 0 01-3 3H8"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',quote:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"/></svg>',link:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>',image:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',code:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',codeBlock:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="18" rx="2"/><polyline points="10 8 6 12 10 16"/><polyline points="14 8 18 12 14 16"/></svg>',unorderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor"/><circle cx="4" cy="12" r="1" fill="currentColor"/><circle cx="4" cy="18" r="1" fill="currentColor"/></svg>',orderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="8" fill="currentColor" stroke="none">1</text><text x="2" y="15" font-size="8" fill="currentColor" stroke="none">2</text><text x="2" y="21" font-size="8" fill="currentColor" stroke="none">3</text></svg>',taskList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="6" height="6" rx="1"/><path d="M5 8l1 1 2-2"/><line x1="13" y1="8" x2="21" y2="8"/><rect x="3" y="13" width="6" height="6" rx="1"/><line x1="13" y1="16" x2="21" y2="16"/></svg>',table:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',highlight:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',admonition:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',tab:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="6" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M5 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',imageBackground:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1" stroke-dasharray="4,2"/><circle cx="12" cy="12" r="3"/></svg>',imageFrame:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1"/></svg>',accordion:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="6" rx="1"/><path d="M15 6l-3 3-3-3"/><rect x="3" y="13" width="18" height="6" rx="1"/></svg>',accordionGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="2" width="18" height="5" rx="1"/><rect x="3" y="9" width="18" height="5" rx="1"/><rect x="3" y="16" width="18" height="5" rx="1"/></svg>',multiColumn:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',card:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="7" y1="10" x2="17" y2="10"/><line x1="7" y1="14" x2="13" y2="14"/></svg>',cardGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="8" height="8" rx="2"/><rect x="14" y="3" width="8" height="8" rx="2"/><rect x="2" y="13" width="8" height="8" rx="2"/><rect x="14" y="13" width="8" height="8" rx="2"/></svg>',step:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="5" r="3"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="19" r="3"/><line x1="12" y1="8" x2="12" y2="9"/><line x1="12" y1="15" x2="12" y2="16"/></svg>',tip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18h6M10 22h4M12 2a7 7 0 017 7c0 2.38-1.19 4.47-3 5.74V17H8v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 017-7z"/></svg>',container:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" stroke-dasharray="4,2"/></svg>',copyText:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',tooltip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="12" rx="2"/><path d="M9 15l3 4 3-4"/></svg>',embedVideo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10,8 16,12 10,16"/></svg>',embedOthers:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><ellipse cx="12" cy="12" rx="4" ry="10"/></svg>',mermaid:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="8" height="6" rx="1"/><rect x="14" y="16" width="8" height="6" rx="1"/><rect x="14" y="2" width="8" height="6" rx="1"/><path d="M10 5h4M6 8v8l12-4"/></svg>',emoji:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>',formula:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="3" y="17" font-size="14" fill="currentColor" stroke="none" font-style="italic">∑x</text></svg>',insert:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',scrollSync:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M12 4v16"/></svg>'};function P(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:p.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(r=>({id:`h${r}`,label:`Heading ${r}`,icon:p[`h${r}`],tooltip:`Heading ${r}`,action:({editor:e})=>{const t="#".repeat(r)+" ",i=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+i)}})),action:({editor:r})=>{const e=r.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const o=Math.min(t[1].length+1,6),i=e.replace(/^#{1,6}\s*/,"");r.replaceCurrentLine("#".repeat(o)+" "+i)}else r.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:r})=>r.replaceCurrentLine("# "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:r})=>r.replaceCurrentLine("## "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:r})=>r.replaceCurrentLine("### "+r.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}]}}function A(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:p.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:r})=>r.wrapSelection("**","**"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:o}=r;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(o)}}],shortcuts:[{key:"Ctrl+b",action:({editor:r})=>r.wrapSelection("**","**"),description:"Bold"}]}}function D(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:p.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:r})=>r.wrapSelection("*","*"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:o}=r;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(o)}}],shortcuts:[{key:"Ctrl+i",action:({editor:r})=>r.wrapSelection("*","*"),description:"Italic"}]}}function H(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:p.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:r})=>r.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:r})=>r.wrapSelection("~~","~~"),description:"Strikethrough"}]}}function z(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:p.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:r})=>{const e=r.getCurrentLine();e.startsWith("> ")?r.replaceCurrentLine(e.substring(2)):r.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:r})=>{const e=r.getCurrentLine();r.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}]}}function R(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:p.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:r,selection:e})=>{e.text?r.replaceSelection(`[${e.text}](url)`):r.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:r,selection:e})=>{e.text?r.replaceSelection(`[${e.text}](url)`):r.insertText("[link text](url)")},description:"Insert Link"}]}}function N(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:p.image,tooltip:"Insert Image",action:({editor:r,selection:e})=>{const t=e.text||"alt text";r.replaceSelection(``)}}]}}function O(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:p.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:r})=>r.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:p.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:r,selection:e})=>{r.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:r})=>r.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:r,selection:e})=>{r.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}]}}function j(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:p.unorderedList,tooltip:"Bullet List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^[-*]\s/)?r.replaceCurrentLine(e.replace(/^[-*]\s/,"")):r.replaceCurrentLine("- "+e)}}]}}function G(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:p.orderedList,tooltip:"Numbered List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^\d+\.\s/)?r.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):r.replaceCurrentLine("1. "+e)}}]}}function _(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:p.taskList,tooltip:"Task List",action:({editor:r})=>{const e=r.getCurrentLine();e.match(/^- \[[ x]\]\s/)?r.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):r.replaceCurrentLine("- [ ] "+e)}}]}}function q(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:p.table,tooltip:"Insert Table",action:({editor:r})=>{r.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
1
|
+
(function(b,G){typeof exports=="object"&&typeof module<"u"?G(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],G):(b=typeof globalThis<"u"?globalThis:b||self,G(b.SynclineMDXEditor={},b.hljs))})(this,function(b,G){"use strict";class Se{constructor(){this.listeners=new Map}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var i;(i=this.listeners.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.listeners.get(e))==null||i.forEach(r=>{try{r(t)}catch(o){console.error(`[SynclineMDX] Error in event handler for "${e}":`,o)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class le{constructor(e,t){this.editorApi=e,this.plugins=new Map,this.toolbarItems=new Map,this.shortcuts=[],this.renderers=[],this.parsers=[],this.styleElements=[],this.completionsByPlugin=new Map,this.events=t}async register(e){if(this.plugins.has(e.name)){console.warn(`[SynclineMDX] Plugin "${e.name}" is already registered.`);return}if(e.dependencies){for(const i of e.dependencies)if(!this.plugins.has(i))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${i}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const i of e.toolbarItems)this.toolbarItems.set(i.id,i);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((i,r)=>(r.priority??0)-(i.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((i,r)=>(r.priority??0)-(i.priority??0)));const t=e.completions?[...e.completions]:[];this.completionsByPlugin.set(e.name,t),e.styles&&this.injectStyles(e.styles),e.init&&await e.init(this.createContext(e.name)),this.events.emit("plugin-registered",e.name)}unregister(e){const t=this.plugins.get(e);if(t){if(t.destroy&&t.destroy(this.createContext(e)),t.toolbarItems)for(const i of t.toolbarItems)this.toolbarItems.delete(i.id);if(t.shortcuts&&(this.shortcuts=this.shortcuts.filter(i=>!t.shortcuts.some(r=>r.key===i.key))),t.renderers){const i=new Set(t.renderers.map(r=>r.name));this.renderers=this.renderers.filter(r=>!i.has(r.name))}if(t.parsers){const i=new Set(t.parsers.map(r=>r.name));this.parsers=this.parsers.filter(r=>!i.has(r.name))}this.completionsByPlugin.delete(e),this.plugins.delete(e),this.events.emit("plugin-removed",e)}}getToolbarItem(e){return this.toolbarItems.get(e)}getAllToolbarItems(){return this.toolbarItems}getShortcuts(){return this.shortcuts}getRenderers(){return this.renderers}getParsers(){return this.parsers}getCompletions(){const e=[];for(const t of this.completionsByPlugin.values())e.push(...t);return e}hasPlugin(e){return this.plugins.has(e)}getPlugin(e){return this.plugins.get(e)}createContext(e){return{editor:this.editorApi,registerToolbarItem:t=>this.toolbarItems.set(t.id,t),registerShortcut:t=>this.shortcuts.push(t),registerRenderer:t=>{this.renderers.push(t),this.renderers.sort((i,r)=>(r.priority??0)-(i.priority??0))},registerParser:t=>{this.parsers.push(t),this.parsers.sort((i,r)=>(r.priority??0)-(i.priority??0))},registerCompletion:t=>{const i=this.completionsByPlugin.get(e)??[];i.push(t),this.completionsByPlugin.set(e,i)},injectStyles:t=>this.injectStyles(t),emit:(t,i)=>this.events.emit(t,i),on:(t,i)=>this.events.on(t,i),off:(t,i)=>this.events.off(t,i)}}injectStyles(e){const t=document.createElement("style");t.setAttribute("data-syncline-mdx","plugin"),t.textContent=e,document.head.appendChild(t),this.styleElements.push(t)}destroy(){for(const[e]of this.plugins)this.unregister(e);for(const e of this.styleElements)e.remove();this.styleElements=[]}}function ai(){var e;if(typeof navigator>"u")return!1;const n=navigator;return(e=n.userAgentData)!=null&&e.platform?/mac/i.test(n.userAgentData.platform):navigator.platform?/mac/i.test(navigator.platform):/Macintosh|MacIntel|MacPPC|Mac OS X/.test(navigator.userAgent)}function de(n){return ai()?n.replace(/ctrl\+/gi,"⌘").replace(/shift\+/gi,"⇧").replace(/alt\+/gi,"⌥"):n.replace(/⌘/g,"Ctrl+").replace(/⇧/g,"Shift+").replace(/⌥/g,"Alt+")}class ce{constructor(e,t,i,r){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=r,this.activeDropdown=null,this.documentClickHandler=o=>{this.activeDropdown&&!this.activeDropdown.contains(o.target)&&this.closeDropdowns()}}render(e){this.el=document.createElement("div"),this.el.className="smdx-toolbar";for(const t of this.config){const i=document.createElement("div");i.className="smdx-toolbar-row",this.renderRow(t,i),this.el.appendChild(i)}return e.appendChild(this.el),document.addEventListener("click",this.documentClickHandler),this.el}renderRow(e,t){for(const i of e)typeof i=="string"?i==="|"?this.renderDivider(t):this.renderItem(i,t):"type"in i&&i.type==="divider"?this.renderDivider(t):"type"in i&&i.type==="group"&&this.renderGroup(i,t)}renderDivider(e){const t=document.createElement("span");t.className="smdx-toolbar-divider",e.appendChild(t)}renderItem(e,t){const i=this.pluginManager.getToolbarItem(e);if(i)if(i.children&&i.children.length>0)this.renderDropdownItem(i,t);else{const r=this.createButton(i);t.appendChild(r)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const r of e.items)typeof r=="string"?this.renderItem(r,i):this.renderGroup(r,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const r=document.createElement("button");r.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",r.type="button",r.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label||""}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,r.title=e.label||"",r.setAttribute("aria-label",e.label||"Dropdown"),r.setAttribute("aria-haspopup","true"),r.setAttribute("aria-expanded","false");const o=document.createElement("div");o.className="smdx-toolbar-dropdown-menu",o.setAttribute("role","menu"),o.style.display="none";for(const s of e.items)if(typeof s=="string"){const a=this.pluginManager.getToolbarItem(s);if(!a)continue;if(a.children&&a.children.length>0)this.renderSubmenu(a,o);else{const l=this.createMenuButton(a);o.appendChild(l)}}else{const a=document.createElement("div");if(a.className="smdx-toolbar-dropdown-section",s.label){const l=document.createElement("div");l.className="smdx-toolbar-dropdown-section-label",l.textContent=s.label,a.appendChild(l)}for(const l of s.items)if(typeof l=="string"){const d=this.pluginManager.getToolbarItem(l);if(d)if(d.children&&d.children.length>0)this.renderSubmenu(d,a);else{const h=this.createMenuButton(d);a.appendChild(h)}}o.appendChild(a)}r.addEventListener("click",s=>{s.stopPropagation(),this.toggleDropdown(o,i)}),i.appendChild(r),i.appendChild(o),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const r=document.createElement("button");r.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",r.type="button",r.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const o=e.tooltip||e.label,s=e.shortcutLabel?de(e.shortcutLabel):void 0;r.title=s?`${o} (${s})`:o,r.setAttribute("aria-label",s?`${o} (${s})`:o),r.setAttribute("aria-haspopup","true"),r.setAttribute("aria-expanded","false");const a=document.createElement("div");a.className="smdx-toolbar-dropdown-menu",a.setAttribute("role","menu"),a.style.display="none";for(const l of e.children)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const d=this.createMenuButton(l);a.appendChild(d)}r.addEventListener("click",l=>{l.stopPropagation(),this.toggleDropdown(a,i)}),i.appendChild(r),i.appendChild(a),t.appendChild(i)}positionMenu(e,t){const i=t.getBoundingClientRect(),r=4;let o=i.bottom+r,s=i.left;e.style.top=o+"px",e.style.left=s+"px",e.style.visibility="hidden",e.style.display="",requestAnimationFrame(()=>{const a=e.getBoundingClientRect();a.right>window.innerWidth-4&&(s=i.right-a.width,e.style.left=Math.max(4,s)+"px"),a.bottom>window.innerHeight-4&&(o=i.top-a.height-r,e.style.top=Math.max(4,o)+"px"),e.style.visibility=""})}renderSubmenu(e,t){const i=document.createElement("div");i.className="smdx-toolbar-submenu";const r=document.createElement("button");r.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",r.type="button",r.innerHTML=`${e.icon||""}<span>${e.label}</span><svg class="smdx-submenu-arrow" width="6" height="10" viewBox="0 0 6 10"><path d="M1 1l4 4-4 4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const o=document.createElement("div");o.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",o.style.display="none";for(const h of e.children)if(h.children&&h.children.length>0)this.renderSubmenu(h,o);else{const c=this.createMenuButton(h);o.appendChild(c)}const s=()=>{const h=i.getBoundingClientRect();o.style.left=`${h.right}px`,o.style.top=`${h.top}px`,requestAnimationFrame(()=>{const c=o.getBoundingClientRect();c.right>window.innerWidth&&(o.style.left=`${h.left-c.width}px`),c.bottom>window.innerHeight&&(o.style.top=`${window.innerHeight-c.height-8}px`)})};let a=null;const l=()=>{a&&(clearTimeout(a),a=null),o.style.display="",s()},d=()=>{a&&clearTimeout(a),a=setTimeout(()=>{o.style.display="none",a=null},120)};r.addEventListener("mouseenter",l),o.addEventListener("mouseenter",l),i.addEventListener("mouseleave",d),o.addEventListener("mouseleave",d),i.appendChild(r),i.appendChild(o),t.appendChild(i)}createButton(e){const t=document.createElement("button");t.className=`smdx-toolbar-btn${e.className?" "+e.className:""}`,t.type="button",t.tabIndex=0;const i=e.tooltip||e.label,r=e.shortcutLabel?de(e.shortcutLabel):void 0;return t.title=r?`${i} (${r})`:i,t.setAttribute("aria-label",r?`${i} (${r})`:i),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,r&&t.setAttribute("data-shortcut",r),t.addEventListener("click",o=>{o.preventDefault(),this.executeAction(e)}),e.render&&e.render(t,this.getActionContext()),t}createMenuButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-menu-btn${e.className?" "+e.className:""}`,t.type="button",t.setAttribute("role","menuitem"),t.dataset.toolbarId=e.id,t.innerHTML=`${e.icon||""}<span>${e.label}</span>${e.shortcutLabel?`<span class="smdx-shortcut-label">${de(e.shortcutLabel)}</span>`:""}`,t.addEventListener("click",i=>{i.preventDefault(),this.closeDropdowns(),this.executeAction(e)}),t}executeAction(e){var i;const t=this.getActionContext();(i=e.isDisabled)!=null&&i.call(e,t)||(e.action(t),this.events.emit("toolbar-action",e.id))}getActionContext(){return{editor:this.editorApi,selection:this.editorApi.getSelection()}}toggleDropdown(e,t){var i,r;if(e.style.display==="none"){this.closeDropdowns();const o=t.querySelector(".smdx-toolbar-dropdown-trigger");o?this.positionMenu(e,o):e.style.display="",this.activeDropdown=t,(i=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||i.setAttribute("aria-expanded","true")}else e.style.display="none",e.style.visibility="",(r=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||r.setAttribute("aria-expanded","false"),this.activeDropdown=null}closeDropdowns(){var e,t;(e=this.el)==null||e.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(i=>{i.style.display="none",i.style.visibility=""}),(t=this.el)==null||t.querySelectorAll('[aria-expanded="true"]').forEach(i=>{i.setAttribute("aria-expanded","false")}),this.activeDropdown=null}updateActiveStates(){var t;const e=this.getActionContext();(t=this.el)==null||t.querySelectorAll("[data-toolbar-id]").forEach(i=>{const r=i.dataset.toolbarId,o=this.pluginManager.getToolbarItem(r);o!=null&&o.isActive&&i.classList.toggle("smdx-active",o.isActive(e)),o!=null&&o.isDisabled&&(i.disabled=o.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const li=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),di=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function ci(n){return di.some(e=>n.startsWith(e))}const Me=/^on/i,hi=/^\s*javascript\s*:/i;function pi(n){if(typeof document>"u")return n;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${n}</body>`,"text/html"),i=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),r=[];let o=i.currentNode;for(;o;){if(o.nodeType===Node.ELEMENT_NODE){const s=o,a=s.tagName.toLowerCase();if(li.has(a))r.push(s);else if(a==="iframe"){const l=s.getAttribute("src")||"";if(!ci(l))r.push(s);else{const d=[];for(const h of Array.from(s.attributes))Me.test(h.name)&&d.push(h.name);for(const h of d)s.removeAttribute(h)}}else{const l=[];for(const d of Array.from(s.attributes))(Me.test(d.name)||(d.name==="href"||d.name==="src"||d.name==="action")&&hi.test(d.value))&&l.push(d.name);for(const d of l)s.removeAttribute(d)}}o=i.nextNode()}for(const s of r)s.remove();return t.body.innerHTML}const ui={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",py:"Python",python:"Python",java:"Java",rb:"Ruby",ruby:"Ruby",go:"Go",rust:"Rust",rs:"Rust",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",swift:"Swift",kt:"Kotlin",kotlin:"Kotlin",scala:"Scala",sh:"Shell",bash:"Bash",zsh:"Zsh",sql:"SQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",md:"Markdown",markdown:"Markdown",graphql:"GraphQL",dart:"Dart",r:"R",lua:"Lua",perl:"Perl",text:"Text",txt:"Text"};class $e{escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}renderBlock(e,t,i){let r;const o=i.trimEnd();try{e&&G.getLanguage(e)?r=G.highlight(o,{language:e}).value:r=G.highlightAuto(o).value}catch{r=this.escapeHtml(o)}const s=e?ui[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1):"",a=s?`<span class="smdx-code-lang">${s}</span>`:"",l=t?`<span class="smdx-code-filename"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>${this.escapeHtml(t)}</span>`:"",d='<button class="smdx-copy-btn" data-copy-btn="true" title="Copy code" aria-label="Copy code"><svg class="smdx-copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg><svg class="smdx-check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></button>',h=!!(s||t),c=h?`<div class="smdx-code-header">${a}${l}${d}</div>`:"";return`<div class="smdx-code-block${h?" smdx-has-header":""}">${c}<pre><code class="hljs language-${e||"text"}">${r}</code></pre>${h?"":d}</div>`}}class Le{parseTableRow(e){return e.split("|").slice(1,-1).map(t=>t.trim())}render(e){const t=/(?:^[ \t]*(\|.+\|)\n[ \t]*(\|[-| :]+\|)\n((?:[ \t]*\|.+\|\n?)*))/gm;return e.replace(t,(i,r,o,s)=>{const a=this.parseTableRow(r),l=s.trim().split(`
|
|
2
|
+
`).filter(Boolean).map(h=>this.parseTableRow(h));let d='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const h of a)d+=`<th>${h}</th>`;d+="</tr></thead><tbody>";for(const h of l){d+="<tr>";for(const c of h)d+=`<td>${c}</td>`;d+="</tr>"}return d+="</tbody></table></div>",d})}}class Be{isListItem(e){return/^\s*[-*]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)}buildNestedList(e){var l,d,h;if(e.length===0)return"";const t=((l=e[0].match(/^(\s*)/))==null?void 0:l[1].length)??0,i=/^\s*\d+\.\s+/.test(e[0]),r=i?"ol":"ul",o=i?"smdx-ol-item":"smdx-ul-item";let s=`<${r}>`,a=0;for(;a<e.length;){const c=e[a],p=((d=c.match(/^(\s*)/))==null?void 0:d[1].length)??0;if(p<t)break;if(p>t){a++;continue}const m=i?c.replace(/^\s*\d+\.\s+/,""):c.replace(/^\s*[-*]\s+/,"");a++;const g=[];for(;a<e.length&&((((h=e[a].match(/^(\s*)/))==null?void 0:h[1].length)??0)>t&&this.isListItem(e[a]));)g.push(e[a]),a++;const f=g.length>0?this.buildNestedList(g):"";s+=`<li class="${o}">${m}${f}</li>`}return s+=`</${r}>`,s}render(e){const t=e.split(`
|
|
3
|
+
`),i=[];let r=0;for(;r<t.length;)if(this.isListItem(t[r])){const o=[];for(;r<t.length&&this.isListItem(t[r]);)o.push(t[r]),r++;i.push(this.buildNestedList(o))}else i.push(t[r]),r++;return i.join(`
|
|
4
|
+
`)}}class Ae{constructor(){this.codeRenderer=new $e,this.tableRenderer=new Le,this.listRenderer=new Be}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}render(e){let t=e;const i=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(o,s,a,l)=>{const d=i.length;return i.push(this.codeRenderer.renderBlock(s,a,l)),`%%CODEBLOCK_${d}%%`}),t=t.replace(/`([^`]+)`/g,(o,s)=>`<code class="smdx-inline-code">${this.escapeHtml(s)}</code>`);const r=o=>o.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(o,s)=>`<h6 id="${r(s)}">${s}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(o,s)=>`<h5 id="${r(s)}">${s}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(o,s)=>`<h4 id="${r(s)}">${s}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(o,s)=>`<h3 id="${r(s)}">${s}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(o,s)=>`<h2 id="${r(s)}">${s}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(o,s)=>`<h1 id="${r(s)}">${s}</h1>`),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/^>\s+(.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^- \[x\]\s+(.+)$/gm,'<div class="smdx-task"><span class="smdx-task-checkbox smdx-task-checked" role="checkbox" aria-checked="true" tabindex="0"></span><span>$1</span></div>'),t=t.replace(/^- \[ \]\s+(.+)$/gm,'<div class="smdx-task"><span class="smdx-task-checkbox" role="checkbox" aria-checked="false" tabindex="0"></span><span>$1</span></div>'),t=this.listRenderer.render(t),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="smdx-image"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=this.tableRenderer.render(t),t=t.replace(/ {2,}$/gm,"<br/>"),t=t.replace(/^(?!\s*<[a-zA-Z/!]|\s*%%)(.*\S.*)$/gm,"<p>$1</p>"),t=t.replace(/<p>\s*<\/p>/g,"");for(let o=0;o<i.length;o++)t=t.replace(`%%CODEBLOCK_${o}%%`,i[o]);return t}}class Ie{validate(e){const t=[];let i=e.replace(/```[\s\S]*?```/g,"");i=i.replace(/`[^`]+`/g,"");const r=[],o=i.split(`
|
|
5
|
+
`);for(let s=0;s<o.length;s++){const a=o[s];let l;const d=/<\/?([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?\/?>|<([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?>/g;for(;(l=d.exec(a))!==null;){const h=l[0];if(h.endsWith("/>"))continue;const c=l[1]||l[2];if(!c)continue;const p=l.index+1;if(h.startsWith("</")){let g=!1;for(let f=r.length-1;f>=0;f--)if(r[f].tag===c){r.splice(f,1),g=!0;break}g||t.push(`Unexpected closing tag '</${c}>' at line ${s+1}:${p} — no matching opening tag found.`)}else r.push({tag:c,line:s+1,col:p})}}for(const s of r)t.push(`Expected a closing tag for '<${s.tag}>' (${s.line}:${s.col}) before the end of the document.`);return t}}class Q{constructor(){this.renderers=[],this.parsers=[],this.markdownRenderer=new Ae,this.mdxValidator=new Ie}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const i=this.mdxValidator.validate(e),r=[];t=t.replace(/`([^`\n]+)`/g,(o,s)=>{const a=r.length;return r.push(s),`%%INLINECODE_${a}%%`});for(const o of this.parsers)t=t.replace(o.pattern,(...s)=>o.transform(s));for(const o of this.renderers)t=t.replace(o.pattern,(s,...a)=>{const l={};return a.length>0&&(l.content=a[0]||""),o.render(s,l)});for(let o=0;o<r.length;o++)t=t.replace(`%%INLINECODE_${o}%%`,`\`${r[o]}\``);if(t=this.markdownRenderer.render(t),i.length>0){const o=a=>a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");t=i.map(a=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">⚠</span> ${o(a)}</div>`).join("")+t}return pi(t)}}const se=class se{constructor(e,t,i){this.isDragging=!1,this.startX=0,this.startLeftWidth=0,this.onResizeCallback=null,this.resizeRafId=null,this.onMouseDown=r=>{this.startDrag(r.clientX),r.preventDefault()},this.onMouseMove=r=>{this.isDragging&&this.moveDrag(r.clientX)},this.onMouseUp=()=>{this.endDrag()},this.onTouchStart=r=>{r.touches.length===1&&(this.startDrag(r.touches[0].clientX),r.preventDefault())},this.onTouchMove=r=>{!this.isDragging||r.touches.length!==1||(this.moveDrag(r.touches[0].clientX),r.preventDefault())},this.onTouchEnd=()=>{this.endDrag()},this.onKeyDown=r=>{if(r.key!=="ArrowLeft"&&r.key!=="ArrowRight")return;r.preventDefault();const o=this.container.getBoundingClientRect().width;if(o<=0)return;const s=this.left.getBoundingClientRect().width,a=o*se.KEYBOARD_STEP_PERCENT,l=r.key==="ArrowRight"?a:-a;let d=(s+l)/o*100;d=Math.max(20,Math.min(80,d)),this.left.style.flex=`0 0 ${d}%`,this.right.style.flex="1 1 0",this.notifyResize()},this.container=e,this.left=t,this.right=i,this.splitter=document.createElement("div"),this.splitter.className="smdx-splitter",this.splitter.setAttribute("role","separator"),this.splitter.setAttribute("aria-label","Resize editor and preview"),this.splitter.setAttribute("tabindex","0"),t.after(this.splitter),this.splitter.addEventListener("mousedown",this.onMouseDown),document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp),this.splitter.addEventListener("touchstart",this.onTouchStart,{passive:!1}),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.splitter.addEventListener("keydown",this.onKeyDown)}onResize(e){this.onResizeCallback=e}startDrag(e){this.isDragging=!0,this.startX=e,this.startLeftWidth=this.left.getBoundingClientRect().width,document.body.style.cursor="col-resize",document.body.style.userSelect="none",this.right.style.pointerEvents="none"}moveDrag(e){const t=e-this.startX,i=this.container.getBoundingClientRect().width;if(i<=0)return;let r=(this.startLeftWidth+t)/i*100;r=Math.max(20,Math.min(80,r)),this.left.style.flex=`0 0 ${r}%`,this.right.style.flex="1 1 0",this.notifyResize()}endDrag(){this.isDragging&&(this.isDragging=!1,document.body.style.cursor="",document.body.style.userSelect="",this.right.style.pointerEvents="",this.notifyResize())}notifyResize(){var e;this.resizeRafId===null&&(typeof requestAnimationFrame<"u"?this.resizeRafId=requestAnimationFrame(()=>{var t;this.resizeRafId=null,(t=this.onResizeCallback)==null||t.call(this)}):(e=this.onResizeCallback)==null||e.call(this))}destroy(){document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.splitter.removeEventListener("mousedown",this.onMouseDown),this.splitter.removeEventListener("touchstart",this.onTouchStart),this.splitter.removeEventListener("keydown",this.onKeyDown),this.resizeRafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.resizeRafId),this.splitter.remove()}};se.KEYBOARD_STEP_PERCENT=.02;let ee=se;var mi=Object.defineProperty,gi=(n,e,t)=>e in n?mi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e,t)=>gi(n,typeof e!="symbol"?e+"":e,t);const bi={typescript:"//",javascript:"//",css:"//",json:"",markdown:"",text:""},he=new Set(["function","const","let","var","return","if","else","for","while","class","import","export","default","async","await","new","this","typeof","instanceof","try","catch","finally","throw","extends","interface","type","readonly","private","public","protected","static","override","implements","enum","namespace","declare","abstract","as","from","of","in","void","switch","case","break","continue","do","delete","yield","super","null","true","false","undefined","require","constructor"]),fi=new Set(["function","const","let","var","return","if","else","for","while","class","import","export","default","async","await","new","this","typeof","instanceof","try","catch","finally","throw","extends","as","from","of","in","void","switch","case","break","continue","do","delete","yield","super","null","true","false","undefined","require","constructor","static"]),xi=new Set(["media","keyframes","import","charset","supports","layer","container","namespace","page","static","relative","absolute","fixed","sticky","block","inline","flex","grid","none","contents","table","hidden","visible","scroll","clip","auto","bold","normal","italic","underline","uppercase","lowercase","capitalize","left","right","center","justify","inherit","initial","unset","revert","pointer","default","transparent","solid","dashed","dotted","double","cover","contain","no-repeat","repeat","var","calc","min","max","clamp"]),yi=new Set(["null","true","false"]),Pe=new Set,pe=new Set(["number","string","boolean","any","never","unknown","object","Promise","Array","Map","Set","Record","Partial","Required","Readonly","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),vi=new Set(["number","string","boolean","object","Promise","Array","Map","Set","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),ki=new Set,wi=new Set,Re=new Set,He={typescript:he,javascript:fi,css:xi,json:yi,markdown:Pe,text:Pe},De={typescript:pe,javascript:vi,css:ki,json:wi,markdown:Re,text:Re};function je(n,e){return{fileId:n,doc:[...e],cur:{row:0,col:0},sel:null,dirty:!1,undoStack:[],redoStack:[],scrollTop:0}}function M(n,e=300){const t={doc:[...n.doc],cur:{...n.cur},sel:n.sel?{...n.sel}:null};n.undoStack.push(t),n.undoStack.length>e&&n.undoStack.shift(),n.redoStack=[],n.dirty=!0}function _i(n){if(!n.undoStack.length)return!1;const e={doc:[...n.doc],cur:{...n.cur},sel:n.sel?{...n.sel}:null};n.redoStack.push(e);const t=n.undoStack.pop();return n.doc=t.doc,n.cur=t.cur,n.sel=t.sel,!0}function Ci(n){if(!n.redoStack.length)return!1;const e={doc:[...n.doc],cur:{...n.cur},sel:n.sel?{...n.sel}:null};n.undoStack.push(e);const t=n.redoStack.pop();return n.doc=t.doc,n.cur=t.cur,n.sel=t.sel,!0}function L(n){const{doc:e,cur:t}=n;t.row=Math.max(0,Math.min(e.length-1,t.row)),t.col=Math.max(0,Math.min((e[t.row]??"").length,t.col))}function N(n){const{ar:e,ac:t,fr:i,fc:r}=n;return e<i||e===i&&t<=r?n:{ar:i,ac:r,fr:e,fc:t}}function Ne(n,e,t){if(!n)return null;const i=N(n);return e<i.ar||e>i.fr?null:{start:e===i.ar?i.ac:0,end:e===i.fr?i.fc:t}}function Ti(n){if(!n.sel)return 0;const e=N(n.sel);let t=0;for(let i=e.ar;i<=e.fr;i++){const r=n.doc[i]??"",o=i===e.ar?e.ac:0,s=i===e.fr?e.fc:r.length;t+=s-o}return t}function Oe(n){if(!n.sel)return"";const e=N(n.sel),t=[];for(let i=e.ar;i<=e.fr;i++){const r=n.doc[i]??"";t.push(r.slice(i===e.ar?e.ac:0,i===e.fr?e.fc:r.length))}return t.join(`
|
|
6
|
+
`)}function q(n){const e=n.sel;if(!e)return n.cur;const t=N(e),i=(n.doc[t.ar]??"").slice(0,t.ac),r=(n.doc[t.fr]??"").slice(t.fc);return n.doc.splice(t.ar,t.fr-t.ar+1,i+r),n.sel=null,{row:t.ar,col:t.ac}}function Ei(n,e,t){if(!t||n.length<=e)return[n];const i=[];let r=0;for(;r<n.length;){if(n.length-r<=e){i.push(n.slice(r));break}const o=r+e;let s=-1;for(let a=o;a>r;a--)if(n[a-1]===" "){s=a;break}s===-1?(i.push(n.slice(r,o)),r=o):(i.push(n.slice(r,s)),r=s)}return i}function Si(n,e,t,i){const r=[],o=[],s=[];let a=-1;for(let l=0;l<n.length;l++){if(l>0&&l<=a){s.push(o.length),r.push([n[l]??""]);continue}s.push(o.length);const d=Ei(n[l]??"",e,t);r.push(d),d.forEach((h,c)=>o.push({docLine:l,segIdx:c,text:h})),i.has(l)&&(a=i.get(l))}return{segments:r,visualRows:o,docToVisArr:s}}function U(n,e,t){const i=n.segments[e]??[""];let r=t;for(let o=0;o<i.length;o++){if(r<=i[o].length||o===i.length-1)return{visRow:n.docToVisArr[e]+o,colInSeg:Math.min(r,i[o].length)};r-=i[o].length}return{visRow:n.docToVisArr[e]??0,colInSeg:0}}function te(n,e,t){var i;const r=n.visualRows[e];if(!r)return{row:0,col:0};const o=n.segments[r.docLine]??[""];let s=Math.min(t,((i=o[r.segIdx])==null?void 0:i.length)??0);for(let a=0;a<r.segIdx;a++)s+=o[a].length;return{row:r.docLine,col:s}}function ue(n,e={}){var t,i;const r=[],o=n.length;let s=0;const a=(p,m,g)=>{g>m&&r.push({cls:p,start:m,end:g})},l=He[e.language??"typescript"]??he,d=De[e.language??"typescript"]??pe,h=(t=e.extraKeywords)!=null&&t.size?new Set([...l,...e.extraKeywords]):l,c=(i=e.extraTypes)!=null&&i.size?new Set([...d,...e.extraTypes]):d;for(;s<o;){if(n[s]==="/"&&n[s+1]==="/"){a("cmt",s,o);break}if(n[s]==="*"||n[s]==="/"&&n[s+1]==="*"){a("cmt",s,o);break}if(n[s]==="@"){let p=s+1;for(;p<o&&/\w/.test(n[p]);)p++;a("dec",s,p),s=p;continue}if(n[s]==='"'||n[s]==="'"||n[s]==="`"){const p=n[s];let m=s+1;for(;m<o;){if(n[m]==="\\"){m+=2;continue}if(n[m]===p){m++;break}m++}a("str",s,m),s=m;continue}if(/\d/.test(n[s])&&(s===0||!/\w/.test(n[s-1]))){let p=s;for(;p<o&&/[\d._xXa-fA-F]/.test(n[p]);)p++;a("num",s,p),s=p;continue}if(/[a-zA-Z_$]/.test(n[s])){let p=s;for(;p<o&&/[\w$]/.test(n[p]);)p++;const m=n.slice(s,p);h.has(m)?a("kw",s,p):c.has(m)?a("typ",s,p):p<o&&n[p]==="("?a("fn",s,p):/^[A-Z]/.test(m)&&a("cls",s,p),s=p;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(n[s])){a("op",s,s+1),s++;continue}s++}return r}function We(n,e){const t=new Array(n.length).fill("");for(const i of e)for(let r=i.start;r<i.end;r++)t[r]=i.cls;return t}class Mi{constructor(e=5e3){y(this,"_cache",new Map),y(this,"_maxSize"),y(this,"_hits",0),y(this,"_misses",0),y(this,"_evictions",0),this._maxSize=e}get metrics(){return{hits:this._hits,misses:this._misses,evictions:this._evictions,size:this._cache.size}}get(e,t){const i=this._cache.get(e);return i&&i.src===t?(this._hits++,i.segs):(this._misses++,null)}set(e,t,i){this._cache.size>=this._maxSize&&(this._cache.delete(this._cache.keys().next().value),this._evictions++),this._cache.set(e,{src:t,segs:i})}invalidateLine(e,t){for(let i=0;i<t;i++)this._cache.delete(`${e}:${i}`)}clear(){this._cache.clear(),this._hits=0,this._misses=0,this._evictions=0}resetMetrics(){this._hits=0,this._misses=0,this._evictions=0}}const $i={id:"",name:"VR Dark",description:"Default deep dark theme",light:!1,tokens:{bg0:"#0d0d0f",bg1:"#111115",bg2:"#16161b",bg3:"#1d1d24",bg4:"#24242d",border:"rgba(255,255,255,.07)",border2:"rgba(255,255,255,.12)",border3:"rgba(255,255,255,.19)",text:"#c9c7c0",text2:"#8b8994",text3:"#4e4c58",accent:"#6e9fff",accent2:"#2f5db0",green:"#4ec9a0",orange:"#d4976e",purple:"#b48eff",red:"#f28b82",yellow:"#e8c97a",cur:"#6e9fff",curGlow:"rgba(110,159,255,.65)",curLineBg:"rgba(255,255,255,.032)",curLineGutter:"#181820",gutterBg:"#0f0f12",gutterHover:"#181820",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#4e4c58",gutterNumAct:"#9997a2",selBg:"rgba(110,159,255,.22)",wordHlBg:"rgba(200,198,210,.09)",wordHlBorder:"rgba(200,198,210,.28)",bmBorder:"rgba(110,159,255,.65)",foldBg:"rgba(110,159,255,.07)",foldBorder:"rgba(110,159,255,.30)",findBg:"rgba(234,180,86,.18)",findBorder:"rgba(234,180,86,.50)",findCurBg:"rgba(234,180,86,.80)",findCurBorder:"rgba(234,180,86,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(110,159,255,.11)",fileActiveText:"#6e9fff",mmBg:"#0d0d0f",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#6e9fff",tokStr:"#4ec9a0",tokCmt:"#4e4c58",tokFn:"#d4976e",tokNum:"#b48eff",tokCls:"#e8c97a",tokOp:"#55536a",tokTyp:"#6ec9d4",tokDec:"#f28b82"}},Li={id:"vscode-dark",name:"VSCode Dark+",description:"Visual Studio Code dark",light:!1,tokens:{bg0:"#1e1e1e",bg1:"#252526",bg2:"#1e1e1e",bg3:"#2d2d30",bg4:"#3a3a3d",border:"rgba(255,255,255,.09)",border2:"rgba(255,255,255,.15)",border3:"rgba(255,255,255,.24)",text:"#d4d4d4",text2:"#9a9a9a",text3:"#505050",accent:"#569cd6",accent2:"#0e639c",green:"#4ec9b0",orange:"#ce9178",purple:"#c586c0",red:"#f44747",yellow:"#dcdcaa",cur:"#aeafad",curGlow:"rgba(174,175,173,.40)",curLineBg:"rgba(255,255,255,.038)",curLineGutter:"#282828",gutterBg:"#1e1e1e",gutterHover:"#282828",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#838383",gutterNumAct:"#c8c8c8",selBg:"rgba(38,79,120,.65)",wordHlBg:"rgba(173,214,255,.06)",wordHlBorder:"rgba(173,214,255,.28)",bmBorder:"rgba(86,156,214,.70)",foldBg:"rgba(86,156,214,.07)",foldBorder:"rgba(86,156,214,.35)",findBg:"rgba(255,215,0,.13)",findBorder:"rgba(255,215,0,.52)",findCurBg:"#f6f6a0",findCurBorder:"#d4d400",findCurText:"#000",fileActiveBg:"rgba(255,255,255,.07)",fileActiveText:"#d4d4d4",mmBg:"#1e1e1e",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#569cd6",tokStr:"#ce9178",tokCmt:"#6a9955",tokFn:"#dcdcaa",tokNum:"#b5cea8",tokCls:"#4ec9b0",tokOp:"#d4d4d4",tokTyp:"#4ec9b0",tokDec:"#9cdcfe"}},Bi={id:"monokai",name:"Monokai",description:"Classic Sublime Text theme",light:!1,tokens:{bg0:"#272822",bg1:"#1e1f1c",bg2:"#272822",bg3:"#3a3930",bg4:"#48473d",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.13)",border3:"rgba(255,255,255,.20)",text:"#f8f8f2",text2:"#a8a7a0",text3:"#58574e",accent:"#a6e22e",accent2:"#3d5a10",green:"#a6e22e",orange:"#fd971f",purple:"#ae81ff",red:"#f92672",yellow:"#e6db74",cur:"#f8f8f2",curGlow:"rgba(248,248,242,.25)",curLineBg:"rgba(255,255,255,.042)",curLineGutter:"#2c2d27",gutterBg:"#1e1f1c",gutterHover:"#2c2d27",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#6e6d64",gutterNumAct:"#cccac0",selBg:"rgba(73,72,62,.80)",wordHlBg:"rgba(248,248,242,.06)",wordHlBorder:"rgba(248,248,242,.22)",bmBorder:"rgba(166,226,46,.65)",foldBg:"rgba(166,226,46,.07)",foldBorder:"rgba(166,226,46,.30)",findBg:"rgba(230,219,116,.16)",findBorder:"rgba(230,219,116,.52)",findCurBg:"#e6db74",findCurBorder:"#c9be50",findCurText:"#272822",fileActiveBg:"rgba(166,226,46,.10)",fileActiveText:"#a6e22e",mmBg:"#1e1f1c",mmSlider:"rgba(255,255,255,.06)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#f92672",tokStr:"#e6db74",tokCmt:"#75715e",tokFn:"#a6e22e",tokNum:"#ae81ff",tokCls:"#66d9e8",tokOp:"#f8f8f2",tokTyp:"#66d9e8",tokDec:"#fd971f"}},Ai={id:"dracula",name:"Dracula",description:"Purple-tinted dark theme",light:!1,tokens:{bg0:"#282a36",bg1:"#21222c",bg2:"#282a36",bg3:"#333545",bg4:"#44475a",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.14)",border3:"rgba(255,255,255,.22)",text:"#f8f8f2",text2:"#b2b5c8",text3:"#5a5e78",accent:"#bd93f9",accent2:"#5b3fa8",green:"#50fa7b",orange:"#ffb86c",purple:"#bd93f9",red:"#ff5555",yellow:"#f1fa8c",cur:"#f8f8f2",curGlow:"rgba(189,147,249,.55)",curLineBg:"rgba(255,255,255,.045)",curLineGutter:"#2f3144",gutterBg:"#21222c",gutterHover:"#2f3144",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#5e638a",gutterNumAct:"#f8f8f2",selBg:"rgba(68,71,90,.85)",wordHlBg:"rgba(248,248,242,.05)",wordHlBorder:"rgba(248,248,242,.20)",bmBorder:"rgba(189,147,249,.70)",foldBg:"rgba(189,147,249,.08)",foldBorder:"rgba(189,147,249,.35)",findBg:"rgba(241,250,140,.14)",findBorder:"rgba(241,250,140,.52)",findCurBg:"#f1fa8c",findCurBorder:"#d4dc50",findCurText:"#282a36",fileActiveBg:"rgba(189,147,249,.12)",fileActiveText:"#bd93f9",mmBg:"#21222c",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#ff79c6",tokStr:"#f1fa8c",tokCmt:"#6272a4",tokFn:"#50fa7b",tokNum:"#bd93f9",tokCls:"#8be9fd",tokOp:"#f8f8f2",tokTyp:"#8be9fd",tokDec:"#ffb86c"}},Ii={id:"github-light",name:"GitHub Light",description:"GitHub's clean light theme",light:!0,tokens:{bg0:"#ffffff",bg1:"#f6f8fa",bg2:"#ffffff",bg3:"#f0f3f6",bg4:"#e7eaee",border:"#d0d7de",border2:"#bdc4cc",border3:"#aab1ba",text:"#1f2328",text2:"#57606a",text3:"#8c959f",accent:"#0969da",accent2:"#0550ae",green:"#1a7f37",orange:"#bc4c00",purple:"#8250df",red:"#cf222e",yellow:"#7d4e00",cur:"#0969da",curGlow:"rgba(9,105,218,.30)",curLineBg:"rgba(9,105,218,.055)",curLineGutter:"#ebf0f8",gutterBg:"#f6f8fa",gutterHover:"#eaedf1",gutterBorder:"#d0d7de",gutterNum:"#9da5b0",gutterNumAct:"#1f2328",selBg:"rgba(9,105,218,.15)",wordHlBg:"rgba(9,105,218,.07)",wordHlBorder:"rgba(9,105,218,.28)",bmBorder:"rgba(9,105,218,.60)",foldBg:"rgba(9,105,218,.06)",foldBorder:"rgba(9,105,218,.28)",findBg:"rgba(180,100,0,.09)",findBorder:"rgba(180,100,0,.42)",findCurBg:"rgba(180,100,0,.75)",findCurBorder:"rgba(180,100,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(9,105,218,.09)",fileActiveText:"#0969da",mmBg:"#f6f8fa",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.09)",tokKw:"#cf222e",tokStr:"#0a3069",tokCmt:"#6e7781",tokFn:"#8250df",tokNum:"#0550ae",tokCls:"#953800",tokOp:"#1f2328",tokTyp:"#0550ae",tokDec:"#0969da"}},Pi={id:"solarized-light",name:"Solarized Light",description:"Warm precision light theme",light:!0,tokens:{bg0:"#fdf6e3",bg1:"#eee8d5",bg2:"#fdf6e3",bg3:"#e5dfcc",bg4:"#dad4c1",border:"#cdc7b4",border2:"#bab4a2",border3:"#a9a390",text:"#002b36",text2:"#586e75",text3:"#93a1a1",accent:"#268bd2",accent2:"#1a6fa8",green:"#859900",orange:"#cb4b16",purple:"#6c71c4",red:"#dc322f",yellow:"#b58900",cur:"#268bd2",curGlow:"rgba(38,139,210,.32)",curLineBg:"rgba(38,139,210,.07)",curLineGutter:"#e2dcc8",gutterBg:"#eee8d5",gutterHover:"#e2dcc8",gutterBorder:"#cdc7b4",gutterNum:"#93a1a1",gutterNumAct:"#002b36",selBg:"rgba(38,139,210,.18)",wordHlBg:"rgba(38,139,210,.08)",wordHlBorder:"rgba(38,139,210,.28)",bmBorder:"rgba(38,139,210,.58)",foldBg:"rgba(38,139,210,.07)",foldBorder:"rgba(38,139,210,.28)",findBg:"rgba(181,137,0,.11)",findBorder:"rgba(181,137,0,.42)",findCurBg:"rgba(181,137,0,.75)",findCurBorder:"rgba(181,137,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(38,139,210,.10)",fileActiveText:"#268bd2",mmBg:"#eee8d5",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.16)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#859900",tokStr:"#2aa198",tokCmt:"#93a1a1",tokFn:"#268bd2",tokNum:"#d33682",tokCls:"#b58900",tokOp:"#657b83",tokTyp:"#268bd2",tokDec:"#cb4b16"}},Ri={id:"mdx-dark",name:"MDX Dark",description:"Catppuccin Mocha — matches .smdx-dark MDX editor chrome, single-colour tokens",light:!1,tokens:{bg0:"#181825",bg1:"#1e1e2e",bg2:"#1e1e2e",bg3:"#2a2a3c",bg4:"#313147",border:"#374151",border2:"rgba(129,140,248,.22)",border3:"rgba(129,140,248,.40)",text:"#e2e8f0",text2:"#94a3b8",text3:"#475569",accent:"#818cf8",accent2:"#6366f1",green:"#c3e88d",orange:"#f78c6c",purple:"#c792ea",red:"#f07178",yellow:"#ffcb6b",cur:"#818cf8",curGlow:"rgba(129,140,248,.55)",curLineBg:"rgba(129,140,248,.055)",curLineGutter:"#252540",gutterBg:"#181825",gutterHover:"#252540",gutterBorder:"#374151",gutterNum:"#475569",gutterNumAct:"#94a3b8",selBg:"rgba(129,140,248,.24)",wordHlBg:"rgba(226,232,240,.07)",wordHlBorder:"rgba(226,232,240,.25)",bmBorder:"rgba(137,221,255,.70)",foldBg:"rgba(129,140,248,.07)",foldBorder:"rgba(129,140,248,.30)",findBg:"rgba(251,191,36,.16)",findBorder:"rgba(251,191,36,.50)",findCurBg:"rgba(251,191,36,.85)",findCurBorder:"rgba(251,191,36,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(129,140,248,.12)",fileActiveText:"#818cf8",mmBg:"#181825",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#e2e8f0",tokStr:"#e2e8f0",tokCmt:"#e2e8f0",tokFn:"#e2e8f0",tokNum:"#e2e8f0",tokCls:"#e2e8f0",tokOp:"#e2e8f0",tokTyp:"#e2e8f0",tokDec:"#e2e8f0"}},Hi={id:"mdx-light",name:"MDX Light",description:"Clean light — matches default .smdx-editor MDX chrome, single-colour tokens",light:!0,tokens:{bg0:"#f1f5f9",bg1:"#ffffff",bg2:"#ffffff",bg3:"#f8fafc",bg4:"#f1f5f9",border:"#e2e8f0",border2:"rgba(99,102,241,.20)",border3:"rgba(99,102,241,.40)",text:"#1e293b",text2:"#64748b",text3:"#94a3b8",accent:"#6366f1",accent2:"#4f46e5",green:"#15803d",orange:"#c2410c",purple:"#7c3aed",red:"#dc2626",yellow:"#b45309",cur:"#6366f1",curGlow:"rgba(99,102,241,.35)",curLineBg:"rgba(99,102,241,.05)",curLineGutter:"#eef2ff",gutterBg:"#f8fafc",gutterHover:"#eef2ff",gutterBorder:"#e2e8f0",gutterNum:"#94a3b8",gutterNumAct:"#475569",selBg:"rgba(99,102,241,.18)",wordHlBg:"rgba(99,102,241,.07)",wordHlBorder:"rgba(99,102,241,.30)",bmBorder:"rgba(14,116,144,.60)",foldBg:"rgba(99,102,241,.06)",foldBorder:"rgba(99,102,241,.28)",findBg:"rgba(180,83,9,.09)",findBorder:"rgba(180,83,9,.40)",findCurBg:"rgba(180,83,9,.75)",findCurBorder:"rgba(180,83,9,.95)",findCurText:"#ffffff",fileActiveBg:"rgba(99,102,241,.10)",fileActiveText:"#6366f1",mmBg:"#f8fafc",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.05)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#1e293b",tokStr:"#1e293b",tokCmt:"#1e293b",tokFn:"#1e293b",tokNum:"#1e293b",tokCls:"#1e293b",tokOp:"#1e293b",tokTyp:"#1e293b",tokDec:"#1e293b"}},Di=[$i,Li,Bi,Ai,Ii,Pi,Ri,Hi],ji={bg0:"--bg0",bg1:"--bg1",bg2:"--bg2",bg3:"--bg3",bg4:"--bg4",border:"--border",border2:"--border2",border3:"--border3",text:"--text",text2:"--text2",text3:"--text3",accent:"--accent",accent2:"--accent2",green:"--green",orange:"--orange",purple:"--purple",red:"--red",yellow:"--yellow",cur:"--cur",curGlow:"--cur-glow",curLineBg:"--cur-line-bg",curLineGutter:"--cur-line-gutter",gutterBg:"--gutter-bg",gutterHover:"--gutter-hover",gutterBorder:"--gutter-border",gutterNum:"--gutter-num",gutterNumAct:"--gutter-num-act",selBg:"--sel-bg",wordHlBg:"--word-hl-bg",wordHlBorder:"--word-hl-border",bmBorder:"--bm-border",foldBg:"--fold-bg",foldBorder:"--fold-border",findBg:"--find-bg",findBorder:"--find-border",findCurBg:"--find-cur-bg",findCurBorder:"--find-cur-border",findCurText:"--find-cur-text",fileActiveBg:"--file-active-bg",fileActiveText:"--file-active-text",mmBg:"--mm-bg",mmSlider:"--mm-slider",mmDim:"--mm-dim",mmEdge:"--mm-edge",indentGuide:"--indent-guide",tokKw:"--tok-kw",tokStr:"--tok-str",tokCmt:"--tok-cmt",tokFn:"--tok-fn",tokNum:"--tok-num",tokCls:"--tok-cls",tokOp:"--tok-op",tokTyp:"--tok-typ",tokDec:"--tok-dec"};class Ni{constructor(e){y(this,"_registry",new Map),y(this,"_activeId",""),y(this,"_root"),this._root=e;for(const t of Di)this._registry.set(t.id,t)}register(e){this._registry.set(e.id,e)}apply(e){let t;typeof e=="string"?(t=this._registry.get(e),t||(console.warn(`[syncline-editor] Unknown theme: "${e}". Falling back to VR Dark.`),t=this._registry.get(""))):(t=e,this._registry.set(t.id,t)),this._activeId=t.id,this._applyTokens(t.tokens)}get activeId(){return this._activeId}get activeTheme(){return this._registry.get(this._activeId)}get allIds(){return[...this._registry.keys()]}get all(){return[...this._registry.values()]}_applyTokens(e){const t=this._root.style;for(const[i,r]of Object.entries(ji))t.setProperty(r,e[i])}}const Oi=`
|
|
7
|
+
/* ── Reset ── */
|
|
8
|
+
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
9
|
+
|
|
10
|
+
/* ── Host element ── */
|
|
11
|
+
:host,.sl-host{
|
|
12
|
+
display:flex;flex-direction:column;
|
|
13
|
+
height:100%;overflow:hidden;
|
|
14
|
+
font-family:var(--sans,'Geist',system-ui,sans-serif);
|
|
15
|
+
color:var(--text,#c9c7c0);
|
|
16
|
+
background:var(--bg0,#0d0d0f);
|
|
17
|
+
|
|
18
|
+
/* Default token vars (can be overridden by theme) */
|
|
19
|
+
--sans:'Geist',system-ui,sans-serif;
|
|
20
|
+
--mono:'JetBrains Mono',monospace;
|
|
21
|
+
|
|
22
|
+
/* ── VR Dark defaults ── */
|
|
23
|
+
--bg0:#0d0d0f; --bg1:#111115; --bg2:#16161b; --bg3:#1d1d24; --bg4:#24242d;
|
|
24
|
+
--border:rgba(255,255,255,.07);
|
|
25
|
+
--border2:rgba(255,255,255,.12);
|
|
26
|
+
--border3:rgba(255,255,255,.19);
|
|
27
|
+
--text:#c9c7c0; --text2:#8b8994; --text3:#4e4c58;
|
|
28
|
+
--accent:#6e9fff; --accent2:#2f5db0;
|
|
29
|
+
--green:#4ec9a0; --orange:#d4976e; --purple:#b48eff;
|
|
30
|
+
--red:#f28b82; --yellow:#e8c97a;
|
|
31
|
+
--cur:#6e9fff; --cur-glow:rgba(110,159,255,.65);
|
|
32
|
+
--cur-line-bg:rgba(255,255,255,.032);
|
|
33
|
+
--cur-line-gutter:#181820;
|
|
34
|
+
--gutter-bg:#0f0f12; --gutter-hover:#181820;
|
|
35
|
+
--gutter-border:rgba(255,255,255,.06);
|
|
36
|
+
--gutter-num:#4e4c58; --gutter-num-act:#9997a2;
|
|
37
|
+
--sel-bg:rgba(110,159,255,.22);
|
|
38
|
+
--word-hl-bg:rgba(200,198,210,.09);
|
|
39
|
+
--word-hl-border:rgba(200,198,210,.28);
|
|
40
|
+
--bm-border:rgba(110,159,255,.65);
|
|
41
|
+
--fold-bg:rgba(110,159,255,.07);
|
|
42
|
+
--fold-border:rgba(110,159,255,.30);
|
|
43
|
+
--find-bg:rgba(234,180,86,.18);
|
|
44
|
+
--find-border:rgba(234,180,86,.50);
|
|
45
|
+
--find-cur-bg:rgba(234,180,86,.80);
|
|
46
|
+
--find-cur-border:rgba(234,180,86,.95);
|
|
47
|
+
--find-cur-text:#1a1000;
|
|
48
|
+
--file-active-bg:rgba(110,159,255,.11);
|
|
49
|
+
--file-active-text:#6e9fff;
|
|
50
|
+
--mm-bg:#0d0d0f; --mm-slider:rgba(255,255,255,.07);
|
|
51
|
+
--mm-dim:rgba(0,0,0,.30); --mm-edge:rgba(255,255,255,.18);
|
|
52
|
+
--indent-guide:rgba(255,255,255,.06);
|
|
53
|
+
--tok-kw:#6e9fff; --tok-str:#4ec9a0; --tok-cmt:#4e4c58;
|
|
54
|
+
--tok-fn:#d4976e; --tok-num:#b48eff; --tok-cls:#e8c97a;
|
|
55
|
+
--tok-op:#55536a; --tok-typ:#6ec9d4; --tok-dec:#f28b82;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* ── Layout ── */
|
|
59
|
+
.sl-layout{display:flex;flex:1;overflow:hidden}
|
|
60
|
+
.sl-ed-pane{flex:1;display:flex;flex-direction:column;overflow:hidden;position:relative;background:var(--bg2)}
|
|
61
|
+
|
|
62
|
+
/* ── Hidden textarea (input capture) ── */
|
|
63
|
+
.sl-input{position:fixed;left:-9999px;top:0;width:200px;height:40px;
|
|
64
|
+
opacity:0;resize:none;border:none;outline:none;padding:0;margin:0;
|
|
65
|
+
font-size:16px;background:transparent;color:transparent;
|
|
66
|
+
caret-color:transparent;pointer-events:none}
|
|
67
|
+
|
|
68
|
+
/* ── Editor scroll container ── */
|
|
69
|
+
.sl-editor{flex:1;overflow-y:scroll;overflow-x:auto;position:relative;
|
|
70
|
+
cursor:text;scrollbar-width:thin;scrollbar-color:var(--border3) transparent}
|
|
71
|
+
.sl-editor::-webkit-scrollbar{width:10px;height:8px}
|
|
72
|
+
.sl-editor::-webkit-scrollbar-track{background:transparent}
|
|
73
|
+
.sl-editor::-webkit-scrollbar-thumb{background:var(--border3);border-radius:5px;border:2px solid var(--bg2)}
|
|
74
|
+
.sl-spacer{position:absolute;left:0;top:0;width:1px;pointer-events:none}
|
|
75
|
+
.sl-vp{position:absolute;left:0;right:0;will-change:transform}
|
|
76
|
+
|
|
77
|
+
/* ── Editor row ── */
|
|
78
|
+
.sl-er{display:flex;align-items:stretch;position:relative}
|
|
79
|
+
.sl-er:hover .sl-eg{background:var(--gutter-hover)}
|
|
80
|
+
.sl-er.sl-cur-row{background:var(--cur-line-bg)}
|
|
81
|
+
.sl-er.sl-cur-row .sl-eg{background:var(--cur-line-gutter)!important}
|
|
82
|
+
.sl-eg{min-width:60px;font-family:var(--mono);font-size:11px;color:var(--gutter-num);
|
|
83
|
+
user-select:none;border-right:1px solid var(--gutter-border);
|
|
84
|
+
background:var(--gutter-bg);flex-shrink:0;position:sticky;left:0;z-index:2;
|
|
85
|
+
display:flex;flex-direction:column;justify-content:flex-start;
|
|
86
|
+
transition:background .12s,color .12s}
|
|
87
|
+
.sl-er.sl-cur-row .sl-eg{color:var(--gutter-num-act)}
|
|
88
|
+
.sl-egn{height:22px;line-height:22px;padding-right:10px;text-align:right;display:block}
|
|
89
|
+
.sl-er.sl-wrap-cont .sl-egn{visibility:hidden}
|
|
90
|
+
.sl-el{flex:1;font-family:var(--mono);font-size:13px;line-height:22px;
|
|
91
|
+
color:var(--text);position:relative;min-width:0}
|
|
92
|
+
.sl-cl{display:block;height:22px;line-height:22px;
|
|
93
|
+
padding:0 20px 0 14px;white-space:pre;position:relative}
|
|
94
|
+
.sl-wrap-mode .sl-cl{white-space:pre-wrap;word-break:break-all;height:auto;overflow-wrap:anywhere}
|
|
95
|
+
|
|
96
|
+
/* ── Cursor ── */
|
|
97
|
+
.sl-cur{display:inline;width:0;height:0;position:relative}
|
|
98
|
+
.sl-cur::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
99
|
+
background:var(--cur);border-radius:1px;
|
|
100
|
+
box-shadow:0 0 8px var(--cur-glow);
|
|
101
|
+
animation:sl-blink 1.05s step-end infinite;pointer-events:none}
|
|
102
|
+
@keyframes sl-blink{0%,100%{opacity:1}45%,55%{opacity:0}}
|
|
103
|
+
|
|
104
|
+
/* ── Multi-cursor extra beams ── */
|
|
105
|
+
.sl-cur-extra{display:inline;width:0;height:0;position:relative}
|
|
106
|
+
.sl-cur-extra::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
107
|
+
background:var(--cur);border-radius:1px;
|
|
108
|
+
box-shadow:0 0 8px var(--cur-glow);
|
|
109
|
+
animation:sl-blink 1.05s step-end infinite;pointer-events:none}
|
|
110
|
+
|
|
111
|
+
/* ── Overlays ── */
|
|
112
|
+
.sl-sh{background:var(--sel-bg);border-radius:2px}
|
|
113
|
+
.sl-fh{background:var(--find-bg);border:1px solid var(--find-border);border-radius:2px}
|
|
114
|
+
.sl-fh.sl-fh-cur{background:var(--find-cur-bg);border:1px solid var(--find-cur-border);color:var(--find-cur-text)}
|
|
115
|
+
.sl-wh{background:var(--word-hl-bg);border:1px solid var(--word-hl-border);border-radius:2px}
|
|
116
|
+
.sl-bm{box-shadow:0 0 0 1px var(--bm-border);border-radius:2px}
|
|
117
|
+
.sl-ig{position:absolute;top:0;bottom:0;width:1px;background:var(--indent-guide);pointer-events:none}
|
|
118
|
+
|
|
119
|
+
/* ── Code folding ── */
|
|
120
|
+
.sl-fold-btn{position:absolute;left:3px;top:4px;width:13px;height:13px;border-radius:3px;
|
|
121
|
+
display:flex;align-items:center;justify-content:center;font-size:9px;
|
|
122
|
+
color:var(--gutter-num);cursor:pointer;opacity:0;
|
|
123
|
+
transition:opacity .15s,background .1s;user-select:none;line-height:1}
|
|
124
|
+
.sl-er:hover .sl-fold-btn{opacity:1}
|
|
125
|
+
.sl-fold-btn:hover{background:var(--border3);color:var(--gutter-num-act)}
|
|
126
|
+
.sl-folded{background:var(--fold-bg);border-bottom:1px dashed var(--fold-border)}
|
|
127
|
+
|
|
128
|
+
/* ── Syntax tokens ── */
|
|
129
|
+
.kw{color:var(--tok-kw)}.str{color:var(--tok-str)}.cmt{color:var(--tok-cmt);font-style:italic}
|
|
130
|
+
.fn{color:var(--tok-fn)}.num{color:var(--tok-num)}.cls{color:var(--tok-cls)}
|
|
131
|
+
.op{color:var(--tok-op)}.typ{color:var(--tok-typ)}.dec{color:var(--tok-dec)}
|
|
132
|
+
|
|
133
|
+
/* ── Minimap ── */
|
|
134
|
+
.sl-minimap{background:var(--mm-bg);border-left:1px solid var(--border);
|
|
135
|
+
overflow:hidden;position:relative;flex-shrink:0;cursor:pointer;user-select:none}
|
|
136
|
+
.sl-minimap canvas{display:block;position:absolute;top:0;left:0}
|
|
137
|
+
.sl-mm-slider{position:absolute;left:0;right:0;pointer-events:none}
|
|
138
|
+
|
|
139
|
+
/* ── Status bar ── */
|
|
140
|
+
.sl-statusbar{height:26px;background:var(--accent2);display:flex;align-items:center;
|
|
141
|
+
padding:0 6px;font-size:11px;color:rgba(255,255,255,.85);flex-shrink:0;gap:0}
|
|
142
|
+
.sl-sb-item{display:flex;align-items:center;gap:4px;padding:0 8px;height:100%;
|
|
143
|
+
cursor:pointer;transition:background .1s;white-space:nowrap;border-radius:3px}
|
|
144
|
+
.sl-sb-item:hover{background:rgba(255,255,255,.15)}
|
|
145
|
+
.sl-sb-item.sl-no-click{cursor:default}
|
|
146
|
+
.sl-sb-item.sl-no-click:hover{background:transparent}
|
|
147
|
+
.sl-sb-sep{width:1px;height:14px;background:rgba(255,255,255,.22);margin:0 1px;flex-shrink:0}
|
|
148
|
+
.sl-sb-right{margin-left:auto;display:flex;align-items:center}
|
|
149
|
+
.sl-sb-wrap.sl-on{font-weight:700}
|
|
150
|
+
|
|
151
|
+
/* ── Find + Replace bar ── */
|
|
152
|
+
.sl-find-bar{position:absolute;top:0;right:125px;z-index:50;background:var(--bg3);
|
|
153
|
+
border:1px solid var(--border3);border-top:none;border-radius:0 0 10px 10px;
|
|
154
|
+
display:flex;flex-direction:column;overflow:hidden;
|
|
155
|
+
transform:translateY(-100%);transition:transform .18s,box-shadow .18s;pointer-events:none}
|
|
156
|
+
.sl-find-bar.sl-open{transform:translateY(0);pointer-events:all;box-shadow:0 8px 28px rgba(0,0,0,.4)}
|
|
157
|
+
.sl-find-row{display:flex;align-items:center;gap:6px;padding:7px 10px}
|
|
158
|
+
.sl-find-row+.sl-find-row{border-top:1px solid var(--border)}
|
|
159
|
+
.sl-find-bar input{width:180px;background:var(--bg4);border:1px solid var(--border3);
|
|
160
|
+
border-radius:5px;padding:4px 8px;font-size:12px;font-family:var(--mono);
|
|
161
|
+
color:var(--text);outline:none;transition:border-color .15s}
|
|
162
|
+
.sl-find-bar input:focus{border-color:var(--accent)}
|
|
163
|
+
.sl-find-btn{padding:3px 8px;font-size:11px;border:1px solid var(--border3);
|
|
164
|
+
border-radius:4px;background:transparent;color:var(--text2);cursor:pointer;
|
|
165
|
+
transition:background .1s;white-space:nowrap}
|
|
166
|
+
.sl-find-btn:hover{background:var(--border3);color:var(--text)}
|
|
167
|
+
.sl-find-btn.sl-active{background:var(--accent);border-color:var(--accent);color:#fff}
|
|
168
|
+
.sl-find-count{font-size:11px;color:var(--text3);font-family:var(--mono);min-width:52px}
|
|
169
|
+
.sl-find-x{font-size:14px;color:var(--text3);cursor:pointer;padding:2px 5px;
|
|
170
|
+
border-radius:3px;margin-left:2px}
|
|
171
|
+
.sl-find-x:hover{color:var(--text);background:var(--border3)}
|
|
172
|
+
|
|
173
|
+
/* ── Autocomplete popup (VS Code-style with optional description panel) ── */
|
|
174
|
+
.sl-ac-popup{position:fixed;z-index:400;background:var(--bg3);
|
|
175
|
+
border:1px solid var(--border3);border-radius:8px;overflow:hidden;
|
|
176
|
+
box-shadow:0 12px 40px rgba(0,0,0,.55);
|
|
177
|
+
display:flex;flex-direction:row;
|
|
178
|
+
animation:sl-acIn .1s ease;pointer-events:all}
|
|
179
|
+
@keyframes sl-acIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
|
|
180
|
+
/* Left: item list */
|
|
181
|
+
.sl-ac-list{min-width:240px;max-width:300px;max-height:320px;overflow-y:auto;flex-shrink:0}
|
|
182
|
+
.sl-ac-list::-webkit-scrollbar{width:4px}
|
|
183
|
+
.sl-ac-list::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
184
|
+
.sl-ac-item{display:flex;align-items:center;gap:8px;padding:4px 10px;font-size:12px;
|
|
185
|
+
font-family:var(--mono);cursor:pointer;color:var(--text2);transition:background .07s;
|
|
186
|
+
white-space:nowrap}
|
|
187
|
+
.sl-ac-item:hover,.sl-ac-item.sl-sel{background:var(--bg4);color:var(--text)}
|
|
188
|
+
.sl-ac-badge{width:18px;height:18px;border-radius:4px;display:flex;align-items:center;
|
|
189
|
+
justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;font-family:var(--sans)}
|
|
190
|
+
.sl-ac-badge.kw{background:rgba(110,159,255,.18);color:var(--tok-kw)}
|
|
191
|
+
.sl-ac-badge.fn{background:rgba(212,151,110,.18);color:var(--tok-fn)}
|
|
192
|
+
.sl-ac-badge.typ{background:rgba(110,201,212,.18);color:var(--tok-typ)}
|
|
193
|
+
.sl-ac-badge.cls{background:rgba(232,201,122,.18);color:var(--tok-cls)}
|
|
194
|
+
.sl-ac-badge.var{background:rgba(78,201,160,.18);color:var(--tok-str)}
|
|
195
|
+
.sl-ac-badge.snip{background:rgba(155,100,255,.18);color:#a78bfa}
|
|
196
|
+
.sl-ac-badge.emmet{background:rgba(255,140,0,.18);color:#fb923c}
|
|
197
|
+
.sl-ac-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
198
|
+
.sl-ac-detail{font-size:10px;color:var(--text3);flex-shrink:0;max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-left:4px}
|
|
199
|
+
/* Right: description / docs panel */
|
|
200
|
+
.sl-ac-desc{width:260px;max-height:320px;overflow-y:auto;
|
|
201
|
+
border-left:1px solid var(--border3);padding:10px 12px;flex-shrink:0}
|
|
202
|
+
.sl-ac-desc::-webkit-scrollbar{width:4px}
|
|
203
|
+
.sl-ac-desc::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
204
|
+
.sl-ac-desc-body{margin:0;font-size:11.5px;font-family:var(--mono);
|
|
205
|
+
color:var(--text2);line-height:1.6;white-space:pre-wrap;word-break:break-word}
|
|
206
|
+
|
|
207
|
+
/* ── Hover documentation tooltip ── */
|
|
208
|
+
.sl-hover-tip{position:fixed;z-index:500;background:var(--bg3);
|
|
209
|
+
border:1px solid var(--border3);border-radius:8px;
|
|
210
|
+
box-shadow:0 8px 32px rgba(0,0,0,.55);
|
|
211
|
+
max-width:380px;min-width:180px;padding:10px 14px;
|
|
212
|
+
pointer-events:all;cursor:default;
|
|
213
|
+
animation:sl-hoverIn .12s ease}
|
|
214
|
+
@keyframes sl-hoverIn{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
|
|
215
|
+
.sl-ht-sig{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;margin-bottom:5px}
|
|
216
|
+
.sl-ht-title{font-size:12.5px;font-family:var(--mono);font-weight:600;color:var(--tok-fn)}
|
|
217
|
+
.sl-ht-type{font-size:11px;font-family:var(--mono);color:var(--tok-typ);opacity:.9;word-break:break-all}
|
|
218
|
+
.sl-ht-body{font-size:12px;font-family:var(--sans);color:var(--text2);line-height:1.55;
|
|
219
|
+
max-height:120px;overflow-y:auto}
|
|
220
|
+
.sl-ht-body::-webkit-scrollbar{width:3px}
|
|
221
|
+
.sl-ht-body::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
222
|
+
.sl-hover-tip .sl-ht-divider{height:1px;background:var(--border);margin:6px 0}
|
|
223
|
+
|
|
224
|
+
/* ── Emmet tooltip ── */
|
|
225
|
+
.sl-emmet-tip{position:fixed;z-index:600;background:var(--bg3);
|
|
226
|
+
border:1px solid var(--border3);border-radius:6px;padding:4px 10px;
|
|
227
|
+
font-size:11px;font-family:var(--mono);color:var(--accent);
|
|
228
|
+
pointer-events:none;box-shadow:0 4px 16px rgba(0,0,0,.45);
|
|
229
|
+
white-space:nowrap;max-width:400px;overflow:hidden;text-overflow:ellipsis}
|
|
230
|
+
|
|
231
|
+
/* ── Theme picker ── */
|
|
232
|
+
.sl-theme-overlay{position:fixed;inset:0;z-index:700;
|
|
233
|
+
background:rgba(0,0,0,.50);backdrop-filter:blur(2px)}
|
|
234
|
+
.sl-theme-panel{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
|
|
235
|
+
z-index:701;background:var(--bg2);border:1px solid var(--border3);
|
|
236
|
+
border-radius:14px;overflow:hidden;width:420px;
|
|
237
|
+
box-shadow:0 32px 80px rgba(0,0,0,.65),0 0 0 1px var(--border2)}
|
|
238
|
+
.sl-theme-header{padding:16px 20px 12px;display:flex;align-items:center;
|
|
239
|
+
justify-content:space-between;border-bottom:1px solid var(--border)}
|
|
240
|
+
.sl-theme-title{font-size:13px;font-weight:600;color:var(--text);letter-spacing:.01em}
|
|
241
|
+
.sl-theme-close{width:24px;height:24px;border-radius:6px;display:flex;align-items:center;
|
|
242
|
+
justify-content:center;font-size:14px;color:var(--text3);cursor:pointer;
|
|
243
|
+
transition:background .1s,color .1s}
|
|
244
|
+
.sl-theme-close:hover{background:var(--border3);color:var(--text)}
|
|
245
|
+
.sl-theme-list{padding:8px 8px 10px}
|
|
246
|
+
.sl-theme-item{display:flex;align-items:center;gap:14px;padding:10px 12px;
|
|
247
|
+
border-radius:9px;cursor:pointer;transition:background .1s;
|
|
248
|
+
border:1px solid transparent;margin-bottom:2px}
|
|
249
|
+
.sl-theme-item:hover{background:var(--bg4)}
|
|
250
|
+
.sl-theme-item.sl-active{background:var(--bg4);border-color:var(--border3)}
|
|
251
|
+
.sl-theme-check{width:18px;height:18px;margin-left:auto;color:var(--accent);
|
|
252
|
+
font-size:13px;font-weight:700;flex-shrink:0;opacity:0}
|
|
253
|
+
.sl-theme-item.sl-active .sl-theme-check{opacity:1}
|
|
254
|
+
.sl-theme-swatch{width:46px;height:30px;border-radius:7px;flex-shrink:0;
|
|
255
|
+
overflow:hidden;border:1px solid rgba(0,0,0,.15);
|
|
256
|
+
display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr}
|
|
257
|
+
.sl-theme-swatch span{display:block}
|
|
258
|
+
.sl-theme-name{font-size:13px;color:var(--text);font-weight:500;line-height:1.3}
|
|
259
|
+
.sl-theme-desc{font-size:11px;color:var(--text3);margin-top:2px}
|
|
260
|
+
.sl-theme-tag{display:inline-block;font-size:9px;font-weight:600;letter-spacing:.08em;
|
|
261
|
+
text-transform:uppercase;padding:1px 5px;border-radius:3px;margin-left:6px;
|
|
262
|
+
background:var(--border3);color:var(--text3);vertical-align:middle}
|
|
263
|
+
.sl-theme-tag.sl-light{background:rgba(255,200,50,.15);color:#b58900}
|
|
264
|
+
|
|
265
|
+
/* ── Empty state ── */
|
|
266
|
+
.sl-empty{flex:1;display:flex;flex-direction:column;align-items:center;
|
|
267
|
+
justify-content:center;gap:10px;color:var(--text3);font-size:13px}
|
|
268
|
+
`;function B(n,e,t){const i=document.createElement(n);return e&&(i.className=e),i}function X(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function me(n,e=document.documentElement){return getComputedStyle(e).getPropertyValue(n).trim()}function ze(n,e){const t=n.replace("#",""),i=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return`rgba(${i},${r},${o},${e})`}function Fe(n){return n.split(`
|
|
269
|
+
`)}function A(n){return n.join(`
|
|
270
|
+
`)}function Ge(n){return(n.match(/^(\s*)/)??["",""])[1]}function ie(n){return" ".repeat(Math.max(0,n))}function Ve(n){return/[\w$]/.test(n)}function ge(n,e,t=Ve){let i=e;for(;i>0&&t(n[i-1]);)i--;return i}function be(n,e,t=Ve){let i=e;for(;i<n.length&&t(n[i]);)i++;return i}function fe(n,e){let t=0,i=null;return(...r)=>{const o=Date.now(),s=e-(o-t);s<=0?(i!==null&&(clearTimeout(i),i=null),t=o,n(...r)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,n(...r)},s))}}const Wi={fontSize:[8,72,13],lineHeight:[14,64,22],tabSize:[1,16,2],wrapColumn:[20,500,80],maxCompletions:[1,50,14],autocompletePrefixLength:[1,10,2],gutterWidth:[30,200,60],minimapWidth:[60,300,120],cursorBlinkRate:[200,5e3,1050],maxUndoHistory:[10,5e3,300],undoBatchMs:[0,5e3,700]};function zi(n,e,t,i){const r=Number(n);return Number.isFinite(r)?Math.max(e,Math.min(t,Math.round(r))):i}function qe(n){const e={...n};for(const[t,i]of Object.entries(Wi))if(t in n&&n[t]!==void 0){const[r,o,s]=i;e[t]=zi(n[t],r,o,s)}return e}const xe={"(":")","{":"}","[":"]"},ye={")":"(","}":"{","]":"["};function Fi(n,e){const{row:t,col:i}=e,r=n[t]??"";let o=r[i],s=i;if(!xe[o]&&!ye[o]&&(o=r[i-1],s=i-1),!o)return null;if(xe[o]){const a=xe[o];let l=0;for(let d=t;d<Math.min(n.length,t+500);d++){const h=n[d]??"",c=d===t?s:0;for(let p=c;p<h.length;p++)if(h[p]===o)l++;else if(h[p]===a&&(l--,l===0))return{open:{row:t,col:s},close:{row:d,col:p}}}}else if(ye[o]){const a=ye[o];let l=0;for(let d=t;d>=Math.max(0,t-500);d--){const h=n[d]??"",c=d===t?s:h.length-1;for(let p=c;p>=0;p--)if(h[p]===o)l++;else if(h[p]===a&&(l--,l===0))return{open:{row:d,col:p},close:{row:t,col:s}}}}return null}function Gi(n,e){const t=n[e]??"";let i=0;for(const r of t)r==="{"?i++:r==="}"&&i--;return i>0}function Vi(n,e){let t=0;for(let i=e;i<n.length;i++)for(const r of n[i]??"")if(r==="{")t++;else if(r==="}"&&(t--,t===0))return i;return null}function qi(n,e,t){const i=new Map(n);if(i.has(t))i.delete(t);else{const r=Vi(e,t);r!==null&&r>t&&i.set(t,r)}return i}const Ui=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function Ue(n){const e=n.trim();if(!e)return null;try{const t=ve(e);return t===e?null:t}catch{return null}}function ve(n){if(n.includes(">")){const t=n.indexOf(">");return ke(n.slice(0,t),ve(n.slice(t+1)))}if(n.includes("+"))return n.split("+").map(t=>ve(t.trim())).join(`
|
|
271
|
+
`);const e=n.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,r)=>ke(e[1],`$${r+1}`)).join(`
|
|
272
|
+
`)}return ke(n,"$1")}function ke(n,e){const t=n.match(/#([\w-]+)/),i=n.match(/\.([\w.-]+)/g),r=n.match(/\[([^\]]+)\]/);let o=n.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",s="";return t&&(s+=` id="${t[1]}"`),i&&(s+=` class="${i.map(a=>a.slice(1)).join(" ")}"`),r&&(s+=` ${r[1]}`),Ui.has(o)?`<${o}${s}>`:`<${o}${s}>${e}</${o}>`}function Ke(n,e){let t=e;for(;t>0&&/[\w#.[\]*>+{}()$@:-]/.test(n[t-1]);)t--;const i=n.slice(t,e);return i.length<2?null:{abbr:i,start:t}}const Ki=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
|
|
273
|
+
|
|
274
|
+
function name(params) {
|
|
275
|
+
// body
|
|
276
|
+
}`,body:`function $1($2) {
|
|
277
|
+
$3
|
|
278
|
+
}`},{label:"afn",kind:"snip",detail:"arrow function",description:`Declares a const arrow function.
|
|
279
|
+
|
|
280
|
+
const name = (params) => {
|
|
281
|
+
// body
|
|
282
|
+
};`,body:`const $1 = ($2) => {
|
|
283
|
+
$3
|
|
284
|
+
};`},{label:"asyncfn",kind:"snip",detail:"async function",description:`Declares an async function returning a Promise.
|
|
285
|
+
|
|
286
|
+
async function name(params): Promise<T> {
|
|
287
|
+
// body
|
|
288
|
+
}`,body:`async function $1($2): Promise<$3> {
|
|
289
|
+
$4
|
|
290
|
+
}`},{label:"cl",kind:"snip",detail:"class declaration",description:`Declares a class with a constructor.
|
|
291
|
+
|
|
292
|
+
class Name {
|
|
293
|
+
constructor(params) { ... }
|
|
294
|
+
}`,body:`class $1 {
|
|
295
|
+
constructor($2) {
|
|
296
|
+
$3
|
|
297
|
+
}
|
|
298
|
+
}`},{label:"forof",kind:"snip",detail:"for…of loop",description:`Iterates over the values of an iterable (array, string, Map, etc.).
|
|
299
|
+
|
|
300
|
+
for (const item of iterable) { ... }`,body:`for (const $1 of $2) {
|
|
301
|
+
$3
|
|
302
|
+
}`},{label:"forin",kind:"snip",detail:"for…in loop",description:`Iterates over the enumerable property keys of an object.
|
|
303
|
+
|
|
304
|
+
for (const key in object) { ... }`,body:`for (const $1 in $2) {
|
|
305
|
+
$3
|
|
306
|
+
}`},{label:"trycatch",kind:"snip",detail:"try / catch block",description:`Wraps code in a try/catch to handle runtime errors.
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
...
|
|
310
|
+
} catch (error) {
|
|
311
|
+
...
|
|
312
|
+
}`,body:`try {
|
|
313
|
+
$1
|
|
314
|
+
} catch ($2error) {
|
|
315
|
+
$3
|
|
316
|
+
}`},{label:"promise",kind:"snip",detail:"new Promise",description:`Creates a new Promise with resolve and reject handlers.
|
|
317
|
+
|
|
318
|
+
new Promise<T>((resolve, reject) => { ... })`,body:`new Promise<$1>((resolve, reject) => {
|
|
319
|
+
$2
|
|
320
|
+
})`},{label:"imp",kind:"snip",detail:"import statement",description:`Adds a named import from a module.
|
|
321
|
+
|
|
322
|
+
import { name } from 'module';`,body:"import { $1 } from '$2';"},{label:"iface",kind:"snip",detail:"interface (TypeScript)",description:`Declares a TypeScript interface.
|
|
323
|
+
|
|
324
|
+
interface Name {
|
|
325
|
+
field: Type;
|
|
326
|
+
}`,body:`interface $1 {
|
|
327
|
+
$2: $3;
|
|
328
|
+
}`,language:["typescript"]},{label:"ife",kind:"snip",detail:"immediately-invoked function expression",description:`An IIFE — defines and immediately calls a function.
|
|
329
|
+
|
|
330
|
+
((params) => {
|
|
331
|
+
...
|
|
332
|
+
})(args);`,body:`(($1) => {
|
|
333
|
+
$2
|
|
334
|
+
})($3);`},{label:"sw",kind:"snip",detail:"switch statement",description:`A switch/case statement with a default branch.
|
|
335
|
+
|
|
336
|
+
switch (expr) {
|
|
337
|
+
case value:
|
|
338
|
+
...
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
...
|
|
342
|
+
}`,body:`switch ($1) {
|
|
343
|
+
case $2:
|
|
344
|
+
$3
|
|
345
|
+
break;
|
|
346
|
+
default:
|
|
347
|
+
$4
|
|
348
|
+
}`}],Yi=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
|
|
349
|
+
|
|
350
|
+
display: flex;
|
|
351
|
+
align-items: center;
|
|
352
|
+
justify-content: center;`,body:`display: flex;
|
|
353
|
+
align-items: $1center;
|
|
354
|
+
justify-content: $2center;`,language:["css"]},{label:"grid",kind:"snip",detail:"CSS grid",description:`Sets up a CSS grid with equal columns and gap.
|
|
355
|
+
|
|
356
|
+
display: grid;
|
|
357
|
+
grid-template-columns: repeat(3, 1fr);
|
|
358
|
+
gap: 16px;`,body:`display: grid;
|
|
359
|
+
grid-template-columns: $1repeat(3, 1fr);
|
|
360
|
+
gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",description:`A responsive media query breakpoint.
|
|
361
|
+
|
|
362
|
+
@media (max-width: 768px) {
|
|
363
|
+
...
|
|
364
|
+
}`,body:`@media ($1max-width: 768px) {
|
|
365
|
+
$2
|
|
366
|
+
}`,language:["css"]},{label:"anim",kind:"snip",detail:"@keyframes animation",description:`A CSS keyframes animation block.
|
|
367
|
+
|
|
368
|
+
@keyframes name {
|
|
369
|
+
from { ... }
|
|
370
|
+
to { ... }
|
|
371
|
+
}`,body:`@keyframes $1 {
|
|
372
|
+
from { $2 }
|
|
373
|
+
to { $3 }
|
|
374
|
+
}`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
|
|
375
|
+
|
|
376
|
+
--name: value;`,body:"--$1: $2;",language:["css"]}],Xi=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
|
|
377
|
+
|
|
378
|
+
<details>
|
|
379
|
+
<summary>Title</summary>
|
|
380
|
+
<div>content</div>
|
|
381
|
+
</details>`,body:`<details>
|
|
382
|
+
<summary>$1Title</summary>
|
|
383
|
+
<div>
|
|
384
|
+
$2
|
|
385
|
+
</div>
|
|
386
|
+
</details>`},{label:"card",kind:"snip",detail:"card component",description:"A generic card component with header, body, and footer sections.",body:`<div class="card">
|
|
387
|
+
<div class="card-header">$1</div>
|
|
388
|
+
<div class="card-body">$2</div>
|
|
389
|
+
<div class="card-footer">$3</div>
|
|
390
|
+
</div>`},{label:"navbar",kind:"snip",detail:"navigation bar",description:`A simple navigation bar with anchor links.
|
|
391
|
+
|
|
392
|
+
<nav class="navbar">
|
|
393
|
+
<a href="#">Home</a> ...
|
|
394
|
+
</nav>`,body:`<nav class="navbar">
|
|
395
|
+
<a href="$1#">Home</a>
|
|
396
|
+
<a href="$2#">About</a>
|
|
397
|
+
<a href="$3#">Contact</a>
|
|
398
|
+
</nav>`},{label:"modal",kind:"snip",detail:"modal dialog",description:`A modal dialog layout with header, body, and footer.
|
|
399
|
+
|
|
400
|
+
<div class="modal">
|
|
401
|
+
<div class="modal-dialog"> ... </div>
|
|
402
|
+
</div>`,body:`<div class="modal">
|
|
403
|
+
<div class="modal-dialog">
|
|
404
|
+
<div class="modal-header">$1</div>
|
|
405
|
+
<div class="modal-body">$2</div>
|
|
406
|
+
<div class="modal-footer">$3</div>
|
|
407
|
+
</div>
|
|
408
|
+
</div>`},{label:"table",kind:"snip",detail:"HTML table",description:`A semantic HTML table with thead and tbody.
|
|
409
|
+
|
|
410
|
+
<table>
|
|
411
|
+
<thead><tr><th>...</th></tr></thead>
|
|
412
|
+
<tbody><tr><td>...</td></tr></tbody>
|
|
413
|
+
</table>`,body:`<table>
|
|
414
|
+
<thead>
|
|
415
|
+
<tr>
|
|
416
|
+
<th>$1</th>
|
|
417
|
+
</tr>
|
|
418
|
+
</thead>
|
|
419
|
+
<tbody>
|
|
420
|
+
<tr>
|
|
421
|
+
<td>$2</td>
|
|
422
|
+
</tr>
|
|
423
|
+
</tbody>
|
|
424
|
+
</table>`}];function Ji(n){const e=[...Xi];return(n==="typescript"||n==="javascript")&&e.push(...Ki.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(n):t.language===n))),n==="css"&&e.push(...Yi),e}function Zi(n,e,t){let i=e;for(;i>0&&/\w/.test(n[i-1]);)i--;const r=n.slice(i,e);if(!r)return null;const o=t.find(s=>s.kind==="snip"&&s.label===r);return o?{snippet:o,start:i}:null}function Qi(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function Ye(n,e,t,i){n.cursors.some(r=>r.row===e&&r.col===t)||n.cursors.push({row:e,col:t,sel:i})}function Xe(n){n.cursors=[],n.searchWord="",n.lastMatchRow=-1,n.lastMatchCol=-1}function er(n,e,t,i,r){const o=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((h,c)=>({row:h.row,col:h.col,isPrimary:!1,idx:c+1}))];o.sort((h,c)=>c.row!==h.row?c.row-h.row:c.col-h.col);const s=n.map(h=>h);let a=e,l=t;const d=i.map(h=>({...h}));for(const h of o){const c=s[h.row]??"";s[h.row]=c.slice(0,h.col)+r+c.slice(h.col);for(const p of o)p!==h&&p.row===h.row&&p.col>=h.col&&(p.col+=r.length);h.col+=r.length,h.isPrimary?(a=h.row,l=h.col):(d[h.idx-1].row=h.row,d[h.idx-1].col=h.col)}return{doc:s,primaryRow:a,primaryCol:l,extraCursors:d}}function tr(n,e,t,i){const r=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((d,h)=>({row:d.row,col:d.col,isPrimary:!1,idx:h+1}))];r.sort((d,h)=>h.row!==d.row?h.row-d.row:h.col-d.col);const o=n.map(d=>d);let s=e,a=t;const l=i.map(d=>({...d}));for(const d of r){if(d.col<=0)continue;const h=o[d.row]??"";o[d.row]=h.slice(0,d.col-1)+h.slice(d.col);for(const c of r)c!==d&&c.row===d.row&&c.col>d.col&&c.col--;d.col--,d.isPrimary?(s=d.row,a=d.col):l[d.idx-1].col=d.col}return{doc:o,primaryRow:s,primaryCol:a,extraCursors:l}}function ir(n,e,t,i,r){let o=n.searchWord;if(!o){if(r&&r.ar===r.fr&&(o=(e[r.ar]??"").slice(r.ac,r.fc)),!o){const l=e[t]??"",d=ge(l,i),h=be(l,i);o=l.slice(d,h)}if(!o)return null;n.searchWord=o,n.lastMatchRow=t,n.lastMatchCol=i}const s=n.lastMatchRow,a=n.lastMatchCol;for(let l=s;l<e.length;l++){const d=e[l]??"";let h=l===s?a:0;for(;h<=d.length-o.length;){const c=d.indexOf(o,h);if(c<0)break;const p=c===0||!/\w/.test(d[c-1]),m=c+o.length>=d.length||!/\w/.test(d[c+o.length]);if(p&&m)return n.lastMatchRow=l,n.lastMatchCol=c+o.length,{word:o,sel:{ar:l,ac:c,fr:l,fc:c+o.length},row:l,col:c+o.length};h=c+1}}for(let l=0;l<=s;l++){const d=e[l]??"",h=l===s?a:d.length;let c=0;for(;c<h;){const p=d.indexOf(o,c);if(p<0||p>=h)break;const m=p===0||!/\w/.test(d[p-1]),g=p+o.length>=d.length||!/\w/.test(d[p+o.length]);if(m&&g)return n.lastMatchRow=l,n.lastMatchCol=p+o.length,{word:o,sel:{ar:l,ac:p,fr:l,fc:p+o.length},row:l,col:p+o.length};c=p+1}}return null}function rr(n,e,t){if(!e)return[];const i=[];for(let r=0;r<n.length;r++){const o=n[r]??"";if(t.useRegex)try{const s=new RegExp(e,t.caseSensitive?"g":"gi");let a;for(;(a=s.exec(o))!==null&&(i.push({row:r,col:a.index,len:a[0].length}),!!a[0].length););}catch{}else{const s=t.caseSensitive?o:o.toLowerCase(),a=t.caseSensitive?e:e.toLowerCase();let l=0;for(;;){const d=s.indexOf(a,l);if(d===-1)break;i.push({row:r,col:d,len:e.length}),l=d+1}}}return i}function nr(n,e,t,i){const r=e[t];if(!r)return n;const o=[...n],s=o[r.row]??"";return o[r.row]=s.slice(0,r.col)+i+s.slice(r.col+r.len),o}function or(n,e,t){const i=[...n];for(let r=e.length-1;r>=0;r--){const o=e[r],s=i[o.row]??"";i[o.row]=s.slice(0,o.col)+t+s.slice(o.col+o.len)}return i}function sr(n,e,t){return n.length?(e+t+n.length)%n.length:-1}function ar(n,e,t,i){if(i)return[];const r=n[e]??"",o=ge(r,t),s=be(r,t),a=r.slice(o,s);if(!a||a.length<2)return[];const l=[];for(let d=0;d<n.length;d++){const h=n[d]??"";let c=0;for(;c<=h.length-a.length;){const p=h.indexOf(a,c);if(p<0)break;const m=p===0||!/\w/.test(h[p-1]),g=p+a.length>=h.length||!/\w/.test(h[p+a.length]);m&&g&&!(d===e&&p===o)&&l.push({row:d,col:p,len:a.length}),c=p+1}}return l}const we=[{label:"console.log",kind:"fn",detail:"void"},{label:"console.error",kind:"fn",detail:"void"},{label:"console.warn",kind:"fn",detail:"void"},{label:"console.info",kind:"fn",detail:"void"},{label:"console.table",kind:"fn",detail:"void"},{label:"document.getElementById",kind:"fn",detail:"HTMLElement | null"},{label:"document.querySelector",kind:"fn",detail:"Element | null"},{label:"document.querySelectorAll",kind:"fn",detail:"NodeList"},{label:"document.createElement",kind:"fn",detail:"HTMLElement"},{label:"document.createTextNode",kind:"fn",detail:"Text"},{label:"addEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"removeEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"requestAnimationFrame",kind:"fn",detail:"(cb) => number"},{label:"cancelAnimationFrame",kind:"fn",detail:"(id) => void"},{label:"setTimeout",kind:"fn",detail:"(cb, ms) => id"},{label:"clearTimeout",kind:"fn",detail:"(id) => void"},{label:"setInterval",kind:"fn",detail:"(cb, ms) => id"},{label:"clearInterval",kind:"fn",detail:"(id) => void"},{label:"JSON.stringify",kind:"fn",detail:"string"},{label:"JSON.parse",kind:"fn",detail:"any"},{label:"Math.max",kind:"fn",detail:"number"},{label:"Math.min",kind:"fn",detail:"number"},{label:"Math.floor",kind:"fn",detail:"number"},{label:"Math.ceil",kind:"fn",detail:"number"},{label:"Math.round",kind:"fn",detail:"number"},{label:"Math.abs",kind:"fn",detail:"number"},{label:"Math.pow",kind:"fn",detail:"number"},{label:"Math.sqrt",kind:"fn",detail:"number"},{label:"Math.random",kind:"fn",detail:"number"},{label:"Object.keys",kind:"fn",detail:"string[]"},{label:"Object.values",kind:"fn",detail:"any[]"},{label:"Object.entries",kind:"fn",detail:"[string, any][]"},{label:"Object.assign",kind:"fn",detail:"T & U"},{label:"Object.freeze",kind:"fn",detail:"Readonly<T>"},{label:"Object.create",kind:"fn",detail:"object"},{label:"Array.from",kind:"fn",detail:"T[]"},{label:"Array.isArray",kind:"fn",detail:"boolean"},{label:"Promise.all",kind:"fn",detail:"Promise<T[]>"},{label:"Promise.resolve",kind:"fn",detail:"Promise<T>"},{label:"Promise.reject",kind:"fn",detail:"Promise<never>"},{label:"Promise.allSettled",kind:"fn",detail:"Promise<...>"},{label:"parseInt",kind:"fn",detail:"number"},{label:"parseFloat",kind:"fn",detail:"number"},{label:"isNaN",kind:"fn",detail:"boolean"},{label:"isFinite",kind:"fn",detail:"boolean"},{label:"encodeURIComponent",kind:"fn",detail:"string"},{label:"decodeURIComponent",kind:"fn",detail:"string"},{label:"structuredClone",kind:"fn",detail:"T"},{label:"queueMicrotask",kind:"fn",detail:"void"},{label:"fetch",kind:"fn",detail:"Promise<Response>"}],lr=[{label:"display",kind:"var",detail:"property"},{label:"position",kind:"var",detail:"property"},{label:"top",kind:"var",detail:"property"},{label:"right",kind:"var",detail:"property"},{label:"bottom",kind:"var",detail:"property"},{label:"left",kind:"var",detail:"property"},{label:"width",kind:"var",detail:"property"},{label:"height",kind:"var",detail:"property"},{label:"min-width",kind:"var",detail:"property"},{label:"max-width",kind:"var",detail:"property"},{label:"min-height",kind:"var",detail:"property"},{label:"max-height",kind:"var",detail:"property"},{label:"z-index",kind:"var",detail:"property"},{label:"overflow",kind:"var",detail:"property"},{label:"overflow-x",kind:"var",detail:"property"},{label:"overflow-y",kind:"var",detail:"property"},{label:"box-sizing",kind:"var",detail:"property"},{label:"flex",kind:"var",detail:"property"},{label:"flex-direction",kind:"var",detail:"property"},{label:"flex-wrap",kind:"var",detail:"property"},{label:"flex-grow",kind:"var",detail:"property"},{label:"flex-shrink",kind:"var",detail:"property"},{label:"flex-basis",kind:"var",detail:"property"},{label:"flex-flow",kind:"var",detail:"property"},{label:"align-items",kind:"var",detail:"property"},{label:"align-content",kind:"var",detail:"property"},{label:"align-self",kind:"var",detail:"property"},{label:"justify-content",kind:"var",detail:"property"},{label:"justify-items",kind:"var",detail:"property"},{label:"justify-self",kind:"var",detail:"property"},{label:"gap",kind:"var",detail:"property"},{label:"row-gap",kind:"var",detail:"property"},{label:"column-gap",kind:"var",detail:"property"},{label:"grid",kind:"var",detail:"property"},{label:"grid-template",kind:"var",detail:"property"},{label:"grid-template-columns",kind:"var",detail:"property"},{label:"grid-template-rows",kind:"var",detail:"property"},{label:"grid-template-areas",kind:"var",detail:"property"},{label:"grid-column",kind:"var",detail:"property"},{label:"grid-row",kind:"var",detail:"property"},{label:"grid-area",kind:"var",detail:"property"},{label:"grid-auto-flow",kind:"var",detail:"property"},{label:"margin",kind:"var",detail:"property"},{label:"margin-top",kind:"var",detail:"property"},{label:"margin-right",kind:"var",detail:"property"},{label:"margin-bottom",kind:"var",detail:"property"},{label:"margin-left",kind:"var",detail:"property"},{label:"padding",kind:"var",detail:"property"},{label:"padding-top",kind:"var",detail:"property"},{label:"padding-right",kind:"var",detail:"property"},{label:"padding-bottom",kind:"var",detail:"property"},{label:"padding-left",kind:"var",detail:"property"},{label:"color",kind:"var",detail:"property"},{label:"font",kind:"var",detail:"property"},{label:"font-family",kind:"var",detail:"property"},{label:"font-size",kind:"var",detail:"property"},{label:"font-weight",kind:"var",detail:"property"},{label:"font-style",kind:"var",detail:"property"},{label:"line-height",kind:"var",detail:"property"},{label:"text-align",kind:"var",detail:"property"},{label:"text-decoration",kind:"var",detail:"property"},{label:"text-transform",kind:"var",detail:"property"},{label:"letter-spacing",kind:"var",detail:"property"},{label:"word-spacing",kind:"var",detail:"property"},{label:"white-space",kind:"var",detail:"property"},{label:"word-break",kind:"var",detail:"property"},{label:"word-wrap",kind:"var",detail:"property"},{label:"text-overflow",kind:"var",detail:"property"},{label:"background",kind:"var",detail:"property"},{label:"background-color",kind:"var",detail:"property"},{label:"background-image",kind:"var",detail:"property"},{label:"background-size",kind:"var",detail:"property"},{label:"background-position",kind:"var",detail:"property"},{label:"background-repeat",kind:"var",detail:"property"},{label:"background-clip",kind:"var",detail:"property"},{label:"background-attachment",kind:"var",detail:"property"},{label:"border",kind:"var",detail:"property"},{label:"border-width",kind:"var",detail:"property"},{label:"border-style",kind:"var",detail:"property"},{label:"border-color",kind:"var",detail:"property"},{label:"border-radius",kind:"var",detail:"property"},{label:"border-top",kind:"var",detail:"property"},{label:"border-right",kind:"var",detail:"property"},{label:"border-bottom",kind:"var",detail:"property"},{label:"border-left",kind:"var",detail:"property"},{label:"outline",kind:"var",detail:"property"},{label:"outline-width",kind:"var",detail:"property"},{label:"outline-style",kind:"var",detail:"property"},{label:"outline-color",kind:"var",detail:"property"},{label:"outline-offset",kind:"var",detail:"property"},{label:"opacity",kind:"var",detail:"property"},{label:"box-shadow",kind:"var",detail:"property"},{label:"text-shadow",kind:"var",detail:"property"},{label:"filter",kind:"var",detail:"property"},{label:"backdrop-filter",kind:"var",detail:"property"},{label:"transform",kind:"var",detail:"property"},{label:"transform-origin",kind:"var",detail:"property"},{label:"transition",kind:"var",detail:"property"},{label:"animation",kind:"var",detail:"property"},{label:"animation-name",kind:"var",detail:"property"},{label:"animation-duration",kind:"var",detail:"property"},{label:"animation-timing-function",kind:"var",detail:"property"},{label:"animation-delay",kind:"var",detail:"property"},{label:"animation-iteration-count",kind:"var",detail:"property"},{label:"animation-fill-mode",kind:"var",detail:"property"},{label:"cursor",kind:"var",detail:"property"},{label:"pointer-events",kind:"var",detail:"property"},{label:"user-select",kind:"var",detail:"property"},{label:"resize",kind:"var",detail:"property"},{label:"visibility",kind:"var",detail:"property"},{label:"content",kind:"var",detail:"property"},{label:"list-style",kind:"var",detail:"property"},{label:"will-change",kind:"var",detail:"property"},{label:"appearance",kind:"var",detail:"property"},{label:"clip-path",kind:"var",detail:"property"},{label:"object-fit",kind:"var",detail:"property"},{label:"object-position",kind:"var",detail:"property"},{label:"scroll-behavior",kind:"var",detail:"property"},{label:"aspect-ratio",kind:"var",detail:"property"},{label:"var",kind:"fn",detail:"css fn"},{label:"calc",kind:"fn",detail:"css fn"},{label:"min",kind:"fn",detail:"css fn"},{label:"max",kind:"fn",detail:"css fn"},{label:"clamp",kind:"fn",detail:"css fn"},{label:"rgb",kind:"fn",detail:"css fn"},{label:"rgba",kind:"fn",detail:"css fn"},{label:"hsl",kind:"fn",detail:"css fn"},{label:"hsla",kind:"fn",detail:"css fn"},{label:"oklch",kind:"fn",detail:"css fn"},{label:"linear-gradient",kind:"fn",detail:"css fn"},{label:"radial-gradient",kind:"fn",detail:"css fn"},{label:"conic-gradient",kind:"fn",detail:"css fn"},{label:"translate",kind:"fn",detail:"css fn"},{label:"scale",kind:"fn",detail:"css fn"},{label:"rotate",kind:"fn",detail:"css fn"},{label:"skew",kind:"fn",detail:"css fn"},{label:"matrix",kind:"fn",detail:"css fn"},{label:"perspective",kind:"fn",detail:"css fn"},{label:"url",kind:"fn",detail:"css fn"},{label:"attr",kind:"fn",detail:"css fn"},{label:"env",kind:"fn",detail:"css fn"},{label:"repeat",kind:"fn",detail:"css fn"},{label:"minmax",kind:"fn",detail:"css fn"},{label:"fit-content",kind:"fn",detail:"css fn"}],dr={typescript:we,javascript:we,css:lr,json:[],markdown:[],text:[]};function Je(n,e,t){const i=He[n]??he,r=De[n]??pe,o=dr[n]??we;return[...[...i,...e].map(s=>({label:s,kind:"kw",detail:"keyword"})),...[...r,...t].map(s=>({label:s,kind:"typ",detail:"type"})),...o]}function cr(n,e){const t=new Set;for(const i of n){const r=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const o of r)o!==e&&o.length>2&&t.add(o)}return t}function Ze(n,e){return n.language?Array.isArray(n.language)?n.language.includes(e):n.language===e:!0}function hr(n,e,t={},i=0,r=0){if(e.length<2)return[];const o=e.toLowerCase(),{language:s="typescript",extraKeywords:a=[],extraTypes:l=[],completions:d=[],replaceBuiltins:h=!1,maxResults:c=14}=t,p=d.filter(v=>v.kind==="snip"&&!!v.body&&Ze(v,s)),m=d.filter(v=>!(v.kind==="snip"&&v.body)&&Ze(v,s)),g=p.filter(v=>v.label.toLowerCase().startsWith(o));let f;if(t.provideCompletions){const v={line:n[i]??"",col:r,prefix:e,language:s,doc:n};let E;try{E=t.provideCompletions(v)}catch(H){console.error("[syncline-editor] provideCompletions threw an error:",H),E=null}f=E!=null?[...E,...m]:[...h?[]:Je(s,a,l),...m]}else f=h?m:[...Je(s,a,l),...m];const u=new Set(f.map(v=>v.label)),k=f.filter(v=>v.label.toLowerCase().startsWith(o)&&v.label!==e),_=new Set(g.map(v=>v.label)),x=[...cr(n,e)].filter(v=>v.toLowerCase().startsWith(o)&&!u.has(v)&&!_.has(v)).slice(0,8).map(v=>({label:v,kind:"var",detail:"in file"}));return[...g,...k.filter(v=>!_.has(v.label)),...x].slice(0,c)}function pr(n,e,t=!1){let i=e;for(;i>0&&(t?/[\w$.\-]/:/[\w$.]/).test(n[i-1]);)i--;return{prefix:n.slice(i,e),start:i}}function ur(n,e){const t=o=>/[\w$]/.test(o);let i=e;for(;i<n.length&&t(n[i]);)i++;let r=e;for(;r>0&&t(n[r-1]);)r--;if(r===i)return"";if(r>0&&n[r-1]==="."){let o=r-1,s=o;for(;s>0&&t(n[s-1]);)s--;if(s<o)return n.slice(s,i)}return n.slice(r,i)}const mr={console:{title:"console",type:"Console",body:"Provides access to the browser's debugging console. Useful for logging, timing, profiling, and inspecting values during development.",language:["typescript","javascript"]},"console.log":{title:"console.log()",type:"(...data: any[]) => void",body:"Outputs a message to the web console. Accepts any number of arguments — objects are logged as expandable trees, primitives as their string form.",language:["typescript","javascript"]},"console.error":{title:"console.error()",type:"(...data: any[]) => void",body:"Logs an error message to the console, typically rendered in red with a stack trace. Use for unrecoverable failures.",language:["typescript","javascript"]},"console.warn":{title:"console.warn()",type:"(...data: any[]) => void",body:"Logs a warning message to the console, typically rendered in yellow. Use for non-fatal issues or deprecation notices.",language:["typescript","javascript"]},"console.info":{title:"console.info()",type:"(...data: any[]) => void",body:"Logs an informational message. Behaves identically to console.log in most environments.",language:["typescript","javascript"]},"console.table":{title:"console.table()",type:"(data: any, columns?: string[]) => void",body:"Displays an array or object as a formatted table in the console. Optionally restrict displayed columns.",language:["typescript","javascript"]},"console.time":{title:"console.time()",type:"(label?: string) => void",body:"Starts a timer with the given label. Call console.timeEnd() with the same label to log the elapsed time.",language:["typescript","javascript"]},"console.timeEnd":{title:"console.timeEnd()",type:"(label?: string) => void",body:"Stops the timer started by console.time() and logs the elapsed duration in milliseconds.",language:["typescript","javascript"]},"console.group":{title:"console.group()",type:"(...label: any[]) => void",body:"Creates a new inline group in the console output, indenting subsequent messages until console.groupEnd() is called.",language:["typescript","javascript"]},"console.groupEnd":{title:"console.groupEnd()",type:"() => void",body:"Closes the current inline group in the console, exiting the indented group created by console.group().",language:["typescript","javascript"]},Math:{title:"Math",type:"namespace Math",body:"A built-in object with properties and methods for mathematical constants and functions. Not a constructor — all properties and methods are static.",language:["typescript","javascript"]},"Math.max":{title:"Math.max()",type:"(...values: number[]) => number",body:"Returns the largest of the given numbers. Returns -Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.min":{title:"Math.min()",type:"(...values: number[]) => number",body:"Returns the smallest of the given numbers. Returns Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.floor":{title:"Math.floor()",type:"(x: number) => number",body:"Returns the largest integer less than or equal to x. Rounds toward negative infinity.",language:["typescript","javascript"]},"Math.ceil":{title:"Math.ceil()",type:"(x: number) => number",body:"Returns the smallest integer greater than or equal to x. Rounds toward positive infinity.",language:["typescript","javascript"]},"Math.round":{title:"Math.round()",type:"(x: number) => number",body:"Returns the value of x rounded to the nearest integer. Values with a fractional part of exactly 0.5 round up.",language:["typescript","javascript"]},"Math.abs":{title:"Math.abs()",type:"(x: number) => number",body:"Returns the absolute (non-negative) value of x.",language:["typescript","javascript"]},"Math.sqrt":{title:"Math.sqrt()",type:"(x: number) => number",body:"Returns the square root of x. Returns NaN if x is negative.",language:["typescript","javascript"]},"Math.pow":{title:"Math.pow()",type:"(base: number, exponent: number) => number",body:"Returns base raised to the power of exponent. Equivalent to the ** operator.",language:["typescript","javascript"]},"Math.random":{title:"Math.random()",type:"() => number",body:"Returns a pseudo-random floating-point number in the range [0, 1). Not cryptographically secure — use crypto.getRandomValues() for security-sensitive code.",language:["typescript","javascript"]},"Math.PI":{title:"Math.PI",type:"number",body:"The ratio of a circle's circumference to its diameter: approximately 3.14159265358979.",language:["typescript","javascript"]},"Math.trunc":{title:"Math.trunc()",type:"(x: number) => number",body:"Returns the integer part of x by removing any fractional digits. Does not round — simply truncates toward zero.",language:["typescript","javascript"]},"Math.sign":{title:"Math.sign()",type:"(x: number) => number",body:"Returns 1 if x is positive, -1 if x is negative, 0 if x is zero, or NaN if x is not a number.",language:["typescript","javascript"]},"Math.clamp":{title:"Math.clamp()",type:"(value: number, min: number, max: number) => number",body:"Clamps value between min and max. Note: not yet standard — use Math.min(Math.max(value, min), max) for compatibility.",language:["typescript","javascript"]},JSON:{title:"JSON",type:"namespace JSON",body:"Provides methods for parsing and serializing JSON (JavaScript Object Notation). All methods are static.",language:["typescript","javascript"]},"JSON.stringify":{title:"JSON.stringify()",type:"(value: any, replacer?: any, space?: string | number) => string",body:"Converts a JavaScript value to a JSON string. Pass a number or string as the third argument to pretty-print with indentation. Throws on circular references.",language:["typescript","javascript"]},"JSON.parse":{title:"JSON.parse()",type:"(text: string, reviver?: (key: string, value: any) => any) => any",body:"Parses a JSON string and returns the corresponding JavaScript value. Throws SyntaxError if the string is not valid JSON.",language:["typescript","javascript"]},Array:{title:"Array",type:"interface Array<T>",body:"Represents an ordered list of values. Provides methods for traversal, mutation, searching, and transformation.",language:["typescript","javascript"]},"Array.from":{title:"Array.from()",type:"<T>(arrayLike: Iterable<T> | ArrayLike<T>, mapFn?: (v: T, i: number) => T) => T[]",body:"Creates a new Array from an array-like or iterable object (e.g. NodeList, Set, Map, string). Optionally applies a mapping function.",language:["typescript","javascript"]},"Array.isArray":{title:"Array.isArray()",type:"(value: unknown) => value is any[]",body:"Returns true if the given value is an Array. More reliable than instanceof Array across iframe boundaries.",language:["typescript","javascript"]},Object:{title:"Object",type:"interface Object",body:"The base class of all JavaScript objects. Provides static methods for working with object properties, prototypes, and descriptors.",language:["typescript","javascript"]},"Object.keys":{title:"Object.keys()",type:"(obj: object) => string[]",body:"Returns an array of an object's own enumerable string-keyed property names, in insertion order.",language:["typescript","javascript"]},"Object.values":{title:"Object.values()",type:"(obj: object) => any[]",body:"Returns an array of an object's own enumerable string-keyed property values, in insertion order.",language:["typescript","javascript"]},"Object.entries":{title:"Object.entries()",type:"(obj: object) => [string, any][]",body:"Returns an array of [key, value] pairs for all own enumerable string-keyed properties of an object.",language:["typescript","javascript"]},"Object.assign":{title:"Object.assign()",type:"<T, U>(target: T, source: U) => T & U",body:"Copies own enumerable properties from one or more source objects into a target object. Returns the modified target. Does a shallow copy.",language:["typescript","javascript"]},"Object.freeze":{title:"Object.freeze()",type:"<T>(obj: T) => Readonly<T>",body:"Freezes an object — prevents adding, removing, or changing its properties. Returns the same object. Shallow — nested objects are not frozen.",language:["typescript","javascript"]},"Object.create":{title:"Object.create()",type:"(proto: object | null, propertiesObject?: PropertyDescriptorMap) => any",body:"Creates a new object with the specified prototype object and optional property descriptors.",language:["typescript","javascript"]},"Object.fromEntries":{title:"Object.fromEntries()",type:"<T>(entries: Iterable<[string, T]>) => Record<string, T>",body:"Creates an object from an array of [key, value] pairs or any iterable of key-value entries. The inverse of Object.entries().",language:["typescript","javascript"]},Promise:{title:"Promise",type:"interface Promise<T>",body:"Represents an asynchronous operation that will eventually complete (or fail) and produce a value. Use .then(), .catch(), and .finally() to handle outcomes.",language:["typescript","javascript"]},"Promise.all":{title:"Promise.all()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T[]>",body:"Waits for all promises to resolve and returns an array of results. If any promise rejects, the entire result rejects immediately (fail-fast).",language:["typescript","javascript"]},"Promise.allSettled":{title:"Promise.allSettled()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<PromiseSettledResult<T>[]>",body:'Waits for all promises to settle (resolve or reject) and returns an array of result objects, each with a status of "fulfilled" or "rejected". Never rejects.',language:["typescript","javascript"]},"Promise.race":{title:"Promise.race()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T>",body:"Returns a promise that resolves or rejects as soon as one of the given promises resolves or rejects, with that value or reason.",language:["typescript","javascript"]},"Promise.resolve":{title:"Promise.resolve()",type:"<T>(value: T | PromiseLike<T>) => Promise<T>",body:"Returns a Promise object that is resolved with the given value. If the value is a thenable, the returned promise follows it.",language:["typescript","javascript"]},"Promise.reject":{title:"Promise.reject()",type:"(reason?: any) => Promise<never>",body:"Returns a Promise that is rejected with the given reason. Useful for creating pre-rejected promises in control flow.",language:["typescript","javascript"]},setTimeout:{title:"setTimeout()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Executes a function after a specified delay in milliseconds. Returns a timer ID that can be passed to clearTimeout() to cancel.",language:["typescript","javascript"]},clearTimeout:{title:"clearTimeout()",type:"(id: number) => void",body:"Cancels a timeout previously established by setTimeout(), preventing its callback from running.",language:["typescript","javascript"]},setInterval:{title:"setInterval()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Repeatedly executes a function with a fixed time delay between each call. Returns a timer ID for cancellation via clearInterval().",language:["typescript","javascript"]},clearInterval:{title:"clearInterval()",type:"(id: number) => void",body:"Cancels a repeating timer established by setInterval().",language:["typescript","javascript"]},requestAnimationFrame:{title:"requestAnimationFrame()",type:"(callback: (timestamp: DOMHighResTimeStamp) => void) => number",body:"Schedules a callback to run before the next browser repaint. Ideal for animations — the browser can batch and throttle calls to 60fps or the display refresh rate.",language:["typescript","javascript"]},cancelAnimationFrame:{title:"cancelAnimationFrame()",type:"(id: number) => void",body:"Cancels an animation frame request previously scheduled with requestAnimationFrame().",language:["typescript","javascript"]},queueMicrotask:{title:"queueMicrotask()",type:"(callback: () => void) => void",body:"Queues a microtask to be executed before the next task in the event loop. Runs after the current JavaScript execution but before any setTimeout callbacks.",language:["typescript","javascript"]},fetch:{title:"fetch()",type:"(input: RequestInfo | URL, init?: RequestInit) => Promise<Response>",body:"Fetches a resource from the network. Returns a Promise that resolves to a Response. Use .json(), .text(), or .blob() on the response to read the body.",language:["typescript","javascript"]},parseInt:{title:"parseInt()",type:"(string: string, radix?: number) => number",body:"Parses a string and returns an integer in the specified radix (base). Always provide the radix (typically 10) to avoid unexpected behavior with leading zeros.",language:["typescript","javascript"]},parseFloat:{title:"parseFloat()",type:"(string: string) => number",body:"Parses a string and returns a floating-point number. Returns NaN if the string cannot be converted.",language:["typescript","javascript"]},isNaN:{title:"isNaN()",type:"(value: number) => boolean",body:"Returns true if the value is NaN (Not a Number). Note: coerces the argument to number first — use Number.isNaN() for strict checking without coercion.",language:["typescript","javascript"]},isFinite:{title:"isFinite()",type:"(value: number) => boolean",body:"Returns true if the value is a finite number. Returns false for ±Infinity and NaN. Coerces the argument to number first.",language:["typescript","javascript"]},encodeURIComponent:{title:"encodeURIComponent()",type:"(uriComponent: string | number | boolean) => string",body:"Encodes a URI component by replacing special characters with their UTF-8 escape sequences. Use for encoding query string values before appending to a URL.",language:["typescript","javascript"]},decodeURIComponent:{title:"decodeURIComponent()",type:"(encodedURIComponent: string) => string",body:"Decodes a URI component that was previously encoded with encodeURIComponent(). Throws URIError on malformed sequences.",language:["typescript","javascript"]},structuredClone:{title:"structuredClone()",type:"<T>(value: T, options?: StructuredSerializeOptions) => T",body:"Creates a deep clone of the given value using the structured clone algorithm. Handles cycles, Maps, Sets, Dates, and typed arrays. Does not clone functions or class instances.",language:["typescript","javascript"]},"document.getElementById":{title:"document.getElementById()",type:"(elementId: string) => HTMLElement | null",body:"Returns the first element in the document with the specified ID, or null if not found. IDs must be unique per document.",language:["typescript","javascript"]},"document.querySelector":{title:"document.querySelector()",type:"(selectors: string) => Element | null",body:"Returns the first Element matching the given CSS selector string, or null if no match. Use querySelectorAll() for all matches.",language:["typescript","javascript"]},"document.querySelectorAll":{title:"document.querySelectorAll()",type:"(selectors: string) => NodeListOf<Element>",body:"Returns a static NodeList of all Elements matching the given CSS selector string. Does not update as the document changes.",language:["typescript","javascript"]},"document.createElement":{title:"document.createElement()",type:"<K extends keyof HTMLElementTagNameMap>(tagName: K) => HTMLElementTagNameMap[K]",body:"Creates a new HTML element with the specified tag name. The element is not attached to the DOM until you call appendChild() or similar.",language:["typescript","javascript"]},addEventListener:{title:"addEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void",body:"Registers an event listener on the target element. The listener is called whenever the specified event fires. Remember to call removeEventListener() to clean up.",language:["typescript","javascript"]},removeEventListener:{title:"removeEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void",body:"Removes an event listener previously added with addEventListener(). The listener reference must be the same function object.",language:["typescript","javascript"]},const:{title:"const",type:"keyword",body:"Declares a block-scoped variable that cannot be reassigned. The binding is immutable — but for objects and arrays, their contents can still be mutated.",language:["typescript","javascript"]},let:{title:"let",type:"keyword",body:"Declares a block-scoped variable that can be reassigned. Prefer const for bindings that never change.",language:["typescript","javascript"]},var:{title:"var",type:"keyword",body:"Declares a function-scoped (or globally-scoped) variable. Hoisted to the top of its scope. Prefer const or let in modern code.",language:["typescript","javascript"]},function:{title:"function",type:"keyword",body:"Defines a named function declaration, or introduces a function expression. Function declarations are hoisted; expressions are not.",language:["typescript","javascript"]},class:{title:"class",type:"keyword",body:"Declares a class — a blueprint for creating objects with shared methods and properties. Classes support extends, implements, constructors, getters, setters, and static members.",language:["typescript","javascript"]},async:{title:"async",type:"keyword",body:"Marks a function as asynchronous, making it return a Promise implicitly. Enables the use of the await keyword inside the function body.",language:["typescript","javascript"]},await:{title:"await",type:"keyword",body:"Pauses execution of an async function until the Promise settles, then returns the resolved value. Must be used inside an async function.",language:["typescript","javascript"]},return:{title:"return",type:"keyword",body:"Exits the current function and optionally returns a value to the caller. In an async function, the value is wrapped in a resolved Promise.",language:["typescript","javascript"]},interface:{title:"interface",type:"keyword",body:"Defines a TypeScript interface — a named contract describing the shape of an object. Interfaces can be extended, merged (declaration merging), and implemented by classes.",language:["typescript"]},type:{title:"type",type:"keyword",body:"Declares a TypeScript type alias — a name for any type expression including unions, intersections, tuples, mapped types, and conditional types.",language:["typescript"]},extends:{title:"extends",type:"keyword",body:"Establishes inheritance (class extends Base) or constrains a generic type parameter (T extends object). Also used in conditional types (T extends U ? X : Y).",language:["typescript","javascript"]},implements:{title:"implements",type:"keyword",body:"Declares that a class satisfies the shape of one or more interfaces. TypeScript verifies at compile time that all required members are present.",language:["typescript"]},export:{title:"export",type:"keyword",body:"Makes a declaration (variable, function, class, type, interface) available for import in other modules. Use export default for a single primary export.",language:["typescript","javascript"]},import:{title:"import",type:"keyword",body:"Imports bindings from another module. Supports named imports ({ foo, bar }), default imports (Foo), namespace imports (* as Foo), and side-effect imports.",language:["typescript","javascript"]},typeof:{title:"typeof",type:"keyword",body:'Returns a string describing the type of its operand at runtime ("string", "number", "boolean", "object", "function", "undefined", "symbol", "bigint"). In TypeScript, also used as a type operator to capture the type of a value.',language:["typescript","javascript"]},instanceof:{title:"instanceof",type:"keyword",body:"Tests whether an object has a given constructor in its prototype chain. Returns true if the object is an instance of the constructor.",language:["typescript","javascript"]},new:{title:"new",type:"keyword",body:"Creates a new instance of a class or constructor function. Allocates memory, sets the prototype, calls the constructor with `this` bound to the new object, and returns it.",language:["typescript","javascript"]},throw:{title:"throw",type:"keyword",body:"Throws a user-defined exception, stopping execution of the current function and propagating up the call stack until caught by a try...catch block.",language:["typescript","javascript"]},try:{title:"try...catch...finally",type:"keyword",body:"Wraps code that might throw an exception. The catch block handles errors; the finally block always runs whether or not an error occurred.",language:["typescript","javascript"]},string:{title:"string",type:"primitive type",body:'Represents a sequence of UTF-16 code units. In TypeScript, the string type accepts any text value. Literal types like "hello" narrow to specific string values.',language:["typescript"]},number:{title:"number",type:"primitive type",body:"Represents a double-precision 64-bit IEEE 754 floating-point value. Includes integers, decimals, NaN, and Infinity. TypeScript does not have a separate int type.",language:["typescript"]},boolean:{title:"boolean",type:"primitive type",body:"Represents a logical true or false value. Literal types true and false narrow to specific boolean values.",language:["typescript"]},any:{title:"any",type:"TypeScript type",body:"Disables type checking for a value — allows any operation without compile errors. Avoid using any; prefer unknown when the type is genuinely uncertain.",language:["typescript"]},unknown:{title:"unknown",type:"TypeScript type",body:"The type-safe alternative to any. You cannot perform operations on an unknown value without first narrowing its type with typeof, instanceof, or a type guard.",language:["typescript"]},void:{title:"void",type:"TypeScript type",body:"Represents the absence of a value, typically used as the return type of functions that do not return anything meaningful.",language:["typescript"]},never:{title:"never",type:"TypeScript type",body:"A type with no values — used for functions that never return (throw or infinite loop) and for exhaustive checks in union type switches.",language:["typescript"]},Record:{title:"Record<K, V>",type:"type Record<K extends keyof any, T> = { [P in K]: T }",body:"A utility type that constructs an object type whose keys are of type K and values are of type V. Useful for dictionaries and lookup tables.",language:["typescript"]},Partial:{title:"Partial<T>",type:"type Partial<T> = { [P in keyof T]?: T[P] }",body:"A utility type that makes all properties of T optional. Useful for update payloads, patches, and configuration objects with defaults.",language:["typescript"]},Required:{title:"Required<T>",type:"type Required<T> = { [P in keyof T]-?: T[P] }",body:"A utility type that makes all properties of T required (removes optionality). The inverse of Partial<T>.",language:["typescript"]},Readonly:{title:"Readonly<T>",type:"type Readonly<T> = { readonly [P in keyof T]: T[P] }",body:"A utility type that makes all properties of T readonly. Prevents property reassignment at the type level.",language:["typescript"]},ReturnType:{title:"ReturnType<T>",type:"type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any",body:"A utility type that extracts the return type of a function type T.",language:["typescript"]},Omit:{title:"Omit<T, K>",type:"type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>",body:"A utility type that constructs a type by picking all properties from T then removing those in K.",language:["typescript"]},Pick:{title:"Pick<T, K>",type:"type Pick<T, K extends keyof T> = { [P in K]: T[P] }",body:"A utility type that constructs a type by picking the set of properties K from T.",language:["typescript"]},NonNullable:{title:"NonNullable<T>",type:"type NonNullable<T> = T extends null | undefined ? never : T",body:"A utility type that removes null and undefined from the type T.",language:["typescript"]},keyof:{title:"keyof",type:"TypeScript type operator",body:'Produces a union type of all property keys of an object type. keyof { a: string; b: number } is "a" | "b".',language:["typescript"]}};function gr(n,e){const t=mr[n];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}function br(n){var e,t,i,r;const{vr:o,visIdx:s,curVisRow:a,wm:l,foldedLines:d,isFoldable:h,opts:c}=n,{docLine:p,segIdx:m,text:g}=o,f=s===a,u=p===((e=l.visualRows[a])==null?void 0:e.docLine),k=m>0,_=((t=l.segments[p])==null?void 0:t.slice(0,m).reduce((w,T)=>w+T.length,0))??0,x=n.docSel?Ne(n.docSel,p,((i=(l.segments[p]??[""])[m])==null?void 0:i.length)??0):null;let v=null;if(x){const w=((r=(l.segments[p]??[""])[m])==null?void 0:r.length)??0,T=Ne(n.docSel,p,w+_);if(T){const S=T.start-_,D=T.end-_;D>0&&S<g.length&&(v={start:Math.max(0,S),end:Math.min(g.length,D)})}}const E=n.findMatches.filter(w=>w.row===p).map(w=>{var T,S;const D=w.col-_,P=w.col+w.len-_;if(P<=0||D>=g.length)return null;const ae=n.findIdx>=0&&((T=n.findMatches[n.findIdx])==null?void 0:T.row)===w.row&&((S=n.findMatches[n.findIdx])==null?void 0:S.col)===w.col;return{start:Math.max(0,D),end:Math.min(g.length,P),isCur:ae}}).filter(Boolean),H=n.wordHighlights.filter(w=>w.row===p).map(w=>{const T=w.col-_,S=w.col+w.len-_;return S<=0||T>=g.length?null:{start:Math.max(0,T),end:Math.min(g.length,S)}}).filter(Boolean),I=[];if(n.bracketMatch){for(const w of[n.bracketMatch.open,n.bracketMatch.close])if(w.row===p){const T=w.col-_;T>=0&&T<g.length&&I.push({start:T,end:T+1})}}const J=[],Z=[];for(const w of n.extraCursors){const T=U(l,w.row,w.col);if(T.visRow===s&&J.push(T.colInSeg),w.sel){const S=xr(w.sel);if(p>=S.ar&&p<=S.fr){const D=p===S.ar?S.ac-_:-_,P=p===S.fr?S.fc-_:g.length+999;P>0&&D<g.length&&Z.push({start:Math.max(0,D),end:Math.min(g.length,P)})}}}const V=fr(g,c.renderWhitespace),Ee=f||v||E.length||J.length||H.length||I.length||Z.length;let O;if(Ee)O=vr(V,f?n.curColInSeg:-1,v,E,J,H,I,Z,c.tokeniserOpts);else{const w=`${p}:${m}:${c.renderWhitespace}`;let T=n.tokenCache.get(w,V);T||(T=ue(V,c.tokeniserOpts),n.tokenCache.set(w,V,T)),O=yr(V,T)||"​"}let W="";if(m===0&&c.showIndentGuides){const w=(g.match(/^(\s*)/)??["",""])[1].length,T=Math.floor(w/c.tabSize);for(let S=1;S<T;S++){const D=c.codePaddingLeft+S*c.tabSize*c.charWidth;W+=`<span class="sl-ig" style="left:${D}px"></span>`}}let z="";if(m===0&&h){const w=d.has(p);z=`<span class="sl-fold-btn" data-row="${p}">${w?"▸":"▾"}</span>`}const Y=d.has(p)&&m===0,$=m===0?String(p+1):"";return`<div class="${["sl-er",c.highlightActiveLine&&u?"sl-cur-row":"",k?"sl-wrap-cont":"",Y?"sl-folded":""].filter(Boolean).join(" ")}" style="height:${c.lineHeight}px" data-v="${s}" data-doc="${p}"><div class="sl-eg" style="position:relative">${z}<span class="sl-egn">${$}</span></div><div class="sl-el"><span class="sl-cl">${W}${O}</span></div></div>`}function fr(n,e){if(e==="none")return n;if(e==="all")return n.replace(/ /g,"·").replace(/\t/g,"→");const t=(n.match(/^ +/)??[""])[0].length,i=(n.match(/ +$/)??[""])[0].length;let r=n;return t&&(r="·".repeat(t)+r.slice(t)),i&&(r=r.slice(0,r.length-i)+"·".repeat(i)),r.replace(/\t/g,"→")}function xr(n){return n.ar<n.fr||n.ar===n.fr&&n.ac<=n.fc?n:{ar:n.fr,ac:n.fc,fr:n.ar,fc:n.ac}}function yr(n,e){if(!n)return"";const t=We(n,e);let i="",r=0,o=t[0];const s=a=>{if(a<=r)return;const l=X(n.slice(r,a));i+=o?`<span class="${o}">${l}</span>`:l};for(let a=1;a<=n.length;a++){const l=a<n.length?t[a]:null;l!==o&&(s(a),r=a,o=l??"")}return i}function vr(n,e,t,i,r,o,s,a,l){if(n.length===0){let u=e>=0?'<span class="sl-cur"></span>':"";for(const k of r)u+='<span class="sl-cur-extra"></span>';return u||"​"}const d=ue(n,l),h=We(n,d);let c="",p=0,m="",g="";const f=u=>{if(u<=p)return;const k=X(n.slice(p,u)),_=[m,g].filter(Boolean).join(" ");c+=_?`<span class="${_}">${k}</span>`:k};for(let u=0;u<=n.length;u++){e===u&&(f(u),p=u,c+='<span class="sl-cur"></span>');for(const I of r)I===u&&(f(u),p=u,c+='<span class="sl-cur-extra"></span>');if(u===n.length){f(u);break}const k=h[u],_=i.find(I=>u>=I.start&&u<I.end),x=t&&u>=t.start&&u<t.end||a.some(I=>u>=I.start&&u<I.end),v=!x&&!_&&o.some(I=>u>=I.start&&u<I.end),E=!x&&!_&&s.some(I=>u>=I.start&&u<I.end);let H="";x?H="sl-sh":_?H="sl-fh"+(_.isCur?" sl-fh-cur":""):E?H="sl-bm":v&&(H="sl-wh"),(H!==m||k!==g)&&(f(u),p=u,m=H,g=k)}return c||"​"}function _e(n,e,t,i,r){const o=Math.max(0,n*r-t),s=Math.max(0,n*2-i),a=(o>0?e/o:0)*s,l=Math.max(20,t/r*2),d=e/r*2-a;return{mmScroll:a,sliderTop:d,sliderHeight:l}}function kr(n,e,t,i,r){const o=Math.max(0,e*r-t),s=Math.max(0,e*2-i);if(o<=0)return 0;const a=2/r-s/o;if(Math.abs(a)<1e-9){const l=Math.max(20,t/r*2);return Math.max(0,Math.min(o,n/Math.max(1,i-l)*o))}return Math.max(0,Math.min(o,n/a))}function wr(n,e,t,i,r,o){const s=Math.max(0,e*o-i),a=Math.max(0,e*2-r);if(s<=0)return 0;const l=t/s*a,d=(n+l)/2;return Math.max(0,Math.min(s,d*o-i/2))}function Qe(n){const e=t=>{const i=n(t);return i.startsWith("#")&&i.length===7?ze(i,.85):i};return{kw:e("--tok-kw"),fn:e("--tok-fn"),cls:e("--tok-cls"),typ:e("--tok-typ"),str:e("--tok-str"),num:e("--tok-num"),cmt:e("--tok-cmt"),dec:e("--tok-dec"),op:e("--tok-op"),txt:(()=>{const t=n("--text2");return t.startsWith("#")&&t.length===7?ze(t,.28):"rgba(150,148,140,0.28)"})()}}function _r(n){var e,t;const{canvas:i,doc:r,firstLine:o,lastLine:s,subPx:a,wrapperWidth:l,canvasHeight:d,cursorRow:h,sel:c,findMatches:p,findIdx:m,sliderTop:g,sliderHeight:f,colors:u,getCssVar:k,dpr:_}=n,x=i.getContext("2d");if(!x)return;x.setTransform(_,0,0,_,0,0);const v=k("--mm-bg")||"#0d0d0f",E=k("--mm-dim")||"rgba(0,0,0,.30)",H=k("--mm-edge")||"rgba(255,255,255,.18)",I=k("--mm-slider")||"rgba(255,255,255,.07)",J=k("--sel-bg")||"rgba(110,159,255,.22)",Z=k("--cur-line-bg")||"rgba(255,255,255,.05)",V=k("--find-border")||"rgba(234,180,86,.50)",Ee=k("--find-cur-bg")||"rgba(234,180,86,.80)",O=$=>($-o)*2;if(x.fillStyle=v,x.fillRect(0,0,l,d),h>=o&&h<s&&(x.fillStyle=Z,x.fillRect(0,O(h),l,2)),c){const $=Math.max(o,c.ar),w=Math.min(s-1,c.fr);w>=$&&(x.fillStyle=J,x.fillRect(0,O($),l,(w-$+1)*2))}for(const $ of p){if($.row<o||$.row>=s)continue;const w=m>=0&&((e=p[m])==null?void 0:e.row)===$.row&&((t=p[m])==null?void 0:t.col)===$.col;x.fillStyle=w?Ee:V,x.fillRect(3+$.col*1.1,O($.row),Math.max(3,$.len*1.1),2)}const W=Math.floor((l-3)/1.1);for(let $=o;$<s;$++){const w=r[$]??"";if(!w.trim())continue;const T=O($),S=1.5,D=ue(w);let P=0;for(const F of D){if(F.start>=W)break;F.start>P&&(x.fillStyle=u.txt,x.fillRect(3+P*1.1,T,(Math.min(F.start,W)-P)*1.1,S));const on=u[F.cls]??u.txt,si=Math.min(F.end,W)-F.start;si>0&&(x.fillStyle=on,x.fillRect(3+F.start*1.1,T,si*1.1,S)),P=Math.max(P,Math.min(F.end,W))}const ae=Math.min(w.length,W);P<ae&&(x.fillStyle=u.txt,x.fillRect(3+P*1.1,T,(ae-P)*1.1,S))}const z=g+a,Y=z+f;x.fillStyle=E,z>0&&x.fillRect(0,0,l,z),Y<d&&x.fillRect(0,Y,l,d-Y),x.fillStyle=I,x.fillRect(0,z,l,f),x.fillStyle=H,x.fillRect(0,Math.max(0,z),l,1),x.fillRect(0,Math.max(0,Y-1),l,1)}const Cr={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:80,fontFamily:"'JetBrains Mono', monospace",fontSize:13,lineHeight:22,tabSize:2,insertSpaces:!0,maxUndoHistory:300,showIndentGuides:!0,bracketMatching:!0,codeFolding:!0,emmet:!0,snippetExpansion:!0,autocomplete:!0,multiCursor:!0,find:!0,findReplace:!0,wordSelection:!0,wordHighlight:!0,highlightActiveLine:!0,autocompletePrefixLength:2,readOnly:!1,extraKeywords:[],extraTypes:[],completions:[],replaceBuiltins:!1,maxCompletions:14,autoClosePairs:{"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},lineCommentToken:"",wordSeparators:"",undoBatchMs:700,gutterWidth:60,minimapWidth:120,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0};class Tr{constructor(e,t={}){y(this,"_host"),y(this,"_shadow"),y(this,"_editorEl"),y(this,"_spacerEl"),y(this,"_vpEl"),y(this,"_inputEl"),y(this,"_minimapWrap"),y(this,"_mmCanvas"),y(this,"_mmSlider"),y(this,"_statusBar"),y(this,"_findBar"),y(this,"_findInput"),y(this,"_replaceInput"),y(this,"_findCount"),y(this,"_replaceRow"),y(this,"_acPopup"),y(this,"_emmetTip"),y(this,"_snippetTip"),y(this,"_hoverTip"),y(this,"_themeOverlay"),y(this,"_themePanel"),y(this,"_config"),y(this,"_tab",je(1,[""])),y(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0]}),y(this,"_foldedLines",new Map),y(this,"_tokenCache",new Mi),y(this,"_themeManager"),y(this,"_findMatches",[]),y(this,"_findIdx",-1),y(this,"_findCaseSensitive",!1),y(this,"_findRegex",!1),y(this,"_wordHighlights",[]),y(this,"_bracketMatch",null),y(this,"_acItems",[]),y(this,"_acSel",0),y(this,"_acPrefix",""),y(this,"_acStartCol",0),y(this,"_emmetAcStartCol",0),y(this,"_mc",Qi()),y(this,"_extraCursors",[]),y(this,"_isDragging",!1),y(this,"_dragAnchor",null),y(this,"_hoverTimer",null),y(this,"_hoverPinned",!1),y(this,"_mmDragMode","none"),y(this,"_mmDragStartY",0),y(this,"_mmDragStartScroll",0),y(this,"_mmSliderOffset",0),y(this,"_mmColors"),y(this,"_lastInputTime",0),y(this,"_dynamicStyleEl"),y(this,"_emmetExpanded",null),y(this,"_snippetExpanded",null),y(this,"_acDebounceTimer",null),y(this,"_rafId",null),y(this,"_onWinMouseUp"),y(this,"_onWinResize"),y(this,"_onEditorScroll"),y(this,"_onWinMmMouseMove"),y(this,"_onWinMmMouseUp"),y(this,"_ro",null),y(this,"_onFoldBtnClick",l=>{const d=l.target.closest(".sl-fold-btn");if(!d)return;l.preventDefault(),l.stopPropagation();const h=parseInt(d.dataset.row??"0",10);this._foldedLines=qi(this._foldedLines,this._tab.doc,h),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()}),this._config={...Cr,...qe(t)},this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null},this._onEditorScroll=fe(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=fe(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=l=>{if(this._mmDragMode==="none")return;const d=this._minimapWrap.clientHeight;if(this._mmDragMode==="slider"){const h=l.clientY-this._minimapWrap.getBoundingClientRect().top;this._editorEl.scrollTop=kr(h-this._mmSliderOffset,this._tab.doc.length,this._editorEl.clientHeight,d,this._config.lineHeight)}else{const h=l.clientY-this._mmDragStartY,c=Math.max(0,this._tab.doc.length*this._config.lineHeight-this._editorEl.clientHeight);this._editorEl.scrollTop=Math.max(0,Math.min(c,this._mmDragStartScroll+h/2*this._config.lineHeight))}this._render()},this._onWinMmMouseUp=()=>{this._mmDragMode!=="none"&&(this._mmDragMode="none",this._minimapWrap.style.cursor="pointer")},this._host=e,this._host.classList.add("sl-host"),this._shadow=this._host.attachShadow({mode:"open"});const i=B("style");i.textContent=Oi,this._shadow.appendChild(i),this._dynamicStyleEl=B("style"),this._shadow.appendChild(this._dynamicStyleEl),this._themeManager=new Ni(this._host);const r=typeof this._config.theme=="string"?this._config.theme:this._config.theme;this._themeManager.apply(r);const o=B("div","sl-layout"),s=B("div","sl-ed-pane");this._inputEl=B("textarea","sl-input"),this._inputEl.setAttribute("autocomplete","off"),this._inputEl.setAttribute("autocorrect","off"),this._inputEl.setAttribute("autocapitalize","off"),this._inputEl.setAttribute("spellcheck","false"),this._inputEl.setAttribute("role","textbox"),this._inputEl.setAttribute("aria-multiline","true"),this._inputEl.setAttribute("aria-label","Code editor"),this._inputEl.setAttribute("aria-readonly",String(!!this._config.readOnly)),this._inputEl.setAttribute("aria-haspopup","listbox"),this._editorEl=B("div","sl-editor"),this._spacerEl=B("div","sl-spacer"),this._vpEl=B("div","sl-vp"),this._editorEl.appendChild(this._spacerEl),this._editorEl.appendChild(this._vpEl),this._findBar=this._buildFindBar(),this._findInput=this._findBar.querySelector(".sl-find-input"),this._replaceInput=this._findBar.querySelector(".sl-find-replace-input"),this._findCount=this._findBar.querySelector(".sl-find-count"),this._replaceRow=this._findBar.querySelector(".sl-replace-row"),s.appendChild(this._inputEl),s.appendChild(this._findBar),s.appendChild(this._editorEl),this._minimapWrap=B("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._mmCanvas=B("canvas",""),this._mmSlider=B("div","sl-mm-slider"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),o.appendChild(s),this._config.showMinimap&&o.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=B("div","sl-ac-popup"),this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.style.display="none",this._emmetTip=B("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=B("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=B("div","sl-hover-tip"),this._hoverTip.style.display="none",this._hoverTip.addEventListener("mouseenter",()=>{this._hoverPinned=!0}),this._hoverTip.addEventListener("mouseleave",()=>{this._hoverPinned=!1,this._hideHover()}),this._themeOverlay=B("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=B("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(o),this._config.showStatusBar&&this._shadow.appendChild(this._statusBar),this._shadow.appendChild(this._acPopup),this._shadow.appendChild(this._emmetTip),this._shadow.appendChild(this._snippetTip),this._shadow.appendChild(this._hoverTip),this._shadow.appendChild(this._themeOverlay);const a=typeof this._config.value=="string"?Fe(this._config.value):this._config.value;this._tab=je(1,a.length?a:[""]),this._mmColors=Qe(l=>me(l,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(fe(()=>{this._config.wordWrap&&(this._rebuildWrapMap(),this._scheduleRender())},60)),this._ro.observe(this._host)),this._rebuildWrapMap(),this._render()}getValue(){return A(this._tab.doc)}setValue(e){var t,i;M(this._tab,this._config.maxUndoHistory),this._tab.doc=Fe(e),this._tab.cur={row:0,col:0},this._tab.sel=null,this._tokenCache.clear(),this._foldedLines.clear(),this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,e)}getCursor(){return{...this._tab.cur}}setCursor(e){this._tab.cur={...e},L(this._tab),this._scrollIntoView(),this._render()}getSelection(){return this._tab.sel?{...this._tab.sel}:null}setSelection(e){this._tab.sel=e,this._render()}insertText(e){this._config.readOnly||(this._insertStr(e,!1),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=Qe(t=>me(t,this._host)),this._tokenCache.clear(),this._render()}updateConfig(e){const t=qe(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:r,...o}=t;Object.assign(this._config,o)}else Object.assign(this._config,t);if(t.readOnly!==void 0&&this._inputEl.setAttribute("aria-readonly",String(!!t.readOnly)),e.theme!==void 0&&this.setTheme(e.theme),(e.wordWrap!==void 0||e.wrapColumn!==void 0)&&this._rebuildWrapMap(),e.showMinimap!==void 0){const i=this._shadow.querySelector(".sl-layout");e.showMinimap?i.contains(this._minimapWrap)||i.appendChild(this._minimapWrap):this._minimapWrap.remove()}e.showStatusBar!==void 0&&(e.showStatusBar?this._shadow.contains(this._statusBar)||this._shadow.appendChild(this._statusBar):this._statusBar.remove()),(e.fontFamily!==void 0||e.fontSize!==void 0||e.lineHeight!==void 0||e.cursorBlinkRate!==void 0||e.cursorStyle!==void 0||e.gutterWidth!==void 0||e.minimapWidth!==void 0||e.showGutter!==void 0||e.tokenColors!==void 0)&&this._applyDynamicStyles(),(e.language!==void 0||e.extraKeywords!==void 0||e.extraTypes!==void 0||e.renderWhitespace!==void 0||e.completions!==void 0)&&this._tokenCache.clear(),e.find===!1?this._closeFind():e.findReplace===!1&&(this._replaceRow.style.display="none"),this._render()}focus(){this._focusInput()}getThemes(){return this._themeManager.allIds}registerTheme(e){this._themeManager.register(e)}undo(){var e,t;_i(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc)))}redo(){var e,t;Ci(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc)))}executeCommand(e){const t=this._config.readOnly;switch(e){case"undo":t||this.undo();break;case"redo":t||this.redo();break;case"selectAll":this._selectAll();break;case"copy":this._doCopy();break;case"cut":t||this._doCut();break;case"toggleComment":t||this._toggleComment();break;case"duplicateLine":t||this._duplicateLine();break;case"deleteLine":t||this._deleteLine();break;case"toggleWordWrap":this._toggleWrap();break;case"find":this._config.find&&this._openFind(!1);break;case"findReplace":this._config.find&&this._config.findReplace&&this._openFind(!0);break;case"indentLine":t||this._indentSel();break;case"outdentLine":t||this._unindentSel();break;default:console.warn(`[syncline-editor] executeCommand: unknown command "${e}"`);break}}destroy(){var e;this._acDebounceTimer!==null&&(clearTimeout(this._acDebounceTimer),this._acDebounceTimer=null),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),window.removeEventListener("mouseup",this._onWinMouseUp),window.removeEventListener("resize",this._onWinResize),window.removeEventListener("mousemove",this._onWinMmMouseMove),window.removeEventListener("mouseup",this._onWinMmMouseUp),(e=this._ro)==null||e.disconnect();const t=this._mmCanvas.getContext("2d");t&&t.clearRect(0,0,this._mmCanvas.width,this._mmCanvas.height),this._shadow.innerHTML="",this._host.classList.remove("sl-host")}_buildFindBar(){const e=B("div","sl-find-bar");return e.innerHTML=`
|
|
425
|
+
<div class="sl-find-row">
|
|
426
|
+
<input class="sl-find-input" placeholder="Find…" autocomplete="off" spellcheck="false">
|
|
427
|
+
<span class="sl-find-count">–</span>
|
|
428
|
+
<button class="sl-find-btn sl-find-prev" title="Previous">↑</button>
|
|
429
|
+
<button class="sl-find-btn sl-find-next" title="Next">↓</button>
|
|
430
|
+
<button class="sl-find-btn sl-find-case" title="Match case">Aa</button>
|
|
431
|
+
<button class="sl-find-btn sl-find-regex" title="Regex">.*</button>
|
|
432
|
+
<span class="sl-find-x sl-find-close">✕</span>
|
|
433
|
+
</div>
|
|
434
|
+
<div class="sl-find-row sl-replace-row" style="display:none">
|
|
435
|
+
<input class="sl-find-replace-input" placeholder="Replace…" autocomplete="off" spellcheck="false">
|
|
436
|
+
<button class="sl-find-btn sl-replace-one">Replace</button>
|
|
437
|
+
<button class="sl-find-btn sl-replace-all">All</button>
|
|
438
|
+
</div>
|
|
439
|
+
`,e}_buildStatusBar(){const e=B("div","sl-statusbar");return e.innerHTML=`
|
|
440
|
+
<div class="sl-sb-item sl-no-click sl-sb-lang">⬡ TypeScript</div>
|
|
441
|
+
<div class="sl-sb-sep"></div>
|
|
442
|
+
<div class="sl-sb-item sl-no-click sl-sb-pos">Ln 1, Col 1</div>
|
|
443
|
+
<div class="sl-sb-sep"></div>
|
|
444
|
+
<div class="sl-sb-item sl-no-click sl-sb-sel"></div>
|
|
445
|
+
<div class="sl-sb-sep sl-sb-sel-sep" style="display:none"></div>
|
|
446
|
+
<div class="sl-sb-item sl-no-click sl-sb-lines">1 line</div>
|
|
447
|
+
<div class="sl-sb-sep"></div>
|
|
448
|
+
<div class="sl-sb-item sl-no-click">UTF-8 LF</div>
|
|
449
|
+
<div class="sl-sb-right">
|
|
450
|
+
<div class="sl-sb-item sl-no-click sl-sb-mc" style="display:none">⊕ <span class="sl-sb-mc-count">1</span> cursors</div>
|
|
451
|
+
<div class="sl-sb-item sl-sb-wrap sl-sb-wrap-btn">⇥ Wrap: OFF</div>
|
|
452
|
+
<div class="sl-sb-sep"></div>
|
|
453
|
+
<div class="sl-sb-item sl-sb-theme-btn">🎨 Theme</div>
|
|
454
|
+
<div class="sl-sb-sep"></div>
|
|
455
|
+
<div class="sl-sb-item sl-no-click sl-sb-undo">↩0 ↪0</div>
|
|
456
|
+
</div>
|
|
457
|
+
`,e.querySelector(".sl-sb-wrap-btn").addEventListener("click",()=>this._toggleWrap()),e.querySelector(".sl-sb-theme-btn").addEventListener("click",()=>this._openThemePicker()),e}_applyDynamicStyles(){const{fontFamily:e,fontSize:t,lineHeight:i,cursorBlinkRate:r,cursorStyle:o,gutterWidth:s,minimapWidth:a,showGutter:l}=this._config,d=Math.max(2,i-4),h=Math.floor((i-d)/2);let c="";o==="block"?c=`width:${7.82}px;opacity:.5;border-radius:1px;`:o==="underline"&&(c=`width:${7.82}px;height:2px;top:${i-2}px;border-radius:0;`);const p=l?s:0;this._dynamicStyleEl.textContent=`
|
|
458
|
+
.sl-el{font-family:${e};font-size:${t}px;line-height:${i}px}
|
|
459
|
+
.sl-cl{height:${i}px;line-height:${i}px}
|
|
460
|
+
.sl-egn{height:${i}px;line-height:${i}px}
|
|
461
|
+
.sl-eg{min-width:${p}px;width:${p}px;${l?"":"display:none"}}
|
|
462
|
+
.sl-cur::after{height:${d}px;top:${h}px;animation-duration:${r}ms;${c}}
|
|
463
|
+
.sl-cur-extra::after{height:${d}px;top:${h}px;animation-duration:${r}ms;${c}}
|
|
464
|
+
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${a}px`}_applyTokenOverrides(){const e=this._config.tokenColors??{},t=this._themeManager.activeTheme,i=this._host.style,r=(s,a,l)=>{i.setProperty(s,a||l)},o=t==null?void 0:t.tokens;r("--tok-kw",e.keyword,(o==null?void 0:o.tokKw)??""),r("--tok-str",e.string,(o==null?void 0:o.tokStr)??""),r("--tok-cmt",e.comment,(o==null?void 0:o.tokCmt)??""),r("--tok-fn",e.function,(o==null?void 0:o.tokFn)??""),r("--tok-num",e.number,(o==null?void 0:o.tokNum)??""),r("--tok-cls",e.class,(o==null?void 0:o.tokCls)??""),r("--tok-op",e.operator,(o==null?void 0:o.tokOp)??""),r("--tok-typ",e.type,(o==null?void 0:o.tokTyp)??""),r("--tok-dec",e.decorator,(o==null?void 0:o.tokDec)??"")}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._render()}))}_render(){const{doc:e,cur:t,sel:i}=this._tab,{lineHeight:r}=this._config;this._wordHighlights=this._config.wordHighlight?ar(e,t.row,t.col,i):[],this._bracketMatch=this._config.bracketMatching?Fi(e,t):null;const o=this._wm.visualRows.length;this._spacerEl.style.height=`${o*r}px`;const s=this._editorEl.scrollTop,a=this._editorEl.clientHeight,l=Math.max(0,Math.floor(s/r)-6),d=Math.min(o-1,Math.ceil((s+a)/r)+6);this._vpEl.style.transform=`translateY(${l*r}px)`;const h=U(this._wm,t.row,t.col);let c="";for(let p=l;p<=d;p++){const m=this._wm.visualRows[p];m&&(c+=br({vr:m,visIdx:p,curVisRow:h.visRow,curColInSeg:h.colInSeg,docSel:i,findMatches:this._findMatches,findIdx:this._findIdx,wordHighlights:this._wordHighlights,bracketMatch:this._bracketMatch,extraCursors:this._extraCursors,foldedLines:this._foldedLines,isFoldable:this._config.codeFolding&&Gi(e,m.docLine),wm:this._wm,tokenCache:this._tokenCache,opts:{tokeniserOpts:{language:this._config.language,extraKeywords:new Set(this._config.extraKeywords),extraTypes:new Set(this._config.extraTypes)},showIndentGuides:this._config.showIndentGuides,highlightActiveLine:this._config.highlightActiveLine,charWidth:7.82,codePaddingLeft:14,tabSize:this._config.tabSize,lineHeight:r,renderWhitespace:this._config.renderWhitespace}}))}this._vpEl.innerHTML=c,this._updateStatusBar(),this._updateMinimap()}_updateStatusBar(){if(!this._config.showStatusBar)return;const{cur:e,doc:t,undoStack:i,redoStack:r}=this._tab,o=this._config.language,s={typescript:"TypeScript",javascript:"JavaScript",css:"CSS",json:"JSON",markdown:"Markdown",text:"Text"},a=p=>this._statusBar.querySelector(p);a(".sl-sb-lang").textContent=`⬡ ${s[o]??o}`,a(".sl-sb-pos").textContent=`Ln ${e.row+1}, Col ${e.col+1}`,a(".sl-sb-lines").textContent=`${t.length.toLocaleString()} lines`;const l=Ti(this._tab),d=a(".sl-sb-sel"),h=a(".sl-sb-sel-sep");d.textContent=l?`${l.toLocaleString()} selected`:"",h.style.display=l?"":"none",a(".sl-sb-undo").textContent=`↩${i.length} ↪${r.length}`;const c=a(".sl-sb-mc");this._extraCursors.length?(c.style.display="",a(".sl-sb-mc-count").textContent=String(this._extraCursors.length+1)):c.style.display="none"}_updateMinimap(){if(!this._config.showMinimap)return;const e=this._minimapWrap.clientWidth,t=this._minimapWrap.clientHeight;if(!e||!t)return;const i=this._tab.doc,r=i.length,o=Math.min(window.devicePixelRatio||1,2),s=this._config.lineHeight,{mmScroll:a,sliderTop:l,sliderHeight:d}=_e(r,this._editorEl.scrollTop,this._editorEl.clientHeight,t,s),h=a/2,c=Math.floor(h),p=Math.ceil(t/2)+2,m=Math.min(r,c+p),g=(m-c)*2,f=(h-c)*2,u=Math.round(e*o),k=Math.round(g*o);(this._mmCanvas.width!==u||this._mmCanvas.height!==k)&&(this._mmCanvas.width=u,this._mmCanvas.height=k,this._mmCanvas.style.width=`${e}px`,this._mmCanvas.style.height=`${g}px`),this._mmCanvas.style.transform=`translateY(${-f}px)`,_r({canvas:this._mmCanvas,doc:i,firstLine:c,lastLine:m,subPx:f,wrapperWidth:e,canvasHeight:g,cursorRow:this._tab.cur.row,sel:this._tab.sel,findMatches:this._findMatches,findIdx:this._findIdx,sliderTop:l,sliderHeight:d,colors:this._mmColors,getCssVar:_=>me(_,this._host),dpr:o}),this._mmSlider.style.top=`${Math.max(0,Math.min(t-d,l))}px`,this._mmSlider.style.height=`${d}px`}_rebuildWrapMap(){let e;if(this._config.wordWrap){const t=this._config.showGutter?this._config.gutterWidth:0,i=this._editorEl.clientWidth;if(i>0){const r=i-t-14-20;e=Math.max(20,Math.floor(r/7.82))}else e=this._config.wrapColumn}else e=9999;this._wm=Si(this._tab.doc,e,this._config.wordWrap,this._foldedLines)}_scrollIntoView(){const e=this._tab.cur,t=U(this._wm,e.row,e.col).visRow*this._config.lineHeight,i=t+this._config.lineHeight,r=this._editorEl.scrollTop,o=this._editorEl.clientHeight,s=this._config.lineHeight*3;t<r+s?this._editorEl.scrollTop=Math.max(0,t-s):i>r+o-s&&(this._editorEl.scrollTop=i-o+s)}_focusInput(){this._inputEl.style.pointerEvents="auto",this._inputEl.focus(),this._inputEl.style.pointerEvents="none"}_insertStr(e,t){var i,r;const o=Date.now();(!t||o-this._lastInputTime>this._config.undoBatchMs)&&M(this._tab,this._config.maxUndoHistory),this._lastInputTime=o,this._tab.sel&&(this._tab.cur=q(this._tab));const{doc:s,cur:a}=this._tab,l=e.split(`
|
|
465
|
+
`),d=s[a.row]??"",h=d.slice(0,a.col),c=d.slice(a.col);if(l.length===1)s[a.row]=h+e+c,a.col+=e.length;else{const p=[h+l[0]];for(let m=1;m<l.length-1;m++)p.push(l[m]);p.push(l[l.length-1]+c),s.splice(a.row,1,...p),a.row+=l.length-1,a.col=l[l.length-1].length}this._tokenCache.invalidateLine(a.row,(this._wm.segments[a.row]??[""]).length),this._tab.dirty=!0,(r=(i=this._config).onChange)==null||r.call(i,A(s))}_doBackspace(){var e;if(M(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:t,cur:i}=this._tab;if(i.col>0){const r=t[i.row]??"",o=r.slice(0,i.col),s=o.length>=2&&o.endsWith(" ")&&!o.trim()?2:1;t[i.row]=r.slice(0,i.col-s)+r.slice(i.col),i.col-=s,this._tokenCache.invalidateLine(i.row,((e=this._wm.segments[i.row])==null?void 0:e.length)??1)}else if(i.row>0){const r=(t[i.row-1]??"").length;t[i.row-1]+=t[i.row]??"",t.splice(i.row,1),i.row--,i.col=r,this._tokenCache.clear()}this._tab.dirty=!0}_doEnter(){M(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=q(this._tab));const{doc:e,cur:t}=this._tab,i=e[t.row]??"",r=i.slice(0,t.col),o=i.slice(t.col),s=Ge(i),a=r.trimEnd().endsWith("{")?ie(this._config.tabSize):"";e[t.row]=r,r.trimEnd().endsWith("{")&&o.trimStart()==="}"?e.splice(t.row+1,0,s+a,s+o):e.splice(t.row+1,0,s+a+o),t.row++,t.col=s.length+a.length,this._tokenCache.clear(),this._tab.dirty=!0}_doDelete(){var e;if(M(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:t,cur:i}=this._tab,r=t[i.row]??"";i.col<r.length?(t[i.row]=r.slice(0,i.col)+r.slice(i.col+1),this._tokenCache.invalidateLine(i.row,((e=this._wm.segments[i.row])==null?void 0:e.length)??1)):i.row<t.length-1&&(t[i.row]=r+(t[i.row+1]??""),t.splice(i.row+1,1),this._tokenCache.clear()),this._tab.dirty=!0}_selectAll(){const e=this._tab.doc,t=e.length-1;this._tab.sel={ar:0,ac:0,fr:t,fc:(e[t]??"").length},this._tab.cur={row:t,col:(e[t]??"").length},this._render()}_doCopy(){var e;const t=Oe(this._tab);t&&((e=navigator.clipboard)==null||e.writeText(t).catch(()=>{}))}_doCut(){var e,t,i;const r=Oe(this._tab);r&&((e=navigator.clipboard)==null||e.writeText(r).catch(()=>{}),M(this._tab,this._config.maxUndoHistory),this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc)))}_toggleComment(){var e,t;M(this._tab,this._config.maxUndoHistory);const i=this._getSelRows(),r=this._config.lineCommentToken||bi[this._config.language]||"";if(!r)return;const o=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=i.every(a=>(this._tab.doc[a]??"").trimStart().startsWith(r));i.forEach(a=>{var l;const d=this._tab.doc[a]??"";this._tab.doc[a]=s?d.replace(new RegExp(`^(\\s*)${o}\\s?`),"$1"):d.replace(/^(\s*)/,`$1${r} `),this._tokenCache.invalidateLine(a,((l=this._wm.segments[a])==null?void 0:l.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_duplicateLine(){var e,t;M(this._tab,this._config.maxUndoHistory);const i=this._tab.cur.row;this._tab.doc.splice(i+1,0,this._tab.doc[i]??""),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_deleteLine(){var e,t;M(this._tab,this._config.maxUndoHistory);const{doc:i,cur:r}=this._tab;i.length>1?i.splice(r.row,1):(i[0]="",r.col=0),this._tokenCache.clear(),this._tab.dirty=!0,L(this._tab),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_indentSel(){var e,t;if(!this._tab.sel){this._insertStr(ie(this._config.tabSize),!1);return}M(this._tab,this._config.maxUndoHistory);const i=ie(this._config.tabSize);this._getSelRows().forEach(r=>{var o;this._tab.doc[r]=i+(this._tab.doc[r]??""),this._tokenCache.invalidateLine(r,((o=this._wm.segments[r])==null?void 0:o.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_unindentSel(){var e,t;M(this._tab,this._config.maxUndoHistory);const i=this._config.tabSize;this._getSelRows().forEach(r=>{var o;const s=this._tab.doc[r]??"";s.startsWith(ie(i))?this._tab.doc[r]=s.slice(i):s.startsWith(" ")&&(this._tab.doc[r]=s.slice(1)),this._tokenCache.invalidateLine(r,((o=this._wm.segments[r])==null?void 0:o.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_toggleWrap(){this._config.wordWrap=!this._config.wordWrap,this._vpEl.classList.toggle("sl-wrap-mode",this._config.wordWrap);const e=this._statusBar.querySelector(".sl-sb-wrap-btn");e&&(e.textContent=`⇥ Wrap: ${this._config.wordWrap?"ON":"OFF"}`,e.classList.toggle("sl-on",this._config.wordWrap)),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()}_getSelRows(){if(!this._tab.sel)return[this._tab.cur.row];const e=N(this._tab.sel),t=[];for(let i=e.ar;i<=e.fr;i++)t.push(i);return t}_posFromMouse(e){var t;const i=this._editorEl.getBoundingClientRect(),r=e.clientY-i.top+this._editorEl.scrollTop,o=this._config.showGutter?this._config.gutterWidth:0,s=e.clientX-i.left-o-14,a=this._config.lineHeight,l=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(r/a))),d=Math.max(0,Math.min((((t=this._wm.visualRows[l])==null?void 0:t.text)??"").length,Math.round(s/7.82)));return te(this._wm,l,d)}_openFind(e){this._findBar.classList.add("sl-open"),this._replaceRow.style.display=e&&this._config.findReplace?"":"none",this._findInput.focus(),this._findInput.select(),this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx=-1,this._navFind(1)):this._render()}_closeFind(){this._findBar.classList.remove("sl-open"),this._findMatches=[],this._findIdx=-1,this._findCount.textContent="–",this._focusInput(),this._render()}_runFind(e){this._findMatches=rr(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}this._findIdx=sr(this._findMatches,this._findIdx,e);const t=this._findMatches[this._findIdx];this._tab.cur={row:t.row,col:t.col},this._tab.sel={ar:t.row,ac:t.col,fr:t.row,fc:t.col+t.len},this._scrollIntoView(),this._render(),this._findCount.textContent=`${this._findIdx+1}/${this._findMatches.length}`}_acVisible(){return this._acPopup.style.display!=="none"}_acHide(){this._acPopup.style.display="none",this._acItems=[]}_acTrigger(){if(!this._config.autocomplete){this._acHide();return}this._acDebounceTimer!==null&&clearTimeout(this._acDebounceTimer),this._acDebounceTimer=setTimeout(()=>{this._acDebounceTimer=null,this._acTriggerNow()},120)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",r=this._config.language==="css",{prefix:o,start:s}=pr(i,e.col,r);this._acPrefix=o,this._acStartCol=s;const a=[];if(this._config.emmet){const d=Ke(i,e.col);if(d){const h=Ue(d.abbr);if(h){this._emmetAcStartCol=d.start;const c=h.replace(/\n/g,"↵ ").slice(0,60);a.push({label:d.abbr,kind:"emmet",detail:c,body:h})}}}const l=o.length>=this._config.autocompletePrefixLength?hr(t,o,{language:this._config.language,extraKeywords:this._config.extraKeywords,extraTypes:this._config.extraTypes,completions:this._allCompletions(),replaceBuiltins:this._config.replaceBuiltins,maxResults:this._config.maxCompletions,provideCompletions:this._config.provideCompletions},e.row,e.col):[];if(this._acItems=[...a,...l],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const e=l=>{switch(l){case"kw":return"K";case"fn":return"f";case"typ":return"T";case"cls":return"C";case"snip":return"S";case"emmet":return"E";default:return"·"}},t=this._acItems[this._acSel];let i="";t!=null&&t.description?i=t.description:(t==null?void 0:t.kind)==="snip"&&t.body?i=t.body.replace(/\$\d/g,"▌"):(t==null?void 0:t.kind)==="emmet"&&t.body&&(i=t.body);const r=this._acItems.map((l,d)=>{const h=d===this._acSel;return`<div class="sl-ac-item${h?" sl-sel":""}" data-i="${d}" role="option" aria-selected="${h}"><span class="sl-ac-badge ${l.kind}">${e(l.kind)}</span><span class="sl-ac-label">${l.label}</span><span class="sl-ac-detail">${l.detail??""}</span></div>`}).join(""),o=i?`<div class="sl-ac-desc"><pre class="sl-ac-desc-body">${i.replace(/</g,"<")}</pre></div>`:"";this._acPopup.innerHTML=`<div class="sl-ac-list">${r}</div>`+o,this._acPopup.style.display="flex",this._posAcPopup();const s=this._acPopup.querySelector(".sl-ac-list"),a=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(s&&a){const l=a.offsetTop,d=l+a.offsetHeight;d>s.scrollTop+s.clientHeight?s.scrollTop=d-s.clientHeight:l<s.scrollTop&&(s.scrollTop=l)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(l=>{l.addEventListener("mousedown",d=>{d.preventDefault(),this._acSel=parseInt(l.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=U(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,r=e.left+i+14+this._acStartCol*7.82,o=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,s=this._acPopup.querySelector(".sl-ac-desc")?620:300,a=Math.min(this._acItems.length*28+8,320),l=o+a>window.innerHeight-16;this._acPopup.style.left=`${Math.min(r,window.innerWidth-s-16)}px`,this._acPopup.style.top=`${l?o-this._config.lineHeight-2-a:o}px`}_acAccept(){const e=this._acItems[this._acSel];if(!e)return;if(this._acHide(),e.kind==="emmet"&&e.body){M(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._emmetAcStartCol);return}if(e.body){M(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._acStartCol);return}const t=e.label.slice(this._acPrefix.length);this._insertStr(t,!1),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render()}_emmetCheck(){if(this._emmetTip.style.display="none",!this._config.emmet){this._emmetExpanded=null;return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",r=Ke(i,e.col);if(!r){this._emmetExpanded=null;return}const o=Ue(r.abbr);if(!o){this._emmetExpanded=null;return}this._emmetExpanded={abbr:r.abbr,result:o,start:r.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{abbr:e,result:t,start:i}=this._emmetExpanded;return M(this._tab,this._config.maxUndoHistory),this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(t,i),!0}_allCompletions(){return[...this._config.replaceBuiltins?[]:Ji(this._config.language),...this._config.completions]}_snippetCheck(){if(this._snippetTip.style.display="none",!this._config.snippetExpansion){this._snippetExpanded=null;return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",r=Zi(i,e.col,this._allCompletions());if(!r){this._snippetExpanded=null;return}this._snippetExpanded={snippet:r.snippet,start:r.start}}_snippetAccept(){if(!this._snippetExpanded||this._snippetTip.style.display==="none")return!1;const{snippet:e,start:t}=this._snippetExpanded;return e.body?(M(this._tab,this._config.maxUndoHistory),this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t),!0):!1}_expandBodyAt(e,t){var i,r;const{doc:o,cur:s}=this._tab,a=o[s.row]??"",l=a.slice(0,t),d=a.slice(s.col),h=Ge(a),c=e.split(`
|
|
466
|
+
`).map((u,k)=>k===0?u:h+u),p=c.join(`
|
|
467
|
+
`),m=p.indexOf("$1"),g=c.map(u=>u.replace(/\$\d+/g,"")),f=g.length===1?[l+g[0]+d]:[l+g[0],...g.slice(1,-1),g[g.length-1]+d];if(o.splice(s.row,1,...f),m>=0){const u=p.slice(0,m).split(`
|
|
468
|
+
`),k=u.length-1,_=u[k].length,x=(u[k].match(/\$\d+/g)??[]).join("").length;s.row+=k,s.col=(k===0?t:h.length)+(_-x)}else s.row+=f.length-1,s.col=(f[f.length-1]??"").length-d.length;this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(r=(i=this._config).onChange)==null||r.call(i,A(this._tab.doc))}_openThemePicker(){var e;const t=this._themeManager.all;this._themePanel.innerHTML=`
|
|
469
|
+
<div class="sl-theme-header">
|
|
470
|
+
<div class="sl-theme-title">Color Theme</div>
|
|
471
|
+
<div class="sl-theme-close">✕</div>
|
|
472
|
+
</div>
|
|
473
|
+
<div class="sl-theme-list">
|
|
474
|
+
${t.map(i=>`
|
|
475
|
+
<div class="sl-theme-item${i.id===this._themeManager.activeId?" sl-active":""}" data-id="${i.id}">
|
|
476
|
+
<div class="sl-theme-swatch">
|
|
477
|
+
${i.tokens.bg0?`<span style="background:${i.tokens.bg0}"></span>`:""}
|
|
478
|
+
<span style="background:${i.tokens.accent}"></span>
|
|
479
|
+
<span style="background:${i.tokens.tokStr}"></span>
|
|
480
|
+
<span style="background:${i.tokens.tokFn}"></span>
|
|
481
|
+
</div>
|
|
482
|
+
<div>
|
|
483
|
+
<div class="sl-theme-name">${i.name}<span class="sl-theme-tag${i.light?" sl-light":""}">${i.light?"Light":"Dark"}</span></div>
|
|
484
|
+
<div class="sl-theme-desc">${i.description}</div>
|
|
485
|
+
</div>
|
|
486
|
+
<div class="sl-theme-check">✓</div>
|
|
487
|
+
</div>
|
|
488
|
+
`).join("")}
|
|
489
|
+
</div>
|
|
490
|
+
`,this._themeOverlay.style.display="block",(e=this._themePanel.querySelector(".sl-theme-close"))==null||e.addEventListener("click",()=>{this._themeOverlay.style.display="none"}),this._themeOverlay.addEventListener("click",i=>{i.target===this._themeOverlay&&(this._themeOverlay.style.display="none")},{once:!0}),this._themePanel.querySelectorAll(".sl-theme-item").forEach(i=>{i.addEventListener("click",()=>{const r=i.dataset.id??"";this.setTheme(r),this._themePanel.querySelectorAll(".sl-theme-item").forEach(o=>o.classList.remove("sl-active")),i.classList.add("sl-active")})})}_bindEditorEvents(){this._vpEl.addEventListener("mousedown",this._onFoldBtnClick),this._editorEl.addEventListener("mousedown",e=>{if(e.button!==0)return;e.preventDefault(),this._focusInput(),this._acHide(),this._emmetTip.style.display="none",e.altKey||(Xe(this._mc),this._extraCursors=[]);const t=this._posFromMouse(e);if(this._tab.cur={...t},e.detail===3)this._tab.sel={ar:t.row,ac:0,fr:t.row,fc:(this._tab.doc[t.row]??"").length},this._tab.cur.col=this._tab.sel.fc;else if(e.detail===2&&this._config.wordSelection){const i=this._tab.doc[t.row]??"",r=ge(i,t.col,this._isWordChar.bind(this)),o=be(i,t.col,this._isWordChar.bind(this));r!==o?(this._tab.sel={ar:t.row,ac:r,fr:t.row,fc:o},this._tab.cur.col=o):this._tab.sel=null}else{if(e.altKey&&this._config.multiCursor){Ye(this._mc,t.row,t.col,null),this._extraCursors=[...this._mc.cursors],this._render();return}this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...t}}L(this._tab),this._render()}),this._editorEl.addEventListener("mousemove",e=>{if(this._config.hover&&!this._hoverPinned&&!this._isDragging&&this._scheduleHover(e),!this._isDragging||!this._dragAnchor)return;const t=this._posFromMouse(e);this._tab.cur={...t},t.row!==this._dragAnchor.row||t.col!==this._dragAnchor.col?this._tab.sel={ar:this._dragAnchor.row,ac:this._dragAnchor.col,fr:t.row,fc:t.col}:this._tab.sel=null,L(this._tab),this._render()}),this._editorEl.addEventListener("mouseleave",()=>{this._hoverPinned||this._hideHover()}),window.addEventListener("mouseup",this._onWinMouseUp),this._editorEl.addEventListener("scroll",this._onEditorScroll,{passive:!0}),window.addEventListener("resize",this._onWinResize),this._inputEl.addEventListener("keydown",e=>this._onKeyDown(e)),this._inputEl.addEventListener("input",e=>this._onInput(e)),this._inputEl.addEventListener("paste",e=>{var t;if(e.preventDefault(),this._config.readOnly)return;const i=(t=e.clipboardData??window.clipboardData)==null?void 0:t.getData("text/plain");i&&(this._insertStr(i,!1),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render())}),this._editorEl.addEventListener("mousedown",()=>setTimeout(()=>this._focusInput(),0)),this._inputEl.addEventListener("focus",()=>{var e,t;return(t=(e=this._config).onFocus)==null?void 0:t.call(e)}),this._inputEl.addEventListener("blur",()=>{var e,t;return(t=(e=this._config).onBlur)==null?void 0:t.call(e)})}_onKeyDown(e){var t,i,r,o,s,a,l,d,h;const c=e.ctrlKey||e.metaKey,p=e.shiftKey,m=e.altKey,g=this._config.readOnly;if(this._hideHover(),this._acVisible()){if(e.key==="ArrowDown"){e.preventDefault(),this._acSel=Math.min(this._acItems.length-1,this._acSel+1),this._renderAcPopup();return}if(e.key==="ArrowUp"){e.preventDefault(),this._acSel=Math.max(0,this._acSel-1),this._renderAcPopup();return}if(e.key==="Tab"||e.key==="Enter"){e.preventDefault(),this._acAccept();return}if(e.key==="Escape"){this._acHide();return}}if(m&&(e.key==="z"||e.key==="Z"||e.key==="Ω")){e.preventDefault(),this._toggleWrap();return}if(c&&e.key==="z"&&!p){e.preventDefault(),g||this.undo();return}if(c&&(e.key==="y"||p&&e.key==="z")){e.preventDefault(),g||this.redo();return}if(c&&e.key==="a"){e.preventDefault(),this._selectAll();return}if(c&&e.key==="c"){e.preventDefault(),this._doCopy();return}if(c&&e.key==="x"){e.preventDefault(),g||this._doCut();return}if(c&&e.key==="f"){e.preventDefault(),this._config.find&&this._openFind(!1);return}if(c&&e.key==="h"){e.preventDefault(),this._config.find&&this._config.findReplace&&this._openFind(!0);return}if(c&&e.key==="d"){e.preventDefault(),!g&&this._config.multiCursor&&this._ctrlD();return}if(c&&p&&e.key==="d"){e.preventDefault(),g||this._duplicateLine();return}if(c&&e.key==="/"){e.preventDefault(),g||this._toggleComment();return}if(c&&e.key==="k"){e.preventDefault(),g||this._deleteLine();return}if(e.key==="Escape"){this._tab.sel=null,this._acHide(),this._closeFind(),this._emmetTip.style.display="none",this._snippetTip.style.display="none",this._snippetExpanded=null,Xe(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(g){this._handleArrowKeys(e,c,p);return}if(e.key==="Tab"){if(e.preventDefault(),!p&&this._emmetAccept()||!p&&this._snippetAccept())return;p?this._unindentSel():this._indentSel(),L(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){const f=tr(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors);this._tab.doc=f.doc,this._tab.cur.row=f.primaryRow,this._tab.cur.col=f.primaryCol,this._extraCursors=f.extraCursors,this._mc.cursors=f.extraCursors}else this._doBackspace();this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc));return}if(e.key==="Delete"){e.preventDefault(),this._doDelete(),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(o=(r=this._config).onChange)==null||o.call(r,A(this._tab.doc));return}if(e.key==="Enter"){e.preventDefault(),this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(a=(s=this._config).onChange)==null||a.call(s,A(this._tab.doc));return}if(!c&&!m&&this._config.autoClosePairs[e.key]){e.preventDefault(),M(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=q(this._tab));const{doc:f,cur:u}=this._tab,k=f[u.row]??"";f[u.row]=k.slice(0,u.col)+e.key+this._config.autoClosePairs[e.key]+k.slice(u.col),u.col++,this._tokenCache.invalidateLine(u.row,((l=this._wm.segments[u.row])==null?void 0:l.length)??1),this._tab.dirty=!0,this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(h=(d=this._config).onChange)==null||h.call(d,A(this._tab.doc));return}if(!c&&!m&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:f,cur:u}=this._tab;if((f[u.row]??"")[u.col]===e.key){e.preventDefault(),u.col++,L(this._tab),this._scrollIntoView(),this._render();return}}if(m&&!c&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._moveLines(e.key==="ArrowUp");return}this._handleArrowKeys(e,c,p)}_handleArrowKeys(e,t,i){var r,o,s,a,l,d;const{doc:h,cur:c}=this._tab,p=this._config.lineHeight,m=e.metaKey,g=e.ctrlKey,f=e.altKey,u=(x,v)=>{if(i){this._tab.sel||(this._tab.sel={ar:c.row,ac:c.col,fr:c.row,fc:c.col}),c.row=x,c.col=v;const E=this._tab.sel;E.fr=x,E.fc=v,E.ar===E.fr&&E.ac===E.fc&&(this._tab.sel=null)}else this._tab.sel=null,c.row=x,c.col=v},k=x=>{const v=(h[x]??"").search(/\S/);return v===-1||c.col===v?0:v},_=()=>({row:h.length-1,col:(h[h.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const x=N(this._tab.sel);c.row=x.fr,c.col=x.fc,this._tab.sel=null;break}if(m)u(c.row,(h[c.row]??"").length);else if(g||f){const x=this._wordSkipRight(h[c.row]??"",c.col);u(c.row,x)}else c.col<(h[c.row]??"").length?u(c.row,c.col+1):c.row<h.length-1&&u(c.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const x=N(this._tab.sel);c.row=x.ar,c.col=x.ac,this._tab.sel=null;break}if(m)u(c.row,k(c.row));else if(g||f){const x=this._wordSkipLeft(h[c.row]??"",c.col);u(c.row,x)}else c.col>0?u(c.row,c.col-1):c.row>0&&u(c.row-1,(h[c.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),m){const x=_();u(x.row,x.col)}else if(this._config.wordWrap){const x=U(this._wm,c.row,c.col),v=Math.min(this._wm.visualRows.length-1,x.visRow+1),E=te(this._wm,v,Math.min(x.colInSeg,(((r=this._wm.visualRows[v])==null?void 0:r.text)??"").length));u(E.row,E.col)}else{const x=Math.min(h.length-1,c.row+1);u(x,Math.min(c.col,(h[x]??"").length))}break;case"ArrowUp":if(e.preventDefault(),m)u(0,0);else if(this._config.wordWrap){const x=U(this._wm,c.row,c.col),v=Math.max(0,x.visRow-1),E=te(this._wm,v,Math.min(x.colInSeg,(((o=this._wm.visualRows[v])==null?void 0:o.text)??"").length));u(E.row,E.col)}else{const x=Math.max(0,c.row-1);u(x,Math.min(c.col,(h[x]??"").length))}break;case"Home":e.preventDefault(),g?u(0,0):u(c.row,k(c.row));break;case"End":if(e.preventDefault(),g){const x=_();u(x.row,x.col)}else u(c.row,(h[c.row]??"").length);break;case"PageDown":e.preventDefault();{const x=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),v=Math.min(h.length-1,c.row+x);u(v,Math.min(c.col,(h[v]??"").length)),this._editorEl.scrollTop+=this._editorEl.clientHeight-p;break}case"PageUp":e.preventDefault();{const x=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),v=Math.max(0,c.row-x);u(v,Math.min(c.col,(h[v]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-p;break}default:return}L(this._tab),this._scrollIntoView(),this._acHide(),(a=(s=this._config).onCursorChange)==null||a.call(s,{...this._tab.cur}),(d=(l=this._config).onSelectionChange)==null||d.call(l,this._tab.sel?{...this._tab.sel}:null),this._render()}_isWordChar(e){const t=this._config.wordSeparators;return t?e.trim()!==""&&!t.includes(e):/[\w$]/.test(e)}_wordSkipRight(e,t){let i=t;for(;i<e.length&&/\s/.test(e[i]);)i++;for(;i<e.length&&/\S/.test(e[i]);)i++;return i}_wordSkipLeft(e,t){let i=t;for(;i>0&&/\s/.test(e[i-1]);)i--;for(;i>0&&/\S/.test(e[i-1]);)i--;return i}_moveLines(e){var t,i,r,o;const{doc:s,cur:a}=this._tab,l=this._tab.sel;let d=a.row,h=a.row;if(l){const c=N(l);d=c.ar,h=c.fr,c.fc===0&&c.fr>c.ar&&h--}if(e){if(d===0)return;M(this._tab,this._config.maxUndoHistory);const c=s.splice(d,h-d+1);s.splice(d-1,0,...c),a.row--,l&&(l.ar--,l.fr--)}else{if(h>=s.length-1)return;M(this._tab,this._config.maxUndoHistory);const c=s.splice(d,h-d+1);s.splice(d+1,0,...c),a.row++,l&&(l.ar++,l.fr++)}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc)),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur})}_scheduleHover(e){this._hoverTip.style.display!=="none"&&(this._hoverTip.style.display="none"),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null);const{clientX:t,clientY:i}=e;this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._doHover(t,i)},500)}_doHover(e,t){var i,r,o;if(!this._config.hover)return;const s=this._editorEl.getBoundingClientRect(),a=t-s.top+this._editorEl.scrollTop,l=this._config.showGutter?this._config.gutterWidth:0,d=e-s.left-l-14,h=this._config.lineHeight,c=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(a/h))),p=Math.max(0,Math.min((((i=this._wm.visualRows[c])==null?void 0:i.text)??"").length,Math.round(d/7.82))),m=te(this._wm,c,p),g=this._tab.doc[m.row]??"",f=ur(g,m.col);if(!f)return;let u=gr(f,this._config.language);if(!u){const k=this._config.completions.find(_=>_.label===f);k&&(k.description||k.detail)&&(u={title:k.label,type:k.detail,body:k.description??""})}if(!u){const k=(o=(r=this._config).provideHover)==null?void 0:o.call(r,{word:f,row:m.row,col:m.col,line:g,language:this._config.language,doc:this._tab.doc});k&&(u=k)}u&&this._showHoverTip(u,e,t)}_showHoverTip(e,t,i){const r=this._hoverTip;let o='<div class="sl-ht-sig">';o+=`<span class="sl-ht-title">${X(e.title)}</span>`,e.type&&(o+=`<code class="sl-ht-type">${X(e.type)}</code>`),o+="</div>",e.title&&e.body&&(o+='<div class="sl-ht-divider"></div>'),e.body&&(o+=`<div class="sl-ht-body">${X(e.body)}</div>`),r.innerHTML=o,r.style.display="block";const s=12,a=18,l=r.offsetWidth||300,d=r.offsetHeight||80;let h=t,c=i+a;c+d>window.innerHeight-s&&(c=i-d-8),h+l>window.innerWidth-s&&(h=window.innerWidth-l-s),h<s&&(h=s),r.style.left=`${h}px`,r.style.top=`${Math.max(s,c)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_onInput(e){var t,i,r,o;if(this._config.readOnly){e.target.value="";return}const s=e.target,a=s.value;if(s.value="",!a||a==="Ω")return;const l=a.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(l){if(this._extraCursors.length){const d=er(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors,l);this._tab.doc=d.doc,this._tab.cur.row=d.primaryRow,this._tab.cur.col=d.primaryCol,this._extraCursors=d.extraCursors,this._mc.cursors=d.extraCursors,this._tab.dirty=!0,(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc))}else this._insertStr(l,!0);this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur})}}_ctrlD(){if(!this._config.multiCursor)return;const e=ir(this._mc,this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel);e&&(!this._mc.cursors.length||e.word!==this._mc.searchWord?(this._tab.sel=e.sel,this._tab.cur.col=e.col):(Ye(this._mc,e.row,e.col,e.sel),this._extraCursors=[...this._mc.cursors]),this._mc.searchWord=e.word,this._mc.lastMatchRow=e.row,this._mc.lastMatchCol=e.col,this._scrollIntoView(),this._render())}_bindFindEvents(){var e,t,i,r,o,s,a;this._findInput.addEventListener("input",()=>{this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),this._findInput.addEventListener("keydown",l=>{l.key==="Enter"?l.shiftKey?this._navFind(-1):this._navFind(1):l.key==="Escape"&&this._closeFind(),l.stopPropagation()}),this._replaceInput.addEventListener("keydown",l=>{l.key==="Enter"?this._doReplaceOne():l.key==="Escape"&&this._closeFind(),l.stopPropagation()}),(e=this._findBar.querySelector(".sl-find-prev"))==null||e.addEventListener("click",()=>this._navFind(-1)),(t=this._findBar.querySelector(".sl-find-next"))==null||t.addEventListener("click",()=>this._navFind(1)),(i=this._findBar.querySelector(".sl-find-close"))==null||i.addEventListener("click",()=>this._closeFind()),(r=this._findBar.querySelector(".sl-find-case"))==null||r.addEventListener("click",l=>{this._findCaseSensitive=!this._findCaseSensitive,l.target.classList.toggle("sl-active",this._findCaseSensitive),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(o=this._findBar.querySelector(".sl-find-regex"))==null||o.addEventListener("click",l=>{this._findRegex=!this._findRegex,l.target.classList.toggle("sl-active",this._findRegex),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(s=this._findBar.querySelector(".sl-replace-one"))==null||s.addEventListener("click",()=>this._doReplaceOne()),(a=this._findBar.querySelector(".sl-replace-all"))==null||a.addEventListener("click",()=>this._doReplaceAll())}_doReplaceOne(){var e,t;this._findIdx<0||!this._findMatches.length||(M(this._tab,this._config.maxUndoHistory),this._tab.doc=nr(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0,this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx>=this._findMatches.length&&(this._findIdx=0),this._navFind(0)):(this._findCount.textContent="0/0",this._rebuildWrapMap(),this._render()),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc)))}_doReplaceAll(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches.length;M(this._tab,this._config.maxUndoHistory),this._tab.doc=or(this._tab.doc,this._findMatches,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0,this._findMatches=[],this._findIdx=-1,this._findCount.textContent=`0/0 (${i} replaced)`,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_bindMinimapEvents(){const e=this._minimapWrap;e.addEventListener("mousemove",t=>{if(this._mmDragMode!=="none")return;const i=t.clientY-e.getBoundingClientRect().top,{sliderTop:r,sliderHeight:o}=_e(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=r&&i<=r+o?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,r=t.clientY-e.getBoundingClientRect().top,{sliderTop:o,sliderHeight:s}=_e(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);if(r>=o&&r<=o+s)this._mmDragMode="slider",this._mmSliderOffset=r-o,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const a=wr(r,this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=a,this._mmDragStartY=t.clientY,this._mmDragStartScroll=a,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}const et={id:"mdx-dark",name:"MDX Dark",description:"Catppuccin Mocha — matches .smdx-dark MDX editor chrome, single-colour tokens",light:!1,tokens:{bg0:"#181825",bg1:"#1e1e2e",bg2:"#1e1e2e",bg3:"#2a2a3c",bg4:"#313147",border:"#374151",border2:"rgba(129,140,248,.22)",border3:"rgba(129,140,248,.40)",text:"#e2e8f0",text2:"#94a3b8",text3:"#475569",accent:"#818cf8",accent2:"#6366f1",green:"#c3e88d",orange:"#f78c6c",purple:"#c792ea",red:"#f07178",yellow:"#ffcb6b",cur:"#818cf8",curGlow:"rgba(129,140,248,.55)",curLineBg:"rgba(129,140,248,.055)",curLineGutter:"#252540",gutterBg:"#181825",gutterHover:"#252540",gutterBorder:"#374151",gutterNum:"#475569",gutterNumAct:"#94a3b8",selBg:"rgba(129,140,248,.24)",wordHlBg:"rgba(226,232,240,.07)",wordHlBorder:"rgba(226,232,240,.25)",bmBorder:"rgba(137,221,255,.70)",foldBg:"rgba(129,140,248,.07)",foldBorder:"rgba(129,140,248,.30)",findBg:"rgba(251,191,36,.16)",findBorder:"rgba(251,191,36,.50)",findCurBg:"rgba(251,191,36,.85)",findCurBorder:"rgba(251,191,36,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(129,140,248,.12)",fileActiveText:"#818cf8",mmBg:"#181825",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#e2e8f0",tokStr:"#e2e8f0",tokCmt:"#e2e8f0",tokFn:"#e2e8f0",tokNum:"#e2e8f0",tokCls:"#e2e8f0",tokOp:"#e2e8f0",tokTyp:"#e2e8f0",tokDec:"#e2e8f0"}},tt={id:"mdx-light",name:"MDX Light",description:"Clean light — matches default .smdx-editor MDX chrome, single-colour tokens",light:!0,tokens:{bg0:"#f1f5f9",bg1:"#ffffff",bg2:"#ffffff",bg3:"#f8fafc",bg4:"#f1f5f9",border:"#e2e8f0",border2:"rgba(99,102,241,.20)",border3:"rgba(99,102,241,.40)",text:"#1e293b",text2:"#64748b",text3:"#94a3b8",accent:"#6366f1",accent2:"#4f46e5",green:"#15803d",orange:"#c2410c",purple:"#7c3aed",red:"#dc2626",yellow:"#b45309",cur:"#6366f1",curGlow:"rgba(99,102,241,.35)",curLineBg:"rgba(99,102,241,.05)",curLineGutter:"#eef2ff",gutterBg:"#f8fafc",gutterHover:"#eef2ff",gutterBorder:"#e2e8f0",gutterNum:"#94a3b8",gutterNumAct:"#475569",selBg:"rgba(99,102,241,.18)",wordHlBg:"rgba(99,102,241,.07)",wordHlBorder:"rgba(99,102,241,.30)",bmBorder:"rgba(14,116,144,.60)",foldBg:"rgba(99,102,241,.06)",foldBorder:"rgba(99,102,241,.28)",findBg:"rgba(180,83,9,.09)",findBorder:"rgba(180,83,9,.40)",findCurBg:"rgba(180,83,9,.75)",findCurBorder:"rgba(180,83,9,.95)",findCurText:"#ffffff",fileActiveBg:"rgba(99,102,241,.10)",fileActiveText:"#6366f1",mmBg:"#f8fafc",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.05)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#1e293b",tokStr:"#1e293b",tokCmt:"#1e293b",tokFn:"#1e293b",tokNum:"#1e293b",tokCls:"#1e293b",tokOp:"#1e293b",tokTyp:"#1e293b",tokDec:"#1e293b"}},Er="#e2e8f0",Sr="#1e293b";function it(n){return{keyword:n,string:n,comment:n,function:n,number:n,class:n,operator:n,type:n,decorator:n}}const rt=it(Er),nt=it(Sr),re={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},Mr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ne=[{label:"title",kind:"var",detail:"attribute"},{label:"color",kind:"var",detail:"attribute"},{label:"icon",kind:"var",detail:"attribute"},{label:"href",kind:"var",detail:"attribute"},{label:"src",kind:"var",detail:"attribute"},{label:"alt",kind:"var",detail:"attribute"},{label:"className",kind:"var",detail:"attribute"},{label:"style",kind:"var",detail:"attribute"},{label:"id",kind:"var",detail:"attribute"},{label:"type",kind:"var",detail:"attribute"},{label:"lang",kind:"var",detail:"attribute"},{label:"label",kind:"var",detail:"attribute"},{label:"description",kind:"var",detail:"attribute"},{label:"variant",kind:"var",detail:"attribute"},{label:"size",kind:"var",detail:"attribute"}],ot=[{label:"h1",kind:"snip",detail:"Heading 1",body:"# $1Heading"},{label:"h2",kind:"snip",detail:"Heading 2",body:"## $1Heading"},{label:"h3",kind:"snip",detail:"Heading 3",body:"### $1Heading"},{label:"h4",kind:"snip",detail:"Heading 4",body:"#### $1Heading"},{label:"h5",kind:"snip",detail:"Heading 5",body:"##### $1Heading"},{label:"h6",kind:"snip",detail:"Heading 6",body:"###### $1Heading"},{label:"bold",kind:"snip",detail:"bold text",body:"**$1bold text**"},{label:"italic",kind:"snip",detail:"italic text",body:"*$1italic text*"},{label:"strike",kind:"snip",detail:"strikethrough",body:"~~$1strikethrough~~"},{label:"code",kind:"snip",detail:"inline code",body:"`$1code`"},{label:"link",kind:"snip",detail:"markdown link",body:"[link text](url)"},{label:"img",kind:"snip",detail:"image",body:""},{label:"cb",kind:"snip",detail:"fenced code block",body:"```language\ncode here\n```"},{label:"quote",kind:"snip",detail:"blockquote",body:"> $1"},{label:"hr",kind:"snip",detail:"horizontal rule",body:"---"},{label:"ul",kind:"snip",detail:"unordered list",body:`- $1Item 1
|
|
491
|
+
- $2Item 2
|
|
492
|
+
- $3Item 3`},{label:"ol",kind:"snip",detail:"ordered list",body:`1. $1Item 1
|
|
493
|
+
2. $2Item 2
|
|
494
|
+
3. $3Item 3`},{label:"task",kind:"snip",detail:"task list",body:`- [ ] $1Task 1
|
|
495
|
+
- [ ] $2Task 2
|
|
496
|
+
- [ ] $3Task 3`},{label:"tbl",kind:"snip",detail:"markdown table",body:`| Header 1 | Header 2 | Header 3 |
|
|
17
497
|
| -------- | -------- | -------- |
|
|
18
498
|
| Cell 1 | Cell 2 | Cell 3 |
|
|
19
|
-
| Cell 4 | Cell 5 | Cell 6 |`
|
|
499
|
+
| Cell 4 | Cell 5 | Cell 6 |`},{label:"hl-yellow",kind:"snip",detail:"yellow highlight",body:'<Highlight color="yellow">$1text</Highlight>'},{label:"hl-green",kind:"snip",detail:"green highlight",body:'<Highlight color="green">$1text</Highlight>'},{label:"hl-blue",kind:"snip",detail:"blue highlight",body:'<Highlight color="blue">$1text</Highlight>'},{label:"hl-purple",kind:"snip",detail:"purple highlight",body:'<Highlight color="purple">$1text</Highlight>'},{label:"hl-pink",kind:"snip",detail:"pink highlight",body:'<Highlight color="pink">$1text</Highlight>'},{label:"hl-red",kind:"snip",detail:"red highlight",body:'<Highlight color="red">$1text</Highlight>'},{label:"hl-orange",kind:"snip",detail:"orange highlight",body:'<Highlight color="orange">$1text</Highlight>'},{label:"hl-cyan",kind:"snip",detail:"cyan highlight",body:'<Highlight color="cyan">$1text</Highlight>'},{label:"adm-tip",kind:"snip",detail:":::tip admonition",body:`:::tip
|
|
500
|
+
TIP: $1Your message here
|
|
501
|
+
:::`},{label:"adm-warning",kind:"snip",detail:":::warning admonition",body:`:::warning
|
|
502
|
+
WARNING: $1Your message here
|
|
503
|
+
:::`},{label:"adm-caution",kind:"snip",detail:":::caution admonition",body:`:::caution
|
|
504
|
+
CAUTION: $1Your message here
|
|
505
|
+
:::`},{label:"adm-danger",kind:"snip",detail:":::danger admonition",body:`:::danger
|
|
506
|
+
DANGER: $1Your message here
|
|
507
|
+
:::`},{label:"adm-check",kind:"snip",detail:":::check admonition",body:`:::check
|
|
508
|
+
CHECK: $1Your message here
|
|
509
|
+
:::`},{label:"adm-info",kind:"snip",detail:":::info admonition",body:`:::info
|
|
510
|
+
INFO: $1Your message here
|
|
511
|
+
:::`},{label:"adm-note",kind:"snip",detail:":::note admonition",body:`:::note
|
|
512
|
+
NOTE: $1Your message here
|
|
513
|
+
:::`},{label:"info",kind:"snip",detail:":::info callout",body:`:::info
|
|
514
|
+
INFO: $1Your message here
|
|
515
|
+
:::`},{label:"tip",kind:"snip",detail:":::tip callout",body:`:::tip
|
|
516
|
+
TIP: $1Your message here
|
|
517
|
+
:::`},{label:"warn",kind:"snip",detail:":::warning callout",body:`:::warning
|
|
518
|
+
WARNING: $1Your message here
|
|
519
|
+
:::`},{label:"danger",kind:"snip",detail:":::danger callout",body:`:::danger
|
|
520
|
+
DANGER: $1Your message here
|
|
521
|
+
:::`},{label:"note",kind:"snip",detail:":::note callout",body:`:::note
|
|
522
|
+
NOTE: $1Your message here
|
|
523
|
+
:::`},{label:"tipgood",kind:"snip",detail:"<TipGood> block",body:"<TipGood>$1Your tip message here</TipGood>"},{label:"tipbad",kind:"snip",detail:"<TipBad> block",body:"<TipBad>$1Your tip message here</TipBad>"},{label:"tipinfo",kind:"snip",detail:"<TipInfo> block",body:"<TipInfo>$1Your tip message here</TipInfo>"},{label:"accordion",kind:"snip",detail:"<Accordion> component",body:`<Accordion title="$1Accordion Title" defaultOpen>
|
|
524
|
+
$2Your content here. You can include any markdown or components.
|
|
525
|
+
</Accordion>`},{label:"accordiongroup",kind:"snip",detail:"<AccordionGroup> component",body:`<AccordionGroup>
|
|
526
|
+
<Accordion title="$1Section 1" defaultOpen>
|
|
527
|
+
$2Content for section 1
|
|
528
|
+
</Accordion>
|
|
529
|
+
<Accordion title="$3Section 2">
|
|
530
|
+
$4Content for section 2
|
|
531
|
+
</Accordion>
|
|
532
|
+
<Accordion title="$5Section 3">
|
|
533
|
+
$6Content for section 3
|
|
534
|
+
</Accordion>
|
|
535
|
+
</AccordionGroup>`},{label:"col2",kind:"snip",detail:"2-column layout",body:`<Columns count="2">
|
|
536
|
+
<Column>
|
|
537
|
+
$1Column 1 content
|
|
538
|
+
</Column>
|
|
539
|
+
<Column>
|
|
540
|
+
$2Column 2 content
|
|
541
|
+
</Column>
|
|
542
|
+
</Columns>`},{label:"col3",kind:"snip",detail:"3-column layout",body:`<Columns count="3">
|
|
543
|
+
<Column>
|
|
544
|
+
$1Column 1 content
|
|
545
|
+
</Column>
|
|
546
|
+
<Column>
|
|
547
|
+
$2Column 2 content
|
|
548
|
+
</Column>
|
|
549
|
+
<Column>
|
|
550
|
+
$3Column 3 content
|
|
551
|
+
</Column>
|
|
552
|
+
</Columns>`},{label:"col4",kind:"snip",detail:"4-column layout",body:`<Columns count="4">
|
|
553
|
+
<Column>
|
|
554
|
+
$1Column 1 content
|
|
555
|
+
</Column>
|
|
556
|
+
<Column>
|
|
557
|
+
$2Column 2 content
|
|
558
|
+
</Column>
|
|
559
|
+
<Column>
|
|
560
|
+
$3Column 3 content
|
|
561
|
+
</Column>
|
|
562
|
+
<Column>
|
|
563
|
+
$4Column 4 content
|
|
564
|
+
</Column>
|
|
565
|
+
</Columns>`},{label:"col5",kind:"snip",detail:"5-column layout",body:`<Columns count="5">
|
|
566
|
+
<Column>
|
|
567
|
+
$1Column 1 content
|
|
568
|
+
</Column>
|
|
569
|
+
<Column>
|
|
570
|
+
$2Column 2 content
|
|
571
|
+
</Column>
|
|
572
|
+
<Column>
|
|
573
|
+
$3Column 3 content
|
|
574
|
+
</Column>
|
|
575
|
+
<Column>
|
|
576
|
+
$4Column 4 content
|
|
577
|
+
</Column>
|
|
578
|
+
<Column>
|
|
579
|
+
$5Column 5 content
|
|
580
|
+
</Column>
|
|
581
|
+
</Columns>`},{label:"columns",kind:"snip",detail:"2-column layout",body:`<Columns count="2">
|
|
582
|
+
<Column>
|
|
583
|
+
$1Column 1 content
|
|
584
|
+
</Column>
|
|
585
|
+
<Column>
|
|
586
|
+
$2Column 2 content
|
|
587
|
+
</Column>
|
|
588
|
+
</Columns>`},{label:"card",kind:"snip",detail:"<Card> component",body:`<Card title="$1Card Title" icon="📄" href="$2/link">
|
|
589
|
+
$3Card description or content goes here.
|
|
590
|
+
</Card>`},{label:"cards",kind:"snip",detail:"<CardGroup> component",body:`<CardGroup cols="2">
|
|
591
|
+
<Card title="$1Card 1" icon="📄">
|
|
592
|
+
$2Description for card 1
|
|
593
|
+
</Card>
|
|
594
|
+
<Card title="$3Card 2" icon="📄">
|
|
595
|
+
$4Description for card 2
|
|
596
|
+
</Card>
|
|
597
|
+
</CardGroup>`},{label:"steps",kind:"snip",detail:"<Steps> component",body:`<Steps>
|
|
598
|
+
<Step title="$1First Step">
|
|
599
|
+
$2These are instructions or content that only pertain to the first step.
|
|
600
|
+
</Step>
|
|
601
|
+
<Step title="$3Second Step">
|
|
602
|
+
$4These are instructions or content that only pertain to the second step.
|
|
603
|
+
</Step>
|
|
604
|
+
<Step title="$5Third Step">
|
|
605
|
+
$6These are instructions or content that only pertain to the third step.
|
|
606
|
+
</Step>
|
|
607
|
+
</Steps>`},{label:"container",kind:"snip",detail:"<Container> block",body:`<Container>
|
|
608
|
+
$1Content inside a styled container.
|
|
609
|
+
</Container>`},{label:"tabs",kind:"snip",detail:"<Tabs> component",body:`<Tabs>
|
|
610
|
+
<Tab title="$1Tab 1">
|
|
611
|
+
$2Content for tab 1
|
|
612
|
+
</Tab>
|
|
613
|
+
<Tab title="$3Tab 2">
|
|
614
|
+
$4Content for tab 2
|
|
615
|
+
</Tab>
|
|
616
|
+
</Tabs>`},{label:"mermaid",kind:"snip",detail:"Mermaid diagram (flowchart)",body:"```mermaid\ngraph TD\n Start --> Stop\n```"},{label:"mermaid-flow",kind:"snip",detail:"Mermaid flowchart",body:"```mermaid\ngraph TD\n Start --> Stop\n```"},{label:"mermaid-seq",kind:"snip",detail:"Mermaid sequence diagram",body:"```mermaid\nsequenceDiagram\n Alice->>John: Hello John, how are you?\n John-->>Alice: Great!\n Alice-)John: See you later!\n```"},{label:"mermaid-class",kind:"snip",detail:"Mermaid class diagram",body:`\`\`\`mermaid
|
|
617
|
+
classDiagram
|
|
618
|
+
Animal <|-- Duck
|
|
619
|
+
Animal <|-- Fish
|
|
620
|
+
Animal : +int age
|
|
621
|
+
Animal : +String gender
|
|
622
|
+
Animal: +isMammal()
|
|
623
|
+
class Duck{
|
|
624
|
+
+String beakColor
|
|
625
|
+
+swim()
|
|
626
|
+
+quack()
|
|
627
|
+
}
|
|
628
|
+
\`\`\``},{label:"mermaid-state",kind:"snip",detail:"Mermaid state diagram",body:`\`\`\`mermaid
|
|
629
|
+
stateDiagram-v2
|
|
630
|
+
[*] --> Still
|
|
631
|
+
Still --> [*]
|
|
632
|
+
Still --> Moving
|
|
633
|
+
Moving --> Still
|
|
634
|
+
Moving --> Crash
|
|
635
|
+
Crash --> [*]
|
|
636
|
+
\`\`\``},{label:"mermaid-er",kind:"snip",detail:"Mermaid ER diagram",body:"```mermaid\nerDiagram\n CUSTOMER ||--o{ ORDER : places\n ORDER ||--|{ LINE-ITEM : contains\n CUSTOMER }|..|{ DELIVERY-ADDRESS : uses\n```"},{label:"mermaid-journey",kind:"snip",detail:"Mermaid user journey",body:`\`\`\`mermaid
|
|
637
|
+
journey
|
|
638
|
+
title My working day
|
|
639
|
+
section Go to work
|
|
640
|
+
Make tea: 5: Me
|
|
641
|
+
Go upstairs: 3: Me
|
|
642
|
+
Do work: 1: Me, Cat
|
|
643
|
+
section Go home
|
|
644
|
+
Go downstairs: 5: Me
|
|
645
|
+
Sit down: 5: Me
|
|
646
|
+
\`\`\``},{label:"mermaid-gantt",kind:"snip",detail:"Mermaid Gantt chart",body:`\`\`\`mermaid
|
|
647
|
+
gantt
|
|
648
|
+
title A Gantt Diagram
|
|
649
|
+
dateFormat YYYY-MM-DD
|
|
650
|
+
section Section
|
|
651
|
+
A task :a1, 2014-01-01, 30d
|
|
652
|
+
Another task :after a1 , 20d
|
|
653
|
+
section Another
|
|
654
|
+
Task in sec :2014-01-12 , 12d
|
|
655
|
+
another task : 24d
|
|
656
|
+
\`\`\``},{label:"youtube",kind:"snip",detail:"Embed YouTube video",body:'<EmbedVideo type="youtube" src="$1https://www.youtube.com/watch?v=VIDEO_ID" />'},{label:"video",kind:"snip",detail:"Embed video file",body:'<EmbedVideo type="file" src="$1video.mp4" />'},{label:"gist",kind:"snip",detail:"Embed GitHub Gist",body:'<Embed type="github" src="$1https://gist.github.com/USER/GIST_ID" />'},{label:"tweet",kind:"snip",detail:"Embed Tweet / X post",body:'<Embed type="twitter" src="$1https://twitter.com/user/status/TWEET_ID" />'},{label:"codepen",kind:"snip",detail:"Embed CodePen",body:'<Embed type="codepen" src="$1https://codepen.io/user/pen/PEN_ID" />'},{label:"codesandbox",kind:"snip",detail:"Embed CodeSandbox",body:'<Embed type="codesandbox" src="$1https://codesandbox.io/s/SANDBOX_ID" />'},{label:"math",kind:"snip",detail:"inline math formula",body:"$$1formula$"},{label:"mathblock",kind:"snip",detail:"block math formula",body:`$$
|
|
657
|
+
$1E = mc^2
|
|
658
|
+
$$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<CopyText>$1Text that users can click to copy</CopyText>"},{label:"tooltip",kind:"snip",detail:"<Tooltip> inline hover tip",body:'<Tooltip tip="$1Tooltip content">$2hover text</Tooltip>'},{label:"import",kind:"snip",detail:"<Import> external markdown file",body:'<Import src="$1./path/to/file.md" />'},{label:"snippet",kind:"snip",detail:"<Snippet> code reference",body:'<Snippet src="$1./snippets/example.ts" lines="$21-20" />'},{label:"endpoint",kind:"snip",detail:"<Endpoint> GET block",body:`<Endpoint method="GET" path="$1/api/v1/resource">
|
|
659
|
+
$2Description of the endpoint.
|
|
660
|
+
|
|
661
|
+
**Parameters:**
|
|
662
|
+
| Name | Type | Description |
|
|
663
|
+
|------|------|-------------|
|
|
664
|
+
| id | string | Resource ID |
|
|
665
|
+
|
|
666
|
+
**Response:**
|
|
667
|
+
\`\`\`json
|
|
668
|
+
{
|
|
669
|
+
"status": "success",
|
|
670
|
+
"data": {}
|
|
671
|
+
}
|
|
672
|
+
\`\`\`
|
|
673
|
+
</Endpoint>`},{label:"endpoint-post",kind:"snip",detail:"<Endpoint> POST block",body:`<Endpoint method="POST" path="$1/api/v1/resource">
|
|
674
|
+
$2Description of the endpoint.
|
|
675
|
+
|
|
676
|
+
**Body:**
|
|
677
|
+
| Name | Type | Description |
|
|
678
|
+
|------|------|-------------|
|
|
679
|
+
| name | string | Resource name |
|
|
680
|
+
|
|
681
|
+
**Response:**
|
|
682
|
+
\`\`\`json
|
|
683
|
+
{
|
|
684
|
+
"status": "created",
|
|
685
|
+
"data": {}
|
|
686
|
+
}
|
|
687
|
+
\`\`\`
|
|
688
|
+
</Endpoint>`},{label:"endpoint-put",kind:"snip",detail:"<Endpoint> PUT block",body:`<Endpoint method="PUT" path="$1/api/v1/resource/{id}">
|
|
689
|
+
$2Update an existing resource.
|
|
690
|
+
|
|
691
|
+
**Body:**
|
|
692
|
+
| Name | Type | Description |
|
|
693
|
+
|------|------|-------------|
|
|
694
|
+
| name | string | Updated name |
|
|
695
|
+
|
|
696
|
+
**Response:**
|
|
697
|
+
\`\`\`json
|
|
698
|
+
{
|
|
699
|
+
"status": "updated",
|
|
700
|
+
"data": {}
|
|
701
|
+
}
|
|
702
|
+
\`\`\`
|
|
703
|
+
</Endpoint>`},{label:"endpoint-patch",kind:"snip",detail:"<Endpoint> PATCH block",body:`<Endpoint method="PATCH" path="$1/api/v1/resource/{id}">
|
|
704
|
+
$2Partially update a resource.
|
|
705
|
+
|
|
706
|
+
**Body:**
|
|
707
|
+
| Name | Type | Description |
|
|
708
|
+
|------|------|-------------|
|
|
709
|
+
| field | string | Field to update |
|
|
710
|
+
|
|
711
|
+
**Response:**
|
|
712
|
+
\`\`\`json
|
|
713
|
+
{
|
|
714
|
+
"status": "updated",
|
|
715
|
+
"data": {}
|
|
716
|
+
}
|
|
717
|
+
\`\`\`
|
|
718
|
+
</Endpoint>`},{label:"endpoint-delete",kind:"snip",detail:"<Endpoint> DELETE block",body:`<Endpoint method="DELETE" path="$1/api/v1/resource/{id}">
|
|
719
|
+
$2Delete a resource by ID.
|
|
720
|
+
|
|
721
|
+
**Response:**
|
|
722
|
+
\`\`\`json
|
|
723
|
+
{
|
|
724
|
+
"status": "deleted"
|
|
725
|
+
}
|
|
726
|
+
\`\`\`
|
|
727
|
+
</Endpoint>`}];class st{constructor(e){this.tocCollapsed=!1,this.themeObserver=null,this.events=new Se,this.renderer=new Q,this.renderTimer=null,this._destroyed=!1,this._userCompletions=[],this.config=e,this.mode=e.mode||"split",this.init()}init(){const e=typeof this.config.container=="string"?document.querySelector(this.config.container):this.config.container;if(!e)throw new Error("[SynclineMDX] Container element not found");this.buildDOM(e),this.config.theme&&this.applyTheme(this.config.theme),this.mountCodeEditor(this.config.value||""),this.pluginManager=new le(this,this.events);const t=this.config.toolbar||[this.getDefaultToolbar()];this.toolbar=new ce(t,this.pluginManager,this,this.events);const i=()=>{this._refreshCompletions(),this.toolbar.render(this.toolbarLeft),this.renderPreview(),this.refreshToc()};this.config.plugins?this.registerPlugins(this.config.plugins).then(i):i(),this.editorHost.addEventListener("keydown",r=>{var a;if(!(r.metaKey||r.ctrlKey))return;const s=((a=this.pluginManager)==null?void 0:a.getShortcuts())??[];for(const l of s)if(this.matchShortcut(r,l.key)){r.preventDefault(),r.stopPropagation(),l.action({editor:this,selection:this.getSelection()});return}},!0),this.mode==="split"&&(this.root.getBoundingClientRect().width||window.innerWidth)<=640&&(this.mode="editor"),this.setMode(this.mode),this.config.onChange&&this.on("change",r=>{typeof r=="string"&&this.config.onChange(r)})}isDarkMode(){var i;if(this.root.classList.contains("smdx-dark")||this.root.closest(".smdx-dark"))return!0;const e=this.root.closest("[data-theme]");if(e){const r=e.dataset.theme;if(r==="dark")return!0;if(r==="light")return!1}return document.documentElement.dataset.colorScheme==="dark"?!0:document.documentElement.classList.contains("smdx-dark")||(((i=document.body)==null?void 0:i.classList.contains("smdx-dark"))??!1)}syncCodeEditorTheme(){const e=this.isDarkMode();this.codeEditor.setTheme(e?et:tt),this.codeEditor.updateConfig({tokenColors:e?rt:nt})}setupThemeObserver(){const e=()=>this.syncCodeEditorTheme();this.themeObserver=new MutationObserver(e);const t={attributes:!0,attributeFilter:["class","data-theme","data-color-scheme"]};let i=this.root;for(;i;)this.themeObserver.observe(i,t),i=i.parentElement}mountCodeEditor(e){this.codeEditor=new Tr(this.editorHost,{showGutter:!0,wordWrap:!0,bracketMatching:!0,showIndentGuides:!0,multiCursor:!0,autocomplete:!0,wordHighlight:!1,emmet:!1,codeFolding:!1,showMinimap:!1,find:!1,findReplace:!1,value:e,language:"markdown",theme:this.isDarkMode()?et:tt,showStatusBar:!1,extraKeywords:["import","export","default","from","as","true","false","null","undefined"],completions:[...ne,...ot],replaceBuiltins:!0,provideCompletions:i=>{const r=i.line.slice(0,i.col),o=r.match(/<([A-Za-z]*)$/);if(o){const a=o[1].toLowerCase();return ne.filter(l=>l.kind==="cls"&&(a===""||l.label.toLowerCase().startsWith(a)))}const s=r.match(/<[A-Za-z][\w.]*(?:\s+[\w-]*="[^"]*"\s*)*\s+([A-Za-z]*)$/);if(s){const a=s[1].toLowerCase();return ne.filter(l=>l.kind==="var"&&(a===""||l.label.toLowerCase().startsWith(a)))}return null},tokenColors:this.isDarkMode()?rt:nt,readOnly:this.config.readOnly,onChange:i=>{this.textarea.value=i,this.scheduleRender(),this.updateStatusBar(),this.events.emit("change",i),this.refreshToc()},onFocus:()=>this.events.emit("focus"),onBlur:()=>this.events.emit("blur"),onSelectionChange:()=>{this.toolbar.updateActiveStates(),this.events.emit("selection-change",this.getSelection())},onCursorChange:()=>{this.updateStatusBar()}}),this.editorHost.shadowRoot.querySelector(".sl-input").addEventListener("keydown",i=>{if(!this.config.readOnly&&!(i.ctrlKey||i.metaKey||i.altKey)){if(re[i.key]){const r=this.getSelection();if(r.text){i.preventDefault(),i.stopImmediatePropagation();const o=i.key,s=re[o],a=this.codeEditor.getValue(),l=a.substring(0,r.start)+o+r.text+s+a.substring(r.end);this.codeEditor.setValue(l),this.setSelection(r.start+1,r.end+1);return}}if(i.key==="Backspace"){const r=this.getSelection();if(r.start===r.end&&r.start>0){const o=this.codeEditor.getValue(),s=o[r.start-1],a=o[r.start];if(re[s]&&re[s]===a){i.preventDefault(),i.stopImmediatePropagation();const l=o.substring(0,r.start-1)+o.substring(r.start+1);this.codeEditor.setValue(l),this.setSelection(r.start-1,r.start-1);return}}}if(i.key===">"){const r=this.getSelection(),o=this.codeEditor.getValue(),a=o.substring(0,r.start).match(/<([A-Za-z][A-Za-z0-9.-]*)(?:\s[^>]*)?\s*$/);if(a){const l=a[1];if(!Mr.has(l.toLowerCase())){i.preventDefault(),i.stopImmediatePropagation();const d=`></${l}>`,h=o.substring(0,r.start)+d+o.substring(r.end);this.codeEditor.setValue(h),this.setSelection(r.start+1,r.start+1);return}}}}},!0),this.textarea.value=e,this.setupThemeObserver(),this.updateStatusBar()}_refreshCompletions(){!this.codeEditor||!this.pluginManager||this.codeEditor.updateConfig({completions:[...ne,...ot,...this.pluginManager.getCompletions(),...this._userCompletions]})}registerAutoComplete(e){const t=Array.isArray(e)?e:[e];this._userCompletions.push(...t),this._refreshCompletions()}buildDOM(e){this.root=document.createElement("div"),this.root.className="smdx-editor",this.root.setAttribute("role","application"),this.root.setAttribute("aria-label","Markdown Editor");const t=document.createElement("a");t.className="smdx-skip-link",t.href="#smdx-editor-content",t.textContent="Skip to editor",this.root.appendChild(t),this.textarea=document.createElement("textarea"),this.textarea.className="smdx-textarea-compat",this.textarea.setAttribute("aria-hidden","true"),this.textarea.setAttribute("role","textbox"),this.textarea.setAttribute("aria-label","Markdown editor"),this.textarea.setAttribute("aria-multiline","true"),this.textarea.setAttribute("tabindex","-1"),this.textarea.style.cssText="position:absolute;opacity:0;width:0;height:0;pointer-events:none;overflow:hidden;",this.root.appendChild(this.textarea),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="smdx-toolbar-container",this.toolbarEl.setAttribute("role","toolbar"),this.toolbarEl.setAttribute("aria-label","Formatting toolbar"),this.toolbarLeft=document.createElement("div"),this.toolbarLeft.className="smdx-toolbar-left",this.toolbarEl.appendChild(this.toolbarLeft),this.modeArea=document.createElement("div"),this.modeArea.className="smdx-toolbar-mode-area",this.toolbarEl.appendChild(this.modeArea),this.updateModeButtons(this.modeArea);const i=document.createElement("div");i.className="smdx-main",this.editorPane=document.createElement("div"),this.editorPane.className="smdx-editor-pane",this.editorPane.id="smdx-editor-content",this.editorHost=document.createElement("div"),this.editorHost.className="smdx-code-editor-host",this.editorHost.style.cssText="width:100%;height:100%;display:flex;flex-direction:column;",this.editorPane.appendChild(this.editorHost),this.previewPane=document.createElement("div"),this.previewPane.className="smdx-preview-pane",this.previewContent=document.createElement("div"),this.previewContent.className="smdx-preview-content",this.previewContent.setAttribute("role","region"),this.previewContent.setAttribute("aria-label","Preview"),this.previewContent.setAttribute("aria-live","polite"),this.previewContent.addEventListener("click",r=>{const o=r.target,s=o.closest("[data-smdx-tab-btn]");if(s){const h=s.closest(".smdx-tabs");if(h){const c=parseInt(s.dataset.tabIndex??"0",10);h.querySelectorAll(".smdx-tab-btn").forEach(p=>p.classList.remove("smdx-active")),s.classList.add("smdx-active"),h.querySelectorAll(".smdx-tab-panel").forEach((p,m)=>{p.style.display=m===c?"block":"none"})}return}const a=o.closest("[data-copy-btn]");if(!a)return;const l=a.closest(".smdx-code-block"),d=l==null?void 0:l.querySelector("code");d&&navigator.clipboard.writeText(d.textContent||"").then(()=>{a.classList.add("smdx-copied"),setTimeout(()=>a.classList.remove("smdx-copied"),2e3)}).catch(()=>{})}),this.previewPane.appendChild(this.previewContent),i.appendChild(this.editorPane),i.appendChild(this.previewPane),this.splitterController=new ee(i,this.editorPane,this.previewPane),this.tocContainer=document.createElement("div"),this.tocContainer.className="smdx-toc-container",this.tocContainer.setAttribute("aria-label","Table of contents"),this.buildTocPanel(),i.appendChild(this.tocContainer),this.statusBar=document.createElement("div"),this.statusBar.className="smdx-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-label","Editor status"),this.root.appendChild(this.toolbarEl),this.root.appendChild(i),this.root.appendChild(this.statusBar),e.appendChild(this.root)}offsetToPos(e){const t=this.codeEditor.getValue();let i=0,r=0;for(let o=0;o<e&&o<t.length;o++)t[o]===`
|
|
728
|
+
`?(i++,r=0):r++;return{row:i,col:r}}posToOffset(e,t){const i=this.codeEditor.getValue().split(`
|
|
729
|
+
`);let r=0;for(let o=0;o<e&&o<i.length;o++)r+=i[o].length+1;return r+t}async registerPlugins(e){for(const t of e)await this.pluginManager.register(t)}getDefaultToolbar(){return["undo","redo","|","heading","|","bold","italic","strikethrough","code","|","unorderedList","orderedList","taskList","|","insert-hr","insert-layout","insert-endpoint","insert-markdown","insert-snippet","|","link","image","table","quote"]}matchShortcut(e,t){const i=t.toLowerCase().split("+"),r=i.includes("cmd")||i.includes("meta")||i.includes("ctrl"),o=i.includes("shift"),s=i.includes("alt"),a=i.find(d=>!["cmd","meta","ctrl","shift","alt"].includes(d));return a?(e.metaKey||e.ctrlKey)===r&&e.shiftKey===o&&e.altKey===s&&e.key.toLowerCase()===a:!1}scheduleRender(){this.renderTimer&&clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>this.renderPreview(),150)}getCursorPosition(){const e=this.codeEditor.getCursor();return{lineNum:e.row+1,colNum:e.col+1}}updateStatusBar(){var l;const e=((l=this.codeEditor)==null?void 0:l.getValue())??"",t=this.getWordCount(),i=this.getLineCount(),r=e.length,{lineNum:o,colNum:s}=this.getCursorPosition(),a=this.config.readOnly?'<span class="smdx-status-sep">|</span><span class="smdx-status-item smdx-status-readonly">Read Only</span>':"";this.statusBar.innerHTML=`
|
|
730
|
+
<span class="smdx-status-item">Ln ${o}, Col ${s}</span>
|
|
731
|
+
<span class="smdx-status-sep">|</span>
|
|
732
|
+
<span class="smdx-status-item">${i} lines</span>
|
|
733
|
+
<span class="smdx-status-sep">|</span>
|
|
734
|
+
<span class="smdx-status-item">${t} words</span>
|
|
735
|
+
<span class="smdx-status-sep">|</span>
|
|
736
|
+
<span class="smdx-status-item">${r} characters</span>
|
|
737
|
+
<span class="smdx-status-sep">|</span>
|
|
738
|
+
<span class="smdx-status-item">MDX</span>
|
|
739
|
+
<span class="smdx-status-sep">|</span>
|
|
740
|
+
<span class="smdx-status-item">UTF-8</span>
|
|
741
|
+
${a}
|
|
742
|
+
`}updateModeButtons(e){e.innerHTML="";const t=document.createElement("div");t.className="smdx-mode-switch",["editor","split","preview"].forEach(i=>{const r=document.createElement("button");r.type="button",r.className=`smdx-mode-btn${i===this.mode?" smdx-active":""}`,r.dataset.mode=i;const o={editor:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> Editor',split:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/></svg> Split',preview:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg> Preview'};r.innerHTML=o[i],r.setAttribute("aria-label",`${i.charAt(0).toUpperCase()+i.slice(1)} mode`),r.setAttribute("aria-pressed",String(i===this.mode)),r.addEventListener("click",()=>this.setMode(i)),t.appendChild(r)}),e.appendChild(t)}buildTocPanel(){if(this.tocContainer.innerHTML="",this.tocCollapsed){this.tocContainer.classList.add("smdx-toc-collapsed");const r=document.createElement("button");r.className="smdx-toc-expand-btn",r.type="button",r.title="Show table of contents",r.setAttribute("aria-label","Show table of contents"),r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>',r.addEventListener("click",()=>{this.tocCollapsed=!1,this.buildTocPanel(),this.refreshToc()}),this.tocContainer.appendChild(r);return}this.tocContainer.classList.remove("smdx-toc-collapsed");const e=document.createElement("div");e.className="smdx-toc-header",e.innerHTML=`
|
|
743
|
+
<div class="smdx-toc-title">
|
|
744
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="8" y1="13" x2="16" y2="13"/><line x1="8" y1="17" x2="16" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
|
|
745
|
+
<span>CONTENTS</span>
|
|
746
|
+
</div>
|
|
747
|
+
<button class="smdx-toc-close-btn" type="button" title="Hide table of contents" aria-label="Hide table of contents">
|
|
748
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>
|
|
749
|
+
</button>
|
|
750
|
+
`,e.querySelector(".smdx-toc-close-btn").addEventListener("click",()=>{this.tocCollapsed=!0,this.buildTocPanel()});const t=document.createElement("div");t.className="smdx-toc-body";const i=document.createElement("div");i.className="smdx-toc-footer",i.textContent="0 headings",this.tocContainer.appendChild(e),this.tocContainer.appendChild(t),this.tocContainer.appendChild(i)}refreshToc(){if(this.tocCollapsed)return;const e=this.tocContainer.querySelector(".smdx-toc-body"),t=this.tocContainer.querySelector(".smdx-toc-footer");if(!e||!t)return;const i=this.textarea.value,r=[];let o=!1;for(const s of i.split(`
|
|
751
|
+
`)){if(s.trim().startsWith("```")){o=!o;continue}if(o)continue;const a=s.match(/^(#{1,6})\s+(.+)/);if(a){const l=a[1].length,d=a[2].replace(/[*_`~\[\]]/g,"").trim(),h=d.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-");r.push({level:l,text:d,slug:h})}}if(r.length===0)e.innerHTML='<div class="smdx-toc-empty">No headings found.</div>';else{const s=document.createElement("nav");s.className="smdx-toc-nav";const a=this.previewContent;r.forEach(l=>{const d=document.createElement("button");d.type="button",d.className=`smdx-toc-item smdx-toc-h${l.level}`,d.style.paddingLeft=`${(l.level-1)*12+8}px`,d.textContent=l.text,d.title=l.text,d.addEventListener("click",()=>{const h=a.querySelector(`#${CSS.escape(l.slug)}`);h&&h.scrollIntoView({behavior:"smooth",block:"start"})}),s.appendChild(d)}),e.innerHTML="",e.appendChild(s)}t.textContent=`${r.length} heading${r.length!==1?"s":""}`}toggleToc(){this.tocCollapsed=!this.tocCollapsed,this.buildTocPanel(),this.tocCollapsed||this.refreshToc()}getValue(){return this.codeEditor.getValue()}setValue(e){this.codeEditor.setValue(e),this.textarea.value=e,this.scheduleRender(),this.events.emit("change",e)}insertText(e){this.codeEditor.insertText(e),this.codeEditor.focus()}wrapSelection(e,t){const{start:i,end:r,text:o}=this.getSelection(),s=this.codeEditor.getValue(),a=o||"text",l=e+a+t,d=s.substring(0,i)+l+s.substring(r);this.codeEditor.setValue(d);const h=i+e.length,c=h+a.length;this.setSelection(h,c),this.codeEditor.focus()}replaceSelection(e){const{start:t,end:i}=this.getSelection(),r=this.codeEditor.getValue(),o=r.substring(0,t)+e+r.substring(i);this.codeEditor.setValue(o);const s=this.offsetToPos(t+e.length);this.codeEditor.setCursor(s),this.codeEditor.focus()}getSelection(){const e=this.codeEditor.getValue(),t=this.codeEditor.getSelection(),i=this.codeEditor.getCursor();if(!t){const l=this.posToOffset(i.row,i.col);return{start:l,end:l,text:"",beforeText:e.substring(0,l),afterText:e.substring(l)}}const r=this.posToOffset(t.ar,t.ac),o=this.posToOffset(t.fr,t.fc),s=Math.min(r,o),a=Math.max(r,o);return{start:s,end:a,text:e.substring(s,a),beforeText:e.substring(0,s),afterText:e.substring(a)}}setSelection(e,t){const i=this.offsetToPos(e),r=this.offsetToPos(t),o={ar:i.row,ac:i.col,fr:r.row,fc:r.col};this.codeEditor.setSelection(o),this.codeEditor.focus()}insertBlock(e){const{start:t,end:i}=this.getSelection(),r=this.codeEditor.getValue(),o=r.substring(0,t),s=r.substring(i),a=o.length>0&&!o.endsWith(`
|
|
752
|
+
`),l=s.length>0&&!s.startsWith(`
|
|
753
|
+
`),d=(a?`
|
|
754
|
+
|
|
755
|
+
`:"")+e+(l?`
|
|
756
|
+
|
|
757
|
+
`:""),h=o+d+s;this.codeEditor.setValue(h);const c=this.offsetToPos(o.length+d.length);this.codeEditor.setCursor(c),this.codeEditor.focus()}getTextarea(){return this.textarea}getPreview(){return this.previewContent}getRoot(){return this.root}focus(){this.codeEditor.focus()}async renderPreview(){this.renderer.setRenderers(this.pluginManager.getRenderers()),this.renderer.setParsers(this.pluginManager.getParsers());const e=await this.renderer.render(this.textarea.value);this.previewContent.innerHTML=e,this.events.emit("render",e),this.refreshToc()}getMode(){return this.mode}setMode(e){this.mode=e,this.root.classList.remove("smdx-mode-split","smdx-mode-editor","smdx-mode-preview"),this.root.classList.add(`smdx-mode-${e}`),this.updateModeButtons(this.modeArea),this.updateStatusBar(),this.events.emit("mode-change",e)}registerPlugin(e){this.pluginManager.register(e).then(()=>{this._refreshCompletions(),this.toolbarLeft.innerHTML="",this.toolbar.render(this.toolbarLeft),this.renderPreview()})}unregisterPlugin(e){this.pluginManager.unregister(e),this._refreshCompletions(),this.toolbarLeft.innerHTML="",this.toolbar.render(this.toolbarLeft),this.renderPreview()}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}emit(e,t){this.events.emit(e,t)}destroy(){var e;this._destroyed||(this._destroyed=!0,(e=this.themeObserver)==null||e.disconnect(),this.themeObserver=null,this.codeEditor.destroy(),this.pluginManager.destroy(),this.toolbar.destroy(),this.splitterController.destroy(),this.events.removeAllListeners(),this.renderTimer&&clearTimeout(this.renderTimer),this.root.remove())}undo(){this.codeEditor.undo()}redo(){this.codeEditor.redo()}getCurrentLine(){const e=this.codeEditor.getCursor();return this.codeEditor.getValue().split(`
|
|
758
|
+
`)[e.row]??""}getCurrentLineNumber(){return this.codeEditor.getCursor().row+1}replaceCurrentLine(e){const t=this.codeEditor.getCursor(),i=this.codeEditor.getValue().split(`
|
|
759
|
+
`);i[t.row]=e,this.codeEditor.setValue(i.join(`
|
|
760
|
+
`)),this.codeEditor.setCursor({row:t.row,col:e.length})}insertAt(e,t){const i=this.codeEditor.getValue(),r=i.substring(0,e)+t+i.substring(e);this.codeEditor.setValue(r);const o=this.offsetToPos(e+t.length);this.codeEditor.setCursor(o)}getWordCount(){var t;const e=(((t=this.codeEditor)==null?void 0:t.getValue())??this.textarea.value).trim();return e?e.split(/\s+/).length:0}getLineCount(){var e;return(((e=this.codeEditor)==null?void 0:e.getValue())??this.textarea.value).split(`
|
|
761
|
+
`).length}setLineNumbers(e){this.codeEditor.updateConfig({showGutter:e})}jumpToLine(e){const t=Math.max(1,Math.min(e,this.getLineCount()));this.codeEditor.setCursor({row:t-1,col:0}),this.codeEditor.focus()}applyTheme(e){for(const[t,i]of Object.entries(e))this.root.style.setProperty(t.startsWith("--")?t:`--smdx-${t}`,i);this.syncCodeEditorTheme()}setCodeEditorTheme(e){e?this.codeEditor.setTheme(e):this.syncCodeEditorTheme()}}class $r{constructor(e=100){this.stack=[],this.pointer=-1,this.maxSize=e}push(e){this.pointer<this.stack.length-1&&(this.stack=this.stack.slice(0,this.pointer+1)),this.stack[this.stack.length-1]!==e&&(this.stack.push(e),this.stack.length>this.maxSize&&this.stack.shift(),this.pointer=this.stack.length-1)}undo(){if(this.pointer>0)return this.pointer--,this.stack[this.pointer]}redo(){if(this.pointer<this.stack.length-1)return this.pointer++,this.stack[this.pointer]}current(){return this.stack[this.pointer]}clear(){this.stack=[],this.pointer=-1}}const C={heading:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M4 6v12M20 6v12"/></svg>',h1:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H1</text></svg>',h2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H2</text></svg>',h3:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H3</text></svg>',h4:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H4</text></svg>',h5:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H5</text></svg>',h6:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H6</text></svg>',bold:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6zM6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"/></svg>',italic:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>',strikethrough:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 4H9a3 3 0 00-3 3v0a3 3 0 003 3h6a3 3 0 013 3v0a3 3 0 01-3 3H8"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',quote:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"/></svg>',link:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>',image:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',code:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',codeBlock:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="18" rx="2"/><polyline points="10 8 6 12 10 16"/><polyline points="14 8 18 12 14 16"/></svg>',unorderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor"/><circle cx="4" cy="12" r="1" fill="currentColor"/><circle cx="4" cy="18" r="1" fill="currentColor"/></svg>',orderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="8" fill="currentColor" stroke="none">1</text><text x="2" y="15" font-size="8" fill="currentColor" stroke="none">2</text><text x="2" y="21" font-size="8" fill="currentColor" stroke="none">3</text></svg>',taskList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="6" height="6" rx="1"/><path d="M5 8l1 1 2-2"/><line x1="13" y1="8" x2="21" y2="8"/><rect x="3" y="13" width="6" height="6" rx="1"/><line x1="13" y1="16" x2="21" y2="16"/></svg>',table:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',highlight:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',admonition:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',tab:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="6" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M5 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',imageBackground:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1" stroke-dasharray="4,2"/><circle cx="12" cy="12" r="3"/></svg>',imageFrame:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1"/></svg>',accordion:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="6" rx="1"/><path d="M15 6l-3 3-3-3"/><rect x="3" y="13" width="18" height="6" rx="1"/></svg>',accordionGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="2" width="18" height="5" rx="1"/><rect x="3" y="9" width="18" height="5" rx="1"/><rect x="3" y="16" width="18" height="5" rx="1"/></svg>',multiColumn:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',card:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="7" y1="10" x2="17" y2="10"/><line x1="7" y1="14" x2="13" y2="14"/></svg>',cardGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="8" height="8" rx="2"/><rect x="14" y="3" width="8" height="8" rx="2"/><rect x="2" y="13" width="8" height="8" rx="2"/><rect x="14" y="13" width="8" height="8" rx="2"/></svg>',step:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="5" r="3"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="19" r="3"/><line x1="12" y1="8" x2="12" y2="9"/><line x1="12" y1="15" x2="12" y2="16"/></svg>',tip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18h6M10 22h4M12 2a7 7 0 017 7c0 2.38-1.19 4.47-3 5.74V17H8v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 017-7z"/></svg>',container:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" stroke-dasharray="4,2"/></svg>',copyText:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',tooltip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="12" rx="2"/><path d="M9 15l3 4 3-4"/></svg>',embedVideo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10,8 16,12 10,16"/></svg>',embedOthers:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><ellipse cx="12" cy="12" rx="4" ry="10"/></svg>',mermaid:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="8" height="6" rx="1"/><rect x="14" y="16" width="8" height="6" rx="1"/><rect x="14" y="2" width="8" height="6" rx="1"/><path d="M10 5h4M6 8v8l12-4"/></svg>',emoji:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>',formula:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="3" y="17" font-size="14" fill="currentColor" stroke="none" font-style="italic">∑x</text></svg>',insert:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>'};function at(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:C.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(n=>({id:`h${n}`,label:`Heading ${n}`,icon:C[`h${n}`],tooltip:`Heading ${n}`,...n<=3?{shortcutLabel:`⌘${n}`}:{},action:({editor:e})=>{const t="#".repeat(n)+" ",r=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+r)}})),action:({editor:n})=>{const e=n.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),r=e.replace(/^#{1,6}\s*/,"");n.replaceCurrentLine("#".repeat(i)+" "+r)}else n.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:n})=>n.replaceCurrentLine("# "+n.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:n})=>n.replaceCurrentLine("## "+n.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:n})=>n.replaceCurrentLine("### "+n.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}]}}function lt(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:C.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:n})=>n.wrapSelection("**","**"),isActive:({selection:n})=>{const{beforeText:e,afterText:t,text:i}=n;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(i)}}],shortcuts:[{key:"Ctrl+b",action:({editor:n})=>n.wrapSelection("**","**"),description:"Bold"}]}}function dt(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:C.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:n})=>n.wrapSelection("*","*"),isActive:({selection:n})=>{const{beforeText:e,afterText:t,text:i}=n;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(i)}}],shortcuts:[{key:"Ctrl+i",action:({editor:n})=>n.wrapSelection("*","*"),description:"Italic"}]}}function ct(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:C.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:n})=>n.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:n})=>n.wrapSelection("~~","~~"),description:"Strikethrough"}]}}function ht(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:C.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:n})=>{const e=n.getCurrentLine();e.startsWith("> ")?n.replaceCurrentLine(e.substring(2)):n.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:n})=>{const e=n.getCurrentLine();n.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}]}}function pt(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:C.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:n,selection:e})=>{e.text?n.replaceSelection(`[${e.text}](url)`):n.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:n,selection:e})=>{e.text?n.replaceSelection(`[${e.text}](url)`):n.insertText("[link text](url)")},description:"Insert Link"}]}}function ut(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:C.image,tooltip:"Insert Image",shortcutLabel:"⌘⇧I",action:({editor:n,selection:e})=>{const t=e.text||"alt text";n.replaceSelection(``)}}],shortcuts:[{key:"Ctrl+Shift+i",action:({editor:n,selection:e})=>{const t=e.text||"alt text";n.replaceSelection(``)},description:"Insert Image"}]}}function mt(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:C.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:n})=>n.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:C.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:n,selection:e})=>{n.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:n})=>n.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:n,selection:e})=>{n.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}]}}function gt(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:C.unorderedList,tooltip:"Bullet List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^[-*]\s/)?n.replaceCurrentLine(e.replace(/^[-*]\s/,"")):n.replaceCurrentLine("- "+e)}}]}}function bt(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:C.orderedList,tooltip:"Numbered List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^\d+\.\s/)?n.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):n.replaceCurrentLine("1. "+e)}}]}}function ft(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:C.taskList,tooltip:"Task List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^- \[[ x]\]\s/)?n.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):n.replaceCurrentLine("- [ ] "+e)}}]}}function xt(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:C.table,tooltip:"Insert Table",action:({editor:n})=>{n.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
762
|
+
| -------- | -------- | -------- |
|
|
763
|
+
| Cell 1 | Cell 2 | Cell 3 |
|
|
764
|
+
| Cell 4 | Cell 5 | Cell 6 |`)}}]}}const Lr=[{name:"Yellow",color:"#fef08a",darkColor:"#854d0e",class:"yellow"},{name:"Green",color:"#bbf7d0",darkColor:"#166534",class:"green"},{name:"Blue",color:"#bfdbfe",darkColor:"#1e3a5f",class:"blue"},{name:"Purple",color:"#ddd6fe",darkColor:"#4c1d95",class:"purple"},{name:"Pink",color:"#fbcfe8",darkColor:"#831843",class:"pink"},{name:"Red",color:"#fecaca",darkColor:"#991b1b",class:"red"},{name:"Orange",color:"#fed7aa",darkColor:"#9a3412",class:"orange"},{name:"Cyan",color:"#a5f3fc",darkColor:"#155e75",class:"cyan"}];function yt(){return{name:"highlight",toolbarItems:[{id:"highlight",label:"Highlight",icon:C.highlight,tooltip:"Highlight Text",children:Lr.map(n=>({id:`highlight-${n.class}`,label:n.name,icon:`<span class="smdx-color-dot" style="background:${n.color}"></span>`,tooltip:`${n.name} Highlight`,action:({editor:e})=>{e.wrapSelection(`<Highlight color="${n.class}">`,"</Highlight>")}})),action:({editor:n})=>{n.wrapSelection('<Highlight color="yellow">',"</Highlight>")}}],renderers:[{name:"highlight",pattern:/<Highlight\s+color="([^"]+)">([\s\S]*?)<\/Highlight>/gi,render:n=>{const e=n.match(/<Highlight\s+color="([^"]+)">([\s\S]*?)<\/Highlight>/i);return e?`<mark class="smdx-highlight smdx-highlight-${e[1]}">${e[2]}</mark>`:n}}],styles:`
|
|
20
765
|
.smdx-highlight { padding: 2px 4px; border-radius: 3px; }
|
|
21
766
|
.smdx-highlight-yellow { background-color: #fef08a; }
|
|
22
767
|
.smdx-highlight-green { background-color: #bbf7d0; }
|
|
@@ -35,11 +780,11 @@
|
|
|
35
780
|
.smdx-dark .smdx-highlight-orange { background-color: #9a3412; color: #fed7aa; }
|
|
36
781
|
.smdx-dark .smdx-highlight-cyan { background-color: #155e75; color: #a5f3fc; }
|
|
37
782
|
.smdx-color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); vertical-align: middle; margin-right: 6px; }
|
|
38
|
-
`}}const
|
|
39
|
-
${
|
|
40
|
-
:::`)}})),action:({editor:
|
|
783
|
+
`}}const vt=[{type:"tip",label:"TIP",color:"#10b981",bg:"#ecfdf5",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#10b981"/><path d="M9 12l2 2 4-4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"warning",label:"WARNING",color:"#f59e0b",bg:"#fffbeb",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" fill="#f59e0b"/><path d="M12 9v4M12 17h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"caution",label:"CAUTION",color:"#f97316",bg:"#fff7ed",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#f97316"/><path d="M12 8v4M12 16h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"danger",label:"DANGER",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"check",label:"CHECK",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"info",label:"INFO",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"note",label:"NOTE",color:"#8b5cf6",bg:"#f5f3ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3" fill="#8b5cf6"/><path d="M8 10h8M8 14h5" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function kt(){return{name:"admonition",toolbarItems:[{id:"admonition",label:"Admonition",icon:C.admonition,tooltip:"Admonition / Callout",children:vt.map(n=>({id:`admonition-${n.type}`,label:n.label,icon:n.icon,tooltip:`${n.label} callout`,action:({editor:e})=>{e.insertBlock(`:::${n.type}
|
|
784
|
+
${n.label}: Your message here
|
|
785
|
+
:::`)}})),action:({editor:n})=>{n.insertBlock(`:::info
|
|
41
786
|
INFO: Your message here
|
|
42
|
-
:::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:
|
|
787
|
+
:::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:n=>{const e=n.match(/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/);if(!e)return n;const t=vt.find(r=>r.type===e[1]),i=e[2]||t.label;return`<div class="smdx-admonition smdx-admonition-${e[1]}"><div class="smdx-admonition-title"><span class="smdx-admonition-icon">${t.icon}</span>${i}</div><div class="smdx-admonition-content">${e[3]}</div></div>`},priority:10}],styles:`
|
|
43
788
|
.smdx-admonition { padding: 14px 16px; border-radius: 6px; margin: 12px 0; border-left: 4px solid; }
|
|
44
789
|
.smdx-admonition-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.02em; }
|
|
45
790
|
.smdx-admonition-icon { display: flex; align-items: center; flex-shrink: 0; }
|
|
@@ -68,42 +813,42 @@ INFO: Your message here
|
|
|
68
813
|
.smdx-dark .smdx-admonition-info { background: #172554; }
|
|
69
814
|
.smdx-dark .smdx-admonition-note { background: #2e1065; }
|
|
70
815
|
.smdx-dark .smdx-admonition-content { color: var(--smdx-text, #e2e8f0); }
|
|
71
|
-
`}}function
|
|
72
|
-
`),t=e.filter(
|
|
73
|
-
`).trim():
|
|
816
|
+
`}}function Br(n){const e=n.split(`
|
|
817
|
+
`),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
|
|
818
|
+
`).trim():n.trim()}function wt(){return{name:"tab",toolbarItems:[{id:"tab",label:"Tab",icon:C.tab,tooltip:"Insert Tabs",action:({editor:n})=>{n.insertBlock(`<Tabs>
|
|
74
819
|
<Tab title="Tab 1">
|
|
75
820
|
Content for tab 1
|
|
76
821
|
</Tab>
|
|
77
822
|
<Tab title="Tab 2">
|
|
78
823
|
Content for tab 2
|
|
79
824
|
</Tab>
|
|
80
|
-
</Tabs>`)}}],renderers:[{name:"tabs",pattern:/<Tabs>([\s\S]*?)<\/Tabs>/
|
|
825
|
+
</Tabs>`)}}],renderers:[{name:"tabs",pattern:/<Tabs>([\s\S]*?)<\/Tabs>/gi,render:n=>{const e=/<Tab\s+title="([^"]*)">([\s\S]*?)<\/Tab>/gi;let t=[],i;for(;(i=e.exec(n))!==null;)t.push({title:i[1],content:Br(i[2])});if(t.length===0)return n;let o=`<div class="smdx-tabs" data-tab-id="${"tab-"+Math.random().toString(36).substring(2,8)}"><div class="smdx-tabs-header">`;return t.forEach((s,a)=>{o+=`<button class="smdx-tab-btn${a===0?" smdx-active":""}" data-smdx-tab-btn="true" data-tab-index="${a}">${s.title}</button>`}),o+="</div>",t.forEach((s,a)=>{o+=`<div class="smdx-tab-panel" style="display:${a===0?"block":"none"}">${s.content}</div>`}),o+="</div>",o},priority:15}],styles:`
|
|
81
826
|
.smdx-tabs { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
82
827
|
.smdx-tabs-header { display: flex; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
83
828
|
.smdx-tab-btn { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 0.9em; color: var(--smdx-text-muted, #64748b); border-bottom: 2px solid transparent; transition: all 0.15s; }
|
|
84
829
|
.smdx-tab-btn:hover { color: var(--smdx-text, #1e293b); }
|
|
85
830
|
.smdx-tab-btn.smdx-active { color: var(--smdx-primary, #6366f1); border-bottom-color: var(--smdx-primary, #6366f1); background: var(--smdx-bg, #fff); }
|
|
86
831
|
.smdx-tab-panel { padding: 16px; }
|
|
87
|
-
`}}function
|
|
832
|
+
`}}function _t(){return{name:"imageBackground",toolbarItems:[{id:"imageBackground",label:"Image Background",icon:C.imageBackground,tooltip:"Image with Background",action:({editor:n})=>{n.insertBlock(`<ImageBackground src="image-url" alt="description" background="#f0f0f0">
|
|
88
833
|
Content overlaying the image
|
|
89
|
-
</ImageBackground>`)}}],renderers:[{name:"imageBackground",pattern:/<ImageBackground\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+background="([^"]*)")?\s*>([\s\S]*?)<\/ImageBackground>/
|
|
834
|
+
</ImageBackground>`)}}],renderers:[{name:"imageBackground",pattern:/<ImageBackground\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+background="([^"]*)")?\s*>([\s\S]*?)<\/ImageBackground>/gi,render:n=>{const e=n.match(/<ImageBackground\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+background="([^"]*)")?\s*>([\s\S]*?)<\/ImageBackground>/i);return e?`<div class="smdx-image-bg" style="${e[3]?`background-image:url(${e[1]});background-color:${e[3]}`:`background-image:url(${e[1]})`}">
|
|
90
835
|
<div class="smdx-image-bg-overlay">${e[4].trim()}</div>
|
|
91
|
-
</div>`:
|
|
836
|
+
</div>`:n}}],styles:`
|
|
92
837
|
.smdx-image-bg { background-size: cover; background-position: center; border-radius: 8px; overflow: hidden; min-height: 200px; display: flex; align-items: center; justify-content: center; margin: 12px 0; background-color: var(--smdx-bg-muted, #f0f0f0); border: 1px solid var(--smdx-border, #e2e8f0); }
|
|
93
838
|
.smdx-image-bg-overlay { background: rgba(0,0,0,0.5); color: white; padding: 24px; width: 100%; text-align: center; }
|
|
94
839
|
.smdx-dark .smdx-image-bg-overlay { background: rgba(0,0,0,0.6); }
|
|
95
|
-
`}}function
|
|
840
|
+
`}}function Ct(){return{name:"imageFrame",toolbarItems:[{id:"imageFrame",label:"Image Frame",icon:C.imageFrame,tooltip:"Image in Frame",action:({editor:n})=>{n.insertBlock('<ImageFrame src="image-url" alt="description" caption="Image caption" />')}}],renderers:[{name:"imageFrame",pattern:/<ImageFrame\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+caption="([^"]*)")?\s*\/?>/gi,render:n=>{const e=n.match(/<ImageFrame\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+caption="([^"]*)")?\s*\/?>/i);return e?`<figure class="smdx-image-frame">
|
|
96
841
|
<img src="${e[1]}" alt="${e[2]||""}" />
|
|
97
842
|
${e[3]?`<figcaption>${e[3]}</figcaption>`:""}
|
|
98
|
-
</figure>`:
|
|
843
|
+
</figure>`:n}}],styles:`
|
|
99
844
|
.smdx-image-frame { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; padding: 8px; background: var(--smdx-bg-muted, #f8fafc); }
|
|
100
845
|
.smdx-image-frame img { width: 100%; border-radius: 4px; display: block; }
|
|
101
846
|
.smdx-image-frame figcaption { text-align: center; padding: 8px 0 4px; font-size: 0.85em; color: var(--smdx-text-muted, #64748b); }
|
|
102
|
-
`}}function
|
|
103
|
-
`),t=e.filter(
|
|
104
|
-
`).trim():
|
|
847
|
+
`}}function Tt(n){const e=n.split(`
|
|
848
|
+
`),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
|
|
849
|
+
`).trim():n.trim()}function Et(){return{name:"accordion",toolbarItems:[{id:"accordion",label:"Accordion",icon:C.accordion,tooltip:"Insert Accordion",action:({editor:n})=>{n.insertBlock(`<Accordion title="Accordion Title" defaultOpen>
|
|
105
850
|
Your content here. You can include any markdown or components.
|
|
106
|
-
</Accordion>`)}}],renderers:[{name:"accordion",pattern:/<Accordion\s+title="([^"]*)"(
|
|
851
|
+
</Accordion>`)}}],renderers:[{name:"accordion",pattern:/<Accordion\s+title="([^"]*)"([^>]*?)>([\s\S]*?)<\/Accordion>/gi,render:n=>{const e=n.match(/<Accordion\s+title="([^"]*)"([^>]*?)>([\s\S]*?)<\/Accordion>/i);return e?`<details class="smdx-accordion"${/defaultopen/i.test(e[2])?" open":""}><summary class="smdx-accordion-header"><span class="smdx-accordion-arrow"></span><span class="smdx-accordion-title">${e[1]}</span></summary><div class="smdx-accordion-content">${Tt(e[3])}</div></details>`:n},priority:12}],styles:`
|
|
107
852
|
.smdx-accordion { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; margin: 8px 0; overflow: hidden; background: var(--smdx-bg, #fff); }
|
|
108
853
|
.smdx-accordion-header { padding: 14px 18px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95em; user-select: none; list-style: none; color: var(--smdx-text, #1e293b); }
|
|
109
854
|
.smdx-accordion-header::-webkit-details-marker { display: none; }
|
|
@@ -113,7 +858,7 @@ INFO: Your message here
|
|
|
113
858
|
.smdx-accordion-content { padding: 14px 18px 18px 18px; border-top: 1px solid var(--smdx-border, #e2e8f0); }
|
|
114
859
|
.smdx-accordion-content p { margin: 6px 0; }
|
|
115
860
|
.smdx-accordion-content > :last-child { margin-bottom: 0; }
|
|
116
|
-
`}}function
|
|
861
|
+
`}}function St(){return{name:"accordionGroup",dependencies:["accordion"],toolbarItems:[{id:"accordionGroup",label:"Accordion Group",icon:C.accordionGroup,tooltip:"Insert Accordion Group",action:({editor:n})=>{n.insertBlock(`<AccordionGroup>
|
|
117
862
|
<Accordion title="Section 1" defaultOpen>
|
|
118
863
|
Content for section 1
|
|
119
864
|
</Accordion>
|
|
@@ -123,32 +868,36 @@ INFO: Your message here
|
|
|
123
868
|
<Accordion title="Section 3">
|
|
124
869
|
Content for section 3
|
|
125
870
|
</Accordion>
|
|
126
|
-
</AccordionGroup>`)}}],renderers:[{name:"accordionGroup",pattern:/<AccordionGroup>([\s\S]*?)<\/AccordionGroup>/
|
|
871
|
+
</AccordionGroup>`)}}],renderers:[{name:"accordionGroup",pattern:/<AccordionGroup>([\s\S]*?)<\/AccordionGroup>/gi,render:n=>{const e=n.match(/<AccordionGroup>([\s\S]*?)<\/AccordionGroup>/i);return e?`<div class="smdx-accordion-group">${e[1]}</div>`:n},priority:14}],styles:`
|
|
127
872
|
.smdx-accordion-group { display: flex; flex-direction: column; gap: 0; margin: 12px 0; }
|
|
128
873
|
.smdx-accordion-group > :not(.smdx-accordion) { display: none; }
|
|
129
874
|
.smdx-accordion-group .smdx-accordion { margin: 0; border-radius: 0; border-bottom: none; }
|
|
130
875
|
.smdx-accordion-group .smdx-accordion:first-of-type { border-radius: 8px 8px 0 0; }
|
|
131
876
|
.smdx-accordion-group .smdx-accordion:last-of-type { border-radius: 0 0 8px 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
132
|
-
`}}function
|
|
133
|
-
Column ${
|
|
877
|
+
`}}function Mt(){return{name:"multiColumn",toolbarItems:[{id:"multiColumn",label:"Columns",icon:C.multiColumn,tooltip:"Multiple Columns",children:[2,3,4,5].map(n=>({id:`columns-${n}`,label:`${n} Columns`,tooltip:`${n} column layout`,action:({editor:e})=>{const t=Array.from({length:n},(i,r)=>` <Column>
|
|
878
|
+
Column ${r+1} content
|
|
134
879
|
</Column>`).join(`
|
|
135
|
-
`);e.insertBlock(`<Columns count="${
|
|
880
|
+
`);e.insertBlock(`<Columns count="${n}">
|
|
136
881
|
${t}
|
|
137
|
-
</Columns>`)}})),action:({editor:
|
|
882
|
+
</Columns>`)}})),action:({editor:n})=>{n.insertBlock(`<Columns count="2">
|
|
138
883
|
<Column>
|
|
139
884
|
Column 1 content
|
|
140
885
|
</Column>
|
|
141
886
|
<Column>
|
|
142
887
|
Column 2 content
|
|
143
888
|
</Column>
|
|
144
|
-
</Columns>`)}}],renderers:[{name:"columns",pattern:/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/
|
|
889
|
+
</Columns>`)}}],renderers:[{name:"columns",pattern:/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/gi,render:n=>{const e=n.match(/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/i);if(!e)return n;const t=parseInt(e[1]),i=/<Column>([\s\S]*?)<\/Column>/gi;let r=[],o;for(;(o=i.exec(e[2]))!==null;)r.push(Tt(o[1]));let s=`<div class="smdx-columns" style="grid-template-columns:repeat(${t},1fr)">
|
|
890
|
+
`;for(const a of r)s+=`<div class="smdx-column">
|
|
891
|
+
${a}
|
|
892
|
+
</div>
|
|
893
|
+
`;return s+="</div>",s},priority:13}],styles:`
|
|
145
894
|
.smdx-columns { display: grid; gap: 16px; margin: 12px 0; }
|
|
146
895
|
.smdx-column { padding: 12px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 6px; }
|
|
147
|
-
`}}function
|
|
148
|
-
`),t=e.filter(
|
|
149
|
-
`).trim():
|
|
896
|
+
`}}function Ar(n){const e=n.split(`
|
|
897
|
+
`),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
|
|
898
|
+
`).trim():n.trim()}function $t(){return{name:"card",toolbarItems:[{id:"card",label:"Card",icon:C.card,tooltip:"Insert Card",action:({editor:n})=>{n.insertBlock(`<Card title="Card Title" icon="📄" href="/link">
|
|
150
899
|
Card description or content goes here.
|
|
151
|
-
</Card>`)}}],renderers:[{name:"card",pattern:/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/
|
|
900
|
+
</Card>`)}}],renderers:[{name:"card",pattern:/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/gi,render:n=>{const e=n.match(/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/i);if(!e)return n;const t=e[3]?"a":"div",i=e[3]?` href="${e[3]}" target="_blank" rel="noopener noreferrer"`:"",r=e[2]?`<span class="smdx-card-icon">${e[2]}</span>`:"",o=e[3]?'<svg class="smdx-card-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>':"";return`<${t} class="smdx-card"${i}><div class="smdx-card-header">${r}<span class="smdx-card-title">${e[1]}</span>${o}</div><div class="smdx-card-content">${Ar(e[4])}</div></${t}>`},priority:11}],styles:`
|
|
152
901
|
.smdx-card { display: block; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 10px; padding: 16px 20px; margin: 8px 0; text-decoration: none; color: inherit; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; background: var(--smdx-bg, #fff); }
|
|
153
902
|
a.smdx-card { cursor: pointer; }
|
|
154
903
|
a.smdx-card:hover { border-color: var(--smdx-primary, #6366f1); box-shadow: 0 2px 12px rgba(99,102,241,0.1); background: var(--smdx-bg-muted, #f8fafc); }
|
|
@@ -158,7 +907,7 @@ ${t}
|
|
|
158
907
|
.smdx-card-arrow { margin-left: auto; flex-shrink: 0; color: var(--smdx-text-muted, #94a3b8); transition: transform 0.2s, color 0.2s; }
|
|
159
908
|
a.smdx-card:hover .smdx-card-arrow { transform: translateX(2px); color: var(--smdx-primary, #6366f1); }
|
|
160
909
|
.smdx-card-content { font-size: 0.9em; color: var(--smdx-text-muted, #64748b); line-height: 1.5; }
|
|
161
|
-
`}}function
|
|
910
|
+
`}}function Lt(){return{name:"cardGroup",dependencies:["card"],toolbarItems:[{id:"cardGroup",label:"Card Group",icon:C.cardGroup,tooltip:"Insert Card Group",action:({editor:n})=>{n.insertBlock(`<CardGroup cols="2">
|
|
162
911
|
<Card title="Card 1" icon="📄">
|
|
163
912
|
Description for card 1
|
|
164
913
|
</Card>
|
|
@@ -171,12 +920,12 @@ ${t}
|
|
|
171
920
|
<Card title="Card 4" icon="💡">
|
|
172
921
|
Description for card 4
|
|
173
922
|
</Card>
|
|
174
|
-
</CardGroup>`)}}],renderers:[{name:"cardGroup",pattern:/<CardGroup(?:\s+cols="(\d+)")?\s*>([\s\S]*?)<\/CardGroup>/
|
|
923
|
+
</CardGroup>`)}}],renderers:[{name:"cardGroup",pattern:/<CardGroup(?:\s+cols="(\d+)")?\s*>([\s\S]*?)<\/CardGroup>/gi,render:n=>{const e=n.match(/<CardGroup(?:\s+cols="(\d+)")?\s*>([\s\S]*?)<\/CardGroup>/i);return e?`<div class="smdx-card-group" style="grid-template-columns:repeat(${e[1]||"2"},1fr)">${e[2]}</div>`:n},priority:13}],styles:`
|
|
175
924
|
.smdx-card-group { display: grid; gap: 12px; margin: 12px 0; }
|
|
176
925
|
.smdx-card-group .smdx-card { margin: 0; }
|
|
177
|
-
`}}function
|
|
178
|
-
`),t=e.filter(
|
|
179
|
-
`).trim():
|
|
926
|
+
`}}function Bt(n){const e=n.split(`
|
|
927
|
+
`),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
|
|
928
|
+
`).trim():n.trim()}function At(){return{name:"step",toolbarItems:[{id:"steps",label:"Steps",icon:C.step,tooltip:"Insert Steps",action:({editor:n})=>{n.insertBlock(`<Steps>
|
|
180
929
|
<Step title="First Step">
|
|
181
930
|
These are instructions or content that only pertain to the first step.
|
|
182
931
|
</Step>
|
|
@@ -186,7 +935,7 @@ ${t}
|
|
|
186
935
|
<Step title="Third Step">
|
|
187
936
|
These are instructions or content that only pertain to the third step.
|
|
188
937
|
</Step>
|
|
189
|
-
</Steps>`)}}],renderers:[{name:"steps",pattern:/<Steps>([\s\S]*?)<\/Steps>/
|
|
938
|
+
</Steps>`)}}],renderers:[{name:"steps",pattern:/<Steps>([\s\S]*?)<\/Steps>/gi,render:n=>{const e=n.match(/<Steps>([\s\S]*?)<\/Steps>/i);if(!e)return n;const t=/<Step\s+title="([^"]*)">([\s\S]*?)<\/Step>/gi;let i=[],r;for(;(r=t.exec(e[1]))!==null;)i.push({title:r[1],content:Bt(r[2])});let o='<div class="smdx-steps">';return i.forEach((s,a)=>{const l=a===i.length-1;o+=`<div class="smdx-step"><div class="smdx-step-indicator"><div class="smdx-step-number">${a+1}</div>${l?"":'<div class="smdx-step-line"></div>'}</div><div class="smdx-step-content"><div class="smdx-step-title">${s.title}</div><div class="smdx-step-body">${s.content}</div></div></div>`}),o+="</div>",o},priority:15}],styles:`
|
|
190
939
|
.smdx-steps { margin: 20px 0; }
|
|
191
940
|
.smdx-step { display: flex; gap: 20px; position: relative; }
|
|
192
941
|
.smdx-step-indicator { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 34px; position: relative; }
|
|
@@ -196,7 +945,7 @@ ${t}
|
|
|
196
945
|
.smdx-step:last-child .smdx-step-content { padding-bottom: 0; }
|
|
197
946
|
.smdx-step-title { font-weight: 700; font-size: 1.05em; color: var(--smdx-text, #1e293b); margin-bottom: 8px; }
|
|
198
947
|
.smdx-step-body { color: var(--smdx-text-muted, #64748b); font-size: 0.95em; line-height: 1.7; }
|
|
199
|
-
`}}const
|
|
948
|
+
`}}const It=[{type:"good",label:"Good",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"bad",label:"Bad",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"info",label:"Info",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function Pt(){return{name:"tip",toolbarItems:[{id:"tip",label:"Tip",icon:C.tip,tooltip:"Insert Tip",children:It.map(n=>({id:`tip-${n.type}`,label:n.label,icon:n.icon,tooltip:`${n.label} tip`,action:({editor:e})=>{e.insertBlock(`<Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>Your tip message here</Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>`)}})),action:({editor:n})=>{n.insertBlock("<TipGood>Your tip message here</TipGood>")}}],renderers:It.map(n=>({name:`tip-${n.type}`,pattern:new RegExp(`<Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>([\\s\\S]*?)<\\/Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>`,"gi"),render:e=>{const t=`Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}`,i=new RegExp(`<${t}>([\\s\\S]*?)<\\/${t}>`,"i"),r=e.match(i);return r?`<div class="smdx-tip smdx-tip-${n.type}"><span class="smdx-tip-icon">${n.icon}</span><span class="smdx-tip-text">${r[1].trim()}</span></div>`:e},priority:10})),styles:`
|
|
200
949
|
.smdx-tip { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 6px; margin: 8px 0; font-size: 0.95em; border-left: 4px solid; }
|
|
201
950
|
.smdx-tip-icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 1px; }
|
|
202
951
|
.smdx-tip-icon svg { display: block; }
|
|
@@ -207,12 +956,12 @@ ${t}
|
|
|
207
956
|
.smdx-dark .smdx-tip-good { background: #052e16; }
|
|
208
957
|
.smdx-dark .smdx-tip-bad { background: #450a0a; }
|
|
209
958
|
.smdx-dark .smdx-tip-info { background: #172554; }
|
|
210
|
-
`}}function
|
|
959
|
+
`}}function Rt(){return{name:"container",toolbarItems:[{id:"container",label:"Container",icon:C.container,tooltip:"Insert Container",action:({editor:n})=>{n.insertBlock(`<Container>
|
|
211
960
|
Content inside a styled container.
|
|
212
|
-
</Container>`)}}],renderers:[{name:"container",pattern:/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/
|
|
961
|
+
</Container>`)}}],renderers:[{name:"container",pattern:/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/gi,render:n=>{const e=n.match(/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/i);return e?`<div class="smdx-container">${e[1]?`<div class="smdx-container-title">${e[1]}</div>`:""}<div class="smdx-container-content">${Bt(e[2])}</div></div>`:n}}],styles:`
|
|
213
962
|
.smdx-container { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; padding: 16px; margin: 12px 0; background: var(--smdx-bg-muted, #f8fafc); }
|
|
214
963
|
.smdx-container-title { font-weight: 600; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
215
|
-
`}}function
|
|
964
|
+
`}}function Ht(){return{name:"copyText",toolbarItems:[{id:"copyText",label:"Copy Text",icon:C.copyText,tooltip:"Copyable Text Block",action:({editor:n})=>{n.insertBlock("<CopyText>Text that users can click to copy</CopyText>")}}],renderers:[{name:"copyText",pattern:/<CopyText>([\s\S]*?)<\/CopyText>/gi,render:n=>{const e=n.match(/<CopyText>([\s\S]*?)<\/CopyText>/i);if(!e)return n;const t=e[1].trim();return`<div class="smdx-copy-text" data-copy-text-div="true" data-text="${t.replace(/"/g,""")}"><code class="smdx-copy-text-content">${t}</code><button class="smdx-copy-text-btn" type="button"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg></button></div>`}}],styles:`
|
|
216
965
|
.smdx-copy-text { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--smdx-bg-muted, #f1f5f9); border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; cursor: pointer; transition: all 0.15s; font-size: 0.9em; margin: 6px 0; }
|
|
217
966
|
.smdx-copy-text:hover { border-color: var(--smdx-primary, #6366f1); }
|
|
218
967
|
.smdx-copy-text.smdx-copied { border-color: #22c55e; background: #f0fdf4; }
|
|
@@ -221,7 +970,7 @@ ${t}
|
|
|
221
970
|
.smdx-copy-text:hover .smdx-copy-text-btn { color: var(--smdx-text, #1e293b); }
|
|
222
971
|
.smdx-copy-text.smdx-copied .smdx-copy-text-btn { color: #22c55e; }
|
|
223
972
|
.smdx-dark .smdx-copy-text.smdx-copied { background: #052e16; border-color: #166534; }
|
|
224
|
-
`}}function
|
|
973
|
+
`}}function Dt(){return{name:"tooltip",toolbarItems:[{id:"tooltip",label:"Tooltip",icon:C.tooltip,tooltip:"Insert Tooltip",action:({editor:n})=>{const t=n.getSelection().text||"hover text";n.replaceSelection(`<Tooltip tip="Tooltip content">${t}</Tooltip>`)}}],renderers:[{name:"tooltip",pattern:/<Tooltip\s+tip="([^"]*)">([\s\S]*?)<\/Tooltip>/gi,render:n=>{const e=n.match(/<Tooltip\s+tip="([^"]*)">([\s\S]*?)<\/Tooltip>/i);return e?`<span class="smdx-tooltip-wrapper"><span class="smdx-tooltip-trigger">${e[2]}<span class="smdx-tooltip-popup">${e[1]}</span></span></span>`:n}}],styles:`
|
|
225
974
|
.smdx-tooltip-wrapper { position: relative; display: inline; }
|
|
226
975
|
.smdx-tooltip-trigger { position: relative; border-bottom: 1px dashed var(--smdx-primary, #6366f1); cursor: help; text-decoration: none; }
|
|
227
976
|
.smdx-tooltip-popup { visibility: hidden; opacity: 0; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 6px 12px; background: #1e293b; color: #fff; border-radius: 6px; font-size: 0.8em; white-space: nowrap; transition: opacity 0.15s, visibility 0.15s; z-index: 1000; pointer-events: none; }
|
|
@@ -229,16 +978,16 @@ ${t}
|
|
|
229
978
|
.smdx-tooltip-trigger:hover .smdx-tooltip-popup { visibility: visible; opacity: 1; }
|
|
230
979
|
.smdx-dark .smdx-tooltip-popup { background: #e2e8f0; color: #1e293b; }
|
|
231
980
|
.smdx-dark .smdx-tooltip-popup::after { border-top-color: #e2e8f0; }
|
|
232
|
-
`}}function
|
|
233
|
-
<iframe src="https://www.youtube.com/embed/${encodeURIComponent(
|
|
981
|
+
`}}function jt(){return{name:"embedVideo",toolbarItems:[{id:"embedVideo",label:"Embed Video",icon:C.embedVideo,tooltip:"Embed Video",children:[{id:"embed-youtube",label:"YouTube",tooltip:"Embed YouTube video",action:({editor:n})=>{n.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}},{id:"embed-video-file",label:"Video File",tooltip:"Embed video file",action:({editor:n})=>{n.insertBlock('<EmbedVideo type="file" src="video.mp4" />')}}],action:({editor:n})=>{n.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}}],renderers:[{name:"embedVideo",pattern:/<EmbedVideo\s+type="([^"]*)"(?:\s+src="([^"]*)")?\s*\/?>/gi,render:n=>{const e=n.match(/<EmbedVideo\s+type="([^"]*)"(?:\s+src="([^"]*)")?\s*\/?>/i);if(!e)return n;const t=e[1],i=e[2]||"";if(t==="youtube"){const r=i.match(/(?:v=|\/embed\/|youtu\.be\/)([\w-]+)/),o=r?r[1]:i;return`<div class="smdx-embed-video">
|
|
982
|
+
<iframe src="https://www.youtube.com/embed/${encodeURIComponent(o)}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
|
|
234
983
|
</div>`}return`<div class="smdx-embed-video">
|
|
235
|
-
<video controls src="${
|
|
984
|
+
<video controls src="${i}" class="smdx-video-player">
|
|
236
985
|
Your browser does not support the video tag.
|
|
237
986
|
</video>
|
|
238
987
|
</div>`}}],styles:`
|
|
239
988
|
.smdx-embed-video { position: relative; width: 100%; padding-top: 56.25%; margin: 12px 0; border-radius: 8px; overflow: hidden; background: #000; }
|
|
240
989
|
.smdx-embed-video iframe, .smdx-embed-video video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
|
241
|
-
`}}function
|
|
990
|
+
`}}function Nt(){return{name:"embedOthers",toolbarItems:[{id:"embedOthers",label:"Embed",icon:C.embedOthers,tooltip:"Embed External Content",children:[{id:"embed-github",label:"GitHub Gist",tooltip:"Embed GitHub Gist",action:({editor:n})=>{n.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}},{id:"embed-twitter",label:"Twitter/X Post",tooltip:"Embed Tweet",action:({editor:n})=>{n.insertBlock('<Embed type="twitter" src="https://twitter.com/user/status/TWEET_ID" />')}},{id:"embed-codepen",label:"CodePen",tooltip:"Embed CodePen",action:({editor:n})=>{n.insertBlock('<Embed type="codepen" src="https://codepen.io/user/pen/PEN_ID" />')}},{id:"embed-codesandbox",label:"CodeSandbox",tooltip:"Embed CodeSandbox",action:({editor:n})=>{n.insertBlock('<Embed type="codesandbox" src="https://codesandbox.io/s/SANDBOX_ID" />')}}],action:({editor:n})=>{n.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}}],renderers:[{name:"embedOthers",pattern:/<Embed\s+[^>]*?\/?>/gi,render:n=>{const e=n.match(/type="([^"]*)"/),t=n.match(/src="([^"]*)"/),i=n.match(/label="([^"]*)"/);if(!e)return n;const r=e[1],o=t?t[1]:"",s=i?i[1]:"";switch(r){case"github":return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"GitHub Gist"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`;case"twitter":return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon smdx-embed-twitter-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"Post on X (Twitter)"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`;case"codepen":{const a=o.match(/codepen\.io\/([^/]+)\/pen\/([^/?]+)/);return a?`<div class="smdx-embed smdx-embed-codepen"><iframe height="400" style="width:100%" scrolling="no" src="https://codepen.io/${encodeURIComponent(a[1])}/embed/${encodeURIComponent(a[2])}?default-tab=result" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe></div>`:`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2"/><line x1="12" y1="22" x2="12" y2="15.5"/><polyline points="22 8.5 12 15.5 2 8.5"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"CodePen"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`}case"codesandbox":{const a=o.split("/").pop()||"";return`<div class="smdx-embed smdx-embed-codesandbox"><iframe src="https://codesandbox.io/embed/${encodeURIComponent(a)}" style="width:100%;height:500px;border:0;border-radius:4px;overflow:hidden" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe></div>`}default:return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"Embedded Content"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`}}}],styles:`
|
|
242
991
|
.smdx-embed { margin: 12px 0; border-radius: 8px; overflow: hidden; }
|
|
243
992
|
.smdx-embed iframe { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; }
|
|
244
993
|
.smdx-embed-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; background: var(--smdx-bg-muted, #f8fafc); transition: border-color 0.15s; }
|
|
@@ -251,7 +1000,7 @@ ${t}
|
|
|
251
1000
|
.smdx-embed-card-url { font-size: 0.8em; color: var(--smdx-text-muted, #64748b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
|
|
252
1001
|
.smdx-embed-card-link { display: flex; align-items: center; gap: 4px; font-size: 0.8em; font-weight: 500; color: var(--smdx-primary, #6366f1); text-decoration: none; white-space: nowrap; flex-shrink: 0; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--smdx-border, #e2e8f0); background: var(--smdx-bg, #fff); transition: background 0.15s; }
|
|
253
1002
|
.smdx-embed-card-link:hover { background: var(--smdx-bg-muted, #f8fafc); text-decoration: none; }
|
|
254
|
-
`}}const
|
|
1003
|
+
`}}const Ot=[{id:"flowchart",label:"Flowchart",template:`graph TD
|
|
255
1004
|
Start --> Stop`},{id:"sequence",label:"Sequence Diagram",template:`sequenceDiagram
|
|
256
1005
|
Alice->>John: Hello John, how are you?
|
|
257
1006
|
John-->>Alice: Great!
|
|
@@ -301,7 +1050,7 @@ ${t}
|
|
|
301
1050
|
Another task :after a1 , 20d
|
|
302
1051
|
section Another
|
|
303
1052
|
Task in sec :2014-01-12 , 12d
|
|
304
|
-
another task : 24d`}];function
|
|
1053
|
+
another task : 24d`}];function Wt(){return{name:"mermaid",toolbarItems:[{id:"mermaid",label:"Mermaid",icon:C.mermaid,tooltip:"Insert Mermaid Diagram",children:Ot.map(n=>({id:`mermaid-${n.id}`,label:n.label,tooltip:`Insert ${n.label}`,action:({editor:e})=>{e.insertBlock("```mermaid\n"+n.template+"\n```")}})),action:({editor:n})=>{n.insertBlock("```mermaid\n"+Ot[0].template+"\n```")}}],renderers:[{name:"mermaid",pattern:/```mermaid\n([\s\S]*?)```/g,render:n=>{const e=n.match(/```mermaid\n([\s\S]*?)```/);if(!e)return n;const t="mermaid-"+Math.random().toString(36).substring(2,10),i=encodeURIComponent(e[1].trim());return`<div class="smdx-mermaid" data-mermaid-id="${t}" data-mermaid-code="${i}"><div class="smdx-mermaid-placeholder">Loading diagram…</div></div>`},priority:20}],async init(n){const e=async()=>{try{const t=window.mermaid;if(!t)return;const i=n.editor.getRoot().classList.contains("smdx-dark");t.initialize({startOnLoad:!1,theme:i?"dark":"default"});const r=n.editor.getPreview();if(!r)return;const o=r.querySelectorAll(".smdx-mermaid[data-mermaid-code]");for(const s of Array.from(o)){const a=decodeURIComponent(s.getAttribute("data-mermaid-code")),l=s.getAttribute("data-mermaid-id");try{const{svg:d}=await t.render(l,a);s.innerHTML=d,s.removeAttribute("data-mermaid-code")}catch{s.innerHTML=`<pre class="smdx-mermaid-error">${a.replace(/</g,"<").replace(/>/g,">")}</pre>`,s.removeAttribute("data-mermaid-code")}}}catch{}};n.on("render",e)},styles:`
|
|
305
1054
|
.smdx-mermaid { margin: 12px 0; text-align: center; }
|
|
306
1055
|
.smdx-mermaid svg { max-width: 100%; height: auto; }
|
|
307
1056
|
.smdx-mermaid-placeholder { padding: 24px; color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
|
|
@@ -352,9 +1101,9 @@ ${t}
|
|
|
352
1101
|
.smdx-dark .smdx-mermaid .section0,
|
|
353
1102
|
.smdx-dark .smdx-mermaid .section1 { fill: #374151 !important; }
|
|
354
1103
|
.smdx-dark .smdx-mermaid .today { stroke: #818cf8 !important; }
|
|
355
|
-
`}}const
|
|
1104
|
+
`}}const Ce=[["😀","grinning smile happy"],["😂","joy laugh cry tears"],["🥰","love hearts smiling"],["😎","cool sunglasses"],["🤔","thinking hmm"],["😢","cry sad tear"],["😡","angry mad rage"],["🥳","party celebrate"],["👍","thumbs up good yes ok"],["👎","thumbs down bad no"],["👋","wave hello hi bye"],["🙏","pray please thanks"],["💪","strong muscle flex"],["🎉","party tada celebrate confetti"],["🔥","fire hot lit"],["⭐","star favorite"],["❤️","heart love red"],["💔","broken heart"],["💯","hundred perfect score"],["✅","check done yes complete"],["❌","cross no wrong cancel"],["⚠️","warning alert caution"],["💡","idea bulb light tip"],["🚀","rocket launch ship fast"],["📝","memo note write edit"],["📌","pin pushpin"],["📎","paperclip clip attach"],["🔗","link chain url"],["📁","folder file directory"],["🗂️","dividers tabs index"],["🔍","search magnifying find look"],["🔧","wrench tool fix settings"],["🎯","target goal dart bullseye"],["🏆","trophy winner cup award"],["🎨","art palette paint color"],["🎵","music note song"],["📊","chart bar graph stats"],["📈","chart up increase growth"],["📉","chart down decrease decline"],["💰","money bag dollar rich"],["🕐","clock time one"],["📅","calendar date schedule"],["🌟","glowing star sparkle shine"],["🌍","earth globe world"],["☀️","sun sunny bright"],["🌙","moon crescent night"],["⚡","lightning bolt zap electric"],["💧","water drop droplet"],["🟢","green circle dot"],["🔴","red circle dot"],["🟡","yellow circle dot"],["🔵","blue circle dot"],["⚪","white circle dot"],["⚫","black circle dot"],["🟣","purple circle dot"],["🟠","orange circle dot"]];function zt(){return{name:"emoji",toolbarItems:[{id:"emoji",label:"Emoji",icon:C.emoji,tooltip:"Insert Emoji",action:n=>{},render:(n,e)=>{n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),Ir(n,e.editor)})}}]}}function Ir(n,e){var d;(d=document.querySelector(".smdx-emoji-picker"))==null||d.remove();const t=document.createElement("div");t.className="smdx-emoji-picker";const i=n.closest(".smdx-editor");i!=null&&i.classList.contains("smdx-dark")&&t.classList.add("smdx-dark");const r=document.createElement("input");r.type="text",r.placeholder="Search emoji...",r.className="smdx-emoji-search",t.appendChild(r);const o=document.createElement("div");o.className="smdx-emoji-grid";const s=h=>{o.innerHTML="";for(const[c]of h){const p=document.createElement("button");p.type="button",p.className="smdx-emoji-btn",p.textContent=c,p.addEventListener("click",()=>{e.insertText(c),t.remove()}),o.appendChild(p)}};s(Ce),r.addEventListener("input",()=>{const h=r.value.toLowerCase().trim();if(!h){s(Ce);return}s(Ce.filter(([,c])=>c.includes(h)))}),t.appendChild(o);const a=n.getBoundingClientRect();t.style.position="fixed",t.style.top=`${a.bottom+4}px`,t.style.left=`${a.left}px`,document.body.appendChild(t);const l=h=>{!t.contains(h.target)&&h.target!==n&&(t.remove(),document.removeEventListener("click",l))};setTimeout(()=>document.addEventListener("click",l),0),r.focus()}function Ft(){return{name:"formula",toolbarItems:[{id:"formula",label:"Formula",icon:C.formula,tooltip:"Insert Formula",children:[{id:"formula-inline",label:"Inline Formula",tooltip:"Inline math: $formula$",action:({editor:n})=>{n.wrapSelection("$","$")}},{id:"formula-block",label:"Block Formula",tooltip:"Block math: $$formula$$",action:({editor:n,selection:e})=>{n.insertBlock(`$$
|
|
356
1105
|
`+(e.text||"E = mc^2")+`
|
|
357
|
-
$$`)}}],action:({editor:
|
|
1106
|
+
$$`)}}],action:({editor:n})=>{n.wrapSelection("$","$")}}],renderers:[{name:"formula-block",pattern:/\$\$([\s\S]*?)\$\$/g,render:n=>{const e=n.match(/\$\$([\s\S]*?)\$\$/);if(!e)return n;const t=e[1].trim();try{const i=window.katex;if(i)return`<div class="smdx-formula-block">${i.renderToString(t,{displayMode:!0,throwOnError:!1})}</div>`}catch{}return`<div class="smdx-formula-block smdx-formula-fallback"><code>${t}</code></div>`},priority:18},{name:"formula-inline",pattern:new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$","g"),render:n=>{const e=n.match(new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$"));if(!e)return n;const t=e[1].trim();try{const i=window.katex;if(i)return i.renderToString(t,{displayMode:!1,throwOnError:!1})}catch{}return`<code class="smdx-formula-inline">${t}</code>`},priority:17}],styles:`
|
|
358
1107
|
.smdx-formula-block { text-align: center; margin: 16px 0; font-size: 1.2em; overflow-x: auto; }
|
|
359
1108
|
.smdx-formula-fallback { background: var(--smdx-bg-muted, #f8fafc); padding: 12px; border-radius: 6px; border: 1px solid var(--smdx-border, #e2e8f0); }
|
|
360
1109
|
.smdx-formula-inline { font-size: 0.95em; }
|
|
@@ -369,10 +1118,40 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
369
1118
|
.smdx-dark .smdx-emoji-search, .smdx-emoji-picker.smdx-dark .smdx-emoji-search { background: #2a2a3c; color: #e2e8f0; border-color: #374151; }
|
|
370
1119
|
.smdx-dark .smdx-emoji-search:focus, .smdx-emoji-picker.smdx-dark .smdx-emoji-search:focus { border-color: #818cf8; }
|
|
371
1120
|
.smdx-dark .smdx-emoji-btn:hover, .smdx-emoji-picker.smdx-dark .smdx-emoji-btn:hover { background: #2a2a3c; }
|
|
372
|
-
`}}function
|
|
373
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(c
|
|
374
|
-
`).slice(a-1,
|
|
375
|
-
`)}async function
|
|
1121
|
+
`}}function R(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Gt(){const n=new Map;async function e(r){if(n.has(r))return n.get(r);try{let o=await fetch(r+"?raw");if(o.ok||(o=await fetch(r)),!o.ok){const h={content:null,error:`File not found: ${r} (${o.status})`};return n.set(r,h),h}let s=await o.text();const a=s.trimStart();if(a.startsWith("<!DOCTYPE")||a.startsWith("<!doctype")||a.startsWith("<html")){const h={content:null,error:`File not found: ${r}`};return n.set(r,h),h}const l=s.match(/^export default (?:\/\*(?:[^*]|\*(?!\/))*\*\/\s*)?["']([\s\S]*)["']\s*;?\s*$/);l&&(s=l[1].replace(/\\n/g,`
|
|
1122
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(h,c)=>String.fromCharCode(parseInt(c,16))));const d={content:s};return n.set(r,d),d}catch{const o={content:null,error:`Failed to load: ${r}`};return n.set(r,o),o}}function t(r,o){const s=o.match(/^(\d+)-(\d+)$/);if(!s)return r;const a=Math.max(1,parseInt(s[1],10)),l=parseInt(s[2],10);return r.split(`
|
|
1123
|
+
`).slice(a-1,l).join(`
|
|
1124
|
+
`)}async function i(r){const o=r.querySelectorAll(".smdx-import[data-src]");for(const a of o){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const l=a.dataset.src,{content:d,error:h}=await e(l);h?(a.innerHTML=`<span class="smdx-import-icon">⚠️</span> <span class="smdx-import-error">${R(h)}</span>`,a.classList.add("smdx-import-failed")):(a.innerHTML=`<div class="smdx-import-header"><span class="smdx-import-icon">📄</span> <code>${R(l)}</code></div><div class="smdx-import-content">${R(d)}</div>`,a.classList.add("smdx-import-loaded"))}const s=r.querySelectorAll(".smdx-snippet[data-src]");for(const a of s){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const l=a.dataset.src,d=a.dataset.lines||"",{content:h,error:c}=await e(l);if(c)a.innerHTML=`<span class="smdx-snippet-icon">⚠️</span> <span class="smdx-snippet-error">${R(c)}</span>`,a.classList.add("smdx-snippet-failed");else{const p=d?t(h,d):h,m=l.split(".").pop()||"text",g=d?` <span class="smdx-snippet-lines">(lines ${R(d)})</span>`:"";a.innerHTML=`<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${R(l)}</code>${g}</div><pre class="smdx-snippet-code"><code class="language-${R(m)}">${R(p)}</code></pre>`,a.classList.add("smdx-snippet-loaded")}}}return{name:"insert",init(r){r.on("render",()=>{const o=r.editor.getPreview();o&&i(o)})},toolbarItems:(()=>{const r={id:"insert-hr",label:"Horizontal Rule",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="12" x2="21" y2="12"/></svg>',tooltip:"Insert Horizontal Rule",action:({editor:c})=>{c.insertBlock("---")}},o={id:"insert-layout",label:"Layout",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',tooltip:"Insert layout",action:()=>{},children:[{id:"insert-2col",label:"2 Columns",icon:"",tooltip:"Insert 2-column layout",action:({editor:c})=>{c.insertBlock(`<Columns count="2">
|
|
1125
|
+
<Column>
|
|
1126
|
+
Column 1 content here.
|
|
1127
|
+
</Column>
|
|
1128
|
+
<Column>
|
|
1129
|
+
Column 2 content here.
|
|
1130
|
+
</Column>
|
|
1131
|
+
</Columns>`)}},{id:"insert-3col",label:"3 Columns",icon:"",tooltip:"Insert 3-column layout",action:({editor:c})=>{c.insertBlock(`<Columns count="3">
|
|
1132
|
+
<Column>
|
|
1133
|
+
Column 1 content here.
|
|
1134
|
+
</Column>
|
|
1135
|
+
<Column>
|
|
1136
|
+
Column 2 content here.
|
|
1137
|
+
</Column>
|
|
1138
|
+
<Column>
|
|
1139
|
+
Column 3 content here.
|
|
1140
|
+
</Column>
|
|
1141
|
+
</Columns>`)}},{id:"insert-4col",label:"4 Columns",icon:"",tooltip:"Insert 4-column layout",action:({editor:c})=>{c.insertBlock(`<Columns count="4">
|
|
1142
|
+
<Column>
|
|
1143
|
+
Column 1 here.
|
|
1144
|
+
</Column>
|
|
1145
|
+
<Column>
|
|
1146
|
+
Column 2 here.
|
|
1147
|
+
</Column>
|
|
1148
|
+
<Column>
|
|
1149
|
+
Column 3 here.
|
|
1150
|
+
</Column>
|
|
1151
|
+
<Column>
|
|
1152
|
+
Column 4 here.
|
|
1153
|
+
</Column>
|
|
1154
|
+
</Columns>`)}}]},s=`<Endpoint method="GET" path="/api/v1/resource">
|
|
376
1155
|
Description of the endpoint.
|
|
377
1156
|
|
|
378
1157
|
**Parameters:**
|
|
@@ -387,13 +1166,28 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
387
1166
|
"data": {}
|
|
388
1167
|
}
|
|
389
1168
|
\`\`\`
|
|
390
|
-
</Endpoint
|
|
1169
|
+
</Endpoint>`,a={id:"insert-endpoint",label:"API Endpoint",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"/><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><circle cx="6" cy="6" r="1.5" fill="currentColor" stroke="none"/><circle cx="6" cy="18" r="1.5" fill="currentColor" stroke="none"/></svg>',tooltip:"Insert API endpoint block",shortcutLabel:"⌘⇧E",action:({editor:c})=>{c.insertBlock(s)}},l={id:"insert-markdown",label:"Markdown Import",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="12" y1="18" x2="12" y2="12"/><polyline points="9 15 12 12 15 15"/></svg>',tooltip:"Import external markdown",shortcutLabel:"⌘⇧M",action:({editor:c})=>{c.insertBlock('<Import src="./path/to/file.md" />')}},d={id:"insert-snippet",label:"Code Snippet",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',tooltip:"Insert code snippet reference",shortcutLabel:"⌘⇧S",action:({editor:c})=>{c.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />')}};return[{id:"insert",label:"Insert",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',tooltip:"Insert block elements",action:()=>{},children:[r,o,a,l,d]},r,o,a,l,d]})(),shortcuts:[{key:"Ctrl+Shift+e",action:({editor:r})=>r.insertBlock(`<Endpoint method="GET" path="/api/v1/resource">
|
|
1170
|
+
Description of the endpoint.
|
|
1171
|
+
|
|
1172
|
+
**Parameters:**
|
|
1173
|
+
| Name | Type | Description |
|
|
1174
|
+
|------|------|-------------|
|
|
1175
|
+
| id | string | Resource ID |
|
|
1176
|
+
|
|
1177
|
+
**Response:**
|
|
1178
|
+
\`\`\`json
|
|
1179
|
+
{
|
|
1180
|
+
"status": "success",
|
|
1181
|
+
"data": {}
|
|
1182
|
+
}
|
|
1183
|
+
\`\`\`
|
|
1184
|
+
</Endpoint>`),description:"Insert API Endpoint"},{key:"Ctrl+Shift+m",action:({editor:r})=>r.insertBlock('<Import src="./path/to/file.md" />'),description:"Insert Markdown Import"},{key:"Ctrl+Shift+s",action:({editor:r})=>r.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />'),description:"Insert Code Snippet"}],renderers:[{name:"endpoint",pattern:/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/gi,render:r=>{const o=r.match(/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/i);if(!o)return r;const s=o[1].toUpperCase(),a=o[2]||"";return`<div class="smdx-endpoint">
|
|
391
1185
|
<div class="smdx-endpoint-header">
|
|
392
|
-
<span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[
|
|
1186
|
+
<span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[s]||"#64748b"}">${s}</span>
|
|
393
1187
|
<code class="smdx-endpoint-path">${a}</code>
|
|
394
1188
|
</div>
|
|
395
|
-
<div class="smdx-endpoint-body">${
|
|
396
|
-
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/
|
|
1189
|
+
<div class="smdx-endpoint-body">${o[3].trim()}</div>
|
|
1190
|
+
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/gi,render:r=>{const o=r.match(/<Import\s+src="([^"]*)"(?:\s*\/)?>/i);if(!o)return r;const s=o[1];return`<div class="smdx-import" data-src="${R(s)}"><span class="smdx-import-icon">📄</span> Loading <code>${R(s)}</code>…</div>`}},{name:"snippet",pattern:/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/gi,render:r=>{const o=r.match(/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/i);if(!o)return r;const s=o[1],a=o[2]||"";return`<div class="smdx-snippet" data-src="${R(s)}"${a?` data-lines="${R(a)}"`:""}><span class="smdx-snippet-icon">📋</span> Loading <code>${R(s)}</code>…</div>`}}],styles:`
|
|
397
1191
|
.smdx-endpoint { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
398
1192
|
.smdx-endpoint-header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
399
1193
|
.smdx-endpoint-method { color: white; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.8em; letter-spacing: 0.05em; }
|
|
@@ -405,24 +1199,101 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
405
1199
|
.smdx-import-header, .smdx-snippet-header { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); font-size: 0.85em; }
|
|
406
1200
|
.smdx-import-content { padding: 16px; white-space: pre-wrap; font-size: 0.9em; line-height: 1.6; }
|
|
407
1201
|
.smdx-snippet-code { margin: 0; padding: 16px; background: var(--smdx-bg-code, #1e293b); color: var(--smdx-text-code, #e2e8f0); overflow-x: auto; font-size: 0.85em; line-height: 1.5; }
|
|
1202
|
+
.smdx-preview-content .smdx-snippet-code { margin: 0; }
|
|
408
1203
|
.smdx-snippet-code code { font-family: var(--smdx-font-mono, 'SF Mono', 'Fira Code', monospace); }
|
|
409
1204
|
.smdx-snippet-lines { color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
|
|
410
1205
|
.smdx-import-failed, .smdx-snippet-failed { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #fef2f2; border-color: #fecaca; }
|
|
411
1206
|
.smdx-import-error, .smdx-snippet-error { color: #b91c1c; }
|
|
412
1207
|
.smdx-dark .smdx-import-failed, .smdx-dark .smdx-snippet-failed { background: #450a0a; border-color: #991b1b; }
|
|
413
1208
|
.smdx-dark .smdx-import-error, .smdx-dark .smdx-snippet-error { color: #fca5a5; }
|
|
414
|
-
`}}function
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
1209
|
+
`}}function Vt(){return{name:"toc",toolbarItems:[{id:"toc",label:"Contents",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><polyline points="3 6 4 6"/><polyline points="3 12 4 12"/><polyline points="3 18 4 18"/></svg>',tooltip:"Toggle Table of Contents",action:({editor:n})=>{var e;(e=n.toggleToc)==null||e.call(n)}}],styles:".smdx-toc-container { /* built-in TOC panel — see toc.css */ }"}}function qt(){return{name:"breakLine",toolbarItems:[{id:"breakLine",label:"Line Break",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 7H3"/><path d="M21 17H9"/><path d="M18 13l3 4-3 4"/></svg>',tooltip:"Insert Line Break",action:({editor:n})=>{n.insertText(`<br/>
|
|
1210
|
+
`)}}]}}function Ut(){return{name:"horizontalRule",toolbarItems:[{id:"horizontalRule",label:"Horizontal Rule",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="12" x2="21" y2="12"/></svg>',tooltip:"Insert Horizontal Rule",action:({editor:n})=>{n.insertBlock("---")}}]}}function Pr(){return{name:"undo",toolbarItems:[{id:"undo",label:"Undo",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 102.13-9.36L1 10"/></svg>',tooltip:"Undo",shortcutLabel:"⌘Z",action:({editor:n})=>{n.undo()},isDisabled:()=>!1}]}}function Rr(){return{name:"redo",toolbarItems:[{id:"redo",label:"Redo",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>',tooltip:"Redo",shortcutLabel:"⌘⇧Z",action:({editor:n})=>{n.redo()},isDisabled:()=>!1}]}}function Kt(){return[Pr(),Rr(),at(),lt(),dt(),ct(),ht(),pt(),ut(),mt(),gt(),bt(),ft(),xt(),yt(),kt(),wt(),_t(),Ct(),Et(),St(),Mt(),$t(),Lt(),At(),Pt(),Rt(),Ht(),Dt(),jt(),Nt(),Wt(),zt(),Ft(),Gt(),Vt(),qt(),Ut()]}function Yt(){return[["undo","redo","|","heading","|","bold","italic","strikethrough","code","codeBlock","|","unorderedList","orderedList","taskList","|","insert-hr","insert-endpoint","insert-markdown","insert-snippet","|","link","image","table","quote","|","highlight","admonition","|","mermaid","|","steps","tip","container","|","tab","|","card","cardGroup","|","accordion","accordionGroup","multiColumn","|","embedVideo","embedOthers","|","emoji","formula","|","breakLine","horizontalRule","|","copyText","tooltip","|","toc"]]}class Hr{constructor(e){this.editor=e.editor,this.registerToolbarItem=e.registerToolbarItem,this.registerShortcut=e.registerShortcut,this.registerRenderer=e.registerRenderer,this.registerParser=e.registerParser,this.injectStyles=e.injectStyles,this.emit=e.emit,this.on=e.on,this.off=e.off}}function Xt(n){const e=document.createElement("div");e.className="smdx-editor",e.setAttribute("role","application"),e.setAttribute("aria-label","Markdown editor");const t=document.createElement("a");t.className="smdx-skip-link",t.href=`#${n}-textarea`,t.textContent="Skip to editor";const i=document.createElement("div");i.className="smdx-toolbar-container";const r=document.createElement("div");r.className="smdx-main";const o=document.createElement("div");return e.appendChild(t),e.appendChild(i),e.appendChild(r),e.appendChild(o),{root:e,skipLink:t,toolbarSlot:i,main:r,statusBarSlot:o}}function Jt(n){const e=document.createElement("div");e.className="smdx-editor-pane";const t=document.createElement("div");t.className="smdx-scroll-wrapper";const i=document.createElement("div");i.className="smdx-line-gutter",i.setAttribute("aria-hidden","true");const r=document.createElement("textarea");return r.className="smdx-textarea",r.id=`${n}-textarea`,r.setAttribute("aria-label","Markdown input"),r.setAttribute("aria-multiline","true"),r.spellcheck=!1,t.appendChild(i),t.appendChild(r),e.appendChild(t),{pane:e,scrollWrapper:t,gutter:i,textarea:r}}function Zt(n){const e=document.createElement("div");e.className="smdx-preview-pane",e.id=`${n}-preview`;const t=document.createElement("div");return t.className="smdx-preview-content",t.setAttribute("aria-live","polite"),t.setAttribute("aria-label","Rendered preview"),e.appendChild(t),{pane:e,content:t}}function Qt(n={}){const e=document.createElement("div");e.className="smdx-status-bar";const t=document.createElement("span");t.className="smdx-word-count";const i=document.createElement("span");i.className="smdx-line-count";const r=document.createElement("span");r.className="smdx-char-count";const o=document.createElement("div");return o.className="smdx-mode-switch",n.showWordCount!==!1&&e.appendChild(t),n.showLineCount!==!1&&e.appendChild(i),e.appendChild(r),n.showModeSwitcher!==!1&&e.appendChild(o),{bar:e,wordCount:t,lineCount:i,charCount:r,modeSwitcher:o}}class ei{constructor(e,t="split"){this.root=e,this.currentMode=t,this.applyMode(t)}getMode(){return this.currentMode}setMode(e){this.root.classList.remove(`smdx-mode-${this.currentMode}`),this.currentMode=e,this.applyMode(e)}applyMode(e){this.root.classList.add(`smdx-mode-${e}`)}}class ti{constructor(e){this._isDark=!1,this.root=e}applyTheme(e){for(const[t,i]of Object.entries(e))this.root.style.setProperty(t,i)}toggleDarkMode(e){this._isDark=e!==void 0?e:!this._isDark,this.root.classList.toggle("smdx-dark",this._isDark)}isDarkMode(){return this._isDark}}class ii{constructor(e){this.opts=e,this.buildModeSwitcher()}buildModeSwitcher(){const e=["editor","split","preview"],t={editor:"Editor",split:"Split",preview:"Preview"};this.opts.modeSwitcher.innerHTML="";for(const i of e){const r=document.createElement("button");r.className="smdx-mode-btn",r.type="button",r.textContent=t[i],r.dataset.mode=i,r.addEventListener("click",()=>this.opts.onModeChange(i)),this.opts.modeSwitcher.appendChild(r)}}updateCounts(e){const t=e.trim()?e.trim().split(/\s+/).length:0,i=e.split(`
|
|
1211
|
+
`).length,r=e.length;this.opts.wordCount.textContent=`${t} words`,this.opts.lineCount.textContent=`${i} lines`,this.opts.charCount.textContent=`${r} chars`}updateActiveMode(e){this.opts.modeSwitcher.querySelectorAll(".smdx-mode-btn").forEach(t=>{t.classList.toggle("smdx-active",t.dataset.mode===e)})}}const j=class j{constructor(e,t){this.scrollEl=null,this.enabled=!1,this.mirror=null,this.rafPending=!1,this.scrollRafId=null,this.offsets=new Float32Array(0),this.heights=new Float32Array(0),this.totalHeight=0,this.lineCount=0,this.lineHeightPx=27.2,this.contentWidth=0,this.avgCharWidth=8.4,this.paddingTop=16,this.cachedClientHeight=0,this.deferredUpdateTimer=null,this.cachedContentWidth=0,this.lastTextareaHeight=0,this.OVERSCAN=8,this.spanPool=[],this.poolStart=-1,this.poolEnd=-1,this.onViewportChange=null,this.onScroll=()=>{const i=this.scrollEl||this.textarea;this.recyclePool(i.scrollTop)},this.gutter=e,this.textarea=t,this.buildInner()}setScrollElement(e){this.scrollEl=e}buildInner(){this.inner=document.createElement("div"),this.inner.className="smdx-gutter-inner",this.inner.setAttribute("aria-hidden","true"),Object.assign(this.inner.style,{position:"relative",pointerEvents:"none"}),this.gutter.appendChild(this.inner)}setupMirror(){this.mirror=document.createElement("div"),this.mirror.setAttribute("aria-hidden","true"),Object.assign(this.mirror.style,{position:"fixed",top:"-9999px",left:"-9999px",visibility:"hidden",pointerEvents:"none",whiteSpace:"pre-wrap",wordWrap:"break-word",overflowWrap:"break-word",overflow:"hidden"}),document.body.appendChild(this.mirror)}destroyMirror(){var e;(e=this.mirror)==null||e.remove(),this.mirror=null}syncMirror(){if(!this.mirror)return null;const e=window.getComputedStyle(this.textarea),t=parseFloat(e.paddingLeft)||0,i=parseFloat(e.paddingRight)||0,r=parseFloat(e.paddingTop)||16,o=this.textarea.clientWidth-t-i;if(o<=0)return null;const s=parseFloat(e.lineHeight)||27.2;this.paddingTop=r,this.contentWidth=o,this.lineHeightPx=s,Object.assign(this.mirror.style,{fontFamily:e.fontFamily,fontSize:e.fontSize,lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,tabSize:e.tabSize||"2",width:o+"px"});try{const l=document.createElement("canvas").getContext("2d");if(l){l.font=`${e.fontSize} ${e.fontFamily}`;const d="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _.,;:()[]{}";this.avgCharWidth=l.measureText(d).width/d.length||8.4}}catch{}return{lineHeightPx:s,contentWidth:o}}rowCount(e,t){return!e||e.length*this.avgCharWidth<this.contentWidth*j.WRAP_THRESHOLD||!this.mirror?1:(this.mirror.textContent=e,Math.max(1,Math.round(this.mirror.scrollHeight/t)))}enable(){var t;this.enabled=!0,(t=this.scrollEl||this.textarea.parentElement)==null||t.classList.add("smdx-has-gutter"),this.gutter.style.display="",this.setupMirror(),this.update(),(this.scrollEl||this.textarea).addEventListener("scroll",this.onScroll)}disable(){var t;this.enabled=!1,(t=this.scrollEl||this.textarea.parentElement)==null||t.classList.remove("smdx-has-gutter"),this.gutter.style.display="none",(this.scrollEl||this.textarea).removeEventListener("scroll",this.onScroll),this.destroyMirror(),this.cancelScrollRaf(),this.deferredUpdateTimer&&(clearTimeout(this.deferredUpdateTimer),this.deferredUpdateTimer=null)}notifyResize(){if(!this.enabled)return;const e=this.scrollEl||this.textarea;this.cachedClientHeight=e.clientHeight;const t=window.getComputedStyle(this.textarea),i=parseFloat(t.paddingLeft)||0,r=parseFloat(t.paddingRight)||0,o=this.textarea.clientWidth-i-r;if(o>0&&Math.abs(o-this.cachedContentWidth)>j.WIDTH_CHANGE_THRESHOLD_PX){this.cachedContentWidth=o,this.update();return}this.poolStart=-1,this.poolEnd=-1,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible()}update(){if(!this.enabled)return;const e=this.textarea.value.split(`
|
|
1212
|
+
`),t=e.length;this.lineCount=t;const i=t>j.LARGE_DOC_THRESHOLD,r=this.syncMirror();if(r){this.rafPending=!1;const{lineHeightPx:s}=r;this.cachedContentWidth=this.contentWidth;const a=new Float32Array(t+1),l=new Float32Array(t);let d=0;if(i){const h=this.contentWidth,c=this.avgCharWidth;for(let p=0;p<t;p++){a[p]=d;const g=e[p].length*c,u=(h>0?Math.max(1,Math.ceil(g/h)):1)*s;l[p]=u,d+=u}this.deferredUpdateTimer&&clearTimeout(this.deferredUpdateTimer),this.deferredUpdateTimer=setTimeout(()=>{this.deferredUpdateTimer=null,this.enabled&&this.refineLargeDoc(e,s)},j.DEFERRED_UPDATE_DELAY_MS)}else for(let h=0;h<t;h++){a[h]=d;const p=this.rowCount(e[h],s)*s;l[h]=p,d+=p}a[t]=d,this.offsets=a,this.heights=l,this.totalHeight=d}else{!this.rafPending&&typeof requestAnimationFrame<"u"&&(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.enabled&&this.update()}));const s=this.lineHeightPx,a=new Float32Array(t+1),l=new Float32Array(t).fill(s);for(let d=0;d<=t;d++)a[d]=d*s;this.offsets=a,this.heights=l,this.totalHeight=t*s}this.poolStart=-1,this.poolEnd=-1;for(let s=0;s<this.spanPool.length;s++)this.spanPool[s].style.visibility="hidden";const o=this.scrollEl||this.textarea;this.cachedClientHeight=o.clientHeight,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible()}refineLargeDoc(e,t){const i=e.length,r=this.contentWidth,o=this.avgCharWidth,s=r*j.WRAP_THRESHOLD;let a=!1;const l=new Float32Array(i+1),d=new Float32Array(i);let h=0;for(let c=0;c<i;c++){l[c]=h;const m=e[c].length*o;let g;m>=s&&this.mirror?g=this.rowCount(e[c],t):g=r>0?Math.max(1,Math.ceil(m/r)):1;const f=g*t;Math.abs(f-this.heights[c])>.5&&(a=!0),d[c]=f,h+=f}l[i]=h,a&&(this.offsets=l,this.heights=d,this.totalHeight=h,this.poolStart=-1,this.poolEnd=-1,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible())}autoResizeTextarea(){var a;const e=this.textarea,t=this.scrollEl,i=t?t.clientHeight:((a=e.parentElement)==null?void 0:a.clientHeight)||200,r=parseFloat(e.style.height)||0;if(r>0&&r>=i&&e.scrollHeight<=r+2)return;e.style.height="1px";const o=e.scrollHeight,s=Math.max(o,i);e.style.height=s+"px",this.lastTextareaHeight=s}renderVisible(){const t=(this.scrollEl||this.textarea).scrollTop;this.recyclePool(t)}recyclePool(e){const t=this.cachedClientHeight,i=this.paddingTop,r=Math.max(0,e-i),o=e-i+t,s=Math.max(0,this.lineIndexAtOffset(r)-this.OVERSCAN),a=Math.min(this.lineCount-1,this.lineIndexAtOffset(o)+this.OVERSCAN);if(s===this.poolStart&&a===this.poolEnd)return;this.poolStart=s,this.poolEnd=a;const l=this.lineCount>0?a-s+1:0,d=this.lineHeightPx;for(;this.spanPool.length<l;){const h=document.createElement("span");h.className="smdx-line-num",h.style.position="absolute",h.style.left="0",h.style.right="0",this.inner.appendChild(h),this.spanPool.push(h)}for(let h=0;h<l;h++){const c=s+h,p=this.spanPool[h],g=this.offsets[c]+i+"px";p.style.top!==g&&(p.style.top=g);const f=d+"px";p.style.height!==f&&(p.style.height=f,p.style.lineHeight=f);const u=String(c+1);p.textContent!==u&&(p.textContent=u),p.style.visibility!==""&&(p.style.visibility="")}for(let h=l;h<this.spanPool.length;h++)this.spanPool[h].style.visibility!=="hidden"&&(this.spanPool[h].style.visibility="hidden");this.onViewportChange&&this.onViewportChange(this.getStats())}lineIndexAtOffset(e){const t=this.lineCount;if(t===0||e<=0)return 0;if(e>=this.totalHeight)return t-1;const i=this.offsets;let r=0,o=t-1;for(;r<o;){const s=r+o+1>>1;i[s]<=e?r=s:o=s-1}return r}cancelScrollRaf(){this.scrollRafId!==null&&(cancelAnimationFrame(this.scrollRafId),this.scrollRafId=null)}ensureCursorVisible(){const e=this.scrollEl;if(!e||!this.enabled)return;const t=this.textarea.selectionEnd,r=this.textarea.value.substring(0,t).split(`
|
|
1213
|
+
`).length-1,o=this.lineHeightPx,s=this.paddingTop,a=(r<this.lineCount?this.offsets[r]:this.totalHeight)+s,l=a+o,d=e.scrollTop,h=d+e.clientHeight;l>h?e.scrollTop=l-e.clientHeight:a<d&&(e.scrollTop=Math.max(0,a))}getLineOffset(e){return e<0||e>=this.lineCount?0:this.offsets[e]}getStats(){const e=this.poolEnd>=this.poolStart&&this.poolStart>=0?this.poolEnd-this.poolStart+1:0;return{lineCount:this.lineCount,visibleFirst:Math.max(1,this.poolStart+1),visibleLast:Math.max(1,this.poolEnd+1),domNodes:e,totalHeight:this.totalHeight,enabled:this.enabled}}getScrollElement(){return this.scrollEl}destroy(){this.disable()}};j.WRAP_THRESHOLD=.85,j.LARGE_DOC_THRESHOLD=500,j.DEFERRED_UPDATE_DELAY_MS=50,j.WIDTH_CHANGE_THRESHOLD_PX=1;let oe=j;class ri{constructor(e,t=150){this.renderTimer=null,this.contentEl=e,this.delay=t,this.renderer=new Q}setRenderers(e){this.renderer.setRenderers(e)}setParsers(e){this.renderer.setParsers(e)}render(e){this.renderTimer&&clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>{this.renderImmediate(e)},this.delay)}async renderImmediate(e){const t=await this.renderer.render(e);this.contentEl.innerHTML=t,this.contentEl.querySelectorAll('[data-copy-text-div="true"]').forEach(i=>{i.addEventListener("click",async()=>{const r=i.getAttribute("data-text")||"";try{await navigator.clipboard.writeText(r),i.classList.add("smdx-copied"),setTimeout(()=>i.classList.remove("smdx-copied"),2e3)}catch{}})}),this.contentEl.querySelectorAll('[data-copy-btn="true"]').forEach(i=>{i.addEventListener("click",async()=>{var o;const r=(o=i.closest(".smdx-code-block"))==null?void 0:o.querySelector("pre code");if(r)try{await navigator.clipboard.writeText(r.textContent||""),i.classList.add("smdx-copied"),setTimeout(()=>i.classList.remove("smdx-copied"),2e3)}catch{}})})}destroy(){this.renderTimer&&clearTimeout(this.renderTimer)}}const K=class K{constructor(e){this.root=e,this.observer=null}start(){typeof ResizeObserver>"u"||(this.observer=new ResizeObserver(e=>{for(const t of e)this.applyBreakpointClasses(t.contentRect.width)}),this.observer.observe(this.root),this.applyBreakpointClasses(this.root.getBoundingClientRect().width))}destroy(){var e;(e=this.observer)==null||e.disconnect(),this.observer=null}applyBreakpointClasses(e){const t=e<=K.MOBILE_BREAKPOINT,i=!t&&e<=K.TABLET_BREAKPOINT;this.root.classList.toggle("smdx-is-mobile",t),this.root.classList.toggle("smdx-is-tablet",i)}};K.MOBILE_BREAKPOINT=640,K.TABLET_BREAKPOINT=1024;let Te=K;class Dr{constructor(e,t){this.config=e,this.events=t,this.editorId=`smdx-${Math.random().toString(36).slice(2,9)}`}build(e,t,i){const{root:r,toolbarSlot:o,main:s,statusBarSlot:a}=Xt(this.editorId),{pane:l,scrollWrapper:d,gutter:h,textarea:c}=Jt(this.editorId),{pane:p,content:m}=Zt(this.editorId),{bar:g,wordCount:f,lineCount:u,charCount:k,modeSwitcher:_}=Qt();s.appendChild(l),s.appendChild(p),a.replaceWith(g),e.appendChild(r),this.elements={root:r,toolbarEl:o,editorPane:l,previewPane:p,textarea:c,previewContent:m,statusBar:g},this.modeController=new ei(r,this.config.mode??"split"),this.themeController=new ti(r),this.lineNumberController=new oe(h,c),this.lineNumberController.setScrollElement(d),this.previewController=new ri(m),this.statusBarController=new ii({bar:g,wordCount:f,lineCount:u,charCount:k,modeSwitcher:_,onModeChange:v=>i.setMode(v)}),this.statusBarController.updateActiveMode(this.config.mode??"split"),this.config.theme&&this.themeController.applyTheme(this.config.theme);const x=this.config.toolbar||[];return x.length>0&&(this.toolbar=new ce(x,t,i,this.events),this.toolbar.render(o)),this.responsiveController=new Te(r),this.responsiveController.start(),this.elements}getMode(){return this.modeController.getMode()}setMode(e){this.modeController.setMode(e),this.statusBarController.updateActiveMode(e)}applyTheme(e){this.themeController.applyTheme(e)}toggleDarkMode(e){this.themeController.toggleDarkMode(e)}isDarkMode(){return this.themeController.isDarkMode()}updateStatusBar(e){this.statusBarController.updateCounts(e)}updateToolbarActiveStates(){var e;(e=this.toolbar)==null||e.updateActiveStates()}enableLineNumbers(){this.lineNumberController.enable()}disableLineNumbers(){this.lineNumberController.disable()}updateLineNumbers(){this.lineNumberController.update()}renderPreview(e){this.previewController.render(e)}renderPreviewImmediate(e){return this.previewController.renderImmediate(e)}getElements(){return this.elements}destroy(){var e,t,i;(e=this.toolbar)==null||e.destroy(),this.previewController.destroy(),this.lineNumberController.destroy(),(t=this.splitterController)==null||t.destroy(),(i=this.responsiveController)==null||i.destroy()}}class jr{constructor(){this.activeDropdown=null,this.documentClickHandler=e=>{this.activeDropdown&&!this.activeDropdown.contains(e.target)&&this.closeAll()},document.addEventListener("click",this.documentClickHandler)}toggle(e,t){var i,r;e.style.display==="none"?(this.closeAll(),e.style.display="",this.activeDropdown=t,(i=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||i.setAttribute("aria-expanded","true")):(e.style.display="none",(r=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||r.setAttribute("aria-expanded","false"),this.activeDropdown=null)}closeAll(){document.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(e=>{e.style.display="none"}),document.querySelectorAll('[aria-expanded="true"]').forEach(e=>{e.setAttribute("aria-expanded","false")}),this.activeDropdown=null}destroy(){document.removeEventListener("click",this.documentClickHandler)}}const Nr=[{label:"Accordion",kind:"tag",detail:"Expandable section",insertText:`<Accordion title="Title">
|
|
1214
|
+
Content
|
|
1215
|
+
</Accordion>`},{label:"AccordionGroup",kind:"tag",detail:"Group of accordions",insertText:`<AccordionGroup>
|
|
1216
|
+
<Accordion title="Section 1">
|
|
1217
|
+
Content
|
|
1218
|
+
</Accordion>
|
|
1219
|
+
</AccordionGroup>`},{label:"Card",kind:"tag",detail:"Card component",insertText:`<Card title="Title" icon="📄">
|
|
1220
|
+
Description
|
|
1221
|
+
</Card>`},{label:"CardGroup",kind:"tag",detail:"Card grid",insertText:`<CardGroup cols="2">
|
|
1222
|
+
<Card title="Card 1" icon="📄">Description</Card>
|
|
1223
|
+
<Card title="Card 2" icon="🔧">Description</Card>
|
|
1224
|
+
</CardGroup>`},{label:"Columns",kind:"tag",detail:"Multi-column layout",insertText:`<Columns count="2">
|
|
1225
|
+
<Column>
|
|
1226
|
+
Column 1
|
|
1227
|
+
</Column>
|
|
1228
|
+
<Column>
|
|
1229
|
+
Column 2
|
|
1230
|
+
</Column>
|
|
1231
|
+
</Columns>`},{label:"Column",kind:"tag",detail:"Column in layout",insertText:`<Column>
|
|
1232
|
+
Content
|
|
1233
|
+
</Column>`},{label:"Container",kind:"tag",detail:"Styled container",insertText:`<Container title="Title">
|
|
1234
|
+
Content
|
|
1235
|
+
</Container>`},{label:"CopyText",kind:"tag",detail:"Copyable text",insertText:"<CopyText>text to copy</CopyText>"},{label:"Embed",kind:"tag",detail:"External embed",insertText:'<Embed type="github" src="https://gist.github.com/..." />'},{label:"EmbedVideo",kind:"tag",detail:"Video embed",insertText:'<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=ID" />'},{label:"Endpoint",kind:"tag",detail:"API endpoint docs",insertText:`<Endpoint method="GET" path="/api/v1/resource">
|
|
1236
|
+
Description
|
|
1237
|
+
</Endpoint>`},{label:"Highlight",kind:"tag",detail:"Highlight text",insertText:'<Highlight color="yellow">text</Highlight>'},{label:"ImageBackground",kind:"tag",detail:"Image with overlay",insertText:'<ImageBackground src="image.jpg" alt="description" />'},{label:"ImageFrame",kind:"tag",detail:"Framed image",insertText:'<ImageFrame src="image.jpg" alt="description" caption="Caption" />'},{label:"Import",kind:"tag",detail:"Import markdown",insertText:'<Import src="./path/to/file.md" />'},{label:"Snippet",kind:"tag",detail:"Code snippet ref",insertText:'<Snippet src="./snippets/example.ts" lines="1-20" />'},{label:"Step",kind:"tag",detail:"Step item",insertText:`<Step title="Step Title">
|
|
1238
|
+
Instructions
|
|
1239
|
+
</Step>`},{label:"Steps",kind:"tag",detail:"Step-by-step",insertText:`<Steps>
|
|
1240
|
+
<Step title="First Step">
|
|
1241
|
+
Instructions
|
|
1242
|
+
</Step>
|
|
1243
|
+
<Step title="Second Step">
|
|
1244
|
+
Instructions
|
|
1245
|
+
</Step>
|
|
1246
|
+
</Steps>`},{label:"Tab",kind:"tag",detail:"Tab pane",insertText:`<Tab title="Tab Title">
|
|
1247
|
+
Content
|
|
1248
|
+
</Tab>`},{label:"Tabs",kind:"tag",detail:"Tabbed sections",insertText:`<Tabs>
|
|
1249
|
+
<Tab title="Tab 1">Content 1</Tab>
|
|
1250
|
+
<Tab title="Tab 2">Content 2</Tab>
|
|
1251
|
+
</Tabs>`},{label:"TipGood",kind:"tag",detail:"Good tip callout",insertText:`<TipGood>
|
|
1252
|
+
Tip message
|
|
1253
|
+
</TipGood>`},{label:"TipBad",kind:"tag",detail:"Bad tip callout",insertText:`<TipBad>
|
|
1254
|
+
Warning message
|
|
1255
|
+
</TipBad>`},{label:"TipInfo",kind:"tag",detail:"Info tip callout",insertText:`<TipInfo>
|
|
1256
|
+
Info message
|
|
1257
|
+
</TipInfo>`},{label:"Tooltip",kind:"tag",detail:"Hover tooltip",insertText:'<Tooltip tip="Tooltip text">hover text</Tooltip>'}],Or=[{label:"# Heading 1",kind:"md",detail:"H1 heading",insertText:"# "},{label:"## Heading 2",kind:"md",detail:"H2 heading",insertText:"## "},{label:"### Heading 3",kind:"md",detail:"H3 heading",insertText:"### "},{label:"#### Heading 4",kind:"md",detail:"H4 heading",insertText:"#### "},{label:"**bold**",kind:"md",detail:"Bold text",insertText:"**bold**"},{label:"*italic*",kind:"md",detail:"Italic text",insertText:"*italic*"},{label:"~~strike~~",kind:"md",detail:"Strikethrough",insertText:"~~text~~"},{label:"`inline code`",kind:"md",detail:"Inline code",insertText:"`code`"},{label:"```code block```",kind:"md",detail:"Code block",insertText:"```\ncode\n```"},{label:"> blockquote",kind:"md",detail:"Blockquote",insertText:"> "},{label:"- list item",kind:"md",detail:"Unordered list",insertText:"- "},{label:"1. ordered item",kind:"md",detail:"Ordered list",insertText:"1. "},{label:"- [ ] task",kind:"md",detail:"Task list item",insertText:"- [ ] "},{label:"[link](url)",kind:"md",detail:"Hyperlink",insertText:"[text](url)"},{label:"",kind:"md",detail:"Image",insertText:""},{label:"---",kind:"md",detail:"Horizontal rule",insertText:`---
|
|
1258
|
+
`},{label:"| Table |",kind:"md",detail:"Table",insertText:`| Column 1 | Column 2 |
|
|
1259
|
+
|----------|----------|
|
|
1260
|
+
| Cell 1 | Cell 2 |`},{label:":::tip",kind:"md",detail:"Tip admonition",insertText:`:::tip
|
|
1261
|
+
Tip content
|
|
1262
|
+
:::`},{label:":::warning",kind:"md",detail:"Warning admonition",insertText:`:::warning
|
|
1263
|
+
Warning content
|
|
1264
|
+
:::`},{label:":::info",kind:"md",detail:"Info admonition",insertText:`:::info
|
|
1265
|
+
Info content
|
|
1266
|
+
:::`},{label:":::danger",kind:"md",detail:"Danger admonition",insertText:`:::danger
|
|
1267
|
+
Danger content
|
|
1268
|
+
:::`},{label:":::note",kind:"md",detail:"Note admonition",insertText:`:::note
|
|
1269
|
+
Note content
|
|
1270
|
+
:::`},{label:"$formula$",kind:"md",detail:"Inline math",insertText:"$E = mc^2$"},{label:"$$block math$$",kind:"md",detail:"Math block",insertText:`$$
|
|
1271
|
+
E = mc^2
|
|
1272
|
+
$$`},{label:"```mermaid",kind:"md",detail:"Mermaid diagram",insertText:"```mermaid\ngraph TD\n A --> B\n```"}],Wr=[{label:"<div>",kind:"html",detail:"Division",insertText:`<div>
|
|
1273
|
+
|
|
1274
|
+
</div>`},{label:"<span>",kind:"html",detail:"Inline span",insertText:"<span></span>"},{label:"<p>",kind:"html",detail:"Paragraph",insertText:`<p>
|
|
1275
|
+
|
|
1276
|
+
</p>`},{label:"<a>",kind:"html",detail:"Anchor link",insertText:`<a href="">
|
|
1277
|
+
|
|
1278
|
+
</a>`},{label:"<img>",kind:"html",detail:"Image",insertText:'<img src="" alt="" />'},{label:"<br>",kind:"html",detail:"Line break",insertText:"<br />"},{label:"<hr>",kind:"html",detail:"Horizontal rule",insertText:"<hr />"},{label:"<ul>",kind:"html",detail:"Unordered list",insertText:`<ul>
|
|
1279
|
+
<li></li>
|
|
1280
|
+
</ul>`},{label:"<ol>",kind:"html",detail:"Ordered list",insertText:`<ol>
|
|
1281
|
+
<li></li>
|
|
1282
|
+
</ol>`},{label:"<table>",kind:"html",detail:"Table",insertText:`<table>
|
|
1283
|
+
<tr><th></th></tr>
|
|
1284
|
+
<tr><td></td></tr>
|
|
1285
|
+
</table>`},{label:"<details>",kind:"html",detail:"Disclosure widget",insertText:`<details>
|
|
1286
|
+
<summary>Summary</summary>
|
|
1287
|
+
Content
|
|
1288
|
+
</details>`},{label:"<summary>",kind:"html",detail:"Disclosure summary",insertText:"<summary></summary>"},{label:"<pre>",kind:"html",detail:"Preformatted",insertText:`<pre><code>
|
|
1289
|
+
|
|
1290
|
+
</code></pre>`},{label:"<code>",kind:"html",detail:"Code element",insertText:"<code></code>"},{label:"<blockquote>",kind:"html",detail:"Block quotation",insertText:`<blockquote>
|
|
1291
|
+
|
|
1292
|
+
</blockquote>`},{label:"<section>",kind:"html",detail:"Section",insertText:`<section>
|
|
1293
|
+
|
|
1294
|
+
</section>`}],ni=[...Nr,...Or,...Wr],zr=new Set(ni.map(n=>n.label.toLowerCase())),Fr={tag:"⚛",md:"M",html:"<>",var:"·",snippet:"{}"};function oi(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Gr=/[\w</.:#*\-$![\]>(){}~|`@]/,Vr=.6;class qr{constructor(e,t){this.items=[],this.selected=0,this.prefix="",this.startPos=0,this._onAccept=null,this.extraItems=[],this.textarea=e,this.editorRoot=t,this.popup=document.createElement("div"),this.popup.className="smdx-ac-popup",this.popup.style.display="none",this.popup.setAttribute("role","listbox"),this.popup.setAttribute("aria-label","Autocomplete suggestions"),this.popup.addEventListener("mousedown",i=>{i.preventDefault();const r=i.target.closest(".smdx-ac-item");r&&r.dataset.i&&(this.selected=parseInt(r.dataset.i,10),this.accept())}),t.appendChild(this.popup)}registerItems(e){this.extraItems.push(...e)}isVisible(){return this.popup.style.display!=="none"}trigger(){const e=this.textarea.selectionStart,t=this.textarea.value,i=t.lastIndexOf(`
|
|
1295
|
+
`,e-1)+1,r=t.substring(i,e);let o=r.length;for(;o>0&&Gr.test(r[o-1]);)o--;const s=r.substring(o);if(s.length<1){this.hide();return}this.prefix=s,this.startPos=i+o;const a=s.startsWith("<")?s.substring(1):s;if(a.length<1){this.hide();return}const l=a.toLowerCase(),d=new Set,c=t.match(/[a-zA-Z_$][\w$]*/g);if(c)for(const f of c)f!==a&&f.length>2&&d.add(f);const p=[...d].filter(f=>f.toLowerCase().startsWith(l)&&!zr.has(f.toLowerCase())).slice(0,8).map(f=>({label:f,kind:"var",detail:"in document"})),g=[...ni,...this.extraItems].filter(f=>f.label.toLowerCase().includes(l)&&f.label.toLowerCase()!==l).concat(p).slice(0,14);if(!g.length){this.hide();return}this.items=g,this.selected=0,this.render(),this.position()}move(e){this.selected=Math.max(0,Math.min(this.items.length-1,this.selected+e)),this.render()}accept(){const e=this.items[this.selected];if(!e)return;const t=this.textarea.value,i=e.insertText||e.label,r=this.textarea.selectionStart;this.textarea.value=t.substring(0,this.startPos)+i+t.substring(r);const o=this.startPos+i.length;this.textarea.selectionStart=this.textarea.selectionEnd=o,this.textarea.focus(),this.hide(),this._onAccept&&this._onAccept()}onAccept(e){this._onAccept=e}handleKeyDown(e){return this.isVisible()?e.key==="ArrowDown"?(e.preventDefault(),this.move(1),!0):e.key==="ArrowUp"?(e.preventDefault(),this.move(-1),!0):e.key==="Tab"||e.key==="Enter"?(e.preventDefault(),this.accept(),!0):e.key==="Escape"?(this.hide(),!0):!1:!1}hide(){this.popup.style.display="none",this.items=[],this.selected=0}render(){this.popup.innerHTML=this.items.map((t,i)=>`<div class="smdx-ac-item${i===this.selected?" smdx-ac-sel":""}" data-i="${i}" role="option" aria-selected="${i===this.selected}"><span class="smdx-ac-badge smdx-ac-${t.kind}">${Fr[t.kind]||"·"}</span><span class="smdx-ac-label">${oi(t.label)}</span><span class="smdx-ac-detail">${oi(t.detail)}</span></div>`).join(""),this.popup.style.display="block";const e=this.popup.querySelector(".smdx-ac-sel");e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}position(){var _;const e=this.editorRoot.getBoundingClientRect(),t=this.textarea.selectionStart,i=this.textarea.value,r=i.lastIndexOf(`
|
|
1296
|
+
`,t-1)+1,o=t-r,s=getComputedStyle(this.textarea),a=parseFloat(s.lineHeight)||22,d=(parseFloat(s.fontSize)||14)*Vr,c=i.substring(0,t).split(`
|
|
1297
|
+
`).length,p=this.textarea.getBoundingClientRect(),m=((_=this.textarea.parentElement)==null?void 0:_.scrollTop)||0,g=p.left-e.left+o*d+16,f=p.top-e.top+c*a-m+4,u=this.items.length*30+8,k=f+u>e.height-16;this.popup.style.left=Math.min(g,e.width-360)+"px",this.popup.style.top=(k?Math.max(0,f-a-u):f)+"px"}destroy(){this.popup.remove()}}const Ur=1e4;class Kr{constructor(e,t){this.matches=[],this.currentMatch=-1,this.caseSensitive=!1,this.useRegex=!1,this.wholeWord=!1,this.showReplace=!1,this._onInputCallback=null,this.textarea=e,this.editorRoot=t,this.panel=document.createElement("div"),this.panel.className="smdx-find-panel",this.panel.style.display="none",this.panel.setAttribute("role","search"),this.panel.setAttribute("aria-label","Find and Replace");const i=document.createElement("div");i.className="smdx-find-row",this.findInput=document.createElement("input"),this.findInput.type="text",this.findInput.className="smdx-find-input",this.findInput.placeholder="Find…",this.findInput.setAttribute("aria-label","Search"),this.findInput.setAttribute("autocomplete","off"),this.findInput.setAttribute("spellcheck","false"),this.caseSensitiveBtn=this.createToggle("Aa","Case sensitive"),this.wholeWordBtn=this.createToggle("ab","Whole word"),this.regexBtn=this.createToggle(".*","Regex");const r=this.createActionBtn("❮","Previous match"),o=this.createActionBtn("❯","Next match");this.countLabel=document.createElement("span"),this.countLabel.className="smdx-find-count",this.countLabel.textContent="No results";const s=this.createActionBtn("✕","Close");s.classList.add("smdx-find-close"),i.appendChild(this.findInput),i.appendChild(this.caseSensitiveBtn),i.appendChild(this.wholeWordBtn),i.appendChild(this.regexBtn),i.appendChild(r),i.appendChild(o),i.appendChild(this.countLabel),i.appendChild(s),this.replaceRow=document.createElement("div"),this.replaceRow.className="smdx-find-row smdx-replace-row",this.replaceRow.style.display="none",this.replaceInput=document.createElement("input"),this.replaceInput.type="text",this.replaceInput.className="smdx-find-input",this.replaceInput.placeholder="Replace…",this.replaceInput.setAttribute("aria-label","Replace"),this.replaceInput.setAttribute("autocomplete","off"),this.replaceInput.setAttribute("spellcheck","false");const a=this.createActionBtn("Replace","Replace current");a.classList.add("smdx-find-action-text");const l=this.createActionBtn("All","Replace all");l.classList.add("smdx-find-action-text"),this.replaceRow.appendChild(this.replaceInput),this.replaceRow.appendChild(a),this.replaceRow.appendChild(l),this.panel.appendChild(i),this.panel.appendChild(this.replaceRow),t.appendChild(this.panel),this.findInput.addEventListener("input",()=>this.search()),this.findInput.addEventListener("keydown",d=>{d.stopPropagation(),d.key==="Enter"&&(d.shiftKey?this.prev():this.next()),d.key==="Escape"&&this.close()}),this.replaceInput.addEventListener("keydown",d=>{d.stopPropagation(),d.key==="Enter"&&this.replaceCurrent(),d.key==="Escape"&&this.close()}),this.caseSensitiveBtn.addEventListener("click",()=>{this.caseSensitive=!this.caseSensitive,this.caseSensitiveBtn.classList.toggle("smdx-find-toggle-on",this.caseSensitive),this.search()}),this.wholeWordBtn.addEventListener("click",()=>{this.wholeWord=!this.wholeWord,this.wholeWordBtn.classList.toggle("smdx-find-toggle-on",this.wholeWord),this.search()}),this.regexBtn.addEventListener("click",()=>{this.useRegex=!this.useRegex,this.regexBtn.classList.toggle("smdx-find-toggle-on",this.useRegex),this.search()}),r.addEventListener("click",()=>this.prev()),o.addEventListener("click",()=>this.next()),s.addEventListener("click",()=>this.close()),a.addEventListener("click",()=>this.replaceCurrent()),l.addEventListener("click",()=>this.replaceAll())}onInput(e){this._onInputCallback=e}open(e=!1){this.showReplace=e,this.panel.style.display="flex",this.replaceRow.style.display=e?"flex":"none";const t=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd);t&&!t.includes(`
|
|
1298
|
+
`)&&(this.findInput.value=t),this.findInput.focus(),this.findInput.select(),this.search()}close(){this.panel.style.display="none",this.matches=[],this.currentMatch=-1,this.textarea.focus()}isOpen(){return this.panel.style.display!=="none"}search(){this.matches=[],this.currentMatch=-1;const e=this.findInput.value;if(!e){this.countLabel.textContent="No results";return}const t=this.textarea.value;let i;try{if(this.useRegex){const s=this.caseSensitive?"g":"gi";i=new RegExp(e,s)}else{let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.wholeWord&&(s=`\\b${s}\\b`);const a=this.caseSensitive?"g":"gi";i=new RegExp(s,a)}}catch{this.countLabel.textContent="Invalid regex";return}let r,o=0;for(;(r=i.exec(t))!==null&&o<Ur;){if(o++,r[0].length===0){i.lastIndex++;continue}this.matches.push({start:r.index,end:r.index+r[0].length})}if(this.matches.length>0){const s=this.textarea.selectionStart;this.currentMatch=this.matches.findIndex(a=>a.start>=s),this.currentMatch===-1&&(this.currentMatch=0),this.highlightCurrent()}this.updateCount()}next(){this.matches.length&&(this.currentMatch=(this.currentMatch+1)%this.matches.length,this.highlightCurrent(),this.updateCount())}prev(){this.matches.length&&(this.currentMatch=(this.currentMatch-1+this.matches.length)%this.matches.length,this.highlightCurrent(),this.updateCount())}highlightCurrent(){if(this.currentMatch<0||this.currentMatch>=this.matches.length)return;const e=this.matches[this.currentMatch];this.textarea.focus(),this.textarea.setSelectionRange(e.start,e.end);const t=this.textarea.parentElement;if(t){const i=this.textarea.value.substring(0,e.start).split(`
|
|
1299
|
+
`).length,r=parseFloat(getComputedStyle(this.textarea).lineHeight)||22,o=(i-1)*r-t.clientHeight/3;t.scrollTop=Math.max(0,o)}}updateCount(){this.matches.length===0?this.countLabel.textContent=this.findInput.value?"No results":"":this.countLabel.textContent=`${this.currentMatch+1} of ${this.matches.length}`}replaceCurrent(){if(this.currentMatch<0||!this.matches.length)return;const e=this.matches[this.currentMatch],t=this.textarea.value,i=this.replaceInput.value;this.textarea.value=t.substring(0,e.start)+i+t.substring(e.end),this.textarea.selectionStart=this.textarea.selectionEnd=e.start+i.length,this._onInputCallback&&this._onInputCallback(),this.search()}replaceAll(){if(!this.matches.length)return;const e=this.replaceInput.value,t=this.textarea.value;let i="",r=0;for(const o of this.matches)i+=t.substring(r,o.start)+e,r=o.end;i+=t.substring(r),this.textarea.value=i,this._onInputCallback&&this._onInputCallback(),this.search()}createToggle(e,t){const i=document.createElement("button");return i.type="button",i.className="smdx-find-toggle",i.textContent=e,i.title=t,i.setAttribute("aria-label",t),i}createActionBtn(e,t){const i=document.createElement("button");return i.type="button",i.className="smdx-find-btn",i.textContent=e,i.title=t,i.setAttribute("aria-label",t),i}destroy(){this.panel.remove()}}const Yr="split",Xr="Start writing markdown...",Jr={lineNumbers:!1,wordCount:!0,lineCount:!0,modeSwitcher:!0,statusBar:!0,autoPreview:!0,previewDelay:150,spellcheck:!1,autocomplete:!1,dragAndDrop:!0,pasteImages:!1,keyboardShortcuts:!0,autoSave:!1,autoSaveKey:"smdx-autosave",autofocus:!1,vimMode:!1,history:{maxSize:100,debounce:300}},Zr={splitterPosition:50,minEditorWidth:200,minPreviewWidth:200,resizableSplitter:!0};function Qr(n){return{container:n.container,value:n.value??"",plugins:n.plugins??[],toolbar:n.toolbar,theme:n.theme,mode:n.mode??Yr,placeholder:n.placeholder??Xr,readOnly:n.readOnly??!1,renderers:n.renderers,locale:n.locale,onChange:n.onChange}}function en(n){if(!n.container)throw new Error("[SynclineMDX] Container is required");return Qr(n)}function tn(){const n=document.createElement("div");n.className="smdx-toolbar-container";const e=document.createElement("div");return e.className="smdx-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Editor toolbar"),n.appendChild(e),{container:n,toolbar:e}}function rn(n){const e=document.createElement("a");return e.className="smdx-skip-link",e.href=`#${n}`,e.textContent="Skip to editor",e}function nn(n){return new st({plugins:Kt(),toolbar:Yt(),placeholder:"Start writing markdown...",mode:"split",...n})}b.AutocompleteController=qr,b.CodeRenderer=$e,b.DEFAULT_FEATURES=Jr,b.DEFAULT_LAYOUT=Zr,b.DropdownController=jr,b.EventEmitter=Se,b.FindReplaceController=Kr,b.History=$r,b.LineNumberController=oe,b.ListRenderer=Be,b.MarkdownRenderer=Ae,b.MdxValidator=Ie,b.ModeController=ei,b.PluginContextClass=Hr,b.PluginManager=le,b.PluginManagerNew=le,b.PreviewController=ri,b.Renderer=Q,b.RendererPipeline=Q,b.SplitterController=ee,b.StatusBarController=ii,b.SynclineMDXEditor=st,b.TableRenderer=Le,b.ThemeController=ti,b.Toolbar=ce,b.UIController=Dr,b.accordionGroupPlugin=St,b.accordionPlugin=Et,b.admonitionPlugin=kt,b.allPlugins=Kt,b.boldPlugin=lt,b.breakLinePlugin=qt,b.cardGroupPlugin=Lt,b.cardPlugin=$t,b.codePlugin=mt,b.containerPlugin=Rt,b.copyTextPlugin=Ht,b.createEditor=nn,b.createEditorPane=Jt,b.createEditorRoot=Xt,b.createPreviewPane=Zt,b.createSkipLink=rn,b.createStatusBar=Qt,b.createToolbarDOM=tn,b.defaultToolbar=Yt,b.embedOthersPlugin=Nt,b.embedVideoPlugin=jt,b.emojiPlugin=zt,b.formulaPlugin=Ft,b.headingPlugin=at,b.highlightPlugin=yt,b.horizontalRulePlugin=Ut,b.icons=C,b.imageBackgroundPlugin=_t,b.imageFramePlugin=Ct,b.imagePlugin=ut,b.insertPlugin=Gt,b.italicPlugin=dt,b.linkPlugin=pt,b.mermaidPlugin=Wt,b.multiColumnPlugin=Mt,b.orderedListPlugin=bt,b.quotePlugin=ht,b.resolveConfig=en,b.stepPlugin=At,b.strikethroughPlugin=ct,b.tabPlugin=wt,b.tablePlugin=xt,b.taskListPlugin=ft,b.tipPlugin=Pt,b.tocPlugin=Vt,b.tooltipPlugin=Dt,b.unorderedListPlugin=gt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|