@synclineapi/mdx-editor 1.0.0 → 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.
@@ -1,9 +1,165 @@
1
- (function(b,G){typeof exports=="object"&&typeof module<"u"?G(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],G):(b=typeof globalThis<"u"?globalThis:b||self,G(b.SynclineMDXEditor={},b.hljs))})(this,function(b,G){"use strict";class Se{constructor(){this.listeners=new Map}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var i;(i=this.listeners.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.listeners.get(e))==null||i.forEach(r=>{try{r(t)}catch(o){console.error(`[SynclineMDX] Error in event handler for "${e}":`,o)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class le{constructor(e,t){this.editorApi=e,this.plugins=new Map,this.toolbarItems=new Map,this.shortcuts=[],this.renderers=[],this.parsers=[],this.styleElements=[],this.completionsByPlugin=new Map,this.events=t}async register(e){if(this.plugins.has(e.name)){console.warn(`[SynclineMDX] Plugin "${e.name}" is already registered.`);return}if(e.dependencies){for(const i of e.dependencies)if(!this.plugins.has(i))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${i}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const i of e.toolbarItems)this.toolbarItems.set(i.id,i);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((i,r)=>(r.priority??0)-(i.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((i,r)=>(r.priority??0)-(i.priority??0)));const t=e.completions?[...e.completions]:[];this.completionsByPlugin.set(e.name,t),e.styles&&this.injectStyles(e.styles),e.init&&await e.init(this.createContext(e.name)),this.events.emit("plugin-registered",e.name)}unregister(e){const t=this.plugins.get(e);if(t){if(t.destroy&&t.destroy(this.createContext(e)),t.toolbarItems)for(const i of t.toolbarItems)this.toolbarItems.delete(i.id);if(t.shortcuts&&(this.shortcuts=this.shortcuts.filter(i=>!t.shortcuts.some(r=>r.key===i.key))),t.renderers){const i=new Set(t.renderers.map(r=>r.name));this.renderers=this.renderers.filter(r=>!i.has(r.name))}if(t.parsers){const i=new Set(t.parsers.map(r=>r.name));this.parsers=this.parsers.filter(r=>!i.has(r.name))}this.completionsByPlugin.delete(e),this.plugins.delete(e),this.events.emit("plugin-removed",e)}}getToolbarItem(e){return this.toolbarItems.get(e)}getAllToolbarItems(){return this.toolbarItems}getShortcuts(){return this.shortcuts}getRenderers(){return this.renderers}getParsers(){return this.parsers}getCompletions(){const e=[];for(const t of this.completionsByPlugin.values())e.push(...t);return e}hasPlugin(e){return this.plugins.has(e)}getPlugin(e){return this.plugins.get(e)}createContext(e){return{editor:this.editorApi,registerToolbarItem:t=>this.toolbarItems.set(t.id,t),registerShortcut:t=>this.shortcuts.push(t),registerRenderer:t=>{this.renderers.push(t),this.renderers.sort((i,r)=>(r.priority??0)-(i.priority??0))},registerParser:t=>{this.parsers.push(t),this.parsers.sort((i,r)=>(r.priority??0)-(i.priority??0))},registerCompletion:t=>{const i=this.completionsByPlugin.get(e)??[];i.push(t),this.completionsByPlugin.set(e,i)},injectStyles:t=>this.injectStyles(t),emit:(t,i)=>this.events.emit(t,i),on:(t,i)=>this.events.on(t,i),off:(t,i)=>this.events.off(t,i)}}injectStyles(e){const t=document.createElement("style");t.setAttribute("data-syncline-mdx","plugin"),t.textContent=e,document.head.appendChild(t),this.styleElements.push(t)}destroy(){for(const[e]of this.plugins)this.unregister(e);for(const e of this.styleElements)e.remove();this.styleElements=[]}}function ai(){var e;if(typeof navigator>"u")return!1;const n=navigator;return(e=n.userAgentData)!=null&&e.platform?/mac/i.test(n.userAgentData.platform):navigator.platform?/mac/i.test(navigator.platform):/Macintosh|MacIntel|MacPPC|Mac OS X/.test(navigator.userAgent)}function de(n){return ai()?n.replace(/ctrl\+/gi,"⌘").replace(/shift\+/gi,"⇧").replace(/alt\+/gi,"⌥"):n.replace(/⌘/g,"Ctrl+").replace(/⇧/g,"Shift+").replace(/⌥/g,"Alt+")}class ce{constructor(e,t,i,r){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=r,this.activeDropdown=null,this.documentClickHandler=o=>{this.activeDropdown&&!this.activeDropdown.contains(o.target)&&this.closeDropdowns()}}render(e){this.el=document.createElement("div"),this.el.className="smdx-toolbar";for(const t of this.config){const i=document.createElement("div");i.className="smdx-toolbar-row",this.renderRow(t,i),this.el.appendChild(i)}return e.appendChild(this.el),document.addEventListener("click",this.documentClickHandler),this.el}renderRow(e,t){for(const i of e)typeof i=="string"?i==="|"?this.renderDivider(t):this.renderItem(i,t):"type"in i&&i.type==="divider"?this.renderDivider(t):"type"in i&&i.type==="group"&&this.renderGroup(i,t)}renderDivider(e){const t=document.createElement("span");t.className="smdx-toolbar-divider",e.appendChild(t)}renderItem(e,t){const i=this.pluginManager.getToolbarItem(e);if(i)if(i.children&&i.children.length>0)this.renderDropdownItem(i,t);else{const r=this.createButton(i);t.appendChild(r)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const r of e.items)typeof r=="string"?this.renderItem(r,i):this.renderGroup(r,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const r=document.createElement("button");r.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",r.type="button",r.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label||""}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`,r.title=e.label||"",r.setAttribute("aria-label",e.label||"Dropdown"),r.setAttribute("aria-haspopup","true"),r.setAttribute("aria-expanded","false");const o=document.createElement("div");o.className="smdx-toolbar-dropdown-menu",o.setAttribute("role","menu"),o.style.display="none";for(const s of e.items)if(typeof s=="string"){const a=this.pluginManager.getToolbarItem(s);if(!a)continue;if(a.children&&a.children.length>0)this.renderSubmenu(a,o);else{const l=this.createMenuButton(a);o.appendChild(l)}}else{const a=document.createElement("div");if(a.className="smdx-toolbar-dropdown-section",s.label){const l=document.createElement("div");l.className="smdx-toolbar-dropdown-section-label",l.textContent=s.label,a.appendChild(l)}for(const l of s.items)if(typeof l=="string"){const d=this.pluginManager.getToolbarItem(l);if(d)if(d.children&&d.children.length>0)this.renderSubmenu(d,a);else{const h=this.createMenuButton(d);a.appendChild(h)}}o.appendChild(a)}r.addEventListener("click",s=>{s.stopPropagation(),this.toggleDropdown(o,i)}),i.appendChild(r),i.appendChild(o),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const r=document.createElement("button");r.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",r.type="button",r.innerHTML=`${e.icon||""}<span class="smdx-toolbar-btn-label">${e.label}</span><svg class="smdx-dropdown-arrow" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const o=e.tooltip||e.label,s=e.shortcutLabel?de(e.shortcutLabel):void 0;r.title=s?`${o} (${s})`:o,r.setAttribute("aria-label",s?`${o} (${s})`:o),r.setAttribute("aria-haspopup","true"),r.setAttribute("aria-expanded","false");const a=document.createElement("div");a.className="smdx-toolbar-dropdown-menu",a.setAttribute("role","menu"),a.style.display="none";for(const l of e.children)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const d=this.createMenuButton(l);a.appendChild(d)}r.addEventListener("click",l=>{l.stopPropagation(),this.toggleDropdown(a,i)}),i.appendChild(r),i.appendChild(a),t.appendChild(i)}positionMenu(e,t){const i=t.getBoundingClientRect(),r=4;let o=i.bottom+r,s=i.left;e.style.top=o+"px",e.style.left=s+"px",e.style.visibility="hidden",e.style.display="",requestAnimationFrame(()=>{const a=e.getBoundingClientRect();a.right>window.innerWidth-4&&(s=i.right-a.width,e.style.left=Math.max(4,s)+"px"),a.bottom>window.innerHeight-4&&(o=i.top-a.height-r,e.style.top=Math.max(4,o)+"px"),e.style.visibility=""})}renderSubmenu(e,t){const i=document.createElement("div");i.className="smdx-toolbar-submenu";const r=document.createElement("button");r.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",r.type="button",r.innerHTML=`${e.icon||""}<span>${e.label}</span><svg class="smdx-submenu-arrow" width="6" height="10" viewBox="0 0 6 10"><path d="M1 1l4 4-4 4" stroke="currentColor" fill="none" stroke-width="1.5"/></svg>`;const o=document.createElement("div");o.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",o.style.display="none";for(const h of e.children)if(h.children&&h.children.length>0)this.renderSubmenu(h,o);else{const c=this.createMenuButton(h);o.appendChild(c)}const s=()=>{const h=i.getBoundingClientRect();o.style.left=`${h.right}px`,o.style.top=`${h.top}px`,requestAnimationFrame(()=>{const c=o.getBoundingClientRect();c.right>window.innerWidth&&(o.style.left=`${h.left-c.width}px`),c.bottom>window.innerHeight&&(o.style.top=`${window.innerHeight-c.height-8}px`)})};let a=null;const l=()=>{a&&(clearTimeout(a),a=null),o.style.display="",s()},d=()=>{a&&clearTimeout(a),a=setTimeout(()=>{o.style.display="none",a=null},120)};r.addEventListener("mouseenter",l),o.addEventListener("mouseenter",l),i.addEventListener("mouseleave",d),o.addEventListener("mouseleave",d),i.appendChild(r),i.appendChild(o),t.appendChild(i)}createButton(e){const t=document.createElement("button");t.className=`smdx-toolbar-btn${e.className?" "+e.className:""}`,t.type="button",t.tabIndex=0;const i=e.tooltip||e.label,r=e.shortcutLabel?de(e.shortcutLabel):void 0;return t.title=r?`${i} (${r})`:i,t.setAttribute("aria-label",r?`${i} (${r})`:i),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,r&&t.setAttribute("data-shortcut",r),t.addEventListener("click",o=>{o.preventDefault(),this.executeAction(e)}),e.render&&e.render(t,this.getActionContext()),t}createMenuButton(e){const t=document.createElement("button");return t.className=`smdx-toolbar-menu-btn${e.className?" "+e.className:""}`,t.type="button",t.setAttribute("role","menuitem"),t.dataset.toolbarId=e.id,t.innerHTML=`${e.icon||""}<span>${e.label}</span>${e.shortcutLabel?`<span class="smdx-shortcut-label">${de(e.shortcutLabel)}</span>`:""}`,t.addEventListener("click",i=>{i.preventDefault(),this.closeDropdowns(),this.executeAction(e)}),t}executeAction(e){var i;const t=this.getActionContext();(i=e.isDisabled)!=null&&i.call(e,t)||(e.action(t),this.events.emit("toolbar-action",e.id))}getActionContext(){return{editor:this.editorApi,selection:this.editorApi.getSelection()}}toggleDropdown(e,t){var i,r;if(e.style.display==="none"){this.closeDropdowns();const o=t.querySelector(".smdx-toolbar-dropdown-trigger");o?this.positionMenu(e,o):e.style.display="",this.activeDropdown=t,(i=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||i.setAttribute("aria-expanded","true")}else e.style.display="none",e.style.visibility="",(r=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||r.setAttribute("aria-expanded","false"),this.activeDropdown=null}closeDropdowns(){var e,t;(e=this.el)==null||e.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(i=>{i.style.display="none",i.style.visibility=""}),(t=this.el)==null||t.querySelectorAll('[aria-expanded="true"]').forEach(i=>{i.setAttribute("aria-expanded","false")}),this.activeDropdown=null}updateActiveStates(){var t;const e=this.getActionContext();(t=this.el)==null||t.querySelectorAll("[data-toolbar-id]").forEach(i=>{const r=i.dataset.toolbarId,o=this.pluginManager.getToolbarItem(r);o!=null&&o.isActive&&i.classList.toggle("smdx-active",o.isActive(e)),o!=null&&o.isDisabled&&(i.disabled=o.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const li=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),di=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function ci(n){return di.some(e=>n.startsWith(e))}const Me=/^on/i,hi=/^\s*javascript\s*:/i;function pi(n){if(typeof document>"u")return n;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${n}</body>`,"text/html"),i=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),r=[];let o=i.currentNode;for(;o;){if(o.nodeType===Node.ELEMENT_NODE){const s=o,a=s.tagName.toLowerCase();if(li.has(a))r.push(s);else if(a==="iframe"){const l=s.getAttribute("src")||"";if(!ci(l))r.push(s);else{const d=[];for(const h of Array.from(s.attributes))Me.test(h.name)&&d.push(h.name);for(const h of d)s.removeAttribute(h)}}else{const l=[];for(const d of Array.from(s.attributes))(Me.test(d.name)||(d.name==="href"||d.name==="src"||d.name==="action")&&hi.test(d.value))&&l.push(d.name);for(const d of l)s.removeAttribute(d)}}o=i.nextNode()}for(const s of r)s.remove();return t.body.innerHTML}const ui={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",py:"Python",python:"Python",java:"Java",rb:"Ruby",ruby:"Ruby",go:"Go",rust:"Rust",rs:"Rust",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",swift:"Swift",kt:"Kotlin",kotlin:"Kotlin",scala:"Scala",sh:"Shell",bash:"Bash",zsh:"Zsh",sql:"SQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",md:"Markdown",markdown:"Markdown",graphql:"GraphQL",dart:"Dart",r:"R",lua:"Lua",perl:"Perl",text:"Text",txt:"Text"};class $e{escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}renderBlock(e,t,i){let r;const o=i.trimEnd();try{e&&G.getLanguage(e)?r=G.highlight(o,{language:e}).value:r=G.highlightAuto(o).value}catch{r=this.escapeHtml(o)}const s=e?ui[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1):"",a=s?`<span class="smdx-code-lang">${s}</span>`:"",l=t?`<span class="smdx-code-filename"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>${this.escapeHtml(t)}</span>`:"",d='<button class="smdx-copy-btn" data-copy-btn="true" title="Copy code" aria-label="Copy code"><svg class="smdx-copy-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg><svg class="smdx-check-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></button>',h=!!(s||t),c=h?`<div class="smdx-code-header">${a}${l}${d}</div>`:"";return`<div class="smdx-code-block${h?" smdx-has-header":""}">${c}<pre><code class="hljs language-${e||"text"}">${r}</code></pre>${h?"":d}</div>`}}class Le{parseTableRow(e){return e.split("|").slice(1,-1).map(t=>t.trim())}render(e){const t=/(?:^[ \t]*(\|.+\|)\n[ \t]*(\|[-| :]+\|)\n((?:[ \t]*\|.+\|\n?)*))/gm;return e.replace(t,(i,r,o,s)=>{const a=this.parseTableRow(r),l=s.trim().split(`
2
- `).filter(Boolean).map(h=>this.parseTableRow(h));let d='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const h of a)d+=`<th>${h}</th>`;d+="</tr></thead><tbody>";for(const h of l){d+="<tr>";for(const c of h)d+=`<td>${c}</td>`;d+="</tr>"}return d+="</tbody></table></div>",d})}}class Be{isListItem(e){return/^\s*[-*]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)}buildNestedList(e){var l,d,h;if(e.length===0)return"";const t=((l=e[0].match(/^(\s*)/))==null?void 0:l[1].length)??0,i=/^\s*\d+\.\s+/.test(e[0]),r=i?"ol":"ul",o=i?"smdx-ol-item":"smdx-ul-item";let s=`<${r}>`,a=0;for(;a<e.length;){const c=e[a],p=((d=c.match(/^(\s*)/))==null?void 0:d[1].length)??0;if(p<t)break;if(p>t){a++;continue}const m=i?c.replace(/^\s*\d+\.\s+/,""):c.replace(/^\s*[-*]\s+/,"");a++;const g=[];for(;a<e.length&&((((h=e[a].match(/^(\s*)/))==null?void 0:h[1].length)??0)>t&&this.isListItem(e[a]));)g.push(e[a]),a++;const f=g.length>0?this.buildNestedList(g):"";s+=`<li class="${o}">${m}${f}</li>`}return s+=`</${r}>`,s}render(e){const t=e.split(`
3
- `),i=[];let r=0;for(;r<t.length;)if(this.isListItem(t[r])){const o=[];for(;r<t.length&&this.isListItem(t[r]);)o.push(t[r]),r++;i.push(this.buildNestedList(o))}else i.push(t[r]),r++;return i.join(`
4
- `)}}class Ae{constructor(){this.codeRenderer=new $e,this.tableRenderer=new Le,this.listRenderer=new Be}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}render(e){let t=e;const i=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(o,s,a,l)=>{const d=i.length;return i.push(this.codeRenderer.renderBlock(s,a,l)),`%%CODEBLOCK_${d}%%`}),t=t.replace(/`([^`]+)`/g,(o,s)=>`<code class="smdx-inline-code">${this.escapeHtml(s)}</code>`);const r=o=>o.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(o,s)=>`<h6 id="${r(s)}">${s}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(o,s)=>`<h5 id="${r(s)}">${s}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(o,s)=>`<h4 id="${r(s)}">${s}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(o,s)=>`<h3 id="${r(s)}">${s}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(o,s)=>`<h2 id="${r(s)}">${s}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(o,s)=>`<h1 id="${r(s)}">${s}</h1>`),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/^>\s+(.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^- \[x\]\s+(.+)$/gm,'<div class="smdx-task"><span class="smdx-task-checkbox smdx-task-checked" role="checkbox" aria-checked="true" tabindex="0"></span><span>$1</span></div>'),t=t.replace(/^- \[ \]\s+(.+)$/gm,'<div class="smdx-task"><span class="smdx-task-checkbox" role="checkbox" aria-checked="false" tabindex="0"></span><span>$1</span></div>'),t=this.listRenderer.render(t),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="smdx-image"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=this.tableRenderer.render(t),t=t.replace(/ {2,}$/gm,"<br/>"),t=t.replace(/^(?!\s*<[a-zA-Z/!]|\s*%%)(.*\S.*)$/gm,"<p>$1</p>"),t=t.replace(/<p>\s*<\/p>/g,"");for(let o=0;o<i.length;o++)t=t.replace(`%%CODEBLOCK_${o}%%`,i[o]);return t}}class Ie{validate(e){const t=[];let i=e.replace(/```[\s\S]*?```/g,"");i=i.replace(/`[^`]+`/g,"");const r=[],o=i.split(`
5
- `);for(let s=0;s<o.length;s++){const a=o[s];let l;const d=/<\/?([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?\/?>|<([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?>/g;for(;(l=d.exec(a))!==null;){const h=l[0];if(h.endsWith("/>"))continue;const c=l[1]||l[2];if(!c)continue;const p=l.index+1;if(h.startsWith("</")){let g=!1;for(let f=r.length-1;f>=0;f--)if(r[f].tag===c){r.splice(f,1),g=!0;break}g||t.push(`Unexpected closing tag '</${c}>' at line ${s+1}:${p} — no matching opening tag found.`)}else r.push({tag:c,line:s+1,col:p})}}for(const s of r)t.push(`Expected a closing tag for '<${s.tag}>' (${s.line}:${s.col}) before the end of the document.`);return t}}class Q{constructor(){this.renderers=[],this.parsers=[],this.markdownRenderer=new Ae,this.mdxValidator=new Ie}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const i=this.mdxValidator.validate(e),r=[];t=t.replace(/`([^`\n]+)`/g,(o,s)=>{const a=r.length;return r.push(s),`%%INLINECODE_${a}%%`});for(const o of this.parsers)t=t.replace(o.pattern,(...s)=>o.transform(s));for(const o of this.renderers)t=t.replace(o.pattern,(s,...a)=>{const l={};return a.length>0&&(l.content=a[0]||""),o.render(s,l)});for(let o=0;o<r.length;o++)t=t.replace(`%%INLINECODE_${o}%%`,`\`${r[o]}\``);if(t=this.markdownRenderer.render(t),i.length>0){const o=a=>a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");t=i.map(a=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">&#9888;</span> ${o(a)}</div>`).join("")+t}return pi(t)}}const se=class se{constructor(e,t,i){this.isDragging=!1,this.startX=0,this.startLeftWidth=0,this.onResizeCallback=null,this.resizeRafId=null,this.onMouseDown=r=>{this.startDrag(r.clientX),r.preventDefault()},this.onMouseMove=r=>{this.isDragging&&this.moveDrag(r.clientX)},this.onMouseUp=()=>{this.endDrag()},this.onTouchStart=r=>{r.touches.length===1&&(this.startDrag(r.touches[0].clientX),r.preventDefault())},this.onTouchMove=r=>{!this.isDragging||r.touches.length!==1||(this.moveDrag(r.touches[0].clientX),r.preventDefault())},this.onTouchEnd=()=>{this.endDrag()},this.onKeyDown=r=>{if(r.key!=="ArrowLeft"&&r.key!=="ArrowRight")return;r.preventDefault();const o=this.container.getBoundingClientRect().width;if(o<=0)return;const s=this.left.getBoundingClientRect().width,a=o*se.KEYBOARD_STEP_PERCENT,l=r.key==="ArrowRight"?a:-a;let d=(s+l)/o*100;d=Math.max(20,Math.min(80,d)),this.left.style.flex=`0 0 ${d}%`,this.right.style.flex="1 1 0",this.notifyResize()},this.container=e,this.left=t,this.right=i,this.splitter=document.createElement("div"),this.splitter.className="smdx-splitter",this.splitter.setAttribute("role","separator"),this.splitter.setAttribute("aria-label","Resize editor and preview"),this.splitter.setAttribute("tabindex","0"),t.after(this.splitter),this.splitter.addEventListener("mousedown",this.onMouseDown),document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp),this.splitter.addEventListener("touchstart",this.onTouchStart,{passive:!1}),document.addEventListener("touchmove",this.onTouchMove,{passive:!1}),document.addEventListener("touchend",this.onTouchEnd),this.splitter.addEventListener("keydown",this.onKeyDown)}onResize(e){this.onResizeCallback=e}startDrag(e){this.isDragging=!0,this.startX=e,this.startLeftWidth=this.left.getBoundingClientRect().width,document.body.style.cursor="col-resize",document.body.style.userSelect="none",this.right.style.pointerEvents="none"}moveDrag(e){const t=e-this.startX,i=this.container.getBoundingClientRect().width;if(i<=0)return;let r=(this.startLeftWidth+t)/i*100;r=Math.max(20,Math.min(80,r)),this.left.style.flex=`0 0 ${r}%`,this.right.style.flex="1 1 0",this.notifyResize()}endDrag(){this.isDragging&&(this.isDragging=!1,document.body.style.cursor="",document.body.style.userSelect="",this.right.style.pointerEvents="",this.notifyResize())}notifyResize(){var e;this.resizeRafId===null&&(typeof requestAnimationFrame<"u"?this.resizeRafId=requestAnimationFrame(()=>{var t;this.resizeRafId=null,(t=this.onResizeCallback)==null||t.call(this)}):(e=this.onResizeCallback)==null||e.call(this))}destroy(){document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd),this.splitter.removeEventListener("mousedown",this.onMouseDown),this.splitter.removeEventListener("touchstart",this.onTouchStart),this.splitter.removeEventListener("keydown",this.onKeyDown),this.resizeRafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.resizeRafId),this.splitter.remove()}};se.KEYBOARD_STEP_PERCENT=.02;let ee=se;var mi=Object.defineProperty,gi=(n,e,t)=>e in n?mi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e,t)=>gi(n,typeof e!="symbol"?e+"":e,t);const bi={typescript:"//",javascript:"//",css:"//",json:"",markdown:"",text:""},he=new Set(["function","const","let","var","return","if","else","for","while","class","import","export","default","async","await","new","this","typeof","instanceof","try","catch","finally","throw","extends","interface","type","readonly","private","public","protected","static","override","implements","enum","namespace","declare","abstract","as","from","of","in","void","switch","case","break","continue","do","delete","yield","super","null","true","false","undefined","require","constructor"]),fi=new Set(["function","const","let","var","return","if","else","for","while","class","import","export","default","async","await","new","this","typeof","instanceof","try","catch","finally","throw","extends","as","from","of","in","void","switch","case","break","continue","do","delete","yield","super","null","true","false","undefined","require","constructor","static"]),xi=new Set(["media","keyframes","import","charset","supports","layer","container","namespace","page","static","relative","absolute","fixed","sticky","block","inline","flex","grid","none","contents","table","hidden","visible","scroll","clip","auto","bold","normal","italic","underline","uppercase","lowercase","capitalize","left","right","center","justify","inherit","initial","unset","revert","pointer","default","transparent","solid","dashed","dotted","double","cover","contain","no-repeat","repeat","var","calc","min","max","clamp"]),yi=new Set(["null","true","false"]),Pe=new Set,pe=new Set(["number","string","boolean","any","never","unknown","object","Promise","Array","Map","Set","Record","Partial","Required","Readonly","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),vi=new Set(["number","string","boolean","object","Promise","Array","Map","Set","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),ki=new Set,wi=new Set,Re=new Set,He={typescript:he,javascript:fi,css:xi,json:yi,markdown:Pe,text:Pe},De={typescript:pe,javascript:vi,css:ki,json:wi,markdown:Re,text:Re};function je(n,e){return{fileId:n,doc:[...e],cur:{row:0,col:0},sel:null,dirty:!1,undoStack:[],redoStack:[],scrollTop:0}}function M(n,e=300){const t={doc:[...n.doc],cur:{...n.cur},sel:n.sel?{...n.sel}:null};n.undoStack.push(t),n.undoStack.length>e&&n.undoStack.shift(),n.redoStack=[],n.dirty=!0}function _i(n){if(!n.undoStack.length)return!1;const e={doc:[...n.doc],cur:{...n.cur},sel:n.sel?{...n.sel}:null};n.redoStack.push(e);const t=n.undoStack.pop();return n.doc=t.doc,n.cur=t.cur,n.sel=t.sel,!0}function Ci(n){if(!n.redoStack.length)return!1;const e={doc:[...n.doc],cur:{...n.cur},sel:n.sel?{...n.sel}:null};n.undoStack.push(e);const t=n.redoStack.pop();return n.doc=t.doc,n.cur=t.cur,n.sel=t.sel,!0}function L(n){const{doc:e,cur:t}=n;t.row=Math.max(0,Math.min(e.length-1,t.row)),t.col=Math.max(0,Math.min((e[t.row]??"").length,t.col))}function N(n){const{ar:e,ac:t,fr:i,fc:r}=n;return e<i||e===i&&t<=r?n:{ar:i,ac:r,fr:e,fc:t}}function Ne(n,e,t){if(!n)return null;const i=N(n);return e<i.ar||e>i.fr?null:{start:e===i.ar?i.ac:0,end:e===i.fr?i.fc:t}}function Ti(n){if(!n.sel)return 0;const e=N(n.sel);let t=0;for(let i=e.ar;i<=e.fr;i++){const r=n.doc[i]??"",o=i===e.ar?e.ac:0,s=i===e.fr?e.fc:r.length;t+=s-o}return t}function Oe(n){if(!n.sel)return"";const e=N(n.sel),t=[];for(let i=e.ar;i<=e.fr;i++){const r=n.doc[i]??"";t.push(r.slice(i===e.ar?e.ac:0,i===e.fr?e.fc:r.length))}return t.join(`
6
- `)}function q(n){const e=n.sel;if(!e)return n.cur;const t=N(e),i=(n.doc[t.ar]??"").slice(0,t.ac),r=(n.doc[t.fr]??"").slice(t.fc);return n.doc.splice(t.ar,t.fr-t.ar+1,i+r),n.sel=null,{row:t.ar,col:t.ac}}function Ei(n,e,t){if(!t||n.length<=e)return[n];const i=[];let r=0;for(;r<n.length;){if(n.length-r<=e){i.push(n.slice(r));break}const o=r+e;let s=-1;for(let a=o;a>r;a--)if(n[a-1]===" "){s=a;break}s===-1?(i.push(n.slice(r,o)),r=o):(i.push(n.slice(r,s)),r=s)}return i}function Si(n,e,t,i){const r=[],o=[],s=[];let a=-1;for(let l=0;l<n.length;l++){if(l>0&&l<=a){s.push(o.length),r.push([n[l]??""]);continue}s.push(o.length);const d=Ei(n[l]??"",e,t);r.push(d),d.forEach((h,c)=>o.push({docLine:l,segIdx:c,text:h})),i.has(l)&&(a=i.get(l))}return{segments:r,visualRows:o,docToVisArr:s}}function U(n,e,t){const i=n.segments[e]??[""];let r=t;for(let o=0;o<i.length;o++){if(r<=i[o].length||o===i.length-1)return{visRow:n.docToVisArr[e]+o,colInSeg:Math.min(r,i[o].length)};r-=i[o].length}return{visRow:n.docToVisArr[e]??0,colInSeg:0}}function te(n,e,t){var i;const r=n.visualRows[e];if(!r)return{row:0,col:0};const o=n.segments[r.docLine]??[""];let s=Math.min(t,((i=o[r.segIdx])==null?void 0:i.length)??0);for(let a=0;a<r.segIdx;a++)s+=o[a].length;return{row:r.docLine,col:s}}function ue(n,e={}){var t,i;const r=[],o=n.length;let s=0;const a=(p,m,g)=>{g>m&&r.push({cls:p,start:m,end:g})},l=He[e.language??"typescript"]??he,d=De[e.language??"typescript"]??pe,h=(t=e.extraKeywords)!=null&&t.size?new Set([...l,...e.extraKeywords]):l,c=(i=e.extraTypes)!=null&&i.size?new Set([...d,...e.extraTypes]):d;for(;s<o;){if(n[s]==="/"&&n[s+1]==="/"){a("cmt",s,o);break}if(n[s]==="*"||n[s]==="/"&&n[s+1]==="*"){a("cmt",s,o);break}if(n[s]==="@"){let p=s+1;for(;p<o&&/\w/.test(n[p]);)p++;a("dec",s,p),s=p;continue}if(n[s]==='"'||n[s]==="'"||n[s]==="`"){const p=n[s];let m=s+1;for(;m<o;){if(n[m]==="\\"){m+=2;continue}if(n[m]===p){m++;break}m++}a("str",s,m),s=m;continue}if(/\d/.test(n[s])&&(s===0||!/\w/.test(n[s-1]))){let p=s;for(;p<o&&/[\d._xXa-fA-F]/.test(n[p]);)p++;a("num",s,p),s=p;continue}if(/[a-zA-Z_$]/.test(n[s])){let p=s;for(;p<o&&/[\w$]/.test(n[p]);)p++;const m=n.slice(s,p);h.has(m)?a("kw",s,p):c.has(m)?a("typ",s,p):p<o&&n[p]==="("?a("fn",s,p):/^[A-Z]/.test(m)&&a("cls",s,p),s=p;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(n[s])){a("op",s,s+1),s++;continue}s++}return r}function We(n,e){const t=new Array(n.length).fill("");for(const i of e)for(let r=i.start;r<i.end;r++)t[r]=i.cls;return t}class Mi{constructor(e=5e3){y(this,"_cache",new Map),y(this,"_maxSize"),y(this,"_hits",0),y(this,"_misses",0),y(this,"_evictions",0),this._maxSize=e}get metrics(){return{hits:this._hits,misses:this._misses,evictions:this._evictions,size:this._cache.size}}get(e,t){const i=this._cache.get(e);return i&&i.src===t?(this._hits++,i.segs):(this._misses++,null)}set(e,t,i){this._cache.size>=this._maxSize&&(this._cache.delete(this._cache.keys().next().value),this._evictions++),this._cache.set(e,{src:t,segs:i})}invalidateLine(e,t){for(let i=0;i<t;i++)this._cache.delete(`${e}:${i}`)}clear(){this._cache.clear(),this._hits=0,this._misses=0,this._evictions=0}resetMetrics(){this._hits=0,this._misses=0,this._evictions=0}}const $i={id:"",name:"VR Dark",description:"Default deep dark theme",light:!1,tokens:{bg0:"#0d0d0f",bg1:"#111115",bg2:"#16161b",bg3:"#1d1d24",bg4:"#24242d",border:"rgba(255,255,255,.07)",border2:"rgba(255,255,255,.12)",border3:"rgba(255,255,255,.19)",text:"#c9c7c0",text2:"#8b8994",text3:"#4e4c58",accent:"#6e9fff",accent2:"#2f5db0",green:"#4ec9a0",orange:"#d4976e",purple:"#b48eff",red:"#f28b82",yellow:"#e8c97a",cur:"#6e9fff",curGlow:"rgba(110,159,255,.65)",curLineBg:"rgba(255,255,255,.032)",curLineGutter:"#181820",gutterBg:"#0f0f12",gutterHover:"#181820",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#4e4c58",gutterNumAct:"#9997a2",selBg:"rgba(110,159,255,.22)",wordHlBg:"rgba(200,198,210,.09)",wordHlBorder:"rgba(200,198,210,.28)",bmBorder:"rgba(110,159,255,.65)",foldBg:"rgba(110,159,255,.07)",foldBorder:"rgba(110,159,255,.30)",findBg:"rgba(234,180,86,.18)",findBorder:"rgba(234,180,86,.50)",findCurBg:"rgba(234,180,86,.80)",findCurBorder:"rgba(234,180,86,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(110,159,255,.11)",fileActiveText:"#6e9fff",mmBg:"#0d0d0f",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#6e9fff",tokStr:"#4ec9a0",tokCmt:"#4e4c58",tokFn:"#d4976e",tokNum:"#b48eff",tokCls:"#e8c97a",tokOp:"#55536a",tokTyp:"#6ec9d4",tokDec:"#f28b82"}},Li={id:"vscode-dark",name:"VSCode Dark+",description:"Visual Studio Code dark",light:!1,tokens:{bg0:"#1e1e1e",bg1:"#252526",bg2:"#1e1e1e",bg3:"#2d2d30",bg4:"#3a3a3d",border:"rgba(255,255,255,.09)",border2:"rgba(255,255,255,.15)",border3:"rgba(255,255,255,.24)",text:"#d4d4d4",text2:"#9a9a9a",text3:"#505050",accent:"#569cd6",accent2:"#0e639c",green:"#4ec9b0",orange:"#ce9178",purple:"#c586c0",red:"#f44747",yellow:"#dcdcaa",cur:"#aeafad",curGlow:"rgba(174,175,173,.40)",curLineBg:"rgba(255,255,255,.038)",curLineGutter:"#282828",gutterBg:"#1e1e1e",gutterHover:"#282828",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#838383",gutterNumAct:"#c8c8c8",selBg:"rgba(38,79,120,.65)",wordHlBg:"rgba(173,214,255,.06)",wordHlBorder:"rgba(173,214,255,.28)",bmBorder:"rgba(86,156,214,.70)",foldBg:"rgba(86,156,214,.07)",foldBorder:"rgba(86,156,214,.35)",findBg:"rgba(255,215,0,.13)",findBorder:"rgba(255,215,0,.52)",findCurBg:"#f6f6a0",findCurBorder:"#d4d400",findCurText:"#000",fileActiveBg:"rgba(255,255,255,.07)",fileActiveText:"#d4d4d4",mmBg:"#1e1e1e",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#569cd6",tokStr:"#ce9178",tokCmt:"#6a9955",tokFn:"#dcdcaa",tokNum:"#b5cea8",tokCls:"#4ec9b0",tokOp:"#d4d4d4",tokTyp:"#4ec9b0",tokDec:"#9cdcfe"}},Bi={id:"monokai",name:"Monokai",description:"Classic Sublime Text theme",light:!1,tokens:{bg0:"#272822",bg1:"#1e1f1c",bg2:"#272822",bg3:"#3a3930",bg4:"#48473d",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.13)",border3:"rgba(255,255,255,.20)",text:"#f8f8f2",text2:"#a8a7a0",text3:"#58574e",accent:"#a6e22e",accent2:"#3d5a10",green:"#a6e22e",orange:"#fd971f",purple:"#ae81ff",red:"#f92672",yellow:"#e6db74",cur:"#f8f8f2",curGlow:"rgba(248,248,242,.25)",curLineBg:"rgba(255,255,255,.042)",curLineGutter:"#2c2d27",gutterBg:"#1e1f1c",gutterHover:"#2c2d27",gutterBorder:"rgba(255,255,255,.06)",gutterNum:"#6e6d64",gutterNumAct:"#cccac0",selBg:"rgba(73,72,62,.80)",wordHlBg:"rgba(248,248,242,.06)",wordHlBorder:"rgba(248,248,242,.22)",bmBorder:"rgba(166,226,46,.65)",foldBg:"rgba(166,226,46,.07)",foldBorder:"rgba(166,226,46,.30)",findBg:"rgba(230,219,116,.16)",findBorder:"rgba(230,219,116,.52)",findCurBg:"#e6db74",findCurBorder:"#c9be50",findCurText:"#272822",fileActiveBg:"rgba(166,226,46,.10)",fileActiveText:"#a6e22e",mmBg:"#1e1f1c",mmSlider:"rgba(255,255,255,.06)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#f92672",tokStr:"#e6db74",tokCmt:"#75715e",tokFn:"#a6e22e",tokNum:"#ae81ff",tokCls:"#66d9e8",tokOp:"#f8f8f2",tokTyp:"#66d9e8",tokDec:"#fd971f"}},Ai={id:"dracula",name:"Dracula",description:"Purple-tinted dark theme",light:!1,tokens:{bg0:"#282a36",bg1:"#21222c",bg2:"#282a36",bg3:"#333545",bg4:"#44475a",border:"rgba(255,255,255,.08)",border2:"rgba(255,255,255,.14)",border3:"rgba(255,255,255,.22)",text:"#f8f8f2",text2:"#b2b5c8",text3:"#5a5e78",accent:"#bd93f9",accent2:"#5b3fa8",green:"#50fa7b",orange:"#ffb86c",purple:"#bd93f9",red:"#ff5555",yellow:"#f1fa8c",cur:"#f8f8f2",curGlow:"rgba(189,147,249,.55)",curLineBg:"rgba(255,255,255,.045)",curLineGutter:"#2f3144",gutterBg:"#21222c",gutterHover:"#2f3144",gutterBorder:"rgba(255,255,255,.07)",gutterNum:"#5e638a",gutterNumAct:"#f8f8f2",selBg:"rgba(68,71,90,.85)",wordHlBg:"rgba(248,248,242,.05)",wordHlBorder:"rgba(248,248,242,.20)",bmBorder:"rgba(189,147,249,.70)",foldBg:"rgba(189,147,249,.08)",foldBorder:"rgba(189,147,249,.35)",findBg:"rgba(241,250,140,.14)",findBorder:"rgba(241,250,140,.52)",findCurBg:"#f1fa8c",findCurBorder:"#d4dc50",findCurText:"#282a36",fileActiveBg:"rgba(189,147,249,.12)",fileActiveText:"#bd93f9",mmBg:"#21222c",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.32)",mmEdge:"rgba(255,255,255,.20)",indentGuide:"rgba(255,255,255,.07)",tokKw:"#ff79c6",tokStr:"#f1fa8c",tokCmt:"#6272a4",tokFn:"#50fa7b",tokNum:"#bd93f9",tokCls:"#8be9fd",tokOp:"#f8f8f2",tokTyp:"#8be9fd",tokDec:"#ffb86c"}},Ii={id:"github-light",name:"GitHub Light",description:"GitHub's clean light theme",light:!0,tokens:{bg0:"#ffffff",bg1:"#f6f8fa",bg2:"#ffffff",bg3:"#f0f3f6",bg4:"#e7eaee",border:"#d0d7de",border2:"#bdc4cc",border3:"#aab1ba",text:"#1f2328",text2:"#57606a",text3:"#8c959f",accent:"#0969da",accent2:"#0550ae",green:"#1a7f37",orange:"#bc4c00",purple:"#8250df",red:"#cf222e",yellow:"#7d4e00",cur:"#0969da",curGlow:"rgba(9,105,218,.30)",curLineBg:"rgba(9,105,218,.055)",curLineGutter:"#ebf0f8",gutterBg:"#f6f8fa",gutterHover:"#eaedf1",gutterBorder:"#d0d7de",gutterNum:"#9da5b0",gutterNumAct:"#1f2328",selBg:"rgba(9,105,218,.15)",wordHlBg:"rgba(9,105,218,.07)",wordHlBorder:"rgba(9,105,218,.28)",bmBorder:"rgba(9,105,218,.60)",foldBg:"rgba(9,105,218,.06)",foldBorder:"rgba(9,105,218,.28)",findBg:"rgba(180,100,0,.09)",findBorder:"rgba(180,100,0,.42)",findCurBg:"rgba(180,100,0,.75)",findCurBorder:"rgba(180,100,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(9,105,218,.09)",fileActiveText:"#0969da",mmBg:"#f6f8fa",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.09)",tokKw:"#cf222e",tokStr:"#0a3069",tokCmt:"#6e7781",tokFn:"#8250df",tokNum:"#0550ae",tokCls:"#953800",tokOp:"#1f2328",tokTyp:"#0550ae",tokDec:"#0969da"}},Pi={id:"solarized-light",name:"Solarized Light",description:"Warm precision light theme",light:!0,tokens:{bg0:"#fdf6e3",bg1:"#eee8d5",bg2:"#fdf6e3",bg3:"#e5dfcc",bg4:"#dad4c1",border:"#cdc7b4",border2:"#bab4a2",border3:"#a9a390",text:"#002b36",text2:"#586e75",text3:"#93a1a1",accent:"#268bd2",accent2:"#1a6fa8",green:"#859900",orange:"#cb4b16",purple:"#6c71c4",red:"#dc322f",yellow:"#b58900",cur:"#268bd2",curGlow:"rgba(38,139,210,.32)",curLineBg:"rgba(38,139,210,.07)",curLineGutter:"#e2dcc8",gutterBg:"#eee8d5",gutterHover:"#e2dcc8",gutterBorder:"#cdc7b4",gutterNum:"#93a1a1",gutterNumAct:"#002b36",selBg:"rgba(38,139,210,.18)",wordHlBg:"rgba(38,139,210,.08)",wordHlBorder:"rgba(38,139,210,.28)",bmBorder:"rgba(38,139,210,.58)",foldBg:"rgba(38,139,210,.07)",foldBorder:"rgba(38,139,210,.28)",findBg:"rgba(181,137,0,.11)",findBorder:"rgba(181,137,0,.42)",findCurBg:"rgba(181,137,0,.75)",findCurBorder:"rgba(181,137,0,.95)",findCurText:"#fff",fileActiveBg:"rgba(38,139,210,.10)",fileActiveText:"#268bd2",mmBg:"#eee8d5",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.055)",mmEdge:"rgba(0,0,0,.16)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#859900",tokStr:"#2aa198",tokCmt:"#93a1a1",tokFn:"#268bd2",tokNum:"#d33682",tokCls:"#b58900",tokOp:"#657b83",tokTyp:"#268bd2",tokDec:"#cb4b16"}},Ri={id:"mdx-dark",name:"MDX Dark",description:"Catppuccin Mocha — matches .smdx-dark MDX editor chrome, single-colour tokens",light:!1,tokens:{bg0:"#181825",bg1:"#1e1e2e",bg2:"#1e1e2e",bg3:"#2a2a3c",bg4:"#313147",border:"#374151",border2:"rgba(129,140,248,.22)",border3:"rgba(129,140,248,.40)",text:"#e2e8f0",text2:"#94a3b8",text3:"#475569",accent:"#818cf8",accent2:"#6366f1",green:"#c3e88d",orange:"#f78c6c",purple:"#c792ea",red:"#f07178",yellow:"#ffcb6b",cur:"#818cf8",curGlow:"rgba(129,140,248,.55)",curLineBg:"rgba(129,140,248,.055)",curLineGutter:"#252540",gutterBg:"#181825",gutterHover:"#252540",gutterBorder:"#374151",gutterNum:"#475569",gutterNumAct:"#94a3b8",selBg:"rgba(129,140,248,.24)",wordHlBg:"rgba(226,232,240,.07)",wordHlBorder:"rgba(226,232,240,.25)",bmBorder:"rgba(137,221,255,.70)",foldBg:"rgba(129,140,248,.07)",foldBorder:"rgba(129,140,248,.30)",findBg:"rgba(251,191,36,.16)",findBorder:"rgba(251,191,36,.50)",findCurBg:"rgba(251,191,36,.85)",findCurBorder:"rgba(251,191,36,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(129,140,248,.12)",fileActiveText:"#818cf8",mmBg:"#181825",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#e2e8f0",tokStr:"#e2e8f0",tokCmt:"#e2e8f0",tokFn:"#e2e8f0",tokNum:"#e2e8f0",tokCls:"#e2e8f0",tokOp:"#e2e8f0",tokTyp:"#e2e8f0",tokDec:"#e2e8f0"}},Hi={id:"mdx-light",name:"MDX Light",description:"Clean light — matches default .smdx-editor MDX chrome, single-colour tokens",light:!0,tokens:{bg0:"#f1f5f9",bg1:"#ffffff",bg2:"#ffffff",bg3:"#f8fafc",bg4:"#f1f5f9",border:"#e2e8f0",border2:"rgba(99,102,241,.20)",border3:"rgba(99,102,241,.40)",text:"#1e293b",text2:"#64748b",text3:"#94a3b8",accent:"#6366f1",accent2:"#4f46e5",green:"#15803d",orange:"#c2410c",purple:"#7c3aed",red:"#dc2626",yellow:"#b45309",cur:"#6366f1",curGlow:"rgba(99,102,241,.35)",curLineBg:"rgba(99,102,241,.05)",curLineGutter:"#eef2ff",gutterBg:"#f8fafc",gutterHover:"#eef2ff",gutterBorder:"#e2e8f0",gutterNum:"#94a3b8",gutterNumAct:"#475569",selBg:"rgba(99,102,241,.18)",wordHlBg:"rgba(99,102,241,.07)",wordHlBorder:"rgba(99,102,241,.30)",bmBorder:"rgba(14,116,144,.60)",foldBg:"rgba(99,102,241,.06)",foldBorder:"rgba(99,102,241,.28)",findBg:"rgba(180,83,9,.09)",findBorder:"rgba(180,83,9,.40)",findCurBg:"rgba(180,83,9,.75)",findCurBorder:"rgba(180,83,9,.95)",findCurText:"#ffffff",fileActiveBg:"rgba(99,102,241,.10)",fileActiveText:"#6366f1",mmBg:"#f8fafc",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.05)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#1e293b",tokStr:"#1e293b",tokCmt:"#1e293b",tokFn:"#1e293b",tokNum:"#1e293b",tokCls:"#1e293b",tokOp:"#1e293b",tokTyp:"#1e293b",tokDec:"#1e293b"}},Di=[$i,Li,Bi,Ai,Ii,Pi,Ri,Hi],ji={bg0:"--bg0",bg1:"--bg1",bg2:"--bg2",bg3:"--bg3",bg4:"--bg4",border:"--border",border2:"--border2",border3:"--border3",text:"--text",text2:"--text2",text3:"--text3",accent:"--accent",accent2:"--accent2",green:"--green",orange:"--orange",purple:"--purple",red:"--red",yellow:"--yellow",cur:"--cur",curGlow:"--cur-glow",curLineBg:"--cur-line-bg",curLineGutter:"--cur-line-gutter",gutterBg:"--gutter-bg",gutterHover:"--gutter-hover",gutterBorder:"--gutter-border",gutterNum:"--gutter-num",gutterNumAct:"--gutter-num-act",selBg:"--sel-bg",wordHlBg:"--word-hl-bg",wordHlBorder:"--word-hl-border",bmBorder:"--bm-border",foldBg:"--fold-bg",foldBorder:"--fold-border",findBg:"--find-bg",findBorder:"--find-border",findCurBg:"--find-cur-bg",findCurBorder:"--find-cur-border",findCurText:"--find-cur-text",fileActiveBg:"--file-active-bg",fileActiveText:"--file-active-text",mmBg:"--mm-bg",mmSlider:"--mm-slider",mmDim:"--mm-dim",mmEdge:"--mm-edge",indentGuide:"--indent-guide",tokKw:"--tok-kw",tokStr:"--tok-str",tokCmt:"--tok-cmt",tokFn:"--tok-fn",tokNum:"--tok-num",tokCls:"--tok-cls",tokOp:"--tok-op",tokTyp:"--tok-typ",tokDec:"--tok-dec"};class Ni{constructor(e){y(this,"_registry",new Map),y(this,"_activeId",""),y(this,"_root"),this._root=e;for(const t of Di)this._registry.set(t.id,t)}register(e){this._registry.set(e.id,e)}apply(e){let t;typeof e=="string"?(t=this._registry.get(e),t||(console.warn(`[syncline-editor] Unknown theme: "${e}". Falling back to VR Dark.`),t=this._registry.get(""))):(t=e,this._registry.set(t.id,t)),this._activeId=t.id,this._applyTokens(t.tokens)}get activeId(){return this._activeId}get activeTheme(){return this._registry.get(this._activeId)}get allIds(){return[...this._registry.keys()]}get all(){return[...this._registry.values()]}_applyTokens(e){const t=this._root.style;for(const[i,r]of Object.entries(ji))t.setProperty(r,e[i])}}const Oi=`
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");t=i.map(a=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">&#9888;</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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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)||"&#8203;"}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||"&#8203;"}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||"&#8203;"}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=`
7
163
  /* ── Reset ── */
8
164
  *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
9
165
 
@@ -72,7 +228,7 @@
72
228
  .sl-editor::-webkit-scrollbar-track{background:transparent}
73
229
  .sl-editor::-webkit-scrollbar-thumb{background:var(--border3);border-radius:5px;border:2px solid var(--bg2)}
74
230
  .sl-spacer{position:absolute;left:0;top:0;width:1px;pointer-events:none}
75
- .sl-vp{position:absolute;left:0;right:0;will-change:transform}
231
+ .sl-vp{position:absolute;left:0;right:0;overflow-x:hidden;will-change:transform}
76
232
 
77
233
  /* ── Editor row ── */
78
234
  .sl-er{display:flex;align-items:stretch;position:relative}
@@ -108,11 +264,16 @@
108
264
  box-shadow:0 0 8px var(--cur-glow);
109
265
  animation:sl-blink 1.05s step-end infinite;pointer-events:none}
110
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
+
111
272
  /* ── Overlays ── */
112
273
  .sl-sh{background:var(--sel-bg);border-radius:2px}
113
- .sl-fh{background:var(--find-bg);border:1px solid var(--find-border);border-radius:2px}
114
- .sl-fh.sl-fh-cur{background:var(--find-cur-bg);border:1px solid var(--find-cur-border);color:var(--find-cur-text)}
115
- .sl-wh{background:var(--word-hl-bg);border:1px solid var(--word-hl-border);border-radius:2px}
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}
116
277
  .sl-bm{box-shadow:0 0 0 1px var(--bm-border);border-radius:2px}
117
278
  .sl-ig{position:absolute;top:0;bottom:0;width:1px;background:var(--indent-guide);pointer-events:none}
118
279
 
@@ -148,6 +309,24 @@
148
309
  .sl-sb-right{margin-left:auto;display:flex;align-items:center}
149
310
  .sl-sb-wrap.sl-on{font-weight:700}
150
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
+
151
330
  /* ── Find + Replace bar ── */
152
331
  .sl-find-bar{position:absolute;top:0;right:125px;z-index:50;background:var(--bg3);
153
332
  border:1px solid var(--border3);border-top:none;border-radius:0 0 10px 10px;
@@ -265,163 +444,7 @@
265
444
  /* ── Empty state ── */
266
445
  .sl-empty{flex:1;display:flex;flex-direction:column;align-items:center;
267
446
  justify-content:center;gap:10px;color:var(--text3);font-size:13px}
268
- `;function B(n,e,t){const i=document.createElement(n);return e&&(i.className=e),i}function X(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function me(n,e=document.documentElement){return getComputedStyle(e).getPropertyValue(n).trim()}function ze(n,e){const t=n.replace("#",""),i=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return`rgba(${i},${r},${o},${e})`}function Fe(n){return n.split(`
269
- `)}function A(n){return n.join(`
270
- `)}function Ge(n){return(n.match(/^(\s*)/)??["",""])[1]}function ie(n){return" ".repeat(Math.max(0,n))}function Ve(n){return/[\w$]/.test(n)}function ge(n,e,t=Ve){let i=e;for(;i>0&&t(n[i-1]);)i--;return i}function be(n,e,t=Ve){let i=e;for(;i<n.length&&t(n[i]);)i++;return i}function fe(n,e){let t=0,i=null;return(...r)=>{const o=Date.now(),s=e-(o-t);s<=0?(i!==null&&(clearTimeout(i),i=null),t=o,n(...r)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,n(...r)},s))}}const Wi={fontSize:[8,72,13],lineHeight:[14,64,22],tabSize:[1,16,2],wrapColumn:[20,500,80],maxCompletions:[1,50,14],autocompletePrefixLength:[1,10,2],gutterWidth:[30,200,60],minimapWidth:[60,300,120],cursorBlinkRate:[200,5e3,1050],maxUndoHistory:[10,5e3,300],undoBatchMs:[0,5e3,700]};function zi(n,e,t,i){const r=Number(n);return Number.isFinite(r)?Math.max(e,Math.min(t,Math.round(r))):i}function qe(n){const e={...n};for(const[t,i]of Object.entries(Wi))if(t in n&&n[t]!==void 0){const[r,o,s]=i;e[t]=zi(n[t],r,o,s)}return e}const xe={"(":")","{":"}","[":"]"},ye={")":"(","}":"{","]":"["};function Fi(n,e){const{row:t,col:i}=e,r=n[t]??"";let o=r[i],s=i;if(!xe[o]&&!ye[o]&&(o=r[i-1],s=i-1),!o)return null;if(xe[o]){const a=xe[o];let l=0;for(let d=t;d<Math.min(n.length,t+500);d++){const h=n[d]??"",c=d===t?s:0;for(let p=c;p<h.length;p++)if(h[p]===o)l++;else if(h[p]===a&&(l--,l===0))return{open:{row:t,col:s},close:{row:d,col:p}}}}else if(ye[o]){const a=ye[o];let l=0;for(let d=t;d>=Math.max(0,t-500);d--){const h=n[d]??"",c=d===t?s:h.length-1;for(let p=c;p>=0;p--)if(h[p]===o)l++;else if(h[p]===a&&(l--,l===0))return{open:{row:d,col:p},close:{row:t,col:s}}}}return null}function Gi(n,e){const t=n[e]??"";let i=0;for(const r of t)r==="{"?i++:r==="}"&&i--;return i>0}function Vi(n,e){let t=0;for(let i=e;i<n.length;i++)for(const r of n[i]??"")if(r==="{")t++;else if(r==="}"&&(t--,t===0))return i;return null}function qi(n,e,t){const i=new Map(n);if(i.has(t))i.delete(t);else{const r=Vi(e,t);r!==null&&r>t&&i.set(t,r)}return i}const Ui=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function Ue(n){const e=n.trim();if(!e)return null;try{const t=ve(e);return t===e?null:t}catch{return null}}function ve(n){if(n.includes(">")){const t=n.indexOf(">");return ke(n.slice(0,t),ve(n.slice(t+1)))}if(n.includes("+"))return n.split("+").map(t=>ve(t.trim())).join(`
271
- `);const e=n.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,r)=>ke(e[1],`$${r+1}`)).join(`
272
- `)}return ke(n,"$1")}function ke(n,e){const t=n.match(/#([\w-]+)/),i=n.match(/\.([\w.-]+)/g),r=n.match(/\[([^\]]+)\]/);let o=n.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",s="";return t&&(s+=` id="${t[1]}"`),i&&(s+=` class="${i.map(a=>a.slice(1)).join(" ")}"`),r&&(s+=` ${r[1]}`),Ui.has(o)?`<${o}${s}>`:`<${o}${s}>${e}</${o}>`}function Ke(n,e){let t=e;for(;t>0&&/[\w#.[\]*>+{}()$@:-]/.test(n[t-1]);)t--;const i=n.slice(t,e);return i.length<2?null:{abbr:i,start:t}}const Ki=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
273
-
274
- function name(params) {
275
- // body
276
- }`,body:`function $1($2) {
277
- $3
278
- }`},{label:"afn",kind:"snip",detail:"arrow function",description:`Declares a const arrow function.
279
-
280
- const name = (params) => {
281
- // body
282
- };`,body:`const $1 = ($2) => {
283
- $3
284
- };`},{label:"asyncfn",kind:"snip",detail:"async function",description:`Declares an async function returning a Promise.
285
-
286
- async function name(params): Promise<T> {
287
- // body
288
- }`,body:`async function $1($2): Promise<$3> {
289
- $4
290
- }`},{label:"cl",kind:"snip",detail:"class declaration",description:`Declares a class with a constructor.
291
-
292
- class Name {
293
- constructor(params) { ... }
294
- }`,body:`class $1 {
295
- constructor($2) {
296
- $3
297
- }
298
- }`},{label:"forof",kind:"snip",detail:"for…of loop",description:`Iterates over the values of an iterable (array, string, Map, etc.).
299
-
300
- for (const item of iterable) { ... }`,body:`for (const $1 of $2) {
301
- $3
302
- }`},{label:"forin",kind:"snip",detail:"for…in loop",description:`Iterates over the enumerable property keys of an object.
303
-
304
- for (const key in object) { ... }`,body:`for (const $1 in $2) {
305
- $3
306
- }`},{label:"trycatch",kind:"snip",detail:"try / catch block",description:`Wraps code in a try/catch to handle runtime errors.
307
-
308
- try {
309
- ...
310
- } catch (error) {
311
- ...
312
- }`,body:`try {
313
- $1
314
- } catch ($2error) {
315
- $3
316
- }`},{label:"promise",kind:"snip",detail:"new Promise",description:`Creates a new Promise with resolve and reject handlers.
317
-
318
- new Promise<T>((resolve, reject) => { ... })`,body:`new Promise<$1>((resolve, reject) => {
319
- $2
320
- })`},{label:"imp",kind:"snip",detail:"import statement",description:`Adds a named import from a module.
321
-
322
- import { name } from 'module';`,body:"import { $1 } from '$2';"},{label:"iface",kind:"snip",detail:"interface (TypeScript)",description:`Declares a TypeScript interface.
323
-
324
- interface Name {
325
- field: Type;
326
- }`,body:`interface $1 {
327
- $2: $3;
328
- }`,language:["typescript"]},{label:"ife",kind:"snip",detail:"immediately-invoked function expression",description:`An IIFE — defines and immediately calls a function.
329
-
330
- ((params) => {
331
- ...
332
- })(args);`,body:`(($1) => {
333
- $2
334
- })($3);`},{label:"sw",kind:"snip",detail:"switch statement",description:`A switch/case statement with a default branch.
335
-
336
- switch (expr) {
337
- case value:
338
- ...
339
- break;
340
- default:
341
- ...
342
- }`,body:`switch ($1) {
343
- case $2:
344
- $3
345
- break;
346
- default:
347
- $4
348
- }`}],Yi=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
349
-
350
- display: flex;
351
- align-items: center;
352
- justify-content: center;`,body:`display: flex;
353
- align-items: $1center;
354
- justify-content: $2center;`,language:["css"]},{label:"grid",kind:"snip",detail:"CSS grid",description:`Sets up a CSS grid with equal columns and gap.
355
-
356
- display: grid;
357
- grid-template-columns: repeat(3, 1fr);
358
- gap: 16px;`,body:`display: grid;
359
- grid-template-columns: $1repeat(3, 1fr);
360
- gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",description:`A responsive media query breakpoint.
361
-
362
- @media (max-width: 768px) {
363
- ...
364
- }`,body:`@media ($1max-width: 768px) {
365
- $2
366
- }`,language:["css"]},{label:"anim",kind:"snip",detail:"@keyframes animation",description:`A CSS keyframes animation block.
367
-
368
- @keyframes name {
369
- from { ... }
370
- to { ... }
371
- }`,body:`@keyframes $1 {
372
- from { $2 }
373
- to { $3 }
374
- }`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
375
-
376
- --name: value;`,body:"--$1: $2;",language:["css"]}],Xi=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
377
-
378
- <details>
379
- <summary>Title</summary>
380
- <div>content</div>
381
- </details>`,body:`<details>
382
- <summary>$1Title</summary>
383
- <div>
384
- $2
385
- </div>
386
- </details>`},{label:"card",kind:"snip",detail:"card component",description:"A generic card component with header, body, and footer sections.",body:`<div class="card">
387
- <div class="card-header">$1</div>
388
- <div class="card-body">$2</div>
389
- <div class="card-footer">$3</div>
390
- </div>`},{label:"navbar",kind:"snip",detail:"navigation bar",description:`A simple navigation bar with anchor links.
391
-
392
- <nav class="navbar">
393
- <a href="#">Home</a> ...
394
- </nav>`,body:`<nav class="navbar">
395
- <a href="$1#">Home</a>
396
- <a href="$2#">About</a>
397
- <a href="$3#">Contact</a>
398
- </nav>`},{label:"modal",kind:"snip",detail:"modal dialog",description:`A modal dialog layout with header, body, and footer.
399
-
400
- <div class="modal">
401
- <div class="modal-dialog"> ... </div>
402
- </div>`,body:`<div class="modal">
403
- <div class="modal-dialog">
404
- <div class="modal-header">$1</div>
405
- <div class="modal-body">$2</div>
406
- <div class="modal-footer">$3</div>
407
- </div>
408
- </div>`},{label:"table",kind:"snip",detail:"HTML table",description:`A semantic HTML table with thead and tbody.
409
-
410
- <table>
411
- <thead><tr><th>...</th></tr></thead>
412
- <tbody><tr><td>...</td></tr></tbody>
413
- </table>`,body:`<table>
414
- <thead>
415
- <tr>
416
- <th>$1</th>
417
- </tr>
418
- </thead>
419
- <tbody>
420
- <tr>
421
- <td>$2</td>
422
- </tr>
423
- </tbody>
424
- </table>`}];function Ji(n){const e=[...Xi];return(n==="typescript"||n==="javascript")&&e.push(...Ki.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(n):t.language===n))),n==="css"&&e.push(...Yi),e}function Zi(n,e,t){let i=e;for(;i>0&&/\w/.test(n[i-1]);)i--;const r=n.slice(i,e);if(!r)return null;const o=t.find(s=>s.kind==="snip"&&s.label===r);return o?{snippet:o,start:i}:null}function Qi(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function Ye(n,e,t,i){n.cursors.some(r=>r.row===e&&r.col===t)||n.cursors.push({row:e,col:t,sel:i})}function Xe(n){n.cursors=[],n.searchWord="",n.lastMatchRow=-1,n.lastMatchCol=-1}function er(n,e,t,i,r){const o=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((h,c)=>({row:h.row,col:h.col,isPrimary:!1,idx:c+1}))];o.sort((h,c)=>c.row!==h.row?c.row-h.row:c.col-h.col);const s=n.map(h=>h);let a=e,l=t;const d=i.map(h=>({...h}));for(const h of o){const c=s[h.row]??"";s[h.row]=c.slice(0,h.col)+r+c.slice(h.col);for(const p of o)p!==h&&p.row===h.row&&p.col>=h.col&&(p.col+=r.length);h.col+=r.length,h.isPrimary?(a=h.row,l=h.col):(d[h.idx-1].row=h.row,d[h.idx-1].col=h.col)}return{doc:s,primaryRow:a,primaryCol:l,extraCursors:d}}function tr(n,e,t,i){const r=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((d,h)=>({row:d.row,col:d.col,isPrimary:!1,idx:h+1}))];r.sort((d,h)=>h.row!==d.row?h.row-d.row:h.col-d.col);const o=n.map(d=>d);let s=e,a=t;const l=i.map(d=>({...d}));for(const d of r){if(d.col<=0)continue;const h=o[d.row]??"";o[d.row]=h.slice(0,d.col-1)+h.slice(d.col);for(const c of r)c!==d&&c.row===d.row&&c.col>d.col&&c.col--;d.col--,d.isPrimary?(s=d.row,a=d.col):l[d.idx-1].col=d.col}return{doc:o,primaryRow:s,primaryCol:a,extraCursors:l}}function ir(n,e,t,i,r){let o=n.searchWord;if(!o){if(r&&r.ar===r.fr&&(o=(e[r.ar]??"").slice(r.ac,r.fc)),!o){const l=e[t]??"",d=ge(l,i),h=be(l,i);o=l.slice(d,h)}if(!o)return null;n.searchWord=o,n.lastMatchRow=t,n.lastMatchCol=i}const s=n.lastMatchRow,a=n.lastMatchCol;for(let l=s;l<e.length;l++){const d=e[l]??"";let h=l===s?a:0;for(;h<=d.length-o.length;){const c=d.indexOf(o,h);if(c<0)break;const p=c===0||!/\w/.test(d[c-1]),m=c+o.length>=d.length||!/\w/.test(d[c+o.length]);if(p&&m)return n.lastMatchRow=l,n.lastMatchCol=c+o.length,{word:o,sel:{ar:l,ac:c,fr:l,fc:c+o.length},row:l,col:c+o.length};h=c+1}}for(let l=0;l<=s;l++){const d=e[l]??"",h=l===s?a:d.length;let c=0;for(;c<h;){const p=d.indexOf(o,c);if(p<0||p>=h)break;const m=p===0||!/\w/.test(d[p-1]),g=p+o.length>=d.length||!/\w/.test(d[p+o.length]);if(m&&g)return n.lastMatchRow=l,n.lastMatchCol=p+o.length,{word:o,sel:{ar:l,ac:p,fr:l,fc:p+o.length},row:l,col:p+o.length};c=p+1}}return null}function rr(n,e,t){if(!e)return[];const i=[];for(let r=0;r<n.length;r++){const o=n[r]??"";if(t.useRegex)try{const s=new RegExp(e,t.caseSensitive?"g":"gi");let a;for(;(a=s.exec(o))!==null&&(i.push({row:r,col:a.index,len:a[0].length}),!!a[0].length););}catch{}else{const s=t.caseSensitive?o:o.toLowerCase(),a=t.caseSensitive?e:e.toLowerCase();let l=0;for(;;){const d=s.indexOf(a,l);if(d===-1)break;i.push({row:r,col:d,len:e.length}),l=d+1}}}return i}function nr(n,e,t,i){const r=e[t];if(!r)return n;const o=[...n],s=o[r.row]??"";return o[r.row]=s.slice(0,r.col)+i+s.slice(r.col+r.len),o}function or(n,e,t){const i=[...n];for(let r=e.length-1;r>=0;r--){const o=e[r],s=i[o.row]??"";i[o.row]=s.slice(0,o.col)+t+s.slice(o.col+o.len)}return i}function sr(n,e,t){return n.length?(e+t+n.length)%n.length:-1}function ar(n,e,t,i){if(i)return[];const r=n[e]??"",o=ge(r,t),s=be(r,t),a=r.slice(o,s);if(!a||a.length<2)return[];const l=[];for(let d=0;d<n.length;d++){const h=n[d]??"";let c=0;for(;c<=h.length-a.length;){const p=h.indexOf(a,c);if(p<0)break;const m=p===0||!/\w/.test(h[p-1]),g=p+a.length>=h.length||!/\w/.test(h[p+a.length]);m&&g&&!(d===e&&p===o)&&l.push({row:d,col:p,len:a.length}),c=p+1}}return l}const we=[{label:"console.log",kind:"fn",detail:"void"},{label:"console.error",kind:"fn",detail:"void"},{label:"console.warn",kind:"fn",detail:"void"},{label:"console.info",kind:"fn",detail:"void"},{label:"console.table",kind:"fn",detail:"void"},{label:"document.getElementById",kind:"fn",detail:"HTMLElement | null"},{label:"document.querySelector",kind:"fn",detail:"Element | null"},{label:"document.querySelectorAll",kind:"fn",detail:"NodeList"},{label:"document.createElement",kind:"fn",detail:"HTMLElement"},{label:"document.createTextNode",kind:"fn",detail:"Text"},{label:"addEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"removeEventListener",kind:"fn",detail:"(ev, cb) => void"},{label:"requestAnimationFrame",kind:"fn",detail:"(cb) => number"},{label:"cancelAnimationFrame",kind:"fn",detail:"(id) => void"},{label:"setTimeout",kind:"fn",detail:"(cb, ms) => id"},{label:"clearTimeout",kind:"fn",detail:"(id) => void"},{label:"setInterval",kind:"fn",detail:"(cb, ms) => id"},{label:"clearInterval",kind:"fn",detail:"(id) => void"},{label:"JSON.stringify",kind:"fn",detail:"string"},{label:"JSON.parse",kind:"fn",detail:"any"},{label:"Math.max",kind:"fn",detail:"number"},{label:"Math.min",kind:"fn",detail:"number"},{label:"Math.floor",kind:"fn",detail:"number"},{label:"Math.ceil",kind:"fn",detail:"number"},{label:"Math.round",kind:"fn",detail:"number"},{label:"Math.abs",kind:"fn",detail:"number"},{label:"Math.pow",kind:"fn",detail:"number"},{label:"Math.sqrt",kind:"fn",detail:"number"},{label:"Math.random",kind:"fn",detail:"number"},{label:"Object.keys",kind:"fn",detail:"string[]"},{label:"Object.values",kind:"fn",detail:"any[]"},{label:"Object.entries",kind:"fn",detail:"[string, any][]"},{label:"Object.assign",kind:"fn",detail:"T & U"},{label:"Object.freeze",kind:"fn",detail:"Readonly<T>"},{label:"Object.create",kind:"fn",detail:"object"},{label:"Array.from",kind:"fn",detail:"T[]"},{label:"Array.isArray",kind:"fn",detail:"boolean"},{label:"Promise.all",kind:"fn",detail:"Promise<T[]>"},{label:"Promise.resolve",kind:"fn",detail:"Promise<T>"},{label:"Promise.reject",kind:"fn",detail:"Promise<never>"},{label:"Promise.allSettled",kind:"fn",detail:"Promise<...>"},{label:"parseInt",kind:"fn",detail:"number"},{label:"parseFloat",kind:"fn",detail:"number"},{label:"isNaN",kind:"fn",detail:"boolean"},{label:"isFinite",kind:"fn",detail:"boolean"},{label:"encodeURIComponent",kind:"fn",detail:"string"},{label:"decodeURIComponent",kind:"fn",detail:"string"},{label:"structuredClone",kind:"fn",detail:"T"},{label:"queueMicrotask",kind:"fn",detail:"void"},{label:"fetch",kind:"fn",detail:"Promise<Response>"}],lr=[{label:"display",kind:"var",detail:"property"},{label:"position",kind:"var",detail:"property"},{label:"top",kind:"var",detail:"property"},{label:"right",kind:"var",detail:"property"},{label:"bottom",kind:"var",detail:"property"},{label:"left",kind:"var",detail:"property"},{label:"width",kind:"var",detail:"property"},{label:"height",kind:"var",detail:"property"},{label:"min-width",kind:"var",detail:"property"},{label:"max-width",kind:"var",detail:"property"},{label:"min-height",kind:"var",detail:"property"},{label:"max-height",kind:"var",detail:"property"},{label:"z-index",kind:"var",detail:"property"},{label:"overflow",kind:"var",detail:"property"},{label:"overflow-x",kind:"var",detail:"property"},{label:"overflow-y",kind:"var",detail:"property"},{label:"box-sizing",kind:"var",detail:"property"},{label:"flex",kind:"var",detail:"property"},{label:"flex-direction",kind:"var",detail:"property"},{label:"flex-wrap",kind:"var",detail:"property"},{label:"flex-grow",kind:"var",detail:"property"},{label:"flex-shrink",kind:"var",detail:"property"},{label:"flex-basis",kind:"var",detail:"property"},{label:"flex-flow",kind:"var",detail:"property"},{label:"align-items",kind:"var",detail:"property"},{label:"align-content",kind:"var",detail:"property"},{label:"align-self",kind:"var",detail:"property"},{label:"justify-content",kind:"var",detail:"property"},{label:"justify-items",kind:"var",detail:"property"},{label:"justify-self",kind:"var",detail:"property"},{label:"gap",kind:"var",detail:"property"},{label:"row-gap",kind:"var",detail:"property"},{label:"column-gap",kind:"var",detail:"property"},{label:"grid",kind:"var",detail:"property"},{label:"grid-template",kind:"var",detail:"property"},{label:"grid-template-columns",kind:"var",detail:"property"},{label:"grid-template-rows",kind:"var",detail:"property"},{label:"grid-template-areas",kind:"var",detail:"property"},{label:"grid-column",kind:"var",detail:"property"},{label:"grid-row",kind:"var",detail:"property"},{label:"grid-area",kind:"var",detail:"property"},{label:"grid-auto-flow",kind:"var",detail:"property"},{label:"margin",kind:"var",detail:"property"},{label:"margin-top",kind:"var",detail:"property"},{label:"margin-right",kind:"var",detail:"property"},{label:"margin-bottom",kind:"var",detail:"property"},{label:"margin-left",kind:"var",detail:"property"},{label:"padding",kind:"var",detail:"property"},{label:"padding-top",kind:"var",detail:"property"},{label:"padding-right",kind:"var",detail:"property"},{label:"padding-bottom",kind:"var",detail:"property"},{label:"padding-left",kind:"var",detail:"property"},{label:"color",kind:"var",detail:"property"},{label:"font",kind:"var",detail:"property"},{label:"font-family",kind:"var",detail:"property"},{label:"font-size",kind:"var",detail:"property"},{label:"font-weight",kind:"var",detail:"property"},{label:"font-style",kind:"var",detail:"property"},{label:"line-height",kind:"var",detail:"property"},{label:"text-align",kind:"var",detail:"property"},{label:"text-decoration",kind:"var",detail:"property"},{label:"text-transform",kind:"var",detail:"property"},{label:"letter-spacing",kind:"var",detail:"property"},{label:"word-spacing",kind:"var",detail:"property"},{label:"white-space",kind:"var",detail:"property"},{label:"word-break",kind:"var",detail:"property"},{label:"word-wrap",kind:"var",detail:"property"},{label:"text-overflow",kind:"var",detail:"property"},{label:"background",kind:"var",detail:"property"},{label:"background-color",kind:"var",detail:"property"},{label:"background-image",kind:"var",detail:"property"},{label:"background-size",kind:"var",detail:"property"},{label:"background-position",kind:"var",detail:"property"},{label:"background-repeat",kind:"var",detail:"property"},{label:"background-clip",kind:"var",detail:"property"},{label:"background-attachment",kind:"var",detail:"property"},{label:"border",kind:"var",detail:"property"},{label:"border-width",kind:"var",detail:"property"},{label:"border-style",kind:"var",detail:"property"},{label:"border-color",kind:"var",detail:"property"},{label:"border-radius",kind:"var",detail:"property"},{label:"border-top",kind:"var",detail:"property"},{label:"border-right",kind:"var",detail:"property"},{label:"border-bottom",kind:"var",detail:"property"},{label:"border-left",kind:"var",detail:"property"},{label:"outline",kind:"var",detail:"property"},{label:"outline-width",kind:"var",detail:"property"},{label:"outline-style",kind:"var",detail:"property"},{label:"outline-color",kind:"var",detail:"property"},{label:"outline-offset",kind:"var",detail:"property"},{label:"opacity",kind:"var",detail:"property"},{label:"box-shadow",kind:"var",detail:"property"},{label:"text-shadow",kind:"var",detail:"property"},{label:"filter",kind:"var",detail:"property"},{label:"backdrop-filter",kind:"var",detail:"property"},{label:"transform",kind:"var",detail:"property"},{label:"transform-origin",kind:"var",detail:"property"},{label:"transition",kind:"var",detail:"property"},{label:"animation",kind:"var",detail:"property"},{label:"animation-name",kind:"var",detail:"property"},{label:"animation-duration",kind:"var",detail:"property"},{label:"animation-timing-function",kind:"var",detail:"property"},{label:"animation-delay",kind:"var",detail:"property"},{label:"animation-iteration-count",kind:"var",detail:"property"},{label:"animation-fill-mode",kind:"var",detail:"property"},{label:"cursor",kind:"var",detail:"property"},{label:"pointer-events",kind:"var",detail:"property"},{label:"user-select",kind:"var",detail:"property"},{label:"resize",kind:"var",detail:"property"},{label:"visibility",kind:"var",detail:"property"},{label:"content",kind:"var",detail:"property"},{label:"list-style",kind:"var",detail:"property"},{label:"will-change",kind:"var",detail:"property"},{label:"appearance",kind:"var",detail:"property"},{label:"clip-path",kind:"var",detail:"property"},{label:"object-fit",kind:"var",detail:"property"},{label:"object-position",kind:"var",detail:"property"},{label:"scroll-behavior",kind:"var",detail:"property"},{label:"aspect-ratio",kind:"var",detail:"property"},{label:"var",kind:"fn",detail:"css fn"},{label:"calc",kind:"fn",detail:"css fn"},{label:"min",kind:"fn",detail:"css fn"},{label:"max",kind:"fn",detail:"css fn"},{label:"clamp",kind:"fn",detail:"css fn"},{label:"rgb",kind:"fn",detail:"css fn"},{label:"rgba",kind:"fn",detail:"css fn"},{label:"hsl",kind:"fn",detail:"css fn"},{label:"hsla",kind:"fn",detail:"css fn"},{label:"oklch",kind:"fn",detail:"css fn"},{label:"linear-gradient",kind:"fn",detail:"css fn"},{label:"radial-gradient",kind:"fn",detail:"css fn"},{label:"conic-gradient",kind:"fn",detail:"css fn"},{label:"translate",kind:"fn",detail:"css fn"},{label:"scale",kind:"fn",detail:"css fn"},{label:"rotate",kind:"fn",detail:"css fn"},{label:"skew",kind:"fn",detail:"css fn"},{label:"matrix",kind:"fn",detail:"css fn"},{label:"perspective",kind:"fn",detail:"css fn"},{label:"url",kind:"fn",detail:"css fn"},{label:"attr",kind:"fn",detail:"css fn"},{label:"env",kind:"fn",detail:"css fn"},{label:"repeat",kind:"fn",detail:"css fn"},{label:"minmax",kind:"fn",detail:"css fn"},{label:"fit-content",kind:"fn",detail:"css fn"}],dr={typescript:we,javascript:we,css:lr,json:[],markdown:[],text:[]};function Je(n,e,t){const i=He[n]??he,r=De[n]??pe,o=dr[n]??we;return[...[...i,...e].map(s=>({label:s,kind:"kw",detail:"keyword"})),...[...r,...t].map(s=>({label:s,kind:"typ",detail:"type"})),...o]}function cr(n,e){const t=new Set;for(const i of n){const r=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const o of r)o!==e&&o.length>2&&t.add(o)}return t}function Ze(n,e){return n.language?Array.isArray(n.language)?n.language.includes(e):n.language===e:!0}function hr(n,e,t={},i=0,r=0){if(e.length<2)return[];const o=e.toLowerCase(),{language:s="typescript",extraKeywords:a=[],extraTypes:l=[],completions:d=[],replaceBuiltins:h=!1,maxResults:c=14}=t,p=d.filter(v=>v.kind==="snip"&&!!v.body&&Ze(v,s)),m=d.filter(v=>!(v.kind==="snip"&&v.body)&&Ze(v,s)),g=p.filter(v=>v.label.toLowerCase().startsWith(o));let f;if(t.provideCompletions){const v={line:n[i]??"",col:r,prefix:e,language:s,doc:n};let E;try{E=t.provideCompletions(v)}catch(H){console.error("[syncline-editor] provideCompletions threw an error:",H),E=null}f=E!=null?[...E,...m]:[...h?[]:Je(s,a,l),...m]}else f=h?m:[...Je(s,a,l),...m];const u=new Set(f.map(v=>v.label)),k=f.filter(v=>v.label.toLowerCase().startsWith(o)&&v.label!==e),_=new Set(g.map(v=>v.label)),x=[...cr(n,e)].filter(v=>v.toLowerCase().startsWith(o)&&!u.has(v)&&!_.has(v)).slice(0,8).map(v=>({label:v,kind:"var",detail:"in file"}));return[...g,...k.filter(v=>!_.has(v.label)),...x].slice(0,c)}function pr(n,e,t=!1){let i=e;for(;i>0&&(t?/[\w$.\-]/:/[\w$.]/).test(n[i-1]);)i--;return{prefix:n.slice(i,e),start:i}}function ur(n,e){const t=o=>/[\w$]/.test(o);let i=e;for(;i<n.length&&t(n[i]);)i++;let r=e;for(;r>0&&t(n[r-1]);)r--;if(r===i)return"";if(r>0&&n[r-1]==="."){let o=r-1,s=o;for(;s>0&&t(n[s-1]);)s--;if(s<o)return n.slice(s,i)}return n.slice(r,i)}const mr={console:{title:"console",type:"Console",body:"Provides access to the browser's debugging console. Useful for logging, timing, profiling, and inspecting values during development.",language:["typescript","javascript"]},"console.log":{title:"console.log()",type:"(...data: any[]) => void",body:"Outputs a message to the web console. Accepts any number of arguments — objects are logged as expandable trees, primitives as their string form.",language:["typescript","javascript"]},"console.error":{title:"console.error()",type:"(...data: any[]) => void",body:"Logs an error message to the console, typically rendered in red with a stack trace. Use for unrecoverable failures.",language:["typescript","javascript"]},"console.warn":{title:"console.warn()",type:"(...data: any[]) => void",body:"Logs a warning message to the console, typically rendered in yellow. Use for non-fatal issues or deprecation notices.",language:["typescript","javascript"]},"console.info":{title:"console.info()",type:"(...data: any[]) => void",body:"Logs an informational message. Behaves identically to console.log in most environments.",language:["typescript","javascript"]},"console.table":{title:"console.table()",type:"(data: any, columns?: string[]) => void",body:"Displays an array or object as a formatted table in the console. Optionally restrict displayed columns.",language:["typescript","javascript"]},"console.time":{title:"console.time()",type:"(label?: string) => void",body:"Starts a timer with the given label. Call console.timeEnd() with the same label to log the elapsed time.",language:["typescript","javascript"]},"console.timeEnd":{title:"console.timeEnd()",type:"(label?: string) => void",body:"Stops the timer started by console.time() and logs the elapsed duration in milliseconds.",language:["typescript","javascript"]},"console.group":{title:"console.group()",type:"(...label: any[]) => void",body:"Creates a new inline group in the console output, indenting subsequent messages until console.groupEnd() is called.",language:["typescript","javascript"]},"console.groupEnd":{title:"console.groupEnd()",type:"() => void",body:"Closes the current inline group in the console, exiting the indented group created by console.group().",language:["typescript","javascript"]},Math:{title:"Math",type:"namespace Math",body:"A built-in object with properties and methods for mathematical constants and functions. Not a constructor — all properties and methods are static.",language:["typescript","javascript"]},"Math.max":{title:"Math.max()",type:"(...values: number[]) => number",body:"Returns the largest of the given numbers. Returns -Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.min":{title:"Math.min()",type:"(...values: number[]) => number",body:"Returns the smallest of the given numbers. Returns Infinity if no arguments, or NaN if any argument is not a number.",language:["typescript","javascript"]},"Math.floor":{title:"Math.floor()",type:"(x: number) => number",body:"Returns the largest integer less than or equal to x. Rounds toward negative infinity.",language:["typescript","javascript"]},"Math.ceil":{title:"Math.ceil()",type:"(x: number) => number",body:"Returns the smallest integer greater than or equal to x. Rounds toward positive infinity.",language:["typescript","javascript"]},"Math.round":{title:"Math.round()",type:"(x: number) => number",body:"Returns the value of x rounded to the nearest integer. Values with a fractional part of exactly 0.5 round up.",language:["typescript","javascript"]},"Math.abs":{title:"Math.abs()",type:"(x: number) => number",body:"Returns the absolute (non-negative) value of x.",language:["typescript","javascript"]},"Math.sqrt":{title:"Math.sqrt()",type:"(x: number) => number",body:"Returns the square root of x. Returns NaN if x is negative.",language:["typescript","javascript"]},"Math.pow":{title:"Math.pow()",type:"(base: number, exponent: number) => number",body:"Returns base raised to the power of exponent. Equivalent to the ** operator.",language:["typescript","javascript"]},"Math.random":{title:"Math.random()",type:"() => number",body:"Returns a pseudo-random floating-point number in the range [0, 1). Not cryptographically secure — use crypto.getRandomValues() for security-sensitive code.",language:["typescript","javascript"]},"Math.PI":{title:"Math.PI",type:"number",body:"The ratio of a circle's circumference to its diameter: approximately 3.14159265358979.",language:["typescript","javascript"]},"Math.trunc":{title:"Math.trunc()",type:"(x: number) => number",body:"Returns the integer part of x by removing any fractional digits. Does not round — simply truncates toward zero.",language:["typescript","javascript"]},"Math.sign":{title:"Math.sign()",type:"(x: number) => number",body:"Returns 1 if x is positive, -1 if x is negative, 0 if x is zero, or NaN if x is not a number.",language:["typescript","javascript"]},"Math.clamp":{title:"Math.clamp()",type:"(value: number, min: number, max: number) => number",body:"Clamps value between min and max. Note: not yet standard — use Math.min(Math.max(value, min), max) for compatibility.",language:["typescript","javascript"]},JSON:{title:"JSON",type:"namespace JSON",body:"Provides methods for parsing and serializing JSON (JavaScript Object Notation). All methods are static.",language:["typescript","javascript"]},"JSON.stringify":{title:"JSON.stringify()",type:"(value: any, replacer?: any, space?: string | number) => string",body:"Converts a JavaScript value to a JSON string. Pass a number or string as the third argument to pretty-print with indentation. Throws on circular references.",language:["typescript","javascript"]},"JSON.parse":{title:"JSON.parse()",type:"(text: string, reviver?: (key: string, value: any) => any) => any",body:"Parses a JSON string and returns the corresponding JavaScript value. Throws SyntaxError if the string is not valid JSON.",language:["typescript","javascript"]},Array:{title:"Array",type:"interface Array<T>",body:"Represents an ordered list of values. Provides methods for traversal, mutation, searching, and transformation.",language:["typescript","javascript"]},"Array.from":{title:"Array.from()",type:"<T>(arrayLike: Iterable<T> | ArrayLike<T>, mapFn?: (v: T, i: number) => T) => T[]",body:"Creates a new Array from an array-like or iterable object (e.g. NodeList, Set, Map, string). Optionally applies a mapping function.",language:["typescript","javascript"]},"Array.isArray":{title:"Array.isArray()",type:"(value: unknown) => value is any[]",body:"Returns true if the given value is an Array. More reliable than instanceof Array across iframe boundaries.",language:["typescript","javascript"]},Object:{title:"Object",type:"interface Object",body:"The base class of all JavaScript objects. Provides static methods for working with object properties, prototypes, and descriptors.",language:["typescript","javascript"]},"Object.keys":{title:"Object.keys()",type:"(obj: object) => string[]",body:"Returns an array of an object's own enumerable string-keyed property names, in insertion order.",language:["typescript","javascript"]},"Object.values":{title:"Object.values()",type:"(obj: object) => any[]",body:"Returns an array of an object's own enumerable string-keyed property values, in insertion order.",language:["typescript","javascript"]},"Object.entries":{title:"Object.entries()",type:"(obj: object) => [string, any][]",body:"Returns an array of [key, value] pairs for all own enumerable string-keyed properties of an object.",language:["typescript","javascript"]},"Object.assign":{title:"Object.assign()",type:"<T, U>(target: T, source: U) => T & U",body:"Copies own enumerable properties from one or more source objects into a target object. Returns the modified target. Does a shallow copy.",language:["typescript","javascript"]},"Object.freeze":{title:"Object.freeze()",type:"<T>(obj: T) => Readonly<T>",body:"Freezes an object — prevents adding, removing, or changing its properties. Returns the same object. Shallow — nested objects are not frozen.",language:["typescript","javascript"]},"Object.create":{title:"Object.create()",type:"(proto: object | null, propertiesObject?: PropertyDescriptorMap) => any",body:"Creates a new object with the specified prototype object and optional property descriptors.",language:["typescript","javascript"]},"Object.fromEntries":{title:"Object.fromEntries()",type:"<T>(entries: Iterable<[string, T]>) => Record<string, T>",body:"Creates an object from an array of [key, value] pairs or any iterable of key-value entries. The inverse of Object.entries().",language:["typescript","javascript"]},Promise:{title:"Promise",type:"interface Promise<T>",body:"Represents an asynchronous operation that will eventually complete (or fail) and produce a value. Use .then(), .catch(), and .finally() to handle outcomes.",language:["typescript","javascript"]},"Promise.all":{title:"Promise.all()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T[]>",body:"Waits for all promises to resolve and returns an array of results. If any promise rejects, the entire result rejects immediately (fail-fast).",language:["typescript","javascript"]},"Promise.allSettled":{title:"Promise.allSettled()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<PromiseSettledResult<T>[]>",body:'Waits for all promises to settle (resolve or reject) and returns an array of result objects, each with a status of "fulfilled" or "rejected". Never rejects.',language:["typescript","javascript"]},"Promise.race":{title:"Promise.race()",type:"<T>(promises: Iterable<Promise<T>>) => Promise<T>",body:"Returns a promise that resolves or rejects as soon as one of the given promises resolves or rejects, with that value or reason.",language:["typescript","javascript"]},"Promise.resolve":{title:"Promise.resolve()",type:"<T>(value: T | PromiseLike<T>) => Promise<T>",body:"Returns a Promise object that is resolved with the given value. If the value is a thenable, the returned promise follows it.",language:["typescript","javascript"]},"Promise.reject":{title:"Promise.reject()",type:"(reason?: any) => Promise<never>",body:"Returns a Promise that is rejected with the given reason. Useful for creating pre-rejected promises in control flow.",language:["typescript","javascript"]},setTimeout:{title:"setTimeout()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Executes a function after a specified delay in milliseconds. Returns a timer ID that can be passed to clearTimeout() to cancel.",language:["typescript","javascript"]},clearTimeout:{title:"clearTimeout()",type:"(id: number) => void",body:"Cancels a timeout previously established by setTimeout(), preventing its callback from running.",language:["typescript","javascript"]},setInterval:{title:"setInterval()",type:"(callback: () => void, delay?: number, ...args: any[]) => number",body:"Repeatedly executes a function with a fixed time delay between each call. Returns a timer ID for cancellation via clearInterval().",language:["typescript","javascript"]},clearInterval:{title:"clearInterval()",type:"(id: number) => void",body:"Cancels a repeating timer established by setInterval().",language:["typescript","javascript"]},requestAnimationFrame:{title:"requestAnimationFrame()",type:"(callback: (timestamp: DOMHighResTimeStamp) => void) => number",body:"Schedules a callback to run before the next browser repaint. Ideal for animations — the browser can batch and throttle calls to 60fps or the display refresh rate.",language:["typescript","javascript"]},cancelAnimationFrame:{title:"cancelAnimationFrame()",type:"(id: number) => void",body:"Cancels an animation frame request previously scheduled with requestAnimationFrame().",language:["typescript","javascript"]},queueMicrotask:{title:"queueMicrotask()",type:"(callback: () => void) => void",body:"Queues a microtask to be executed before the next task in the event loop. Runs after the current JavaScript execution but before any setTimeout callbacks.",language:["typescript","javascript"]},fetch:{title:"fetch()",type:"(input: RequestInfo | URL, init?: RequestInit) => Promise<Response>",body:"Fetches a resource from the network. Returns a Promise that resolves to a Response. Use .json(), .text(), or .blob() on the response to read the body.",language:["typescript","javascript"]},parseInt:{title:"parseInt()",type:"(string: string, radix?: number) => number",body:"Parses a string and returns an integer in the specified radix (base). Always provide the radix (typically 10) to avoid unexpected behavior with leading zeros.",language:["typescript","javascript"]},parseFloat:{title:"parseFloat()",type:"(string: string) => number",body:"Parses a string and returns a floating-point number. Returns NaN if the string cannot be converted.",language:["typescript","javascript"]},isNaN:{title:"isNaN()",type:"(value: number) => boolean",body:"Returns true if the value is NaN (Not a Number). Note: coerces the argument to number first — use Number.isNaN() for strict checking without coercion.",language:["typescript","javascript"]},isFinite:{title:"isFinite()",type:"(value: number) => boolean",body:"Returns true if the value is a finite number. Returns false for ±Infinity and NaN. Coerces the argument to number first.",language:["typescript","javascript"]},encodeURIComponent:{title:"encodeURIComponent()",type:"(uriComponent: string | number | boolean) => string",body:"Encodes a URI component by replacing special characters with their UTF-8 escape sequences. Use for encoding query string values before appending to a URL.",language:["typescript","javascript"]},decodeURIComponent:{title:"decodeURIComponent()",type:"(encodedURIComponent: string) => string",body:"Decodes a URI component that was previously encoded with encodeURIComponent(). Throws URIError on malformed sequences.",language:["typescript","javascript"]},structuredClone:{title:"structuredClone()",type:"<T>(value: T, options?: StructuredSerializeOptions) => T",body:"Creates a deep clone of the given value using the structured clone algorithm. Handles cycles, Maps, Sets, Dates, and typed arrays. Does not clone functions or class instances.",language:["typescript","javascript"]},"document.getElementById":{title:"document.getElementById()",type:"(elementId: string) => HTMLElement | null",body:"Returns the first element in the document with the specified ID, or null if not found. IDs must be unique per document.",language:["typescript","javascript"]},"document.querySelector":{title:"document.querySelector()",type:"(selectors: string) => Element | null",body:"Returns the first Element matching the given CSS selector string, or null if no match. Use querySelectorAll() for all matches.",language:["typescript","javascript"]},"document.querySelectorAll":{title:"document.querySelectorAll()",type:"(selectors: string) => NodeListOf<Element>",body:"Returns a static NodeList of all Elements matching the given CSS selector string. Does not update as the document changes.",language:["typescript","javascript"]},"document.createElement":{title:"document.createElement()",type:"<K extends keyof HTMLElementTagNameMap>(tagName: K) => HTMLElementTagNameMap[K]",body:"Creates a new HTML element with the specified tag name. The element is not attached to the DOM until you call appendChild() or similar.",language:["typescript","javascript"]},addEventListener:{title:"addEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void",body:"Registers an event listener on the target element. The listener is called whenever the specified event fires. Remember to call removeEventListener() to clean up.",language:["typescript","javascript"]},removeEventListener:{title:"removeEventListener()",type:"(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void",body:"Removes an event listener previously added with addEventListener(). The listener reference must be the same function object.",language:["typescript","javascript"]},const:{title:"const",type:"keyword",body:"Declares a block-scoped variable that cannot be reassigned. The binding is immutable — but for objects and arrays, their contents can still be mutated.",language:["typescript","javascript"]},let:{title:"let",type:"keyword",body:"Declares a block-scoped variable that can be reassigned. Prefer const for bindings that never change.",language:["typescript","javascript"]},var:{title:"var",type:"keyword",body:"Declares a function-scoped (or globally-scoped) variable. Hoisted to the top of its scope. Prefer const or let in modern code.",language:["typescript","javascript"]},function:{title:"function",type:"keyword",body:"Defines a named function declaration, or introduces a function expression. Function declarations are hoisted; expressions are not.",language:["typescript","javascript"]},class:{title:"class",type:"keyword",body:"Declares a class — a blueprint for creating objects with shared methods and properties. Classes support extends, implements, constructors, getters, setters, and static members.",language:["typescript","javascript"]},async:{title:"async",type:"keyword",body:"Marks a function as asynchronous, making it return a Promise implicitly. Enables the use of the await keyword inside the function body.",language:["typescript","javascript"]},await:{title:"await",type:"keyword",body:"Pauses execution of an async function until the Promise settles, then returns the resolved value. Must be used inside an async function.",language:["typescript","javascript"]},return:{title:"return",type:"keyword",body:"Exits the current function and optionally returns a value to the caller. In an async function, the value is wrapped in a resolved Promise.",language:["typescript","javascript"]},interface:{title:"interface",type:"keyword",body:"Defines a TypeScript interface — a named contract describing the shape of an object. Interfaces can be extended, merged (declaration merging), and implemented by classes.",language:["typescript"]},type:{title:"type",type:"keyword",body:"Declares a TypeScript type alias — a name for any type expression including unions, intersections, tuples, mapped types, and conditional types.",language:["typescript"]},extends:{title:"extends",type:"keyword",body:"Establishes inheritance (class extends Base) or constrains a generic type parameter (T extends object). Also used in conditional types (T extends U ? X : Y).",language:["typescript","javascript"]},implements:{title:"implements",type:"keyword",body:"Declares that a class satisfies the shape of one or more interfaces. TypeScript verifies at compile time that all required members are present.",language:["typescript"]},export:{title:"export",type:"keyword",body:"Makes a declaration (variable, function, class, type, interface) available for import in other modules. Use export default for a single primary export.",language:["typescript","javascript"]},import:{title:"import",type:"keyword",body:"Imports bindings from another module. Supports named imports ({ foo, bar }), default imports (Foo), namespace imports (* as Foo), and side-effect imports.",language:["typescript","javascript"]},typeof:{title:"typeof",type:"keyword",body:'Returns a string describing the type of its operand at runtime ("string", "number", "boolean", "object", "function", "undefined", "symbol", "bigint"). In TypeScript, also used as a type operator to capture the type of a value.',language:["typescript","javascript"]},instanceof:{title:"instanceof",type:"keyword",body:"Tests whether an object has a given constructor in its prototype chain. Returns true if the object is an instance of the constructor.",language:["typescript","javascript"]},new:{title:"new",type:"keyword",body:"Creates a new instance of a class or constructor function. Allocates memory, sets the prototype, calls the constructor with `this` bound to the new object, and returns it.",language:["typescript","javascript"]},throw:{title:"throw",type:"keyword",body:"Throws a user-defined exception, stopping execution of the current function and propagating up the call stack until caught by a try...catch block.",language:["typescript","javascript"]},try:{title:"try...catch...finally",type:"keyword",body:"Wraps code that might throw an exception. The catch block handles errors; the finally block always runs whether or not an error occurred.",language:["typescript","javascript"]},string:{title:"string",type:"primitive type",body:'Represents a sequence of UTF-16 code units. In TypeScript, the string type accepts any text value. Literal types like "hello" narrow to specific string values.',language:["typescript"]},number:{title:"number",type:"primitive type",body:"Represents a double-precision 64-bit IEEE 754 floating-point value. Includes integers, decimals, NaN, and Infinity. TypeScript does not have a separate int type.",language:["typescript"]},boolean:{title:"boolean",type:"primitive type",body:"Represents a logical true or false value. Literal types true and false narrow to specific boolean values.",language:["typescript"]},any:{title:"any",type:"TypeScript type",body:"Disables type checking for a value — allows any operation without compile errors. Avoid using any; prefer unknown when the type is genuinely uncertain.",language:["typescript"]},unknown:{title:"unknown",type:"TypeScript type",body:"The type-safe alternative to any. You cannot perform operations on an unknown value without first narrowing its type with typeof, instanceof, or a type guard.",language:["typescript"]},void:{title:"void",type:"TypeScript type",body:"Represents the absence of a value, typically used as the return type of functions that do not return anything meaningful.",language:["typescript"]},never:{title:"never",type:"TypeScript type",body:"A type with no values — used for functions that never return (throw or infinite loop) and for exhaustive checks in union type switches.",language:["typescript"]},Record:{title:"Record<K, V>",type:"type Record<K extends keyof any, T> = { [P in K]: T }",body:"A utility type that constructs an object type whose keys are of type K and values are of type V. Useful for dictionaries and lookup tables.",language:["typescript"]},Partial:{title:"Partial<T>",type:"type Partial<T> = { [P in keyof T]?: T[P] }",body:"A utility type that makes all properties of T optional. Useful for update payloads, patches, and configuration objects with defaults.",language:["typescript"]},Required:{title:"Required<T>",type:"type Required<T> = { [P in keyof T]-?: T[P] }",body:"A utility type that makes all properties of T required (removes optionality). The inverse of Partial<T>.",language:["typescript"]},Readonly:{title:"Readonly<T>",type:"type Readonly<T> = { readonly [P in keyof T]: T[P] }",body:"A utility type that makes all properties of T readonly. Prevents property reassignment at the type level.",language:["typescript"]},ReturnType:{title:"ReturnType<T>",type:"type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any",body:"A utility type that extracts the return type of a function type T.",language:["typescript"]},Omit:{title:"Omit<T, K>",type:"type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>",body:"A utility type that constructs a type by picking all properties from T then removing those in K.",language:["typescript"]},Pick:{title:"Pick<T, K>",type:"type Pick<T, K extends keyof T> = { [P in K]: T[P] }",body:"A utility type that constructs a type by picking the set of properties K from T.",language:["typescript"]},NonNullable:{title:"NonNullable<T>",type:"type NonNullable<T> = T extends null | undefined ? never : T",body:"A utility type that removes null and undefined from the type T.",language:["typescript"]},keyof:{title:"keyof",type:"TypeScript type operator",body:'Produces a union type of all property keys of an object type. keyof { a: string; b: number } is "a" | "b".',language:["typescript"]}};function gr(n,e){const t=mr[n];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}function br(n){var e,t,i,r;const{vr:o,visIdx:s,curVisRow:a,wm:l,foldedLines:d,isFoldable:h,opts:c}=n,{docLine:p,segIdx:m,text:g}=o,f=s===a,u=p===((e=l.visualRows[a])==null?void 0:e.docLine),k=m>0,_=((t=l.segments[p])==null?void 0:t.slice(0,m).reduce((w,T)=>w+T.length,0))??0,x=n.docSel?Ne(n.docSel,p,((i=(l.segments[p]??[""])[m])==null?void 0:i.length)??0):null;let v=null;if(x){const w=((r=(l.segments[p]??[""])[m])==null?void 0:r.length)??0,T=Ne(n.docSel,p,w+_);if(T){const S=T.start-_,D=T.end-_;D>0&&S<g.length&&(v={start:Math.max(0,S),end:Math.min(g.length,D)})}}const E=n.findMatches.filter(w=>w.row===p).map(w=>{var T,S;const D=w.col-_,P=w.col+w.len-_;if(P<=0||D>=g.length)return null;const ae=n.findIdx>=0&&((T=n.findMatches[n.findIdx])==null?void 0:T.row)===w.row&&((S=n.findMatches[n.findIdx])==null?void 0:S.col)===w.col;return{start:Math.max(0,D),end:Math.min(g.length,P),isCur:ae}}).filter(Boolean),H=n.wordHighlights.filter(w=>w.row===p).map(w=>{const T=w.col-_,S=w.col+w.len-_;return S<=0||T>=g.length?null:{start:Math.max(0,T),end:Math.min(g.length,S)}}).filter(Boolean),I=[];if(n.bracketMatch){for(const w of[n.bracketMatch.open,n.bracketMatch.close])if(w.row===p){const T=w.col-_;T>=0&&T<g.length&&I.push({start:T,end:T+1})}}const J=[],Z=[];for(const w of n.extraCursors){const T=U(l,w.row,w.col);if(T.visRow===s&&J.push(T.colInSeg),w.sel){const S=xr(w.sel);if(p>=S.ar&&p<=S.fr){const D=p===S.ar?S.ac-_:-_,P=p===S.fr?S.fc-_:g.length+999;P>0&&D<g.length&&Z.push({start:Math.max(0,D),end:Math.min(g.length,P)})}}}const V=fr(g,c.renderWhitespace),Ee=f||v||E.length||J.length||H.length||I.length||Z.length;let O;if(Ee)O=vr(V,f?n.curColInSeg:-1,v,E,J,H,I,Z,c.tokeniserOpts);else{const w=`${p}:${m}:${c.renderWhitespace}`;let T=n.tokenCache.get(w,V);T||(T=ue(V,c.tokeniserOpts),n.tokenCache.set(w,V,T)),O=yr(V,T)||"&#8203;"}let W="";if(m===0&&c.showIndentGuides){const w=(g.match(/^(\s*)/)??["",""])[1].length,T=Math.floor(w/c.tabSize);for(let S=1;S<T;S++){const D=c.codePaddingLeft+S*c.tabSize*c.charWidth;W+=`<span class="sl-ig" style="left:${D}px"></span>`}}let z="";if(m===0&&h){const w=d.has(p);z=`<span class="sl-fold-btn" data-row="${p}">${w?"▸":"▾"}</span>`}const Y=d.has(p)&&m===0,$=m===0?String(p+1):"";return`<div class="${["sl-er",c.highlightActiveLine&&u?"sl-cur-row":"",k?"sl-wrap-cont":"",Y?"sl-folded":""].filter(Boolean).join(" ")}" style="height:${c.lineHeight}px" data-v="${s}" data-doc="${p}"><div class="sl-eg" style="position:relative">${z}<span class="sl-egn">${$}</span></div><div class="sl-el"><span class="sl-cl">${W}${O}</span></div></div>`}function fr(n,e){if(e==="none")return n;if(e==="all")return n.replace(/ /g,"·").replace(/\t/g,"→");const t=(n.match(/^ +/)??[""])[0].length,i=(n.match(/ +$/)??[""])[0].length;let r=n;return t&&(r="·".repeat(t)+r.slice(t)),i&&(r=r.slice(0,r.length-i)+"·".repeat(i)),r.replace(/\t/g,"→")}function xr(n){return n.ar<n.fr||n.ar===n.fr&&n.ac<=n.fc?n:{ar:n.fr,ac:n.fc,fr:n.ar,fc:n.ac}}function yr(n,e){if(!n)return"";const t=We(n,e);let i="",r=0,o=t[0];const s=a=>{if(a<=r)return;const l=X(n.slice(r,a));i+=o?`<span class="${o}">${l}</span>`:l};for(let a=1;a<=n.length;a++){const l=a<n.length?t[a]:null;l!==o&&(s(a),r=a,o=l??"")}return i}function vr(n,e,t,i,r,o,s,a,l){if(n.length===0){let u=e>=0?'<span class="sl-cur"></span>':"";for(const k of r)u+='<span class="sl-cur-extra"></span>';return u||"&#8203;"}const d=ue(n,l),h=We(n,d);let c="",p=0,m="",g="";const f=u=>{if(u<=p)return;const k=X(n.slice(p,u)),_=[m,g].filter(Boolean).join(" ");c+=_?`<span class="${_}">${k}</span>`:k};for(let u=0;u<=n.length;u++){e===u&&(f(u),p=u,c+='<span class="sl-cur"></span>');for(const I of r)I===u&&(f(u),p=u,c+='<span class="sl-cur-extra"></span>');if(u===n.length){f(u);break}const k=h[u],_=i.find(I=>u>=I.start&&u<I.end),x=t&&u>=t.start&&u<t.end||a.some(I=>u>=I.start&&u<I.end),v=!x&&!_&&o.some(I=>u>=I.start&&u<I.end),E=!x&&!_&&s.some(I=>u>=I.start&&u<I.end);let H="";x?H="sl-sh":_?H="sl-fh"+(_.isCur?" sl-fh-cur":""):E?H="sl-bm":v&&(H="sl-wh"),(H!==m||k!==g)&&(f(u),p=u,m=H,g=k)}return c||"&#8203;"}function _e(n,e,t,i,r){const o=Math.max(0,n*r-t),s=Math.max(0,n*2-i),a=(o>0?e/o:0)*s,l=Math.max(20,t/r*2),d=e/r*2-a;return{mmScroll:a,sliderTop:d,sliderHeight:l}}function kr(n,e,t,i,r){const o=Math.max(0,e*r-t),s=Math.max(0,e*2-i);if(o<=0)return 0;const a=2/r-s/o;if(Math.abs(a)<1e-9){const l=Math.max(20,t/r*2);return Math.max(0,Math.min(o,n/Math.max(1,i-l)*o))}return Math.max(0,Math.min(o,n/a))}function wr(n,e,t,i,r,o){const s=Math.max(0,e*o-i),a=Math.max(0,e*2-r);if(s<=0)return 0;const l=t/s*a,d=(n+l)/2;return Math.max(0,Math.min(s,d*o-i/2))}function Qe(n){const e=t=>{const i=n(t);return i.startsWith("#")&&i.length===7?ze(i,.85):i};return{kw:e("--tok-kw"),fn:e("--tok-fn"),cls:e("--tok-cls"),typ:e("--tok-typ"),str:e("--tok-str"),num:e("--tok-num"),cmt:e("--tok-cmt"),dec:e("--tok-dec"),op:e("--tok-op"),txt:(()=>{const t=n("--text2");return t.startsWith("#")&&t.length===7?ze(t,.28):"rgba(150,148,140,0.28)"})()}}function _r(n){var e,t;const{canvas:i,doc:r,firstLine:o,lastLine:s,subPx:a,wrapperWidth:l,canvasHeight:d,cursorRow:h,sel:c,findMatches:p,findIdx:m,sliderTop:g,sliderHeight:f,colors:u,getCssVar:k,dpr:_}=n,x=i.getContext("2d");if(!x)return;x.setTransform(_,0,0,_,0,0);const v=k("--mm-bg")||"#0d0d0f",E=k("--mm-dim")||"rgba(0,0,0,.30)",H=k("--mm-edge")||"rgba(255,255,255,.18)",I=k("--mm-slider")||"rgba(255,255,255,.07)",J=k("--sel-bg")||"rgba(110,159,255,.22)",Z=k("--cur-line-bg")||"rgba(255,255,255,.05)",V=k("--find-border")||"rgba(234,180,86,.50)",Ee=k("--find-cur-bg")||"rgba(234,180,86,.80)",O=$=>($-o)*2;if(x.fillStyle=v,x.fillRect(0,0,l,d),h>=o&&h<s&&(x.fillStyle=Z,x.fillRect(0,O(h),l,2)),c){const $=Math.max(o,c.ar),w=Math.min(s-1,c.fr);w>=$&&(x.fillStyle=J,x.fillRect(0,O($),l,(w-$+1)*2))}for(const $ of p){if($.row<o||$.row>=s)continue;const w=m>=0&&((e=p[m])==null?void 0:e.row)===$.row&&((t=p[m])==null?void 0:t.col)===$.col;x.fillStyle=w?Ee:V,x.fillRect(3+$.col*1.1,O($.row),Math.max(3,$.len*1.1),2)}const W=Math.floor((l-3)/1.1);for(let $=o;$<s;$++){const w=r[$]??"";if(!w.trim())continue;const T=O($),S=1.5,D=ue(w);let P=0;for(const F of D){if(F.start>=W)break;F.start>P&&(x.fillStyle=u.txt,x.fillRect(3+P*1.1,T,(Math.min(F.start,W)-P)*1.1,S));const on=u[F.cls]??u.txt,si=Math.min(F.end,W)-F.start;si>0&&(x.fillStyle=on,x.fillRect(3+F.start*1.1,T,si*1.1,S)),P=Math.max(P,Math.min(F.end,W))}const ae=Math.min(w.length,W);P<ae&&(x.fillStyle=u.txt,x.fillRect(3+P*1.1,T,(ae-P)*1.1,S))}const z=g+a,Y=z+f;x.fillStyle=E,z>0&&x.fillRect(0,0,l,z),Y<d&&x.fillRect(0,Y,l,d-Y),x.fillStyle=I,x.fillRect(0,z,l,f),x.fillStyle=H,x.fillRect(0,Math.max(0,z),l,1),x.fillRect(0,Math.max(0,Y-1),l,1)}const Cr={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:80,fontFamily:"'JetBrains Mono', monospace",fontSize:13,lineHeight:22,tabSize:2,insertSpaces:!0,maxUndoHistory:300,showIndentGuides:!0,bracketMatching:!0,codeFolding:!0,emmet:!0,snippetExpansion:!0,autocomplete:!0,multiCursor:!0,find:!0,findReplace:!0,wordSelection:!0,wordHighlight:!0,highlightActiveLine:!0,autocompletePrefixLength:2,readOnly:!1,extraKeywords:[],extraTypes:[],completions:[],replaceBuiltins:!1,maxCompletions:14,autoClosePairs:{"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},lineCommentToken:"",wordSeparators:"",undoBatchMs:700,gutterWidth:60,minimapWidth:120,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0};class Tr{constructor(e,t={}){y(this,"_host"),y(this,"_shadow"),y(this,"_editorEl"),y(this,"_spacerEl"),y(this,"_vpEl"),y(this,"_inputEl"),y(this,"_minimapWrap"),y(this,"_mmCanvas"),y(this,"_mmSlider"),y(this,"_statusBar"),y(this,"_findBar"),y(this,"_findInput"),y(this,"_replaceInput"),y(this,"_findCount"),y(this,"_replaceRow"),y(this,"_acPopup"),y(this,"_emmetTip"),y(this,"_snippetTip"),y(this,"_hoverTip"),y(this,"_themeOverlay"),y(this,"_themePanel"),y(this,"_config"),y(this,"_tab",je(1,[""])),y(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0]}),y(this,"_foldedLines",new Map),y(this,"_tokenCache",new Mi),y(this,"_themeManager"),y(this,"_findMatches",[]),y(this,"_findIdx",-1),y(this,"_findCaseSensitive",!1),y(this,"_findRegex",!1),y(this,"_wordHighlights",[]),y(this,"_bracketMatch",null),y(this,"_acItems",[]),y(this,"_acSel",0),y(this,"_acPrefix",""),y(this,"_acStartCol",0),y(this,"_emmetAcStartCol",0),y(this,"_mc",Qi()),y(this,"_extraCursors",[]),y(this,"_isDragging",!1),y(this,"_dragAnchor",null),y(this,"_hoverTimer",null),y(this,"_hoverPinned",!1),y(this,"_mmDragMode","none"),y(this,"_mmDragStartY",0),y(this,"_mmDragStartScroll",0),y(this,"_mmSliderOffset",0),y(this,"_mmColors"),y(this,"_lastInputTime",0),y(this,"_dynamicStyleEl"),y(this,"_emmetExpanded",null),y(this,"_snippetExpanded",null),y(this,"_acDebounceTimer",null),y(this,"_rafId",null),y(this,"_onWinMouseUp"),y(this,"_onWinResize"),y(this,"_onEditorScroll"),y(this,"_onWinMmMouseMove"),y(this,"_onWinMmMouseUp"),y(this,"_ro",null),y(this,"_onFoldBtnClick",l=>{const d=l.target.closest(".sl-fold-btn");if(!d)return;l.preventDefault(),l.stopPropagation();const h=parseInt(d.dataset.row??"0",10);this._foldedLines=qi(this._foldedLines,this._tab.doc,h),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()}),this._config={...Cr,...qe(t)},this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null},this._onEditorScroll=fe(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=fe(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=l=>{if(this._mmDragMode==="none")return;const d=this._minimapWrap.clientHeight;if(this._mmDragMode==="slider"){const h=l.clientY-this._minimapWrap.getBoundingClientRect().top;this._editorEl.scrollTop=kr(h-this._mmSliderOffset,this._tab.doc.length,this._editorEl.clientHeight,d,this._config.lineHeight)}else{const h=l.clientY-this._mmDragStartY,c=Math.max(0,this._tab.doc.length*this._config.lineHeight-this._editorEl.clientHeight);this._editorEl.scrollTop=Math.max(0,Math.min(c,this._mmDragStartScroll+h/2*this._config.lineHeight))}this._render()},this._onWinMmMouseUp=()=>{this._mmDragMode!=="none"&&(this._mmDragMode="none",this._minimapWrap.style.cursor="pointer")},this._host=e,this._host.classList.add("sl-host"),this._shadow=this._host.attachShadow({mode:"open"});const i=B("style");i.textContent=Oi,this._shadow.appendChild(i),this._dynamicStyleEl=B("style"),this._shadow.appendChild(this._dynamicStyleEl),this._themeManager=new Ni(this._host);const r=typeof this._config.theme=="string"?this._config.theme:this._config.theme;this._themeManager.apply(r);const o=B("div","sl-layout"),s=B("div","sl-ed-pane");this._inputEl=B("textarea","sl-input"),this._inputEl.setAttribute("autocomplete","off"),this._inputEl.setAttribute("autocorrect","off"),this._inputEl.setAttribute("autocapitalize","off"),this._inputEl.setAttribute("spellcheck","false"),this._inputEl.setAttribute("role","textbox"),this._inputEl.setAttribute("aria-multiline","true"),this._inputEl.setAttribute("aria-label","Code editor"),this._inputEl.setAttribute("aria-readonly",String(!!this._config.readOnly)),this._inputEl.setAttribute("aria-haspopup","listbox"),this._editorEl=B("div","sl-editor"),this._spacerEl=B("div","sl-spacer"),this._vpEl=B("div","sl-vp"),this._editorEl.appendChild(this._spacerEl),this._editorEl.appendChild(this._vpEl),this._findBar=this._buildFindBar(),this._findInput=this._findBar.querySelector(".sl-find-input"),this._replaceInput=this._findBar.querySelector(".sl-find-replace-input"),this._findCount=this._findBar.querySelector(".sl-find-count"),this._replaceRow=this._findBar.querySelector(".sl-replace-row"),s.appendChild(this._inputEl),s.appendChild(this._findBar),s.appendChild(this._editorEl),this._minimapWrap=B("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._mmCanvas=B("canvas",""),this._mmSlider=B("div","sl-mm-slider"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),o.appendChild(s),this._config.showMinimap&&o.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=B("div","sl-ac-popup"),this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.style.display="none",this._emmetTip=B("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=B("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=B("div","sl-hover-tip"),this._hoverTip.style.display="none",this._hoverTip.addEventListener("mouseenter",()=>{this._hoverPinned=!0}),this._hoverTip.addEventListener("mouseleave",()=>{this._hoverPinned=!1,this._hideHover()}),this._themeOverlay=B("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=B("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(o),this._config.showStatusBar&&this._shadow.appendChild(this._statusBar),this._shadow.appendChild(this._acPopup),this._shadow.appendChild(this._emmetTip),this._shadow.appendChild(this._snippetTip),this._shadow.appendChild(this._hoverTip),this._shadow.appendChild(this._themeOverlay);const a=typeof this._config.value=="string"?Fe(this._config.value):this._config.value;this._tab=je(1,a.length?a:[""]),this._mmColors=Qe(l=>me(l,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(fe(()=>{this._config.wordWrap&&(this._rebuildWrapMap(),this._scheduleRender())},60)),this._ro.observe(this._host)),this._rebuildWrapMap(),this._render()}getValue(){return A(this._tab.doc)}setValue(e){var t,i;M(this._tab,this._config.maxUndoHistory),this._tab.doc=Fe(e),this._tab.cur={row:0,col:0},this._tab.sel=null,this._tokenCache.clear(),this._foldedLines.clear(),this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,e)}getCursor(){return{...this._tab.cur}}setCursor(e){this._tab.cur={...e},L(this._tab),this._scrollIntoView(),this._render()}getSelection(){return this._tab.sel?{...this._tab.sel}:null}setSelection(e){this._tab.sel=e,this._render()}insertText(e){this._config.readOnly||(this._insertStr(e,!1),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=Qe(t=>me(t,this._host)),this._tokenCache.clear(),this._render()}updateConfig(e){const t=qe(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:r,...o}=t;Object.assign(this._config,o)}else Object.assign(this._config,t);if(t.readOnly!==void 0&&this._inputEl.setAttribute("aria-readonly",String(!!t.readOnly)),e.theme!==void 0&&this.setTheme(e.theme),(e.wordWrap!==void 0||e.wrapColumn!==void 0)&&this._rebuildWrapMap(),e.showMinimap!==void 0){const i=this._shadow.querySelector(".sl-layout");e.showMinimap?i.contains(this._minimapWrap)||i.appendChild(this._minimapWrap):this._minimapWrap.remove()}e.showStatusBar!==void 0&&(e.showStatusBar?this._shadow.contains(this._statusBar)||this._shadow.appendChild(this._statusBar):this._statusBar.remove()),(e.fontFamily!==void 0||e.fontSize!==void 0||e.lineHeight!==void 0||e.cursorBlinkRate!==void 0||e.cursorStyle!==void 0||e.gutterWidth!==void 0||e.minimapWidth!==void 0||e.showGutter!==void 0||e.tokenColors!==void 0)&&this._applyDynamicStyles(),(e.language!==void 0||e.extraKeywords!==void 0||e.extraTypes!==void 0||e.renderWhitespace!==void 0||e.completions!==void 0)&&this._tokenCache.clear(),e.find===!1?this._closeFind():e.findReplace===!1&&(this._replaceRow.style.display="none"),this._render()}focus(){this._focusInput()}getThemes(){return this._themeManager.allIds}registerTheme(e){this._themeManager.register(e)}undo(){var e,t;_i(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc)))}redo(){var e,t;Ci(this._tab)&&(this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc)))}executeCommand(e){const t=this._config.readOnly;switch(e){case"undo":t||this.undo();break;case"redo":t||this.redo();break;case"selectAll":this._selectAll();break;case"copy":this._doCopy();break;case"cut":t||this._doCut();break;case"toggleComment":t||this._toggleComment();break;case"duplicateLine":t||this._duplicateLine();break;case"deleteLine":t||this._deleteLine();break;case"toggleWordWrap":this._toggleWrap();break;case"find":this._config.find&&this._openFind(!1);break;case"findReplace":this._config.find&&this._config.findReplace&&this._openFind(!0);break;case"indentLine":t||this._indentSel();break;case"outdentLine":t||this._unindentSel();break;default:console.warn(`[syncline-editor] executeCommand: unknown command "${e}"`);break}}destroy(){var e;this._acDebounceTimer!==null&&(clearTimeout(this._acDebounceTimer),this._acDebounceTimer=null),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),window.removeEventListener("mouseup",this._onWinMouseUp),window.removeEventListener("resize",this._onWinResize),window.removeEventListener("mousemove",this._onWinMmMouseMove),window.removeEventListener("mouseup",this._onWinMmMouseUp),(e=this._ro)==null||e.disconnect();const t=this._mmCanvas.getContext("2d");t&&t.clearRect(0,0,this._mmCanvas.width,this._mmCanvas.height),this._shadow.innerHTML="",this._host.classList.remove("sl-host")}_buildFindBar(){const e=B("div","sl-find-bar");return e.innerHTML=`
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=`
425
448
  <div class="sl-find-row">
426
449
  <input class="sl-find-input" placeholder="Find…" autocomplete="off" spellcheck="false">
427
450
  <span class="sl-find-count">–</span>
@@ -436,7 +459,12 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
436
459
  <button class="sl-find-btn sl-replace-one">Replace</button>
437
460
  <button class="sl-find-btn sl-replace-all">All</button>
438
461
  </div>
439
- `,e}_buildStatusBar(){const e=B("div","sl-statusbar");return e.innerHTML=`
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=`
440
468
  <div class="sl-sb-item sl-no-click sl-sb-lang">⬡ TypeScript</div>
441
469
  <div class="sl-sb-sep"></div>
442
470
  <div class="sl-sb-item sl-no-click sl-sb-pos">Ln 1, Col 1</div>
@@ -448,24 +476,28 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
448
476
  <div class="sl-sb-item sl-no-click">UTF-8 LF</div>
449
477
  <div class="sl-sb-right">
450
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>
451
481
  <div class="sl-sb-item sl-sb-wrap sl-sb-wrap-btn">⇥ Wrap: OFF</div>
452
482
  <div class="sl-sb-sep"></div>
453
483
  <div class="sl-sb-item sl-sb-theme-btn">🎨 Theme</div>
454
484
  <div class="sl-sb-sep"></div>
455
485
  <div class="sl-sb-item sl-no-click sl-sb-undo">↩0 ↪0</div>
456
486
  </div>
457
- `,e.querySelector(".sl-sb-wrap-btn").addEventListener("click",()=>this._toggleWrap()),e.querySelector(".sl-sb-theme-btn").addEventListener("click",()=>this._openThemePicker()),e}_applyDynamicStyles(){const{fontFamily:e,fontSize:t,lineHeight:i,cursorBlinkRate:r,cursorStyle:o,gutterWidth:s,minimapWidth:a,showGutter:l}=this._config,d=Math.max(2,i-4),h=Math.floor((i-d)/2);let c="";o==="block"?c=`width:${7.82}px;opacity:.5;border-radius:1px;`:o==="underline"&&(c=`width:${7.82}px;height:2px;top:${i-2}px;border-radius:0;`);const p=l?s:0;this._dynamicStyleEl.textContent=`
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=`
458
488
  .sl-el{font-family:${e};font-size:${t}px;line-height:${i}px}
459
489
  .sl-cl{height:${i}px;line-height:${i}px}
460
490
  .sl-egn{height:${i}px;line-height:${i}px}
461
491
  .sl-eg{min-width:${p}px;width:${p}px;${l?"":"display:none"}}
462
- .sl-cur::after{height:${d}px;top:${h}px;animation-duration:${r}ms;${c}}
463
- .sl-cur-extra::after{height:${d}px;top:${h}px;animation-duration:${r}ms;${c}}
464
- `,this._applyTokenOverrides(),this._minimapWrap.style.width=`${a}px`}_applyTokenOverrides(){const e=this._config.tokenColors??{},t=this._themeManager.activeTheme,i=this._host.style,r=(s,a,l)=>{i.setProperty(s,a||l)},o=t==null?void 0:t.tokens;r("--tok-kw",e.keyword,(o==null?void 0:o.tokKw)??""),r("--tok-str",e.string,(o==null?void 0:o.tokStr)??""),r("--tok-cmt",e.comment,(o==null?void 0:o.tokCmt)??""),r("--tok-fn",e.function,(o==null?void 0:o.tokFn)??""),r("--tok-num",e.number,(o==null?void 0:o.tokNum)??""),r("--tok-cls",e.class,(o==null?void 0:o.tokCls)??""),r("--tok-op",e.operator,(o==null?void 0:o.tokOp)??""),r("--tok-typ",e.type,(o==null?void 0:o.tokTyp)??""),r("--tok-dec",e.decorator,(o==null?void 0:o.tokDec)??"")}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._render()}))}_render(){const{doc:e,cur:t,sel:i}=this._tab,{lineHeight:r}=this._config;this._wordHighlights=this._config.wordHighlight?ar(e,t.row,t.col,i):[],this._bracketMatch=this._config.bracketMatching?Fi(e,t):null;const o=this._wm.visualRows.length;this._spacerEl.style.height=`${o*r}px`;const s=this._editorEl.scrollTop,a=this._editorEl.clientHeight,l=Math.max(0,Math.floor(s/r)-6),d=Math.min(o-1,Math.ceil((s+a)/r)+6);this._vpEl.style.transform=`translateY(${l*r}px)`;const h=U(this._wm,t.row,t.col);let c="";for(let p=l;p<=d;p++){const m=this._wm.visualRows[p];m&&(c+=br({vr:m,visIdx:p,curVisRow:h.visRow,curColInSeg:h.colInSeg,docSel:i,findMatches:this._findMatches,findIdx:this._findIdx,wordHighlights:this._wordHighlights,bracketMatch:this._bracketMatch,extraCursors:this._extraCursors,foldedLines:this._foldedLines,isFoldable:this._config.codeFolding&&Gi(e,m.docLine),wm:this._wm,tokenCache:this._tokenCache,opts:{tokeniserOpts:{language:this._config.language,extraKeywords:new Set(this._config.extraKeywords),extraTypes:new Set(this._config.extraTypes)},showIndentGuides:this._config.showIndentGuides,highlightActiveLine:this._config.highlightActiveLine,charWidth:7.82,codePaddingLeft:14,tabSize:this._config.tabSize,lineHeight:r,renderWhitespace:this._config.renderWhitespace}}))}this._vpEl.innerHTML=c,this._updateStatusBar(),this._updateMinimap()}_updateStatusBar(){if(!this._config.showStatusBar)return;const{cur:e,doc:t,undoStack:i,redoStack:r}=this._tab,o=this._config.language,s={typescript:"TypeScript",javascript:"JavaScript",css:"CSS",json:"JSON",markdown:"Markdown",text:"Text"},a=p=>this._statusBar.querySelector(p);a(".sl-sb-lang").textContent=`⬡ ${s[o]??o}`,a(".sl-sb-pos").textContent=`Ln ${e.row+1}, Col ${e.col+1}`,a(".sl-sb-lines").textContent=`${t.length.toLocaleString()} lines`;const l=Ti(this._tab),d=a(".sl-sb-sel"),h=a(".sl-sb-sel-sep");d.textContent=l?`${l.toLocaleString()} selected`:"",h.style.display=l?"":"none",a(".sl-sb-undo").textContent=`↩${i.length} ↪${r.length}`;const c=a(".sl-sb-mc");this._extraCursors.length?(c.style.display="",a(".sl-sb-mc-count").textContent=String(this._extraCursors.length+1)):c.style.display="none"}_updateMinimap(){if(!this._config.showMinimap)return;const e=this._minimapWrap.clientWidth,t=this._minimapWrap.clientHeight;if(!e||!t)return;const i=this._tab.doc,r=i.length,o=Math.min(window.devicePixelRatio||1,2),s=this._config.lineHeight,{mmScroll:a,sliderTop:l,sliderHeight:d}=_e(r,this._editorEl.scrollTop,this._editorEl.clientHeight,t,s),h=a/2,c=Math.floor(h),p=Math.ceil(t/2)+2,m=Math.min(r,c+p),g=(m-c)*2,f=(h-c)*2,u=Math.round(e*o),k=Math.round(g*o);(this._mmCanvas.width!==u||this._mmCanvas.height!==k)&&(this._mmCanvas.width=u,this._mmCanvas.height=k,this._mmCanvas.style.width=`${e}px`,this._mmCanvas.style.height=`${g}px`),this._mmCanvas.style.transform=`translateY(${-f}px)`,_r({canvas:this._mmCanvas,doc:i,firstLine:c,lastLine:m,subPx:f,wrapperWidth:e,canvasHeight:g,cursorRow:this._tab.cur.row,sel:this._tab.sel,findMatches:this._findMatches,findIdx:this._findIdx,sliderTop:l,sliderHeight:d,colors:this._mmColors,getCssVar:_=>me(_,this._host),dpr:o}),this._mmSlider.style.top=`${Math.max(0,Math.min(t-d,l))}px`,this._mmSlider.style.height=`${d}px`}_rebuildWrapMap(){let e;if(this._config.wordWrap){const t=this._config.showGutter?this._config.gutterWidth:0,i=this._editorEl.clientWidth;if(i>0){const r=i-t-14-20;e=Math.max(20,Math.floor(r/7.82))}else e=this._config.wrapColumn}else e=9999;this._wm=Si(this._tab.doc,e,this._config.wordWrap,this._foldedLines)}_scrollIntoView(){const e=this._tab.cur,t=U(this._wm,e.row,e.col).visRow*this._config.lineHeight,i=t+this._config.lineHeight,r=this._editorEl.scrollTop,o=this._editorEl.clientHeight,s=this._config.lineHeight*3;t<r+s?this._editorEl.scrollTop=Math.max(0,t-s):i>r+o-s&&(this._editorEl.scrollTop=i-o+s)}_focusInput(){this._inputEl.style.pointerEvents="auto",this._inputEl.focus(),this._inputEl.style.pointerEvents="none"}_insertStr(e,t){var i,r;const o=Date.now();(!t||o-this._lastInputTime>this._config.undoBatchMs)&&M(this._tab,this._config.maxUndoHistory),this._lastInputTime=o,this._tab.sel&&(this._tab.cur=q(this._tab));const{doc:s,cur:a}=this._tab,l=e.split(`
465
- `),d=s[a.row]??"",h=d.slice(0,a.col),c=d.slice(a.col);if(l.length===1)s[a.row]=h+e+c,a.col+=e.length;else{const p=[h+l[0]];for(let m=1;m<l.length-1;m++)p.push(l[m]);p.push(l[l.length-1]+c),s.splice(a.row,1,...p),a.row+=l.length-1,a.col=l[l.length-1].length}this._tokenCache.invalidateLine(a.row,(this._wm.segments[a.row]??[""]).length),this._tab.dirty=!0,(r=(i=this._config).onChange)==null||r.call(i,A(s))}_doBackspace(){var e;if(M(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:t,cur:i}=this._tab;if(i.col>0){const r=t[i.row]??"",o=r.slice(0,i.col),s=o.length>=2&&o.endsWith(" ")&&!o.trim()?2:1;t[i.row]=r.slice(0,i.col-s)+r.slice(i.col),i.col-=s,this._tokenCache.invalidateLine(i.row,((e=this._wm.segments[i.row])==null?void 0:e.length)??1)}else if(i.row>0){const r=(t[i.row-1]??"").length;t[i.row-1]+=t[i.row]??"",t.splice(i.row,1),i.row--,i.col=r,this._tokenCache.clear()}this._tab.dirty=!0}_doEnter(){M(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=q(this._tab));const{doc:e,cur:t}=this._tab,i=e[t.row]??"",r=i.slice(0,t.col),o=i.slice(t.col),s=Ge(i),a=r.trimEnd().endsWith("{")?ie(this._config.tabSize):"";e[t.row]=r,r.trimEnd().endsWith("{")&&o.trimStart()==="}"?e.splice(t.row+1,0,s+a,s+o):e.splice(t.row+1,0,s+a+o),t.row++,t.col=s.length+a.length,this._tokenCache.clear(),this._tab.dirty=!0}_doDelete(){var e;if(M(this._tab,this._config.maxUndoHistory),this._tab.sel){this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;return}const{doc:t,cur:i}=this._tab,r=t[i.row]??"";i.col<r.length?(t[i.row]=r.slice(0,i.col)+r.slice(i.col+1),this._tokenCache.invalidateLine(i.row,((e=this._wm.segments[i.row])==null?void 0:e.length)??1)):i.row<t.length-1&&(t[i.row]=r+(t[i.row+1]??""),t.splice(i.row+1,1),this._tokenCache.clear()),this._tab.dirty=!0}_selectAll(){const e=this._tab.doc,t=e.length-1;this._tab.sel={ar:0,ac:0,fr:t,fc:(e[t]??"").length},this._tab.cur={row:t,col:(e[t]??"").length},this._render()}_doCopy(){var e;const t=Oe(this._tab);t&&((e=navigator.clipboard)==null||e.writeText(t).catch(()=>{}))}_doCut(){var e,t,i;const r=Oe(this._tab);r&&((e=navigator.clipboard)==null||e.writeText(r).catch(()=>{}),M(this._tab,this._config.maxUndoHistory),this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc)))}_toggleComment(){var e,t;M(this._tab,this._config.maxUndoHistory);const i=this._getSelRows(),r=this._config.lineCommentToken||bi[this._config.language]||"";if(!r)return;const o=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=i.every(a=>(this._tab.doc[a]??"").trimStart().startsWith(r));i.forEach(a=>{var l;const d=this._tab.doc[a]??"";this._tab.doc[a]=s?d.replace(new RegExp(`^(\\s*)${o}\\s?`),"$1"):d.replace(/^(\s*)/,`$1${r} `),this._tokenCache.invalidateLine(a,((l=this._wm.segments[a])==null?void 0:l.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_duplicateLine(){var e,t;M(this._tab,this._config.maxUndoHistory);const i=this._tab.cur.row;this._tab.doc.splice(i+1,0,this._tab.doc[i]??""),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_deleteLine(){var e,t;M(this._tab,this._config.maxUndoHistory);const{doc:i,cur:r}=this._tab;i.length>1?i.splice(r.row,1):(i[0]="",r.col=0),this._tokenCache.clear(),this._tab.dirty=!0,L(this._tab),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_indentSel(){var e,t;if(!this._tab.sel){this._insertStr(ie(this._config.tabSize),!1);return}M(this._tab,this._config.maxUndoHistory);const i=ie(this._config.tabSize);this._getSelRows().forEach(r=>{var o;this._tab.doc[r]=i+(this._tab.doc[r]??""),this._tokenCache.invalidateLine(r,((o=this._wm.segments[r])==null?void 0:o.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_unindentSel(){var e,t;M(this._tab,this._config.maxUndoHistory);const i=this._config.tabSize;this._getSelRows().forEach(r=>{var o;const s=this._tab.doc[r]??"";s.startsWith(ie(i))?this._tab.doc[r]=s.slice(i):s.startsWith(" ")&&(this._tab.doc[r]=s.slice(1)),this._tokenCache.invalidateLine(r,((o=this._wm.segments[r])==null?void 0:o.length)??1)}),this._tab.dirty=!0,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_toggleWrap(){this._config.wordWrap=!this._config.wordWrap,this._vpEl.classList.toggle("sl-wrap-mode",this._config.wordWrap);const e=this._statusBar.querySelector(".sl-sb-wrap-btn");e&&(e.textContent=`⇥ Wrap: ${this._config.wordWrap?"ON":"OFF"}`,e.classList.toggle("sl-on",this._config.wordWrap)),this._tokenCache.clear(),this._rebuildWrapMap(),this._render()}_getSelRows(){if(!this._tab.sel)return[this._tab.cur.row];const e=N(this._tab.sel),t=[];for(let i=e.ar;i<=e.fr;i++)t.push(i);return t}_posFromMouse(e){var t;const i=this._editorEl.getBoundingClientRect(),r=e.clientY-i.top+this._editorEl.scrollTop,o=this._config.showGutter?this._config.gutterWidth:0,s=e.clientX-i.left-o-14,a=this._config.lineHeight,l=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(r/a))),d=Math.max(0,Math.min((((t=this._wm.visualRows[l])==null?void 0:t.text)??"").length,Math.round(s/7.82)));return te(this._wm,l,d)}_openFind(e){this._findBar.classList.add("sl-open"),this._replaceRow.style.display=e&&this._config.findReplace?"":"none",this._findInput.focus(),this._findInput.select(),this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx=-1,this._navFind(1)):this._render()}_closeFind(){this._findBar.classList.remove("sl-open"),this._findMatches=[],this._findIdx=-1,this._findCount.textContent="–",this._focusInput(),this._render()}_runFind(e){this._findMatches=rr(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}this._findIdx=sr(this._findMatches,this._findIdx,e);const t=this._findMatches[this._findIdx];this._tab.cur={row:t.row,col:t.col},this._tab.sel={ar:t.row,ac:t.col,fr:t.row,fc:t.col+t.len},this._scrollIntoView(),this._render(),this._findCount.textContent=`${this._findIdx+1}/${this._findMatches.length}`}_acVisible(){return this._acPopup.style.display!=="none"}_acHide(){this._acPopup.style.display="none",this._acItems=[]}_acTrigger(){if(!this._config.autocomplete){this._acHide();return}this._acDebounceTimer!==null&&clearTimeout(this._acDebounceTimer),this._acDebounceTimer=setTimeout(()=>{this._acDebounceTimer=null,this._acTriggerNow()},120)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",r=this._config.language==="css",{prefix:o,start:s}=pr(i,e.col,r);this._acPrefix=o,this._acStartCol=s;const a=[];if(this._config.emmet){const d=Ke(i,e.col);if(d){const h=Ue(d.abbr);if(h){this._emmetAcStartCol=d.start;const c=h.replace(/\n/g,"↵ ").slice(0,60);a.push({label:d.abbr,kind:"emmet",detail:c,body:h})}}}const l=o.length>=this._config.autocompletePrefixLength?hr(t,o,{language:this._config.language,extraKeywords:this._config.extraKeywords,extraTypes:this._config.extraTypes,completions:this._allCompletions(),replaceBuiltins:this._config.replaceBuiltins,maxResults:this._config.maxCompletions,provideCompletions:this._config.provideCompletions},e.row,e.col):[];if(this._acItems=[...a,...l],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const e=l=>{switch(l){case"kw":return"K";case"fn":return"f";case"typ":return"T";case"cls":return"C";case"snip":return"S";case"emmet":return"E";default:return"·"}},t=this._acItems[this._acSel];let i="";t!=null&&t.description?i=t.description:(t==null?void 0:t.kind)==="snip"&&t.body?i=t.body.replace(/\$\d/g,"▌"):(t==null?void 0:t.kind)==="emmet"&&t.body&&(i=t.body);const r=this._acItems.map((l,d)=>{const h=d===this._acSel;return`<div class="sl-ac-item${h?" sl-sel":""}" data-i="${d}" role="option" aria-selected="${h}"><span class="sl-ac-badge ${l.kind}">${e(l.kind)}</span><span class="sl-ac-label">${l.label}</span><span class="sl-ac-detail">${l.detail??""}</span></div>`}).join(""),o=i?`<div class="sl-ac-desc"><pre class="sl-ac-desc-body">${i.replace(/</g,"&lt;")}</pre></div>`:"";this._acPopup.innerHTML=`<div class="sl-ac-list">${r}</div>`+o,this._acPopup.style.display="flex",this._posAcPopup();const s=this._acPopup.querySelector(".sl-ac-list"),a=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(s&&a){const l=a.offsetTop,d=l+a.offsetHeight;d>s.scrollTop+s.clientHeight?s.scrollTop=d-s.clientHeight:l<s.scrollTop&&(s.scrollTop=l)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(l=>{l.addEventListener("mousedown",d=>{d.preventDefault(),this._acSel=parseInt(l.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=U(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,r=e.left+i+14+this._acStartCol*7.82,o=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,s=this._acPopup.querySelector(".sl-ac-desc")?620:300,a=Math.min(this._acItems.length*28+8,320),l=o+a>window.innerHeight-16;this._acPopup.style.left=`${Math.min(r,window.innerWidth-s-16)}px`,this._acPopup.style.top=`${l?o-this._config.lineHeight-2-a:o}px`}_acAccept(){const e=this._acItems[this._acSel];if(!e)return;if(this._acHide(),e.kind==="emmet"&&e.body){M(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._emmetAcStartCol);return}if(e.body){M(this._tab,this._config.maxUndoHistory),this._expandBodyAt(e.body,this._acStartCol);return}const t=e.label.slice(this._acPrefix.length);this._insertStr(t,!1),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render()}_emmetCheck(){if(this._emmetTip.style.display="none",!this._config.emmet){this._emmetExpanded=null;return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",r=Ke(i,e.col);if(!r){this._emmetExpanded=null;return}const o=Ue(r.abbr);if(!o){this._emmetExpanded=null;return}this._emmetExpanded={abbr:r.abbr,result:o,start:r.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{abbr:e,result:t,start:i}=this._emmetExpanded;return M(this._tab,this._config.maxUndoHistory),this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(t,i),!0}_allCompletions(){return[...this._config.replaceBuiltins?[]:Ji(this._config.language),...this._config.completions]}_snippetCheck(){if(this._snippetTip.style.display="none",!this._config.snippetExpansion){this._snippetExpanded=null;return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",r=Zi(i,e.col,this._allCompletions());if(!r){this._snippetExpanded=null;return}this._snippetExpanded={snippet:r.snippet,start:r.start}}_snippetAccept(){if(!this._snippetExpanded||this._snippetTip.style.display==="none")return!1;const{snippet:e,start:t}=this._snippetExpanded;return e.body?(M(this._tab,this._config.maxUndoHistory),this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t),!0):!1}_expandBodyAt(e,t){var i,r;const{doc:o,cur:s}=this._tab,a=o[s.row]??"",l=a.slice(0,t),d=a.slice(s.col),h=Ge(a),c=e.split(`
466
- `).map((u,k)=>k===0?u:h+u),p=c.join(`
467
- `),m=p.indexOf("$1"),g=c.map(u=>u.replace(/\$\d+/g,"")),f=g.length===1?[l+g[0]+d]:[l+g[0],...g.slice(1,-1),g[g.length-1]+d];if(o.splice(s.row,1,...f),m>=0){const u=p.slice(0,m).split(`
468
- `),k=u.length-1,_=u[k].length,x=(u[k].match(/\$\d+/g)??[]).join("").length;s.row+=k,s.col=(k===0?t:h.length)+(_-x)}else s.row+=f.length-1,s.col=(f[f.length-1]??"").length-d.length;this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(r=(i=this._config).onChange)==null||r.call(i,A(this._tab.doc))}_openThemePicker(){var e;const t=this._themeManager.all;this._themePanel.innerHTML=`
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,"&lt;")}</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=`
469
501
  <div class="sl-theme-header">
470
502
  <div class="sl-theme-title">Color Theme</div>
471
503
  <div class="sl-theme-close">✕</div>
@@ -487,7 +519,8 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
487
519
  </div>
488
520
  `).join("")}
489
521
  </div>
490
- `,this._themeOverlay.style.display="block",(e=this._themePanel.querySelector(".sl-theme-close"))==null||e.addEventListener("click",()=>{this._themeOverlay.style.display="none"}),this._themeOverlay.addEventListener("click",i=>{i.target===this._themeOverlay&&(this._themeOverlay.style.display="none")},{once:!0}),this._themePanel.querySelectorAll(".sl-theme-item").forEach(i=>{i.addEventListener("click",()=>{const r=i.dataset.id??"";this.setTheme(r),this._themePanel.querySelectorAll(".sl-theme-item").forEach(o=>o.classList.remove("sl-active")),i.classList.add("sl-active")})})}_bindEditorEvents(){this._vpEl.addEventListener("mousedown",this._onFoldBtnClick),this._editorEl.addEventListener("mousedown",e=>{if(e.button!==0)return;e.preventDefault(),this._focusInput(),this._acHide(),this._emmetTip.style.display="none",e.altKey||(Xe(this._mc),this._extraCursors=[]);const t=this._posFromMouse(e);if(this._tab.cur={...t},e.detail===3)this._tab.sel={ar:t.row,ac:0,fr:t.row,fc:(this._tab.doc[t.row]??"").length},this._tab.cur.col=this._tab.sel.fc;else if(e.detail===2&&this._config.wordSelection){const i=this._tab.doc[t.row]??"",r=ge(i,t.col,this._isWordChar.bind(this)),o=be(i,t.col,this._isWordChar.bind(this));r!==o?(this._tab.sel={ar:t.row,ac:r,fr:t.row,fc:o},this._tab.cur.col=o):this._tab.sel=null}else{if(e.altKey&&this._config.multiCursor){Ye(this._mc,t.row,t.col,null),this._extraCursors=[...this._mc.cursors],this._render();return}this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...t}}L(this._tab),this._render()}),this._editorEl.addEventListener("mousemove",e=>{if(this._config.hover&&!this._hoverPinned&&!this._isDragging&&this._scheduleHover(e),!this._isDragging||!this._dragAnchor)return;const t=this._posFromMouse(e);this._tab.cur={...t},t.row!==this._dragAnchor.row||t.col!==this._dragAnchor.col?this._tab.sel={ar:this._dragAnchor.row,ac:this._dragAnchor.col,fr:t.row,fc:t.col}:this._tab.sel=null,L(this._tab),this._render()}),this._editorEl.addEventListener("mouseleave",()=>{this._hoverPinned||this._hideHover()}),window.addEventListener("mouseup",this._onWinMouseUp),this._editorEl.addEventListener("scroll",this._onEditorScroll,{passive:!0}),window.addEventListener("resize",this._onWinResize),this._inputEl.addEventListener("keydown",e=>this._onKeyDown(e)),this._inputEl.addEventListener("input",e=>this._onInput(e)),this._inputEl.addEventListener("paste",e=>{var t;if(e.preventDefault(),this._config.readOnly)return;const i=(t=e.clipboardData??window.clipboardData)==null?void 0:t.getData("text/plain");i&&(this._insertStr(i,!1),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render())}),this._editorEl.addEventListener("mousedown",()=>setTimeout(()=>this._focusInput(),0)),this._inputEl.addEventListener("focus",()=>{var e,t;return(t=(e=this._config).onFocus)==null?void 0:t.call(e)}),this._inputEl.addEventListener("blur",()=>{var e,t;return(t=(e=this._config).onBlur)==null?void 0:t.call(e)})}_onKeyDown(e){var t,i,r,o,s,a,l,d,h;const c=e.ctrlKey||e.metaKey,p=e.shiftKey,m=e.altKey,g=this._config.readOnly;if(this._hideHover(),this._acVisible()){if(e.key==="ArrowDown"){e.preventDefault(),this._acSel=Math.min(this._acItems.length-1,this._acSel+1),this._renderAcPopup();return}if(e.key==="ArrowUp"){e.preventDefault(),this._acSel=Math.max(0,this._acSel-1),this._renderAcPopup();return}if(e.key==="Tab"||e.key==="Enter"){e.preventDefault(),this._acAccept();return}if(e.key==="Escape"){this._acHide();return}}if(m&&(e.key==="z"||e.key==="Z"||e.key==="Ω")){e.preventDefault(),this._toggleWrap();return}if(c&&e.key==="z"&&!p){e.preventDefault(),g||this.undo();return}if(c&&(e.key==="y"||p&&e.key==="z")){e.preventDefault(),g||this.redo();return}if(c&&e.key==="a"){e.preventDefault(),this._selectAll();return}if(c&&e.key==="c"){e.preventDefault(),this._doCopy();return}if(c&&e.key==="x"){e.preventDefault(),g||this._doCut();return}if(c&&e.key==="f"){e.preventDefault(),this._config.find&&this._openFind(!1);return}if(c&&e.key==="h"){e.preventDefault(),this._config.find&&this._config.findReplace&&this._openFind(!0);return}if(c&&e.key==="d"){e.preventDefault(),!g&&this._config.multiCursor&&this._ctrlD();return}if(c&&p&&e.key==="d"){e.preventDefault(),g||this._duplicateLine();return}if(c&&e.key==="/"){e.preventDefault(),g||this._toggleComment();return}if(c&&e.key==="k"){e.preventDefault(),g||this._deleteLine();return}if(e.key==="Escape"){this._tab.sel=null,this._acHide(),this._closeFind(),this._emmetTip.style.display="none",this._snippetTip.style.display="none",this._snippetExpanded=null,Xe(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(g){this._handleArrowKeys(e,c,p);return}if(e.key==="Tab"){if(e.preventDefault(),!p&&this._emmetAccept()||!p&&this._snippetAccept())return;p?this._unindentSel():this._indentSel(),L(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){const f=tr(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors);this._tab.doc=f.doc,this._tab.cur.row=f.primaryRow,this._tab.cur.col=f.primaryCol,this._extraCursors=f.extraCursors,this._mc.cursors=f.extraCursors}else this._doBackspace();this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc));return}if(e.key==="Delete"){e.preventDefault(),this._doDelete(),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(o=(r=this._config).onChange)==null||o.call(r,A(this._tab.doc));return}if(e.key==="Enter"){e.preventDefault(),this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(a=(s=this._config).onChange)==null||a.call(s,A(this._tab.doc));return}if(!c&&!m&&this._config.autoClosePairs[e.key]){e.preventDefault(),M(this._tab,this._config.maxUndoHistory),this._tab.sel&&(this._tab.cur=q(this._tab));const{doc:f,cur:u}=this._tab,k=f[u.row]??"";f[u.row]=k.slice(0,u.col)+e.key+this._config.autoClosePairs[e.key]+k.slice(u.col),u.col++,this._tokenCache.invalidateLine(u.row,((l=this._wm.segments[u.row])==null?void 0:l.length)??1),this._tab.dirty=!0,this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(h=(d=this._config).onChange)==null||h.call(d,A(this._tab.doc));return}if(!c&&!m&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:f,cur:u}=this._tab;if((f[u.row]??"")[u.col]===e.key){e.preventDefault(),u.col++,L(this._tab),this._scrollIntoView(),this._render();return}}if(m&&!c&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this._moveLines(e.key==="ArrowUp");return}this._handleArrowKeys(e,c,p)}_handleArrowKeys(e,t,i){var r,o,s,a,l,d;const{doc:h,cur:c}=this._tab,p=this._config.lineHeight,m=e.metaKey,g=e.ctrlKey,f=e.altKey,u=(x,v)=>{if(i){this._tab.sel||(this._tab.sel={ar:c.row,ac:c.col,fr:c.row,fc:c.col}),c.row=x,c.col=v;const E=this._tab.sel;E.fr=x,E.fc=v,E.ar===E.fr&&E.ac===E.fc&&(this._tab.sel=null)}else this._tab.sel=null,c.row=x,c.col=v},k=x=>{const v=(h[x]??"").search(/\S/);return v===-1||c.col===v?0:v},_=()=>({row:h.length-1,col:(h[h.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const x=N(this._tab.sel);c.row=x.fr,c.col=x.fc,this._tab.sel=null;break}if(m)u(c.row,(h[c.row]??"").length);else if(g||f){const x=this._wordSkipRight(h[c.row]??"",c.col);u(c.row,x)}else c.col<(h[c.row]??"").length?u(c.row,c.col+1):c.row<h.length-1&&u(c.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const x=N(this._tab.sel);c.row=x.ar,c.col=x.ac,this._tab.sel=null;break}if(m)u(c.row,k(c.row));else if(g||f){const x=this._wordSkipLeft(h[c.row]??"",c.col);u(c.row,x)}else c.col>0?u(c.row,c.col-1):c.row>0&&u(c.row-1,(h[c.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),m){const x=_();u(x.row,x.col)}else if(this._config.wordWrap){const x=U(this._wm,c.row,c.col),v=Math.min(this._wm.visualRows.length-1,x.visRow+1),E=te(this._wm,v,Math.min(x.colInSeg,(((r=this._wm.visualRows[v])==null?void 0:r.text)??"").length));u(E.row,E.col)}else{const x=Math.min(h.length-1,c.row+1);u(x,Math.min(c.col,(h[x]??"").length))}break;case"ArrowUp":if(e.preventDefault(),m)u(0,0);else if(this._config.wordWrap){const x=U(this._wm,c.row,c.col),v=Math.max(0,x.visRow-1),E=te(this._wm,v,Math.min(x.colInSeg,(((o=this._wm.visualRows[v])==null?void 0:o.text)??"").length));u(E.row,E.col)}else{const x=Math.max(0,c.row-1);u(x,Math.min(c.col,(h[x]??"").length))}break;case"Home":e.preventDefault(),g?u(0,0):u(c.row,k(c.row));break;case"End":if(e.preventDefault(),g){const x=_();u(x.row,x.col)}else u(c.row,(h[c.row]??"").length);break;case"PageDown":e.preventDefault();{const x=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),v=Math.min(h.length-1,c.row+x);u(v,Math.min(c.col,(h[v]??"").length)),this._editorEl.scrollTop+=this._editorEl.clientHeight-p;break}case"PageUp":e.preventDefault();{const x=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),v=Math.max(0,c.row-x);u(v,Math.min(c.col,(h[v]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-p;break}default:return}L(this._tab),this._scrollIntoView(),this._acHide(),(a=(s=this._config).onCursorChange)==null||a.call(s,{...this._tab.cur}),(d=(l=this._config).onSelectionChange)==null||d.call(l,this._tab.sel?{...this._tab.sel}:null),this._render()}_isWordChar(e){const t=this._config.wordSeparators;return t?e.trim()!==""&&!t.includes(e):/[\w$]/.test(e)}_wordSkipRight(e,t){let i=t;for(;i<e.length&&/\s/.test(e[i]);)i++;for(;i<e.length&&/\S/.test(e[i]);)i++;return i}_wordSkipLeft(e,t){let i=t;for(;i>0&&/\s/.test(e[i-1]);)i--;for(;i>0&&/\S/.test(e[i-1]);)i--;return i}_moveLines(e){var t,i,r,o;const{doc:s,cur:a}=this._tab,l=this._tab.sel;let d=a.row,h=a.row;if(l){const c=N(l);d=c.ar,h=c.fr,c.fc===0&&c.fr>c.ar&&h--}if(e){if(d===0)return;M(this._tab,this._config.maxUndoHistory);const c=s.splice(d,h-d+1);s.splice(d-1,0,...c),a.row--,l&&(l.ar--,l.fr--)}else{if(h>=s.length-1)return;M(this._tab,this._config.maxUndoHistory);const c=s.splice(d,h-d+1);s.splice(d+1,0,...c),a.row++,l&&(l.ar++,l.fr++)}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc)),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur})}_scheduleHover(e){this._hoverTip.style.display!=="none"&&(this._hoverTip.style.display="none"),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null);const{clientX:t,clientY:i}=e;this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._doHover(t,i)},500)}_doHover(e,t){var i,r,o;if(!this._config.hover)return;const s=this._editorEl.getBoundingClientRect(),a=t-s.top+this._editorEl.scrollTop,l=this._config.showGutter?this._config.gutterWidth:0,d=e-s.left-l-14,h=this._config.lineHeight,c=Math.max(0,Math.min(this._wm.visualRows.length-1,Math.floor(a/h))),p=Math.max(0,Math.min((((i=this._wm.visualRows[c])==null?void 0:i.text)??"").length,Math.round(d/7.82))),m=te(this._wm,c,p),g=this._tab.doc[m.row]??"",f=ur(g,m.col);if(!f)return;let u=gr(f,this._config.language);if(!u){const k=this._config.completions.find(_=>_.label===f);k&&(k.description||k.detail)&&(u={title:k.label,type:k.detail,body:k.description??""})}if(!u){const k=(o=(r=this._config).provideHover)==null?void 0:o.call(r,{word:f,row:m.row,col:m.col,line:g,language:this._config.language,doc:this._tab.doc});k&&(u=k)}u&&this._showHoverTip(u,e,t)}_showHoverTip(e,t,i){const r=this._hoverTip;let o='<div class="sl-ht-sig">';o+=`<span class="sl-ht-title">${X(e.title)}</span>`,e.type&&(o+=`<code class="sl-ht-type">${X(e.type)}</code>`),o+="</div>",e.title&&e.body&&(o+='<div class="sl-ht-divider"></div>'),e.body&&(o+=`<div class="sl-ht-body">${X(e.body)}</div>`),r.innerHTML=o,r.style.display="block";const s=12,a=18,l=r.offsetWidth||300,d=r.offsetHeight||80;let h=t,c=i+a;c+d>window.innerHeight-s&&(c=i-d-8),h+l>window.innerWidth-s&&(h=window.innerWidth-l-s),h<s&&(h=s),r.style.left=`${h}px`,r.style.top=`${Math.max(s,c)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_onInput(e){var t,i,r,o;if(this._config.readOnly){e.target.value="";return}const s=e.target,a=s.value;if(s.value="",!a||a==="Ω")return;const l=a.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(l){if(this._extraCursors.length){const d=er(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._extraCursors,l);this._tab.doc=d.doc,this._tab.cur.row=d.primaryRow,this._tab.cur.col=d.primaryCol,this._extraCursors=d.extraCursors,this._mc.cursors=d.extraCursors,this._tab.dirty=!0,(i=(t=this._config).onChange)==null||i.call(t,A(this._tab.doc))}else this._insertStr(l,!0);this._tokenCache.clear(),this._rebuildWrapMap(),L(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur})}}_ctrlD(){if(!this._config.multiCursor)return;const e=ir(this._mc,this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel);e&&(!this._mc.cursors.length||e.word!==this._mc.searchWord?(this._tab.sel=e.sel,this._tab.cur.col=e.col):(Ye(this._mc,e.row,e.col,e.sel),this._extraCursors=[...this._mc.cursors]),this._mc.searchWord=e.word,this._mc.lastMatchRow=e.row,this._mc.lastMatchCol=e.col,this._scrollIntoView(),this._render())}_bindFindEvents(){var e,t,i,r,o,s,a;this._findInput.addEventListener("input",()=>{this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),this._findInput.addEventListener("keydown",l=>{l.key==="Enter"?l.shiftKey?this._navFind(-1):this._navFind(1):l.key==="Escape"&&this._closeFind(),l.stopPropagation()}),this._replaceInput.addEventListener("keydown",l=>{l.key==="Enter"?this._doReplaceOne():l.key==="Escape"&&this._closeFind(),l.stopPropagation()}),(e=this._findBar.querySelector(".sl-find-prev"))==null||e.addEventListener("click",()=>this._navFind(-1)),(t=this._findBar.querySelector(".sl-find-next"))==null||t.addEventListener("click",()=>this._navFind(1)),(i=this._findBar.querySelector(".sl-find-close"))==null||i.addEventListener("click",()=>this._closeFind()),(r=this._findBar.querySelector(".sl-find-case"))==null||r.addEventListener("click",l=>{this._findCaseSensitive=!this._findCaseSensitive,l.target.classList.toggle("sl-active",this._findCaseSensitive),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(o=this._findBar.querySelector(".sl-find-regex"))==null||o.addEventListener("click",l=>{this._findRegex=!this._findRegex,l.target.classList.toggle("sl-active",this._findRegex),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(s=this._findBar.querySelector(".sl-replace-one"))==null||s.addEventListener("click",()=>this._doReplaceOne()),(a=this._findBar.querySelector(".sl-replace-all"))==null||a.addEventListener("click",()=>this._doReplaceAll())}_doReplaceOne(){var e,t;this._findIdx<0||!this._findMatches.length||(M(this._tab,this._config.maxUndoHistory),this._tab.doc=nr(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0,this._runFind(this._findInput.value),this._findMatches.length?(this._findIdx>=this._findMatches.length&&(this._findIdx=0),this._navFind(0)):(this._findCount.textContent="0/0",this._rebuildWrapMap(),this._render()),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc)))}_doReplaceAll(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches.length;M(this._tab,this._config.maxUndoHistory),this._tab.doc=or(this._tab.doc,this._findMatches,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0,this._findMatches=[],this._findIdx=-1,this._findCount.textContent=`0/0 (${i} replaced)`,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,A(this._tab.doc))}_bindMinimapEvents(){const e=this._minimapWrap;e.addEventListener("mousemove",t=>{if(this._mmDragMode!=="none")return;const i=t.clientY-e.getBoundingClientRect().top,{sliderTop:r,sliderHeight:o}=_e(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=r&&i<=r+o?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,r=t.clientY-e.getBoundingClientRect().top,{sliderTop:o,sliderHeight:s}=_e(this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);if(r>=o&&r<=o+s)this._mmDragMode="slider",this._mmSliderOffset=r-o,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const a=wr(r,this._tab.doc.length,this._editorEl.scrollTop,this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=a,this._mmDragStartY=t.clientY,this._mmDragStartScroll=a,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}const et={id:"mdx-dark",name:"MDX Dark",description:"Catppuccin Mocha — matches .smdx-dark MDX editor chrome, single-colour tokens",light:!1,tokens:{bg0:"#181825",bg1:"#1e1e2e",bg2:"#1e1e2e",bg3:"#2a2a3c",bg4:"#313147",border:"#374151",border2:"rgba(129,140,248,.22)",border3:"rgba(129,140,248,.40)",text:"#e2e8f0",text2:"#94a3b8",text3:"#475569",accent:"#818cf8",accent2:"#6366f1",green:"#c3e88d",orange:"#f78c6c",purple:"#c792ea",red:"#f07178",yellow:"#ffcb6b",cur:"#818cf8",curGlow:"rgba(129,140,248,.55)",curLineBg:"rgba(129,140,248,.055)",curLineGutter:"#252540",gutterBg:"#181825",gutterHover:"#252540",gutterBorder:"#374151",gutterNum:"#475569",gutterNumAct:"#94a3b8",selBg:"rgba(129,140,248,.24)",wordHlBg:"rgba(226,232,240,.07)",wordHlBorder:"rgba(226,232,240,.25)",bmBorder:"rgba(137,221,255,.70)",foldBg:"rgba(129,140,248,.07)",foldBorder:"rgba(129,140,248,.30)",findBg:"rgba(251,191,36,.16)",findBorder:"rgba(251,191,36,.50)",findCurBg:"rgba(251,191,36,.85)",findCurBorder:"rgba(251,191,36,.95)",findCurText:"#1a1000",fileActiveBg:"rgba(129,140,248,.12)",fileActiveText:"#818cf8",mmBg:"#181825",mmSlider:"rgba(255,255,255,.07)",mmDim:"rgba(0,0,0,.30)",mmEdge:"rgba(255,255,255,.18)",indentGuide:"rgba(255,255,255,.06)",tokKw:"#e2e8f0",tokStr:"#e2e8f0",tokCmt:"#e2e8f0",tokFn:"#e2e8f0",tokNum:"#e2e8f0",tokCls:"#e2e8f0",tokOp:"#e2e8f0",tokTyp:"#e2e8f0",tokDec:"#e2e8f0"}},tt={id:"mdx-light",name:"MDX Light",description:"Clean light — matches default .smdx-editor MDX chrome, single-colour tokens",light:!0,tokens:{bg0:"#f1f5f9",bg1:"#ffffff",bg2:"#ffffff",bg3:"#f8fafc",bg4:"#f1f5f9",border:"#e2e8f0",border2:"rgba(99,102,241,.20)",border3:"rgba(99,102,241,.40)",text:"#1e293b",text2:"#64748b",text3:"#94a3b8",accent:"#6366f1",accent2:"#4f46e5",green:"#15803d",orange:"#c2410c",purple:"#7c3aed",red:"#dc2626",yellow:"#b45309",cur:"#6366f1",curGlow:"rgba(99,102,241,.35)",curLineBg:"rgba(99,102,241,.05)",curLineGutter:"#eef2ff",gutterBg:"#f8fafc",gutterHover:"#eef2ff",gutterBorder:"#e2e8f0",gutterNum:"#94a3b8",gutterNumAct:"#475569",selBg:"rgba(99,102,241,.18)",wordHlBg:"rgba(99,102,241,.07)",wordHlBorder:"rgba(99,102,241,.30)",bmBorder:"rgba(14,116,144,.60)",foldBg:"rgba(99,102,241,.06)",foldBorder:"rgba(99,102,241,.28)",findBg:"rgba(180,83,9,.09)",findBorder:"rgba(180,83,9,.40)",findCurBg:"rgba(180,83,9,.75)",findCurBorder:"rgba(180,83,9,.95)",findCurText:"#ffffff",fileActiveBg:"rgba(99,102,241,.10)",fileActiveText:"#6366f1",mmBg:"#f8fafc",mmSlider:"rgba(0,0,0,.06)",mmDim:"rgba(0,0,0,.05)",mmEdge:"rgba(0,0,0,.18)",indentGuide:"rgba(0,0,0,.08)",tokKw:"#1e293b",tokStr:"#1e293b",tokCmt:"#1e293b",tokFn:"#1e293b",tokNum:"#1e293b",tokCls:"#1e293b",tokOp:"#1e293b",tokTyp:"#1e293b",tokDec:"#1e293b"}},Er="#e2e8f0",Sr="#1e293b";function it(n){return{keyword:n,string:n,comment:n,function:n,number:n,class:n,operator:n,type:n,decorator:n}}const rt=it(Er),nt=it(Sr),re={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},Mr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ne=[{label:"title",kind:"var",detail:"attribute"},{label:"color",kind:"var",detail:"attribute"},{label:"icon",kind:"var",detail:"attribute"},{label:"href",kind:"var",detail:"attribute"},{label:"src",kind:"var",detail:"attribute"},{label:"alt",kind:"var",detail:"attribute"},{label:"className",kind:"var",detail:"attribute"},{label:"style",kind:"var",detail:"attribute"},{label:"id",kind:"var",detail:"attribute"},{label:"type",kind:"var",detail:"attribute"},{label:"lang",kind:"var",detail:"attribute"},{label:"label",kind:"var",detail:"attribute"},{label:"description",kind:"var",detail:"attribute"},{label:"variant",kind:"var",detail:"attribute"},{label:"size",kind:"var",detail:"attribute"}],ot=[{label:"h1",kind:"snip",detail:"Heading 1",body:"# $1Heading"},{label:"h2",kind:"snip",detail:"Heading 2",body:"## $1Heading"},{label:"h3",kind:"snip",detail:"Heading 3",body:"### $1Heading"},{label:"h4",kind:"snip",detail:"Heading 4",body:"#### $1Heading"},{label:"h5",kind:"snip",detail:"Heading 5",body:"##### $1Heading"},{label:"h6",kind:"snip",detail:"Heading 6",body:"###### $1Heading"},{label:"bold",kind:"snip",detail:"bold text",body:"**$1bold text**"},{label:"italic",kind:"snip",detail:"italic text",body:"*$1italic text*"},{label:"strike",kind:"snip",detail:"strikethrough",body:"~~$1strikethrough~~"},{label:"code",kind:"snip",detail:"inline code",body:"`$1code`"},{label:"link",kind:"snip",detail:"markdown link",body:"[link text](url)"},{label:"img",kind:"snip",detail:"image",body:"![alt text](image-url)"},{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
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:"![alt text](image-url)"},{label:"cb",kind:"snip",detail:"fenced code block",body:"```language\ncode here\n```"},{label:"quote",kind:"snip",detail:"blockquote",body:"> $1"},{label:"hr",kind:"snip",detail:"horizontal rule",body:"---"},{label:"ul",kind:"snip",detail:"unordered list",body:`- $1Item 1
491
524
  - $2Item 2
492
525
  - $3Item 3`},{label:"ol",kind:"snip",detail:"ordered list",body:`1. $1Item 1
493
526
  2. $2Item 2
@@ -724,22 +757,22 @@ $$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<C
724
757
  "status": "deleted"
725
758
  }
726
759
  \`\`\`
727
- </Endpoint>`}];class st{constructor(e){this.tocCollapsed=!1,this.themeObserver=null,this.events=new Se,this.renderer=new Q,this.renderTimer=null,this._destroyed=!1,this._userCompletions=[],this.config=e,this.mode=e.mode||"split",this.init()}init(){const e=typeof this.config.container=="string"?document.querySelector(this.config.container):this.config.container;if(!e)throw new Error("[SynclineMDX] Container element not found");this.buildDOM(e),this.config.theme&&this.applyTheme(this.config.theme),this.mountCodeEditor(this.config.value||""),this.pluginManager=new le(this,this.events);const t=this.config.toolbar||[this.getDefaultToolbar()];this.toolbar=new ce(t,this.pluginManager,this,this.events);const i=()=>{this._refreshCompletions(),this.toolbar.render(this.toolbarLeft),this.renderPreview(),this.refreshToc()};this.config.plugins?this.registerPlugins(this.config.plugins).then(i):i(),this.editorHost.addEventListener("keydown",r=>{var a;if(!(r.metaKey||r.ctrlKey))return;const s=((a=this.pluginManager)==null?void 0:a.getShortcuts())??[];for(const l of s)if(this.matchShortcut(r,l.key)){r.preventDefault(),r.stopPropagation(),l.action({editor:this,selection:this.getSelection()});return}},!0),this.mode==="split"&&(this.root.getBoundingClientRect().width||window.innerWidth)<=640&&(this.mode="editor"),this.setMode(this.mode),this.config.onChange&&this.on("change",r=>{typeof r=="string"&&this.config.onChange(r)})}isDarkMode(){var i;if(this.root.classList.contains("smdx-dark")||this.root.closest(".smdx-dark"))return!0;const e=this.root.closest("[data-theme]");if(e){const r=e.dataset.theme;if(r==="dark")return!0;if(r==="light")return!1}return document.documentElement.dataset.colorScheme==="dark"?!0:document.documentElement.classList.contains("smdx-dark")||(((i=document.body)==null?void 0:i.classList.contains("smdx-dark"))??!1)}syncCodeEditorTheme(){const e=this.isDarkMode();this.codeEditor.setTheme(e?et:tt),this.codeEditor.updateConfig({tokenColors:e?rt:nt})}setupThemeObserver(){const e=()=>this.syncCodeEditorTheme();this.themeObserver=new MutationObserver(e);const t={attributes:!0,attributeFilter:["class","data-theme","data-color-scheme"]};let i=this.root;for(;i;)this.themeObserver.observe(i,t),i=i.parentElement}mountCodeEditor(e){this.codeEditor=new Tr(this.editorHost,{showGutter:!0,wordWrap:!0,bracketMatching:!0,showIndentGuides:!0,multiCursor:!0,autocomplete:!0,wordHighlight:!1,emmet:!1,codeFolding:!1,showMinimap:!1,find:!1,findReplace:!1,value:e,language:"markdown",theme:this.isDarkMode()?et:tt,showStatusBar:!1,extraKeywords:["import","export","default","from","as","true","false","null","undefined"],completions:[...ne,...ot],replaceBuiltins:!0,provideCompletions:i=>{const r=i.line.slice(0,i.col),o=r.match(/<([A-Za-z]*)$/);if(o){const a=o[1].toLowerCase();return ne.filter(l=>l.kind==="cls"&&(a===""||l.label.toLowerCase().startsWith(a)))}const s=r.match(/<[A-Za-z][\w.]*(?:\s+[\w-]*="[^"]*"\s*)*\s+([A-Za-z]*)$/);if(s){const a=s[1].toLowerCase();return ne.filter(l=>l.kind==="var"&&(a===""||l.label.toLowerCase().startsWith(a)))}return null},tokenColors:this.isDarkMode()?rt:nt,readOnly:this.config.readOnly,onChange:i=>{this.textarea.value=i,this.scheduleRender(),this.updateStatusBar(),this.events.emit("change",i),this.refreshToc()},onFocus:()=>this.events.emit("focus"),onBlur:()=>this.events.emit("blur"),onSelectionChange:()=>{this.toolbar.updateActiveStates(),this.events.emit("selection-change",this.getSelection())},onCursorChange:()=>{this.updateStatusBar()}}),this.editorHost.shadowRoot.querySelector(".sl-input").addEventListener("keydown",i=>{if(!this.config.readOnly&&!(i.ctrlKey||i.metaKey||i.altKey)){if(re[i.key]){const r=this.getSelection();if(r.text){i.preventDefault(),i.stopImmediatePropagation();const o=i.key,s=re[o],a=this.codeEditor.getValue(),l=a.substring(0,r.start)+o+r.text+s+a.substring(r.end);this.codeEditor.setValue(l),this.setSelection(r.start+1,r.end+1);return}}if(i.key==="Backspace"){const r=this.getSelection();if(r.start===r.end&&r.start>0){const o=this.codeEditor.getValue(),s=o[r.start-1],a=o[r.start];if(re[s]&&re[s]===a){i.preventDefault(),i.stopImmediatePropagation();const l=o.substring(0,r.start-1)+o.substring(r.start+1);this.codeEditor.setValue(l),this.setSelection(r.start-1,r.start-1);return}}}if(i.key===">"){const r=this.getSelection(),o=this.codeEditor.getValue(),a=o.substring(0,r.start).match(/<([A-Za-z][A-Za-z0-9.-]*)(?:\s[^>]*)?\s*$/);if(a){const l=a[1];if(!Mr.has(l.toLowerCase())){i.preventDefault(),i.stopImmediatePropagation();const d=`></${l}>`,h=o.substring(0,r.start)+d+o.substring(r.end);this.codeEditor.setValue(h),this.setSelection(r.start+1,r.start+1);return}}}}},!0),this.textarea.value=e,this.setupThemeObserver(),this.updateStatusBar()}_refreshCompletions(){!this.codeEditor||!this.pluginManager||this.codeEditor.updateConfig({completions:[...ne,...ot,...this.pluginManager.getCompletions(),...this._userCompletions]})}registerAutoComplete(e){const t=Array.isArray(e)?e:[e];this._userCompletions.push(...t),this._refreshCompletions()}buildDOM(e){this.root=document.createElement("div"),this.root.className="smdx-editor",this.root.setAttribute("role","application"),this.root.setAttribute("aria-label","Markdown Editor");const t=document.createElement("a");t.className="smdx-skip-link",t.href="#smdx-editor-content",t.textContent="Skip to editor",this.root.appendChild(t),this.textarea=document.createElement("textarea"),this.textarea.className="smdx-textarea-compat",this.textarea.setAttribute("aria-hidden","true"),this.textarea.setAttribute("role","textbox"),this.textarea.setAttribute("aria-label","Markdown editor"),this.textarea.setAttribute("aria-multiline","true"),this.textarea.setAttribute("tabindex","-1"),this.textarea.style.cssText="position:absolute;opacity:0;width:0;height:0;pointer-events:none;overflow:hidden;",this.root.appendChild(this.textarea),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="smdx-toolbar-container",this.toolbarEl.setAttribute("role","toolbar"),this.toolbarEl.setAttribute("aria-label","Formatting toolbar"),this.toolbarLeft=document.createElement("div"),this.toolbarLeft.className="smdx-toolbar-left",this.toolbarEl.appendChild(this.toolbarLeft),this.modeArea=document.createElement("div"),this.modeArea.className="smdx-toolbar-mode-area",this.toolbarEl.appendChild(this.modeArea),this.updateModeButtons(this.modeArea);const i=document.createElement("div");i.className="smdx-main",this.editorPane=document.createElement("div"),this.editorPane.className="smdx-editor-pane",this.editorPane.id="smdx-editor-content",this.editorHost=document.createElement("div"),this.editorHost.className="smdx-code-editor-host",this.editorHost.style.cssText="width:100%;height:100%;display:flex;flex-direction:column;",this.editorPane.appendChild(this.editorHost),this.previewPane=document.createElement("div"),this.previewPane.className="smdx-preview-pane",this.previewContent=document.createElement("div"),this.previewContent.className="smdx-preview-content",this.previewContent.setAttribute("role","region"),this.previewContent.setAttribute("aria-label","Preview"),this.previewContent.setAttribute("aria-live","polite"),this.previewContent.addEventListener("click",r=>{const o=r.target,s=o.closest("[data-smdx-tab-btn]");if(s){const h=s.closest(".smdx-tabs");if(h){const c=parseInt(s.dataset.tabIndex??"0",10);h.querySelectorAll(".smdx-tab-btn").forEach(p=>p.classList.remove("smdx-active")),s.classList.add("smdx-active"),h.querySelectorAll(".smdx-tab-panel").forEach((p,m)=>{p.style.display=m===c?"block":"none"})}return}const a=o.closest("[data-copy-btn]");if(!a)return;const l=a.closest(".smdx-code-block"),d=l==null?void 0:l.querySelector("code");d&&navigator.clipboard.writeText(d.textContent||"").then(()=>{a.classList.add("smdx-copied"),setTimeout(()=>a.classList.remove("smdx-copied"),2e3)}).catch(()=>{})}),this.previewPane.appendChild(this.previewContent),i.appendChild(this.editorPane),i.appendChild(this.previewPane),this.splitterController=new ee(i,this.editorPane,this.previewPane),this.tocContainer=document.createElement("div"),this.tocContainer.className="smdx-toc-container",this.tocContainer.setAttribute("aria-label","Table of contents"),this.buildTocPanel(),i.appendChild(this.tocContainer),this.statusBar=document.createElement("div"),this.statusBar.className="smdx-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-label","Editor status"),this.root.appendChild(this.toolbarEl),this.root.appendChild(i),this.root.appendChild(this.statusBar),e.appendChild(this.root)}offsetToPos(e){const t=this.codeEditor.getValue();let i=0,r=0;for(let o=0;o<e&&o<t.length;o++)t[o]===`
728
- `?(i++,r=0):r++;return{row:i,col:r}}posToOffset(e,t){const i=this.codeEditor.getValue().split(`
729
- `);let r=0;for(let o=0;o<e&&o<i.length;o++)r+=i[o].length+1;return r+t}async registerPlugins(e){for(const t of e)await this.pluginManager.register(t)}getDefaultToolbar(){return["undo","redo","|","heading","|","bold","italic","strikethrough","code","|","unorderedList","orderedList","taskList","|","insert-hr","insert-layout","insert-endpoint","insert-markdown","insert-snippet","|","link","image","table","quote"]}matchShortcut(e,t){const i=t.toLowerCase().split("+"),r=i.includes("cmd")||i.includes("meta")||i.includes("ctrl"),o=i.includes("shift"),s=i.includes("alt"),a=i.find(d=>!["cmd","meta","ctrl","shift","alt"].includes(d));return a?(e.metaKey||e.ctrlKey)===r&&e.shiftKey===o&&e.altKey===s&&e.key.toLowerCase()===a:!1}scheduleRender(){this.renderTimer&&clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>this.renderPreview(),150)}getCursorPosition(){const e=this.codeEditor.getCursor();return{lineNum:e.row+1,colNum:e.col+1}}updateStatusBar(){var l;const e=((l=this.codeEditor)==null?void 0:l.getValue())??"",t=this.getWordCount(),i=this.getLineCount(),r=e.length,{lineNum:o,colNum:s}=this.getCursorPosition(),a=this.config.readOnly?'<span class="smdx-status-sep">|</span><span class="smdx-status-item smdx-status-readonly">Read Only</span>':"";this.statusBar.innerHTML=`
730
- <span class="smdx-status-item">Ln ${o}, Col ${s}</span>
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>
731
764
  <span class="smdx-status-sep">|</span>
732
765
  <span class="smdx-status-item">${i} lines</span>
733
766
  <span class="smdx-status-sep">|</span>
734
767
  <span class="smdx-status-item">${t} words</span>
735
768
  <span class="smdx-status-sep">|</span>
736
- <span class="smdx-status-item">${r} characters</span>
769
+ <span class="smdx-status-item">${s} characters</span>
737
770
  <span class="smdx-status-sep">|</span>
738
771
  <span class="smdx-status-item">MDX</span>
739
772
  <span class="smdx-status-sep">|</span>
740
773
  <span class="smdx-status-item">UTF-8</span>
741
774
  ${a}
742
- `}updateModeButtons(e){e.innerHTML="";const t=document.createElement("div");t.className="smdx-mode-switch",["editor","split","preview"].forEach(i=>{const r=document.createElement("button");r.type="button",r.className=`smdx-mode-btn${i===this.mode?" smdx-active":""}`,r.dataset.mode=i;const o={editor:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> Editor',split:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/></svg> Split',preview:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg> Preview'};r.innerHTML=o[i],r.setAttribute("aria-label",`${i.charAt(0).toUpperCase()+i.slice(1)} mode`),r.setAttribute("aria-pressed",String(i===this.mode)),r.addEventListener("click",()=>this.setMode(i)),t.appendChild(r)}),e.appendChild(t)}buildTocPanel(){if(this.tocContainer.innerHTML="",this.tocCollapsed){this.tocContainer.classList.add("smdx-toc-collapsed");const r=document.createElement("button");r.className="smdx-toc-expand-btn",r.type="button",r.title="Show table of contents",r.setAttribute("aria-label","Show table of contents"),r.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>',r.addEventListener("click",()=>{this.tocCollapsed=!1,this.buildTocPanel(),this.refreshToc()}),this.tocContainer.appendChild(r);return}this.tocContainer.classList.remove("smdx-toc-collapsed");const e=document.createElement("div");e.className="smdx-toc-header",e.innerHTML=`
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=`
743
776
  <div class="smdx-toc-title">
744
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>
745
778
  <span>CONTENTS</span>
@@ -747,21 +780,21 @@ $$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<C
747
780
  <button class="smdx-toc-close-btn" type="button" title="Hide table of contents" aria-label="Hide table of contents">
748
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>
749
782
  </button>
750
- `,e.querySelector(".smdx-toc-close-btn").addEventListener("click",()=>{this.tocCollapsed=!0,this.buildTocPanel()});const t=document.createElement("div");t.className="smdx-toc-body";const i=document.createElement("div");i.className="smdx-toc-footer",i.textContent="0 headings",this.tocContainer.appendChild(e),this.tocContainer.appendChild(t),this.tocContainer.appendChild(i)}refreshToc(){if(this.tocCollapsed)return;const e=this.tocContainer.querySelector(".smdx-toc-body"),t=this.tocContainer.querySelector(".smdx-toc-footer");if(!e||!t)return;const i=this.textarea.value,r=[];let o=!1;for(const s of i.split(`
751
- `)){if(s.trim().startsWith("```")){o=!o;continue}if(o)continue;const a=s.match(/^(#{1,6})\s+(.+)/);if(a){const l=a[1].length,d=a[2].replace(/[*_`~\[\]]/g,"").trim(),h=d.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-");r.push({level:l,text:d,slug:h})}}if(r.length===0)e.innerHTML='<div class="smdx-toc-empty">No headings found.</div>';else{const s=document.createElement("nav");s.className="smdx-toc-nav";const a=this.previewContent;r.forEach(l=>{const d=document.createElement("button");d.type="button",d.className=`smdx-toc-item smdx-toc-h${l.level}`,d.style.paddingLeft=`${(l.level-1)*12+8}px`,d.textContent=l.text,d.title=l.text,d.addEventListener("click",()=>{const h=a.querySelector(`#${CSS.escape(l.slug)}`);h&&h.scrollIntoView({behavior:"smooth",block:"start"})}),s.appendChild(d)}),e.innerHTML="",e.appendChild(s)}t.textContent=`${r.length} heading${r.length!==1?"s":""}`}toggleToc(){this.tocCollapsed=!this.tocCollapsed,this.buildTocPanel(),this.tocCollapsed||this.refreshToc()}getValue(){return this.codeEditor.getValue()}setValue(e){this.codeEditor.setValue(e),this.textarea.value=e,this.scheduleRender(),this.events.emit("change",e)}insertText(e){this.codeEditor.insertText(e),this.codeEditor.focus()}wrapSelection(e,t){const{start:i,end:r,text:o}=this.getSelection(),s=this.codeEditor.getValue(),a=o||"text",l=e+a+t,d=s.substring(0,i)+l+s.substring(r);this.codeEditor.setValue(d);const h=i+e.length,c=h+a.length;this.setSelection(h,c),this.codeEditor.focus()}replaceSelection(e){const{start:t,end:i}=this.getSelection(),r=this.codeEditor.getValue(),o=r.substring(0,t)+e+r.substring(i);this.codeEditor.setValue(o);const s=this.offsetToPos(t+e.length);this.codeEditor.setCursor(s),this.codeEditor.focus()}getSelection(){const e=this.codeEditor.getValue(),t=this.codeEditor.getSelection(),i=this.codeEditor.getCursor();if(!t){const l=this.posToOffset(i.row,i.col);return{start:l,end:l,text:"",beforeText:e.substring(0,l),afterText:e.substring(l)}}const r=this.posToOffset(t.ar,t.ac),o=this.posToOffset(t.fr,t.fc),s=Math.min(r,o),a=Math.max(r,o);return{start:s,end:a,text:e.substring(s,a),beforeText:e.substring(0,s),afterText:e.substring(a)}}setSelection(e,t){const i=this.offsetToPos(e),r=this.offsetToPos(t),o={ar:i.row,ac:i.col,fr:r.row,fc:r.col};this.codeEditor.setSelection(o),this.codeEditor.focus()}insertBlock(e){const{start:t,end:i}=this.getSelection(),r=this.codeEditor.getValue(),o=r.substring(0,t),s=r.substring(i),a=o.length>0&&!o.endsWith(`
752
- `),l=s.length>0&&!s.startsWith(`
753
- `),d=(a?`
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?`
754
787
 
755
788
  `:"")+e+(l?`
756
789
 
757
- `:""),h=o+d+s;this.codeEditor.setValue(h);const c=this.offsetToPos(o.length+d.length);this.codeEditor.setCursor(c),this.codeEditor.focus()}getTextarea(){return this.textarea}getPreview(){return this.previewContent}getRoot(){return this.root}focus(){this.codeEditor.focus()}async renderPreview(){this.renderer.setRenderers(this.pluginManager.getRenderers()),this.renderer.setParsers(this.pluginManager.getParsers());const e=await this.renderer.render(this.textarea.value);this.previewContent.innerHTML=e,this.events.emit("render",e),this.refreshToc()}getMode(){return this.mode}setMode(e){this.mode=e,this.root.classList.remove("smdx-mode-split","smdx-mode-editor","smdx-mode-preview"),this.root.classList.add(`smdx-mode-${e}`),this.updateModeButtons(this.modeArea),this.updateStatusBar(),this.events.emit("mode-change",e)}registerPlugin(e){this.pluginManager.register(e).then(()=>{this._refreshCompletions(),this.toolbarLeft.innerHTML="",this.toolbar.render(this.toolbarLeft),this.renderPreview()})}unregisterPlugin(e){this.pluginManager.unregister(e),this._refreshCompletions(),this.toolbarLeft.innerHTML="",this.toolbar.render(this.toolbarLeft),this.renderPreview()}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}emit(e,t){this.events.emit(e,t)}destroy(){var e;this._destroyed||(this._destroyed=!0,(e=this.themeObserver)==null||e.disconnect(),this.themeObserver=null,this.codeEditor.destroy(),this.pluginManager.destroy(),this.toolbar.destroy(),this.splitterController.destroy(),this.events.removeAllListeners(),this.renderTimer&&clearTimeout(this.renderTimer),this.root.remove())}undo(){this.codeEditor.undo()}redo(){this.codeEditor.redo()}getCurrentLine(){const e=this.codeEditor.getCursor();return this.codeEditor.getValue().split(`
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(`
758
791
  `)[e.row]??""}getCurrentLineNumber(){return this.codeEditor.getCursor().row+1}replaceCurrentLine(e){const t=this.codeEditor.getCursor(),i=this.codeEditor.getValue().split(`
759
792
  `);i[t.row]=e,this.codeEditor.setValue(i.join(`
760
- `)),this.codeEditor.setCursor({row:t.row,col:e.length})}insertAt(e,t){const i=this.codeEditor.getValue(),r=i.substring(0,e)+t+i.substring(e);this.codeEditor.setValue(r);const o=this.offsetToPos(e+t.length);this.codeEditor.setCursor(o)}getWordCount(){var t;const e=(((t=this.codeEditor)==null?void 0:t.getValue())??this.textarea.value).trim();return e?e.split(/\s+/).length:0}getLineCount(){var e;return(((e=this.codeEditor)==null?void 0:e.getValue())??this.textarea.value).split(`
761
- `).length}setLineNumbers(e){this.codeEditor.updateConfig({showGutter:e})}jumpToLine(e){const t=Math.max(1,Math.min(e,this.getLineCount()));this.codeEditor.setCursor({row:t-1,col:0}),this.codeEditor.focus()}applyTheme(e){for(const[t,i]of Object.entries(e))this.root.style.setProperty(t.startsWith("--")?t:`--smdx-${t}`,i);this.syncCodeEditorTheme()}setCodeEditorTheme(e){e?this.codeEditor.setTheme(e):this.syncCodeEditorTheme()}}class $r{constructor(e=100){this.stack=[],this.pointer=-1,this.maxSize=e}push(e){this.pointer<this.stack.length-1&&(this.stack=this.stack.slice(0,this.pointer+1)),this.stack[this.stack.length-1]!==e&&(this.stack.push(e),this.stack.length>this.maxSize&&this.stack.shift(),this.pointer=this.stack.length-1)}undo(){if(this.pointer>0)return this.pointer--,this.stack[this.pointer]}redo(){if(this.pointer<this.stack.length-1)return this.pointer++,this.stack[this.pointer]}current(){return this.stack[this.pointer]}clear(){this.stack=[],this.pointer=-1}}const C={heading:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 12h16M4 6v12M20 6v12"/></svg>',h1:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H1</text></svg>',h2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H2</text></svg>',h3:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H3</text></svg>',h4:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H4</text></svg>',h5:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H5</text></svg>',h6:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="2" y="17" font-size="14" fill="currentColor" stroke="none" font-weight="bold">H6</text></svg>',bold:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6zM6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"/></svg>',italic:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>',strikethrough:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 4H9a3 3 0 00-3 3v0a3 3 0 003 3h6a3 3 0 013 3v0a3 3 0 01-3 3H8"/><line x1="4" y1="12" x2="20" y2="12"/></svg>',quote:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"/><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"/></svg>',link:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg>',image:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',code:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',codeBlock:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="18" rx="2"/><polyline points="10 8 6 12 10 16"/><polyline points="14 8 18 12 14 16"/></svg>',unorderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor"/><circle cx="4" cy="12" r="1" fill="currentColor"/><circle cx="4" cy="18" r="1" fill="currentColor"/></svg>',orderedList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="2" y="9" font-size="8" fill="currentColor" stroke="none">1</text><text x="2" y="15" font-size="8" fill="currentColor" stroke="none">2</text><text x="2" y="21" font-size="8" fill="currentColor" stroke="none">3</text></svg>',taskList:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="6" height="6" rx="1"/><path d="M5 8l1 1 2-2"/><line x1="13" y1="8" x2="21" y2="8"/><rect x="3" y="13" width="6" height="6" rx="1"/><line x1="13" y1="16" x2="21" y2="16"/></svg>',table:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',highlight:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',admonition:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',tab:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="6" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M5 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',imageBackground:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1" stroke-dasharray="4,2"/><circle cx="12" cy="12" r="3"/></svg>',imageFrame:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><rect x="5" y="5" width="14" height="14" rx="1"/></svg>',accordion:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="6" rx="1"/><path d="M15 6l-3 3-3-3"/><rect x="3" y="13" width="18" height="6" rx="1"/></svg>',accordionGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="2" width="18" height="5" rx="1"/><rect x="3" y="9" width="18" height="5" rx="1"/><rect x="3" y="16" width="18" height="5" rx="1"/></svg>',multiColumn:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',card:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="3"/><line x1="7" y1="10" x2="17" y2="10"/><line x1="7" y1="14" x2="13" y2="14"/></svg>',cardGroup:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="8" height="8" rx="2"/><rect x="14" y="3" width="8" height="8" rx="2"/><rect x="2" y="13" width="8" height="8" rx="2"/><rect x="14" y="13" width="8" height="8" rx="2"/></svg>',step:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="5" r="3"/><circle cx="12" cy="12" r="3"/><circle cx="12" cy="19" r="3"/><line x1="12" y1="8" x2="12" y2="9"/><line x1="12" y1="15" x2="12" y2="16"/></svg>',tip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18h6M10 22h4M12 2a7 7 0 017 7c0 2.38-1.19 4.47-3 5.74V17H8v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 017-7z"/></svg>',container:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" stroke-dasharray="4,2"/></svg>',copyText:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',tooltip:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="12" rx="2"/><path d="M9 15l3 4 3-4"/></svg>',embedVideo:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="4" width="20" height="16" rx="2"/><polygon points="10,8 16,12 10,16"/></svg>',embedOthers:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><ellipse cx="12" cy="12" rx="4" ry="10"/></svg>',mermaid:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="8" height="6" rx="1"/><rect x="14" y="16" width="8" height="6" rx="1"/><rect x="14" y="2" width="8" height="6" rx="1"/><path d="M10 5h4M6 8v8l12-4"/></svg>',emoji:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>',formula:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><text x="3" y="17" font-size="14" fill="currentColor" stroke="none" font-style="italic">∑x</text></svg>',insert:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>'};function at(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:C.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(n=>({id:`h${n}`,label:`Heading ${n}`,icon:C[`h${n}`],tooltip:`Heading ${n}`,...n<=3?{shortcutLabel:`⌘${n}`}:{},action:({editor:e})=>{const t="#".repeat(n)+" ",r=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+r)}})),action:({editor:n})=>{const e=n.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),r=e.replace(/^#{1,6}\s*/,"");n.replaceCurrentLine("#".repeat(i)+" "+r)}else n.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:n})=>n.replaceCurrentLine("# "+n.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:n})=>n.replaceCurrentLine("## "+n.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:n})=>n.replaceCurrentLine("### "+n.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}]}}function lt(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:C.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:n})=>n.wrapSelection("**","**"),isActive:({selection:n})=>{const{beforeText:e,afterText:t,text:i}=n;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(i)}}],shortcuts:[{key:"Ctrl+b",action:({editor:n})=>n.wrapSelection("**","**"),description:"Bold"}]}}function dt(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:C.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:n})=>n.wrapSelection("*","*"),isActive:({selection:n})=>{const{beforeText:e,afterText:t,text:i}=n;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(i)}}],shortcuts:[{key:"Ctrl+i",action:({editor:n})=>n.wrapSelection("*","*"),description:"Italic"}]}}function ct(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:C.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:n})=>n.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:n})=>n.wrapSelection("~~","~~"),description:"Strikethrough"}]}}function ht(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:C.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:n})=>{const e=n.getCurrentLine();e.startsWith("> ")?n.replaceCurrentLine(e.substring(2)):n.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:n})=>{const e=n.getCurrentLine();n.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}]}}function pt(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:C.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:n,selection:e})=>{e.text?n.replaceSelection(`[${e.text}](url)`):n.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:n,selection:e})=>{e.text?n.replaceSelection(`[${e.text}](url)`):n.insertText("[link text](url)")},description:"Insert Link"}]}}function ut(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:C.image,tooltip:"Insert Image",shortcutLabel:"⌘⇧I",action:({editor:n,selection:e})=>{const t=e.text||"alt text";n.replaceSelection(`![${t}](image-url)`)}}],shortcuts:[{key:"Ctrl+Shift+i",action:({editor:n,selection:e})=>{const t=e.text||"alt text";n.replaceSelection(`![${t}](image-url)`)},description:"Insert Image"}]}}function mt(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:C.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:n})=>n.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:C.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:n,selection:e})=>{n.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:n})=>n.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:n,selection:e})=>{n.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}]}}function gt(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:C.unorderedList,tooltip:"Bullet List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^[-*]\s/)?n.replaceCurrentLine(e.replace(/^[-*]\s/,"")):n.replaceCurrentLine("- "+e)}}]}}function bt(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:C.orderedList,tooltip:"Numbered List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^\d+\.\s/)?n.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):n.replaceCurrentLine("1. "+e)}}]}}function ft(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:C.taskList,tooltip:"Task List",action:({editor:n})=>{const e=n.getCurrentLine();e.match(/^- \[[ x]\]\s/)?n.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):n.replaceCurrentLine("- [ ] "+e)}}]}}function xt(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:C.table,tooltip:"Insert Table",action:({editor:n})=>{n.insertBlock(`| Header 1 | Header 2 | Header 3 |
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(`![${t}](image-url)`)}}],shortcuts:[{key:"Ctrl+Shift+i",action:({editor:n,selection:e})=>{const t=e.text||"alt text";n.replaceSelection(`![${t}](image-url)`)},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 |
762
795
  | -------- | -------- | -------- |
763
796
  | Cell 1 | Cell 2 | Cell 3 |
764
- | Cell 4 | Cell 5 | Cell 6 |`)}}]}}const Lr=[{name:"Yellow",color:"#fef08a",darkColor:"#854d0e",class:"yellow"},{name:"Green",color:"#bbf7d0",darkColor:"#166534",class:"green"},{name:"Blue",color:"#bfdbfe",darkColor:"#1e3a5f",class:"blue"},{name:"Purple",color:"#ddd6fe",darkColor:"#4c1d95",class:"purple"},{name:"Pink",color:"#fbcfe8",darkColor:"#831843",class:"pink"},{name:"Red",color:"#fecaca",darkColor:"#991b1b",class:"red"},{name:"Orange",color:"#fed7aa",darkColor:"#9a3412",class:"orange"},{name:"Cyan",color:"#a5f3fc",darkColor:"#155e75",class:"cyan"}];function yt(){return{name:"highlight",toolbarItems:[{id:"highlight",label:"Highlight",icon:C.highlight,tooltip:"Highlight Text",children:Lr.map(n=>({id:`highlight-${n.class}`,label:n.name,icon:`<span class="smdx-color-dot" style="background:${n.color}"></span>`,tooltip:`${n.name} Highlight`,action:({editor:e})=>{e.wrapSelection(`<Highlight color="${n.class}">`,"</Highlight>")}})),action:({editor:n})=>{n.wrapSelection('<Highlight color="yellow">',"</Highlight>")}}],renderers:[{name:"highlight",pattern:/<Highlight\s+color="([^"]+)">([\s\S]*?)<\/Highlight>/gi,render:n=>{const e=n.match(/<Highlight\s+color="([^"]+)">([\s\S]*?)<\/Highlight>/i);return e?`<mark class="smdx-highlight smdx-highlight-${e[1]}">${e[2]}</mark>`:n}}],styles:`
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:`
765
798
  .smdx-highlight { padding: 2px 4px; border-radius: 3px; }
766
799
  .smdx-highlight-yellow { background-color: #fef08a; }
767
800
  .smdx-highlight-green { background-color: #bbf7d0; }
@@ -780,11 +813,11 @@ $$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<C
780
813
  .smdx-dark .smdx-highlight-orange { background-color: #9a3412; color: #fed7aa; }
781
814
  .smdx-dark .smdx-highlight-cyan { background-color: #155e75; color: #a5f3fc; }
782
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; }
783
- `}}const vt=[{type:"tip",label:"TIP",color:"#10b981",bg:"#ecfdf5",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#10b981"/><path d="M9 12l2 2 4-4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"warning",label:"WARNING",color:"#f59e0b",bg:"#fffbeb",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" fill="#f59e0b"/><path d="M12 9v4M12 17h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"caution",label:"CAUTION",color:"#f97316",bg:"#fff7ed",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#f97316"/><path d="M12 8v4M12 16h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"danger",label:"DANGER",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"check",label:"CHECK",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"info",label:"INFO",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"note",label:"NOTE",color:"#8b5cf6",bg:"#f5f3ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="18" height="18" rx="3" fill="#8b5cf6"/><path d="M8 10h8M8 14h5" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function kt(){return{name:"admonition",toolbarItems:[{id:"admonition",label:"Admonition",icon:C.admonition,tooltip:"Admonition / Callout",children:vt.map(n=>({id:`admonition-${n.type}`,label:n.label,icon:n.icon,tooltip:`${n.label} callout`,action:({editor:e})=>{e.insertBlock(`:::${n.type}
784
- ${n.label}: Your message here
785
- :::`)}})),action:({editor:n})=>{n.insertBlock(`:::info
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
786
819
  INFO: Your message here
787
- :::`)}}],renderers:[{name:"admonition",pattern:/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/g,render:n=>{const e=n.match(/:::(tip|warning|caution|danger|check|info|note)(?:\[([^\]]*)\])?\n([\s\S]*?):::/);if(!e)return n;const t=vt.find(r=>r.type===e[1]),i=e[2]||t.label;return`<div class="smdx-admonition smdx-admonition-${e[1]}"><div class="smdx-admonition-title"><span class="smdx-admonition-icon">${t.icon}</span>${i}</div><div class="smdx-admonition-content">${e[3]}</div></div>`},priority:10}],styles:`
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:`
788
821
  .smdx-admonition { padding: 14px 16px; border-radius: 6px; margin: 12px 0; border-left: 4px solid; }
789
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; }
790
823
  .smdx-admonition-icon { display: flex; align-items: center; flex-shrink: 0; }
@@ -813,23 +846,23 @@ INFO: Your message here
813
846
  .smdx-dark .smdx-admonition-info { background: #172554; }
814
847
  .smdx-dark .smdx-admonition-note { background: #2e1065; }
815
848
  .smdx-dark .smdx-admonition-content { color: var(--smdx-text, #e2e8f0); }
816
- `}}function Br(n){const e=n.split(`
817
- `),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
818
- `).trim():n.trim()}function wt(){return{name:"tab",toolbarItems:[{id:"tab",label:"Tab",icon:C.tab,tooltip:"Insert Tabs",action:({editor:n})=>{n.insertBlock(`<Tabs>
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>
819
852
  <Tab title="Tab 1">
820
853
  Content for tab 1
821
854
  </Tab>
822
855
  <Tab title="Tab 2">
823
856
  Content for tab 2
824
857
  </Tab>
825
- </Tabs>`)}}],renderers:[{name:"tabs",pattern:/<Tabs>([\s\S]*?)<\/Tabs>/gi,render:n=>{const e=/<Tab\s+title="([^"]*)">([\s\S]*?)<\/Tab>/gi;let t=[],i;for(;(i=e.exec(n))!==null;)t.push({title:i[1],content:Br(i[2])});if(t.length===0)return n;let o=`<div class="smdx-tabs" data-tab-id="${"tab-"+Math.random().toString(36).substring(2,8)}"><div class="smdx-tabs-header">`;return t.forEach((s,a)=>{o+=`<button class="smdx-tab-btn${a===0?" smdx-active":""}" data-smdx-tab-btn="true" data-tab-index="${a}">${s.title}</button>`}),o+="</div>",t.forEach((s,a)=>{o+=`<div class="smdx-tab-panel" style="display:${a===0?"block":"none"}">${s.content}</div>`}),o+="</div>",o},priority:15}],styles:`
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:`
826
859
  .smdx-tabs { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
827
860
  .smdx-tabs-header { display: flex; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
828
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; }
829
862
  .smdx-tab-btn:hover { color: var(--smdx-text, #1e293b); }
830
863
  .smdx-tab-btn.smdx-active { color: var(--smdx-primary, #6366f1); border-bottom-color: var(--smdx-primary, #6366f1); background: var(--smdx-bg, #fff); }
831
864
  .smdx-tab-panel { padding: 16px; }
832
- `}}function _t(){return{name:"imageBackground",toolbarItems:[{id:"imageBackground",label:"Image Background",icon:C.imageBackground,tooltip:"Image with Background",action:({editor:n})=>{n.insertBlock(`<ImageBackground src="image-url" alt="description" background="#f0f0f0">
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">
833
866
  Content overlaying the image
834
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]})`}">
835
868
  <div class="smdx-image-bg-overlay">${e[4].trim()}</div>
@@ -837,18 +870,18 @@ INFO: Your message here
837
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); }
838
871
  .smdx-image-bg-overlay { background: rgba(0,0,0,0.5); color: white; padding: 24px; width: 100%; text-align: center; }
839
872
  .smdx-dark .smdx-image-bg-overlay { background: rgba(0,0,0,0.6); }
840
- `}}function Ct(){return{name:"imageFrame",toolbarItems:[{id:"imageFrame",label:"Image Frame",icon:C.imageFrame,tooltip:"Image in Frame",action:({editor:n})=>{n.insertBlock('<ImageFrame src="image-url" alt="description" caption="Image caption" />')}}],renderers:[{name:"imageFrame",pattern:/<ImageFrame\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+caption="([^"]*)")?\s*\/?>/gi,render:n=>{const e=n.match(/<ImageFrame\s+src="([^"]*)"(?:\s+alt="([^"]*)")?(?:\s+caption="([^"]*)")?\s*\/?>/i);return e?`<figure class="smdx-image-frame">
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">
841
874
  <img src="${e[1]}" alt="${e[2]||""}" />
842
875
  ${e[3]?`<figcaption>${e[3]}</figcaption>`:""}
843
876
  </figure>`:n}}],styles:`
844
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); }
845
878
  .smdx-image-frame img { width: 100%; border-radius: 4px; display: block; }
846
879
  .smdx-image-frame figcaption { text-align: center; padding: 8px 0 4px; font-size: 0.85em; color: var(--smdx-text-muted, #64748b); }
847
- `}}function Tt(n){const e=n.split(`
848
- `),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
849
- `).trim():n.trim()}function Et(){return{name:"accordion",toolbarItems:[{id:"accordion",label:"Accordion",icon:C.accordion,tooltip:"Insert Accordion",action:({editor:n})=>{n.insertBlock(`<Accordion title="Accordion Title" defaultOpen>
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>
850
883
  Your content here. You can include any markdown or components.
851
- </Accordion>`)}}],renderers:[{name:"accordion",pattern:/<Accordion\s+title="([^"]*)"([^>]*?)>([\s\S]*?)<\/Accordion>/gi,render:n=>{const e=n.match(/<Accordion\s+title="([^"]*)"([^>]*?)>([\s\S]*?)<\/Accordion>/i);return e?`<details class="smdx-accordion"${/defaultopen/i.test(e[2])?" open":""}><summary class="smdx-accordion-header"><span class="smdx-accordion-arrow"></span><span class="smdx-accordion-title">${e[1]}</span></summary><div class="smdx-accordion-content">${Tt(e[3])}</div></details>`:n},priority:12}],styles:`
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:`
852
885
  .smdx-accordion { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; margin: 8px 0; overflow: hidden; background: var(--smdx-bg, #fff); }
853
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); }
854
887
  .smdx-accordion-header::-webkit-details-marker { display: none; }
@@ -858,7 +891,7 @@ INFO: Your message here
858
891
  .smdx-accordion-content { padding: 14px 18px 18px 18px; border-top: 1px solid var(--smdx-border, #e2e8f0); }
859
892
  .smdx-accordion-content p { margin: 6px 0; }
860
893
  .smdx-accordion-content > :last-child { margin-bottom: 0; }
861
- `}}function St(){return{name:"accordionGroup",dependencies:["accordion"],toolbarItems:[{id:"accordionGroup",label:"Accordion Group",icon:C.accordionGroup,tooltip:"Insert Accordion Group",action:({editor:n})=>{n.insertBlock(`<AccordionGroup>
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>
862
895
  <Accordion title="Section 1" defaultOpen>
863
896
  Content for section 1
864
897
  </Accordion>
@@ -874,8 +907,8 @@ INFO: Your message here
874
907
  .smdx-accordion-group .smdx-accordion { margin: 0; border-radius: 0; border-bottom: none; }
875
908
  .smdx-accordion-group .smdx-accordion:first-of-type { border-radius: 8px 8px 0 0; }
876
909
  .smdx-accordion-group .smdx-accordion:last-of-type { border-radius: 0 0 8px 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
877
- `}}function Mt(){return{name:"multiColumn",toolbarItems:[{id:"multiColumn",label:"Columns",icon:C.multiColumn,tooltip:"Multiple Columns",children:[2,3,4,5].map(n=>({id:`columns-${n}`,label:`${n} Columns`,tooltip:`${n} column layout`,action:({editor:e})=>{const t=Array.from({length:n},(i,r)=>` <Column>
878
- Column ${r+1} content
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
879
912
  </Column>`).join(`
880
913
  `);e.insertBlock(`<Columns count="${n}">
881
914
  ${t}
@@ -886,18 +919,18 @@ ${t}
886
919
  <Column>
887
920
  Column 2 content
888
921
  </Column>
889
- </Columns>`)}}],renderers:[{name:"columns",pattern:/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/gi,render:n=>{const e=n.match(/<Columns\s+count="(\d+)">([\s\S]*?)<\/Columns>/i);if(!e)return n;const t=parseInt(e[1]),i=/<Column>([\s\S]*?)<\/Column>/gi;let r=[],o;for(;(o=i.exec(e[2]))!==null;)r.push(Tt(o[1]));let s=`<div class="smdx-columns" style="grid-template-columns:repeat(${t},1fr)">
890
- `;for(const a of r)s+=`<div class="smdx-column">
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">
891
924
  ${a}
892
925
  </div>
893
- `;return s+="</div>",s},priority:13}],styles:`
926
+ `;return r+="</div>",r},priority:13}],styles:`
894
927
  .smdx-columns { display: grid; gap: 16px; margin: 12px 0; }
895
928
  .smdx-column { padding: 12px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 6px; }
896
- `}}function Ar(n){const e=n.split(`
897
- `),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
898
- `).trim():n.trim()}function $t(){return{name:"card",toolbarItems:[{id:"card",label:"Card",icon:C.card,tooltip:"Insert Card",action:({editor:n})=>{n.insertBlock(`<Card title="Card Title" icon="📄" href="/link">
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">
899
932
  Card description or content goes here.
900
- </Card>`)}}],renderers:[{name:"card",pattern:/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/gi,render:n=>{const e=n.match(/<Card\s+title="([^"]*)"(?:\s+icon="([^"]*)")?(?:\s+href="([^"]*)")?\s*>([\s\S]*?)<\/Card>/i);if(!e)return n;const t=e[3]?"a":"div",i=e[3]?` href="${e[3]}" target="_blank" rel="noopener noreferrer"`:"",r=e[2]?`<span class="smdx-card-icon">${e[2]}</span>`:"",o=e[3]?'<svg class="smdx-card-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>':"";return`<${t} class="smdx-card"${i}><div class="smdx-card-header">${r}<span class="smdx-card-title">${e[1]}</span>${o}</div><div class="smdx-card-content">${Ar(e[4])}</div></${t}>`},priority:11}],styles:`
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:`
901
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); }
902
935
  a.smdx-card { cursor: pointer; }
903
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); }
@@ -907,7 +940,7 @@ ${a}
907
940
  .smdx-card-arrow { margin-left: auto; flex-shrink: 0; color: var(--smdx-text-muted, #94a3b8); transition: transform 0.2s, color 0.2s; }
908
941
  a.smdx-card:hover .smdx-card-arrow { transform: translateX(2px); color: var(--smdx-primary, #6366f1); }
909
942
  .smdx-card-content { font-size: 0.9em; color: var(--smdx-text-muted, #64748b); line-height: 1.5; }
910
- `}}function Lt(){return{name:"cardGroup",dependencies:["card"],toolbarItems:[{id:"cardGroup",label:"Card Group",icon:C.cardGroup,tooltip:"Insert Card Group",action:({editor:n})=>{n.insertBlock(`<CardGroup cols="2">
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">
911
944
  <Card title="Card 1" icon="📄">
912
945
  Description for card 1
913
946
  </Card>
@@ -923,9 +956,9 @@ ${a}
923
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:`
924
957
  .smdx-card-group { display: grid; gap: 12px; margin: 12px 0; }
925
958
  .smdx-card-group .smdx-card { margin: 0; }
926
- `}}function Bt(n){const e=n.split(`
927
- `),t=e.filter(r=>r.trim().length>0),i=t.length>0?Math.min(...t.map(r=>r.match(/^\s*/)[0].length)):0;return i>0?e.map(r=>r.slice(i)).join(`
928
- `).trim():n.trim()}function At(){return{name:"step",toolbarItems:[{id:"steps",label:"Steps",icon:C.step,tooltip:"Insert Steps",action:({editor:n})=>{n.insertBlock(`<Steps>
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>
929
962
  <Step title="First Step">
930
963
  These are instructions or content that only pertain to the first step.
931
964
  </Step>
@@ -935,7 +968,7 @@ ${a}
935
968
  <Step title="Third Step">
936
969
  These are instructions or content that only pertain to the third step.
937
970
  </Step>
938
- </Steps>`)}}],renderers:[{name:"steps",pattern:/<Steps>([\s\S]*?)<\/Steps>/gi,render:n=>{const e=n.match(/<Steps>([\s\S]*?)<\/Steps>/i);if(!e)return n;const t=/<Step\s+title="([^"]*)">([\s\S]*?)<\/Step>/gi;let i=[],r;for(;(r=t.exec(e[1]))!==null;)i.push({title:r[1],content:Bt(r[2])});let o='<div class="smdx-steps">';return i.forEach((s,a)=>{const l=a===i.length-1;o+=`<div class="smdx-step"><div class="smdx-step-indicator"><div class="smdx-step-number">${a+1}</div>${l?"":'<div class="smdx-step-line"></div>'}</div><div class="smdx-step-content"><div class="smdx-step-title">${s.title}</div><div class="smdx-step-body">${s.content}</div></div></div>`}),o+="</div>",o},priority:15}],styles:`
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:`
939
972
  .smdx-steps { margin: 20px 0; }
940
973
  .smdx-step { display: flex; gap: 20px; position: relative; }
941
974
  .smdx-step-indicator { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 34px; position: relative; }
@@ -945,7 +978,7 @@ ${a}
945
978
  .smdx-step:last-child .smdx-step-content { padding-bottom: 0; }
946
979
  .smdx-step-title { font-weight: 700; font-size: 1.05em; color: var(--smdx-text, #1e293b); margin-bottom: 8px; }
947
980
  .smdx-step-body { color: var(--smdx-text-muted, #64748b); font-size: 0.95em; line-height: 1.7; }
948
- `}}const It=[{type:"good",label:"Good",color:"#22c55e",bg:"#f0fdf4",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#22c55e"/><path d="M8 12l3 3 5-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{type:"bad",label:"Bad",color:"#ef4444",bg:"#fef2f2",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#ef4444"/><path d="M15 9l-6 6M9 9l6 6" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'},{type:"info",label:"Info",color:"#3b82f6",bg:"#eff6ff",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" fill="#3b82f6"/><path d="M12 16v-4M12 8h.01" stroke="#fff" stroke-width="2" stroke-linecap="round"/></svg>'}];function Pt(){return{name:"tip",toolbarItems:[{id:"tip",label:"Tip",icon:C.tip,tooltip:"Insert Tip",children:It.map(n=>({id:`tip-${n.type}`,label:n.label,icon:n.icon,tooltip:`${n.label} tip`,action:({editor:e})=>{e.insertBlock(`<Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>Your tip message here</Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>`)}})),action:({editor:n})=>{n.insertBlock("<TipGood>Your tip message here</TipGood>")}}],renderers:It.map(n=>({name:`tip-${n.type}`,pattern:new RegExp(`<Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>([\\s\\S]*?)<\\/Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}>`,"gi"),render:e=>{const t=`Tip${n.type.charAt(0).toUpperCase()+n.type.slice(1)}`,i=new RegExp(`<${t}>([\\s\\S]*?)<\\/${t}>`,"i"),r=e.match(i);return r?`<div class="smdx-tip smdx-tip-${n.type}"><span class="smdx-tip-icon">${n.icon}</span><span class="smdx-tip-text">${r[1].trim()}</span></div>`:e},priority:10})),styles:`
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:`
949
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; }
950
983
  .smdx-tip-icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 1px; }
951
984
  .smdx-tip-icon svg { display: block; }
@@ -956,12 +989,12 @@ ${a}
956
989
  .smdx-dark .smdx-tip-good { background: #052e16; }
957
990
  .smdx-dark .smdx-tip-bad { background: #450a0a; }
958
991
  .smdx-dark .smdx-tip-info { background: #172554; }
959
- `}}function Rt(){return{name:"container",toolbarItems:[{id:"container",label:"Container",icon:C.container,tooltip:"Insert Container",action:({editor:n})=>{n.insertBlock(`<Container>
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>
960
993
  Content inside a styled container.
961
- </Container>`)}}],renderers:[{name:"container",pattern:/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/gi,render:n=>{const e=n.match(/<Container(?:\s+title="([^"]*)")?>([\s\S]*?)<\/Container>/i);return e?`<div class="smdx-container">${e[1]?`<div class="smdx-container-title">${e[1]}</div>`:""}<div class="smdx-container-content">${Bt(e[2])}</div></div>`:n}}],styles:`
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:`
962
995
  .smdx-container { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; padding: 16px; margin: 12px 0; background: var(--smdx-bg-muted, #f8fafc); }
963
996
  .smdx-container-title { font-weight: 600; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
964
- `}}function Ht(){return{name:"copyText",toolbarItems:[{id:"copyText",label:"Copy Text",icon:C.copyText,tooltip:"Copyable Text Block",action:({editor:n})=>{n.insertBlock("<CopyText>Text that users can click to copy</CopyText>")}}],renderers:[{name:"copyText",pattern:/<CopyText>([\s\S]*?)<\/CopyText>/gi,render:n=>{const e=n.match(/<CopyText>([\s\S]*?)<\/CopyText>/i);if(!e)return n;const t=e[1].trim();return`<div class="smdx-copy-text" data-copy-text-div="true" data-text="${t.replace(/"/g,"&quot;")}"><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:`
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,"&quot;")}"><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:`
965
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; }
966
999
  .smdx-copy-text:hover { border-color: var(--smdx-primary, #6366f1); }
967
1000
  .smdx-copy-text.smdx-copied { border-color: #22c55e; background: #f0fdf4; }
@@ -970,7 +1003,7 @@ ${a}
970
1003
  .smdx-copy-text:hover .smdx-copy-text-btn { color: var(--smdx-text, #1e293b); }
971
1004
  .smdx-copy-text.smdx-copied .smdx-copy-text-btn { color: #22c55e; }
972
1005
  .smdx-dark .smdx-copy-text.smdx-copied { background: #052e16; border-color: #166534; }
973
- `}}function Dt(){return{name:"tooltip",toolbarItems:[{id:"tooltip",label:"Tooltip",icon:C.tooltip,tooltip:"Insert Tooltip",action:({editor:n})=>{const t=n.getSelection().text||"hover text";n.replaceSelection(`<Tooltip tip="Tooltip content">${t}</Tooltip>`)}}],renderers:[{name:"tooltip",pattern:/<Tooltip\s+tip="([^"]*)">([\s\S]*?)<\/Tooltip>/gi,render:n=>{const e=n.match(/<Tooltip\s+tip="([^"]*)">([\s\S]*?)<\/Tooltip>/i);return e?`<span class="smdx-tooltip-wrapper"><span class="smdx-tooltip-trigger">${e[2]}<span class="smdx-tooltip-popup">${e[1]}</span></span></span>`:n}}],styles:`
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:`
974
1007
  .smdx-tooltip-wrapper { position: relative; display: inline; }
975
1008
  .smdx-tooltip-trigger { position: relative; border-bottom: 1px dashed var(--smdx-primary, #6366f1); cursor: help; text-decoration: none; }
976
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; }
@@ -978,7 +1011,7 @@ ${a}
978
1011
  .smdx-tooltip-trigger:hover .smdx-tooltip-popup { visibility: visible; opacity: 1; }
979
1012
  .smdx-dark .smdx-tooltip-popup { background: #e2e8f0; color: #1e293b; }
980
1013
  .smdx-dark .smdx-tooltip-popup::after { border-top-color: #e2e8f0; }
981
- `}}function jt(){return{name:"embedVideo",toolbarItems:[{id:"embedVideo",label:"Embed Video",icon:C.embedVideo,tooltip:"Embed Video",children:[{id:"embed-youtube",label:"YouTube",tooltip:"Embed YouTube video",action:({editor:n})=>{n.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}},{id:"embed-video-file",label:"Video File",tooltip:"Embed video file",action:({editor:n})=>{n.insertBlock('<EmbedVideo type="file" src="video.mp4" />')}}],action:({editor:n})=>{n.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}}],renderers:[{name:"embedVideo",pattern:/<EmbedVideo\s+type="([^"]*)"(?:\s+src="([^"]*)")?\s*\/?>/gi,render:n=>{const e=n.match(/<EmbedVideo\s+type="([^"]*)"(?:\s+src="([^"]*)")?\s*\/?>/i);if(!e)return n;const t=e[1],i=e[2]||"";if(t==="youtube"){const r=i.match(/(?:v=|\/embed\/|youtu\.be\/)([\w-]+)/),o=r?r[1]:i;return`<div class="smdx-embed-video">
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">
982
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>
983
1016
  </div>`}return`<div class="smdx-embed-video">
984
1017
  <video controls src="${i}" class="smdx-video-player">
@@ -987,7 +1020,7 @@ ${a}
987
1020
  </div>`}}],styles:`
988
1021
  .smdx-embed-video { position: relative; width: 100%; padding-top: 56.25%; margin: 12px 0; border-radius: 8px; overflow: hidden; background: #000; }
989
1022
  .smdx-embed-video iframe, .smdx-embed-video video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
990
- `}}function Nt(){return{name:"embedOthers",toolbarItems:[{id:"embedOthers",label:"Embed",icon:C.embedOthers,tooltip:"Embed External Content",children:[{id:"embed-github",label:"GitHub Gist",tooltip:"Embed GitHub Gist",action:({editor:n})=>{n.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}},{id:"embed-twitter",label:"Twitter/X Post",tooltip:"Embed Tweet",action:({editor:n})=>{n.insertBlock('<Embed type="twitter" src="https://twitter.com/user/status/TWEET_ID" />')}},{id:"embed-codepen",label:"CodePen",tooltip:"Embed CodePen",action:({editor:n})=>{n.insertBlock('<Embed type="codepen" src="https://codepen.io/user/pen/PEN_ID" />')}},{id:"embed-codesandbox",label:"CodeSandbox",tooltip:"Embed CodeSandbox",action:({editor:n})=>{n.insertBlock('<Embed type="codesandbox" src="https://codesandbox.io/s/SANDBOX_ID" />')}}],action:({editor:n})=>{n.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}}],renderers:[{name:"embedOthers",pattern:/<Embed\s+[^>]*?\/?>/gi,render:n=>{const e=n.match(/type="([^"]*)"/),t=n.match(/src="([^"]*)"/),i=n.match(/label="([^"]*)"/);if(!e)return n;const r=e[1],o=t?t[1]:"",s=i?i[1]:"";switch(r){case"github":return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"GitHub Gist"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`;case"twitter":return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon smdx-embed-twitter-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"Post on X (Twitter)"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`;case"codepen":{const a=o.match(/codepen\.io\/([^/]+)\/pen\/([^/?]+)/);return a?`<div class="smdx-embed smdx-embed-codepen"><iframe height="400" style="width:100%" scrolling="no" src="https://codepen.io/${encodeURIComponent(a[1])}/embed/${encodeURIComponent(a[2])}?default-tab=result" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe></div>`:`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2"/><line x1="12" y1="22" x2="12" y2="15.5"/><polyline points="22 8.5 12 15.5 2 8.5"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"CodePen"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`}case"codesandbox":{const a=o.split("/").pop()||"";return`<div class="smdx-embed smdx-embed-codesandbox"><iframe src="https://codesandbox.io/embed/${encodeURIComponent(a)}" style="width:100%;height:500px;border:0;border-radius:4px;overflow:hidden" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe></div>`}default:return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg></div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${s||"Embedded Content"}</div><div class="smdx-embed-card-url">${o}</div></div><a href="${o}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a></div>`}}}],styles:`
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:`
991
1024
  .smdx-embed { margin: 12px 0; border-radius: 8px; overflow: hidden; }
992
1025
  .smdx-embed iframe { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; }
993
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; }
@@ -1000,7 +1033,7 @@ ${a}
1000
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; }
1001
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; }
1002
1035
  .smdx-embed-card-link:hover { background: var(--smdx-bg-muted, #f8fafc); text-decoration: none; }
1003
- `}}const Ot=[{id:"flowchart",label:"Flowchart",template:`graph TD
1036
+ `,provideTokens:D(["Embed"])}}const qt=[{id:"flowchart",label:"Flowchart",template:`graph TD
1004
1037
  Start --> Stop`},{id:"sequence",label:"Sequence Diagram",template:`sequenceDiagram
1005
1038
  Alice->>John: Hello John, how are you?
1006
1039
  John-->>Alice: Great!
@@ -1050,7 +1083,7 @@ ${a}
1050
1083
  Another task :after a1 , 20d
1051
1084
  section Another
1052
1085
  Task in sec :2014-01-12 , 12d
1053
- another task : 24d`}];function Wt(){return{name:"mermaid",toolbarItems:[{id:"mermaid",label:"Mermaid",icon:C.mermaid,tooltip:"Insert Mermaid Diagram",children:Ot.map(n=>({id:`mermaid-${n.id}`,label:n.label,tooltip:`Insert ${n.label}`,action:({editor:e})=>{e.insertBlock("```mermaid\n"+n.template+"\n```")}})),action:({editor:n})=>{n.insertBlock("```mermaid\n"+Ot[0].template+"\n```")}}],renderers:[{name:"mermaid",pattern:/```mermaid\n([\s\S]*?)```/g,render:n=>{const e=n.match(/```mermaid\n([\s\S]*?)```/);if(!e)return n;const t="mermaid-"+Math.random().toString(36).substring(2,10),i=encodeURIComponent(e[1].trim());return`<div class="smdx-mermaid" data-mermaid-id="${t}" data-mermaid-code="${i}"><div class="smdx-mermaid-placeholder">Loading diagram…</div></div>`},priority:20}],async init(n){const e=async()=>{try{const t=window.mermaid;if(!t)return;const i=n.editor.getRoot().classList.contains("smdx-dark");t.initialize({startOnLoad:!1,theme:i?"dark":"default"});const r=n.editor.getPreview();if(!r)return;const o=r.querySelectorAll(".smdx-mermaid[data-mermaid-code]");for(const s of Array.from(o)){const a=decodeURIComponent(s.getAttribute("data-mermaid-code")),l=s.getAttribute("data-mermaid-id");try{const{svg:d}=await t.render(l,a);s.innerHTML=d,s.removeAttribute("data-mermaid-code")}catch{s.innerHTML=`<pre class="smdx-mermaid-error">${a.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,s.removeAttribute("data-mermaid-code")}}}catch{}};n.on("render",e)},styles:`
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,"&lt;").replace(/>/g,"&gt;")}</pre>`,r.removeAttribute("data-mermaid-code")}}}catch{}};n.on("render",e)},styles:`
1054
1087
  .smdx-mermaid { margin: 12px 0; text-align: center; }
1055
1088
  .smdx-mermaid svg { max-width: 100%; height: auto; }
1056
1089
  .smdx-mermaid-placeholder { padding: 24px; color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
@@ -1101,7 +1134,7 @@ ${a}
1101
1134
  .smdx-dark .smdx-mermaid .section0,
1102
1135
  .smdx-dark .smdx-mermaid .section1 { fill: #374151 !important; }
1103
1136
  .smdx-dark .smdx-mermaid .today { stroke: #818cf8 !important; }
1104
- `}}const Ce=[["😀","grinning smile happy"],["😂","joy laugh cry tears"],["🥰","love hearts smiling"],["😎","cool sunglasses"],["🤔","thinking hmm"],["😢","cry sad tear"],["😡","angry mad rage"],["🥳","party celebrate"],["👍","thumbs up good yes ok"],["👎","thumbs down bad no"],["👋","wave hello hi bye"],["🙏","pray please thanks"],["💪","strong muscle flex"],["🎉","party tada celebrate confetti"],["🔥","fire hot lit"],["⭐","star favorite"],["❤️","heart love red"],["💔","broken heart"],["💯","hundred perfect score"],["✅","check done yes complete"],["❌","cross no wrong cancel"],["⚠️","warning alert caution"],["💡","idea bulb light tip"],["🚀","rocket launch ship fast"],["📝","memo note write edit"],["📌","pin pushpin"],["📎","paperclip clip attach"],["🔗","link chain url"],["📁","folder file directory"],["🗂️","dividers tabs index"],["🔍","search magnifying find look"],["🔧","wrench tool fix settings"],["🎯","target goal dart bullseye"],["🏆","trophy winner cup award"],["🎨","art palette paint color"],["🎵","music note song"],["📊","chart bar graph stats"],["📈","chart up increase growth"],["📉","chart down decrease decline"],["💰","money bag dollar rich"],["🕐","clock time one"],["📅","calendar date schedule"],["🌟","glowing star sparkle shine"],["🌍","earth globe world"],["☀️","sun sunny bright"],["🌙","moon crescent night"],["⚡","lightning bolt zap electric"],["💧","water drop droplet"],["🟢","green circle dot"],["🔴","red circle dot"],["🟡","yellow circle dot"],["🔵","blue circle dot"],["⚪","white circle dot"],["⚫","black circle dot"],["🟣","purple circle dot"],["🟠","orange circle dot"]];function zt(){return{name:"emoji",toolbarItems:[{id:"emoji",label:"Emoji",icon:C.emoji,tooltip:"Insert Emoji",action:n=>{},render:(n,e)=>{n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),Ir(n,e.editor)})}}]}}function Ir(n,e){var d;(d=document.querySelector(".smdx-emoji-picker"))==null||d.remove();const t=document.createElement("div");t.className="smdx-emoji-picker";const i=n.closest(".smdx-editor");i!=null&&i.classList.contains("smdx-dark")&&t.classList.add("smdx-dark");const r=document.createElement("input");r.type="text",r.placeholder="Search emoji...",r.className="smdx-emoji-search",t.appendChild(r);const o=document.createElement("div");o.className="smdx-emoji-grid";const s=h=>{o.innerHTML="";for(const[c]of h){const p=document.createElement("button");p.type="button",p.className="smdx-emoji-btn",p.textContent=c,p.addEventListener("click",()=>{e.insertText(c),t.remove()}),o.appendChild(p)}};s(Ce),r.addEventListener("input",()=>{const h=r.value.toLowerCase().trim();if(!h){s(Ce);return}s(Ce.filter(([,c])=>c.includes(h)))}),t.appendChild(o);const a=n.getBoundingClientRect();t.style.position="fixed",t.style.top=`${a.bottom+4}px`,t.style.left=`${a.left}px`,document.body.appendChild(t);const l=h=>{!t.contains(h.target)&&h.target!==n&&(t.remove(),document.removeEventListener("click",l))};setTimeout(()=>document.addEventListener("click",l),0),r.focus()}function Ft(){return{name:"formula",toolbarItems:[{id:"formula",label:"Formula",icon:C.formula,tooltip:"Insert Formula",children:[{id:"formula-inline",label:"Inline Formula",tooltip:"Inline math: $formula$",action:({editor:n})=>{n.wrapSelection("$","$")}},{id:"formula-block",label:"Block Formula",tooltip:"Block math: $$formula$$",action:({editor:n,selection:e})=>{n.insertBlock(`$$
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(`$$
1105
1138
  `+(e.text||"E = mc^2")+`
1106
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:`
1107
1140
  .smdx-formula-block { text-align: center; margin: 16px 0; font-size: 1.2em; overflow-x: auto; }
@@ -1118,17 +1151,17 @@ $$`)}}],action:({editor:n})=>{n.wrapSelection("$","$")}}],renderers:[{name:"form
1118
1151
  .smdx-dark .smdx-emoji-search, .smdx-emoji-picker.smdx-dark .smdx-emoji-search { background: #2a2a3c; color: #e2e8f0; border-color: #374151; }
1119
1152
  .smdx-dark .smdx-emoji-search:focus, .smdx-emoji-picker.smdx-dark .smdx-emoji-search:focus { border-color: #818cf8; }
1120
1153
  .smdx-dark .smdx-emoji-btn:hover, .smdx-emoji-picker.smdx-dark .smdx-emoji-btn:hover { background: #2a2a3c; }
1121
- `}}function R(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Gt(){const n=new Map;async function e(r){if(n.has(r))return n.get(r);try{let o=await fetch(r+"?raw");if(o.ok||(o=await fetch(r)),!o.ok){const h={content:null,error:`File not found: ${r} (${o.status})`};return n.set(r,h),h}let s=await o.text();const a=s.trimStart();if(a.startsWith("<!DOCTYPE")||a.startsWith("<!doctype")||a.startsWith("<html")){const h={content:null,error:`File not found: ${r}`};return n.set(r,h),h}const l=s.match(/^export default (?:\/\*(?:[^*]|\*(?!\/))*\*\/\s*)?["']([\s\S]*)["']\s*;?\s*$/);l&&(s=l[1].replace(/\\n/g,`
1122
- `).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(h,c)=>String.fromCharCode(parseInt(c,16))));const d={content:s};return n.set(r,d),d}catch{const o={content:null,error:`Failed to load: ${r}`};return n.set(r,o),o}}function t(r,o){const s=o.match(/^(\d+)-(\d+)$/);if(!s)return r;const a=Math.max(1,parseInt(s[1],10)),l=parseInt(s[2],10);return r.split(`
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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(`
1123
1156
  `).slice(a-1,l).join(`
1124
- `)}async function i(r){const o=r.querySelectorAll(".smdx-import[data-src]");for(const a of o){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const l=a.dataset.src,{content:d,error:h}=await e(l);h?(a.innerHTML=`<span class="smdx-import-icon">⚠️</span> <span class="smdx-import-error">${R(h)}</span>`,a.classList.add("smdx-import-failed")):(a.innerHTML=`<div class="smdx-import-header"><span class="smdx-import-icon">📄</span> <code>${R(l)}</code></div><div class="smdx-import-content">${R(d)}</div>`,a.classList.add("smdx-import-loaded"))}const s=r.querySelectorAll(".smdx-snippet[data-src]");for(const a of s){if(a.dataset.loaded==="true")continue;a.dataset.loaded="true";const l=a.dataset.src,d=a.dataset.lines||"",{content:h,error:c}=await e(l);if(c)a.innerHTML=`<span class="smdx-snippet-icon">⚠️</span> <span class="smdx-snippet-error">${R(c)}</span>`,a.classList.add("smdx-snippet-failed");else{const p=d?t(h,d):h,m=l.split(".").pop()||"text",g=d?` <span class="smdx-snippet-lines">(lines ${R(d)})</span>`:"";a.innerHTML=`<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${R(l)}</code>${g}</div><pre class="smdx-snippet-code"><code class="language-${R(m)}">${R(p)}</code></pre>`,a.classList.add("smdx-snippet-loaded")}}}return{name:"insert",init(r){r.on("render",()=>{const o=r.editor.getPreview();o&&i(o)})},toolbarItems:(()=>{const r={id:"insert-hr",label:"Horizontal Rule",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="12" x2="21" y2="12"/></svg>',tooltip:"Insert Horizontal Rule",action:({editor:c})=>{c.insertBlock("---")}},o={id:"insert-layout",label:"Layout",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="18" rx="1"/><rect x="14" y="3" width="7" height="18" rx="1"/></svg>',tooltip:"Insert layout",action:()=>{},children:[{id:"insert-2col",label:"2 Columns",icon:"",tooltip:"Insert 2-column layout",action:({editor:c})=>{c.insertBlock(`<Columns count="2">
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">
1125
1158
  <Column>
1126
1159
  Column 1 content here.
1127
1160
  </Column>
1128
1161
  <Column>
1129
1162
  Column 2 content here.
1130
1163
  </Column>
1131
- </Columns>`)}},{id:"insert-3col",label:"3 Columns",icon:"",tooltip:"Insert 3-column layout",action:({editor:c})=>{c.insertBlock(`<Columns count="3">
1164
+ </Columns>`)}},{id:"insert-3col",label:"3 Columns",icon:"",tooltip:"Insert 3-column layout",action:({editor:h})=>{h.insertBlock(`<Columns count="3">
1132
1165
  <Column>
1133
1166
  Column 1 content here.
1134
1167
  </Column>
@@ -1138,7 +1171,7 @@ Column 2 content here.
1138
1171
  <Column>
1139
1172
  Column 3 content here.
1140
1173
  </Column>
1141
- </Columns>`)}},{id:"insert-4col",label:"4 Columns",icon:"",tooltip:"Insert 4-column layout",action:({editor:c})=>{c.insertBlock(`<Columns count="4">
1174
+ </Columns>`)}},{id:"insert-4col",label:"4 Columns",icon:"",tooltip:"Insert 4-column layout",action:({editor:h})=>{h.insertBlock(`<Columns count="4">
1142
1175
  <Column>
1143
1176
  Column 1 here.
1144
1177
  </Column>
@@ -1151,7 +1184,7 @@ Column 3 here.
1151
1184
  <Column>
1152
1185
  Column 4 here.
1153
1186
  </Column>
1154
- </Columns>`)}}]},s=`<Endpoint method="GET" path="/api/v1/resource">
1187
+ </Columns>`)}}]},r=`<Endpoint method="GET" path="/api/v1/resource">
1155
1188
  Description of the endpoint.
1156
1189
 
1157
1190
  **Parameters:**
@@ -1166,7 +1199,7 @@ Column 4 here.
1166
1199
  "data": {}
1167
1200
  }
1168
1201
  \`\`\`
1169
- </Endpoint>`,a={id:"insert-endpoint",label:"API Endpoint",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"/><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><circle cx="6" cy="6" r="1.5" fill="currentColor" stroke="none"/><circle cx="6" cy="18" r="1.5" fill="currentColor" stroke="none"/></svg>',tooltip:"Insert API endpoint block",shortcutLabel:"⌘⇧E",action:({editor:c})=>{c.insertBlock(s)}},l={id:"insert-markdown",label:"Markdown Import",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="12" y1="18" x2="12" y2="12"/><polyline points="9 15 12 12 15 15"/></svg>',tooltip:"Import external markdown",shortcutLabel:"⌘⇧M",action:({editor:c})=>{c.insertBlock('<Import src="./path/to/file.md" />')}},d={id:"insert-snippet",label:"Code Snippet",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',tooltip:"Insert code snippet reference",shortcutLabel:"⌘⇧S",action:({editor:c})=>{c.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />')}};return[{id:"insert",label:"Insert",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',tooltip:"Insert block elements",action:()=>{},children:[r,o,a,l,d]},r,o,a,l,d]})(),shortcuts:[{key:"Ctrl+Shift+e",action:({editor:r})=>r.insertBlock(`<Endpoint method="GET" path="/api/v1/resource">
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">
1170
1203
  Description of the endpoint.
1171
1204
 
1172
1205
  **Parameters:**
@@ -1181,13 +1214,13 @@ Column 4 here.
1181
1214
  "data": {}
1182
1215
  }
1183
1216
  \`\`\`
1184
- </Endpoint>`),description:"Insert API Endpoint"},{key:"Ctrl+Shift+m",action:({editor:r})=>r.insertBlock('<Import src="./path/to/file.md" />'),description:"Insert Markdown Import"},{key:"Ctrl+Shift+s",action:({editor:r})=>r.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />'),description:"Insert Code Snippet"}],renderers:[{name:"endpoint",pattern:/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/gi,render:r=>{const o=r.match(/<Endpoint\s+method="([^"]*)"(?:\s+path="([^"]*)")?\s*>([\s\S]*?)<\/Endpoint>/i);if(!o)return r;const s=o[1].toUpperCase(),a=o[2]||"";return`<div class="smdx-endpoint">
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">
1185
1218
  <div class="smdx-endpoint-header">
1186
- <span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[s]||"#64748b"}">${s}</span>
1219
+ <span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[r]||"#64748b"}">${r}</span>
1187
1220
  <code class="smdx-endpoint-path">${a}</code>
1188
1221
  </div>
1189
1222
  <div class="smdx-endpoint-body">${o[3].trim()}</div>
1190
- </div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/gi,render:r=>{const o=r.match(/<Import\s+src="([^"]*)"(?:\s*\/)?>/i);if(!o)return r;const s=o[1];return`<div class="smdx-import" data-src="${R(s)}"><span class="smdx-import-icon">📄</span> Loading <code>${R(s)}</code>…</div>`}},{name:"snippet",pattern:/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/gi,render:r=>{const o=r.match(/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/i);if(!o)return r;const s=o[1],a=o[2]||"";return`<div class="smdx-snippet" data-src="${R(s)}"${a?` data-lines="${R(a)}"`:""}><span class="smdx-snippet-icon">📋</span> Loading <code>${R(s)}</code>…</div>`}}],styles:`
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:`
1191
1224
  .smdx-endpoint { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
1192
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); }
1193
1226
  .smdx-endpoint-method { color: white; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.8em; letter-spacing: 0.05em; }
@@ -1206,11 +1239,11 @@ Column 4 here.
1206
1239
  .smdx-import-error, .smdx-snippet-error { color: #b91c1c; }
1207
1240
  .smdx-dark .smdx-import-failed, .smdx-dark .smdx-snippet-failed { background: #450a0a; border-color: #991b1b; }
1208
1241
  .smdx-dark .smdx-import-error, .smdx-dark .smdx-snippet-error { color: #fca5a5; }
1209
- `}}function Vt(){return{name:"toc",toolbarItems:[{id:"toc",label:"Contents",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><polyline points="3 6 4 6"/><polyline points="3 12 4 12"/><polyline points="3 18 4 18"/></svg>',tooltip:"Toggle Table of Contents",action:({editor:n})=>{var e;(e=n.toggleToc)==null||e.call(n)}}],styles:".smdx-toc-container { /* built-in TOC panel — see toc.css */ }"}}function qt(){return{name:"breakLine",toolbarItems:[{id:"breakLine",label:"Line Break",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 7H3"/><path d="M21 17H9"/><path d="M18 13l3 4-3 4"/></svg>',tooltip:"Insert Line Break",action:({editor:n})=>{n.insertText(`<br/>
1210
- `)}}]}}function Ut(){return{name:"horizontalRule",toolbarItems:[{id:"horizontalRule",label:"Horizontal Rule",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="12" x2="21" y2="12"/></svg>',tooltip:"Insert Horizontal Rule",action:({editor:n})=>{n.insertBlock("---")}}]}}function Pr(){return{name:"undo",toolbarItems:[{id:"undo",label:"Undo",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 102.13-9.36L1 10"/></svg>',tooltip:"Undo",shortcutLabel:"⌘Z",action:({editor:n})=>{n.undo()},isDisabled:()=>!1}]}}function Rr(){return{name:"redo",toolbarItems:[{id:"redo",label:"Redo",icon:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>',tooltip:"Redo",shortcutLabel:"⌘⇧Z",action:({editor:n})=>{n.redo()},isDisabled:()=>!1}]}}function Kt(){return[Pr(),Rr(),at(),lt(),dt(),ct(),ht(),pt(),ut(),mt(),gt(),bt(),ft(),xt(),yt(),kt(),wt(),_t(),Ct(),Et(),St(),Mt(),$t(),Lt(),At(),Pt(),Rt(),Ht(),Dt(),jt(),Nt(),Wt(),zt(),Ft(),Gt(),Vt(),qt(),Ut()]}function Yt(){return[["undo","redo","|","heading","|","bold","italic","strikethrough","code","codeBlock","|","unorderedList","orderedList","taskList","|","insert-hr","insert-endpoint","insert-markdown","insert-snippet","|","link","image","table","quote","|","highlight","admonition","|","mermaid","|","steps","tip","container","|","tab","|","card","cardGroup","|","accordion","accordionGroup","multiColumn","|","embedVideo","embedOthers","|","emoji","formula","|","breakLine","horizontalRule","|","copyText","tooltip","|","toc"]]}class Hr{constructor(e){this.editor=e.editor,this.registerToolbarItem=e.registerToolbarItem,this.registerShortcut=e.registerShortcut,this.registerRenderer=e.registerRenderer,this.registerParser=e.registerParser,this.injectStyles=e.injectStyles,this.emit=e.emit,this.on=e.on,this.off=e.off}}function Xt(n){const e=document.createElement("div");e.className="smdx-editor",e.setAttribute("role","application"),e.setAttribute("aria-label","Markdown editor");const t=document.createElement("a");t.className="smdx-skip-link",t.href=`#${n}-textarea`,t.textContent="Skip to editor";const i=document.createElement("div");i.className="smdx-toolbar-container";const r=document.createElement("div");r.className="smdx-main";const o=document.createElement("div");return e.appendChild(t),e.appendChild(i),e.appendChild(r),e.appendChild(o),{root:e,skipLink:t,toolbarSlot:i,main:r,statusBarSlot:o}}function Jt(n){const e=document.createElement("div");e.className="smdx-editor-pane";const t=document.createElement("div");t.className="smdx-scroll-wrapper";const i=document.createElement("div");i.className="smdx-line-gutter",i.setAttribute("aria-hidden","true");const r=document.createElement("textarea");return r.className="smdx-textarea",r.id=`${n}-textarea`,r.setAttribute("aria-label","Markdown input"),r.setAttribute("aria-multiline","true"),r.spellcheck=!1,t.appendChild(i),t.appendChild(r),e.appendChild(t),{pane:e,scrollWrapper:t,gutter:i,textarea:r}}function Zt(n){const e=document.createElement("div");e.className="smdx-preview-pane",e.id=`${n}-preview`;const t=document.createElement("div");return t.className="smdx-preview-content",t.setAttribute("aria-live","polite"),t.setAttribute("aria-label","Rendered preview"),e.appendChild(t),{pane:e,content:t}}function Qt(n={}){const e=document.createElement("div");e.className="smdx-status-bar";const t=document.createElement("span");t.className="smdx-word-count";const i=document.createElement("span");i.className="smdx-line-count";const r=document.createElement("span");r.className="smdx-char-count";const o=document.createElement("div");return o.className="smdx-mode-switch",n.showWordCount!==!1&&e.appendChild(t),n.showLineCount!==!1&&e.appendChild(i),e.appendChild(r),n.showModeSwitcher!==!1&&e.appendChild(o),{bar:e,wordCount:t,lineCount:i,charCount:r,modeSwitcher:o}}class ei{constructor(e,t="split"){this.root=e,this.currentMode=t,this.applyMode(t)}getMode(){return this.currentMode}setMode(e){this.root.classList.remove(`smdx-mode-${this.currentMode}`),this.currentMode=e,this.applyMode(e)}applyMode(e){this.root.classList.add(`smdx-mode-${e}`)}}class ti{constructor(e){this._isDark=!1,this.root=e}applyTheme(e){for(const[t,i]of Object.entries(e))this.root.style.setProperty(t,i)}toggleDarkMode(e){this._isDark=e!==void 0?e:!this._isDark,this.root.classList.toggle("smdx-dark",this._isDark)}isDarkMode(){return this._isDark}}class ii{constructor(e){this.opts=e,this.buildModeSwitcher()}buildModeSwitcher(){const e=["editor","split","preview"],t={editor:"Editor",split:"Split",preview:"Preview"};this.opts.modeSwitcher.innerHTML="";for(const i of e){const r=document.createElement("button");r.className="smdx-mode-btn",r.type="button",r.textContent=t[i],r.dataset.mode=i,r.addEventListener("click",()=>this.opts.onModeChange(i)),this.opts.modeSwitcher.appendChild(r)}}updateCounts(e){const t=e.trim()?e.trim().split(/\s+/).length:0,i=e.split(`
1211
- `).length,r=e.length;this.opts.wordCount.textContent=`${t} words`,this.opts.lineCount.textContent=`${i} lines`,this.opts.charCount.textContent=`${r} chars`}updateActiveMode(e){this.opts.modeSwitcher.querySelectorAll(".smdx-mode-btn").forEach(t=>{t.classList.toggle("smdx-active",t.dataset.mode===e)})}}const j=class j{constructor(e,t){this.scrollEl=null,this.enabled=!1,this.mirror=null,this.rafPending=!1,this.scrollRafId=null,this.offsets=new Float32Array(0),this.heights=new Float32Array(0),this.totalHeight=0,this.lineCount=0,this.lineHeightPx=27.2,this.contentWidth=0,this.avgCharWidth=8.4,this.paddingTop=16,this.cachedClientHeight=0,this.deferredUpdateTimer=null,this.cachedContentWidth=0,this.lastTextareaHeight=0,this.OVERSCAN=8,this.spanPool=[],this.poolStart=-1,this.poolEnd=-1,this.onViewportChange=null,this.onScroll=()=>{const i=this.scrollEl||this.textarea;this.recyclePool(i.scrollTop)},this.gutter=e,this.textarea=t,this.buildInner()}setScrollElement(e){this.scrollEl=e}buildInner(){this.inner=document.createElement("div"),this.inner.className="smdx-gutter-inner",this.inner.setAttribute("aria-hidden","true"),Object.assign(this.inner.style,{position:"relative",pointerEvents:"none"}),this.gutter.appendChild(this.inner)}setupMirror(){this.mirror=document.createElement("div"),this.mirror.setAttribute("aria-hidden","true"),Object.assign(this.mirror.style,{position:"fixed",top:"-9999px",left:"-9999px",visibility:"hidden",pointerEvents:"none",whiteSpace:"pre-wrap",wordWrap:"break-word",overflowWrap:"break-word",overflow:"hidden"}),document.body.appendChild(this.mirror)}destroyMirror(){var e;(e=this.mirror)==null||e.remove(),this.mirror=null}syncMirror(){if(!this.mirror)return null;const e=window.getComputedStyle(this.textarea),t=parseFloat(e.paddingLeft)||0,i=parseFloat(e.paddingRight)||0,r=parseFloat(e.paddingTop)||16,o=this.textarea.clientWidth-t-i;if(o<=0)return null;const s=parseFloat(e.lineHeight)||27.2;this.paddingTop=r,this.contentWidth=o,this.lineHeightPx=s,Object.assign(this.mirror.style,{fontFamily:e.fontFamily,fontSize:e.fontSize,lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,tabSize:e.tabSize||"2",width:o+"px"});try{const l=document.createElement("canvas").getContext("2d");if(l){l.font=`${e.fontSize} ${e.fontFamily}`;const d="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _.,;:()[]{}";this.avgCharWidth=l.measureText(d).width/d.length||8.4}}catch{}return{lineHeightPx:s,contentWidth:o}}rowCount(e,t){return!e||e.length*this.avgCharWidth<this.contentWidth*j.WRAP_THRESHOLD||!this.mirror?1:(this.mirror.textContent=e,Math.max(1,Math.round(this.mirror.scrollHeight/t)))}enable(){var t;this.enabled=!0,(t=this.scrollEl||this.textarea.parentElement)==null||t.classList.add("smdx-has-gutter"),this.gutter.style.display="",this.setupMirror(),this.update(),(this.scrollEl||this.textarea).addEventListener("scroll",this.onScroll)}disable(){var t;this.enabled=!1,(t=this.scrollEl||this.textarea.parentElement)==null||t.classList.remove("smdx-has-gutter"),this.gutter.style.display="none",(this.scrollEl||this.textarea).removeEventListener("scroll",this.onScroll),this.destroyMirror(),this.cancelScrollRaf(),this.deferredUpdateTimer&&(clearTimeout(this.deferredUpdateTimer),this.deferredUpdateTimer=null)}notifyResize(){if(!this.enabled)return;const e=this.scrollEl||this.textarea;this.cachedClientHeight=e.clientHeight;const t=window.getComputedStyle(this.textarea),i=parseFloat(t.paddingLeft)||0,r=parseFloat(t.paddingRight)||0,o=this.textarea.clientWidth-i-r;if(o>0&&Math.abs(o-this.cachedContentWidth)>j.WIDTH_CHANGE_THRESHOLD_PX){this.cachedContentWidth=o,this.update();return}this.poolStart=-1,this.poolEnd=-1,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible()}update(){if(!this.enabled)return;const e=this.textarea.value.split(`
1212
- `),t=e.length;this.lineCount=t;const i=t>j.LARGE_DOC_THRESHOLD,r=this.syncMirror();if(r){this.rafPending=!1;const{lineHeightPx:s}=r;this.cachedContentWidth=this.contentWidth;const a=new Float32Array(t+1),l=new Float32Array(t);let d=0;if(i){const h=this.contentWidth,c=this.avgCharWidth;for(let p=0;p<t;p++){a[p]=d;const g=e[p].length*c,u=(h>0?Math.max(1,Math.ceil(g/h)):1)*s;l[p]=u,d+=u}this.deferredUpdateTimer&&clearTimeout(this.deferredUpdateTimer),this.deferredUpdateTimer=setTimeout(()=>{this.deferredUpdateTimer=null,this.enabled&&this.refineLargeDoc(e,s)},j.DEFERRED_UPDATE_DELAY_MS)}else for(let h=0;h<t;h++){a[h]=d;const p=this.rowCount(e[h],s)*s;l[h]=p,d+=p}a[t]=d,this.offsets=a,this.heights=l,this.totalHeight=d}else{!this.rafPending&&typeof requestAnimationFrame<"u"&&(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.enabled&&this.update()}));const s=this.lineHeightPx,a=new Float32Array(t+1),l=new Float32Array(t).fill(s);for(let d=0;d<=t;d++)a[d]=d*s;this.offsets=a,this.heights=l,this.totalHeight=t*s}this.poolStart=-1,this.poolEnd=-1;for(let s=0;s<this.spanPool.length;s++)this.spanPool[s].style.visibility="hidden";const o=this.scrollEl||this.textarea;this.cachedClientHeight=o.clientHeight,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible()}refineLargeDoc(e,t){const i=e.length,r=this.contentWidth,o=this.avgCharWidth,s=r*j.WRAP_THRESHOLD;let a=!1;const l=new Float32Array(i+1),d=new Float32Array(i);let h=0;for(let c=0;c<i;c++){l[c]=h;const m=e[c].length*o;let g;m>=s&&this.mirror?g=this.rowCount(e[c],t):g=r>0?Math.max(1,Math.ceil(m/r)):1;const f=g*t;Math.abs(f-this.heights[c])>.5&&(a=!0),d[c]=f,h+=f}l[i]=h,a&&(this.offsets=l,this.heights=d,this.totalHeight=h,this.poolStart=-1,this.poolEnd=-1,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible())}autoResizeTextarea(){var a;const e=this.textarea,t=this.scrollEl,i=t?t.clientHeight:((a=e.parentElement)==null?void 0:a.clientHeight)||200,r=parseFloat(e.style.height)||0;if(r>0&&r>=i&&e.scrollHeight<=r+2)return;e.style.height="1px";const o=e.scrollHeight,s=Math.max(o,i);e.style.height=s+"px",this.lastTextareaHeight=s}renderVisible(){const t=(this.scrollEl||this.textarea).scrollTop;this.recyclePool(t)}recyclePool(e){const t=this.cachedClientHeight,i=this.paddingTop,r=Math.max(0,e-i),o=e-i+t,s=Math.max(0,this.lineIndexAtOffset(r)-this.OVERSCAN),a=Math.min(this.lineCount-1,this.lineIndexAtOffset(o)+this.OVERSCAN);if(s===this.poolStart&&a===this.poolEnd)return;this.poolStart=s,this.poolEnd=a;const l=this.lineCount>0?a-s+1:0,d=this.lineHeightPx;for(;this.spanPool.length<l;){const h=document.createElement("span");h.className="smdx-line-num",h.style.position="absolute",h.style.left="0",h.style.right="0",this.inner.appendChild(h),this.spanPool.push(h)}for(let h=0;h<l;h++){const c=s+h,p=this.spanPool[h],g=this.offsets[c]+i+"px";p.style.top!==g&&(p.style.top=g);const f=d+"px";p.style.height!==f&&(p.style.height=f,p.style.lineHeight=f);const u=String(c+1);p.textContent!==u&&(p.textContent=u),p.style.visibility!==""&&(p.style.visibility="")}for(let h=l;h<this.spanPool.length;h++)this.spanPool[h].style.visibility!=="hidden"&&(this.spanPool[h].style.visibility="hidden");this.onViewportChange&&this.onViewportChange(this.getStats())}lineIndexAtOffset(e){const t=this.lineCount;if(t===0||e<=0)return 0;if(e>=this.totalHeight)return t-1;const i=this.offsets;let r=0,o=t-1;for(;r<o;){const s=r+o+1>>1;i[s]<=e?r=s:o=s-1}return r}cancelScrollRaf(){this.scrollRafId!==null&&(cancelAnimationFrame(this.scrollRafId),this.scrollRafId=null)}ensureCursorVisible(){const e=this.scrollEl;if(!e||!this.enabled)return;const t=this.textarea.selectionEnd,r=this.textarea.value.substring(0,t).split(`
1213
- `).length-1,o=this.lineHeightPx,s=this.paddingTop,a=(r<this.lineCount?this.offsets[r]:this.totalHeight)+s,l=a+o,d=e.scrollTop,h=d+e.clientHeight;l>h?e.scrollTop=l-e.clientHeight:a<d&&(e.scrollTop=Math.max(0,a))}getLineOffset(e){return e<0||e>=this.lineCount?0:this.offsets[e]}getStats(){const e=this.poolEnd>=this.poolStart&&this.poolStart>=0?this.poolEnd-this.poolStart+1:0;return{lineCount:this.lineCount,visibleFirst:Math.max(1,this.poolStart+1),visibleLast:Math.max(1,this.poolEnd+1),domNodes:e,totalHeight:this.totalHeight,enabled:this.enabled}}getScrollElement(){return this.scrollEl}destroy(){this.disable()}};j.WRAP_THRESHOLD=.85,j.LARGE_DOC_THRESHOLD=500,j.DEFERRED_UPDATE_DELAY_MS=50,j.WIDTH_CHANGE_THRESHOLD_PX=1;let oe=j;class ri{constructor(e,t=150){this.renderTimer=null,this.contentEl=e,this.delay=t,this.renderer=new Q}setRenderers(e){this.renderer.setRenderers(e)}setParsers(e){this.renderer.setParsers(e)}render(e){this.renderTimer&&clearTimeout(this.renderTimer),this.renderTimer=setTimeout(()=>{this.renderImmediate(e)},this.delay)}async renderImmediate(e){const t=await this.renderer.render(e);this.contentEl.innerHTML=t,this.contentEl.querySelectorAll('[data-copy-text-div="true"]').forEach(i=>{i.addEventListener("click",async()=>{const r=i.getAttribute("data-text")||"";try{await navigator.clipboard.writeText(r),i.classList.add("smdx-copied"),setTimeout(()=>i.classList.remove("smdx-copied"),2e3)}catch{}})}),this.contentEl.querySelectorAll('[data-copy-btn="true"]').forEach(i=>{i.addEventListener("click",async()=>{var o;const r=(o=i.closest(".smdx-code-block"))==null?void 0:o.querySelector("pre code");if(r)try{await navigator.clipboard.writeText(r.textContent||""),i.classList.add("smdx-copied"),setTimeout(()=>i.classList.remove("smdx-copied"),2e3)}catch{}})})}destroy(){this.renderTimer&&clearTimeout(this.renderTimer)}}const K=class K{constructor(e){this.root=e,this.observer=null}start(){typeof ResizeObserver>"u"||(this.observer=new ResizeObserver(e=>{for(const t of e)this.applyBreakpointClasses(t.contentRect.width)}),this.observer.observe(this.root),this.applyBreakpointClasses(this.root.getBoundingClientRect().width))}destroy(){var e;(e=this.observer)==null||e.disconnect(),this.observer=null}applyBreakpointClasses(e){const t=e<=K.MOBILE_BREAKPOINT,i=!t&&e<=K.TABLET_BREAKPOINT;this.root.classList.toggle("smdx-is-mobile",t),this.root.classList.toggle("smdx-is-tablet",i)}};K.MOBILE_BREAKPOINT=640,K.TABLET_BREAKPOINT=1024;let Te=K;class Dr{constructor(e,t){this.config=e,this.events=t,this.editorId=`smdx-${Math.random().toString(36).slice(2,9)}`}build(e,t,i){const{root:r,toolbarSlot:o,main:s,statusBarSlot:a}=Xt(this.editorId),{pane:l,scrollWrapper:d,gutter:h,textarea:c}=Jt(this.editorId),{pane:p,content:m}=Zt(this.editorId),{bar:g,wordCount:f,lineCount:u,charCount:k,modeSwitcher:_}=Qt();s.appendChild(l),s.appendChild(p),a.replaceWith(g),e.appendChild(r),this.elements={root:r,toolbarEl:o,editorPane:l,previewPane:p,textarea:c,previewContent:m,statusBar:g},this.modeController=new ei(r,this.config.mode??"split"),this.themeController=new ti(r),this.lineNumberController=new oe(h,c),this.lineNumberController.setScrollElement(d),this.previewController=new ri(m),this.statusBarController=new ii({bar:g,wordCount:f,lineCount:u,charCount:k,modeSwitcher:_,onModeChange:v=>i.setMode(v)}),this.statusBarController.updateActiveMode(this.config.mode??"split"),this.config.theme&&this.themeController.applyTheme(this.config.theme);const x=this.config.toolbar||[];return x.length>0&&(this.toolbar=new ce(x,t,i,this.events),this.toolbar.render(o)),this.responsiveController=new Te(r),this.responsiveController.start(),this.elements}getMode(){return this.modeController.getMode()}setMode(e){this.modeController.setMode(e),this.statusBarController.updateActiveMode(e)}applyTheme(e){this.themeController.applyTheme(e)}toggleDarkMode(e){this.themeController.toggleDarkMode(e)}isDarkMode(){return this.themeController.isDarkMode()}updateStatusBar(e){this.statusBarController.updateCounts(e)}updateToolbarActiveStates(){var e;(e=this.toolbar)==null||e.updateActiveStates()}enableLineNumbers(){this.lineNumberController.enable()}disableLineNumbers(){this.lineNumberController.disable()}updateLineNumbers(){this.lineNumberController.update()}renderPreview(e){this.previewController.render(e)}renderPreviewImmediate(e){return this.previewController.renderImmediate(e)}getElements(){return this.elements}destroy(){var e,t,i;(e=this.toolbar)==null||e.destroy(),this.previewController.destroy(),this.lineNumberController.destroy(),(t=this.splitterController)==null||t.destroy(),(i=this.responsiveController)==null||i.destroy()}}class jr{constructor(){this.activeDropdown=null,this.documentClickHandler=e=>{this.activeDropdown&&!this.activeDropdown.contains(e.target)&&this.closeAll()},document.addEventListener("click",this.documentClickHandler)}toggle(e,t){var i,r;e.style.display==="none"?(this.closeAll(),e.style.display="",this.activeDropdown=t,(i=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||i.setAttribute("aria-expanded","true")):(e.style.display="none",(r=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||r.setAttribute("aria-expanded","false"),this.activeDropdown=null)}closeAll(){document.querySelectorAll(".smdx-toolbar-dropdown-menu").forEach(e=>{e.style.display="none"}),document.querySelectorAll('[aria-expanded="true"]').forEach(e=>{e.setAttribute("aria-expanded","false")}),this.activeDropdown=null}destroy(){document.removeEventListener("click",this.documentClickHandler)}}const Nr=[{label:"Accordion",kind:"tag",detail:"Expandable section",insertText:`<Accordion title="Title">
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">
1214
1247
  Content
1215
1248
  </Accordion>`},{label:"AccordionGroup",kind:"tag",detail:"Group of accordions",insertText:`<AccordionGroup>
1216
1249
  <Accordion title="Section 1">
@@ -1254,7 +1287,7 @@ Tip message
1254
1287
  Warning message
1255
1288
  </TipBad>`},{label:"TipInfo",kind:"tag",detail:"Info tip callout",insertText:`<TipInfo>
1256
1289
  Info message
1257
- </TipInfo>`},{label:"Tooltip",kind:"tag",detail:"Hover tooltip",insertText:'<Tooltip tip="Tooltip text">hover text</Tooltip>'}],Or=[{label:"# Heading 1",kind:"md",detail:"H1 heading",insertText:"# "},{label:"## Heading 2",kind:"md",detail:"H2 heading",insertText:"## "},{label:"### Heading 3",kind:"md",detail:"H3 heading",insertText:"### "},{label:"#### Heading 4",kind:"md",detail:"H4 heading",insertText:"#### "},{label:"**bold**",kind:"md",detail:"Bold text",insertText:"**bold**"},{label:"*italic*",kind:"md",detail:"Italic text",insertText:"*italic*"},{label:"~~strike~~",kind:"md",detail:"Strikethrough",insertText:"~~text~~"},{label:"`inline code`",kind:"md",detail:"Inline code",insertText:"`code`"},{label:"```code block```",kind:"md",detail:"Code block",insertText:"```\ncode\n```"},{label:"> blockquote",kind:"md",detail:"Blockquote",insertText:"> "},{label:"- list item",kind:"md",detail:"Unordered list",insertText:"- "},{label:"1. ordered item",kind:"md",detail:"Ordered list",insertText:"1. "},{label:"- [ ] task",kind:"md",detail:"Task list item",insertText:"- [ ] "},{label:"[link](url)",kind:"md",detail:"Hyperlink",insertText:"[text](url)"},{label:"![image](url)",kind:"md",detail:"Image",insertText:"![alt](url)"},{label:"---",kind:"md",detail:"Horizontal rule",insertText:`---
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:"![image](url)",kind:"md",detail:"Image",insertText:"![alt](url)"},{label:"---",kind:"md",detail:"Horizontal rule",insertText:`---
1258
1291
  `},{label:"| Table |",kind:"md",detail:"Table",insertText:`| Column 1 | Column 2 |
1259
1292
  |----------|----------|
1260
1293
  | Cell 1 | Cell 2 |`},{label:":::tip",kind:"md",detail:"Tip admonition",insertText:`:::tip
@@ -1269,7 +1302,7 @@ Danger content
1269
1302
  Note content
1270
1303
  :::`},{label:"$formula$",kind:"md",detail:"Inline math",insertText:"$E = mc^2$"},{label:"$$block math$$",kind:"md",detail:"Math block",insertText:`$$
1271
1304
  E = mc^2
1272
- $$`},{label:"```mermaid",kind:"md",detail:"Mermaid diagram",insertText:"```mermaid\ngraph TD\n A --> B\n```"}],Wr=[{label:"<div>",kind:"html",detail:"Division",insertText:`<div>
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>
1273
1306
 
1274
1307
  </div>`},{label:"<span>",kind:"html",detail:"Inline span",insertText:"<span></span>"},{label:"<p>",kind:"html",detail:"Paragraph",insertText:`<p>
1275
1308
 
@@ -1291,9 +1324,9 @@ Content
1291
1324
 
1292
1325
  </blockquote>`},{label:"<section>",kind:"html",detail:"Section",insertText:`<section>
1293
1326
 
1294
- </section>`}],ni=[...Nr,...Or,...Wr],zr=new Set(ni.map(n=>n.label.toLowerCase())),Fr={tag:"⚛",md:"M",html:"<>",var:"·",snippet:"{}"};function oi(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Gr=/[\w</.:#*\-$![\]>(){}~|`@]/,Vr=.6;class qr{constructor(e,t){this.items=[],this.selected=0,this.prefix="",this.startPos=0,this._onAccept=null,this.extraItems=[],this.textarea=e,this.editorRoot=t,this.popup=document.createElement("div"),this.popup.className="smdx-ac-popup",this.popup.style.display="none",this.popup.setAttribute("role","listbox"),this.popup.setAttribute("aria-label","Autocomplete suggestions"),this.popup.addEventListener("mousedown",i=>{i.preventDefault();const r=i.target.closest(".smdx-ac-item");r&&r.dataset.i&&(this.selected=parseInt(r.dataset.i,10),this.accept())}),t.appendChild(this.popup)}registerItems(e){this.extraItems.push(...e)}isVisible(){return this.popup.style.display!=="none"}trigger(){const e=this.textarea.selectionStart,t=this.textarea.value,i=t.lastIndexOf(`
1295
- `,e-1)+1,r=t.substring(i,e);let o=r.length;for(;o>0&&Gr.test(r[o-1]);)o--;const s=r.substring(o);if(s.length<1){this.hide();return}this.prefix=s,this.startPos=i+o;const a=s.startsWith("<")?s.substring(1):s;if(a.length<1){this.hide();return}const l=a.toLowerCase(),d=new Set,c=t.match(/[a-zA-Z_$][\w$]*/g);if(c)for(const f of c)f!==a&&f.length>2&&d.add(f);const p=[...d].filter(f=>f.toLowerCase().startsWith(l)&&!zr.has(f.toLowerCase())).slice(0,8).map(f=>({label:f,kind:"var",detail:"in document"})),g=[...ni,...this.extraItems].filter(f=>f.label.toLowerCase().includes(l)&&f.label.toLowerCase()!==l).concat(p).slice(0,14);if(!g.length){this.hide();return}this.items=g,this.selected=0,this.render(),this.position()}move(e){this.selected=Math.max(0,Math.min(this.items.length-1,this.selected+e)),this.render()}accept(){const e=this.items[this.selected];if(!e)return;const t=this.textarea.value,i=e.insertText||e.label,r=this.textarea.selectionStart;this.textarea.value=t.substring(0,this.startPos)+i+t.substring(r);const o=this.startPos+i.length;this.textarea.selectionStart=this.textarea.selectionEnd=o,this.textarea.focus(),this.hide(),this._onAccept&&this._onAccept()}onAccept(e){this._onAccept=e}handleKeyDown(e){return this.isVisible()?e.key==="ArrowDown"?(e.preventDefault(),this.move(1),!0):e.key==="ArrowUp"?(e.preventDefault(),this.move(-1),!0):e.key==="Tab"||e.key==="Enter"?(e.preventDefault(),this.accept(),!0):e.key==="Escape"?(this.hide(),!0):!1:!1}hide(){this.popup.style.display="none",this.items=[],this.selected=0}render(){this.popup.innerHTML=this.items.map((t,i)=>`<div class="smdx-ac-item${i===this.selected?" smdx-ac-sel":""}" data-i="${i}" role="option" aria-selected="${i===this.selected}"><span class="smdx-ac-badge smdx-ac-${t.kind}">${Fr[t.kind]||"·"}</span><span class="smdx-ac-label">${oi(t.label)}</span><span class="smdx-ac-detail">${oi(t.detail)}</span></div>`).join(""),this.popup.style.display="block";const e=this.popup.querySelector(".smdx-ac-sel");e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}position(){var _;const e=this.editorRoot.getBoundingClientRect(),t=this.textarea.selectionStart,i=this.textarea.value,r=i.lastIndexOf(`
1296
- `,t-1)+1,o=t-r,s=getComputedStyle(this.textarea),a=parseFloat(s.lineHeight)||22,d=(parseFloat(s.fontSize)||14)*Vr,c=i.substring(0,t).split(`
1297
- `).length,p=this.textarea.getBoundingClientRect(),m=((_=this.textarea.parentElement)==null?void 0:_.scrollTop)||0,g=p.left-e.left+o*d+16,f=p.top-e.top+c*a-m+4,u=this.items.length*30+8,k=f+u>e.height-16;this.popup.style.left=Math.min(g,e.width-360)+"px",this.popup.style.top=(k?Math.max(0,f-a-u):f)+"px"}destroy(){this.popup.remove()}}const Ur=1e4;class Kr{constructor(e,t){this.matches=[],this.currentMatch=-1,this.caseSensitive=!1,this.useRegex=!1,this.wholeWord=!1,this.showReplace=!1,this._onInputCallback=null,this.textarea=e,this.editorRoot=t,this.panel=document.createElement("div"),this.panel.className="smdx-find-panel",this.panel.style.display="none",this.panel.setAttribute("role","search"),this.panel.setAttribute("aria-label","Find and Replace");const i=document.createElement("div");i.className="smdx-find-row",this.findInput=document.createElement("input"),this.findInput.type="text",this.findInput.className="smdx-find-input",this.findInput.placeholder="Find…",this.findInput.setAttribute("aria-label","Search"),this.findInput.setAttribute("autocomplete","off"),this.findInput.setAttribute("spellcheck","false"),this.caseSensitiveBtn=this.createToggle("Aa","Case sensitive"),this.wholeWordBtn=this.createToggle("ab","Whole word"),this.regexBtn=this.createToggle(".*","Regex");const r=this.createActionBtn("❮","Previous match"),o=this.createActionBtn("❯","Next match");this.countLabel=document.createElement("span"),this.countLabel.className="smdx-find-count",this.countLabel.textContent="No results";const s=this.createActionBtn("✕","Close");s.classList.add("smdx-find-close"),i.appendChild(this.findInput),i.appendChild(this.caseSensitiveBtn),i.appendChild(this.wholeWordBtn),i.appendChild(this.regexBtn),i.appendChild(r),i.appendChild(o),i.appendChild(this.countLabel),i.appendChild(s),this.replaceRow=document.createElement("div"),this.replaceRow.className="smdx-find-row smdx-replace-row",this.replaceRow.style.display="none",this.replaceInput=document.createElement("input"),this.replaceInput.type="text",this.replaceInput.className="smdx-find-input",this.replaceInput.placeholder="Replace…",this.replaceInput.setAttribute("aria-label","Replace"),this.replaceInput.setAttribute("autocomplete","off"),this.replaceInput.setAttribute("spellcheck","false");const a=this.createActionBtn("Replace","Replace current");a.classList.add("smdx-find-action-text");const l=this.createActionBtn("All","Replace all");l.classList.add("smdx-find-action-text"),this.replaceRow.appendChild(this.replaceInput),this.replaceRow.appendChild(a),this.replaceRow.appendChild(l),this.panel.appendChild(i),this.panel.appendChild(this.replaceRow),t.appendChild(this.panel),this.findInput.addEventListener("input",()=>this.search()),this.findInput.addEventListener("keydown",d=>{d.stopPropagation(),d.key==="Enter"&&(d.shiftKey?this.prev():this.next()),d.key==="Escape"&&this.close()}),this.replaceInput.addEventListener("keydown",d=>{d.stopPropagation(),d.key==="Enter"&&this.replaceCurrent(),d.key==="Escape"&&this.close()}),this.caseSensitiveBtn.addEventListener("click",()=>{this.caseSensitive=!this.caseSensitive,this.caseSensitiveBtn.classList.toggle("smdx-find-toggle-on",this.caseSensitive),this.search()}),this.wholeWordBtn.addEventListener("click",()=>{this.wholeWord=!this.wholeWord,this.wholeWordBtn.classList.toggle("smdx-find-toggle-on",this.wholeWord),this.search()}),this.regexBtn.addEventListener("click",()=>{this.useRegex=!this.useRegex,this.regexBtn.classList.toggle("smdx-find-toggle-on",this.useRegex),this.search()}),r.addEventListener("click",()=>this.prev()),o.addEventListener("click",()=>this.next()),s.addEventListener("click",()=>this.close()),a.addEventListener("click",()=>this.replaceCurrent()),l.addEventListener("click",()=>this.replaceAll())}onInput(e){this._onInputCallback=e}open(e=!1){this.showReplace=e,this.panel.style.display="flex",this.replaceRow.style.display=e?"flex":"none";const t=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd);t&&!t.includes(`
1298
- `)&&(this.findInput.value=t),this.findInput.focus(),this.findInput.select(),this.search()}close(){this.panel.style.display="none",this.matches=[],this.currentMatch=-1,this.textarea.focus()}isOpen(){return this.panel.style.display!=="none"}search(){this.matches=[],this.currentMatch=-1;const e=this.findInput.value;if(!e){this.countLabel.textContent="No results";return}const t=this.textarea.value;let i;try{if(this.useRegex){const s=this.caseSensitive?"g":"gi";i=new RegExp(e,s)}else{let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.wholeWord&&(s=`\\b${s}\\b`);const a=this.caseSensitive?"g":"gi";i=new RegExp(s,a)}}catch{this.countLabel.textContent="Invalid regex";return}let r,o=0;for(;(r=i.exec(t))!==null&&o<Ur;){if(o++,r[0].length===0){i.lastIndex++;continue}this.matches.push({start:r.index,end:r.index+r[0].length})}if(this.matches.length>0){const s=this.textarea.selectionStart;this.currentMatch=this.matches.findIndex(a=>a.start>=s),this.currentMatch===-1&&(this.currentMatch=0),this.highlightCurrent()}this.updateCount()}next(){this.matches.length&&(this.currentMatch=(this.currentMatch+1)%this.matches.length,this.highlightCurrent(),this.updateCount())}prev(){this.matches.length&&(this.currentMatch=(this.currentMatch-1+this.matches.length)%this.matches.length,this.highlightCurrent(),this.updateCount())}highlightCurrent(){if(this.currentMatch<0||this.currentMatch>=this.matches.length)return;const e=this.matches[this.currentMatch];this.textarea.focus(),this.textarea.setSelectionRange(e.start,e.end);const t=this.textarea.parentElement;if(t){const i=this.textarea.value.substring(0,e.start).split(`
1299
- `).length,r=parseFloat(getComputedStyle(this.textarea).lineHeight)||22,o=(i-1)*r-t.clientHeight/3;t.scrollTop=Math.max(0,o)}}updateCount(){this.matches.length===0?this.countLabel.textContent=this.findInput.value?"No results":"":this.countLabel.textContent=`${this.currentMatch+1} of ${this.matches.length}`}replaceCurrent(){if(this.currentMatch<0||!this.matches.length)return;const e=this.matches[this.currentMatch],t=this.textarea.value,i=this.replaceInput.value;this.textarea.value=t.substring(0,e.start)+i+t.substring(e.end),this.textarea.selectionStart=this.textarea.selectionEnd=e.start+i.length,this._onInputCallback&&this._onInputCallback(),this.search()}replaceAll(){if(!this.matches.length)return;const e=this.replaceInput.value,t=this.textarea.value;let i="",r=0;for(const o of this.matches)i+=t.substring(r,o.start)+e,r=o.end;i+=t.substring(r),this.textarea.value=i,this._onInputCallback&&this._onInputCallback(),this.search()}createToggle(e,t){const i=document.createElement("button");return i.type="button",i.className="smdx-find-toggle",i.textContent=e,i.title=t,i.setAttribute("aria-label",t),i}createActionBtn(e,t){const i=document.createElement("button");return i.type="button",i.className="smdx-find-btn",i.textContent=e,i.title=t,i.setAttribute("aria-label",t),i}destroy(){this.panel.remove()}}const Yr="split",Xr="Start writing markdown...",Jr={lineNumbers:!1,wordCount:!0,lineCount:!0,modeSwitcher:!0,statusBar:!0,autoPreview:!0,previewDelay:150,spellcheck:!1,autocomplete:!1,dragAndDrop:!0,pasteImages:!1,keyboardShortcuts:!0,autoSave:!1,autoSaveKey:"smdx-autosave",autofocus:!1,vimMode:!1,history:{maxSize:100,debounce:300}},Zr={splitterPosition:50,minEditorWidth:200,minPreviewWidth:200,resizableSplitter:!0};function Qr(n){return{container:n.container,value:n.value??"",plugins:n.plugins??[],toolbar:n.toolbar,theme:n.theme,mode:n.mode??Yr,placeholder:n.placeholder??Xr,readOnly:n.readOnly??!1,renderers:n.renderers,locale:n.locale,onChange:n.onChange}}function en(n){if(!n.container)throw new Error("[SynclineMDX] Container is required");return Qr(n)}function tn(){const n=document.createElement("div");n.className="smdx-toolbar-container";const e=document.createElement("div");return e.className="smdx-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Editor toolbar"),n.appendChild(e),{container:n,toolbar:e}}function rn(n){const e=document.createElement("a");return e.className="smdx-skip-link",e.href=`#${n}`,e.textContent="Skip to editor",e}function nn(n){return new st({plugins:Kt(),toolbar:Yt(),placeholder:"Start writing markdown...",mode:"split",...n})}b.AutocompleteController=qr,b.CodeRenderer=$e,b.DEFAULT_FEATURES=Jr,b.DEFAULT_LAYOUT=Zr,b.DropdownController=jr,b.EventEmitter=Se,b.FindReplaceController=Kr,b.History=$r,b.LineNumberController=oe,b.ListRenderer=Be,b.MarkdownRenderer=Ae,b.MdxValidator=Ie,b.ModeController=ei,b.PluginContextClass=Hr,b.PluginManager=le,b.PluginManagerNew=le,b.PreviewController=ri,b.Renderer=Q,b.RendererPipeline=Q,b.SplitterController=ee,b.StatusBarController=ii,b.SynclineMDXEditor=st,b.TableRenderer=Le,b.ThemeController=ti,b.Toolbar=ce,b.UIController=Dr,b.accordionGroupPlugin=St,b.accordionPlugin=Et,b.admonitionPlugin=kt,b.allPlugins=Kt,b.boldPlugin=lt,b.breakLinePlugin=qt,b.cardGroupPlugin=Lt,b.cardPlugin=$t,b.codePlugin=mt,b.containerPlugin=Rt,b.copyTextPlugin=Ht,b.createEditor=nn,b.createEditorPane=Jt,b.createEditorRoot=Xt,b.createPreviewPane=Zt,b.createSkipLink=rn,b.createStatusBar=Qt,b.createToolbarDOM=tn,b.defaultToolbar=Yt,b.embedOthersPlugin=Nt,b.embedVideoPlugin=jt,b.emojiPlugin=zt,b.formulaPlugin=Ft,b.headingPlugin=at,b.highlightPlugin=yt,b.horizontalRulePlugin=Ut,b.icons=C,b.imageBackgroundPlugin=_t,b.imageFramePlugin=Ct,b.imagePlugin=ut,b.insertPlugin=Gt,b.italicPlugin=dt,b.linkPlugin=pt,b.mermaidPlugin=Wt,b.multiColumnPlugin=Mt,b.orderedListPlugin=bt,b.quotePlugin=ht,b.resolveConfig=en,b.stepPlugin=At,b.strikethroughPlugin=ct,b.tabPlugin=wt,b.tablePlugin=xt,b.taskListPlugin=ft,b.tipPlugin=Pt,b.tocPlugin=Vt,b.tooltipPlugin=Dt,b.unorderedListPlugin=gt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}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"})});