@synclineapi/mdx-editor 0.1.2 → 1.0.1
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 +403 -139
- 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 +139 -7
- 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 +26 -0
- package/dist/core/plugins/PluginManager.d.ts +41 -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 -31
- package/dist/core/toolbar.d.ts +1 -0
- package/dist/core/types.d.ts +150 -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 +29 -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/token-utils.d.ts +49 -0
- package/dist/plugins/utilities/index.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist/syncline-mdx-editor.js +9628 -1835
- package/dist/syncline-mdx-editor.umd.cjs +988 -90
- package/package.json +5 -4
|
@@ -1,24 +1,800 @@
|
|
|
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 i;(i=this.listeners.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.listeners.get(e))==null||i.forEach(o=>{try{o(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,i)=>(i.priority??0)-(t.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((t,i)=>(i.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 i of t.toolbarItems)this.toolbarItems.delete(i.id);if(t.shortcuts&&(this.shortcuts=this.shortcuts.filter(i=>!t.shortcuts.some(o=>o.key===i.key))),t.renderers){const i=new Set(t.renderers.map(o=>o.name));this.renderers=this.renderers.filter(o=>!i.has(o.name))}if(t.parsers){const i=new Set(t.parsers.map(o=>o.name));this.parsers=this.parsers.filter(o=>!i.has(o.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,i)=>(i.priority??0)-(t.priority??0))},registerParser:e=>{this.parsers.push(e),this.parsers.sort((t,i)=>(i.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,i,o){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=o,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 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 o=this.createButton(i);t.appendChild(o)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const o of e.items)typeof o=="string"?this.renderItem(o,i):this.renderGroup(o,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const o=document.createElement("button");o.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",o.type="button",o.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>`,o.title=e.label||"",o.setAttribute("aria-label",e.label||"Dropdown"),o.setAttribute("aria-haspopup","true"),o.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)}o.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,i)}),i.appendChild(o),i.appendChild(s),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const o=document.createElement("button");o.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",o.type="button",o.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>`,o.title=e.tooltip||e.label,o.setAttribute("aria-label",e.tooltip||e.label),o.setAttribute("aria-haspopup","true"),o.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)}o.addEventListener("click",n=>{n.stopPropagation(),this.toggleDropdown(s,i)}),i.appendChild(o),i.appendChild(s),t.appendChild(i)}renderSubmenu(e,t){const i=document.createElement("div");i.className="smdx-toolbar-submenu";const o=document.createElement("button");o.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",o.type="button",o.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 p=this.createMenuButton(c);s.appendChild(p)}const n=()=>{const c=i.getBoundingClientRect();s.style.left=`${c.right}px`,s.style.top=`${c.top}px`,requestAnimationFrame(()=>{const p=s.getBoundingClientRect();p.right>window.innerWidth&&(s.style.left=`${c.left-p.width}px`),p.bottom>window.innerHeight&&(s.style.top=`${window.innerHeight-p.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)};o.addEventListener("mouseenter",d),s.addEventListener("mouseenter",d),i.addEventListener("mouseleave",l),s.addEventListener("mouseleave",l),i.appendChild(o),i.appendChild(s),t.appendChild(i)}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",i=>{i.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",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){if(e.style.display==="none"){this.closeDropdowns(),e.style.display="",this.activeDropdown=t;const i=t.querySelector(".smdx-toolbar-dropdown-trigger");i==null||i.setAttribute("aria-expanded","true")}else{e.style.display="none";const i=t.querySelector(".smdx-toolbar-dropdown-trigger");i==null||i.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"}),(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 o=i.dataset.toolbarId,s=this.pluginManager.getToolbarItem(o);s!=null&&s.isActive&&i.classList.toggle("smdx-active",s.isActive(e)),s!=null&&s.isDisabled&&(i.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"),i=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),o=[];let s=i.currentNode;for(;s;){if(s.nodeType===Node.ELEMENT_NODE){const n=s,a=n.tagName.toLowerCase();if(Ce.has(a))o.push(n);else if(a==="iframe"){const d=n.getAttribute("src")||"";if(!Se(d))o.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=i.nextNode()}for(const n of o)n.remove();return t.body.innerHTML}class I{constructor(){this.renderers=[],this.parsers=[]}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const i=this.validateMdxTags(e),o=[];t=t.replace(/`([^`\n]+)`/g,(s,n)=>{const a=o.length;return o.push(n),`%%INLINECODE_${a}%%`}),t=this.applyParsers(t),t=this.applyRenderers(t);for(let s=0;s<o.length;s++)t=t.replace(`%%INLINECODE_${s}%%`,`\`${o[s]}\``);return t=this.renderMarkdown(t),i.length>0&&(t=i.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 i of this.parsers)t=t.replace(i.pattern,(...o)=>{const s=o;return i.transform(s)});return t}applyRenderers(e){let t=e;for(const i of this.renderers)t=t.replace(i.pattern,(o,...s)=>{const n={};return s.length>0&&(n.content=s[0]||""),i.render(o,n)});return t}renderMarkdown(e){let t=e;const i=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(s,n,a,d)=>{const l=i.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 p;const u=d.trimEnd();try{n&&v.getLanguage(n)?p=v.highlight(u,{language:n}).value:p=v.highlightAuto(u).value}catch{p=this.escapeHtml(u)}const g=n?c[n.toLowerCase()]||n.charAt(0).toUpperCase()+n.slice(1):"",x=g?`<span class="smdx-code-lang">${g}</span>`:"",f=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=g||a,w=k?`<div class="smdx-code-header">${x}${f}${y}</div>`:"";return i.push(`<div class="smdx-code-block${k?" smdx-has-header":""}">${w}<pre><code class="hljs language-${n||"text"}">${p}</code></pre>${k?"":y}</div>`),`%%CODEBLOCK_${l}%%`}),t=t.replace(/`([^`]+)`/g,(s,n)=>`<code class="smdx-inline-code">${this.escapeHtml(n)}</code>`);const o=s=>s.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(s,n)=>`<h6 id="${o(n)}">${n}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(s,n)=>`<h5 id="${o(n)}">${n}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(s,n)=>`<h4 id="${o(n)}">${n}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(s,n)=>`<h3 id="${o(n)}">${n}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(s,n)=>`<h2 id="${o(n)}">${n}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(s,n)=>`<h1 id="${o(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=this.renderNestedLists(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.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<i.length;s++)t=t.replace(`%%CODEBLOCK_${s}%%`,i[s]);return t}renderTables(e){const t=/(?:^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)*))/gm;return e.replace(t,(i,o,s,n)=>{const a=this.parseTableRow(o),d=n.trim().split(`
|
|
2
|
-
`).filter(Boolean).map(
|
|
3
|
-
`),i=[];let
|
|
4
|
-
`)}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}
|
|
5
|
-
`);for(let
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
`),l=(a?`
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`).length}applyTheme(e){for(const[t,i]of Object.entries(e))this.root.style.setProperty(t.startsWith("--")?t:`--smdx-${t}`,i)}}const h={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:h.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(r=>({id:`h${r}`,label:`Heading ${r}`,icon:h[`h${r}`],tooltip:`Heading ${r}`,action:({editor:e})=>{const t="#".repeat(r)+" ",o=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+o)}})),action:({editor:r})=>{const e=r.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),o=e.replace(/^#{1,6}\s*/,"");r.replaceCurrentLine("#".repeat(i)+" "+o)}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:h.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:r})=>r.wrapSelection("**","**"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:i}=r;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(i)}}],shortcuts:[{key:"Ctrl+b",action:({editor:r})=>r.wrapSelection("**","**"),description:"Bold"}]}}function H(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:h.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:r})=>r.wrapSelection("*","*"),isActive:({selection:r})=>{const{beforeText:e,afterText:t,text:i}=r;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(i)}}],shortcuts:[{key:"Ctrl+i",action:({editor:r})=>r.wrapSelection("*","*"),description:"Italic"}]}}function D(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:h.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:h.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 N(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:h.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 R(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:h.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:h.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:r})=>r.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:h.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:h.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:h.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:h.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:h.table,tooltip:"Insert Table",action:({editor:r})=>{r.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
1
|
+
(function(w,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],K):(w=typeof globalThis<"u"?globalThis:w||self,K(w.SynclineMDXEditor={},w.hljs))})(this,function(w,K){"use strict";class De{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(s=>{try{s(t)}catch(o){console.error(`[SynclineMDX] Error in event handler for "${e}":`,o)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class xe{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.tokenProvidersByPlugin=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 s of e.dependencies)if(!this.plugins.has(s))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${s}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const s of e.toolbarItems)this.toolbarItems.set(s.id,s);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((s,o)=>(o.priority??0)-(s.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((s,o)=>(o.priority??0)-(s.priority??0)));const t=e.completions?[...e.completions]:[];this.completionsByPlugin.set(e.name,t);const i=e.provideTokens?[e.provideTokens]:[];this.tokenProvidersByPlugin.set(e.name,i),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(s=>s.key===i.key))),t.renderers){const i=new Set(t.renderers.map(s=>s.name));this.renderers=this.renderers.filter(s=>!i.has(s.name))}if(t.parsers){const i=new Set(t.parsers.map(s=>s.name));this.parsers=this.parsers.filter(s=>!i.has(s.name))}this.completionsByPlugin.delete(e),this.tokenProvidersByPlugin.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}getTokenProviders(){const e=[];for(const t of this.tokenProvidersByPlugin.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,s)=>(s.priority??0)-(i.priority??0))},registerParser:t=>{this.parsers.push(t),this.parsers.sort((i,s)=>(s.priority??0)-(i.priority??0))},registerCompletion:t=>{const i=this.completionsByPlugin.get(e)??[];i.push(t),this.completionsByPlugin.set(e,i)},registerTokenProvider:t=>{const i=this.tokenProvidersByPlugin.get(e)??[];i.push(t),this.tokenProvidersByPlugin.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 gi(){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 ye(n){return gi()?n.replace(/ctrl\+/gi,"⌘").replace(/shift\+/gi,"⇧").replace(/alt\+/gi,"⌥"):n.replace(/⌘/g,"Ctrl+").replace(/⇧/g,"Shift+").replace(/⌥/g,"Alt+")}class ve{constructor(e,t,i,s){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=s,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 s=this.createButton(i);t.appendChild(s)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const s of e.items)typeof s=="string"?this.renderItem(s,i):this.renderGroup(s,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const s=document.createElement("button");s.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",s.type="button",s.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>`,s.title=e.label||"",s.setAttribute("aria-label",e.label||"Dropdown"),s.setAttribute("aria-haspopup","true"),s.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 r of e.items)if(typeof r=="string"){const a=this.pluginManager.getToolbarItem(r);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",r.label){const l=document.createElement("div");l.className="smdx-toolbar-dropdown-section-label",l.textContent=r.label,a.appendChild(l)}for(const l of r.items)if(typeof l=="string"){const c=this.pluginManager.getToolbarItem(l);if(c)if(c.children&&c.children.length>0)this.renderSubmenu(c,a);else{const d=this.createMenuButton(c);a.appendChild(d)}}o.appendChild(a)}s.addEventListener("click",r=>{r.stopPropagation(),this.toggleDropdown(o,i)}),i.appendChild(s),i.appendChild(o),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const s=document.createElement("button");s.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",s.type="button",s.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,r=e.shortcutLabel?ye(e.shortcutLabel):void 0;s.title=r?`${o} (${r})`:o,s.setAttribute("aria-label",r?`${o} (${r})`:o),s.setAttribute("aria-haspopup","true"),s.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 c=this.createMenuButton(l);a.appendChild(c)}s.addEventListener("click",l=>{l.stopPropagation(),this.toggleDropdown(a,i)}),i.appendChild(s),i.appendChild(a),t.appendChild(i)}positionMenu(e,t){const i=t.getBoundingClientRect(),s=4;let o=i.bottom+s,r=i.left;e.style.top=o+"px",e.style.left=r+"px",e.style.visibility="hidden",e.style.display="",requestAnimationFrame(()=>{const a=e.getBoundingClientRect();a.right>window.innerWidth-4&&(r=i.right-a.width,e.style.left=Math.max(4,r)+"px"),a.bottom>window.innerHeight-4&&(o=i.top-a.height-s,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 s=document.createElement("button");s.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",s.type="button",s.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 d of e.children)if(d.children&&d.children.length>0)this.renderSubmenu(d,o);else{const h=this.createMenuButton(d);o.appendChild(h)}const r=()=>{const d=i.getBoundingClientRect();o.style.left=`${d.right}px`,o.style.top=`${d.top}px`,requestAnimationFrame(()=>{const h=o.getBoundingClientRect();h.right>window.innerWidth&&(o.style.left=`${d.left-h.width}px`),h.bottom>window.innerHeight&&(o.style.top=`${window.innerHeight-h.height-8}px`)})};let a=null;const l=()=>{a&&(clearTimeout(a),a=null),o.style.display="",r()},c=()=>{a&&clearTimeout(a),a=setTimeout(()=>{o.style.display="none",a=null},120)};s.addEventListener("mouseenter",l),o.addEventListener("mouseenter",l),i.addEventListener("mouseleave",c),o.addEventListener("mouseleave",c),i.appendChild(s),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,s=e.shortcutLabel?ye(e.shortcutLabel):void 0;return t.title=s?`${i} (${s})`:i,t.setAttribute("aria-label",s?`${i} (${s})`:i),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,s&&t.setAttribute("data-shortcut",s),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">${ye(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,s;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="",(s=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||s.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 s=i.dataset.toolbarId,o=this.pluginManager.getToolbarItem(s);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 bi=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),fi=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function xi(n){return fi.some(e=>n.startsWith(e))}const je=/^on/i,yi=/^\s*javascript\s*:/i;function vi(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),s=[];let o=i.currentNode;for(;o;){if(o.nodeType===Node.ELEMENT_NODE){const r=o,a=r.tagName.toLowerCase();if(bi.has(a))s.push(r);else if(a==="iframe"){const l=r.getAttribute("src")||"";if(!xi(l))s.push(r);else{const c=[];for(const d of Array.from(r.attributes))je.test(d.name)&&c.push(d.name);for(const d of c)r.removeAttribute(d)}}else{const l=[];for(const c of Array.from(r.attributes))(je.test(c.name)||(c.name==="href"||c.name==="src"||c.name==="action")&&yi.test(c.value))&&l.push(c.name);for(const c of l)r.removeAttribute(c)}}o=i.nextNode()}for(const r of s)r.remove();return t.body.innerHTML}const wi={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 Ne{escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}renderBlock(e,t,i){let s;const o=i.trimEnd();try{e&&K.getLanguage(e)?s=K.highlight(o,{language:e}).value:s=K.highlightAuto(o).value}catch{s=this.escapeHtml(o)}const r=e?wi[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1):"",a=r?`<span class="smdx-code-lang">${r}</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>`:"",c='<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>',d=!!(r||t),h=d?`<div class="smdx-code-header">${a}${l}${c}</div>`:"";return`<div class="smdx-code-block${d?" smdx-has-header":""}">${h}<pre><code class="hljs language-${e||"text"}">${s}</code></pre>${d?"":c}</div>`}}class Oe{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,s,o,r)=>{const a=this.parseTableRow(s),l=r.trim().split(`
|
|
2
|
+
`).filter(Boolean).map(d=>this.parseTableRow(d));let c='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const d of a)c+=`<th>${d}</th>`;c+="</tr></thead><tbody>";for(const d of l){c+="<tr>";for(const h of d)c+=`<td>${h}</td>`;c+="</tr>"}return c+="</tbody></table></div>",c})}}class We{isListItem(e){return/^\s*[-*]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)}buildNestedList(e){var l,c,d;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]),s=i?"ol":"ul",o=i?"smdx-ol-item":"smdx-ul-item";let r=`<${s}>`,a=0;for(;a<e.length;){const h=e[a],p=((c=h.match(/^(\s*)/))==null?void 0:c[1].length)??0;if(p<t)break;if(p>t){a++;continue}const u=i?h.replace(/^\s*\d+\.\s+/,""):h.replace(/^\s*[-*]\s+/,"");a++;const g=[];for(;a<e.length&&((((d=e[a].match(/^(\s*)/))==null?void 0:d[1].length)??0)>t&&this.isListItem(e[a]));)g.push(e[a]),a++;const m=g.length>0?this.buildNestedList(g):"";r+=`<li class="${o}">${u}${m}</li>`}return r+=`</${s}>`,r}render(e){const t=e.split(`
|
|
3
|
+
`),i=[];let s=0;for(;s<t.length;)if(this.isListItem(t[s])){const o=[];for(;s<t.length&&this.isListItem(t[s]);)o.push(t[s]),s++;i.push(this.buildNestedList(o))}else i.push(t[s]),s++;return i.join(`
|
|
4
|
+
`)}}class ze{constructor(){this.codeRenderer=new Ne,this.tableRenderer=new Oe,this.listRenderer=new We}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,r,a,l)=>{const c=i.length;return i.push(this.codeRenderer.renderBlock(r,a,l)),`%%CODEBLOCK_${c}%%`}),t=t.replace(/`([^`]+)`/g,(o,r)=>`<code class="smdx-inline-code">${this.escapeHtml(r)}</code>`);const s=o=>o.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(o,r)=>`<h6 id="${s(r)}">${r}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(o,r)=>`<h5 id="${s(r)}">${r}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(o,r)=>`<h4 id="${s(r)}">${r}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(o,r)=>`<h3 id="${s(r)}">${r}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(o,r)=>`<h2 id="${s(r)}">${r}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(o,r)=>`<h1 id="${s(r)}">${r}</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 Fe{validate(e){const t=[];let i=e.replace(/```[\s\S]*?```/g,"");i=i.replace(/`[^`]+`/g,"");const s=[],o=i.split(`
|
|
5
|
+
`);for(let r=0;r<o.length;r++){const a=o[r];let l;const c=/<\/?([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?\/?>|<([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?>/g;for(;(l=c.exec(a))!==null;){const d=l[0];if(d.endsWith("/>"))continue;const h=l[1]||l[2];if(!h)continue;const p=l.index+1;if(d.startsWith("</")){let g=!1;for(let m=s.length-1;m>=0;m--)if(s[m].tag===h){s.splice(m,1),g=!0;break}g||t.push(`Unexpected closing tag '</${h}>' at line ${r+1}:${p} — no matching opening tag found.`)}else s.push({tag:h,line:r+1,col:p})}}for(const r of s)t.push(`Expected a closing tag for '<${r.tag}>' (${r.line}:${r.col}) before the end of the document.`);return t}}class ie{constructor(){this.renderers=[],this.parsers=[],this.markdownRenderer=new ze,this.mdxValidator=new Fe}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const i=this.mdxValidator.validate(e),s=[];t=t.replace(/`([^`\n]+)`/g,(o,r)=>{const a=s.length;return s.push(r),`%%INLINECODE_${a}%%`});for(const o of this.parsers)t=t.replace(o.pattern,(...r)=>o.transform(r));for(const o of this.renderers)t=t.replace(o.pattern,(r,...a)=>{const l={};return a.length>0&&(l.content=a[0]||""),o.render(r,l)});for(let o=0;o<s.length;o++)t=t.replace(`%%INLINECODE_${o}%%`,`\`${s[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 vi(t)}}const me=class me{constructor(e,t,i){this.isDragging=!1,this.startX=0,this.startLeftWidth=0,this.onResizeCallback=null,this.resizeRafId=null,this.onMouseDown=s=>{this.startDrag(s.clientX),s.preventDefault()},this.onMouseMove=s=>{this.isDragging&&this.moveDrag(s.clientX)},this.onMouseUp=()=>{this.endDrag()},this.onTouchStart=s=>{s.touches.length===1&&(this.startDrag(s.touches[0].clientX),s.preventDefault())},this.onTouchMove=s=>{!this.isDragging||s.touches.length!==1||(this.moveDrag(s.touches[0].clientX),s.preventDefault())},this.onTouchEnd=()=>{this.endDrag()},this.onKeyDown=s=>{if(s.key!=="ArrowLeft"&&s.key!=="ArrowRight")return;s.preventDefault();const o=this.container.getBoundingClientRect().width;if(o<=0)return;const r=this.left.getBoundingClientRect().width,a=o*me.KEYBOARD_STEP_PERCENT,l=s.key==="ArrowRight"?a:-a;let c=(r+l)/o*100;c=Math.max(20,Math.min(80,c)),this.left.style.flex=`0 0 ${c}%`,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 s=(this.startLeftWidth+t)/i*100;s=Math.max(20,Math.min(80,s)),this.left.style.flex=`0 0 ${s}%`,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()}};me.KEYBOARD_STEP_PERCENT=.02;let se=me;var ki=Object.defineProperty,_i=(n,e,t)=>e in n?ki(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,k=(n,e,t)=>_i(n,typeof e!="symbol"?e+"":e,t);const Ci={typescript:"//",javascript:"//",css:"//",json:"",markdown:"",text:""},we=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"]),Ti=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"]),Si=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"]),Ei=new Set(["null","true","false"]),Ge=new Set,ke=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"]),Mi=new Set(["number","string","boolean","object","Promise","Array","Map","Set","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),Li=new Set,$i=new Set,Ve=new Set,Ue={typescript:we,javascript:Ti,css:Si,json:Ei,markdown:Ge,text:Ge},qe={typescript:ke,javascript:Mi,css:Li,json:$i,markdown:Ve,text:Ve};function Ke(n,e){return{fileId:n,doc:[...e],cur:{row:0,col:0},sel:null,dirty:!1,undoStack:[],redoStack:[],scrollTop:0}}function Ai(n,e){switch(n.kind){case"insert":e.splice(n.row,0,...n.lines);break;case"delete":e.splice(n.row,n.count);break;case"replace":e.splice(n.row,n.oldLines.length,...n.newLines);break}}function Bi(n,e){switch(n.kind){case"insert":e.splice(n.row,n.lines.length);break;case"delete":e.splice(n.row,0,...n.removed);break;case"replace":e.splice(n.row,n.newLines.length,...n.oldLines);break}}function M(n,e=100,t,i,s,o=[],r=[]){const a={op:t,beforeCur:{...i},beforeSel:s?{...s}:null,afterCur:{...n.cur},afterSel:n.sel?{...n.sel}:null,beforeExtra:o.map(l=>({...l,sel:l.sel?{...l.sel}:null})),afterExtra:r.map(l=>({...l,sel:l.sel?{...l.sel}:null}))};n.undoStack.push(a),n.undoStack.length>e&&n.undoStack.shift(),n.redoStack=[],n.dirty=!0}function Ii(n){if(!n.undoStack.length)return null;const e=n.undoStack.pop();return n.redoStack.push(e),Bi(e.op,n.doc),n.cur={...e.beforeCur},n.sel=e.beforeSel?{...e.beforeSel}:null,e.beforeExtra.map(t=>({...t,sel:t.sel?{...t.sel}:null}))}function Ri(n){if(!n.redoStack.length)return null;const e=n.redoStack.pop();return n.undoStack.push(e),Ai(e.op,n.doc),n.cur={...e.afterCur},n.sel=e.afterSel?{...e.afterSel}:null,e.afterExtra.map(t=>({...t,sel:t.sel?{...t.sel}:null}))}function A(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 P(n){const{ar:e,ac:t,fr:i,fc:s}=n;return e<i||e===i&&t<=s?n:{ar:i,ac:s,fr:e,fc:t}}function Ye(n,e,t){if(!n)return null;const i=P(n);return e<i.ar||e>i.fr?null:{start:e===i.ar?i.ac:0,end:e===i.fr?i.fc:t}}function Pi(n){if(!n.sel)return 0;const e=P(n.sel);let t=0;for(let i=e.ar;i<=e.fr;i++){const s=n.doc[i]??"",o=i===e.ar?e.ac:0,r=i===e.fr?e.fc:s.length;t+=r-o}return t}function Xe(n){if(!n.sel)return"";const e=P(n.sel),t=[];for(let i=e.ar;i<=e.fr;i++){const s=n.doc[i]??"";t.push(s.slice(i===e.ar?e.ac:0,i===e.fr?e.fc:s.length))}return t.join(`
|
|
6
|
+
`)}function _e(n,e){const t=Math.min(n.length,e.length);let i=0;for(;i<t&&n[i]===e[i];)i++;if(i===n.length&&i===e.length)return{row:i,oldLines:[],newLines:[]};let s=n.length-1,o=e.length-1;for(;s>i&&o>i&&n[s]===e[o];)s--,o--;return{row:i,oldLines:n.slice(i,s+1),newLines:e.slice(i,o+1)}}function F(n){const e=n.sel;if(!e)return n.cur;const t=P(e),i=(n.doc[t.ar]??"").slice(0,t.ac),s=(n.doc[t.fr]??"").slice(t.fc);return n.doc.splice(t.ar,t.fr-t.ar+1,i+s),n.sel=null,{row:t.ar,col:t.ac}}function Hi(n,e,t){if(!t||n.length<=e)return[n];const i=[];let s=0;for(;s<n.length;){if(n.length-s<=e){i.push(n.slice(s));break}const o=s+e;let r=-1;for(let a=o;a>s;a--)if(n[a-1]===" "){r=a;break}r===-1?(i.push(n.slice(s,o)),s=o):(i.push(n.slice(s,r)),s=r)}return i}function Di(n,e,t){return!t||n.length<=e?1:Math.max(1,Math.ceil(n.length/e))}function Je(n,e,t,i,s,o){const r=s!==void 0&&o!==void 0,a=s??0,l=o??n.length-1;if(r&&!t&&i.size===0){const m=[],v=[];for(let y=a;y<=l&&y<n.length;y++){const _=n[y]??"";m[y]=[_],v.push({docLine:y,segIdx:0,text:_})}return{segments:m,visualRows:v,docToVisArr:null,totalVisualRows:n.length,windowVisStart:a}}const c=new Array(n.length),d=new Array(n.length),h=[];let p=0,u=-1,g=0;for(let m=0;m<n.length;m++){if(d[m]=p,m>0&&m<=u){c[m]=[n[m]??""];continue}if(r&&m===a&&(g=p),!r||m>=a&&m<=l){const v=Hi(n[m]??"",e,t);c[m]=v,v.forEach((y,_)=>h.push({docLine:m,segIdx:_,text:y})),p+=v.length}else c[m]=[],p+=Di(n[m]??"",e,t);i.has(m)&&(u=i.get(m))}return{segments:c,visualRows:h,docToVisArr:d,totalVisualRows:p,windowVisStart:g}}function Y(n,e,t){const i=n.segments[e];if(!i||i.length===0)return{visRow:n.docToVisArr!==null?n.docToVisArr[e]??e:e,colInSeg:0};const s=n.docToVisArr!==null?n.docToVisArr[e]??e:e;let o=t;for(let r=0;r<i.length;r++){if(o<=i[r].length||r===i.length-1)return{visRow:s+r,colInSeg:Math.min(o,i[r].length)};o-=i[r].length}return{visRow:s,colInSeg:0}}function ne(n,e,t){var i,s;const o=e-n.windowVisStart,r=n.visualRows[o];if(!r)return n.docToVisArr===null?{row:Math.max(0,Math.min(n.totalVisualRows-1,e)),col:t}:{row:0,col:0};const a=n.segments[r.docLine]??[""];let l=Math.min(t,((i=a[r.segIdx])==null?void 0:i.length)??0);for(let c=0;c<r.segIdx;c++)l+=((s=a[c])==null?void 0:s.length)??0;return{row:r.docLine,col:l}}function Ze(n){return n.split(`
|
|
7
|
+
`)}function R(n){return n.join(`
|
|
8
|
+
`)}function oe(n){return(n.match(/^(\s*)/)??["",""])[1]}function re(n){return" ".repeat(Math.max(0,n))}function Qe(n){return/[\w$]/.test(n)}function et(n,e,t=Qe){let i=e;for(;i>0&&t(n[i-1]);)i--;return i}function tt(n,e,t=Qe){let i=e;for(;i<n.length&&t(n[i]);)i++;return i}function Ce(n,e){let t=0,i=null;return(...s)=>{const o=Date.now(),r=e-(o-t);r<=0?(i!==null&&(clearTimeout(i),i=null),t=o,n(...s)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,n(...s)},r))}}function ji(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function it(n,e,t,i){n.cursors.some(s=>s.row===e&&s.col===t)||n.cursors.push({row:e,col:t,sel:i})}function st(n){n.cursors=[],n.searchWord="",n.lastMatchRow=-1,n.lastMatchCol=-1}function Ni(n,e,t,i,s){const o=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((d,h)=>({row:d.row,col:d.col,isPrimary:!1,idx:h+1}))];o.sort((d,h)=>h.row!==d.row?h.row-d.row:h.col-d.col);const r=n.map(d=>d);let a=e,l=t;const c=i.map(d=>({...d}));for(const d of o){const h=r[d.row]??"";r[d.row]=h.slice(0,d.col)+s+h.slice(d.col);for(const p of o)p!==d&&p.row===d.row&&p.col>=d.col&&(p.col+=s.length);d.col+=s.length}for(const d of o)d.isPrimary?(a=d.row,l=d.col):(c[d.idx-1].row=d.row,c[d.idx-1].col=d.col);return{doc:r,primaryRow:a,primaryCol:l,extraCursors:c}}function Te(n,e,t,i,s,o){const r=[{row:e,col:t,sel:i,isPrimary:!0,idx:0},...s.map((h,p)=>({row:h.row,col:h.col,sel:h.sel,isPrimary:!1,idx:p+1}))];r.sort((h,p)=>p.row!==h.row?p.row-h.row:p.col-h.col);const a=n.slice();let l=e,c=t;const d=s.map(h=>({...h}));for(const h of r){const p=o(a,h.row,h.col,h.sel);if(!p)continue;const{fromRow:u,fromCol:g,toRow:m,toCol:v}=p;if(u===m){const y=a[u]??"";a[u]=y.slice(0,g)+y.slice(v)}else{const y=a[u]??"",_=a[m]??"";a[u]=y.slice(0,g)+_.slice(v),a.splice(u+1,m-u)}h.isPrimary?(l=u,c=g):(d[h.idx-1].row=u,d[h.idx-1].col=g,d[h.idx-1].sel=null)}return{doc:a,primaryRow:l,primaryCol:c,extraCursors:d}}function Oi(n,e,t,i,s){let o=n.searchWord;if(!o){if(s&&s.ar===s.fr&&(o=(e[s.ar]??"").slice(s.ac,s.fc),o))return n.searchWord=o,n.lastMatchRow=s.fr,n.lastMatchCol=s.fc,{word:o,sel:{ar:s.ar,ac:s.ac,fr:s.fr,fc:s.fc},row:s.fr,col:s.fc};const l=e[t]??"",c=et(l,i),d=tt(l,i);return o=l.slice(c,d),o?(n.searchWord=o,n.lastMatchRow=t,n.lastMatchCol=d,{word:o,sel:{ar:t,ac:c,fr:t,fc:d},row:t,col:d}):null}const r=n.lastMatchRow,a=n.lastMatchCol;for(let l=r;l<e.length;l++){const c=e[l]??"";let d=l===r?a:0;for(;d<=c.length-o.length;){const h=c.indexOf(o,d);if(h<0)break;const p=h===0||!/\w/.test(c[h-1]),u=h+o.length>=c.length||!/\w/.test(c[h+o.length]);if(p&&u)return n.lastMatchRow=l,n.lastMatchCol=h+o.length,{word:o,sel:{ar:l,ac:h,fr:l,fc:h+o.length},row:l,col:h+o.length};d=h+1}}for(let l=0;l<=r;l++){const c=e[l]??"",d=l===r?a:c.length;let h=0;for(;h<d;){const p=c.indexOf(o,h);if(p<0||p>=d)break;const u=p===0||!/\w/.test(c[p-1]),g=p+o.length>=c.length||!/\w/.test(c[p+o.length]);if(u&&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};h=p+1}}return null}function Se(n,e={}){var t,i;if(e.provideTokens)return e.provideTokens(n,e.language??"typescript");const s=[],o=n.length;let r=0;const a=(p,u,g)=>{g>u&&s.push({cls:p,start:u,end:g})},l=Ue[e.language??"typescript"]??we,c=qe[e.language??"typescript"]??ke,d=(t=e.extraKeywords)!=null&&t.size?new Set([...l,...e.extraKeywords]):l,h=(i=e.extraTypes)!=null&&i.size?new Set([...c,...e.extraTypes]):c;for(;r<o;){if(n[r]==="/"&&n[r+1]==="/"){a("cmt",r,o);break}if(n[r]==="*"||n[r]==="/"&&n[r+1]==="*"){a("cmt",r,o);break}if(n[r]==="@"){let p=r+1;for(;p<o&&/\w/.test(n[p]);)p++;a("dec",r,p),r=p;continue}if(n[r]==='"'||n[r]==="'"||n[r]==="`"){const p=n[r];let u=r+1;for(;u<o;){if(n[u]==="\\"){u+=2;continue}if(n[u]===p){u++;break}u++}a("str",r,u),r=u;continue}if(/\d/.test(n[r])&&(r===0||!/\w/.test(n[r-1]))){let p=r;for(;p<o&&/[\d._xXa-fA-F]/.test(n[p]);)p++;a("num",r,p),r=p;continue}if(/[a-zA-Z_$]/.test(n[r])){let p=r;for(;p<o&&/[\w$]/.test(n[p]);)p++;const u=n.slice(r,p);d.has(u)?a("kw",r,p):h.has(u)?a("typ",r,p):p<o&&n[p]==="("?a("fn",r,p):/^[A-Z]/.test(u)&&a("cls",r,p),r=p;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(n[r])){a("op",r,r+1),r++;continue}r++}return s}function nt(n,e){const t=new Array(n.length).fill("");for(const i of e)for(let s=i.start;s<i.end;s++)t[s]=i.cls;return t}class Wi{constructor(e=5e3){k(this,"_cache",new Map),k(this,"_maxSize"),k(this,"_hits",0),k(this,"_misses",0),k(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}}function H(n,e,t){const i=document.createElement(n);return e&&(i.className=e),i}function ee(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ae(n,e=document.documentElement){return getComputedStyle(e).getPropertyValue(n).trim()}function ot(n,e){const t=n.replace("#",""),i=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return`rgba(${i},${s},${o},${e})`}function Ee(n,e,t,i,s){const o=Math.max(0,n*s-t),r=Math.max(0,n*2-i),a=(o>0?e/o:0)*r,l=Math.max(20,t/s*2),c=e/s*2-a;return{mmScroll:a,sliderTop:c,sliderHeight:l}}function zi(n,e,t,i,s){const o=Math.max(0,e*s-t),r=Math.max(0,e*2-i);if(o<=0)return 0;const a=2/s-r/o;if(Math.abs(a)<1e-9){const l=Math.max(20,t/s*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 Fi(n,e,t,i,s,o){const r=Math.max(0,e*o-i),a=Math.max(0,e*2-s);if(r<=0)return 0;const l=t/r*a,c=(n+l)/2;return Math.max(0,Math.min(r,c*o-i/2))}function Me(n){const e=t=>{const i=n(t);return i.startsWith("#")&&i.length===7?ot(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?ot(t,.28):"rgba(150,148,140,0.28)"})()}}function Gi(n){var e,t,i,s;const{canvas:o,doc:r,firstLine:a,lastLine:l,subPx:c,wrapperWidth:d,canvasHeight:h,cursorRow:p,sel:u,findMatches:g,findIdx:m,sliderTop:v,sliderHeight:y,colors:_,getCssVar:x,dpr:b}=n,f=o.getContext("2d");if(!f)return;f.setTransform(b,0,0,b,0,0);const C=x("--mm-bg")||"#0d0d0f",S=x("--mm-dim")||"rgba(0,0,0,.30)",T=x("--mm-edge")||"rgba(255,255,255,.18)",I=x("--mm-slider")||"rgba(255,255,255,.07)",W=x("--sel-bg")||"rgba(110,159,255,.22)",j=x("--cur-line-bg")||"rgba(255,255,255,.05)",G=x("--find-border")||"rgba(234,180,86,.50)",ge=x("--find-cur-bg")||"rgba(234,180,86,.80)",X=E=>(E-a)*2;if(f.fillStyle=C,f.fillRect(0,0,d,h),p>=a&&p<l&&(f.fillStyle=j,f.fillRect(0,X(p),d,2)),u){const E=Math.max(a,u.ar),B=Math.min(l-1,u.fr);B>=E&&(f.fillStyle=W,f.fillRect(0,X(E),d,(B-E+1)*2))}for(const E of g){if(E.row<a||E.row>=l)continue;const B=m>=0&&((e=g[m])==null?void 0:e.row)===E.row&&((t=g[m])==null?void 0:t.col)===E.col;f.fillStyle=B?ge:G,f.fillRect(3+E.col*1.1,X(E.row),Math.max(3,E.len*1.1),2)}const J=Math.floor((d-3)/1.1);for(let E=a;E<l;E++){const B=r[E]??"";if(!B.trim())continue;const N=X(E),V=1.5,be=`${E}:0:none`;let fe=((i=n.tokenCache)==null?void 0:i.get(be,B))??null;fe||(fe=Se(B,{language:n.language,provideTokens:n.provideTokens}),(s=n.tokenCache)==null||s.set(be,B,fe));let U=0;for(const q of fe){if(q.start>=J)break;q.start>U&&(f.fillStyle=_.txt,f.fillRect(3+U*1.1,N,(Math.min(q.start,J)-U)*1.1,V));const wn=_[q.cls]??_.txt,mi=Math.min(q.end,J)-q.start;mi>0&&(f.fillStyle=wn,f.fillRect(3+q.start*1.1,N,mi*1.1,V)),U=Math.max(U,Math.min(q.end,J))}const ui=Math.min(B.length,J);U<ui&&(f.fillStyle=_.txt,f.fillRect(3+U*1.1,N,(ui-U)*1.1,V))}const Z=v+c,L=Z+y;f.fillStyle=S,Z>0&&f.fillRect(0,0,d,Z),L<h&&f.fillRect(0,L,d,h-L),f.fillStyle=I,f.fillRect(0,Z,d,y),f.fillStyle=T,f.fillRect(0,Math.max(0,Z),d,1),f.fillRect(0,Math.max(0,L-1),d,1)}function Vi(n,e){const t=o=>/[\w$]/.test(o);let i=e;for(;i<n.length&&t(n[i]);)i++;let s=e;for(;s>0&&t(n[s-1]);)s--;if(s===i)return"";if(s>0&&n[s-1]==="."){let o=s-1,r=o;for(;r>0&&t(n[r-1]);)r--;if(r<o)return n.slice(r,i)}return n.slice(s,i)}const Ui={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 qi(n,e){const t=Ui[n];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}const Ki=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function rt(n){const e=n.trim();if(!e)return null;try{const t=Le(e);return t===e?null:t}catch{return null}}function Le(n){if(n.includes(">")){const t=n.indexOf(">");return $e(n.slice(0,t),Le(n.slice(t+1)))}if(n.includes("+"))return n.split("+").map(t=>Le(t.trim())).join(`
|
|
9
|
+
`);const e=n.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,s)=>$e(e[1],`$${s+1}`)).join(`
|
|
10
|
+
`)}return $e(n,"$1")}function $e(n,e){const t=n.match(/#([\w-]+)/),i=n.match(/\.([\w.-]+)/g),s=n.match(/\[([^\]]+)\]/);let o=n.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",r="";return t&&(r+=` id="${t[1]}"`),i&&(r+=` class="${i.map(a=>a.slice(1)).join(" ")}"`),s&&(r+=` ${s[1]}`),Ki.has(o)?`<${o}${r}>`:`<${o}${r}>${e}</${o}>`}function at(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 Yi=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
|
|
11
|
+
|
|
12
|
+
function name(params) {
|
|
13
|
+
// body
|
|
14
|
+
}`,body:`function $1($2) {
|
|
15
|
+
$3
|
|
16
|
+
}`},{label:"afn",kind:"snip",detail:"arrow function",description:`Declares a const arrow function.
|
|
17
|
+
|
|
18
|
+
const name = (params) => {
|
|
19
|
+
// body
|
|
20
|
+
};`,body:`const $1 = ($2) => {
|
|
21
|
+
$3
|
|
22
|
+
};`},{label:"asyncfn",kind:"snip",detail:"async function",description:`Declares an async function returning a Promise.
|
|
23
|
+
|
|
24
|
+
async function name(params): Promise<T> {
|
|
25
|
+
// body
|
|
26
|
+
}`,body:`async function $1($2): Promise<$3> {
|
|
27
|
+
$4
|
|
28
|
+
}`},{label:"cl",kind:"snip",detail:"class declaration",description:`Declares a class with a constructor.
|
|
29
|
+
|
|
30
|
+
class Name {
|
|
31
|
+
constructor(params) { ... }
|
|
32
|
+
}`,body:`class $1 {
|
|
33
|
+
constructor($2) {
|
|
34
|
+
$3
|
|
35
|
+
}
|
|
36
|
+
}`},{label:"forof",kind:"snip",detail:"for…of loop",description:`Iterates over the values of an iterable (array, string, Map, etc.).
|
|
37
|
+
|
|
38
|
+
for (const item of iterable) { ... }`,body:`for (const $1 of $2) {
|
|
39
|
+
$3
|
|
40
|
+
}`},{label:"forin",kind:"snip",detail:"for…in loop",description:`Iterates over the enumerable property keys of an object.
|
|
41
|
+
|
|
42
|
+
for (const key in object) { ... }`,body:`for (const $1 in $2) {
|
|
43
|
+
$3
|
|
44
|
+
}`},{label:"trycatch",kind:"snip",detail:"try / catch block",description:`Wraps code in a try/catch to handle runtime errors.
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
...
|
|
48
|
+
} catch (error) {
|
|
49
|
+
...
|
|
50
|
+
}`,body:`try {
|
|
51
|
+
$1
|
|
52
|
+
} catch ($2error) {
|
|
53
|
+
$3
|
|
54
|
+
}`},{label:"promise",kind:"snip",detail:"new Promise",description:`Creates a new Promise with resolve and reject handlers.
|
|
55
|
+
|
|
56
|
+
new Promise<T>((resolve, reject) => { ... })`,body:`new Promise<$1>((resolve, reject) => {
|
|
57
|
+
$2
|
|
58
|
+
})`},{label:"imp",kind:"snip",detail:"import statement",description:`Adds a named import from a module.
|
|
59
|
+
|
|
60
|
+
import { name } from 'module';`,body:"import { $1 } from '$2';"},{label:"iface",kind:"snip",detail:"interface (TypeScript)",description:`Declares a TypeScript interface.
|
|
61
|
+
|
|
62
|
+
interface Name {
|
|
63
|
+
field: Type;
|
|
64
|
+
}`,body:`interface $1 {
|
|
65
|
+
$2: $3;
|
|
66
|
+
}`,language:["typescript"]},{label:"ife",kind:"snip",detail:"immediately-invoked function expression",description:`An IIFE — defines and immediately calls a function.
|
|
67
|
+
|
|
68
|
+
((params) => {
|
|
69
|
+
...
|
|
70
|
+
})(args);`,body:`(($1) => {
|
|
71
|
+
$2
|
|
72
|
+
})($3);`},{label:"sw",kind:"snip",detail:"switch statement",description:`A switch/case statement with a default branch.
|
|
73
|
+
|
|
74
|
+
switch (expr) {
|
|
75
|
+
case value:
|
|
76
|
+
...
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
...
|
|
80
|
+
}`,body:`switch ($1) {
|
|
81
|
+
case $2:
|
|
82
|
+
$3
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
$4
|
|
86
|
+
}`}],Xi=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
|
|
87
|
+
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;`,body:`display: flex;
|
|
91
|
+
align-items: $1center;
|
|
92
|
+
justify-content: $2center;`,language:["css"]},{label:"grid",kind:"snip",detail:"CSS grid",description:`Sets up a CSS grid with equal columns and gap.
|
|
93
|
+
|
|
94
|
+
display: grid;
|
|
95
|
+
grid-template-columns: repeat(3, 1fr);
|
|
96
|
+
gap: 16px;`,body:`display: grid;
|
|
97
|
+
grid-template-columns: $1repeat(3, 1fr);
|
|
98
|
+
gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",description:`A responsive media query breakpoint.
|
|
99
|
+
|
|
100
|
+
@media (max-width: 768px) {
|
|
101
|
+
...
|
|
102
|
+
}`,body:`@media ($1max-width: 768px) {
|
|
103
|
+
$2
|
|
104
|
+
}`,language:["css"]},{label:"anim",kind:"snip",detail:"@keyframes animation",description:`A CSS keyframes animation block.
|
|
105
|
+
|
|
106
|
+
@keyframes name {
|
|
107
|
+
from { ... }
|
|
108
|
+
to { ... }
|
|
109
|
+
}`,body:`@keyframes $1 {
|
|
110
|
+
from { $2 }
|
|
111
|
+
to { $3 }
|
|
112
|
+
}`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
|
|
113
|
+
|
|
114
|
+
--name: value;`,body:"--$1: $2;",language:["css"]}],Ji=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
|
|
115
|
+
|
|
116
|
+
<details>
|
|
117
|
+
<summary>Title</summary>
|
|
118
|
+
<div>content</div>
|
|
119
|
+
</details>`,body:`<details>
|
|
120
|
+
<summary>$1Title</summary>
|
|
121
|
+
<div>
|
|
122
|
+
$2
|
|
123
|
+
</div>
|
|
124
|
+
</details>`},{label:"card",kind:"snip",detail:"card component",description:"A generic card component with header, body, and footer sections.",body:`<div class="card">
|
|
125
|
+
<div class="card-header">$1</div>
|
|
126
|
+
<div class="card-body">$2</div>
|
|
127
|
+
<div class="card-footer">$3</div>
|
|
128
|
+
</div>`},{label:"navbar",kind:"snip",detail:"navigation bar",description:`A simple navigation bar with anchor links.
|
|
129
|
+
|
|
130
|
+
<nav class="navbar">
|
|
131
|
+
<a href="#">Home</a> ...
|
|
132
|
+
</nav>`,body:`<nav class="navbar">
|
|
133
|
+
<a href="$1#">Home</a>
|
|
134
|
+
<a href="$2#">About</a>
|
|
135
|
+
<a href="$3#">Contact</a>
|
|
136
|
+
</nav>`},{label:"modal",kind:"snip",detail:"modal dialog",description:`A modal dialog layout with header, body, and footer.
|
|
137
|
+
|
|
138
|
+
<div class="modal">
|
|
139
|
+
<div class="modal-dialog"> ... </div>
|
|
140
|
+
</div>`,body:`<div class="modal">
|
|
141
|
+
<div class="modal-dialog">
|
|
142
|
+
<div class="modal-header">$1</div>
|
|
143
|
+
<div class="modal-body">$2</div>
|
|
144
|
+
<div class="modal-footer">$3</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>`},{label:"table",kind:"snip",detail:"HTML table",description:`A semantic HTML table with thead and tbody.
|
|
147
|
+
|
|
148
|
+
<table>
|
|
149
|
+
<thead><tr><th>...</th></tr></thead>
|
|
150
|
+
<tbody><tr><td>...</td></tr></tbody>
|
|
151
|
+
</table>`,body:`<table>
|
|
152
|
+
<thead>
|
|
153
|
+
<tr>
|
|
154
|
+
<th>$1</th>
|
|
155
|
+
</tr>
|
|
156
|
+
</thead>
|
|
157
|
+
<tbody>
|
|
158
|
+
<tr>
|
|
159
|
+
<td>$2</td>
|
|
160
|
+
</tr>
|
|
161
|
+
</tbody>
|
|
162
|
+
</table>`}];function Zi(n){const e=[...Ji];return(n==="typescript"||n==="javascript")&&e.push(...Yi.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(n):t.language===n))),n==="css"&&e.push(...Xi),e}function Qi(n,e,t){let i=e;for(;i>0&&/\w/.test(n[i-1]);)i--;const s=n.slice(i,e);if(!s)return null;const o=t.find(r=>r.kind==="snip"&&r.label===s);return o?{snippet:o,start:i}:null}const Ae=[{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>"}],es=[{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"}],ts={typescript:Ae,javascript:Ae,css:es,json:[],markdown:[],text:[]};function lt(n,e,t){const i=Ue[n]??we,s=qe[n]??ke,o=ts[n]??Ae;return[...[...i,...e].map(r=>({label:r,kind:"kw",detail:"keyword"})),...[...s,...t].map(r=>({label:r,kind:"typ",detail:"type"})),...o]}function is(n,e){const t=new Set;for(const i of n){const s=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const o of s)o!==e&&o.length>2&&t.add(o)}return t}function dt(n,e){return n.language?Array.isArray(n.language)?n.language.includes(e):n.language===e:!0}function ss(n,e,t={},i=0,s=0){if(e.length<2)return[];const o=e.toLowerCase(),{language:r="typescript",extraKeywords:a=[],extraTypes:l=[],completions:c=[],replaceBuiltins:d=!1,maxResults:h=14}=t,p=c.filter(b=>b.kind==="snip"&&!!b.body&&dt(b,r)),u=c.filter(b=>!(b.kind==="snip"&&b.body)&&dt(b,r)),g=p.filter(b=>b.label.toLowerCase().startsWith(o));let m;if(t.provideCompletions){const b={line:n[i]??"",col:s,prefix:e,language:r,doc:n};let f;try{f=t.provideCompletions(b)}catch(C){console.error("[syncline-editor] provideCompletions threw an error:",C),f=null}m=f!=null?[...f,...u]:[...d?[]:lt(r,a,l),...u]}else m=d?u:[...lt(r,a,l),...u];const v=new Set(m.map(b=>b.label)),y=m.filter(b=>b.label.toLowerCase().startsWith(o)&&b.label!==e),_=new Set(g.map(b=>b.label)),x=[...is(n,e)].filter(b=>b.toLowerCase().startsWith(o)&&!v.has(b)&&!_.has(b)).slice(0,8).map(b=>({label:b,kind:"var",detail:"in file"}));return[...g,...y.filter(b=>!_.has(b.label)),...x].slice(0,h)}function ns(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 os(n,e,t){if(!e)return[];const i=[];for(let s=0;s<n.length;s++){const o=n[s]??"";if(t.useRegex)try{const r=new RegExp(e,t.caseSensitive?"g":"gi");let a;for(;(a=r.exec(o))!==null&&(i.push({row:s,col:a.index,len:a[0].length}),!!a[0].length););}catch{}else{const r=t.caseSensitive?o:o.toLowerCase(),a=t.caseSensitive?e:e.toLowerCase();let l=0;for(;;){const c=r.indexOf(a,l);if(c===-1)break;i.push({row:s,col:c,len:e.length}),l=c+1}}}return i}function rs(n,e,t,i){const s=e[t];if(!s)return n;const o=[...n],r=o[s.row]??"";return o[s.row]=r.slice(0,s.col)+i+r.slice(s.col+s.len),o}function as(n,e,t){const i=[...n];for(let s=e.length-1;s>=0;s--){const o=e[s],r=i[o.row]??"";i[o.row]=r.slice(0,o.col)+t+r.slice(o.col+o.len)}return i}function ls(n,e,t){return n.length?(e+t+n.length)%n.length:-1}function ds(n,e){const t=n[e]??"";let i=0;for(const s of t)s==="{"?i++:s==="}"&&i--;return i>0}function cs(n,e){let t=0;for(let i=e;i<n.length;i++)for(const s of n[i]??"")if(s==="{")t++;else if(s==="}"&&(t--,t===0))return i;return null}function hs(n,e,t){const i=new Map(n);if(i.has(t))i.delete(t);else{const s=cs(e,t);s!==null&&s>t&&i.set(t,s)}return i}function ps(n){var e,t,i,s;const{vr:o,visIdx:r,curVisRow:a,wm:l,foldedLines:c,isFoldable:d,opts:h}=n,{docLine:p,segIdx:u,text:g}=o,m=r===a,v=p===((e=l.visualRows[a-l.windowVisStart])==null?void 0:e.docLine),y=u>0,_=((t=l.segments[p])==null?void 0:t.slice(0,u).reduce((L,E)=>L+E.length,0))??0,x=n.docSel?Ye(n.docSel,p,((i=(l.segments[p]??[""])[u])==null?void 0:i.length)??0):null;let b=null;if(x){const L=((s=(l.segments[p]??[""])[u])==null?void 0:s.length)??0,E=Ye(n.docSel,p,L+_);if(E){const B=E.start-_,N=E.end-_;N>0&&B<g.length&&(b={start:Math.max(0,B),end:Math.min(g.length,N)})}}const f=n.findMatches.filter(L=>L.row===p).map(L=>{var E,B;const N=L.col-_,V=L.col+L.len-_;if(V<=0||N>=g.length)return null;const be=n.findIdx>=0&&((E=n.findMatches[n.findIdx])==null?void 0:E.row)===L.row&&((B=n.findMatches[n.findIdx])==null?void 0:B.col)===L.col;return{start:Math.max(0,N),end:Math.min(g.length,V),isCur:be}}).filter(Boolean),C=n.wordHighlights.filter(L=>L.row===p).map(L=>{const E=L.col-_,B=L.col+L.len-_;return B<=0||E>=g.length?null:{start:Math.max(0,E),end:Math.min(g.length,B)}}).filter(Boolean),S=[];if(n.bracketMatch){for(const L of[n.bracketMatch.open,n.bracketMatch.close])if(L.row===p){const E=L.col-_;E>=0&&E<g.length&&S.push({start:E,end:E+1})}}const T=[],I=[];for(const L of n.extraCursors){const E=Y(l,L.row,L.col);if(E.visRow===r&&T.push(E.colInSeg),L.sel){const B=ms(L.sel);if(p>=B.ar&&p<=B.fr){const N=p===B.ar?B.ac-_:-_,V=p===B.fr?B.fc-_:g.length+999;V>0&&N<g.length&&I.push({start:Math.max(0,N),end:Math.min(g.length,V)})}}}const W=us(g,h.renderWhitespace),j=m||b||f.length||T.length||C.length||S.length||I.length||n.snippetStopCols.length>0;let G;if(j)G=bs(W,m?n.curColInSeg:-1,b,f,T,n.snippetStopCols,C,S,I,h.tokeniserOpts);else{const L=`${p}:${u}:${h.renderWhitespace}`;let E=n.tokenCache.get(L,W);E||(E=Se(W,h.tokeniserOpts),n.tokenCache.set(L,W,E)),G=gs(W,E)||"​"}let ge="";if(u===0&&h.showIndentGuides){const L=(g.match(/^(\s*)/)??["",""])[1].length,E=Math.floor(L/h.tabSize);for(let B=1;B<E;B++){const N=h.codePaddingLeft+B*h.tabSize*h.charWidth;ge+=`<span class="sl-ig" style="left:${N}px"></span>`}}let X="";if(u===0&&d){const L=c.has(p);X=`<span class="sl-fold-btn" data-row="${p}">${L?"▸":"▾"}</span>`}const J=c.has(p)&&u===0,Z=u===0?String(p+1):"";return`<div class="${["sl-er",h.highlightActiveLine&&v?"sl-cur-row":"",y?"sl-wrap-cont":"",J?"sl-folded":""].filter(Boolean).join(" ")}" style="height:${h.lineHeight}px" data-v="${r}" data-doc="${p}"><div class="sl-eg" style="position:relative">${X}<span class="sl-egn">${Z}</span></div><div class="sl-el"><span class="sl-cl">${ge}${G}</span></div></div>`}function us(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 s=n;return t&&(s="·".repeat(t)+s.slice(t)),i&&(s=s.slice(0,s.length-i)+"·".repeat(i)),s.replace(/\t/g,"→")}function ms(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 gs(n,e){if(!n)return"";const t=nt(n,e);let i="",s=0,o=t[0];const r=a=>{if(a<=s)return;const l=ee(n.slice(s,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&&(r(a),s=a,o=l??"")}return i}function bs(n,e,t,i,s,o,r,a,l,c){if(n.length===0){let y=e>=0?'<span class="sl-cur"></span>':"";for(const _ of s)y+='<span class="sl-cur-extra"></span>';for(const _ of o)y+='<span class="sl-snip-stop"></span>';return y||"​"}const d=Se(n,c),h=nt(n,d);let p="",u=0,g="",m="";const v=y=>{if(y<=u)return;const _=ee(n.slice(u,y)),x=[g,m].filter(Boolean).join(" ");p+=x?`<span class="${x}">${_}</span>`:_};for(let y=0;y<=n.length;y++){e===y&&(v(y),u=y,p+='<span class="sl-cur"></span>');for(const T of s)T===y&&(v(y),u=y,p+='<span class="sl-cur-extra"></span>');for(const T of o)T===y&&(v(y),u=y,p+='<span class="sl-snip-stop"></span>');if(y===n.length){v(y);break}const _=h[y],x=i.find(T=>y>=T.start&&y<T.end),b=t&&y>=t.start&&y<t.end||l.some(T=>y>=T.start&&y<T.end),f=!b&&!x&&r.some(T=>y>=T.start&&y<T.end),C=!b&&!x&&a.some(T=>y>=T.start&&y<T.end);let S="";b?S="sl-sh":x?S="sl-fh"+(x.isCur?" sl-fh-cur":""):C?S="sl-bm":f&&(S="sl-wh"),(S!==g||_!==m)&&(v(y),u=y,g=S,m=_)}return p||"​"}const Be={"(":")","{":"}","[":"]"},Ie={")":"(","}":"{","]":"["};function fs(n,e){const{row:t,col:i}=e,s=n[t]??"";let o=s[i],r=i;if(!Be[o]&&!Ie[o]&&(o=s[i-1],r=i-1),!o)return null;if(Be[o]){const a=Be[o];let l=0;for(let c=t;c<Math.min(n.length,t+500);c++){const d=n[c]??"",h=c===t?r:0;for(let p=h;p<d.length;p++)if(d[p]===o)l++;else if(d[p]===a&&(l--,l===0))return{open:{row:t,col:r},close:{row:c,col:p}}}}else if(Ie[o]){const a=Ie[o];let l=0;for(let c=t;c>=Math.max(0,t-500);c--){const d=n[c]??"",h=c===t?r:d.length-1;for(let p=h;p>=0;p--)if(d[p]===o)l++;else if(d[p]===a&&(l--,l===0))return{open:{row:c,col:p},close:{row:t,col:r}}}}return null}function xs(n,e,t,i,s=0,o=n.length-1){if(i)return[];const r=n[e]??"",a=et(r,t),l=tt(r,t),c=r.slice(a,l);if(!c||c.length<2)return[];const d=[],h=Math.min(o,n.length-1);for(let p=Math.max(0,s);p<=h;p++){const u=n[p]??"";let g=0;for(;g<=u.length-c.length;){const m=u.indexOf(c,g);if(m<0)break;const v=m===0||!/\w/.test(u[m-1]),y=m+c.length>=u.length||!/\w/.test(u[m+c.length]);v&&y&&!(p===e&&m===a)&&d.push({row:p,col:m,len:c.length}),g=m+1}}return d}const ys={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"}},vs={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"}},ws={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"}},ks={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"}},_s={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"}},Cs={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"}},Ts={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"}},Ss={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"}},Es=[ys,vs,ws,ks,_s,Cs,Ts,Ss],Ms={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 Ls{constructor(e){k(this,"_registry",new Map),k(this,"_activeId",""),k(this,"_root"),this._root=e;for(const t of Es)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,s]of Object.entries(Ms))t.setProperty(s,e[i])}}const $s=`
|
|
163
|
+
/* ── Reset ── */
|
|
164
|
+
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
165
|
+
|
|
166
|
+
/* ── Host element ── */
|
|
167
|
+
:host,.sl-host{
|
|
168
|
+
display:flex;flex-direction:column;
|
|
169
|
+
height:100%;overflow:hidden;
|
|
170
|
+
font-family:var(--sans,'Geist',system-ui,sans-serif);
|
|
171
|
+
color:var(--text,#c9c7c0);
|
|
172
|
+
background:var(--bg0,#0d0d0f);
|
|
173
|
+
|
|
174
|
+
/* Default token vars (can be overridden by theme) */
|
|
175
|
+
--sans:'Geist',system-ui,sans-serif;
|
|
176
|
+
--mono:'JetBrains Mono',monospace;
|
|
177
|
+
|
|
178
|
+
/* ── VR Dark defaults ── */
|
|
179
|
+
--bg0:#0d0d0f; --bg1:#111115; --bg2:#16161b; --bg3:#1d1d24; --bg4:#24242d;
|
|
180
|
+
--border:rgba(255,255,255,.07);
|
|
181
|
+
--border2:rgba(255,255,255,.12);
|
|
182
|
+
--border3:rgba(255,255,255,.19);
|
|
183
|
+
--text:#c9c7c0; --text2:#8b8994; --text3:#4e4c58;
|
|
184
|
+
--accent:#6e9fff; --accent2:#2f5db0;
|
|
185
|
+
--green:#4ec9a0; --orange:#d4976e; --purple:#b48eff;
|
|
186
|
+
--red:#f28b82; --yellow:#e8c97a;
|
|
187
|
+
--cur:#6e9fff; --cur-glow:rgba(110,159,255,.65);
|
|
188
|
+
--cur-line-bg:rgba(255,255,255,.032);
|
|
189
|
+
--cur-line-gutter:#181820;
|
|
190
|
+
--gutter-bg:#0f0f12; --gutter-hover:#181820;
|
|
191
|
+
--gutter-border:rgba(255,255,255,.06);
|
|
192
|
+
--gutter-num:#4e4c58; --gutter-num-act:#9997a2;
|
|
193
|
+
--sel-bg:rgba(110,159,255,.22);
|
|
194
|
+
--word-hl-bg:rgba(200,198,210,.09);
|
|
195
|
+
--word-hl-border:rgba(200,198,210,.28);
|
|
196
|
+
--bm-border:rgba(110,159,255,.65);
|
|
197
|
+
--fold-bg:rgba(110,159,255,.07);
|
|
198
|
+
--fold-border:rgba(110,159,255,.30);
|
|
199
|
+
--find-bg:rgba(234,180,86,.18);
|
|
200
|
+
--find-border:rgba(234,180,86,.50);
|
|
201
|
+
--find-cur-bg:rgba(234,180,86,.80);
|
|
202
|
+
--find-cur-border:rgba(234,180,86,.95);
|
|
203
|
+
--find-cur-text:#1a1000;
|
|
204
|
+
--file-active-bg:rgba(110,159,255,.11);
|
|
205
|
+
--file-active-text:#6e9fff;
|
|
206
|
+
--mm-bg:#0d0d0f; --mm-slider:rgba(255,255,255,.07);
|
|
207
|
+
--mm-dim:rgba(0,0,0,.30); --mm-edge:rgba(255,255,255,.18);
|
|
208
|
+
--indent-guide:rgba(255,255,255,.06);
|
|
209
|
+
--tok-kw:#6e9fff; --tok-str:#4ec9a0; --tok-cmt:#4e4c58;
|
|
210
|
+
--tok-fn:#d4976e; --tok-num:#b48eff; --tok-cls:#e8c97a;
|
|
211
|
+
--tok-op:#55536a; --tok-typ:#6ec9d4; --tok-dec:#f28b82;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* ── Layout ── */
|
|
215
|
+
.sl-layout{display:flex;flex:1;overflow:hidden}
|
|
216
|
+
.sl-ed-pane{flex:1;display:flex;flex-direction:column;overflow:hidden;position:relative;background:var(--bg2)}
|
|
217
|
+
|
|
218
|
+
/* ── Hidden textarea (input capture) ── */
|
|
219
|
+
.sl-input{position:fixed;left:-9999px;top:0;width:200px;height:40px;
|
|
220
|
+
opacity:0;resize:none;border:none;outline:none;padding:0;margin:0;
|
|
221
|
+
font-size:16px;background:transparent;color:transparent;
|
|
222
|
+
caret-color:transparent;pointer-events:none}
|
|
223
|
+
|
|
224
|
+
/* ── Editor scroll container ── */
|
|
225
|
+
.sl-editor{flex:1;overflow-y:scroll;overflow-x:auto;position:relative;
|
|
226
|
+
cursor:text;scrollbar-width:thin;scrollbar-color:var(--border3) transparent}
|
|
227
|
+
.sl-editor::-webkit-scrollbar{width:10px;height:8px}
|
|
228
|
+
.sl-editor::-webkit-scrollbar-track{background:transparent}
|
|
229
|
+
.sl-editor::-webkit-scrollbar-thumb{background:var(--border3);border-radius:5px;border:2px solid var(--bg2)}
|
|
230
|
+
.sl-spacer{position:absolute;left:0;top:0;width:1px;pointer-events:none}
|
|
231
|
+
.sl-vp{position:absolute;left:0;right:0;overflow-x:hidden;will-change:transform}
|
|
232
|
+
|
|
233
|
+
/* ── Editor row ── */
|
|
234
|
+
.sl-er{display:flex;align-items:stretch;position:relative}
|
|
235
|
+
.sl-er:hover .sl-eg{background:var(--gutter-hover)}
|
|
236
|
+
.sl-er.sl-cur-row{background:var(--cur-line-bg)}
|
|
237
|
+
.sl-er.sl-cur-row .sl-eg{background:var(--cur-line-gutter)!important}
|
|
238
|
+
.sl-eg{min-width:60px;font-family:var(--mono);font-size:11px;color:var(--gutter-num);
|
|
239
|
+
user-select:none;border-right:1px solid var(--gutter-border);
|
|
240
|
+
background:var(--gutter-bg);flex-shrink:0;position:sticky;left:0;z-index:2;
|
|
241
|
+
display:flex;flex-direction:column;justify-content:flex-start;
|
|
242
|
+
transition:background .12s,color .12s}
|
|
243
|
+
.sl-er.sl-cur-row .sl-eg{color:var(--gutter-num-act)}
|
|
244
|
+
.sl-egn{height:22px;line-height:22px;padding-right:10px;text-align:right;display:block}
|
|
245
|
+
.sl-er.sl-wrap-cont .sl-egn{visibility:hidden}
|
|
246
|
+
.sl-el{flex:1;font-family:var(--mono);font-size:13px;line-height:22px;
|
|
247
|
+
color:var(--text);position:relative;min-width:0}
|
|
248
|
+
.sl-cl{display:block;height:22px;line-height:22px;
|
|
249
|
+
padding:0 20px 0 14px;white-space:pre;position:relative}
|
|
250
|
+
.sl-wrap-mode .sl-cl{white-space:pre-wrap;word-break:break-all;height:auto;overflow-wrap:anywhere}
|
|
251
|
+
|
|
252
|
+
/* ── Cursor ── */
|
|
253
|
+
.sl-cur{display:inline;width:0;height:0;position:relative}
|
|
254
|
+
.sl-cur::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
255
|
+
background:var(--cur);border-radius:1px;
|
|
256
|
+
box-shadow:0 0 8px var(--cur-glow);
|
|
257
|
+
animation:sl-blink 1.05s step-end infinite;pointer-events:none}
|
|
258
|
+
@keyframes sl-blink{0%,100%{opacity:1}45%,55%{opacity:0}}
|
|
259
|
+
|
|
260
|
+
/* ── Multi-cursor extra beams ── */
|
|
261
|
+
.sl-cur-extra{display:inline;width:0;height:0;position:relative}
|
|
262
|
+
.sl-cur-extra::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
263
|
+
background:var(--cur);border-radius:1px;
|
|
264
|
+
box-shadow:0 0 8px var(--cur-glow);
|
|
265
|
+
animation:sl-blink 1.05s step-end infinite;pointer-events:none}
|
|
266
|
+
|
|
267
|
+
/* ── Snippet tab-stop ghost markers ── */
|
|
268
|
+
.sl-snip-stop{display:inline;width:0;height:0;position:relative}
|
|
269
|
+
.sl-snip-stop::after{content:'';position:absolute;left:0;top:2px;width:2px;height:18px;
|
|
270
|
+
background:var(--cur);border-radius:1px;opacity:0.28;pointer-events:none}
|
|
271
|
+
|
|
272
|
+
/* ── Overlays ── */
|
|
273
|
+
.sl-sh{background:var(--sel-bg);border-radius:2px}
|
|
274
|
+
.sl-fh{background:var(--find-bg);box-shadow:0 0 0 1px var(--find-border);border-radius:2px}
|
|
275
|
+
.sl-fh.sl-fh-cur{background:var(--find-cur-bg);box-shadow:0 0 0 1px var(--find-cur-border);color:var(--find-cur-text)}
|
|
276
|
+
.sl-wh{background:var(--word-hl-bg);box-shadow:0 0 0 1px var(--word-hl-border);border-radius:2px}
|
|
277
|
+
.sl-bm{box-shadow:0 0 0 1px var(--bm-border);border-radius:2px}
|
|
278
|
+
.sl-ig{position:absolute;top:0;bottom:0;width:1px;background:var(--indent-guide);pointer-events:none}
|
|
279
|
+
|
|
280
|
+
/* ── Code folding ── */
|
|
281
|
+
.sl-fold-btn{position:absolute;left:3px;top:4px;width:13px;height:13px;border-radius:3px;
|
|
282
|
+
display:flex;align-items:center;justify-content:center;font-size:9px;
|
|
283
|
+
color:var(--gutter-num);cursor:pointer;opacity:0;
|
|
284
|
+
transition:opacity .15s,background .1s;user-select:none;line-height:1}
|
|
285
|
+
.sl-er:hover .sl-fold-btn{opacity:1}
|
|
286
|
+
.sl-fold-btn:hover{background:var(--border3);color:var(--gutter-num-act)}
|
|
287
|
+
.sl-folded{background:var(--fold-bg);border-bottom:1px dashed var(--fold-border)}
|
|
288
|
+
|
|
289
|
+
/* ── Syntax tokens ── */
|
|
290
|
+
.kw{color:var(--tok-kw)}.str{color:var(--tok-str)}.cmt{color:var(--tok-cmt);font-style:italic}
|
|
291
|
+
.fn{color:var(--tok-fn)}.num{color:var(--tok-num)}.cls{color:var(--tok-cls)}
|
|
292
|
+
.op{color:var(--tok-op)}.typ{color:var(--tok-typ)}.dec{color:var(--tok-dec)}
|
|
293
|
+
|
|
294
|
+
/* ── Minimap ── */
|
|
295
|
+
.sl-minimap{background:var(--mm-bg);border-left:1px solid var(--border);
|
|
296
|
+
overflow:hidden;position:relative;flex-shrink:0;cursor:pointer;user-select:none}
|
|
297
|
+
.sl-minimap canvas{display:block;position:absolute;top:0;left:0}
|
|
298
|
+
.sl-mm-slider{position:absolute;left:0;right:0;pointer-events:none}
|
|
299
|
+
|
|
300
|
+
/* ── Status bar ── */
|
|
301
|
+
.sl-statusbar{height:26px;background:var(--accent2);display:flex;align-items:center;
|
|
302
|
+
padding:0 6px;font-size:11px;color:rgba(255,255,255,.85);flex-shrink:0;gap:0}
|
|
303
|
+
.sl-sb-item{display:flex;align-items:center;gap:4px;padding:0 8px;height:100%;
|
|
304
|
+
cursor:pointer;transition:background .1s;white-space:nowrap;border-radius:3px}
|
|
305
|
+
.sl-sb-item:hover{background:rgba(255,255,255,.15)}
|
|
306
|
+
.sl-sb-item.sl-no-click{cursor:default}
|
|
307
|
+
.sl-sb-item.sl-no-click:hover{background:transparent}
|
|
308
|
+
.sl-sb-sep{width:1px;height:14px;background:rgba(255,255,255,.22);margin:0 1px;flex-shrink:0}
|
|
309
|
+
.sl-sb-right{margin-left:auto;display:flex;align-items:center}
|
|
310
|
+
.sl-sb-wrap.sl-on{font-weight:700}
|
|
311
|
+
|
|
312
|
+
/* ── Placeholder ── */
|
|
313
|
+
.sl-placeholder{position:absolute;top:0;right:0;pointer-events:none;user-select:none;
|
|
314
|
+
color:var(--text3);white-space:pre;overflow:hidden;z-index:1}
|
|
315
|
+
|
|
316
|
+
/* ── Go to Line bar ── */
|
|
317
|
+
.sl-gtl-bar{position:absolute;top:0;left:50%;z-index:50;background:var(--bg3);
|
|
318
|
+
border:1px solid var(--border3);border-top:none;border-radius:0 0 10px 10px;
|
|
319
|
+
display:flex;align-items:center;gap:8px;padding:8px 12px;
|
|
320
|
+
transform:translateX(-50%) translateY(-100%);transition:transform .18s,box-shadow .18s;pointer-events:none}
|
|
321
|
+
.sl-gtl-bar.sl-open{transform:translateX(-50%) translateY(0);pointer-events:all;box-shadow:0 8px 28px rgba(0,0,0,.4)}
|
|
322
|
+
.sl-gtl-label{font-size:12px;color:var(--text2);white-space:nowrap}
|
|
323
|
+
.sl-gtl-input{width:72px;background:var(--bg4);border:1px solid var(--border3);
|
|
324
|
+
border-radius:5px;padding:4px 8px;font-size:12px;font-family:var(--mono);
|
|
325
|
+
color:var(--text);outline:none;transition:border-color .15s;text-align:center}
|
|
326
|
+
.sl-gtl-input:focus{border-color:var(--accent)}
|
|
327
|
+
.sl-gtl-input.sl-gtl-err{border-color:#e05252}
|
|
328
|
+
.sl-gtl-hint{font-size:11px;color:var(--text3);font-family:var(--mono);min-width:40px}
|
|
329
|
+
|
|
330
|
+
/* ── Find + Replace bar ── */
|
|
331
|
+
.sl-find-bar{position:absolute;top:0;right:125px;z-index:50;background:var(--bg3);
|
|
332
|
+
border:1px solid var(--border3);border-top:none;border-radius:0 0 10px 10px;
|
|
333
|
+
display:flex;flex-direction:column;overflow:hidden;
|
|
334
|
+
transform:translateY(-100%);transition:transform .18s,box-shadow .18s;pointer-events:none}
|
|
335
|
+
.sl-find-bar.sl-open{transform:translateY(0);pointer-events:all;box-shadow:0 8px 28px rgba(0,0,0,.4)}
|
|
336
|
+
.sl-find-row{display:flex;align-items:center;gap:6px;padding:7px 10px}
|
|
337
|
+
.sl-find-row+.sl-find-row{border-top:1px solid var(--border)}
|
|
338
|
+
.sl-find-bar input{width:180px;background:var(--bg4);border:1px solid var(--border3);
|
|
339
|
+
border-radius:5px;padding:4px 8px;font-size:12px;font-family:var(--mono);
|
|
340
|
+
color:var(--text);outline:none;transition:border-color .15s}
|
|
341
|
+
.sl-find-bar input:focus{border-color:var(--accent)}
|
|
342
|
+
.sl-find-btn{padding:3px 8px;font-size:11px;border:1px solid var(--border3);
|
|
343
|
+
border-radius:4px;background:transparent;color:var(--text2);cursor:pointer;
|
|
344
|
+
transition:background .1s;white-space:nowrap}
|
|
345
|
+
.sl-find-btn:hover{background:var(--border3);color:var(--text)}
|
|
346
|
+
.sl-find-btn.sl-active{background:var(--accent);border-color:var(--accent);color:#fff}
|
|
347
|
+
.sl-find-count{font-size:11px;color:var(--text3);font-family:var(--mono);min-width:52px}
|
|
348
|
+
.sl-find-x{font-size:14px;color:var(--text3);cursor:pointer;padding:2px 5px;
|
|
349
|
+
border-radius:3px;margin-left:2px}
|
|
350
|
+
.sl-find-x:hover{color:var(--text);background:var(--border3)}
|
|
351
|
+
|
|
352
|
+
/* ── Autocomplete popup (VS Code-style with optional description panel) ── */
|
|
353
|
+
.sl-ac-popup{position:fixed;z-index:400;background:var(--bg3);
|
|
354
|
+
border:1px solid var(--border3);border-radius:8px;overflow:hidden;
|
|
355
|
+
box-shadow:0 12px 40px rgba(0,0,0,.55);
|
|
356
|
+
display:flex;flex-direction:row;
|
|
357
|
+
animation:sl-acIn .1s ease;pointer-events:all}
|
|
358
|
+
@keyframes sl-acIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
|
|
359
|
+
/* Left: item list */
|
|
360
|
+
.sl-ac-list{min-width:240px;max-width:300px;max-height:320px;overflow-y:auto;flex-shrink:0}
|
|
361
|
+
.sl-ac-list::-webkit-scrollbar{width:4px}
|
|
362
|
+
.sl-ac-list::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
363
|
+
.sl-ac-item{display:flex;align-items:center;gap:8px;padding:4px 10px;font-size:12px;
|
|
364
|
+
font-family:var(--mono);cursor:pointer;color:var(--text2);transition:background .07s;
|
|
365
|
+
white-space:nowrap}
|
|
366
|
+
.sl-ac-item:hover,.sl-ac-item.sl-sel{background:var(--bg4);color:var(--text)}
|
|
367
|
+
.sl-ac-badge{width:18px;height:18px;border-radius:4px;display:flex;align-items:center;
|
|
368
|
+
justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;font-family:var(--sans)}
|
|
369
|
+
.sl-ac-badge.kw{background:rgba(110,159,255,.18);color:var(--tok-kw)}
|
|
370
|
+
.sl-ac-badge.fn{background:rgba(212,151,110,.18);color:var(--tok-fn)}
|
|
371
|
+
.sl-ac-badge.typ{background:rgba(110,201,212,.18);color:var(--tok-typ)}
|
|
372
|
+
.sl-ac-badge.cls{background:rgba(232,201,122,.18);color:var(--tok-cls)}
|
|
373
|
+
.sl-ac-badge.var{background:rgba(78,201,160,.18);color:var(--tok-str)}
|
|
374
|
+
.sl-ac-badge.snip{background:rgba(155,100,255,.18);color:#a78bfa}
|
|
375
|
+
.sl-ac-badge.emmet{background:rgba(255,140,0,.18);color:#fb923c}
|
|
376
|
+
.sl-ac-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
377
|
+
.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}
|
|
378
|
+
/* Right: description / docs panel */
|
|
379
|
+
.sl-ac-desc{width:260px;max-height:320px;overflow-y:auto;
|
|
380
|
+
border-left:1px solid var(--border3);padding:10px 12px;flex-shrink:0}
|
|
381
|
+
.sl-ac-desc::-webkit-scrollbar{width:4px}
|
|
382
|
+
.sl-ac-desc::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
383
|
+
.sl-ac-desc-body{margin:0;font-size:11.5px;font-family:var(--mono);
|
|
384
|
+
color:var(--text2);line-height:1.6;white-space:pre-wrap;word-break:break-word}
|
|
385
|
+
|
|
386
|
+
/* ── Hover documentation tooltip ── */
|
|
387
|
+
.sl-hover-tip{position:fixed;z-index:500;background:var(--bg3);
|
|
388
|
+
border:1px solid var(--border3);border-radius:8px;
|
|
389
|
+
box-shadow:0 8px 32px rgba(0,0,0,.55);
|
|
390
|
+
max-width:380px;min-width:180px;padding:10px 14px;
|
|
391
|
+
pointer-events:all;cursor:default;
|
|
392
|
+
animation:sl-hoverIn .12s ease}
|
|
393
|
+
@keyframes sl-hoverIn{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
|
|
394
|
+
.sl-ht-sig{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;margin-bottom:5px}
|
|
395
|
+
.sl-ht-title{font-size:12.5px;font-family:var(--mono);font-weight:600;color:var(--tok-fn)}
|
|
396
|
+
.sl-ht-type{font-size:11px;font-family:var(--mono);color:var(--tok-typ);opacity:.9;word-break:break-all}
|
|
397
|
+
.sl-ht-body{font-size:12px;font-family:var(--sans);color:var(--text2);line-height:1.55;
|
|
398
|
+
max-height:120px;overflow-y:auto}
|
|
399
|
+
.sl-ht-body::-webkit-scrollbar{width:3px}
|
|
400
|
+
.sl-ht-body::-webkit-scrollbar-thumb{background:var(--border3);border-radius:2px}
|
|
401
|
+
.sl-hover-tip .sl-ht-divider{height:1px;background:var(--border);margin:6px 0}
|
|
402
|
+
|
|
403
|
+
/* ── Emmet tooltip ── */
|
|
404
|
+
.sl-emmet-tip{position:fixed;z-index:600;background:var(--bg3);
|
|
405
|
+
border:1px solid var(--border3);border-radius:6px;padding:4px 10px;
|
|
406
|
+
font-size:11px;font-family:var(--mono);color:var(--accent);
|
|
407
|
+
pointer-events:none;box-shadow:0 4px 16px rgba(0,0,0,.45);
|
|
408
|
+
white-space:nowrap;max-width:400px;overflow:hidden;text-overflow:ellipsis}
|
|
409
|
+
|
|
410
|
+
/* ── Theme picker ── */
|
|
411
|
+
.sl-theme-overlay{position:fixed;inset:0;z-index:700;
|
|
412
|
+
background:rgba(0,0,0,.50);backdrop-filter:blur(2px)}
|
|
413
|
+
.sl-theme-panel{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
|
|
414
|
+
z-index:701;background:var(--bg2);border:1px solid var(--border3);
|
|
415
|
+
border-radius:14px;overflow:hidden;width:420px;
|
|
416
|
+
box-shadow:0 32px 80px rgba(0,0,0,.65),0 0 0 1px var(--border2)}
|
|
417
|
+
.sl-theme-header{padding:16px 20px 12px;display:flex;align-items:center;
|
|
418
|
+
justify-content:space-between;border-bottom:1px solid var(--border)}
|
|
419
|
+
.sl-theme-title{font-size:13px;font-weight:600;color:var(--text);letter-spacing:.01em}
|
|
420
|
+
.sl-theme-close{width:24px;height:24px;border-radius:6px;display:flex;align-items:center;
|
|
421
|
+
justify-content:center;font-size:14px;color:var(--text3);cursor:pointer;
|
|
422
|
+
transition:background .1s,color .1s}
|
|
423
|
+
.sl-theme-close:hover{background:var(--border3);color:var(--text)}
|
|
424
|
+
.sl-theme-list{padding:8px 8px 10px}
|
|
425
|
+
.sl-theme-item{display:flex;align-items:center;gap:14px;padding:10px 12px;
|
|
426
|
+
border-radius:9px;cursor:pointer;transition:background .1s;
|
|
427
|
+
border:1px solid transparent;margin-bottom:2px}
|
|
428
|
+
.sl-theme-item:hover{background:var(--bg4)}
|
|
429
|
+
.sl-theme-item.sl-active{background:var(--bg4);border-color:var(--border3)}
|
|
430
|
+
.sl-theme-check{width:18px;height:18px;margin-left:auto;color:var(--accent);
|
|
431
|
+
font-size:13px;font-weight:700;flex-shrink:0;opacity:0}
|
|
432
|
+
.sl-theme-item.sl-active .sl-theme-check{opacity:1}
|
|
433
|
+
.sl-theme-swatch{width:46px;height:30px;border-radius:7px;flex-shrink:0;
|
|
434
|
+
overflow:hidden;border:1px solid rgba(0,0,0,.15);
|
|
435
|
+
display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr}
|
|
436
|
+
.sl-theme-swatch span{display:block}
|
|
437
|
+
.sl-theme-name{font-size:13px;color:var(--text);font-weight:500;line-height:1.3}
|
|
438
|
+
.sl-theme-desc{font-size:11px;color:var(--text3);margin-top:2px}
|
|
439
|
+
.sl-theme-tag{display:inline-block;font-size:9px;font-weight:600;letter-spacing:.08em;
|
|
440
|
+
text-transform:uppercase;padding:1px 5px;border-radius:3px;margin-left:6px;
|
|
441
|
+
background:var(--border3);color:var(--text3);vertical-align:middle}
|
|
442
|
+
.sl-theme-tag.sl-light{background:rgba(255,200,50,.15);color:#b58900}
|
|
443
|
+
|
|
444
|
+
/* ── Empty state ── */
|
|
445
|
+
.sl-empty{flex:1;display:flex;flex-direction:column;align-items:center;
|
|
446
|
+
justify-content:center;gap:10px;color:var(--text3);font-size:13px}
|
|
447
|
+
`,As={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 Bs(n,e,t,i){const s=Number(n);return Number.isFinite(s)?Math.max(e,Math.min(t,Math.round(s))):i}function ct(n){const e={...n};for(const[t,i]of Object.entries(As))if(t in n&&n[t]!==void 0){const[s,o,r]=i;e[t]=Bs(n[t],s,o,r)}return e}const Is={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:100,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,placeholder:"",goToLine:!1};class Rs{constructor(e,t={}){k(this,"_host"),k(this,"_shadow"),k(this,"_editorEl"),k(this,"_spacerEl"),k(this,"_vpEl"),k(this,"_inputEl"),k(this,"_minimapWrap"),k(this,"_mmCanvas"),k(this,"_mmSlider"),k(this,"_statusBar"),k(this,"_findBar"),k(this,"_findInput"),k(this,"_replaceInput"),k(this,"_findCount"),k(this,"_replaceRow"),k(this,"_acPopup"),k(this,"_emmetTip"),k(this,"_snippetTip"),k(this,"_hoverTip"),k(this,"_themeOverlay"),k(this,"_themePanel"),k(this,"_placeholderEl"),k(this,"_goToLineBar"),k(this,"_goToLineInput"),k(this,"_goToLineHint"),k(this,"_config"),k(this,"_tab",Ke(1,[""])),k(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0],totalVisualRows:1,windowVisStart:0}),k(this,"_foldedLines",new Map),k(this,"_tokenCache",new Wi),k(this,"_themeManager"),k(this,"_findMatches",[]),k(this,"_findIdx",-1),k(this,"_findCaseSensitive",!1),k(this,"_findRegex",!1),k(this,"_wordHighlights",[]),k(this,"_bracketMatch",null),k(this,"_acItems",[]),k(this,"_acSel",0),k(this,"_acPrefix",""),k(this,"_acStartCol",0),k(this,"_emmetAcStartCol",0),k(this,"_mc",ji()),k(this,"_extraCursors",[]),k(this,"_isDragging",!1),k(this,"_dragAnchor",null),k(this,"_hoverTimer",null),k(this,"_hoverPinned",!1),k(this,"_mmDragMode","none"),k(this,"_mmDragStartY",0),k(this,"_mmDragStartScroll",0),k(this,"_mmSliderOffset",0),k(this,"_mmColors"),k(this,"_lastInputTime",0),k(this,"_linewiseCopy",!1),k(this,"_dynamicStyleEl"),k(this,"_emmetExpanded",null),k(this,"_snippetExpanded",null),k(this,"_snippetSession",null),k(this,"_acDebounceTimer",null),k(this,"_rafId",null),k(this,"_renderedRowCount",0),k(this,"_lastRenderScroll",-1),k(this,"_onWinMouseUp"),k(this,"_onWinResize"),k(this,"_onEditorScroll"),k(this,"_onWinMmMouseMove"),k(this,"_onWinMmMouseUp"),k(this,"_ro",null),this._config={...Is,...ct(t)},this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null},this._onEditorScroll=Ce(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=Ce(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=a=>{if(this._mmDragMode==="none")return;const l=this._minimapWrap.clientHeight,c=this._tab.doc.length,d=this._config.lineHeight;if(this._mmDragMode==="slider"){const h=a.clientY-this._minimapWrap.getBoundingClientRect().top,p=zi(h-this._mmSliderOffset,c,this._editorEl.clientHeight,l,d);this._editorEl.scrollTop=this._domScroll(p)}else{const h=a.clientY-this._mmDragStartY,p=this._logicalScroll(this._mmDragStartScroll),u=Math.max(0,c*d-this._editorEl.clientHeight),g=Math.max(0,Math.min(u,p+h/2*d));this._editorEl.scrollTop=this._domScroll(g)}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=H("style");i.textContent=$s,this._shadow.appendChild(i),this._dynamicStyleEl=H("style"),this._shadow.appendChild(this._dynamicStyleEl),this._themeManager=new Ls(this._host),this._themeManager.apply(this._config.theme);const s=H("div","sl-layout"),o=H("div","sl-ed-pane");this._inputEl=H("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=H("div","sl-editor"),this._spacerEl=H("div","sl-spacer"),this._vpEl=H("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"),this._goToLineBar=this._buildGoToLineBar(),this._goToLineInput=this._goToLineBar.querySelector(".sl-gtl-input"),this._goToLineHint=this._goToLineBar.querySelector(".sl-gtl-hint"),this._placeholderEl=H("div","sl-placeholder"),this._placeholderEl.textContent=this._config.placeholder,this._placeholderEl.style.display="none",o.appendChild(this._inputEl),o.appendChild(this._findBar),o.appendChild(this._goToLineBar),o.appendChild(this._placeholderEl),o.appendChild(this._editorEl),this._minimapWrap=H("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._mmCanvas=H("canvas",""),this._mmSlider=H("div","sl-mm-slider"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),s.appendChild(o),this._config.showMinimap&&s.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=H("div","sl-ac-popup"),this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.style.display="none",this._emmetTip=H("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=H("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=H("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=H("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=H("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(s),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 r=typeof this._config.value=="string"?Ze(this._config.value):this._config.value;this._tab=Ke(1,r.length?r:[""]),this._mmColors=Me(a=>ae(a,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(Ce(()=>{this._config.wordWrap&&(this._rebuildWrapMap(),this._scheduleRender())},60)),this._ro.observe(this._host)),this._rebuildWrapMap(),this._render()}_logicalScroll(e){const t=this._tab.doc.length*this._config.lineHeight;if(t<=15e6)return e;const i=this._editorEl.clientHeight,s=15e6-i,o=t-i;return s<=0?0:e/s*o}_domScroll(e){const t=this._tab.doc.length*this._config.lineHeight;if(t<=15e6)return e;const i=this._editorEl.clientHeight,s=15e6-i,o=t-i;return o<=0?0:e/o*s}_buildFindBar(){const e=H("div","sl-find-bar");return e.innerHTML=`
|
|
448
|
+
<div class="sl-find-row">
|
|
449
|
+
<input class="sl-find-input" placeholder="Find…" autocomplete="off" spellcheck="false">
|
|
450
|
+
<span class="sl-find-count">–</span>
|
|
451
|
+
<button class="sl-find-btn sl-find-prev" title="Previous">↑</button>
|
|
452
|
+
<button class="sl-find-btn sl-find-next" title="Next">↓</button>
|
|
453
|
+
<button class="sl-find-btn sl-find-case" title="Match case">Aa</button>
|
|
454
|
+
<button class="sl-find-btn sl-find-regex" title="Regex">.*</button>
|
|
455
|
+
<span class="sl-find-x sl-find-close">✕</span>
|
|
456
|
+
</div>
|
|
457
|
+
<div class="sl-find-row sl-replace-row" style="display:none">
|
|
458
|
+
<input class="sl-find-replace-input" placeholder="Replace…" autocomplete="off" spellcheck="false">
|
|
459
|
+
<button class="sl-find-btn sl-replace-one">Replace</button>
|
|
460
|
+
<button class="sl-find-btn sl-replace-all">All</button>
|
|
461
|
+
</div>
|
|
462
|
+
`,e}_buildGoToLineBar(){const e=H("div","sl-gtl-bar");e.innerHTML=`
|
|
463
|
+
<span class="sl-gtl-label">Go to line</span>
|
|
464
|
+
<input class="sl-gtl-input" type="text" inputmode="numeric" autocomplete="off" spellcheck="false" placeholder="…">
|
|
465
|
+
<span class="sl-gtl-hint"></span>
|
|
466
|
+
<span class="sl-find-x sl-gtl-close" title="Close">✕</span>
|
|
467
|
+
`;const t=e.querySelector(".sl-gtl-input"),i=e.querySelector(".sl-gtl-hint");return t.addEventListener("input",()=>{const s=parseInt(t.value,10),o=!isNaN(s)&&s>=1&&s<=this._tab.doc.length;t.classList.toggle("sl-gtl-err",t.value!==""&&!o),i.textContent=`(1–${this._tab.doc.length})`}),t.addEventListener("keydown",s=>{var o,r;if(s.key==="Enter"){s.preventDefault();const a=parseInt(t.value,10);!isNaN(a)&&a>=1&&a<=this._tab.doc.length&&(this._tab.cur.row=a-1,this._tab.cur.col=Math.min(this._tab.cur.col,(this._tab.doc[a-1]??"").length),A(this._tab),this._tab.sel=null,this._closeGoToLine(),this._scrollIntoView(),this._render(),(r=(o=this._config).onCursorChange)==null||r.call(o,{...this._tab.cur}))}else s.key==="Escape"&&(s.preventDefault(),this._closeGoToLine());s.stopPropagation()}),e.querySelector(".sl-gtl-close").addEventListener("click",()=>this._closeGoToLine()),e}_openGoToLine(){if(this._goToLineBar.classList.contains("sl-open")){this._closeGoToLine();return}this._goToLineHint.textContent=`(1–${this._tab.doc.length})`,this._goToLineInput.value=String(this._tab.cur.row+1),this._goToLineInput.classList.remove("sl-gtl-err"),this._goToLineBar.classList.add("sl-open"),this._goToLineInput.focus(),this._goToLineInput.select()}_closeGoToLine(){this._goToLineBar.classList.remove("sl-open"),this._focusInput()}_focusInput(){this._inputEl.style.pointerEvents="auto",this._inputEl.focus(),this._inputEl.style.pointerEvents="none"}_buildStatusBar(){const e=H("div","sl-statusbar");return e.innerHTML=`
|
|
468
|
+
<div class="sl-sb-item sl-no-click sl-sb-lang">⬡ TypeScript</div>
|
|
469
|
+
<div class="sl-sb-sep"></div>
|
|
470
|
+
<div class="sl-sb-item sl-no-click sl-sb-pos">Ln 1, Col 1</div>
|
|
471
|
+
<div class="sl-sb-sep"></div>
|
|
472
|
+
<div class="sl-sb-item sl-no-click sl-sb-sel"></div>
|
|
473
|
+
<div class="sl-sb-sep sl-sb-sel-sep" style="display:none"></div>
|
|
474
|
+
<div class="sl-sb-item sl-no-click sl-sb-lines">1 line</div>
|
|
475
|
+
<div class="sl-sb-sep"></div>
|
|
476
|
+
<div class="sl-sb-item sl-no-click">UTF-8 LF</div>
|
|
477
|
+
<div class="sl-sb-right">
|
|
478
|
+
<div class="sl-sb-item sl-no-click sl-sb-mc" style="display:none">⊕ <span class="sl-sb-mc-count">1</span> cursors</div>
|
|
479
|
+
<div class="sl-sb-item sl-no-click sl-sb-dom">0 DOM rows</div>
|
|
480
|
+
<div class="sl-sb-sep"></div>
|
|
481
|
+
<div class="sl-sb-item sl-sb-wrap sl-sb-wrap-btn">⇥ Wrap: OFF</div>
|
|
482
|
+
<div class="sl-sb-sep"></div>
|
|
483
|
+
<div class="sl-sb-item sl-sb-theme-btn">🎨 Theme</div>
|
|
484
|
+
<div class="sl-sb-sep"></div>
|
|
485
|
+
<div class="sl-sb-item sl-no-click sl-sb-undo">↩0 ↪0</div>
|
|
486
|
+
</div>
|
|
487
|
+
`,e.querySelector(".sl-sb-wrap-btn").addEventListener("click",()=>this._toggleWrap()),e.querySelector(".sl-sb-theme-btn").addEventListener("click",()=>this._openThemePicker()),e}_destroyBase(){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")}}class Ps extends Rs{_applyDynamicStyles(){const{fontFamily:e,fontSize:t,lineHeight:i,cursorBlinkRate:s,cursorStyle:o,gutterWidth:r,minimapWidth:a,showGutter:l}=this._config,c=Math.max(2,i-4),d=Math.floor((i-c)/2);let h="";o==="block"?h=`width:${7.82}px;opacity:.5;border-radius:1px;`:o==="underline"&&(h=`width:${7.82}px;height:2px;top:${i-2}px;border-radius:0;`);const p=l?r:0;this._dynamicStyleEl.textContent=`
|
|
488
|
+
.sl-el{font-family:${e};font-size:${t}px;line-height:${i}px}
|
|
489
|
+
.sl-cl{height:${i}px;line-height:${i}px}
|
|
490
|
+
.sl-egn{height:${i}px;line-height:${i}px}
|
|
491
|
+
.sl-eg{min-width:${p}px;width:${p}px;${l?"":"display:none"}}
|
|
492
|
+
.sl-cur::after{height:${c}px;top:${d}px;animation-duration:${s}ms;${h}}
|
|
493
|
+
.sl-cur-extra::after{height:${c}px;top:${d}px;animation-duration:${s}ms;${h}}
|
|
494
|
+
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${a}px`,this._placeholderEl.style.left=`${p+14}px`,this._placeholderEl.style.fontFamily=e,this._placeholderEl.style.fontSize=`${t}px`,this._placeholderEl.style.lineHeight=`${i}px`}_applyTokenOverrides(){const e=this._config.tokenColors??{},t=this._themeManager.activeTheme,i=this._host.style,s=(r,a,l)=>{i.setProperty(r,a||l)},o=t==null?void 0:t.tokens;s("--tok-kw",e.keyword,(o==null?void 0:o.tokKw)??""),s("--tok-str",e.string,(o==null?void 0:o.tokStr)??""),s("--tok-cmt",e.comment,(o==null?void 0:o.tokCmt)??""),s("--tok-fn",e.function,(o==null?void 0:o.tokFn)??""),s("--tok-num",e.number,(o==null?void 0:o.tokNum)??""),s("--tok-cls",e.class,(o==null?void 0:o.tokCls)??""),s("--tok-op",e.operator,(o==null?void 0:o.tokOp)??""),s("--tok-typ",e.type,(o==null?void 0:o.tokTyp)??""),s("--tok-dec",e.decorator,(o==null?void 0:o.tokDec)??"")}_refreshMinimapColors(){this._mmColors=Me(e=>ae(e,this._host))}}const te=1e4,le=6*4;class Hs extends Ps{constructor(){super(...arguments),k(this,"_onFoldBtnClick",e=>{const t=e.target.closest(".sl-fold-btn");if(!t)return;e.preventDefault(),e.stopPropagation();const i=parseInt(t.dataset.row??"0",10);if(this._foldedLines=hs(this._foldedLines,this._tab.doc,i),this._foldedLines.has(i)){const s=this._foldedLines.get(i),o=this._tab.cur;o.row>i&&o.row<=s&&(this._tab.cur={row:i,col:(this._tab.doc[i]??"").length},this._tab.sel=null)}this._rebuildWrapMap(),this._render()})}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._render()}))}_render(){const{doc:e,cur:t,sel:i}=this._tab,{lineHeight:s}=this._config,o=e.length,r=o*s,a=Math.min(r,15e6);this._spacerEl.style.height=`${a}px`;const l=this._editorEl.scrollTop,c=this._logicalScroll(l);o>te&&l!==this._lastRenderScroll&&(this._lastRenderScroll=l,this._rebuildWrapMap());const d=this._wm.totalVisualRows,h=this._editorEl.clientHeight,p=Math.max(0,Math.floor(c/s)-6),u=Math.min(d-1,Math.ceil((c+h)/s)+6),g=o>te?p:0,m=o>te?u:o-1;if(this._wordHighlights=this._config.wordHighlight?xs(e,t.row,t.col,i,g,m):[],this._bracketMatch=this._config.bracketMatching?fs(e,t):null,this._config.wordWrap)this._spacerEl.style.width="",this._vpEl.style.width="";else{const b=o>te?this._wm.visualRows.reduce((S,T)=>Math.max(S,(e[T.docLine]??"").length),0):e.reduce((S,T)=>Math.max(S,T.length),0),f=this._config.showGutter?this._config.gutterWidth:0,C=Math.max(this._editorEl.clientWidth,f+14+Math.ceil(b*7.82)+20+64);this._spacerEl.style.width=`${C}px`,this._vpEl.style.width=`${C}px`}this._vpEl.style.transform=`translateY(${l+(p*s-c)}px)`;const v=Y(this._wm,t.row,t.col),y=new Map;if(this._snippetSession)for(let b=this._snippetSession.idx+1;b<this._snippetSession.stops.length;b++){const f=this._snippetSession.stops[b],C=Y(this._wm,f.row,f.col),S=y.get(C.visRow)??[];S.push(C.colInSeg),y.set(C.visRow,S)}const _=this._wm.windowVisStart;let x="";for(let b=p;b<=u;b++){const f=this._wm.visualRows[b-_];f&&(x+=ps({vr:f,visIdx:b,curVisRow:v.visRow,curColInSeg:v.colInSeg,docSel:i,findMatches:this._findMatches,findIdx:this._findIdx,wordHighlights:this._wordHighlights,bracketMatch:this._bracketMatch,extraCursors:this._extraCursors,snippetStopCols:y.get(b)??[],foldedLines:this._foldedLines,isFoldable:this._config.codeFolding&&ds(e,f.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),provideTokens:this._config.provideTokens},showIndentGuides:this._config.showIndentGuides,highlightActiveLine:this._config.highlightActiveLine,charWidth:7.82,codePaddingLeft:14,tabSize:this._config.tabSize,lineHeight:s,renderWhitespace:this._config.renderWhitespace}}))}if(this._renderedRowCount=Math.max(0,u-p+1),this._vpEl.innerHTML=x,this._updateStatusBar(),this._updateMinimap(),this._config.placeholder){const b=this._tab.doc.length===1&&this._tab.doc[0]==="";this._placeholderEl.style.display=b?"":"none"}else this._placeholderEl.style.display="none"}_updateStatusBar(){if(!this._config.showStatusBar)return;const{cur:e,doc:t,undoStack:i,redoStack:s}=this._tab,o=this._config.language,r={typescript:"TypeScript",javascript:"JavaScript",css:"CSS",json:"JSON",markdown:"Markdown",text:"Text"},a=p=>this._statusBar.querySelector(p);a(".sl-sb-lang").textContent=`⬡ ${r[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=Pi(this._tab),c=a(".sl-sb-sel"),d=a(".sl-sb-sel-sep");c.textContent=l?`${l.toLocaleString()} selected`:"",d.style.display=l?"":"none",a(".sl-sb-undo").textContent=`↩${i.length} ↪${s.length}`;const h=a(".sl-sb-mc");this._extraCursors.length?(h.style.display="",a(".sl-sb-mc-count").textContent=String(this._extraCursors.length+1)):h.style.display="none",a(".sl-sb-dom").textContent=`${this._renderedRowCount} DOM rows`}_updateMinimap(){if(!this._config.showMinimap)return;const e=this._minimapWrap.clientWidth,t=this._minimapWrap.clientHeight;if(!e||!t)return;const i=this._tab.doc,s=i.length,o=Math.min(window.devicePixelRatio||1,2),r=this._config.lineHeight,{mmScroll:a,sliderTop:l,sliderHeight:c}=Ee(s,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,t,r),d=a/2,h=Math.floor(d),p=Math.ceil(t/2)+2,u=Math.min(s,h+p),g=(u-h)*2,m=(d-h)*2,v=Math.round(e*o),y=Math.round(g*o);(this._mmCanvas.width!==v||this._mmCanvas.height!==y)&&(this._mmCanvas.width=v,this._mmCanvas.height=y,this._mmCanvas.style.width=`${e}px`,this._mmCanvas.style.height=`${g}px`),this._mmCanvas.style.transform=`translateY(${-m}px)`,Gi({canvas:this._mmCanvas,doc:i,firstLine:h,lastLine:u,subPx:m,wrapperWidth:e,canvasHeight:g,cursorRow:this._tab.cur.row,sel:this._tab.sel,findMatches:this._findMatches,findIdx:this._findIdx,sliderTop:l,sliderHeight:c,colors:this._mmColors,getCssVar:_=>ae(_,this._host),dpr:o,tokenCache:this._tokenCache,language:this._config.language,provideTokens:this._config.provideTokens}),this._mmSlider.style.top=`${Math.max(0,Math.min(t-c,l))}px`,this._mmSlider.style.height=`${c}px`}_rebuildWrapMap(){let e;if(this._config.wordWrap){const i=this._config.showGutter?this._config.gutterWidth:0,s=this._editorEl.clientWidth;if(s>0){const o=s-i-14-20;e=Math.max(20,Math.floor(o/7.82))}else e=this._config.wrapColumn}else e=9999;const t=this._tab.doc.length;if(t>te){const i=this._config.lineHeight,s=this._editorEl.scrollTop,o=this._logicalScroll(s),r=this._editorEl.clientHeight,a=this._tab.cur.row,l=Math.max(0,Math.floor(o/i)-le),c=Math.min(t-1,Math.ceil((o+r)/i)+le),d=this._config.wordWrap||this._foldedLines.size>0,h=d?Math.max(0,Math.min(l,a-le)):l,p=d?Math.min(t-1,Math.max(c,a+le)):c;this._wm=Je(this._tab.doc,e,this._config.wordWrap,this._foldedLines,h,p)}else this._wm=Je(this._tab.doc,e,this._config.wordWrap,this._foldedLines)}_scrollIntoView(){const e=this._tab.cur,t=this._config.lineHeight,i=this._tab.doc.length*t,s=Math.min(i,15e6);this._spacerEl.style.height=`${s}px`;const o=Y(this._wm,e.row,e.col).visRow*t,r=o+t,a=this._domScroll(o),l=this._domScroll(r),c=this._editorEl.scrollTop,d=this._editorEl.clientHeight,h=t*3;a<c+h?this._editorEl.scrollTop=Math.max(0,a-h):l>c+d-h&&(this._editorEl.scrollTop=l-d+h)}}class Ds extends Hs{_insertStr(e,t){var i,s;const o=Date.now(),r=!t||o-this._lastInputTime>this._config.undoBatchMs;this._lastInputTime=o;const a={...this._tab.cur},l=this._tab.sel?{...this._tab.sel}:null;let c,d;if(this._tab.sel){const y=P(this._tab.sel);c=y.ar,d=this._tab.doc.slice(y.ar,y.fr+1),this._tab.cur=F(this._tab)}else c=this._tab.cur.row,d=[this._tab.doc[c]??""];const{doc:h,cur:p}=this._tab,u=e.split(`
|
|
495
|
+
`),g=h[p.row]??"",m=g.slice(0,p.col),v=g.slice(p.col);if(u.length===1)h[p.row]=m+e+v,p.col+=e.length;else{const y=[m+u[0]];for(let _=1;_<u.length-1;_++)y.push(u[_]);y.push(u[u.length-1]+v),h.splice(p.row,1,...y),p.row+=u.length-1,p.col=u[u.length-1].length}if(r){const y=h.slice(c,p.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c,oldLines:d,newLines:y},a,l)}this._tokenCache.invalidateLine(p.row,(this._wm.segments[p.row]??[""]).length),this._tab.dirty=!0,(s=(i=this._config).onChange)==null||s.call(i,R(h))}_doBackspace(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const r=P(this._tab.sel),a=this._tab.doc.slice(r.ar,r.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const l=[this._tab.doc[r.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r.ar,oldLines:a,newLines:l},t,i);return}const{doc:s,cur:o}=this._tab;if(o.col>0){const r=s[o.row]??"",a=r.slice(0,o.col),l=a.length>=2&&a.endsWith(" ")&&!a.trim()?2:1;s[o.row]=r.slice(0,o.col-l)+r.slice(o.col),o.col-=l,this._tokenCache.invalidateLine(o.row,((e=this._wm.segments[o.row])==null?void 0:e.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[r],newLines:[s[o.row]]},t,i)}else if(o.row>0){const r=s[o.row-1]??"",a=s[o.row]??"",l=r.length;s[o.row-1]=r+a,s.splice(o.row,1),o.row--,o.col=l,this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[r,a],newLines:[s[o.row]]},t,i)}else return;this._tab.dirty=!0}_doEnter(){const e={...this._tab.cur},t=this._tab.sel?{...this._tab.sel}:null;let i,s;if(this._tab.sel){const u=P(this._tab.sel);i=u.ar,s=this._tab.doc.slice(u.ar,u.fr+1),this._tab.cur=F(this._tab)}else i=this._tab.cur.row,s=[this._tab.doc[i]??""];const{doc:o,cur:r}=this._tab,a=o[r.row]??"",l=a.slice(0,r.col),c=a.slice(r.col),d=oe(a),h=l.trimEnd().endsWith("{")?re(this._config.tabSize):"";o[r.row]=l,l.trimEnd().endsWith("{")&&c.trimStart()==="}"?o.splice(r.row+1,0,d+h,d+c):o.splice(r.row+1,0,d+h+c),r.row++,r.col=d.length+h.length,this._tokenCache.clear();const p=o.slice(i,r.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:i,oldLines:s,newLines:p},e,t),this._tab.dirty=!0}_doDelete(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const a=P(this._tab.sel),l=this._tab.doc.slice(a.ar,a.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const c=[this._tab.doc[a.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.ar,oldLines:l,newLines:c},t,i);return}const{doc:s,cur:o}=this._tab,r=s[o.row]??"";if(o.col<r.length){const a=r;s[o.row]=r.slice(0,o.col)+r.slice(o.col+1),this._tokenCache.invalidateLine(o.row,((e=this._wm.segments[o.row])==null?void 0:e.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[a],newLines:[s[o.row]]},t,i)}else if(o.row<s.length-1){const a=r,l=s[o.row+1]??"";s[o.row]=a+l,s.splice(o.row+1,1),this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[a,l],newLines:[s[o.row]]},t,i)}else return;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,t;const i=Xe(this._tab);if(i)this._linewiseCopy=!1,(e=navigator.clipboard)==null||e.writeText(i).catch(()=>{});else{this._linewiseCopy=!0;const s=(this._tab.doc[this._tab.cur.row]??"")+`
|
|
496
|
+
`;(t=navigator.clipboard)==null||t.writeText(s).catch(()=>{})}}_doCut(){var e,t,i,s,o,r;const a=Xe(this._tab);if(a){this._linewiseCopy=!1,(e=navigator.clipboard)==null||e.writeText(a).catch(()=>{});const l={...this._tab.cur},c=this._tab.sel?{...this._tab.sel}:null,d=P(this._tab.sel),h=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const p=[this._tab.doc[d.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:h,newLines:p},l,c),this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,R(this._tab.doc))}else{this._linewiseCopy=!0;const{doc:l,cur:c}=this._tab,d={...c},h=l[c.row]??"";(s=navigator.clipboard)==null||s.writeText(h+`
|
|
497
|
+
`).catch(()=>{}),l.length>1?(l.splice(c.row,1),A(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"delete",row:d.row,count:1,removed:[h]},d,null)):(l[0]="",c.col=0,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[h],newLines:[""]},d,null)),this._rebuildWrapMap(),A(this._tab),this._render(),(r=(o=this._config).onChange)==null||r.call(o,R(this._tab.doc))}}_doInsertLineBelow(){var e,t,i,s;const o={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,l=oe(this._tab.doc[a]??"");this._tab.doc.splice(a+1,0,l),this._tab.cur.row=a+1,this._tab.cur.col=l.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:a+1,lines:[l]},o,r),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc)),(s=(i=this._config).onCursorChange)==null||s.call(i,{...this._tab.cur})}_doInsertLineAbove(){var e,t,i,s;const o={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,l=oe(this._tab.doc[a]??"");this._tab.doc.splice(a,0,l),this._tab.cur.row=a,this._tab.cur.col=l.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:a,lines:[l]},o,r),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc)),(s=(i=this._config).onCursorChange)==null||s.call(i,{...this._tab.cur})}_toggleComment(){var e,t;const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._getSelRows(),r=o[0],a=o[o.length-1],l=this._tab.doc.slice(r,a+1),c=this._config.lineCommentToken||Ci[this._config.language]||"";if(!c)return;const d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=o.every(u=>(this._tab.doc[u]??"").trimStart().startsWith(c));o.forEach(u=>{var g;const m=this._tab.doc[u]??"";this._tab.doc[u]=h?m.replace(new RegExp(`^(\\s*)${d}\\s?`),"$1"):m.replace(/^(\s*)/,`$1${c} `),this._tokenCache.invalidateLine(u,((g=this._wm.segments[u])==null?void 0:g.length)??1)}),this._tab.dirty=!0;const p=this._tab.doc.slice(r,a+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r,oldLines:l,newLines:p},i,s),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc))}_duplicateLine(){var e,t;const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,r=this._tab.doc[o]??"";this._tab.doc.splice(o+1,0,r),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:o+1,lines:[r]},i,s),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc))}_deleteLine(){var e,t;const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,{doc:o,cur:r}=this._tab;if(o.length>1){const a=r.row,l=[o[a]??""];o.splice(a,1),A(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"delete",row:a,count:1,removed:l},i,s)}else{const a=o[0]??"";o[0]="",r.col=0,M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[a],newLines:[""]},i,s)}this._tokenCache.clear(),this._tab.dirty=!0,A(this._tab),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc))}_indentSel(){var e,t;if(!this._tab.sel){this._insertStr(re(this._config.tabSize),!1);return}const i={...this._tab.cur},s={...this._tab.sel},o=re(this._config.tabSize),r=this._getSelRows(),a=r[0],l=r[r.length-1],c=this._tab.doc.slice(a,l+1);r.forEach(h=>{var p;this._tab.doc[h]=o+(this._tab.doc[h]??""),this._tokenCache.invalidateLine(h,((p=this._wm.segments[h])==null?void 0:p.length)??1)}),this._tab.dirty=!0;const d=this._tab.doc.slice(a,l+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a,oldLines:c,newLines:d},i,s),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc))}_unindentSel(){var e,t;const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._config.tabSize,r=this._getSelRows(),a=r[0],l=r[r.length-1],c=this._tab.doc.slice(a,l+1);r.forEach(h=>{var p;const u=this._tab.doc[h]??"";u.startsWith(re(o))?this._tab.doc[h]=u.slice(o):u.startsWith(" ")&&(this._tab.doc[h]=u.slice(1)),this._tokenCache.invalidateLine(h,((p=this._wm.segments[h])==null?void 0:p.length)??1)}),this._tab.dirty=!0;const d=this._tab.doc.slice(a,l+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a,oldLines:c,newLines:d},i,s),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(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=P(this._tab.sel),t=[];for(let i=e.ar;i<=e.fr;i++)t.push(i);return t}_duplicateLines(e){var t,i,s,o;const{doc:r,cur:a}=this._tab,l=this._tab.sel;let c=a.row,d=a.row;if(l){const g=P(l);c=g.ar,d=g.fr,g.fc===0&&g.fr>g.ar&&d--}const h={...this._tab.cur},p=l?{...l}:null,u=r.slice(c,d+1);e?(r.splice(d+1,0,...u),a.row+=u.length,l&&(l.ar+=u.length,l.fr+=u.length),M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d+1,lines:[...u]},h,p)):(r.splice(c,0,...u),M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:c,lines:[...u]},h,p)),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,R(this._tab.doc)),(o=(s=this._config).onCursorChange)==null||o.call(s,{...this._tab.cur})}_moveLines(e){var t,i,s,o;const{doc:r,cur:a}=this._tab,l=this._tab.sel;let c=a.row,d=a.row;if(l){const h=P(l);c=h.ar,d=h.fr,h.fc===0&&h.fr>h.ar&&d--}if(e){if(c===0)return;const h={...this._tab.cur},p=l?{...l}:null,u=c-1,g=r.slice(u,d+1),m=r.splice(c,d-c+1);r.splice(c-1,0,...m),a.row--,l&&(l.ar--,l.fr--);const v=r.slice(u,d+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:u,oldLines:g,newLines:v},h,p)}else{if(d>=r.length-1)return;const h={...this._tab.cur},p=l?{...l}:null,u=d+1,g=r.slice(c,u+1),m=r.splice(c,d-c+1);r.splice(c+1,0,...m),a.row++,l&&(l.ar++,l.fr++);const v=r.slice(c,u+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c,oldLines:g,newLines:v},h,p)}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,R(this._tab.doc)),(o=(s=this._config).onCursorChange)==null||o.call(s,{...this._tab.cur})}_wordSkipRight(e,t){let i=t;const s=e.length;for(;i<s&&/\s/.test(e[i]);)i++;if(i>=s)return i;if(/\w/.test(e[i]))for(;i<s&&/\w/.test(e[i]);)i++;else for(;i<s&&/[^\w\s]/.test(e[i]);)i++;return i}_wordSkipLeft(e,t){let i=t;for(;i>0&&/\s/.test(e[i-1]);)i--;if(i<=0)return i;if(/\w/.test(e[i-1]))for(;i>0&&/\w/.test(e[i-1]);)i--;else for(;i>0&&/[^\w\s]/.test(e[i-1]);)i--;return i}_deleteToLineStart(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const a=P(this._tab.sel),l=this._tab.doc.slice(a.ar,a.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const c=[this._tab.doc[a.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.ar,oldLines:l,newLines:c},t,i);return}const{doc:s,cur:o}=this._tab;if(o.col===0)return;const r=s[o.row]??"";s[o.row]=r.slice(o.col),o.col=0,this._tokenCache.invalidateLine(o.row,((e=this._wm.segments[o.row])==null?void 0:e.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[r],newLines:[s[o.row]]},t,i),this._tab.dirty=!0}_deleteWordLeft(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const c=P(this._tab.sel),d=this._tab.doc.slice(c.ar,c.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[c.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c.ar,oldLines:d,newLines:h},t,i);return}const{doc:s,cur:o}=this._tab;if(o.col===0){if(o.row>0){const c=s[o.row-1]??"",d=s[o.row]??"",h=c.length;s[o.row-1]=c+d,s.splice(o.row,1),o.row--,o.col=h,this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[c,d],newLines:[s[o.row]]},t,i),this._tab.dirty=!0}return}const r=s[o.row]??"",a=this._wordSkipLeft(r,o.col),l=r;s[o.row]=r.slice(0,a)+r.slice(o.col),o.col=a,this._tokenCache.invalidateLine(o.row,((e=this._wm.segments[o.row])==null?void 0:e.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[l],newLines:[s[o.row]]},t,i),this._tab.dirty=!0}_deleteToLineEnd(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const l=P(this._tab.sel),c=this._tab.doc.slice(l.ar,l.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[l.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:l.ar,oldLines:c,newLines:d},t,i);return}const{doc:s,cur:o}=this._tab,r=s[o.row]??"";if(o.col>=r.length)return;const a=r;s[o.row]=r.slice(0,o.col),this._tokenCache.invalidateLine(o.row,((e=this._wm.segments[o.row])==null?void 0:e.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[a],newLines:[s[o.row]]},t,i),this._tab.dirty=!0}_deleteWordRight(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const c=P(this._tab.sel),d=this._tab.doc.slice(c.ar,c.fr+1);this._tab.cur=F(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[c.ar]??""];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c.ar,oldLines:d,newLines:h},t,i);return}const{doc:s,cur:o}=this._tab,r=s[o.row]??"";if(o.col>=r.length){if(o.row<s.length-1){const c=s[o.row+1]??"",d=r;s[o.row]=r+c,s.splice(o.row+1,1),this._tokenCache.clear(),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[d,c],newLines:[s[o.row]]},t,i),this._tab.dirty=!0}return}const a=this._wordSkipRight(r,o.col),l=r;s[o.row]=r.slice(0,o.col)+r.slice(a),this._tokenCache.invalidateLine(o.row,((e=this._wm.segments[o.row])==null?void 0:e.length)??1),M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.row,oldLines:[l],newLines:[s[o.row]]},t,i),this._tab.dirty=!0}_doUndo(){var e,t;const i=Ii(this._tab);i!==null&&(this._extraCursors=i,this._mc.cursors=i,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc)))}_doRedo(){var e,t;const i=Ri(this._tab);i!==null&&(this._extraCursors=i,this._mc.cursors=i,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,R(this._tab.doc)))}}class js extends Ds{_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=os(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}this._findIdx=ls(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}`}_doReplaceOne(){var e,t;if(this._findIdx<0||!this._findMatches.length)return;const i=this._findMatches[this._findIdx],s={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,r=this._tab.doc[i.row]??"";this._tab.doc=rs(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const a=this._tab.doc[i.row]??"";M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:i.row,oldLines:[r],newLines:[a]},s,o),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,R(this._tab.doc))}_doReplaceAll(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches.length,s={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,r=this._findMatches[0].row,a=this._findMatches[this._findMatches.length-1].row,l=this._tab.doc.slice(r,a+1);this._tab.doc=as(this._tab.doc,this._findMatches,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const c=this._tab.doc.slice(r,a+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r,oldLines:l,newLines:c},s,o),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,R(this._tab.doc))}_bindFindEvents(){var e,t,i,s,o,r,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()),(s=this._findBar.querySelector(".sl-find-case"))==null||s.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())}),(r=this._findBar.querySelector(".sl-replace-one"))==null||r.addEventListener("click",()=>this._doReplaceOne()),(a=this._findBar.querySelector(".sl-replace-all"))==null||a.addEventListener("click",()=>this._doReplaceAll())}}class Ns extends js{_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]??"",s=this._config.language==="css",{prefix:o,start:r}=ns(i,e.col,s);this._acPrefix=o,this._acStartCol=r;const a=[];if(this._config.emmet){const c=at(i,e.col);if(c){const d=rt(c.abbr);if(d){this._emmetAcStartCol=c.start;const h=d.replace(/\n/g,"↵ ").slice(0,60);a.push({label:c.abbr,kind:"emmet",detail:h,body:d})}}}const l=o.length>=this._config.autocompletePrefixLength?ss(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 s=this._acItems.map((l,c)=>{const d=c===this._acSel;return`<div class="sl-ac-item${d?" sl-sel":""}" data-i="${c}" role="option" aria-selected="${d}"><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">${s}</div>`+o,this._acPopup.style.display="flex",this._posAcPopup();const r=this._acPopup.querySelector(".sl-ac-list"),a=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(r&&a){const l=a.offsetTop,c=l+a.offsetHeight;c>r.scrollTop+r.clientHeight?r.scrollTop=c-r.clientHeight:l<r.scrollTop&&(r.scrollTop=l)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(l=>{l.addEventListener("mousedown",c=>{c.preventDefault(),this._acSel=parseInt(l.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=Y(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,s=e.left+i+14+this._acStartCol*7.82,o=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,r=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(s,window.innerWidth-r-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){const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,r=this._tab.doc[o]??"";this._expandBodyAt(e.body,this._emmetAcStartCol);const a=this._tab.doc.slice(o,this._tab.cur.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:[r],newLines:a},i,s);return}if(e.body){const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,r=this._tab.doc[o]??"";this._expandBodyAt(e.body,this._acStartCol);const a=this._tab.doc.slice(o,this._tab.cur.row+1);M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:[r],newLines:a},i,s);return}const t=e.label.slice(this._acPrefix.length);this._insertStr(t,!1),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render()}_allCompletions(){return[...this._config.replaceBuiltins?[]:Zi(this._config.language),...this._config.completions]}_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]??"",s=at(i,e.col);if(!s){this._emmetExpanded=null;return}const o=rt(s.abbr);if(!o){this._emmetExpanded=null;return}this._emmetExpanded={abbr:s.abbr,result:o,start:s.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{result:e,start:t}=this._emmetExpanded,i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,r=this._tab.doc[o]??"";this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(e,t);const a=this._tab.doc.slice(o,this._tab.cur.row+1);return M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:[r],newLines:a},i,s),!0}_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]??"",s=Qi(i,e.col,this._allCompletions());if(!s){this._snippetExpanded=null;return}this._snippetExpanded={snippet:s.snippet,start:s.start}}_snippetAccept(){if(!this._snippetExpanded||this._snippetTip.style.display==="none")return!1;const{snippet:e,start:t}=this._snippetExpanded;if(!e.body)return!1;const i={...this._tab.cur},s=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,r=this._tab.doc[o]??"";this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t);const a=this._tab.doc.slice(o,this._tab.cur.row+1);return M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:[r],newLines:a},i,s),!0}_expandBodyAt(e,t){var i,s;const{doc:o,cur:r}=this._tab,a=r.row,l=o[r.row]??"",c=l.slice(0,t),d=l.slice(r.col),h=oe(l),p=e.split(`
|
|
498
|
+
`).map((x,b)=>b===0?x:h+x),u=p.join(`
|
|
499
|
+
`),g=[],m=/\$(\d+)/g;let v;for(;(v=m.exec(u))!==null;){const x=parseInt(v[1],10),b=u.slice(0,v.index).split(`
|
|
500
|
+
`),f=b.length-1,C=b[f].length,S=(b[f].match(/\$\d+/g)??[]).join("").length,T=a+f,I=(f===0?t:h.length)+(C-S);g.push({n:x,row:T,col:I})}g.sort((x,b)=>x.n===0?1:b.n===0?-1:x.n-b.n);const y=p.map(x=>x.replace(/\$\d+/g,"")),_=y.length===1?[c+y[0]+d]:[c+y[0],...y.slice(1,-1),y[y.length-1]+d];o.splice(r.row,1,..._),g.length>0?(this._snippetSession={stops:g.map(x=>({row:x.row,col:x.col})),idx:0},r.row=g[0].row,r.col=g[0].col):(this._snippetSession=null,r.row+=_.length-1,r.col=(_[_.length-1]??"").length-d.length),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(s=(i=this._config).onChange)==null||s.call(i,R(this._tab.doc))}_ctrlD(){if(!this._config.multiCursor)return;const e=!this._mc.searchWord,t=!!this._tab.sel;if(e&&t){const s=this._tab.sel,o=Math.min(s.ac,s.fc),r=Math.max(s.ac,s.fc);if(s.ar===s.fr){const a=(this._tab.doc[s.ar]??"").slice(o,r);a&&(this._mc.searchWord=a,this._mc.lastMatchRow=s.fr,this._mc.lastMatchCol=r)}}const i=Oi(this._mc,this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel);i&&(e&&!t?(this._tab.sel=i.sel,this._tab.cur.row=i.row,this._tab.cur.col=i.col):(i.row!==this._tab.cur.row||i.col!==this._tab.cur.col)&&(it(this._mc,i.row,i.col,i.sel),this._extraCursors=[...this._mc.cursors]),this._mc.searchWord=i.word,this._mc.lastMatchRow=i.row,this._mc.lastMatchCol=i.col,this._scrollIntoView(),this._render())}}class Os extends Ns{_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,s,o;if(!this._config.hover)return;const r=this._editorEl.getBoundingClientRect(),a=this._logicalScroll(this._editorEl.scrollTop),l=t-r.top+a,c=this._config.showGutter?this._config.gutterWidth:0,d=e-r.left-c-14,h=this._config.lineHeight,p=this._wm.windowVisStart,u=p+this._wm.visualRows.length-1,g=Math.max(p,Math.min(u,Math.floor(l/h))),m=Math.max(0,Math.min((((i=this._wm.visualRows[g-p])==null?void 0:i.text)??"").length,Math.round(d/7.82))),v=ne(this._wm,g,m),y=this._tab.doc[v.row]??"",_=Vi(y,v.col);if(!_)return;let x=qi(_,this._config.language);if(!x){const b=this._config.completions.find(f=>f.label===_);b&&(b.description||b.detail)&&(x={title:b.label,type:b.detail,body:b.description??""})}if(!x){const b=(o=(s=this._config).provideHover)==null?void 0:o.call(s,{word:_,row:v.row,col:v.col,line:y,language:this._config.language,doc:this._tab.doc});b&&(x=b)}x&&this._showHoverTip(x,e,t)}_showHoverTip(e,t,i){const s=this._hoverTip;let o='<div class="sl-ht-sig">';o+=`<span class="sl-ht-title">${ee(e.title)}</span>`,e.type&&(o+=`<code class="sl-ht-type">${ee(e.type)}</code>`),o+="</div>",e.title&&e.body&&(o+='<div class="sl-ht-divider"></div>'),e.body&&(o+=`<div class="sl-ht-body">${ee(e.body)}</div>`),s.innerHTML=o,s.style.display="block";const r=12,a=18,l=s.offsetWidth||300,c=s.offsetHeight||80;let d=t,h=i+a;h+c>window.innerHeight-r&&(h=i-c-8),d+l>window.innerWidth-r&&(d=window.innerWidth-l-r),d<r&&(d=r),s.style.left=`${d}px`,s.style.top=`${Math.max(r,h)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_openThemePicker(){var e;const t=this._themeManager.all;this._themePanel.innerHTML=`
|
|
501
|
+
<div class="sl-theme-header">
|
|
502
|
+
<div class="sl-theme-title">Color Theme</div>
|
|
503
|
+
<div class="sl-theme-close">✕</div>
|
|
504
|
+
</div>
|
|
505
|
+
<div class="sl-theme-list">
|
|
506
|
+
${t.map(i=>`
|
|
507
|
+
<div class="sl-theme-item${i.id===this._themeManager.activeId?" sl-active":""}" data-id="${i.id}">
|
|
508
|
+
<div class="sl-theme-swatch">
|
|
509
|
+
${i.tokens.bg0?`<span style="background:${i.tokens.bg0}"></span>`:""}
|
|
510
|
+
<span style="background:${i.tokens.accent}"></span>
|
|
511
|
+
<span style="background:${i.tokens.tokStr}"></span>
|
|
512
|
+
<span style="background:${i.tokens.tokFn}"></span>
|
|
513
|
+
</div>
|
|
514
|
+
<div>
|
|
515
|
+
<div class="sl-theme-name">${i.name}<span class="sl-theme-tag${i.light?" sl-light":""}">${i.light?"Light":"Dark"}</span></div>
|
|
516
|
+
<div class="sl-theme-desc">${i.description}</div>
|
|
517
|
+
</div>
|
|
518
|
+
<div class="sl-theme-check">✓</div>
|
|
519
|
+
</div>
|
|
520
|
+
`).join("")}
|
|
521
|
+
</div>
|
|
522
|
+
`,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 s=i.dataset.id??"";this._applyTheme(s),this._themePanel.querySelectorAll(".sl-theme-item").forEach(o=>o.classList.remove("sl-active")),i.classList.add("sl-active")})})}_applyTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=Me(t=>ae(t,this._host)),this._tokenCache.clear(),this._render()}}class Ws extends Os{_posFromMouse(e){var t;const i=this._editorEl.getBoundingClientRect(),s=this._logicalScroll(this._editorEl.scrollTop),o=e.clientY-i.top+s,r=this._config.showGutter?this._config.gutterWidth:0,a=e.clientX-i.left-r-14,l=this._config.lineHeight,c=this._wm.windowVisStart,d=c+this._wm.visualRows.length-1,h=Math.max(c,Math.min(d,Math.floor(o/l))),p=Math.max(0,Math.min((((t=this._wm.visualRows[h-c])==null?void 0:t.text)??"").length,Math.round(a/7.82)));return ne(this._wm,h,p)}_bindEditorEvents(){this._vpEl.addEventListener("mousedown",e=>this._onFoldBtnClick(e)),this._editorEl.addEventListener("mousedown",e=>{var t,i;if(e.button!==0)return;e.preventDefault(),this._focusInput(),this._acHide(),this._snippetSession=null,this._emmetTip.style.display="none",e.altKey||(st(this._mc),this._extraCursors=[]);const s=this._posFromMouse(e);if(e.altKey&&e.detail===1&&!e.shiftKey&&this._config.multiCursor){it(this._mc,s.row,s.col,null),this._extraCursors=[...this._mc.cursors],this._render();return}if(e.shiftKey&&e.detail===1){const o=this._tab.sel?{row:this._tab.sel.ar,col:this._tab.sel.ac}:{row:this._tab.cur.row,col:this._tab.cur.col};this._tab.cur={...s},this._tab.sel={ar:o.row,ac:o.col,fr:s.row,fc:s.col},o.row===s.row&&o.col===s.col&&(this._tab.sel=null),this._isDragging=!1,A(this._tab),this._render(),(i=(t=this._config).onSelectionChange)==null||i.call(t,this._tab.sel?{...this._tab.sel}:null);return}if(this._tab.cur={...s},e.detail===3)this._tab.sel={ar:s.row,ac:0,fr:s.row,fc:(this._tab.doc[s.row]??"").length},this._tab.cur.col=this._tab.sel.fc;else if(e.detail===2&&this._config.wordSelection){const o=this._tab.doc[s.row]??"",r=this._wordStart(o,s.col),a=this._wordEnd(o,s.col);r!==a?(this._tab.sel={ar:s.row,ac:r,fr:s.row,fc:a},this._tab.cur.col=a):this._tab.sel=null}else this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...s};A(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,A(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,i,s,o,r;if(e.preventDefault(),this._config.readOnly)return;const a=(t=e.clipboardData??window.clipboardData)==null?void 0:t.getData("text/plain");if(a){if(this._linewiseCopy&&!this._tab.sel){const l={...this._tab.cur},c=this._tab.cur.row,d=a.endsWith(`
|
|
523
|
+
`)?a.slice(0,-1):a;this._tab.doc.splice(c,0,d),this._tab.cur.row=c+1,M(this._tab,this._config.maxUndoHistory,{kind:"insert",row:c,lines:[d]},l,null),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(s=(i=this._config).onChange)==null||s.call(i,R(this._tab.doc)),(r=(o=this._config).onCursorChange)==null||r.call(o,{...this._tab.cur});return}this._insertStr(a,!1),this._tokenCache.clear(),this._rebuildWrapMap(),A(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,s,o,r,a,l,c,d;const h=e.ctrlKey||e.metaKey,p=e.shiftKey,u=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(u&&(e.key==="z"||e.key==="Z"||e.key==="Ω")){e.preventDefault(),this._toggleWrap();return}if(h&&e.key==="z"&&!p){e.preventDefault(),g||this._doUndo();return}if(h&&(e.key==="y"||p&&e.key==="z")){e.preventDefault(),g||this._doRedo();return}if(h&&e.key==="a"){e.preventDefault(),this._selectAll();return}if(h&&e.key==="c"){e.preventDefault(),this._doCopy();return}if(h&&e.key==="x"){e.preventDefault(),g||this._doCut();return}if(h&&e.key==="f"){e.preventDefault(),this._config.find&&this._openFind(!1);return}if(h&&e.key==="h"){e.preventDefault(),this._config.find&&this._config.findReplace&&this._openFind(!0);return}if(h&&e.key==="g"){e.preventDefault(),this._config.goToLine&&this._openGoToLine();return}if(h&&e.key==="d"){e.preventDefault(),!g&&this._config.multiCursor&&this._ctrlD();return}if(h&&p&&e.key==="d"){e.preventDefault(),g||this._duplicateLine();return}if(h&&e.key==="/"){e.preventDefault(),g||this._toggleComment();return}if(h&&e.key==="k"){e.preventDefault(),g||this._deleteLine();return}if(h&&e.key==="Enter"){e.preventDefault(),g||(p?this._doInsertLineAbove():this._doInsertLineBelow());return}if(e.key==="Escape"){this._tab.sel=null,this._acHide(),this._closeFind(),this._closeGoToLine(),this._emmetTip.style.display="none",this._snippetTip.style.display="none",this._snippetExpanded=null,this._snippetSession=null,st(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(g){this._handleArrowKeys(e,h,p);return}if(e.key==="Tab"){if(e.preventDefault(),this._snippetSession){if(p){if(this._snippetSession.idx>0){this._snippetSession.idx--;const m=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=m.row,this._tab.cur.col=m.col,this._tab.sel=null,A(this._tab),this._scrollIntoView(),this._render()}}else if(this._snippetSession.idx++,this._snippetSession.idx>=this._snippetSession.stops.length)this._snippetSession=null;else{const m=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=m.row,this._tab.cur.col=m.col,this._tab.sel=null,A(this._tab),this._scrollIntoView(),this._render()}return}if(!p&&this._emmetAccept()||!p&&this._snippetAccept())return;p?this._unindentSel():this._indentSel(),A(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){this._snippetSession=null;const m=e.metaKey,v=e.altKey||e.ctrlKey,y=this._tab.doc.slice(),_={...this._tab.cur},x=this._tab.sel?{...this._tab.sel}:null,b=this._extraCursors.map(S=>({...S,sel:S.sel?{...S.sel}:null})),f=Te(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,(S,T,I,W)=>{if(W){const j=P(W);return{fromRow:j.ar,fromCol:j.ac,toRow:j.fr,toCol:j.fc}}return m?I===0?null:{fromRow:T,fromCol:0,toRow:T,toCol:I}:v?I===0?T===0?null:{fromRow:T-1,fromCol:(S[T-1]??"").length,toRow:T,toCol:0}:{fromRow:T,fromCol:this._wordSkipLeft(S[T]??"",I),toRow:T,toCol:I}:I===0?T===0?null:{fromRow:T-1,fromCol:(S[T-1]??"").length,toRow:T,toCol:0}:{fromRow:T,fromCol:I-1,toRow:T,toCol:I}});this._tab.doc=f.doc,this._tab.cur.row=f.primaryRow,this._tab.cur.col=f.primaryCol,this._tab.sel=null,this._extraCursors=f.extraCursors,this._mc.cursors=f.extraCursors,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1;const C=_e(y,this._tab.doc);(C.oldLines.length||C.newLines.length)&&M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:C.row,oldLines:C.oldLines,newLines:C.newLines},_,x,b,f.extraCursors)}else if(e.metaKey)this._snippetSession=null,this._deleteToLineStart();else if(e.altKey||e.ctrlKey)this._snippetSession=null,this._deleteWordLeft();else{if(this._snippetSession){const m=this._snippetSession.stops[this._snippetSession.idx];if(this._tab.cur.row===m.row&&this._tab.cur.col>m.col){for(let v=this._snippetSession.idx+1;v<this._snippetSession.stops.length;v++){const y=this._snippetSession.stops[v];y.row===m.row&&y.col>=this._tab.cur.col&&y.col--}m.col--}else this._snippetSession=null}this._doBackspace()}this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(i=(t=this._config).onChange)==null||i.call(t,R(this._tab.doc));return}if(e.key==="Delete"){if(e.preventDefault(),this._snippetSession=null,this._extraCursors.length){const m=e.metaKey,v=e.altKey||e.ctrlKey,y=this._tab.doc.slice(),_={...this._tab.cur},x=this._tab.sel?{...this._tab.sel}:null,b=this._extraCursors.map(S=>({...S,sel:S.sel?{...S.sel}:null})),f=Te(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,(S,T,I,W)=>{if(W){const G=P(W);return{fromRow:G.ar,fromCol:G.ac,toRow:G.fr,toCol:G.fc}}const j=S[T]??"";return m?I>=j.length?null:{fromRow:T,fromCol:I,toRow:T,toCol:j.length}:v?I>=j.length?T>=S.length-1?null:{fromRow:T,fromCol:I,toRow:T+1,toCol:0}:{fromRow:T,fromCol:I,toRow:T,toCol:this._wordSkipRight(j,I)}:I<j.length?{fromRow:T,fromCol:I,toRow:T,toCol:I+1}:T<S.length-1?{fromRow:T,fromCol:I,toRow:T+1,toCol:0}:null});this._tab.doc=f.doc,this._tab.cur.row=f.primaryRow,this._tab.cur.col=f.primaryCol,this._tab.sel=null,this._extraCursors=f.extraCursors,this._mc.cursors=f.extraCursors,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1;const C=_e(y,this._tab.doc);(C.oldLines.length||C.newLines.length)&&M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:C.row,oldLines:C.oldLines,newLines:C.newLines},_,x,b,f.extraCursors)}else e.metaKey?this._deleteToLineEnd():e.altKey||e.ctrlKey?this._deleteWordRight():this._doDelete();this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(o=(s=this._config).onChange)==null||o.call(s,R(this._tab.doc));return}if(e.key==="Enter"){e.preventDefault(),this._snippetSession=null,this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(a=(r=this._config).onChange)==null||a.call(r,R(this._tab.doc));return}if(!h&&!u&&this._config.autoClosePairs[e.key]){e.preventDefault();const m={...this._tab.cur},v=this._tab.sel?{...this._tab.sel}:null;let y,_;if(this._tab.sel){const C=P(this._tab.sel);y=C.ar,_=this._tab.doc.slice(C.ar,C.fr+1),this._tab.cur=F(this._tab)}else y=this._tab.cur.row,_=[this._tab.doc[y]??""];const{doc:x,cur:b}=this._tab,f=x[b.row]??"";x[b.row]=f.slice(0,b.col)+e.key+this._config.autoClosePairs[e.key]+f.slice(b.col),b.col++,this._tokenCache.invalidateLine(b.row,((l=this._wm.segments[b.row])==null?void 0:l.length)??1),this._tab.dirty=!0,M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:y,oldLines:_,newLines:[x[b.row]]},m,v),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),(d=(c=this._config).onChange)==null||d.call(c,R(this._tab.doc));return}if(!h&&!u&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:m,cur:v}=this._tab;if((m[v.row]??"")[v.col]===e.key){e.preventDefault(),v.col++,A(this._tab),this._scrollIntoView(),this._render();return}}if(p&&u&&!h&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._duplicateLines(e.key==="ArrowDown");return}if(u&&!h&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._moveLines(e.key==="ArrowUp");return}this._handleArrowKeys(e,h,p)}_handleArrowKeys(e,t,i){var s,o,r,a,l,c;const{doc:d,cur:h}=this._tab,p=this._config.lineHeight,u=e.metaKey,g=e.ctrlKey,m=e.altKey,v=(x,b)=>{if(i){this._tab.sel||(this._tab.sel={ar:h.row,ac:h.col,fr:h.row,fc:h.col}),h.row=x,h.col=b;const f=this._tab.sel;f.fr=x,f.fc=b,f.ar===f.fr&&f.ac===f.fc&&(this._tab.sel=null)}else this._tab.sel=null,h.row=x,h.col=b},y=x=>{const b=(d[x]??"").search(/\S/);return b===-1||h.col===b?0:b},_=()=>({row:d.length-1,col:(d[d.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const x=P(this._tab.sel);h.row=x.fr,h.col=x.fc,this._tab.sel=null;break}if(u)v(h.row,(d[h.row]??"").length);else if(g||m){const x=d[h.row]??"";if(h.col>=x.length)h.row<d.length-1&&v(h.row+1,0);else{const b=this._wordSkipRight(x,h.col);v(h.row,b)}}else h.col<(d[h.row]??"").length?v(h.row,h.col+1):h.row<d.length-1&&v(h.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const x=P(this._tab.sel);h.row=x.ar,h.col=x.ac,this._tab.sel=null;break}if(u)v(h.row,y(h.row));else if(g||m)if(h.col===0)h.row>0&&v(h.row-1,(d[h.row-1]??"").length);else{const x=this._wordSkipLeft(d[h.row]??"",h.col);v(h.row,x)}else h.col>0?v(h.row,h.col-1):h.row>0&&v(h.row-1,(d[h.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),u){const x=_();v(x.row,x.col)}else if(this._config.wordWrap){const x=Y(this._wm,h.row,h.col),b=this._wm.windowVisStart,f=Math.min(this._wm.totalVisualRows-1,x.visRow+1),C=ne(this._wm,f,Math.min(x.colInSeg,(((s=this._wm.visualRows[f-b])==null?void 0:s.text)??"").length));v(C.row,C.col)}else{let x=Math.min(d.length-1,h.row+1);for(const[b,f]of this._foldedLines)if(x>b&&x<=f){x=Math.min(d.length-1,f+1);break}v(x,Math.min(h.col,(d[x]??"").length))}break;case"ArrowUp":if(e.preventDefault(),u)v(0,0);else if(this._config.wordWrap){const x=Y(this._wm,h.row,h.col),b=this._wm.windowVisStart,f=Math.max(0,x.visRow-1),C=ne(this._wm,f,Math.min(x.colInSeg,(((o=this._wm.visualRows[f-b])==null?void 0:o.text)??"").length));v(C.row,C.col)}else{let x=Math.max(0,h.row-1);for(const[b,f]of this._foldedLines)if(x>b&&x<=f){x=b;break}v(x,Math.min(h.col,(d[x]??"").length))}break;case"Home":e.preventDefault(),g?v(0,0):v(h.row,y(h.row));break;case"End":if(e.preventDefault(),g){const x=_();v(x.row,x.col)}else v(h.row,(d[h.row]??"").length);break;case"PageDown":e.preventDefault();{const x=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),b=Math.min(d.length-1,h.row+x);v(b,Math.min(h.col,(d[b]??"").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),b=Math.max(0,h.row-x);v(b,Math.min(h.col,(d[b]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-p;break}default:return}if(this._extraCursors.length){const x=(b,f)=>{const C=(d[b]??"").search(/\S/);return C===-1||f===C?0:C};this._extraCursors=this._extraCursors.map(b=>{let f=b.row,C=b.col;if(!i&&b.sel){const S=P(b.sel);if(e.key==="ArrowLeft")return{row:S.ar,col:S.ac,sel:null};if(e.key==="ArrowRight")return{row:S.fr,col:S.fc,sel:null};C=b.col}switch(e.key){case"ArrowRight":if(u)C=(d[f]??"").length;else if(g||m){const S=d[f]??"";C>=S.length?f<d.length-1&&(f++,C=0):C=this._wordSkipRight(S,C)}else C<(d[f]??"").length?C++:f<d.length-1&&(f++,C=0);break;case"ArrowLeft":u?C=x(f,C):g||m?C===0?f>0&&(f--,C=(d[f]??"").length):C=this._wordSkipLeft(d[f]??"",C):C>0?C--:f>0&&(f--,C=(d[f]??"").length);break;case"ArrowDown":u?(f=d.length-1,C=(d[f]??"").length):(f=Math.min(d.length-1,f+1),C=Math.min(b.col,(d[f]??"").length));break;case"ArrowUp":u?(f=0,C=0):(f=Math.max(0,f-1),C=Math.min(b.col,(d[f]??"").length));break;case"Home":g?(f=0,C=0):C=x(f,C);break;case"End":g&&(f=d.length-1),C=(d[f]??"").length;break}return C=Math.max(0,Math.min(C,(d[f]??"").length)),{row:f,col:C,sel:i?b.sel:null}}),this._extraCursors=this._extraCursors.filter(b=>!(b.row===this._tab.cur.row&&b.col===this._tab.cur.col)),this._mc.cursors=this._extraCursors}A(this._tab),this._scrollIntoView(),this._acHide(),(a=(r=this._config).onCursorChange)==null||a.call(r,{...this._tab.cur}),(c=(l=this._config).onSelectionChange)==null||c.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)}_wordStart(e,t){let i=t;for(;i>0&&this._isWordChar(e[i-1]);)i--;return i}_wordEnd(e,t){let i=t;for(;i<e.length&&this._isWordChar(e[i]);)i++;return i}_onInput(e){var t,i,s,o;if(this._config.readOnly){e.target.value="";return}const r=e.target,a=r.value;if(r.value="",!a||a==="Ω")return;const l=a.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(l){if(this._extraCursors.length){this._snippetSession=null;const c=this._tab.doc.slice(),d={...this._tab.cur},h=this._tab.sel?{...this._tab.sel}:null,p=this._extraCursors.map(x=>({...x,sel:x.sel?{...x.sel}:null}));let u=this._tab.doc,g=this._tab.cur.row,m=this._tab.cur.col,v=this._extraCursors;if(this._tab.sel||this._extraCursors.some(x=>x.sel)){const x=Te(u,g,m,this._tab.sel,v,(b,f,C,S)=>{if(!S)return null;const T=P(S);return{fromRow:T.ar,fromCol:T.ac,toRow:T.fr,toCol:T.fc}});u=x.doc,g=x.primaryRow,m=x.primaryCol,v=x.extraCursors,this._tab.sel=null,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1}const y=Ni(u,g,m,v,l);this._tab.doc=y.doc,this._tab.cur.row=y.primaryRow,this._tab.cur.col=y.primaryCol,this._extraCursors=y.extraCursors,this._mc.cursors=y.extraCursors,this._tab.dirty=!0;const _=_e(c,this._tab.doc);(_.oldLines.length||_.newLines.length)&&M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:_.row,oldLines:_.oldLines,newLines:_.newLines},d,h,p,this._extraCursors),(i=(t=this._config).onChange)==null||i.call(t,R(this._tab.doc))}else{const c=this._tab.cur.row,d=this._tab.cur.col;if(this._insertStr(l,!0),this._snippetSession){const h=this._snippetSession,p=h.stops[h.idx];if(this._tab.cur.row===p.row){const u=this._tab.cur.col-d;for(let g=h.idx+1;g<h.stops.length;g++){const m=h.stops[g];m.row===c&&m.col>=d&&(m.col+=u)}p.col=this._tab.cur.col}else this._snippetSession=null}}this._tokenCache.clear(),this._rebuildWrapMap(),A(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(o=(s=this._config).onCursorChange)==null||o.call(s,{...this._tab.cur})}}_bindMinimapEvents(){const e=this._minimapWrap;e.addEventListener("mousemove",t=>{if(this._mmDragMode!=="none")return;const i=t.clientY-e.getBoundingClientRect().top,{sliderTop:s,sliderHeight:o}=Ee(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=s&&i<=s+o?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,s=t.clientY-e.getBoundingClientRect().top,{sliderTop:o,sliderHeight:r}=Ee(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);if(s>=o&&s<=o+r)this._mmDragMode="slider",this._mmSliderOffset=s-o,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const a=Fi(s,this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=this._domScroll(a),this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}class zs extends Ws{getValue(){return R(this._tab.doc)}setValue(e){var t,i;const s={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,r=[...this._tab.doc];this._tab.doc=Ze(e),this._tab.cur={row:0,col:0},this._tab.sel=null;const a=[...this._tab.doc];M(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:r,newLines:a},s,o),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},A(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(),A(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._applyTheme(e)}updateConfig(e){const t=ct(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:s,...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||e.provideTokens!==void 0)&&this._tokenCache.clear(),e.find===!1?this._closeFind():e.findReplace===!1&&(this._replaceRow.style.display="none"),e.goToLine===!1&&this._closeGoToLine(),e.placeholder!==void 0&&(this._placeholderEl.textContent=e.placeholder),this._render()}focus(){this._focusInput()}getThemes(){return this._themeManager.allIds}registerTheme(e){this._themeManager.register(e)}undo(){this._doUndo()}redo(){this._doRedo()}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(){this._destroyBase()}}const de={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:"#c792ea",tokStr:"#c3e88d",tokCmt:"#636e8a",tokFn:"#82aaff",tokNum:"#f78c6c",tokCls:"#ffcb6b",tokOp:"#89ddff",tokTyp:"#82aaff",tokDec:"#f07178"}},ce={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:"#7c3aed",tokStr:"#15803d",tokCmt:"#94a3b8",tokFn:"#2563eb",tokNum:"#c2410c",tokCls:"#b45309",tokOp:"#0891b2",tokTyp:"#2563eb",tokDec:"#dc2626"}};function D(n){const e=n.map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),t=new RegExp(`<(\\/?)(${e.join("|")})(?=[\\s>/])`,"g"),i=/([a-zA-Z_][\w-]*)(?=\s*=)|([a-zA-Z_][\w-]*)(?=[\s\t/>]|$)|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/g;let s=!1;const o=(r,a,l)=>{i.lastIndex=0;for(const c of r.matchAll(i))c[1]!==void 0?l.push({cls:"fn",start:a+c.index,end:a+c.index+c[1].length}):c[2]!==void 0?l.push({cls:"fn",start:a+c.index,end:a+c.index+c[2].length}):c[3]!==void 0&&l.push({cls:"str",start:a+c.index,end:a+c.index+c[3].length})};return r=>{const a=[];if(s){const l=r.indexOf(">"),c=l===-1?r.length:l;return o(r.slice(0,c),0,a),l!==-1&&(s=!1),a}t.lastIndex=0;for(const l of r.matchAll(t))if(l[1]){const c=l.index+2;a.push({cls:"cls",start:c,end:c+l[2].length})}else{const c=l.index+1;a.push({cls:"cls",start:c,end:c+l[2].length});const d=c+l[2].length,h=r.indexOf(">",d),p=h===-1?r.length:h;if(o(r.slice(d,p),d,a),h===-1){s=!0;break}}return a}}function Fs(n,e){const t=[],i=n.match(/^(#{1,6}) /);if(i)return t.push({cls:"kw",start:0,end:i[1].length}),t;const s=n.match(/^(`{3,}|~{3,})([\w-]*)/);if(s)return t.push({cls:"kw",start:0,end:s[1].length}),s[2]&&t.push({cls:"typ",start:s[1].length,end:s[1].length+s[2].length}),t;if(/^(\s*)(---+|\*\*\*+|___+)\s*$/.test(n))return t.push({cls:"kw",start:0,end:n.length}),t;const o=n.match(/^(\s*>+\s?)/);o&&t.push({cls:"kw",start:0,end:o[1].length});const r=n.match(/^(\s*)([-*+]) (\[[ x]\] )?/);if(r){const d=r[1].length;if(t.push({cls:"op",start:d,end:d+1}),r[3]){const h=d+2;t.push({cls:"kw",start:h,end:h+r[3].trimEnd().length})}}const a=n.match(/^(\s*)(\d+\.) /);if(a){const d=a[1].length;t.push({cls:"op",start:d,end:d+a[2].length})}const l=n.match(/^(import|export)(\s)/);if(l&&t.push({cls:"kw",start:0,end:l[1].length}),/^\s*\|/.test(n)){for(const d of n.matchAll(/\|/g))t.push({cls:"op",start:d.index,end:d.index+1});return t}const c=new Set;for(const d of n.matchAll(/`([^`]+)`/g)){for(let h=d.index;h<d.index+d[0].length;h++)c.add(h);t.push({cls:"str",start:d.index,end:d.index+d[0].length})}for(const d of n.matchAll(new RegExp("(\\*\\*|__)(?!\\s)(.+?)(?<!\\s)\\1","g")))if(!c.has(d.index)){for(let h=d.index;h<d.index+d[0].length;h++)c.add(h);t.push({cls:"num",start:d.index,end:d.index+d[0].length})}for(const d of n.matchAll(new RegExp("(?<!\\*)\\*(?!\\*)(?!\\s)(.+?)(?<!\\s)\\*(?!\\*)|(?<!_)_(?!_)(?!\\s)(.+?)(?<!\\s)_(?!_)","g")))if(!c.has(d.index)){for(let h=d.index;h<d.index+d[0].length;h++)c.add(h);t.push({cls:"fn",start:d.index,end:d.index+d[0].length})}for(const d of n.matchAll(/~~(.+?)~~/g))if(!c.has(d.index)){for(let h=d.index;h<d.index+d[0].length;h++)c.add(h);t.push({cls:"cmt",start:d.index,end:d.index+d[0].length})}for(const d of n.matchAll(/!\[([^\]]*)\]\(([^)]*)\)/g)){if(c.has(d.index))continue;const h=d.index+2+d[1].length+1;t.push({cls:"fn",start:d.index,end:h}),t.push({cls:"str",start:h,end:d.index+d[0].length});for(let p=d.index;p<d.index+d[0].length;p++)c.add(p)}for(const d of n.matchAll(/\[([^\]]+)\]\(([^)]*)\)/g)){if(c.has(d.index))continue;const h=d.index+1+d[1].length+1;t.push({cls:"fn",start:d.index,end:h}),t.push({cls:"str",start:h,end:d.index+d[0].length});for(let p=d.index;p<d.index+d[0].length;p++)c.add(p)}return t}function ht(n,e){return(t,i)=>{const s=[];for(const o of n){const r=o(t,i);r.length&&s.push(...r)}for(const o of e){const r=o(t,i);r.length&&s.push(...r)}return s}}function pt(n){const e=n.tokens;return{keyword:e.tokKw??e.text,string:e.tokStr??e.text,comment:e.tokCmt??e.text2,function:e.tokFn??e.text,number:e.tokNum??e.text,class:e.tokCls??e.text,operator:e.tokOp??e.text,type:e.tokTyp??e.text,decorator:e.tokDec??e.text}}const he={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},Gs=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),pe=[{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"}],ut=[{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
|
|
524
|
+
- $2Item 2
|
|
525
|
+
- $3Item 3`},{label:"ol",kind:"snip",detail:"ordered list",body:`1. $1Item 1
|
|
526
|
+
2. $2Item 2
|
|
527
|
+
3. $3Item 3`},{label:"task",kind:"snip",detail:"task list",body:`- [ ] $1Task 1
|
|
528
|
+
- [ ] $2Task 2
|
|
529
|
+
- [ ] $3Task 3`},{label:"tbl",kind:"snip",detail:"markdown table",body:`| Header 1 | Header 2 | Header 3 |
|
|
530
|
+
| -------- | -------- | -------- |
|
|
531
|
+
| Cell 1 | Cell 2 | Cell 3 |
|
|
532
|
+
| 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
|
|
533
|
+
TIP: $1Your message here
|
|
534
|
+
:::`},{label:"adm-warning",kind:"snip",detail:":::warning admonition",body:`:::warning
|
|
535
|
+
WARNING: $1Your message here
|
|
536
|
+
:::`},{label:"adm-caution",kind:"snip",detail:":::caution admonition",body:`:::caution
|
|
537
|
+
CAUTION: $1Your message here
|
|
538
|
+
:::`},{label:"adm-danger",kind:"snip",detail:":::danger admonition",body:`:::danger
|
|
539
|
+
DANGER: $1Your message here
|
|
540
|
+
:::`},{label:"adm-check",kind:"snip",detail:":::check admonition",body:`:::check
|
|
541
|
+
CHECK: $1Your message here
|
|
542
|
+
:::`},{label:"adm-info",kind:"snip",detail:":::info admonition",body:`:::info
|
|
543
|
+
INFO: $1Your message here
|
|
544
|
+
:::`},{label:"adm-note",kind:"snip",detail:":::note admonition",body:`:::note
|
|
545
|
+
NOTE: $1Your message here
|
|
546
|
+
:::`},{label:"info",kind:"snip",detail:":::info callout",body:`:::info
|
|
547
|
+
INFO: $1Your message here
|
|
548
|
+
:::`},{label:"tip",kind:"snip",detail:":::tip callout",body:`:::tip
|
|
549
|
+
TIP: $1Your message here
|
|
550
|
+
:::`},{label:"warn",kind:"snip",detail:":::warning callout",body:`:::warning
|
|
551
|
+
WARNING: $1Your message here
|
|
552
|
+
:::`},{label:"danger",kind:"snip",detail:":::danger callout",body:`:::danger
|
|
553
|
+
DANGER: $1Your message here
|
|
554
|
+
:::`},{label:"note",kind:"snip",detail:":::note callout",body:`:::note
|
|
555
|
+
NOTE: $1Your message here
|
|
556
|
+
:::`},{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>
|
|
557
|
+
$2Your content here. You can include any markdown or components.
|
|
558
|
+
</Accordion>`},{label:"accordiongroup",kind:"snip",detail:"<AccordionGroup> component",body:`<AccordionGroup>
|
|
559
|
+
<Accordion title="$1Section 1" defaultOpen>
|
|
560
|
+
$2Content for section 1
|
|
561
|
+
</Accordion>
|
|
562
|
+
<Accordion title="$3Section 2">
|
|
563
|
+
$4Content for section 2
|
|
564
|
+
</Accordion>
|
|
565
|
+
<Accordion title="$5Section 3">
|
|
566
|
+
$6Content for section 3
|
|
567
|
+
</Accordion>
|
|
568
|
+
</AccordionGroup>`},{label:"col2",kind:"snip",detail:"2-column layout",body:`<Columns count="2">
|
|
569
|
+
<Column>
|
|
570
|
+
$1Column 1 content
|
|
571
|
+
</Column>
|
|
572
|
+
<Column>
|
|
573
|
+
$2Column 2 content
|
|
574
|
+
</Column>
|
|
575
|
+
</Columns>`},{label:"col3",kind:"snip",detail:"3-column layout",body:`<Columns count="3">
|
|
576
|
+
<Column>
|
|
577
|
+
$1Column 1 content
|
|
578
|
+
</Column>
|
|
579
|
+
<Column>
|
|
580
|
+
$2Column 2 content
|
|
581
|
+
</Column>
|
|
582
|
+
<Column>
|
|
583
|
+
$3Column 3 content
|
|
584
|
+
</Column>
|
|
585
|
+
</Columns>`},{label:"col4",kind:"snip",detail:"4-column layout",body:`<Columns count="4">
|
|
586
|
+
<Column>
|
|
587
|
+
$1Column 1 content
|
|
588
|
+
</Column>
|
|
589
|
+
<Column>
|
|
590
|
+
$2Column 2 content
|
|
591
|
+
</Column>
|
|
592
|
+
<Column>
|
|
593
|
+
$3Column 3 content
|
|
594
|
+
</Column>
|
|
595
|
+
<Column>
|
|
596
|
+
$4Column 4 content
|
|
597
|
+
</Column>
|
|
598
|
+
</Columns>`},{label:"col5",kind:"snip",detail:"5-column layout",body:`<Columns count="5">
|
|
599
|
+
<Column>
|
|
600
|
+
$1Column 1 content
|
|
601
|
+
</Column>
|
|
602
|
+
<Column>
|
|
603
|
+
$2Column 2 content
|
|
604
|
+
</Column>
|
|
605
|
+
<Column>
|
|
606
|
+
$3Column 3 content
|
|
607
|
+
</Column>
|
|
608
|
+
<Column>
|
|
609
|
+
$4Column 4 content
|
|
610
|
+
</Column>
|
|
611
|
+
<Column>
|
|
612
|
+
$5Column 5 content
|
|
613
|
+
</Column>
|
|
614
|
+
</Columns>`},{label:"columns",kind:"snip",detail:"2-column layout",body:`<Columns count="2">
|
|
615
|
+
<Column>
|
|
616
|
+
$1Column 1 content
|
|
617
|
+
</Column>
|
|
618
|
+
<Column>
|
|
619
|
+
$2Column 2 content
|
|
620
|
+
</Column>
|
|
621
|
+
</Columns>`},{label:"card",kind:"snip",detail:"<Card> component",body:`<Card title="$1Card Title" icon="📄" href="$2/link">
|
|
622
|
+
$3Card description or content goes here.
|
|
623
|
+
</Card>`},{label:"cards",kind:"snip",detail:"<CardGroup> component",body:`<CardGroup cols="2">
|
|
624
|
+
<Card title="$1Card 1" icon="📄">
|
|
625
|
+
$2Description for card 1
|
|
626
|
+
</Card>
|
|
627
|
+
<Card title="$3Card 2" icon="📄">
|
|
628
|
+
$4Description for card 2
|
|
629
|
+
</Card>
|
|
630
|
+
</CardGroup>`},{label:"steps",kind:"snip",detail:"<Steps> component",body:`<Steps>
|
|
631
|
+
<Step title="$1First Step">
|
|
632
|
+
$2These are instructions or content that only pertain to the first step.
|
|
633
|
+
</Step>
|
|
634
|
+
<Step title="$3Second Step">
|
|
635
|
+
$4These are instructions or content that only pertain to the second step.
|
|
636
|
+
</Step>
|
|
637
|
+
<Step title="$5Third Step">
|
|
638
|
+
$6These are instructions or content that only pertain to the third step.
|
|
639
|
+
</Step>
|
|
640
|
+
</Steps>`},{label:"container",kind:"snip",detail:"<Container> block",body:`<Container>
|
|
641
|
+
$1Content inside a styled container.
|
|
642
|
+
</Container>`},{label:"tabs",kind:"snip",detail:"<Tabs> component",body:`<Tabs>
|
|
643
|
+
<Tab title="$1Tab 1">
|
|
644
|
+
$2Content for tab 1
|
|
645
|
+
</Tab>
|
|
646
|
+
<Tab title="$3Tab 2">
|
|
647
|
+
$4Content for tab 2
|
|
648
|
+
</Tab>
|
|
649
|
+
</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
|
|
650
|
+
classDiagram
|
|
651
|
+
Animal <|-- Duck
|
|
652
|
+
Animal <|-- Fish
|
|
653
|
+
Animal : +int age
|
|
654
|
+
Animal : +String gender
|
|
655
|
+
Animal: +isMammal()
|
|
656
|
+
class Duck{
|
|
657
|
+
+String beakColor
|
|
658
|
+
+swim()
|
|
659
|
+
+quack()
|
|
660
|
+
}
|
|
661
|
+
\`\`\``},{label:"mermaid-state",kind:"snip",detail:"Mermaid state diagram",body:`\`\`\`mermaid
|
|
662
|
+
stateDiagram-v2
|
|
663
|
+
[*] --> Still
|
|
664
|
+
Still --> [*]
|
|
665
|
+
Still --> Moving
|
|
666
|
+
Moving --> Still
|
|
667
|
+
Moving --> Crash
|
|
668
|
+
Crash --> [*]
|
|
669
|
+
\`\`\``},{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
|
|
670
|
+
journey
|
|
671
|
+
title My working day
|
|
672
|
+
section Go to work
|
|
673
|
+
Make tea: 5: Me
|
|
674
|
+
Go upstairs: 3: Me
|
|
675
|
+
Do work: 1: Me, Cat
|
|
676
|
+
section Go home
|
|
677
|
+
Go downstairs: 5: Me
|
|
678
|
+
Sit down: 5: Me
|
|
679
|
+
\`\`\``},{label:"mermaid-gantt",kind:"snip",detail:"Mermaid Gantt chart",body:`\`\`\`mermaid
|
|
680
|
+
gantt
|
|
681
|
+
title A Gantt Diagram
|
|
682
|
+
dateFormat YYYY-MM-DD
|
|
683
|
+
section Section
|
|
684
|
+
A task :a1, 2014-01-01, 30d
|
|
685
|
+
Another task :after a1 , 20d
|
|
686
|
+
section Another
|
|
687
|
+
Task in sec :2014-01-12 , 12d
|
|
688
|
+
another task : 24d
|
|
689
|
+
\`\`\``},{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:`$$
|
|
690
|
+
$1E = mc^2
|
|
691
|
+
$$`},{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">
|
|
692
|
+
$2Description of the endpoint.
|
|
693
|
+
|
|
694
|
+
**Parameters:**
|
|
695
|
+
| Name | Type | Description |
|
|
696
|
+
|------|------|-------------|
|
|
697
|
+
| id | string | Resource ID |
|
|
698
|
+
|
|
699
|
+
**Response:**
|
|
700
|
+
\`\`\`json
|
|
701
|
+
{
|
|
702
|
+
"status": "success",
|
|
703
|
+
"data": {}
|
|
704
|
+
}
|
|
705
|
+
\`\`\`
|
|
706
|
+
</Endpoint>`},{label:"endpoint-post",kind:"snip",detail:"<Endpoint> POST block",body:`<Endpoint method="POST" path="$1/api/v1/resource">
|
|
707
|
+
$2Description of the endpoint.
|
|
708
|
+
|
|
709
|
+
**Body:**
|
|
710
|
+
| Name | Type | Description |
|
|
711
|
+
|------|------|-------------|
|
|
712
|
+
| name | string | Resource name |
|
|
713
|
+
|
|
714
|
+
**Response:**
|
|
715
|
+
\`\`\`json
|
|
716
|
+
{
|
|
717
|
+
"status": "created",
|
|
718
|
+
"data": {}
|
|
719
|
+
}
|
|
720
|
+
\`\`\`
|
|
721
|
+
</Endpoint>`},{label:"endpoint-put",kind:"snip",detail:"<Endpoint> PUT block",body:`<Endpoint method="PUT" path="$1/api/v1/resource/{id}">
|
|
722
|
+
$2Update an existing resource.
|
|
723
|
+
|
|
724
|
+
**Body:**
|
|
725
|
+
| Name | Type | Description |
|
|
726
|
+
|------|------|-------------|
|
|
727
|
+
| name | string | Updated name |
|
|
728
|
+
|
|
729
|
+
**Response:**
|
|
730
|
+
\`\`\`json
|
|
731
|
+
{
|
|
732
|
+
"status": "updated",
|
|
733
|
+
"data": {}
|
|
734
|
+
}
|
|
735
|
+
\`\`\`
|
|
736
|
+
</Endpoint>`},{label:"endpoint-patch",kind:"snip",detail:"<Endpoint> PATCH block",body:`<Endpoint method="PATCH" path="$1/api/v1/resource/{id}">
|
|
737
|
+
$2Partially update a resource.
|
|
738
|
+
|
|
739
|
+
**Body:**
|
|
740
|
+
| Name | Type | Description |
|
|
741
|
+
|------|------|-------------|
|
|
742
|
+
| field | string | Field to update |
|
|
743
|
+
|
|
744
|
+
**Response:**
|
|
745
|
+
\`\`\`json
|
|
746
|
+
{
|
|
747
|
+
"status": "updated",
|
|
748
|
+
"data": {}
|
|
749
|
+
}
|
|
750
|
+
\`\`\`
|
|
751
|
+
</Endpoint>`},{label:"endpoint-delete",kind:"snip",detail:"<Endpoint> DELETE block",body:`<Endpoint method="DELETE" path="$1/api/v1/resource/{id}">
|
|
752
|
+
$2Delete a resource by ID.
|
|
753
|
+
|
|
754
|
+
**Response:**
|
|
755
|
+
\`\`\`json
|
|
756
|
+
{
|
|
757
|
+
"status": "deleted"
|
|
758
|
+
}
|
|
759
|
+
\`\`\`
|
|
760
|
+
</Endpoint>`}];class mt{constructor(e){this.tocCollapsed=!1,this.themeObserver=null,this.events=new De,this.renderer=new ie,this.renderTimer=null,this._destroyed=!1,this._userCompletions=[],this._userTokenProviders=[],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 xe(this,this.events);const t=this.config.toolbar||[this.getDefaultToolbar()];this.toolbar=new ve(t,this.pluginManager,this,this.events);const i=()=>{this._refreshCompletions(),this._refreshTokenProvider(),this.toolbar.render(this.toolbarLeft),this.renderPreview(),this.refreshToc()};this.config.plugins?this.registerPlugins(this.config.plugins).then(i):i(),this.editorHost.addEventListener("keydown",s=>{var a;if(!(s.metaKey||s.ctrlKey))return;const r=((a=this.pluginManager)==null?void 0:a.getShortcuts())??[];for(const l of r)if(this.matchShortcut(s,l.key)){s.preventDefault(),s.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",s=>{typeof s=="string"&&this.config.onChange(s)})}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 s=e.dataset.theme;if(s==="dark")return!0;if(s==="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?de:ce),this.codeEditor.updateConfig({tokenColors:pt(e?de:ce)})}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 zs(this.editorHost,{showGutter:!0,wordWrap:!0,bracketMatching:!0,showIndentGuides:!0,multiCursor:!1,autocomplete:!0,wordHighlight:!1,emmet:!1,codeFolding:!1,showMinimap:!1,find:!1,findReplace:!1,value:e,language:"markdown",theme:this.isDarkMode()?de:ce,showStatusBar:!1,extraKeywords:["import","export","default","from","as","true","false","null","undefined"],completions:[...pe,...ut],replaceBuiltins:!0,provideCompletions:i=>{const s=i.line.slice(0,i.col),o=s.match(/<([A-Za-z]*)$/);if(o){const a=o[1].toLowerCase();return pe.filter(l=>l.kind==="cls"&&(a===""||l.label.toLowerCase().startsWith(a)))}const r=s.match(/<[A-Za-z][\w.]*(?:\s+[\w-]*="[^"]*"\s*)*\s+([A-Za-z]*)$/);if(r){const a=r[1].toLowerCase();return pe.filter(l=>l.kind==="var"&&(a===""||l.label.toLowerCase().startsWith(a)))}return null},tokenColors:pt(this.isDarkMode()?de:ce),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(he[i.key]){const s=this.getSelection();if(s.text){i.preventDefault(),i.stopImmediatePropagation();const o=i.key,r=he[o],a=this.codeEditor.getValue(),l=a.substring(0,s.start)+o+s.text+r+a.substring(s.end);this.codeEditor.setValue(l),this.setSelection(s.start+1,s.end+1);return}}if(i.key==="Backspace"){const s=this.getSelection();if(s.start===s.end&&s.start>0){const o=this.codeEditor.getValue(),r=o[s.start-1],a=o[s.start];if(he[r]&&he[r]===a){i.preventDefault(),i.stopImmediatePropagation();const l=o.substring(0,s.start-1)+o.substring(s.start+1);this.codeEditor.setValue(l),this.setSelection(s.start-1,s.start-1);return}}}if(i.key===">"){const s=this.getSelection(),o=this.codeEditor.getValue(),a=o.substring(0,s.start).match(/<([A-Za-z][A-Za-z0-9.-]*)(?:\s[^>]*)?\s*$/);if(a){const l=a[1];if(!Gs.has(l.toLowerCase())){i.preventDefault(),i.stopImmediatePropagation();const c=`></${l}>`,d=o.substring(0,s.start)+c+o.substring(s.end);this.codeEditor.setValue(d),this.setSelection(s.start+1,s.start+1);return}}}}},!0),this.textarea.value=e,this.setupThemeObserver(),this.updateStatusBar()}_refreshCompletions(){!this.codeEditor||!this.pluginManager||this.codeEditor.updateConfig({completions:[...pe,...ut,...this.pluginManager.getCompletions(),...this._userCompletions]})}registerAutoComplete(e){const t=Array.isArray(e)?e:[e];this._userCompletions.push(...t),this._refreshCompletions()}_refreshTokenProvider(){if(!this.codeEditor||!this.pluginManager)return;const e=this.pluginManager.getTokenProviders();this.codeEditor.updateConfig({provideTokens:ht(e,this._userTokenProviders)})}registerSyntaxHighlighter(e){const t=Array.isArray(e)?e:[e];this._userTokenProviders.push(...t),this._refreshTokenProvider()}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",s=>{const o=s.target,r=o.closest("[data-smdx-tab-btn]");if(r){const d=r.closest(".smdx-tabs");if(d){const h=parseInt(r.dataset.tabIndex??"0",10);d.querySelectorAll(".smdx-tab-btn").forEach(p=>p.classList.remove("smdx-active")),r.classList.add("smdx-active"),d.querySelectorAll(".smdx-tab-panel").forEach((p,u)=>{p.style.display=u===h?"block":"none"})}return}const a=o.closest("[data-copy-btn]");if(!a)return;const l=a.closest(".smdx-code-block"),c=l==null?void 0:l.querySelector("code");c&&navigator.clipboard.writeText(c.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 se(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,s=0;for(let o=0;o<e&&o<t.length;o++)t[o]===`
|
|
761
|
+
`?(i++,s=0):s++;return{row:i,col:s}}posToOffset(e,t){const i=this.codeEditor.getValue().split(`
|
|
762
|
+
`);let s=0;for(let o=0;o<e&&o<i.length;o++)s+=i[o].length+1;return s+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("+"),s=i.includes("cmd")||i.includes("meta")||i.includes("ctrl"),o=i.includes("shift"),r=i.includes("alt"),a=i.find(c=>!["cmd","meta","ctrl","shift","alt"].includes(c));return a?(e.metaKey||e.ctrlKey)===s&&e.shiftKey===o&&e.altKey===r&&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(),s=e.length,{lineNum:o,colNum:r}=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=`
|
|
763
|
+
<span class="smdx-status-item">Ln ${o}, Col ${r}</span>
|
|
764
|
+
<span class="smdx-status-sep">|</span>
|
|
765
|
+
<span class="smdx-status-item">${i} lines</span>
|
|
766
|
+
<span class="smdx-status-sep">|</span>
|
|
767
|
+
<span class="smdx-status-item">${t} words</span>
|
|
768
|
+
<span class="smdx-status-sep">|</span>
|
|
769
|
+
<span class="smdx-status-item">${s} characters</span>
|
|
770
|
+
<span class="smdx-status-sep">|</span>
|
|
771
|
+
<span class="smdx-status-item">MDX</span>
|
|
772
|
+
<span class="smdx-status-sep">|</span>
|
|
773
|
+
<span class="smdx-status-item">UTF-8</span>
|
|
774
|
+
${a}
|
|
775
|
+
`}updateModeButtons(e){e.innerHTML="";const t=document.createElement("div");t.className="smdx-mode-switch",["editor","split","preview"].forEach(i=>{const s=document.createElement("button");s.type="button",s.className=`smdx-mode-btn${i===this.mode?" smdx-active":""}`,s.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'};s.innerHTML=o[i],s.setAttribute("aria-label",`${i.charAt(0).toUpperCase()+i.slice(1)} mode`),s.setAttribute("aria-pressed",String(i===this.mode)),s.addEventListener("click",()=>this.setMode(i)),t.appendChild(s)}),e.appendChild(t)}buildTocPanel(){if(this.tocContainer.innerHTML="",this.tocCollapsed){this.tocContainer.classList.add("smdx-toc-collapsed");const s=document.createElement("button");s.className="smdx-toc-expand-btn",s.type="button",s.title="Show table of contents",s.setAttribute("aria-label","Show table of contents"),s.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>',s.addEventListener("click",()=>{this.tocCollapsed=!1,this.buildTocPanel(),this.refreshToc()}),this.tocContainer.appendChild(s);return}this.tocContainer.classList.remove("smdx-toc-collapsed");const e=document.createElement("div");e.className="smdx-toc-header",e.innerHTML=`
|
|
776
|
+
<div class="smdx-toc-title">
|
|
777
|
+
<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>
|
|
778
|
+
<span>CONTENTS</span>
|
|
779
|
+
</div>
|
|
780
|
+
<button class="smdx-toc-close-btn" type="button" title="Hide table of contents" aria-label="Hide table of contents">
|
|
781
|
+
<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>
|
|
782
|
+
</button>
|
|
783
|
+
`,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,s=[];let o=!1;for(const r of i.split(`
|
|
784
|
+
`)){if(r.trim().startsWith("```")){o=!o;continue}if(o)continue;const a=r.match(/^(#{1,6})\s+(.+)/);if(a){const l=a[1].length,c=a[2].replace(/[*_`~\[\]]/g,"").trim(),d=c.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-");s.push({level:l,text:c,slug:d})}}if(s.length===0)e.innerHTML='<div class="smdx-toc-empty">No headings found.</div>';else{const r=document.createElement("nav");r.className="smdx-toc-nav";const a=this.previewContent;s.forEach(l=>{const c=document.createElement("button");c.type="button",c.className=`smdx-toc-item smdx-toc-h${l.level}`,c.style.paddingLeft=`${(l.level-1)*12+8}px`,c.textContent=l.text,c.title=l.text,c.addEventListener("click",()=>{const d=a.querySelector(`#${CSS.escape(l.slug)}`);d&&d.scrollIntoView({behavior:"smooth",block:"start"})}),r.appendChild(c)}),e.innerHTML="",e.appendChild(r)}t.textContent=`${s.length} heading${s.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:s,text:o}=this.getSelection(),r=this.codeEditor.getValue(),a=o||"text",l=e+a+t,c=r.substring(0,i)+l+r.substring(s);this.codeEditor.setValue(c);const d=i+e.length,h=d+a.length;this.setSelection(d,h),this.codeEditor.focus()}replaceSelection(e){const{start:t,end:i}=this.getSelection(),s=this.codeEditor.getValue(),o=s.substring(0,t)+e+s.substring(i);this.codeEditor.setValue(o);const r=this.offsetToPos(t+e.length);this.codeEditor.setCursor(r),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 s=this.posToOffset(t.ar,t.ac),o=this.posToOffset(t.fr,t.fc),r=Math.min(s,o),a=Math.max(s,o);return{start:r,end:a,text:e.substring(r,a),beforeText:e.substring(0,r),afterText:e.substring(a)}}setSelection(e,t){const i=this.offsetToPos(e),s=this.offsetToPos(t),o={ar:i.row,ac:i.col,fr:s.row,fc:s.col};this.codeEditor.setSelection(o),this.codeEditor.focus()}insertBlock(e){const{start:t,end:i}=this.getSelection(),s=this.codeEditor.getValue(),o=s.substring(0,t),r=s.substring(i),a=o.length>0&&!o.endsWith(`
|
|
785
|
+
`),l=r.length>0&&!r.startsWith(`
|
|
786
|
+
`),c=(a?`
|
|
787
|
+
|
|
788
|
+
`:"")+e+(l?`
|
|
789
|
+
|
|
790
|
+
`:""),d=o+c+r;this.codeEditor.setValue(d);const h=this.offsetToPos(o.length+c.length);this.codeEditor.setCursor(h),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._refreshTokenProvider(),this.toolbarLeft.innerHTML="",this.toolbar.render(this.toolbarLeft),this.renderPreview()})}unregisterPlugin(e){this.pluginManager.unregister(e),this._refreshCompletions(),this._refreshTokenProvider(),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(`
|
|
791
|
+
`)[e.row]??""}getCurrentLineNumber(){return this.codeEditor.getCursor().row+1}replaceCurrentLine(e){const t=this.codeEditor.getCursor(),i=this.codeEditor.getValue().split(`
|
|
792
|
+
`);i[t.row]=e,this.codeEditor.setValue(i.join(`
|
|
793
|
+
`)),this.codeEditor.setCursor({row:t.row,col:e.length})}insertAt(e,t){const i=this.codeEditor.getValue(),s=i.substring(0,e)+t+i.substring(e);this.codeEditor.setValue(s);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(`
|
|
794
|
+
`).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 Vs{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 $={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 gt(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:$.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(n=>({id:`h${n}`,label:`Heading ${n}`,icon:$[`h${n}`],tooltip:`Heading ${n}`,...n<=3?{shortcutLabel:`⌘${n}`}:{},action:({editor:e})=>{const t="#".repeat(n)+" ",s=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+s)}})),action:({editor:n})=>{const e=n.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),s=e.replace(/^#{1,6}\s*/,"");n.replaceCurrentLine("#".repeat(i)+" "+s)}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"}],provideTokens:n=>{const e=n.match(/^(#{1,6}) /);return e?[{cls:"kw",start:0,end:e[1].length}]:[]}}}function bt(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:$.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"}],provideTokens:n=>{const e=[];for(const t of n.matchAll(new RegExp("(\\*\\*|__)(?!\\s)(.+?)(?<!\\s)\\1","g")))e.push({cls:"num",start:t.index,end:t.index+t[0].length});return e}}}function ft(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:$.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"}],provideTokens:n=>{const e=[];for(const t of n.matchAll(new RegExp("(?<!\\*)\\*(?!\\*)(?!\\s)(.+?)(?<!\\s)\\*(?!\\*)|(?<!_)_(?!_)(?!\\s)(.+?)(?<!\\s)_(?!_)","g")))e.push({cls:"fn",start:t.index,end:t.index+t[0].length});return e}}}function xt(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:$.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:n})=>n.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:n})=>n.wrapSelection("~~","~~"),description:"Strikethrough"}],provideTokens:n=>{const e=[];for(const t of n.matchAll(/~~(.+?)~~/g))e.push({cls:"cmt",start:t.index,end:t.index+t[0].length});return e}}}function yt(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:$.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"}],provideTokens:n=>{const e=n.match(/^(\s*>+\s?)/);return e?[{cls:"kw",start:0,end:e[1].length}]:[]}}}function vt(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:$.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"}],provideTokens:n=>{const e=[];for(const t of n.matchAll(/\[([^\]]+)\]\(([^)]*)\)/g)){const i=t.index+1+t[1].length+1;e.push({cls:"fn",start:t.index,end:i}),e.push({cls:"str",start:i,end:t.index+t[0].length})}return e}}}function wt(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:$.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"}],provideTokens:n=>{const e=[];for(const t of n.matchAll(/!\[([^\]]*)\]\(([^)]*)\)/g)){const i=t.index+2+t[1].length+1;e.push({cls:"fn",start:t.index,end:i}),e.push({cls:"str",start:i,end:t.index+t[0].length})}return e}}}function kt(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:$.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:n})=>n.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:$.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"}],provideTokens:n=>{const e=[],t=n.match(/^(`{3,}|~{3,})([\w-]*)/);if(t)return e.push({cls:"kw",start:0,end:t[1].length}),t[2]&&e.push({cls:"typ",start:t[1].length,end:t[1].length+t[2].length}),e;for(const i of n.matchAll(/`([^`]+)`/g))e.push({cls:"str",start:i.index,end:i.index+i[0].length});return e}}}function _t(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:$.unorderedList,tooltip:"Bullet List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^[-*]\s/)?n.replaceCurrentLine(e.replace(/^[-*]\s/,"")):n.replaceCurrentLine("- "+e)}}],provideTokens:n=>{const e=n.match(/^(\s*)([-*+]) /);return e?[{cls:"op",start:e[1].length,end:e[1].length+1}]:[]}}}function Ct(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:$.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)}}],provideTokens:n=>{const e=n.match(/^(\s*)(\d+\.) /);return e?[{cls:"op",start:e[1].length,end:e[1].length+e[2].length}]:[]}}}function Tt(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:$.taskList,tooltip:"Task List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^- \[[ x]\]\s/)?n.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):n.replaceCurrentLine("- [ ] "+e)}}],provideTokens:n=>{const e=[],t=n.match(/^(\s*)([-*+]) (\[[ x]\] )/);if(t){const i=t[1].length;e.push({cls:"op",start:i,end:i+1});const s=i+2;e.push({cls:"kw",start:s,end:s+t[3].trimEnd().length})}return e}}}function St(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:$.table,tooltip:"Insert Table",action:({editor:n})=>{n.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
19
795
|
| -------- | -------- | -------- |
|
|
20
796
|
| Cell 1 | Cell 2 | Cell 3 |
|
|
21
|
-
| Cell 4 | Cell 5 | Cell 6 |`)}}]}}const
|
|
797
|
+
| Cell 4 | Cell 5 | Cell 6 |`)}}],provideTokens:n=>{if(!n.trim().startsWith("|"))return[];const e=[];for(const t of n.matchAll(/\|/g))e.push({cls:"op",start:t.index,end:t.index+1});return e}}}const Us=[{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 Et(){return{name:"highlight",toolbarItems:[{id:"highlight",label:"Highlight",icon:$.highlight,tooltip:"Highlight Text",children:Us.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}}],provideTokens:D(["Highlight"]),styles:`
|
|
22
798
|
.smdx-highlight { padding: 2px 4px; border-radius: 3px; }
|
|
23
799
|
.smdx-highlight-yellow { background-color: #fef08a; }
|
|
24
800
|
.smdx-highlight-green { background-color: #bbf7d0; }
|
|
@@ -37,11 +813,11 @@
|
|
|
37
813
|
.smdx-dark .smdx-highlight-orange { background-color: #9a3412; color: #fed7aa; }
|
|
38
814
|
.smdx-dark .smdx-highlight-cyan { background-color: #155e75; color: #a5f3fc; }
|
|
39
815
|
.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; }
|
|
40
|
-
`}}const
|
|
41
|
-
${
|
|
42
|
-
:::`)}})),action:({editor:
|
|
816
|
+
`}}const Re=[{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 Mt(){const n=Re.map(t=>t.type).join("|"),e=new RegExp(`^(:::)(${n})`);return{name:"admonition",toolbarItems:[{id:"admonition",label:"Admonition",icon:$.admonition,tooltip:"Admonition / Callout",children:Re.map(t=>({id:`admonition-${t.type}`,label:t.label,icon:t.icon,tooltip:`${t.label} callout`,action:({editor:i})=>{i.insertBlock(`:::${t.type}
|
|
817
|
+
${t.label}: Your message here
|
|
818
|
+
:::`)}})),action:({editor:t})=>{t.insertBlock(`:::info
|
|
43
819
|
INFO: Your message here
|
|
44
|
-
:::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:
|
|
820
|
+
:::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:t=>{const i=t.match(/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/);if(!i)return t;const s=Re.find(r=>r.type===i[1]),o=i[2]||s.label;return`<div class="smdx-admonition smdx-admonition-${i[1]}"><div class="smdx-admonition-title"><span class="smdx-admonition-icon">${s.icon}</span>${o}</div><div class="smdx-admonition-content">${i[3]}</div></div>`},priority:10}],styles:`
|
|
45
821
|
.smdx-admonition { padding: 14px 16px; border-radius: 6px; margin: 12px 0; border-left: 4px solid; }
|
|
46
822
|
.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; }
|
|
47
823
|
.smdx-admonition-icon { display: flex; align-items: center; flex-shrink: 0; }
|
|
@@ -70,42 +846,42 @@ INFO: Your message here
|
|
|
70
846
|
.smdx-dark .smdx-admonition-info { background: #172554; }
|
|
71
847
|
.smdx-dark .smdx-admonition-note { background: #2e1065; }
|
|
72
848
|
.smdx-dark .smdx-admonition-content { color: var(--smdx-text, #e2e8f0); }
|
|
73
|
-
|
|
74
|
-
`),t=e.filter(
|
|
75
|
-
`).trim():
|
|
849
|
+
`,provideTokens:t=>{const i=[],s=t.match(e);return s?(i.push({cls:"kw",start:0,end:3}),i.push({cls:"cls",start:3,end:3+s[2].length})):t===":::"&&i.push({cls:"kw",start:0,end:3}),i}}}function qs(n){const e=n.split(`
|
|
850
|
+
`),t=e.filter(s=>s.trim().length>0),i=t.length>0?Math.min(...t.map(s=>s.match(/^\s*/)[0].length)):0;return i>0?e.map(s=>s.slice(i)).join(`
|
|
851
|
+
`).trim():n.trim()}function Lt(){return{name:"tab",toolbarItems:[{id:"tab",label:"Tab",icon:$.tab,tooltip:"Insert Tabs",action:({editor:n})=>{n.insertBlock(`<Tabs>
|
|
76
852
|
<Tab title="Tab 1">
|
|
77
853
|
Content for tab 1
|
|
78
854
|
</Tab>
|
|
79
855
|
<Tab title="Tab 2">
|
|
80
856
|
Content for tab 2
|
|
81
857
|
</Tab>
|
|
82
|
-
</Tabs>`)}}],renderers:[{name:"tabs",pattern:/<Tabs>([\s\S]*?)<\/Tabs>/
|
|
858
|
+
</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:qs(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((r,a)=>{o+=`<button class="smdx-tab-btn${a===0?" smdx-active":""}" data-smdx-tab-btn="true" data-tab-index="${a}">${r.title}</button>`}),o+="</div>",t.forEach((r,a)=>{o+=`<div class="smdx-tab-panel" style="display:${a===0?"block":"none"}">${r.content}</div>`}),o+="</div>",o},priority:15}],styles:`
|
|
83
859
|
.smdx-tabs { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
84
860
|
.smdx-tabs-header { display: flex; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
85
861
|
.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; }
|
|
86
862
|
.smdx-tab-btn:hover { color: var(--smdx-text, #1e293b); }
|
|
87
863
|
.smdx-tab-btn.smdx-active { color: var(--smdx-primary, #6366f1); border-bottom-color: var(--smdx-primary, #6366f1); background: var(--smdx-bg, #fff); }
|
|
88
864
|
.smdx-tab-panel { padding: 16px; }
|
|
89
|
-
|
|
865
|
+
`,provideTokens:D(["Tabs","Tab"])}}function $t(){return{name:"imageBackground",toolbarItems:[{id:"imageBackground",label:"Image Background",icon:$.imageBackground,tooltip:"Image with Background",action:({editor:n})=>{n.insertBlock(`<ImageBackground src="image-url" alt="description" background="#f0f0f0">
|
|
90
866
|
Content overlaying the image
|
|
91
|
-
</ImageBackground>`)}}],renderers:[{name:"imageBackground",pattern:/<ImageBackground\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+background="([^"]*)")?\s*>([\s\S]*?)<\/ImageBackground>/
|
|
867
|
+
</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]})`}">
|
|
92
868
|
<div class="smdx-image-bg-overlay">${e[4].trim()}</div>
|
|
93
|
-
</div>`:
|
|
869
|
+
</div>`:n}}],styles:`
|
|
94
870
|
.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); }
|
|
95
871
|
.smdx-image-bg-overlay { background: rgba(0,0,0,0.5); color: white; padding: 24px; width: 100%; text-align: center; }
|
|
96
872
|
.smdx-dark .smdx-image-bg-overlay { background: rgba(0,0,0,0.6); }
|
|
97
|
-
|
|
873
|
+
`,provideTokens:D(["ImageBackground"])}}function At(){return{name:"imageFrame",toolbarItems:[{id:"imageFrame",label:"Image Frame",icon:$.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">
|
|
98
874
|
<img src="${e[1]}" alt="${e[2]||""}" />
|
|
99
875
|
${e[3]?`<figcaption>${e[3]}</figcaption>`:""}
|
|
100
|
-
</figure>`:
|
|
876
|
+
</figure>`:n}}],styles:`
|
|
101
877
|
.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); }
|
|
102
878
|
.smdx-image-frame img { width: 100%; border-radius: 4px; display: block; }
|
|
103
879
|
.smdx-image-frame figcaption { text-align: center; padding: 8px 0 4px; font-size: 0.85em; color: var(--smdx-text-muted, #64748b); }
|
|
104
|
-
|
|
105
|
-
`),t=e.filter(
|
|
106
|
-
`).trim():
|
|
880
|
+
`,provideTokens:D(["ImageFrame"])}}function Bt(n){const e=n.split(`
|
|
881
|
+
`),t=e.filter(s=>s.trim().length>0),i=t.length>0?Math.min(...t.map(s=>s.match(/^\s*/)[0].length)):0;return i>0?e.map(s=>s.slice(i)).join(`
|
|
882
|
+
`).trim():n.trim()}function It(){return{name:"accordion",toolbarItems:[{id:"accordion",label:"Accordion",icon:$.accordion,tooltip:"Insert Accordion",action:({editor:n})=>{n.insertBlock(`<Accordion title="Accordion Title" defaultOpen>
|
|
107
883
|
Your content here. You can include any markdown or components.
|
|
108
|
-
</Accordion>`)}}],renderers:[{name:"accordion",pattern:/<Accordion\s+title="([^"]*)"(
|
|
884
|
+
</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">${Bt(e[3])}</div></details>`:n},priority:12}],styles:`
|
|
109
885
|
.smdx-accordion { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; margin: 8px 0; overflow: hidden; background: var(--smdx-bg, #fff); }
|
|
110
886
|
.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); }
|
|
111
887
|
.smdx-accordion-header::-webkit-details-marker { display: none; }
|
|
@@ -115,7 +891,7 @@ INFO: Your message here
|
|
|
115
891
|
.smdx-accordion-content { padding: 14px 18px 18px 18px; border-top: 1px solid var(--smdx-border, #e2e8f0); }
|
|
116
892
|
.smdx-accordion-content p { margin: 6px 0; }
|
|
117
893
|
.smdx-accordion-content > :last-child { margin-bottom: 0; }
|
|
118
|
-
|
|
894
|
+
`,provideTokens:D(["Accordion"])}}function Rt(){return{name:"accordionGroup",dependencies:["accordion"],toolbarItems:[{id:"accordionGroup",label:"Accordion Group",icon:$.accordionGroup,tooltip:"Insert Accordion Group",action:({editor:n})=>{n.insertBlock(`<AccordionGroup>
|
|
119
895
|
<Accordion title="Section 1" defaultOpen>
|
|
120
896
|
Content for section 1
|
|
121
897
|
</Accordion>
|
|
@@ -125,36 +901,36 @@ INFO: Your message here
|
|
|
125
901
|
<Accordion title="Section 3">
|
|
126
902
|
Content for section 3
|
|
127
903
|
</Accordion>
|
|
128
|
-
</AccordionGroup>`)}}],renderers:[{name:"accordionGroup",pattern:/<AccordionGroup>([\s\S]*?)<\/AccordionGroup>/
|
|
904
|
+
</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:`
|
|
129
905
|
.smdx-accordion-group { display: flex; flex-direction: column; gap: 0; margin: 12px 0; }
|
|
130
906
|
.smdx-accordion-group > :not(.smdx-accordion) { display: none; }
|
|
131
907
|
.smdx-accordion-group .smdx-accordion { margin: 0; border-radius: 0; border-bottom: none; }
|
|
132
908
|
.smdx-accordion-group .smdx-accordion:first-of-type { border-radius: 8px 8px 0 0; }
|
|
133
909
|
.smdx-accordion-group .smdx-accordion:last-of-type { border-radius: 0 0 8px 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
134
|
-
|
|
135
|
-
Column ${
|
|
910
|
+
`,provideTokens:D(["AccordionGroup"])}}function Pt(){return{name:"multiColumn",toolbarItems:[{id:"multiColumn",label:"Columns",icon:$.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,s)=>` <Column>
|
|
911
|
+
Column ${s+1} content
|
|
136
912
|
</Column>`).join(`
|
|
137
|
-
`);e.insertBlock(`<Columns count="${
|
|
913
|
+
`);e.insertBlock(`<Columns count="${n}">
|
|
138
914
|
${t}
|
|
139
|
-
</Columns>`)}})),action:({editor:
|
|
915
|
+
</Columns>`)}})),action:({editor:n})=>{n.insertBlock(`<Columns count="2">
|
|
140
916
|
<Column>
|
|
141
917
|
Column 1 content
|
|
142
918
|
</Column>
|
|
143
919
|
<Column>
|
|
144
920
|
Column 2 content
|
|
145
921
|
</Column>
|
|
146
|
-
</Columns>`)}}],renderers:[{name:"columns",pattern:/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/
|
|
147
|
-
`;for(const a of
|
|
922
|
+
</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 s=[],o;for(;(o=i.exec(e[2]))!==null;)s.push(Bt(o[1]));let r=`<div class="smdx-columns" style="grid-template-columns:repeat(${t},1fr)">
|
|
923
|
+
`;for(const a of s)r+=`<div class="smdx-column">
|
|
148
924
|
${a}
|
|
149
925
|
</div>
|
|
150
|
-
`;return
|
|
926
|
+
`;return r+="</div>",r},priority:13}],styles:`
|
|
151
927
|
.smdx-columns { display: grid; gap: 16px; margin: 12px 0; }
|
|
152
928
|
.smdx-column { padding: 12px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 6px; }
|
|
153
|
-
|
|
154
|
-
`),t=e.filter(
|
|
155
|
-
`).trim():
|
|
929
|
+
`,provideTokens:D(["Columns","Column"])}}function Ks(n){const e=n.split(`
|
|
930
|
+
`),t=e.filter(s=>s.trim().length>0),i=t.length>0?Math.min(...t.map(s=>s.match(/^\s*/)[0].length)):0;return i>0?e.map(s=>s.slice(i)).join(`
|
|
931
|
+
`).trim():n.trim()}function Ht(){return{name:"card",toolbarItems:[{id:"card",label:"Card",icon:$.card,tooltip:"Insert Card",action:({editor:n})=>{n.insertBlock(`<Card title="Card Title" icon="📄" href="/link">
|
|
156
932
|
Card description or content goes here.
|
|
157
|
-
</Card>`)}}],renderers:[{name:"card",pattern:/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/
|
|
933
|
+
</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"`:"",s=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">${s}<span class="smdx-card-title">${e[1]}</span>${o}</div><div class="smdx-card-content">${Ks(e[4])}</div></${t}>`},priority:11}],styles:`
|
|
158
934
|
.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); }
|
|
159
935
|
a.smdx-card { cursor: pointer; }
|
|
160
936
|
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); }
|
|
@@ -164,7 +940,7 @@ ${a}
|
|
|
164
940
|
.smdx-card-arrow { margin-left: auto; flex-shrink: 0; color: var(--smdx-text-muted, #94a3b8); transition: transform 0.2s, color 0.2s; }
|
|
165
941
|
a.smdx-card:hover .smdx-card-arrow { transform: translateX(2px); color: var(--smdx-primary, #6366f1); }
|
|
166
942
|
.smdx-card-content { font-size: 0.9em; color: var(--smdx-text-muted, #64748b); line-height: 1.5; }
|
|
167
|
-
|
|
943
|
+
`,provideTokens:D(["Card"])}}function Dt(){return{name:"cardGroup",dependencies:["card"],toolbarItems:[{id:"cardGroup",label:"Card Group",icon:$.cardGroup,tooltip:"Insert Card Group",action:({editor:n})=>{n.insertBlock(`<CardGroup cols="2">
|
|
168
944
|
<Card title="Card 1" icon="📄">
|
|
169
945
|
Description for card 1
|
|
170
946
|
</Card>
|
|
@@ -177,12 +953,12 @@ ${a}
|
|
|
177
953
|
<Card title="Card 4" icon="💡">
|
|
178
954
|
Description for card 4
|
|
179
955
|
</Card>
|
|
180
|
-
</CardGroup>`)}}],renderers:[{name:"cardGroup",pattern:/<CardGroup(?:\s+cols="(\d+)")?\s*>([\s\S]*?)<\/CardGroup>/
|
|
956
|
+
</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:`
|
|
181
957
|
.smdx-card-group { display: grid; gap: 12px; margin: 12px 0; }
|
|
182
958
|
.smdx-card-group .smdx-card { margin: 0; }
|
|
183
|
-
|
|
184
|
-
`),t=e.filter(
|
|
185
|
-
`).trim():
|
|
959
|
+
`,provideTokens:D(["CardGroup"])}}function jt(n){const e=n.split(`
|
|
960
|
+
`),t=e.filter(s=>s.trim().length>0),i=t.length>0?Math.min(...t.map(s=>s.match(/^\s*/)[0].length)):0;return i>0?e.map(s=>s.slice(i)).join(`
|
|
961
|
+
`).trim():n.trim()}function Nt(){return{name:"step",toolbarItems:[{id:"steps",label:"Steps",icon:$.step,tooltip:"Insert Steps",action:({editor:n})=>{n.insertBlock(`<Steps>
|
|
186
962
|
<Step title="First Step">
|
|
187
963
|
These are instructions or content that only pertain to the first step.
|
|
188
964
|
</Step>
|
|
@@ -192,7 +968,7 @@ ${a}
|
|
|
192
968
|
<Step title="Third Step">
|
|
193
969
|
These are instructions or content that only pertain to the third step.
|
|
194
970
|
</Step>
|
|
195
|
-
</Steps>`)}}],renderers:[{name:"steps",pattern:/<Steps>([\s\S]*?)<\/Steps>/
|
|
971
|
+
</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=[],s;for(;(s=t.exec(e[1]))!==null;)i.push({title:s[1],content:jt(s[2])});let o='<div class="smdx-steps">';return i.forEach((r,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">${r.title}</div><div class="smdx-step-body">${r.content}</div></div></div>`}),o+="</div>",o},priority:15}],styles:`
|
|
196
972
|
.smdx-steps { margin: 20px 0; }
|
|
197
973
|
.smdx-step { display: flex; gap: 20px; position: relative; }
|
|
198
974
|
.smdx-step-indicator { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 34px; position: relative; }
|
|
@@ -202,7 +978,7 @@ ${a}
|
|
|
202
978
|
.smdx-step:last-child .smdx-step-content { padding-bottom: 0; }
|
|
203
979
|
.smdx-step-title { font-weight: 700; font-size: 1.05em; color: var(--smdx-text, #1e293b); margin-bottom: 8px; }
|
|
204
980
|
.smdx-step-body { color: var(--smdx-text-muted, #64748b); font-size: 0.95em; line-height: 1.7; }
|
|
205
|
-
|
|
981
|
+
`,provideTokens:D(["Steps","Step"])}}const Ot=[{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 Wt(){return{name:"tip",toolbarItems:[{id:"tip",label:"Tip",icon:$.tip,tooltip:"Insert Tip",children:Ot.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:Ot.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"),s=e.match(i);return s?`<div class="smdx-tip smdx-tip-${n.type}"><span class="smdx-tip-icon">${n.icon}</span><span class="smdx-tip-text">${s[1].trim()}</span></div>`:e},priority:10})),styles:`
|
|
206
982
|
.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; }
|
|
207
983
|
.smdx-tip-icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 1px; }
|
|
208
984
|
.smdx-tip-icon svg { display: block; }
|
|
@@ -213,12 +989,12 @@ ${a}
|
|
|
213
989
|
.smdx-dark .smdx-tip-good { background: #052e16; }
|
|
214
990
|
.smdx-dark .smdx-tip-bad { background: #450a0a; }
|
|
215
991
|
.smdx-dark .smdx-tip-info { background: #172554; }
|
|
216
|
-
|
|
992
|
+
`,provideTokens:D(["TipGood","TipBad","TipInfo"])}}function zt(){return{name:"container",toolbarItems:[{id:"container",label:"Container",icon:$.container,tooltip:"Insert Container",action:({editor:n})=>{n.insertBlock(`<Container>
|
|
217
993
|
Content inside a styled container.
|
|
218
|
-
</Container>`)}}],renderers:[{name:"container",pattern:/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/
|
|
994
|
+
</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">${jt(e[2])}</div></div>`:n}}],styles:`
|
|
219
995
|
.smdx-container { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; padding: 16px; margin: 12px 0; background: var(--smdx-bg-muted, #f8fafc); }
|
|
220
996
|
.smdx-container-title { font-weight: 600; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
221
|
-
|
|
997
|
+
`,provideTokens:D(["Container"])}}function Ft(){return{name:"copyText",toolbarItems:[{id:"copyText",label:"Copy Text",icon:$.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:`
|
|
222
998
|
.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; }
|
|
223
999
|
.smdx-copy-text:hover { border-color: var(--smdx-primary, #6366f1); }
|
|
224
1000
|
.smdx-copy-text.smdx-copied { border-color: #22c55e; background: #f0fdf4; }
|
|
@@ -227,7 +1003,7 @@ ${a}
|
|
|
227
1003
|
.smdx-copy-text:hover .smdx-copy-text-btn { color: var(--smdx-text, #1e293b); }
|
|
228
1004
|
.smdx-copy-text.smdx-copied .smdx-copy-text-btn { color: #22c55e; }
|
|
229
1005
|
.smdx-dark .smdx-copy-text.smdx-copied { background: #052e16; border-color: #166534; }
|
|
230
|
-
|
|
1006
|
+
`,provideTokens:D(["CopyText"])}}function Gt(){return{name:"tooltip",toolbarItems:[{id:"tooltip",label:"Tooltip",icon:$.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:`
|
|
231
1007
|
.smdx-tooltip-wrapper { position: relative; display: inline; }
|
|
232
1008
|
.smdx-tooltip-trigger { position: relative; border-bottom: 1px dashed var(--smdx-primary, #6366f1); cursor: help; text-decoration: none; }
|
|
233
1009
|
.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; }
|
|
@@ -235,8 +1011,8 @@ ${a}
|
|
|
235
1011
|
.smdx-tooltip-trigger:hover .smdx-tooltip-popup { visibility: visible; opacity: 1; }
|
|
236
1012
|
.smdx-dark .smdx-tooltip-popup { background: #e2e8f0; color: #1e293b; }
|
|
237
1013
|
.smdx-dark .smdx-tooltip-popup::after { border-top-color: #e2e8f0; }
|
|
238
|
-
|
|
239
|
-
<iframe src="https://www.youtube.com/embed/${encodeURIComponent(
|
|
1014
|
+
`,provideTokens:D(["Tooltip"])}}function Vt(){return{name:"embedVideo",toolbarItems:[{id:"embedVideo",label:"Embed Video",icon:$.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 s=i.match(/(?:v=|\/embed\/|youtu\.be\/)([\w-]+)/),o=s?s[1]:i;return`<div class="smdx-embed-video">
|
|
1015
|
+
<iframe src="https://www.youtube.com/embed/${encodeURIComponent(o)}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
|
|
240
1016
|
</div>`}return`<div class="smdx-embed-video">
|
|
241
1017
|
<video controls src="${i}" class="smdx-video-player">
|
|
242
1018
|
Your browser does not support the video tag.
|
|
@@ -244,7 +1020,7 @@ ${a}
|
|
|
244
1020
|
</div>`}}],styles:`
|
|
245
1021
|
.smdx-embed-video { position: relative; width: 100%; padding-top: 56.25%; margin: 12px 0; border-radius: 8px; overflow: hidden; background: #000; }
|
|
246
1022
|
.smdx-embed-video iframe, .smdx-embed-video video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
|
247
|
-
|
|
1023
|
+
`,provideTokens:D(["EmbedVideo"])}}function Ut(){return{name:"embedOthers",toolbarItems:[{id:"embedOthers",label:"Embed",icon:$.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 s=e[1],o=t?t[1]:"",r=i?i[1]:"";switch(s){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">${r||"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">${r||"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">${r||"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">${r||"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:`
|
|
248
1024
|
.smdx-embed { margin: 12px 0; border-radius: 8px; overflow: hidden; }
|
|
249
1025
|
.smdx-embed iframe { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; }
|
|
250
1026
|
.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; }
|
|
@@ -257,7 +1033,7 @@ ${a}
|
|
|
257
1033
|
.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; }
|
|
258
1034
|
.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; }
|
|
259
1035
|
.smdx-embed-card-link:hover { background: var(--smdx-bg-muted, #f8fafc); text-decoration: none; }
|
|
260
|
-
|
|
1036
|
+
`,provideTokens:D(["Embed"])}}const qt=[{id:"flowchart",label:"Flowchart",template:`graph TD
|
|
261
1037
|
Start --> Stop`},{id:"sequence",label:"Sequence Diagram",template:`sequenceDiagram
|
|
262
1038
|
Alice->>John: Hello John, how are you?
|
|
263
1039
|
John-->>Alice: Great!
|
|
@@ -307,7 +1083,7 @@ ${a}
|
|
|
307
1083
|
Another task :after a1 , 20d
|
|
308
1084
|
section Another
|
|
309
1085
|
Task in sec :2014-01-12 , 12d
|
|
310
|
-
another task : 24d`}];function
|
|
1086
|
+
another task : 24d`}];function Kt(){return{name:"mermaid",toolbarItems:[{id:"mermaid",label:"Mermaid",icon:$.mermaid,tooltip:"Insert Mermaid Diagram",children:qt.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"+qt[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 s=n.editor.getPreview();if(!s)return;const o=s.querySelectorAll(".smdx-mermaid[data-mermaid-code]");for(const r of Array.from(o)){const a=decodeURIComponent(r.getAttribute("data-mermaid-code")),l=r.getAttribute("data-mermaid-id");try{const{svg:c}=await t.render(l,a);r.innerHTML=c,r.removeAttribute("data-mermaid-code")}catch{r.innerHTML=`<pre class="smdx-mermaid-error">${a.replace(/</g,"<").replace(/>/g,">")}</pre>`,r.removeAttribute("data-mermaid-code")}}}catch{}};n.on("render",e)},styles:`
|
|
311
1087
|
.smdx-mermaid { margin: 12px 0; text-align: center; }
|
|
312
1088
|
.smdx-mermaid svg { max-width: 100%; height: auto; }
|
|
313
1089
|
.smdx-mermaid-placeholder { padding: 24px; color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
|
|
@@ -358,9 +1134,9 @@ ${a}
|
|
|
358
1134
|
.smdx-dark .smdx-mermaid .section0,
|
|
359
1135
|
.smdx-dark .smdx-mermaid .section1 { fill: #374151 !important; }
|
|
360
1136
|
.smdx-dark .smdx-mermaid .today { stroke: #818cf8 !important; }
|
|
361
|
-
`}}const
|
|
1137
|
+
`,provideTokens:n=>{const e=[],t=n.match(/^(`{3,})(mermaid)/);return t?(e.push({cls:"kw",start:0,end:t[1].length}),e.push({cls:"typ",start:t[1].length,end:t[1].length+t[2].length})):/^`{3,}\s*$/.test(n)&&e.push({cls:"kw",start:0,end:n.length}),e}}}const Pe=[["😀","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 Yt(){return{name:"emoji",toolbarItems:[{id:"emoji",label:"Emoji",icon:$.emoji,tooltip:"Insert Emoji",action:n=>{},render:(n,e)=>{n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),Ys(n,e.editor)})}}]}}function Ys(n,e){var c;(c=document.querySelector(".smdx-emoji-picker"))==null||c.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 s=document.createElement("input");s.type="text",s.placeholder="Search emoji...",s.className="smdx-emoji-search",t.appendChild(s);const o=document.createElement("div");o.className="smdx-emoji-grid";const r=d=>{o.innerHTML="";for(const[h]of d){const p=document.createElement("button");p.type="button",p.className="smdx-emoji-btn",p.textContent=h,p.addEventListener("click",()=>{e.insertText(h),t.remove()}),o.appendChild(p)}};r(Pe),s.addEventListener("input",()=>{const d=s.value.toLowerCase().trim();if(!d){r(Pe);return}r(Pe.filter(([,h])=>h.includes(d)))}),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=d=>{!t.contains(d.target)&&d.target!==n&&(t.remove(),document.removeEventListener("click",l))};setTimeout(()=>document.addEventListener("click",l),0),s.focus()}function Xt(){return{name:"formula",toolbarItems:[{id:"formula",label:"Formula",icon:$.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(`$$
|
|
362
1138
|
`+(e.text||"E = mc^2")+`
|
|
363
|
-
$$`)}}],action:({editor:
|
|
1139
|
+
$$`)}}],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:`
|
|
364
1140
|
.smdx-formula-block { text-align: center; margin: 16px 0; font-size: 1.2em; overflow-x: auto; }
|
|
365
1141
|
.smdx-formula-fallback { background: var(--smdx-bg-muted, #f8fafc); padding: 12px; border-radius: 6px; border: 1px solid var(--smdx-border, #e2e8f0); }
|
|
366
1142
|
.smdx-formula-inline { font-size: 0.95em; }
|
|
@@ -375,10 +1151,55 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
375
1151
|
.smdx-dark .smdx-emoji-search, .smdx-emoji-picker.smdx-dark .smdx-emoji-search { background: #2a2a3c; color: #e2e8f0; border-color: #374151; }
|
|
376
1152
|
.smdx-dark .smdx-emoji-search:focus, .smdx-emoji-picker.smdx-dark .smdx-emoji-search:focus { border-color: #818cf8; }
|
|
377
1153
|
.smdx-dark .smdx-emoji-btn:hover, .smdx-emoji-picker.smdx-dark .smdx-emoji-btn:hover { background: #2a2a3c; }
|
|
378
|
-
|
|
379
|
-
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(
|
|
380
|
-
`).slice(a-1,
|
|
381
|
-
`)}async function i(
|
|
1154
|
+
`,provideTokens:n=>{const e=[];if(/^\$\$\s*$/.test(n))return e.push({cls:"num",start:0,end:n.trimEnd().length||n.length}),e;for(const t of n.matchAll(new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$","g")))e.push({cls:"num",start:t.index,end:t.index+t[0].length});return e}}}function O(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Jt(){const n=new Map;async function e(s){if(n.has(s))return n.get(s);try{let o=await fetch(s+"?raw");if(o.ok||(o=await fetch(s)),!o.ok){const d={content:null,error:`File not found: ${s} (${o.status})`};return n.set(s,d),d}let r=await o.text();const a=r.trimStart();if(a.startsWith("<!DOCTYPE")||a.startsWith("<!doctype")||a.startsWith("<html")){const d={content:null,error:`File not found: ${s}`};return n.set(s,d),d}const l=r.match(/^export default (?:\/\*(?:[^*]|\*(?!\/))*\*\/\s*)?["']([\s\S]*)["']\s*;?\s*$/);l&&(r=l[1].replace(/\\n/g,`
|
|
1155
|
+
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(d,h)=>String.fromCharCode(parseInt(h,16))));const c={content:r};return n.set(s,c),c}catch{const o={content:null,error:`Failed to load: ${s}`};return n.set(s,o),o}}function t(s,o){const r=o.match(/^(\d+)-(\d+)$/);if(!r)return s;const a=Math.max(1,parseInt(r[1],10)),l=parseInt(r[2],10);return s.split(`
|
|
1156
|
+
`).slice(a-1,l).join(`
|
|
1157
|
+
`)}async function i(s){const o=s.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:c,error:d}=await e(l);d?(a.innerHTML=`<span class="smdx-import-icon">⚠️</span> <span class="smdx-import-error">${O(d)}</span>`,a.classList.add("smdx-import-failed")):(a.innerHTML=`<div class="smdx-import-header"><span class="smdx-import-icon">📄</span> <code>${O(l)}</code></div><div class="smdx-import-content">${O(c)}</div>`,a.classList.add("smdx-import-loaded"))}const r=s.querySelectorAll(".smdx-snippet[data-src]");for(const a of r){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const l=a.dataset.src,c=a.dataset.lines||"",{content:d,error:h}=await e(l);if(h)a.innerHTML=`<span class="smdx-snippet-icon">⚠️</span> <span class="smdx-snippet-error">${O(h)}</span>`,a.classList.add("smdx-snippet-failed");else{const p=c?t(d,c):d,u=l.split(".").pop()||"text",g=c?` <span class="smdx-snippet-lines">(lines ${O(c)})</span>`:"";a.innerHTML=`<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${O(l)}</code>${g}</div><pre class="smdx-snippet-code"><code class="language-${O(u)}">${O(p)}</code></pre>`,a.classList.add("smdx-snippet-loaded")}}}return{name:"insert",init(s){s.on("render",()=>{const o=s.editor.getPreview();o&&i(o)})},toolbarItems:(()=>{const s={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:h})=>{h.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:h})=>{h.insertBlock(`<Columns count="2">
|
|
1158
|
+
<Column>
|
|
1159
|
+
Column 1 content here.
|
|
1160
|
+
</Column>
|
|
1161
|
+
<Column>
|
|
1162
|
+
Column 2 content here.
|
|
1163
|
+
</Column>
|
|
1164
|
+
</Columns>`)}},{id:"insert-3col",label:"3 Columns",icon:"",tooltip:"Insert 3-column layout",action:({editor:h})=>{h.insertBlock(`<Columns count="3">
|
|
1165
|
+
<Column>
|
|
1166
|
+
Column 1 content here.
|
|
1167
|
+
</Column>
|
|
1168
|
+
<Column>
|
|
1169
|
+
Column 2 content here.
|
|
1170
|
+
</Column>
|
|
1171
|
+
<Column>
|
|
1172
|
+
Column 3 content here.
|
|
1173
|
+
</Column>
|
|
1174
|
+
</Columns>`)}},{id:"insert-4col",label:"4 Columns",icon:"",tooltip:"Insert 4-column layout",action:({editor:h})=>{h.insertBlock(`<Columns count="4">
|
|
1175
|
+
<Column>
|
|
1176
|
+
Column 1 here.
|
|
1177
|
+
</Column>
|
|
1178
|
+
<Column>
|
|
1179
|
+
Column 2 here.
|
|
1180
|
+
</Column>
|
|
1181
|
+
<Column>
|
|
1182
|
+
Column 3 here.
|
|
1183
|
+
</Column>
|
|
1184
|
+
<Column>
|
|
1185
|
+
Column 4 here.
|
|
1186
|
+
</Column>
|
|
1187
|
+
</Columns>`)}}]},r=`<Endpoint method="GET" path="/api/v1/resource">
|
|
1188
|
+
Description of the endpoint.
|
|
1189
|
+
|
|
1190
|
+
**Parameters:**
|
|
1191
|
+
| Name | Type | Description |
|
|
1192
|
+
|------|------|-------------|
|
|
1193
|
+
| id | string | Resource ID |
|
|
1194
|
+
|
|
1195
|
+
**Response:**
|
|
1196
|
+
\`\`\`json
|
|
1197
|
+
{
|
|
1198
|
+
"status": "success",
|
|
1199
|
+
"data": {}
|
|
1200
|
+
}
|
|
1201
|
+
\`\`\`
|
|
1202
|
+
</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:h})=>{h.insertBlock(r)}},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:h})=>{h.insertBlock('<Import src="./path/to/file.md" />')}},c={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:h})=>{h.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:[s,o,a,l,c]},s,o,a,l,c]})(),shortcuts:[{key:"Ctrl+Shift+e",action:({editor:s})=>s.insertBlock(`<Endpoint method="GET" path="/api/v1/resource">
|
|
382
1203
|
Description of the endpoint.
|
|
383
1204
|
|
|
384
1205
|
**Parameters:**
|
|
@@ -393,13 +1214,13 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
393
1214
|
"data": {}
|
|
394
1215
|
}
|
|
395
1216
|
\`\`\`
|
|
396
|
-
</Endpoint>`)
|
|
1217
|
+
</Endpoint>`),description:"Insert API Endpoint"},{key:"Ctrl+Shift+m",action:({editor:s})=>s.insertBlock('<Import src="./path/to/file.md" />'),description:"Insert Markdown Import"},{key:"Ctrl+Shift+s",action:({editor:s})=>s.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:s=>{const o=s.match(/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/i);if(!o)return s;const r=o[1].toUpperCase(),a=o[2]||"";return`<div class="smdx-endpoint">
|
|
397
1218
|
<div class="smdx-endpoint-header">
|
|
398
|
-
<span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[
|
|
1219
|
+
<span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[r]||"#64748b"}">${r}</span>
|
|
399
1220
|
<code class="smdx-endpoint-path">${a}</code>
|
|
400
1221
|
</div>
|
|
401
|
-
<div class="smdx-endpoint-body">${
|
|
402
|
-
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/
|
|
1222
|
+
<div class="smdx-endpoint-body">${o[3].trim()}</div>
|
|
1223
|
+
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/gi,render:s=>{const o=s.match(/<Import\s+src="([^"]*)"(?:\s*\/)?>/i);if(!o)return s;const r=o[1];return`<div class="smdx-import" data-src="${O(r)}"><span class="smdx-import-icon">📄</span> Loading <code>${O(r)}</code>…</div>`}},{name:"snippet",pattern:/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/gi,render:s=>{const o=s.match(/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/i);if(!o)return s;const r=o[1],a=o[2]||"";return`<div class="smdx-snippet" data-src="${O(r)}"${a?` data-lines="${O(a)}"`:""}><span class="smdx-snippet-icon">📋</span> Loading <code>${O(r)}</code>…</div>`}}],styles:`
|
|
403
1224
|
.smdx-endpoint { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
404
1225
|
.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); }
|
|
405
1226
|
.smdx-endpoint-method { color: white; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.8em; letter-spacing: 0.05em; }
|
|
@@ -411,24 +1232,101 @@ $$`)}}],action:({editor:r})=>{r.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
411
1232
|
.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; }
|
|
412
1233
|
.smdx-import-content { padding: 16px; white-space: pre-wrap; font-size: 0.9em; line-height: 1.6; }
|
|
413
1234
|
.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; }
|
|
1235
|
+
.smdx-preview-content .smdx-snippet-code { margin: 0; }
|
|
414
1236
|
.smdx-snippet-code code { font-family: var(--smdx-font-mono, 'SF Mono', 'Fira Code', monospace); }
|
|
415
1237
|
.smdx-snippet-lines { color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
|
|
416
1238
|
.smdx-import-failed, .smdx-snippet-failed { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #fef2f2; border-color: #fecaca; }
|
|
417
1239
|
.smdx-import-error, .smdx-snippet-error { color: #b91c1c; }
|
|
418
1240
|
.smdx-dark .smdx-import-failed, .smdx-dark .smdx-snippet-failed { background: #450a0a; border-color: #991b1b; }
|
|
419
1241
|
.smdx-dark .smdx-import-error, .smdx-dark .smdx-snippet-error { color: #fca5a5; }
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
1242
|
+
`,provideTokens:D(["Import","Snippet","Endpoint"])}}function Zt(){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/>
|
|
1243
|
+
`)}}],provideTokens:D(["br"])}}function ei(){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("---")}}],provideTokens:n=>{const e=[];return(/^-{3,}\s*$/.test(n)||/^\*{3,}\s*$/.test(n)||/^_{3,}\s*$/.test(n))&&e.push({cls:"kw",start:0,end:n.trimEnd().length}),e}}}function Xs(){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 Js(){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 ti(){return[Xs(),Js(),gt(),bt(),ft(),xt(),yt(),vt(),wt(),kt(),_t(),Ct(),Tt(),St(),Et(),Mt(),Lt(),$t(),At(),It(),Rt(),Pt(),Ht(),Dt(),Nt(),Wt(),zt(),Ft(),Gt(),Vt(),Ut(),Kt(),Yt(),Xt(),Jt(),Zt(),Qt(),ei()]}function ii(){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 Zs{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,this.registerTokenProvider=e.registerTokenProvider}}function si(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 s=document.createElement("div");s.className="smdx-main";const o=document.createElement("div");return e.appendChild(t),e.appendChild(i),e.appendChild(s),e.appendChild(o),{root:e,skipLink:t,toolbarSlot:i,main:s,statusBarSlot:o}}function ni(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 s=document.createElement("textarea");return s.className="smdx-textarea",s.id=`${n}-textarea`,s.setAttribute("aria-label","Markdown input"),s.setAttribute("aria-multiline","true"),s.spellcheck=!1,t.appendChild(i),t.appendChild(s),e.appendChild(t),{pane:e,scrollWrapper:t,gutter:i,textarea:s}}function oi(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 ri(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 s=document.createElement("span");s.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(s),n.showModeSwitcher!==!1&&e.appendChild(o),{bar:e,wordCount:t,lineCount:i,charCount:s,modeSwitcher:o}}class ai{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 li{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 di{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 s=document.createElement("button");s.className="smdx-mode-btn",s.type="button",s.textContent=t[i],s.dataset.mode=i,s.addEventListener("click",()=>this.opts.onModeChange(i)),this.opts.modeSwitcher.appendChild(s)}}updateCounts(e){const t=e.trim()?e.trim().split(/\s+/).length:0,i=e.split(`
|
|
1244
|
+
`).length,s=e.length;this.opts.wordCount.textContent=`${t} words`,this.opts.lineCount.textContent=`${i} lines`,this.opts.charCount.textContent=`${s} chars`}updateActiveMode(e){this.opts.modeSwitcher.querySelectorAll(".smdx-mode-btn").forEach(t=>{t.classList.toggle("smdx-active",t.dataset.mode===e)})}}const z=class z{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,s=parseFloat(e.paddingTop)||16,o=this.textarea.clientWidth-t-i;if(o<=0)return null;const r=parseFloat(e.lineHeight)||27.2;this.paddingTop=s,this.contentWidth=o,this.lineHeightPx=r,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 c="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _.,;:()[]{}";this.avgCharWidth=l.measureText(c).width/c.length||8.4}}catch{}return{lineHeightPx:r,contentWidth:o}}rowCount(e,t){return!e||e.length*this.avgCharWidth<this.contentWidth*z.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,s=parseFloat(t.paddingRight)||0,o=this.textarea.clientWidth-i-s;if(o>0&&Math.abs(o-this.cachedContentWidth)>z.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(`
|
|
1245
|
+
`),t=e.length;this.lineCount=t;const i=t>z.LARGE_DOC_THRESHOLD,s=this.syncMirror();if(s){this.rafPending=!1;const{lineHeightPx:r}=s;this.cachedContentWidth=this.contentWidth;const a=new Float32Array(t+1),l=new Float32Array(t);let c=0;if(i){const d=this.contentWidth,h=this.avgCharWidth;for(let p=0;p<t;p++){a[p]=c;const g=e[p].length*h,v=(d>0?Math.max(1,Math.ceil(g/d)):1)*r;l[p]=v,c+=v}this.deferredUpdateTimer&&clearTimeout(this.deferredUpdateTimer),this.deferredUpdateTimer=setTimeout(()=>{this.deferredUpdateTimer=null,this.enabled&&this.refineLargeDoc(e,r)},z.DEFERRED_UPDATE_DELAY_MS)}else for(let d=0;d<t;d++){a[d]=c;const p=this.rowCount(e[d],r)*r;l[d]=p,c+=p}a[t]=c,this.offsets=a,this.heights=l,this.totalHeight=c}else{!this.rafPending&&typeof requestAnimationFrame<"u"&&(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.enabled&&this.update()}));const r=this.lineHeightPx,a=new Float32Array(t+1),l=new Float32Array(t).fill(r);for(let c=0;c<=t;c++)a[c]=c*r;this.offsets=a,this.heights=l,this.totalHeight=t*r}this.poolStart=-1,this.poolEnd=-1;for(let r=0;r<this.spanPool.length;r++)this.spanPool[r].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,s=this.contentWidth,o=this.avgCharWidth,r=s*z.WRAP_THRESHOLD;let a=!1;const l=new Float32Array(i+1),c=new Float32Array(i);let d=0;for(let h=0;h<i;h++){l[h]=d;const u=e[h].length*o;let g;u>=r&&this.mirror?g=this.rowCount(e[h],t):g=s>0?Math.max(1,Math.ceil(u/s)):1;const m=g*t;Math.abs(m-this.heights[h])>.5&&(a=!0),c[h]=m,d+=m}l[i]=d,a&&(this.offsets=l,this.heights=c,this.totalHeight=d,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,s=parseFloat(e.style.height)||0;if(s>0&&s>=i&&e.scrollHeight<=s+2)return;e.style.height="1px";const o=e.scrollHeight,r=Math.max(o,i);e.style.height=r+"px",this.lastTextareaHeight=r}renderVisible(){const t=(this.scrollEl||this.textarea).scrollTop;this.recyclePool(t)}recyclePool(e){const t=this.cachedClientHeight,i=this.paddingTop,s=Math.max(0,e-i),o=e-i+t,r=Math.max(0,this.lineIndexAtOffset(s)-this.OVERSCAN),a=Math.min(this.lineCount-1,this.lineIndexAtOffset(o)+this.OVERSCAN);if(r===this.poolStart&&a===this.poolEnd)return;this.poolStart=r,this.poolEnd=a;const l=this.lineCount>0?a-r+1:0,c=this.lineHeightPx;for(;this.spanPool.length<l;){const d=document.createElement("span");d.className="smdx-line-num",d.style.position="absolute",d.style.left="0",d.style.right="0",this.inner.appendChild(d),this.spanPool.push(d)}for(let d=0;d<l;d++){const h=r+d,p=this.spanPool[d],g=this.offsets[h]+i+"px";p.style.top!==g&&(p.style.top=g);const m=c+"px";p.style.height!==m&&(p.style.height=m,p.style.lineHeight=m);const v=String(h+1);p.textContent!==v&&(p.textContent=v),p.style.visibility!==""&&(p.style.visibility="")}for(let d=l;d<this.spanPool.length;d++)this.spanPool[d].style.visibility!=="hidden"&&(this.spanPool[d].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 s=0,o=t-1;for(;s<o;){const r=s+o+1>>1;i[r]<=e?s=r:o=r-1}return s}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,s=this.textarea.value.substring(0,t).split(`
|
|
1246
|
+
`).length-1,o=this.lineHeightPx,r=this.paddingTop,a=(s<this.lineCount?this.offsets[s]:this.totalHeight)+r,l=a+o,c=e.scrollTop,d=c+e.clientHeight;l>d?e.scrollTop=l-e.clientHeight:a<c&&(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()}};z.WRAP_THRESHOLD=.85,z.LARGE_DOC_THRESHOLD=500,z.DEFERRED_UPDATE_DELAY_MS=50,z.WIDTH_CHANGE_THRESHOLD_PX=1;let ue=z;class ci{constructor(e,t=150){this.renderTimer=null,this.contentEl=e,this.delay=t,this.renderer=new ie}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 s=i.getAttribute("data-text")||"";try{await navigator.clipboard.writeText(s),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 s=(o=i.closest(".smdx-code-block"))==null?void 0:o.querySelector("pre code");if(s)try{await navigator.clipboard.writeText(s.textContent||""),i.classList.add("smdx-copied"),setTimeout(()=>i.classList.remove("smdx-copied"),2e3)}catch{}})})}destroy(){this.renderTimer&&clearTimeout(this.renderTimer)}}const Q=class Q{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<=Q.MOBILE_BREAKPOINT,i=!t&&e<=Q.TABLET_BREAKPOINT;this.root.classList.toggle("smdx-is-mobile",t),this.root.classList.toggle("smdx-is-tablet",i)}};Q.MOBILE_BREAKPOINT=640,Q.TABLET_BREAKPOINT=1024;let He=Q;class Qs{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:s,toolbarSlot:o,main:r,statusBarSlot:a}=si(this.editorId),{pane:l,scrollWrapper:c,gutter:d,textarea:h}=ni(this.editorId),{pane:p,content:u}=oi(this.editorId),{bar:g,wordCount:m,lineCount:v,charCount:y,modeSwitcher:_}=ri();r.appendChild(l),r.appendChild(p),a.replaceWith(g),e.appendChild(s),this.elements={root:s,toolbarEl:o,editorPane:l,previewPane:p,textarea:h,previewContent:u,statusBar:g},this.modeController=new ai(s,this.config.mode??"split"),this.themeController=new li(s),this.lineNumberController=new ue(d,h),this.lineNumberController.setScrollElement(c),this.previewController=new ci(u),this.statusBarController=new di({bar:g,wordCount:m,lineCount:v,charCount:y,modeSwitcher:_,onModeChange:b=>i.setMode(b)}),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 ve(x,t,i,this.events),this.toolbar.render(o)),this.responsiveController=new He(s),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 en{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,s;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",(s=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||s.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 tn=[{label:"Accordion",kind:"tag",detail:"Expandable section",insertText:`<Accordion title="Title">
|
|
1247
|
+
Content
|
|
1248
|
+
</Accordion>`},{label:"AccordionGroup",kind:"tag",detail:"Group of accordions",insertText:`<AccordionGroup>
|
|
1249
|
+
<Accordion title="Section 1">
|
|
1250
|
+
Content
|
|
1251
|
+
</Accordion>
|
|
1252
|
+
</AccordionGroup>`},{label:"Card",kind:"tag",detail:"Card component",insertText:`<Card title="Title" icon="📄">
|
|
1253
|
+
Description
|
|
1254
|
+
</Card>`},{label:"CardGroup",kind:"tag",detail:"Card grid",insertText:`<CardGroup cols="2">
|
|
1255
|
+
<Card title="Card 1" icon="📄">Description</Card>
|
|
1256
|
+
<Card title="Card 2" icon="🔧">Description</Card>
|
|
1257
|
+
</CardGroup>`},{label:"Columns",kind:"tag",detail:"Multi-column layout",insertText:`<Columns count="2">
|
|
1258
|
+
<Column>
|
|
1259
|
+
Column 1
|
|
1260
|
+
</Column>
|
|
1261
|
+
<Column>
|
|
1262
|
+
Column 2
|
|
1263
|
+
</Column>
|
|
1264
|
+
</Columns>`},{label:"Column",kind:"tag",detail:"Column in layout",insertText:`<Column>
|
|
1265
|
+
Content
|
|
1266
|
+
</Column>`},{label:"Container",kind:"tag",detail:"Styled container",insertText:`<Container title="Title">
|
|
1267
|
+
Content
|
|
1268
|
+
</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">
|
|
1269
|
+
Description
|
|
1270
|
+
</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">
|
|
1271
|
+
Instructions
|
|
1272
|
+
</Step>`},{label:"Steps",kind:"tag",detail:"Step-by-step",insertText:`<Steps>
|
|
1273
|
+
<Step title="First Step">
|
|
1274
|
+
Instructions
|
|
1275
|
+
</Step>
|
|
1276
|
+
<Step title="Second Step">
|
|
1277
|
+
Instructions
|
|
1278
|
+
</Step>
|
|
1279
|
+
</Steps>`},{label:"Tab",kind:"tag",detail:"Tab pane",insertText:`<Tab title="Tab Title">
|
|
1280
|
+
Content
|
|
1281
|
+
</Tab>`},{label:"Tabs",kind:"tag",detail:"Tabbed sections",insertText:`<Tabs>
|
|
1282
|
+
<Tab title="Tab 1">Content 1</Tab>
|
|
1283
|
+
<Tab title="Tab 2">Content 2</Tab>
|
|
1284
|
+
</Tabs>`},{label:"TipGood",kind:"tag",detail:"Good tip callout",insertText:`<TipGood>
|
|
1285
|
+
Tip message
|
|
1286
|
+
</TipGood>`},{label:"TipBad",kind:"tag",detail:"Bad tip callout",insertText:`<TipBad>
|
|
1287
|
+
Warning message
|
|
1288
|
+
</TipBad>`},{label:"TipInfo",kind:"tag",detail:"Info tip callout",insertText:`<TipInfo>
|
|
1289
|
+
Info message
|
|
1290
|
+
</TipInfo>`},{label:"Tooltip",kind:"tag",detail:"Hover tooltip",insertText:'<Tooltip tip="Tooltip text">hover text</Tooltip>'}],sn=[{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:`---
|
|
1291
|
+
`},{label:"| Table |",kind:"md",detail:"Table",insertText:`| Column 1 | Column 2 |
|
|
1292
|
+
|----------|----------|
|
|
1293
|
+
| Cell 1 | Cell 2 |`},{label:":::tip",kind:"md",detail:"Tip admonition",insertText:`:::tip
|
|
1294
|
+
Tip content
|
|
1295
|
+
:::`},{label:":::warning",kind:"md",detail:"Warning admonition",insertText:`:::warning
|
|
1296
|
+
Warning content
|
|
1297
|
+
:::`},{label:":::info",kind:"md",detail:"Info admonition",insertText:`:::info
|
|
1298
|
+
Info content
|
|
1299
|
+
:::`},{label:":::danger",kind:"md",detail:"Danger admonition",insertText:`:::danger
|
|
1300
|
+
Danger content
|
|
1301
|
+
:::`},{label:":::note",kind:"md",detail:"Note admonition",insertText:`:::note
|
|
1302
|
+
Note content
|
|
1303
|
+
:::`},{label:"$formula$",kind:"md",detail:"Inline math",insertText:"$E = mc^2$"},{label:"$$block math$$",kind:"md",detail:"Math block",insertText:`$$
|
|
1304
|
+
E = mc^2
|
|
1305
|
+
$$`},{label:"```mermaid",kind:"md",detail:"Mermaid diagram",insertText:"```mermaid\ngraph TD\n A --> B\n```"}],nn=[{label:"<div>",kind:"html",detail:"Division",insertText:`<div>
|
|
1306
|
+
|
|
1307
|
+
</div>`},{label:"<span>",kind:"html",detail:"Inline span",insertText:"<span></span>"},{label:"<p>",kind:"html",detail:"Paragraph",insertText:`<p>
|
|
1308
|
+
|
|
1309
|
+
</p>`},{label:"<a>",kind:"html",detail:"Anchor link",insertText:`<a href="">
|
|
1310
|
+
|
|
1311
|
+
</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>
|
|
1312
|
+
<li></li>
|
|
1313
|
+
</ul>`},{label:"<ol>",kind:"html",detail:"Ordered list",insertText:`<ol>
|
|
1314
|
+
<li></li>
|
|
1315
|
+
</ol>`},{label:"<table>",kind:"html",detail:"Table",insertText:`<table>
|
|
1316
|
+
<tr><th></th></tr>
|
|
1317
|
+
<tr><td></td></tr>
|
|
1318
|
+
</table>`},{label:"<details>",kind:"html",detail:"Disclosure widget",insertText:`<details>
|
|
1319
|
+
<summary>Summary</summary>
|
|
1320
|
+
Content
|
|
1321
|
+
</details>`},{label:"<summary>",kind:"html",detail:"Disclosure summary",insertText:"<summary></summary>"},{label:"<pre>",kind:"html",detail:"Preformatted",insertText:`<pre><code>
|
|
1322
|
+
|
|
1323
|
+
</code></pre>`},{label:"<code>",kind:"html",detail:"Code element",insertText:"<code></code>"},{label:"<blockquote>",kind:"html",detail:"Block quotation",insertText:`<blockquote>
|
|
1324
|
+
|
|
1325
|
+
</blockquote>`},{label:"<section>",kind:"html",detail:"Section",insertText:`<section>
|
|
1326
|
+
|
|
1327
|
+
</section>`}],hi=[...tn,...sn,...nn],on=new Set(hi.map(n=>n.label.toLowerCase())),rn={tag:"⚛",md:"M",html:"<>",var:"·",snippet:"{}"};function pi(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const an=/[\w</.:#*\-$![\]>(){}~|`@]/,ln=.6;class dn{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 s=i.target.closest(".smdx-ac-item");s&&s.dataset.i&&(this.selected=parseInt(s.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(`
|
|
1328
|
+
`,e-1)+1,s=t.substring(i,e);let o=s.length;for(;o>0&&an.test(s[o-1]);)o--;const r=s.substring(o);if(r.length<1){this.hide();return}this.prefix=r,this.startPos=i+o;const a=r.startsWith("<")?r.substring(1):r;if(a.length<1){this.hide();return}const l=a.toLowerCase(),c=new Set,h=t.match(/[a-zA-Z_$][\w$]*/g);if(h)for(const m of h)m!==a&&m.length>2&&c.add(m);const p=[...c].filter(m=>m.toLowerCase().startsWith(l)&&!on.has(m.toLowerCase())).slice(0,8).map(m=>({label:m,kind:"var",detail:"in document"})),g=[...hi,...this.extraItems].filter(m=>m.label.toLowerCase().includes(l)&&m.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,s=this.textarea.selectionStart;this.textarea.value=t.substring(0,this.startPos)+i+t.substring(s);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}">${rn[t.kind]||"·"}</span><span class="smdx-ac-label">${pi(t.label)}</span><span class="smdx-ac-detail">${pi(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,s=i.lastIndexOf(`
|
|
1329
|
+
`,t-1)+1,o=t-s,r=getComputedStyle(this.textarea),a=parseFloat(r.lineHeight)||22,c=(parseFloat(r.fontSize)||14)*ln,h=i.substring(0,t).split(`
|
|
1330
|
+
`).length,p=this.textarea.getBoundingClientRect(),u=((_=this.textarea.parentElement)==null?void 0:_.scrollTop)||0,g=p.left-e.left+o*c+16,m=p.top-e.top+h*a-u+4,v=this.items.length*30+8,y=m+v>e.height-16;this.popup.style.left=Math.min(g,e.width-360)+"px",this.popup.style.top=(y?Math.max(0,m-a-v):m)+"px"}destroy(){this.popup.remove()}}const cn=1e4;class hn{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 s=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 r=this.createActionBtn("✕","Close");r.classList.add("smdx-find-close"),i.appendChild(this.findInput),i.appendChild(this.caseSensitiveBtn),i.appendChild(this.wholeWordBtn),i.appendChild(this.regexBtn),i.appendChild(s),i.appendChild(o),i.appendChild(this.countLabel),i.appendChild(r),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",c=>{c.stopPropagation(),c.key==="Enter"&&(c.shiftKey?this.prev():this.next()),c.key==="Escape"&&this.close()}),this.replaceInput.addEventListener("keydown",c=>{c.stopPropagation(),c.key==="Enter"&&this.replaceCurrent(),c.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()}),s.addEventListener("click",()=>this.prev()),o.addEventListener("click",()=>this.next()),r.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(`
|
|
1331
|
+
`)&&(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 r=this.caseSensitive?"g":"gi";i=new RegExp(e,r)}else{let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.wholeWord&&(r=`\\b${r}\\b`);const a=this.caseSensitive?"g":"gi";i=new RegExp(r,a)}}catch{this.countLabel.textContent="Invalid regex";return}let s,o=0;for(;(s=i.exec(t))!==null&&o<cn;){if(o++,s[0].length===0){i.lastIndex++;continue}this.matches.push({start:s.index,end:s.index+s[0].length})}if(this.matches.length>0){const r=this.textarea.selectionStart;this.currentMatch=this.matches.findIndex(a=>a.start>=r),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(`
|
|
1332
|
+
`).length,s=parseFloat(getComputedStyle(this.textarea).lineHeight)||22,o=(i-1)*s-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="",s=0;for(const o of this.matches)i+=t.substring(s,o.start)+e,s=o.end;i+=t.substring(s),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 pn="split",un="Start writing markdown...",mn={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}},gn={splitterPosition:50,minEditorWidth:200,minPreviewWidth:200,resizableSplitter:!0};function bn(n){return{container:n.container,value:n.value??"",plugins:n.plugins??[],toolbar:n.toolbar,theme:n.theme,mode:n.mode??pn,placeholder:n.placeholder??un,readOnly:n.readOnly??!1,renderers:n.renderers,locale:n.locale,onChange:n.onChange}}function fn(n){if(!n.container)throw new Error("[SynclineMDX] Container is required");return bn(n)}function xn(){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 yn(n){const e=document.createElement("a");return e.className="smdx-skip-link",e.href=`#${n}`,e.textContent="Skip to editor",e}function vn(n){return new mt({plugins:ti(),toolbar:ii(),placeholder:"Start writing markdown...",mode:"split",...n})}w.AutocompleteController=dn,w.CodeRenderer=Ne,w.DEFAULT_FEATURES=mn,w.DEFAULT_LAYOUT=gn,w.DropdownController=en,w.EventEmitter=De,w.FindReplaceController=hn,w.History=Vs,w.LineNumberController=ue,w.ListRenderer=We,w.MarkdownRenderer=ze,w.MdxValidator=Fe,w.ModeController=ai,w.PluginContextClass=Zs,w.PluginManager=xe,w.PluginManagerNew=xe,w.PreviewController=ci,w.Renderer=ie,w.RendererPipeline=ie,w.SplitterController=se,w.StatusBarController=di,w.SynclineMDXEditor=mt,w.TableRenderer=Oe,w.ThemeController=li,w.Toolbar=ve,w.UIController=Qs,w.accordionGroupPlugin=Rt,w.accordionPlugin=It,w.admonitionPlugin=Mt,w.allPlugins=ti,w.boldPlugin=bt,w.breakLinePlugin=Qt,w.cardGroupPlugin=Dt,w.cardPlugin=Ht,w.codePlugin=kt,w.componentTagTokens=D,w.composeTokenProviders=ht,w.containerPlugin=zt,w.copyTextPlugin=Ft,w.createEditor=vn,w.createEditorPane=ni,w.createEditorRoot=si,w.createPreviewPane=oi,w.createSkipLink=yn,w.createStatusBar=ri,w.createToolbarDOM=xn,w.defaultToolbar=ii,w.embedOthersPlugin=Ut,w.embedVideoPlugin=Vt,w.emojiPlugin=Yt,w.formulaPlugin=Xt,w.headingPlugin=gt,w.highlightPlugin=Et,w.horizontalRulePlugin=ei,w.icons=$,w.imageBackgroundPlugin=$t,w.imageFramePlugin=At,w.imagePlugin=wt,w.insertPlugin=Jt,w.italicPlugin=ft,w.linkPlugin=vt,w.mdxBaseTokens=Fs,w.mermaidPlugin=Kt,w.multiColumnPlugin=Pt,w.orderedListPlugin=Ct,w.quotePlugin=yt,w.resolveConfig=fn,w.stepPlugin=Nt,w.strikethroughPlugin=xt,w.tabPlugin=Lt,w.tablePlugin=St,w.taskListPlugin=Tt,w.tipPlugin=Wt,w.tocPlugin=Zt,w.tooltipPlugin=Gt,w.unorderedListPlugin=_t,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|