@synclineapi/mdx-editor 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -36
- package/dist/core/define-component.d.ts +124 -0
- package/dist/core/types.d.ts +285 -4
- package/dist/examples/badge-plugin.ts +14 -16
- package/dist/index.d.ts +2 -1
- package/dist/style.css +1 -1
- package/dist/syncline-mdx-editor.js +1365 -1255
- package/dist/syncline-mdx-editor.umd.cjs +98 -111
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
(function(v,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],ne):(v=typeof globalThis<"u"?globalThis:v||self,ne(v.SynclineMDXEditor={},v.hljs))})(this,function(v,ne){"use strict";class gt{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(n=>{try{n(t)}catch(a){console.error(`[SynclineMDX] Error in event handler for "${e}":`,a)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}class Ke{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 n of e.dependencies)if(!this.plugins.has(n))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${n}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const n of e.toolbarItems)this.toolbarItems.set(n.id,n);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.renderers&&(this.renderers.push(...e.renderers),this.renderers.sort((n,a)=>(a.priority??0)-(n.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((n,a)=>(a.priority??0)-(n.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(n=>n.key===i.key))),t.renderers){const i=new Set(t.renderers.map(n=>n.name));this.renderers=this.renderers.filter(n=>!i.has(n.name))}if(t.parsers){const i=new Set(t.parsers.map(n=>n.name));this.parsers=this.parsers.filter(n=>!i.has(n.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,n)=>(n.priority??0)-(i.priority??0))},registerParser:t=>{this.parsers.push(t),this.parsers.sort((i,n)=>(n.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 zi(){var e;if(typeof navigator>"u")return!1;const s=navigator;return(e=s.userAgentData)!=null&&e.platform?/mac/i.test(s.userAgentData.platform):navigator.platform?/mac/i.test(navigator.platform):/Macintosh|MacIntel|MacPPC|Mac OS X/.test(navigator.userAgent)}function Ye(s){return zi()?s.replace(/ctrl\+/gi,"⌘").replace(/shift\+/gi,"⇧").replace(/alt\+/gi,"⌥"):s.replace(/⌘/g,"Ctrl+").replace(/⇧/g,"Shift+").replace(/⌥/g,"Alt+")}class Xe{constructor(e,t,i,n){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=n,this.activeDropdown=null,this.documentClickHandler=a=>{this.activeDropdown&&!this.activeDropdown.contains(a.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 n=this.createButton(i);t.appendChild(n)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const n of e.items)typeof n=="string"?this.renderItem(n,i):this.renderGroup(n,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const n=document.createElement("button");n.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",n.type="button",n.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>`,n.title=e.label||"",n.setAttribute("aria-label",e.label||"Dropdown"),n.setAttribute("aria-haspopup","true"),n.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 r of e.items)if(typeof r=="string"){const o=this.pluginManager.getToolbarItem(r);if(!o)continue;if(o.children&&o.children.length>0)this.renderSubmenu(o,a);else{const c=this.createMenuButton(o);a.appendChild(c)}}else{const o=document.createElement("div");if(o.className="smdx-toolbar-dropdown-section",r.label){const c=document.createElement("div");c.className="smdx-toolbar-dropdown-section-label",c.textContent=r.label,o.appendChild(c)}for(const c of r.items)if(typeof c=="string"){const d=this.pluginManager.getToolbarItem(c);if(d)if(d.children&&d.children.length>0)this.renderSubmenu(d,o);else{const l=this.createMenuButton(d);o.appendChild(l)}}a.appendChild(o)}n.addEventListener("click",r=>{r.stopPropagation(),this.toggleDropdown(a,i)}),i.appendChild(n),i.appendChild(a),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const n=document.createElement("button");n.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",n.type="button",n.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 a=e.tooltip||e.label,r=e.shortcutLabel?Ye(e.shortcutLabel):void 0;n.title=r?`${a} (${r})`:a,n.setAttribute("aria-label",r?`${a} (${r})`:a),n.setAttribute("aria-haspopup","true"),n.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 c of e.children)if(c.children&&c.children.length>0)this.renderSubmenu(c,o);else{const d=this.createMenuButton(c);o.appendChild(d)}n.addEventListener("click",c=>{c.stopPropagation(),this.toggleDropdown(o,i)}),i.appendChild(n),i.appendChild(o),t.appendChild(i)}positionMenu(e,t){const i=t.getBoundingClientRect(),n=4;let a=i.bottom+n,r=i.left;e.style.top=a+"px",e.style.left=r+"px",e.style.visibility="hidden",e.style.display="",requestAnimationFrame(()=>{const o=e.getBoundingClientRect();o.right>window.innerWidth-4&&(r=i.right-o.width,e.style.left=Math.max(4,r)+"px"),o.bottom>window.innerHeight-4&&(a=i.top-o.height-n,e.style.top=Math.max(4,a)+"px"),e.style.visibility=""})}renderSubmenu(e,t){const i=document.createElement("div");i.className="smdx-toolbar-submenu";const n=document.createElement("button");n.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",n.type="button",n.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 a=document.createElement("div");a.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",a.style.display="none";for(const l of e.children)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const h=this.createMenuButton(l);a.appendChild(h)}const r=()=>{const l=i.getBoundingClientRect();a.style.left=`${l.right}px`,a.style.top=`${l.top}px`,requestAnimationFrame(()=>{const h=a.getBoundingClientRect();h.right>window.innerWidth&&(a.style.left=`${l.left-h.width}px`),h.bottom>window.innerHeight&&(a.style.top=`${window.innerHeight-h.height-8}px`)})};let o=null;const c=()=>{o&&(clearTimeout(o),o=null),a.style.display="",r()},d=()=>{o&&clearTimeout(o),o=setTimeout(()=>{a.style.display="none",o=null},120)};n.addEventListener("mouseenter",c),a.addEventListener("mouseenter",c),i.addEventListener("mouseleave",d),a.addEventListener("mouseleave",d),i.appendChild(n),i.appendChild(a),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,n=e.shortcutLabel?Ye(e.shortcutLabel):void 0;return t.title=n?`${i} (${n})`:i,t.setAttribute("aria-label",n?`${i} (${n})`:i),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,n&&t.setAttribute("data-shortcut",n),t.addEventListener("click",a=>{a.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,n;if(e.style.display==="none"){this.closeDropdowns();const a=t.querySelector(".smdx-toolbar-dropdown-trigger");a?this.positionMenu(e,a):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="",(n=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||n.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 n=i.dataset.toolbarId,a=this.pluginManager.getToolbarItem(n);a!=null&&a.isActive&&i.classList.toggle("smdx-active",a.isActive(e)),a!=null&&a.isDisabled&&(i.disabled=a.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const Ui=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),qi=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function Gi(s){return qi.some(e=>s.startsWith(e))}const mt=/^on/i,Vi=/^\s*javascript\s*:/i;function Ki(s){if(typeof document>"u")return s;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${s}</body>`,"text/html"),i=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),n=[];let a=i.currentNode;for(;a;){if(a.nodeType===Node.ELEMENT_NODE){const r=a,o=r.tagName.toLowerCase();if(Ui.has(o))n.push(r);else if(o==="iframe"){const c=r.getAttribute("src")||"";if(!Gi(c))n.push(r);else{const d=[];for(const l of Array.from(r.attributes))mt.test(l.name)&&d.push(l.name);for(const l of d)r.removeAttribute(l)}}else{const c=[];for(const d of Array.from(r.attributes))(mt.test(d.name)||(d.name==="href"||d.name==="src"||d.name==="action")&&Vi.test(d.value))&&c.push(d.name);for(const d of c)r.removeAttribute(d)}}a=i.nextNode()}for(const r of n)r.remove();return t.body.innerHTML}const Yi={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 bt{escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}renderBlock(e,t,i){let n;const a=i.trimEnd();try{e&&ne.getLanguage(e)?n=ne.highlight(a,{language:e}).value:n=ne.highlightAuto(a).value}catch{n=this.escapeHtml(a)}const r=e?Yi[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1):"",o=r?`<span class="smdx-code-lang">${r}</span>`:"",c=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>',l=!!(r||t),h=l?`<div class="smdx-code-header">${o}${c}${d}</div>`:"";return`<div class="smdx-code-block${l?" smdx-has-header":""}">${h}<pre><code class="hljs language-${e||"text"}">${n}</code></pre>${l?"":d}</div>`}}class ft{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,n,a,r)=>{const o=this.parseTableRow(n),c=r.trim().split(`
|
|
2
|
-
`).filter(Boolean).map(l=>this.parseTableRow(l));let d='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const l of o)d+=`<th>${l}</th>`;d+="</tr></thead><tbody>";for(const l of c){d+="<tr>";for(const h of l)d+=`<td>${h}</td>`;d+="</tr>"}return d+="</tbody></table></div>",d})}}class
|
|
3
|
-
`),i=[];let n=0;for(;n<t.length;)if(this.isListItem(t[n])){const a=[];for(;n<t.length
|
|
4
|
-
`)}}class
|
|
5
|
-
`)
|
|
1
|
+
(function(v,ne){typeof exports=="object"&&typeof module<"u"?ne(exports,require("highlight.js")):typeof define=="function"&&define.amd?define(["exports","highlight.js"],ne):(v=typeof globalThis<"u"?globalThis:v||self,ne(v.SynclineMDXEditor={},v.hljs))})(this,function(v,ne){"use strict";class xt{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(n=>{try{n(t)}catch(a){console.error(`[SynclineMDX] Error in event handler for "${e}":`,a)}})}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}}function ae(s){const e=s.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 n=!1;const a=(r,o,c)=>{i.lastIndex=0;for(const d of r.matchAll(i))d[1]!==void 0?c.push({cls:"fn",start:o+d.index,end:o+d.index+d[1].length}):d[2]!==void 0?c.push({cls:"fn",start:o+d.index,end:o+d.index+d[2].length}):d[3]!==void 0&&c.push({cls:"str",start:o+d.index,end:o+d.index+d[3].length})};return r=>{const o=[];if(n){const c=r.indexOf(">"),d=c===-1?r.length:c;return a(r.slice(0,d),0,o),c!==-1&&(n=!1),o}t.lastIndex=0;for(const c of r.matchAll(t))if(c[1]){const d=c.index+2;o.push({cls:"cls",start:d,end:d+c[2].length})}else{const d=c.index+1;o.push({cls:"cls",start:d,end:d+c[2].length});const l=d+c[2].length,h=r.indexOf(">",l),p=h===-1?r.length:h;if(a(r.slice(l,p),l,o),h===-1){n=!0;break}}return o}}function Ki(s,e){const t=[],i=s.match(/^(#{1,6}) /);if(i)return t.push({cls:"kw",start:0,end:i[1].length}),t;const n=s.match(/^(`{3,}|~{3,})([\w-]*)/);if(n)return t.push({cls:"kw",start:0,end:n[1].length}),n[2]&&t.push({cls:"typ",start:n[1].length,end:n[1].length+n[2].length}),t;if(/^(\s*)(---+|\*\*\*+|___+)\s*$/.test(s))return t.push({cls:"kw",start:0,end:s.length}),t;const a=s.match(/^(\s*>+\s?)/);a&&t.push({cls:"kw",start:0,end:a[1].length});const r=s.match(/^(\s*)([-*+]) (\[[ x]\] )?/);if(r){const l=r[1].length;if(t.push({cls:"op",start:l,end:l+1}),r[3]){const h=l+2;t.push({cls:"kw",start:h,end:h+r[3].trimEnd().length})}}const o=s.match(/^(\s*)(\d+\.) /);if(o){const l=o[1].length;t.push({cls:"op",start:l,end:l+o[2].length})}const c=s.match(/^(import|export)(\s)/);if(c&&t.push({cls:"kw",start:0,end:c[1].length}),/^\s*\|/.test(s)){for(const l of s.matchAll(/\|/g))t.push({cls:"op",start:l.index,end:l.index+1});return t}const d=new Set;for(const l of s.matchAll(/`([^`]+)`/g)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"str",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(new RegExp("(\\*\\*|__)(?!\\s)(.+?)(?<!\\s)\\1","g")))if(!d.has(l.index)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"num",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(new RegExp("(?<!\\*)\\*(?!\\*)(?!\\s)(.+?)(?<!\\s)\\*(?!\\*)|(?<!_)_(?!_)(?!\\s)(.+?)(?<!\\s)_(?!_)","g")))if(!d.has(l.index)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"fn",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(/~~(.+?)~~/g))if(!d.has(l.index)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"cmt",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(/!\[([^\]]*)\]\(([^)]*)\)/g)){if(d.has(l.index))continue;const h=l.index+2+l[1].length+1;t.push({cls:"fn",start:l.index,end:h}),t.push({cls:"str",start:h,end:l.index+l[0].length});for(let p=l.index;p<l.index+l[0].length;p++)d.add(p)}for(const l of s.matchAll(/\[([^\]]+)\]\(([^)]*)\)/g)){if(d.has(l.index))continue;const h=l.index+1+l[1].length+1;t.push({cls:"fn",start:l.index,end:h}),t.push({cls:"str",start:h,end:l.index+l[0].length});for(let p=l.index;p<l.index+l[0].length;p++)d.add(p)}return t}function kt(s,e){return(t,i)=>{const n=[];for(const a of s){const r=a(t,i);r.length&&n.push(...r)}for(const a of e){const r=a(t,i);r.length&&n.push(...r)}return n}}class Je{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 n of e.dependencies)if(!this.plugins.has(n))throw new Error(`[SynclineMDX] Plugin "${e.name}" requires "${n}" which is not registered.`)}if(this.plugins.set(e.name,e),e.toolbarItems)for(const n of e.toolbarItems)this.toolbarItems.set(n.id,n);e.shortcuts&&this.shortcuts.push(...e.shortcuts),e.patterns&&(this.renderers.push(...e.patterns),this.renderers.sort((n,a)=>(a.priority??0)-(n.priority??0))),e.components&&(this.renderers.push(...e.components),this.renderers.sort((n,a)=>(a.priority??0)-(n.priority??0))),e.parsers&&(this.parsers.push(...e.parsers),this.parsers.sort((n,a)=>(a.priority??0)-(n.priority??0)));const t=e.completions?[...e.completions]:[];this.completionsByPlugin.set(e.name,t);const i=e.provideTokens?[e.provideTokens]:[];if(e.patterns)for(const n of e.patterns)n.provideTokens&&i.push(n.provideTokens);if(e.components)for(const n of e.components)n.tag&&(i.push(ae([n.tag])),t.push({label:n.label??n.tag,kind:"cls",detail:n.description??`<${n.tag}> component`})),n.completions&&t.push(...n.completions);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(n=>n.key===i.key))),t.patterns){const i=new Set(t.patterns.map(n=>n.name));this.renderers=this.renderers.filter(n=>!i.has(n.name))}if(t.components){const i=new Set(t.components.map(n=>n.name));this.renderers=this.renderers.filter(n=>!i.has(n.name))}if(t.parsers){const i=new Set(t.parsers.map(n=>n.name));this.parsers=this.parsers.filter(n=>!i.has(n.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,n)=>(n.priority??0)-(i.priority??0))},registerParser:t=>{this.parsers.push(t),this.parsers.sort((i,n)=>(n.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 Yi(){var e;if(typeof navigator>"u")return!1;const s=navigator;return(e=s.userAgentData)!=null&&e.platform?/mac/i.test(s.userAgentData.platform):navigator.platform?/mac/i.test(navigator.platform):/Macintosh|MacIntel|MacPPC|Mac OS X/.test(navigator.userAgent)}function Ze(s){return Yi()?s.replace(/ctrl\+/gi,"⌘").replace(/shift\+/gi,"⇧").replace(/alt\+/gi,"⌥"):s.replace(/⌘/g,"Ctrl+").replace(/⇧/g,"Shift+").replace(/⌥/g,"Alt+")}class Qe{constructor(e,t,i,n){this.config=e,this.pluginManager=t,this.editorApi=i,this.events=n,this.activeDropdown=null,this.documentClickHandler=a=>{this.activeDropdown&&!this.activeDropdown.contains(a.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 n=this.createButton(i);t.appendChild(n)}}renderGroup(e,t){if(e.display==="dropdown")this.renderDropdownGroup(e,t);else{const i=document.createElement("div");i.className="smdx-toolbar-group";for(const n of e.items)typeof n=="string"?this.renderItem(n,i):this.renderGroup(n,i);t.appendChild(i)}}renderDropdownGroup(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const n=document.createElement("button");n.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",n.type="button",n.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>`,n.title=e.label||"",n.setAttribute("aria-label",e.label||"Dropdown"),n.setAttribute("aria-haspopup","true"),n.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 r of e.items)if(typeof r=="string"){const o=this.pluginManager.getToolbarItem(r);if(!o)continue;if(o.children&&o.children.length>0)this.renderSubmenu(o,a);else{const c=this.createMenuButton(o);a.appendChild(c)}}else{const o=document.createElement("div");if(o.className="smdx-toolbar-dropdown-section",r.label){const c=document.createElement("div");c.className="smdx-toolbar-dropdown-section-label",c.textContent=r.label,o.appendChild(c)}for(const c of r.items)if(typeof c=="string"){const d=this.pluginManager.getToolbarItem(c);if(d)if(d.children&&d.children.length>0)this.renderSubmenu(d,o);else{const l=this.createMenuButton(d);o.appendChild(l)}}a.appendChild(o)}n.addEventListener("click",r=>{r.stopPropagation(),this.toggleDropdown(a,i)}),i.appendChild(n),i.appendChild(a),t.appendChild(i)}renderDropdownItem(e,t){const i=document.createElement("div");i.className="smdx-toolbar-dropdown";const n=document.createElement("button");n.className="smdx-toolbar-btn smdx-toolbar-dropdown-trigger",n.type="button",n.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 a=e.tooltip||e.label,r=e.shortcutLabel?Ze(e.shortcutLabel):void 0;n.title=r?`${a} (${r})`:a,n.setAttribute("aria-label",r?`${a} (${r})`:a),n.setAttribute("aria-haspopup","true"),n.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 c of e.children)if(c.children&&c.children.length>0)this.renderSubmenu(c,o);else{const d=this.createMenuButton(c);o.appendChild(d)}n.addEventListener("click",c=>{c.stopPropagation(),this.toggleDropdown(o,i)}),i.appendChild(n),i.appendChild(o),t.appendChild(i)}positionMenu(e,t){const i=t.getBoundingClientRect(),n=4;let a=i.bottom+n,r=i.left;e.style.top=a+"px",e.style.left=r+"px",e.style.visibility="hidden",e.style.display="",requestAnimationFrame(()=>{const o=e.getBoundingClientRect();o.right>window.innerWidth-4&&(r=i.right-o.width,e.style.left=Math.max(4,r)+"px"),o.bottom>window.innerHeight-4&&(a=i.top-o.height-n,e.style.top=Math.max(4,a)+"px"),e.style.visibility=""})}renderSubmenu(e,t){const i=document.createElement("div");i.className="smdx-toolbar-submenu";const n=document.createElement("button");n.className="smdx-toolbar-menu-btn smdx-toolbar-submenu-trigger",n.type="button",n.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 a=document.createElement("div");a.className="smdx-toolbar-dropdown-menu smdx-toolbar-submenu-menu",a.style.display="none";for(const l of e.children)if(l.children&&l.children.length>0)this.renderSubmenu(l,a);else{const h=this.createMenuButton(l);a.appendChild(h)}const r=()=>{const l=i.getBoundingClientRect();a.style.left=`${l.right}px`,a.style.top=`${l.top}px`,requestAnimationFrame(()=>{const h=a.getBoundingClientRect();h.right>window.innerWidth&&(a.style.left=`${l.left-h.width}px`),h.bottom>window.innerHeight&&(a.style.top=`${window.innerHeight-h.height-8}px`)})};let o=null;const c=()=>{o&&(clearTimeout(o),o=null),a.style.display="",r()},d=()=>{o&&clearTimeout(o),o=setTimeout(()=>{a.style.display="none",o=null},120)};n.addEventListener("mouseenter",c),a.addEventListener("mouseenter",c),i.addEventListener("mouseleave",d),a.addEventListener("mouseleave",d),i.appendChild(n),i.appendChild(a),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,n=e.shortcutLabel?Ze(e.shortcutLabel):void 0;return t.title=n?`${i} (${n})`:i,t.setAttribute("aria-label",n?`${i} (${n})`:i),t.dataset.toolbarId=e.id,e.icon?t.innerHTML=e.icon:t.textContent=e.label,n&&t.setAttribute("data-shortcut",n),t.addEventListener("click",a=>{a.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">${Ze(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,n;if(e.style.display==="none"){this.closeDropdowns();const a=t.querySelector(".smdx-toolbar-dropdown-trigger");a?this.positionMenu(e,a):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="",(n=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||n.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 n=i.dataset.toolbarId,a=this.pluginManager.getToolbarItem(n);a!=null&&a.isActive&&i.classList.toggle("smdx-active",a.isActive(e)),a!=null&&a.isDisabled&&(i.disabled=a.isDisabled(e))})}destroy(){var e;document.removeEventListener("click",this.documentClickHandler),(e=this.el)==null||e.remove()}}const Xi=new Set(["script","style","object","embed","base","form","input","link","meta","noscript","applet","frame","frameset"]),Ji=["https://www.youtube.com/embed/","https://youtube.com/embed/","https://codepen.io/","https://codesandbox.io/embed/"];function Zi(s){return Ji.some(e=>s.startsWith(e))}const wt=/^on/i,Qi=/^\s*javascript\s*:/i;function en(s){if(typeof document>"u")return s;const t=new DOMParser().parseFromString(`<!DOCTYPE html><body>${s}</body>`,"text/html"),i=document.createTreeWalker(t.body,NodeFilter.SHOW_ELEMENT),n=[];let a=i.currentNode;for(;a;){if(a.nodeType===Node.ELEMENT_NODE){const r=a,o=r.tagName.toLowerCase();if(Xi.has(o))n.push(r);else if(o==="iframe"){const c=r.getAttribute("src")||"";if(!Zi(c))n.push(r);else{const d=[];for(const l of Array.from(r.attributes))wt.test(l.name)&&d.push(l.name);for(const l of d)r.removeAttribute(l)}}else{const c=[];for(const d of Array.from(r.attributes))(wt.test(d.name)||(d.name==="href"||d.name==="src"||d.name==="action")&&Qi.test(d.value))&&c.push(d.name);for(const d of c)r.removeAttribute(d)}}a=i.nextNode()}for(const r of n)r.remove();return t.body.innerHTML}const tn={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 _t{escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}renderBlock(e,t,i){let n;const a=i.trimEnd();try{e&&ne.getLanguage(e)?n=ne.highlight(a,{language:e}).value:n=ne.highlightAuto(a).value}catch{n=this.escapeHtml(a)}const r=e?tn[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1):"",o=r?`<span class="smdx-code-lang">${r}</span>`:"",c=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>',l=!!(r||t),h=l?`<div class="smdx-code-header">${o}${c}${d}</div>`:"";return`<div class="smdx-code-block${l?" smdx-has-header":""}">${h}<pre><code class="hljs language-${e||"text"}">${n}</code></pre>${l?"":d}</div>`}}class vt{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,n,a,r)=>{const o=this.parseTableRow(n),c=r.trim().split(`
|
|
2
|
+
`).filter(Boolean).map(l=>this.parseTableRow(l));let d='<div class="smdx-table-wrapper"><table class="smdx-table"><thead><tr>';for(const l of o)d+=`<th>${l}</th>`;d+="</tr></thead><tbody>";for(const l of c){d+="<tr>";for(const h of l)d+=`<td>${h}</td>`;d+="</tr>"}return d+="</tbody></table></div>",d})}}class Ct{isListItem(e){return/^\s*[-*]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)}buildNestedList(e){var c,d,l;if(e.length===0)return"";const t=((c=e[0].match(/^(\s*)/))==null?void 0:c[1].length)??0,i=/^\s*\d+\.\s+/.test(e[0]),n=i?"ol":"ul",a=i?"smdx-ol-item":"smdx-ul-item";let r=`<${n}>`,o=0;for(;o<e.length;){const h=e[o],p=((d=h.match(/^(\s*)/))==null?void 0:d[1].length)??0;if(p<t)break;if(p>t){o++;continue}const u=i?h.replace(/^\s*\d+\.\s+/,""):h.replace(/^\s*[-*]\s+/,"");o++;const m=[];for(;o<e.length&&((((l=e[o].match(/^(\s*)/))==null?void 0:l[1].length)??0)>t&&this.isListItem(e[o]));)m.push(e[o]),o++;const g=m.length>0?this.buildNestedList(m):"";r+=`<li class="${a}">${u}${g}</li>`}return r+=`</${n}>`,r}render(e){var a,r;const t=e.split(`
|
|
3
|
+
`),i=[];let n=0;for(;n<t.length;)if(this.isListItem(t[n])){const o=[],c=((a=t[n].match(/^(\s*)/))==null?void 0:a[1].length)??0;for(;n<t.length;)if(this.isListItem(t[n]))o.push(t[n]),n++;else if(t[n].trim()===""){let d=n+1;for(;d<t.length&&t[d].trim()==="";)d++;if(d<t.length&&this.isListItem(t[d])&&(((r=t[d].match(/^(\s*)/))==null?void 0:r[1].length)??0)>c){n=d;continue}break}else break;i.push(this.buildNestedList(o))}else i.push(t[n]),n++;return i.join(`
|
|
4
|
+
`)}}class Tt{constructor(){this.codeRenderer=new _t,this.tableRenderer=new vt,this.listRenderer=new Ct}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}render(e){let t=e;const i=[];t=t.replace(/```(\w*)(?:[\t ]+([\w.\/ \-]+?))?\n([\s\S]*?)```/g,(a,r,o,c)=>{const d=i.length;return i.push(this.codeRenderer.renderBlock(r,o,c)),`%%CODEBLOCK_${d}%%`}),t=t.replace(/`([^`]+)`/g,(a,r)=>`<code class="smdx-inline-code">${this.escapeHtml(r)}</code>`);const n=a=>a.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-|-$/g,"");t=t.replace(/^######\s+(.+)$/gm,(a,r)=>`<h6 id="${n(r)}">${r}</h6>`),t=t.replace(/^#####\s+(.+)$/gm,(a,r)=>`<h5 id="${n(r)}">${r}</h5>`),t=t.replace(/^####\s+(.+)$/gm,(a,r)=>`<h4 id="${n(r)}">${r}</h4>`),t=t.replace(/^###\s+(.+)$/gm,(a,r)=>`<h3 id="${n(r)}">${r}</h3>`),t=t.replace(/^##\s+(.+)$/gm,(a,r)=>`<h2 id="${n(r)}">${r}</h2>`),t=t.replace(/^#\s+(.+)$/gm,(a,r)=>`<h1 id="${n(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(/((?:^>[ \t]*.+\n?)+)/gm,a=>"<blockquote>"+a.trimEnd().split(`
|
|
5
|
+
`).map(o=>o.replace(/^>[ \t]*/,"")).join("<br>")+"</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,r,o)=>`<a href="${/^(https?|mailto|ftp|tel):\/\//i.test(o)||o.startsWith("#")||o.startsWith("/")||o.startsWith("./")||o.startsWith("../")?o:`https://${o}`}" target="_blank" rel="noopener noreferrer">${r}</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 a=0;a<i.length;a++)t=t.replace(`%%CODEBLOCK_${a}%%`,i[a]);return t}}class Et{validate(e){const t=[];let i=e.replace(/```[\s\S]*?```/g,"");i=i.replace(/`[^`]+`/g,"");const n=[],a=i.split(`
|
|
6
|
+
`);for(let r=0;r<a.length;r++){const o=a[r];let c;const d=/<\/?([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?\/?>|<([A-Z][A-Za-z0-9]*)(?:\s[^>]*)?>/g;for(;(c=d.exec(o))!==null;){const l=c[0];if(l.endsWith("/>"))continue;const h=c[1]||c[2];if(!h)continue;const p=c.index+1;if(l.startsWith("</")){let m=!1;for(let g=n.length-1;g>=0;g--)if(n[g].tag===h){n.splice(g,1),m=!0;break}m||t.push(`Unexpected closing tag '</${h}>' at line ${r+1}:${p} — no matching opening tag found.`)}else n.push({tag:h,line:r+1,col:p})}}for(const r of n)t.push(`Expected a closing tag for '<${r.tag}>' (${r.line}:${r.col}) before the end of the document.`);return t}}class we{constructor(){this.renderers=[],this.parsers=[],this.markdownRenderer=new Tt,this.mdxValidator=new Et}setRenderers(e){this.renderers=e}setParsers(e){this.parsers=e}async render(e){let t=e;const i=this.mdxValidator.validate(e),n=[];t=t.replace(/`([^`\n]+)`/g,(a,r)=>{const o=n.length;return n.push(r),`%%INLINECODE_${o}%%`});for(const a of this.parsers)t=t.replace(a.pattern,(...r)=>a.transform(r));for(const a of this.renderers)t=t.replace(a.pattern,(r,...o)=>{const c={};return o.length>0&&(c.content=o[0]||""),a.render(r,c)});for(let a=0;a<n.length;a++){const r=`\`${n[a]}\``;t=t.replace(`%%INLINECODE_${a}%%`,()=>r)}if(t=this.markdownRenderer.render(t),i.length>0){const a=o=>o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");t=i.map(o=>`<div class="smdx-parse-error"><span class="smdx-parse-error-icon">⚠</span> ${a(o)}</div>`).join("")+t}return en(t)}}const Ye=class Ye{constructor(e,t,i){this.isDragging=!1,this.startX=0,this.startLeftWidth=0,this.onResizeCallback=null,this.resizeRafId=null,this.onMouseDown=n=>{this.startDrag(n.clientX),n.preventDefault()},this.onMouseMove=n=>{this.isDragging&&this.moveDrag(n.clientX)},this.onMouseUp=()=>{this.endDrag()},this.onTouchStart=n=>{n.touches.length===1&&(this.startDrag(n.touches[0].clientX),n.preventDefault())},this.onTouchMove=n=>{!this.isDragging||n.touches.length!==1||(this.moveDrag(n.touches[0].clientX),n.preventDefault())},this.onTouchEnd=()=>{this.endDrag()},this.onKeyDown=n=>{if(n.key!=="ArrowLeft"&&n.key!=="ArrowRight")return;n.preventDefault();const a=this.container.getBoundingClientRect().width;if(a<=0)return;const r=this.left.getBoundingClientRect().width,o=a*Ye.KEYBOARD_STEP_PERCENT,c=n.key==="ArrowRight"?o:-o;let d=(r+c)/a*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 n=(this.startLeftWidth+t)/i*100;n=Math.max(20,Math.min(80,n)),this.left.style.flex=`0 0 ${n}%`,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()}};Ye.KEYBOARD_STEP_PERCENT=.02;let _e=Ye;var nn=Object.defineProperty,an=(s,e,t)=>e in s?nn(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_=(s,e,t)=>an(s,typeof e!="symbol"?e+"":e,t);const sn=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"]),rn=new Set(["number","string","boolean","object","Promise","Array","Map","Set","HTMLElement","KeyboardEvent","Float64Array","EventListener","Document","Window","Node","Element","Event","MouseEvent","CustomEvent"]),on=[{label:"console.log",kind:"fn",detail:"void",language:"javascript"},{label:"console.error",kind:"fn",detail:"void",language:"javascript"},{label:"console.warn",kind:"fn",detail:"void",language:"javascript"},{label:"console.table",kind:"fn",detail:"void",language:"javascript"},{label:"document.getElementById",kind:"fn",detail:"HTMLElement | null",language:"javascript"},{label:"document.querySelector",kind:"fn",detail:"Element | null",language:"javascript"},{label:"document.querySelectorAll",kind:"fn",detail:"NodeList",language:"javascript"},{label:"document.createElement",kind:"fn",detail:"HTMLElement",language:"javascript"},{label:"addEventListener",kind:"fn",detail:"(ev, cb) => void",language:"javascript"},{label:"removeEventListener",kind:"fn",detail:"(ev, cb) => void",language:"javascript"},{label:"setTimeout",kind:"fn",detail:"(cb, ms) => id",language:"javascript"},{label:"clearTimeout",kind:"fn",detail:"(id) => void",language:"javascript"},{label:"setInterval",kind:"fn",detail:"(cb, ms) => id",language:"javascript"},{label:"clearInterval",kind:"fn",detail:"(id) => void",language:"javascript"},{label:"requestAnimationFrame",kind:"fn",detail:"(cb) => number",language:"javascript"},{label:"JSON.stringify",kind:"fn",detail:"string",language:"javascript"},{label:"JSON.parse",kind:"fn",detail:"any",language:"javascript"},{label:"Math.max",kind:"fn",detail:"number",language:"javascript"},{label:"Math.min",kind:"fn",detail:"number",language:"javascript"},{label:"Math.floor",kind:"fn",detail:"number",language:"javascript"},{label:"Math.ceil",kind:"fn",detail:"number",language:"javascript"},{label:"Math.round",kind:"fn",detail:"number",language:"javascript"},{label:"Math.abs",kind:"fn",detail:"number",language:"javascript"},{label:"Math.sqrt",kind:"fn",detail:"number",language:"javascript"},{label:"Math.random",kind:"fn",detail:"number",language:"javascript"},{label:"Object.keys",kind:"fn",detail:"string[]",language:"javascript"},{label:"Object.values",kind:"fn",detail:"any[]",language:"javascript"},{label:"Object.entries",kind:"fn",detail:"[string, any][]",language:"javascript"},{label:"Object.assign",kind:"fn",detail:"T & U",language:"javascript"},{label:"Object.freeze",kind:"fn",detail:"Readonly<T>",language:"javascript"},{label:"Array.from",kind:"fn",detail:"T[]",language:"javascript"},{label:"Array.isArray",kind:"fn",detail:"boolean",language:"javascript"},{label:"Promise.all",kind:"fn",detail:"Promise<T[]>",language:"javascript"},{label:"Promise.resolve",kind:"fn",detail:"Promise<T>",language:"javascript"},{label:"Promise.reject",kind:"fn",detail:"Promise<never>",language:"javascript"},{label:"fetch",kind:"fn",detail:"Promise<Response>",language:"javascript"},{label:"parseInt",kind:"fn",detail:"number",language:"javascript"},{label:"parseFloat",kind:"fn",detail:"number",language:"javascript"},{label:"arrowfn",kind:"snip",detail:"arrow function",body:`const $1 = ($2) => {
|
|
6
7
|
$3
|
|
7
8
|
};`,language:"javascript"},{label:"asyncfn",kind:"snip",detail:"async function",body:`async function $1($2) {
|
|
8
9
|
$3
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
}
|
|
23
24
|
}`,language:"javascript"},{label:"iife",kind:"snip",detail:"immediately invoked function",body:`(function () {
|
|
24
25
|
$1
|
|
25
|
-
})();`,language:"javascript"}],
|
|
26
|
+
})();`,language:"javascript"}],ve={lineCommentToken:"//",keywords:sn,types:rn,completions:on},ln=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"]),dn=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"]),cn=[{label:"console.log",kind:"fn",detail:"void",language:"typescript"},{label:"console.error",kind:"fn",detail:"void",language:"typescript"},{label:"console.warn",kind:"fn",detail:"void",language:"typescript"},{label:"console.table",kind:"fn",detail:"void",language:"typescript"},{label:"document.getElementById",kind:"fn",detail:"HTMLElement | null",language:"typescript"},{label:"document.querySelector",kind:"fn",detail:"Element | null",language:"typescript"},{label:"document.querySelectorAll",kind:"fn",detail:"NodeListOf<Element>",language:"typescript"},{label:"document.createElement",kind:"fn",detail:"HTMLElement",language:"typescript"},{label:"addEventListener",kind:"fn",detail:"(ev, cb) => void",language:"typescript"},{label:"setTimeout",kind:"fn",detail:"(cb, ms) => number",language:"typescript"},{label:"clearTimeout",kind:"fn",detail:"(id) => void",language:"typescript"},{label:"setInterval",kind:"fn",detail:"(cb, ms) => number",language:"typescript"},{label:"requestAnimationFrame",kind:"fn",detail:"(cb) => number",language:"typescript"},{label:"JSON.stringify",kind:"fn",detail:"string",language:"typescript"},{label:"JSON.parse",kind:"fn",detail:"unknown",language:"typescript"},{label:"Math.max",kind:"fn",detail:"number",language:"typescript"},{label:"Math.min",kind:"fn",detail:"number",language:"typescript"},{label:"Math.floor",kind:"fn",detail:"number",language:"typescript"},{label:"Math.ceil",kind:"fn",detail:"number",language:"typescript"},{label:"Math.round",kind:"fn",detail:"number",language:"typescript"},{label:"Math.abs",kind:"fn",detail:"number",language:"typescript"},{label:"Math.sqrt",kind:"fn",detail:"number",language:"typescript"},{label:"Math.random",kind:"fn",detail:"number",language:"typescript"},{label:"Object.keys",kind:"fn",detail:"string[]",language:"typescript"},{label:"Object.values",kind:"fn",detail:"T[keyof T][]",language:"typescript"},{label:"Object.entries",kind:"fn",detail:"[string, T[keyof T]][]",language:"typescript"},{label:"Object.assign",kind:"fn",detail:"T & U",language:"typescript"},{label:"Object.freeze",kind:"fn",detail:"Readonly<T>",language:"typescript"},{label:"Array.from",kind:"fn",detail:"T[]",language:"typescript"},{label:"Array.isArray",kind:"fn",detail:"boolean",language:"typescript"},{label:"Promise.all",kind:"fn",detail:"Promise<T[]>",language:"typescript"},{label:"Promise.resolve",kind:"fn",detail:"Promise<T>",language:"typescript"},{label:"Promise.reject",kind:"fn",detail:"Promise<never>",language:"typescript"},{label:"fetch",kind:"fn",detail:"Promise<Response>",language:"typescript"},{label:"structuredClone",kind:"fn",detail:"T",language:"typescript"},{label:"Partial",kind:"typ",detail:"Partial<T>",language:"typescript"},{label:"Required",kind:"typ",detail:"Required<T>",language:"typescript"},{label:"Readonly",kind:"typ",detail:"Readonly<T>",language:"typescript"},{label:"Record",kind:"typ",detail:"Record<K, V>",language:"typescript"},{label:"Pick",kind:"typ",detail:"Pick<T, K>",language:"typescript"},{label:"Omit",kind:"typ",detail:"Omit<T, K>",language:"typescript"},{label:"Exclude",kind:"typ",detail:"Exclude<T, U>",language:"typescript"},{label:"Extract",kind:"typ",detail:"Extract<T, U>",language:"typescript"},{label:"NonNullable",kind:"typ",detail:"NonNullable<T>",language:"typescript"},{label:"ReturnType",kind:"typ",detail:"ReturnType<T>",language:"typescript"},{label:"Parameters",kind:"typ",detail:"Parameters<T>",language:"typescript"},{label:"Awaited",kind:"typ",detail:"Awaited<T>",language:"typescript"},{label:"interface",kind:"snip",detail:"interface definition",body:`interface $1 {
|
|
26
27
|
$2
|
|
27
28
|
}`,language:"typescript"},{label:"typeAlias",kind:"snip",detail:"type alias",body:"type $1 = $2;",language:"typescript"},{label:"enumdef",kind:"snip",detail:"enum definition",body:`enum $1 {
|
|
28
29
|
$2,
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
$3
|
|
43
44
|
}`,language:"typescript"},{label:"genericfn",kind:"snip",detail:"generic function",body:`function $1<T>($2: T): $3 {
|
|
44
45
|
$4
|
|
45
|
-
}`,language:"typescript"}],
|
|
46
|
+
}`,language:"typescript"}],Ce={lineCommentToken:"//",keywords:ln,types:dn,completions:cn},hn=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","print","input","range","len","type","super","self"]),pn=new Set(["int","float","complex","bool","str","bytes","bytearray","memoryview","list","tuple","dict","set","frozenset","object","Exception","BaseException","ValueError","TypeError","KeyError","IndexError","AttributeError","RuntimeError","StopIteration","Optional","Union","Any","Dict","List","Tuple","Set","Callable","Generator","Iterable","Iterator","Sequence","Mapping"]),un=[{label:"print",kind:"fn",detail:'print(*args, end="\\n")',language:"python"},{label:"input",kind:"fn",detail:'input(prompt="") -> str',language:"python"},{label:"len",kind:"fn",detail:"len(obj) -> int",language:"python"},{label:"range",kind:"fn",detail:"range(stop) | range(start, stop[, step])",language:"python"},{label:"enumerate",kind:"fn",detail:"enumerate(iterable, start=0)",language:"python"},{label:"zip",kind:"fn",detail:"zip(*iterables)",language:"python"},{label:"map",kind:"fn",detail:"map(fn, iterable)",language:"python"},{label:"filter",kind:"fn",detail:"filter(fn, iterable)",language:"python"},{label:"sorted",kind:"fn",detail:"sorted(iterable, key=None, reverse=False)",language:"python"},{label:"reversed",kind:"fn",detail:"reversed(seq)",language:"python"},{label:"sum",kind:"fn",detail:"sum(iterable, start=0)",language:"python"},{label:"min",kind:"fn",detail:"min(*args) -> T",language:"python"},{label:"max",kind:"fn",detail:"max(*args) -> T",language:"python"},{label:"abs",kind:"fn",detail:"abs(x) -> number",language:"python"},{label:"round",kind:"fn",detail:"round(x, ndigits=None)",language:"python"},{label:"isinstance",kind:"fn",detail:"isinstance(obj, type) -> bool",language:"python"},{label:"issubclass",kind:"fn",detail:"issubclass(cls, type) -> bool",language:"python"},{label:"hasattr",kind:"fn",detail:"hasattr(obj, name) -> bool",language:"python"},{label:"getattr",kind:"fn",detail:"getattr(obj, name, default=...)",language:"python"},{label:"setattr",kind:"fn",detail:"setattr(obj, name, value)",language:"python"},{label:"open",kind:"fn",detail:'open(file, mode="r") -> IO',language:"python"},{label:"str",kind:"fn",detail:"str(obj) -> str",language:"python"},{label:"int",kind:"fn",detail:"int(x, base=10) -> int",language:"python"},{label:"float",kind:"fn",detail:"float(x) -> float",language:"python"},{label:"list",kind:"fn",detail:"list(iterable) -> list",language:"python"},{label:"dict",kind:"fn",detail:"dict(**kwargs) -> dict",language:"python"},{label:"tuple",kind:"fn",detail:"tuple(iterable) -> tuple",language:"python"},{label:"set",kind:"fn",detail:"set(iterable) -> set",language:"python"},{label:"os",kind:"var",detail:"import os",language:"python"},{label:"sys",kind:"var",detail:"import sys",language:"python"},{label:"math",kind:"var",detail:"import math",language:"python"},{label:"json",kind:"var",detail:"import json",language:"python"},{label:"re",kind:"var",detail:"import re",language:"python"},{label:"datetime",kind:"var",detail:"from datetime import datetime",language:"python"},{label:"pathlib",kind:"var",detail:"from pathlib import Path",language:"python"},{label:"def",kind:"snip",detail:"function definition",body:`def $1($2):
|
|
46
47
|
$3`,language:"python"},{label:"classdef",kind:"snip",detail:"class definition",body:`class $1:
|
|
47
48
|
def __init__(self$2):
|
|
48
49
|
$3`,language:"python"},{label:"asyncdef",kind:"snip",detail:"async function definition",body:`async def $1($2):
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
$4`,language:"python"},{label:"tryexcept",kind:"snip",detail:"try / except",body:`try:
|
|
54
55
|
$1
|
|
55
56
|
except $2 as e:
|
|
56
|
-
$3`,language:"python"},{label:"listcomp",kind:"snip",detail:"list comprehension",body:"[$1 for $2 in $3]",language:"python"},{label:"dictcomp",kind:"snip",detail:"dict comprehension",body:"{$1: $2 for $3 in $4}",language:"python"}],
|
|
57
|
+
$3`,language:"python"},{label:"listcomp",kind:"snip",detail:"list comprehension",body:"[$1 for $2 in $3]",language:"python"},{label:"dictcomp",kind:"snip",detail:"dict comprehension",body:"{$1: $2 for $3 in $4}",language:"python"}],Te={lineCommentToken:"#",keywords:hn,types:pn,completions:un},gn=new Set(["abstract","assert","break","case","catch","class","const","continue","default","do","else","enum","extends","final","finally","for","goto","if","implements","import","instanceof","interface","native","new","package","private","protected","public","return","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","var","void","volatile","while","true","false","null","record","sealed","permits","yield"]),mn=new Set(["boolean","byte","char","double","float","int","long","short","String","Integer","Long","Double","Float","Boolean","Character","Byte","Short","Object","Number","Math","System","Runtime","Thread","Runnable","Callable","Exception","RuntimeException","List","ArrayList","LinkedList","Map","HashMap","LinkedHashMap","TreeMap","Set","HashSet","TreeSet","Queue","Deque","ArrayDeque","Optional","Stream","Collectors","Arrays","Collections","StringBuilder","StringBuffer"]),fn=[{label:"System.out.println",kind:"fn",detail:"void",language:"java"},{label:"System.out.print",kind:"fn",detail:"void",language:"java"},{label:"System.out.printf",kind:"fn",detail:"void",language:"java"},{label:"System.err.println",kind:"fn",detail:"void",language:"java"},{label:"System.exit",kind:"fn",detail:"void",language:"java"},{label:"System.currentTimeMillis",kind:"fn",detail:"long",language:"java"},{label:"String.valueOf",kind:"fn",detail:"String",language:"java"},{label:"String.format",kind:"fn",detail:"String",language:"java"},{label:"String.join",kind:"fn",detail:"String",language:"java"},{label:"Math.max",kind:"fn",detail:"T",language:"java"},{label:"Math.min",kind:"fn",detail:"T",language:"java"},{label:"Math.abs",kind:"fn",detail:"T",language:"java"},{label:"Math.sqrt",kind:"fn",detail:"double",language:"java"},{label:"Math.pow",kind:"fn",detail:"double",language:"java"},{label:"Math.floor",kind:"fn",detail:"double",language:"java"},{label:"Math.ceil",kind:"fn",detail:"double",language:"java"},{label:"Math.random",kind:"fn",detail:"double",language:"java"},{label:"Collections.sort",kind:"fn",detail:"void",language:"java"},{label:"Collections.reverse",kind:"fn",detail:"void",language:"java"},{label:"Collections.shuffle",kind:"fn",detail:"void",language:"java"},{label:"Arrays.sort",kind:"fn",detail:"void",language:"java"},{label:"Arrays.asList",kind:"fn",detail:"List<T>",language:"java"},{label:"Arrays.copyOf",kind:"fn",detail:"T[]",language:"java"},{label:"ArrayList",kind:"cls",detail:"java.util.ArrayList<T>",language:"java"},{label:"HashMap",kind:"cls",detail:"java.util.HashMap<K,V>",language:"java"},{label:"HashSet",kind:"cls",detail:"java.util.HashSet<T>",language:"java"},{label:"LinkedList",kind:"cls",detail:"java.util.LinkedList<T>",language:"java"},{label:"StringBuilder",kind:"cls",detail:"java.lang.StringBuilder",language:"java"},{label:"Optional",kind:"cls",detail:"java.util.Optional<T>",language:"java"},{label:"Scanner",kind:"cls",detail:"java.util.Scanner",language:"java"},{label:"main",kind:"snip",detail:"main method",body:`public static void main(String[] args) {
|
|
57
58
|
$1
|
|
58
59
|
}`,language:"java"},{label:"classdef",kind:"snip",detail:"public class",body:`public class $1 {
|
|
59
60
|
$2
|
|
@@ -75,7 +76,7 @@ except $2 as e:
|
|
|
75
76
|
return this.$3;
|
|
76
77
|
}`,language:"java"},{label:"setter",kind:"snip",detail:"setter method",body:`public void set$1($2 $3) {
|
|
77
78
|
this.$4 = $3;
|
|
78
|
-
}`,language:"java"}],
|
|
79
|
+
}`,language:"java"}],Ee={lineCommentToken:"//",keywords:gn,types:mn,completions:fn},St=new Set(["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","inline","int","long","register","restrict","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","NULL","true","false","define","include","ifdef","ifndef","endif","pragma","undef","elif"]),$t=new Set(["size_t","ptrdiff_t","intptr_t","uintptr_t","int8_t","int16_t","int32_t","int64_t","uint8_t","uint16_t","uint32_t","uint64_t","FILE","wchar_t","bool"]),bn=[{label:"printf",kind:"fn",detail:"int printf(const char *format, ...)",language:"c"},{label:"fprintf",kind:"fn",detail:"int fprintf(FILE *stream, ...)",language:"c"},{label:"scanf",kind:"fn",detail:"int scanf(const char *format, ...)",language:"c"},{label:"fgets",kind:"fn",detail:"char *fgets(char *s, int n, FILE *f)",language:"c"},{label:"fputs",kind:"fn",detail:"int fputs(const char *s, FILE *f)",language:"c"},{label:"fopen",kind:"fn",detail:"FILE *fopen(const char *path, const char *mode)",language:"c"},{label:"fclose",kind:"fn",detail:"int fclose(FILE *stream)",language:"c"},{label:"fread",kind:"fn",detail:"size_t fread(void *ptr, size_t size, size_t n, FILE *f)",language:"c"},{label:"fwrite",kind:"fn",detail:"size_t fwrite(const void *ptr, size_t size, size_t n, FILE *f)",language:"c"},{label:"malloc",kind:"fn",detail:"void *malloc(size_t size)",language:"c"},{label:"calloc",kind:"fn",detail:"void *calloc(size_t n, size_t size)",language:"c"},{label:"realloc",kind:"fn",detail:"void *realloc(void *ptr, size_t size)",language:"c"},{label:"free",kind:"fn",detail:"void free(void *ptr)",language:"c"},{label:"exit",kind:"fn",detail:"void exit(int status)",language:"c"},{label:"atoi",kind:"fn",detail:"int atoi(const char *s)",language:"c"},{label:"atof",kind:"fn",detail:"double atof(const char *s)",language:"c"},{label:"abs",kind:"fn",detail:"int abs(int n)",language:"c"},{label:"strlen",kind:"fn",detail:"size_t strlen(const char *s)",language:"c"},{label:"strcpy",kind:"fn",detail:"char *strcpy(char *dst, const char *src)",language:"c"},{label:"strncpy",kind:"fn",detail:"char *strncpy(char *dst, const char *src, size_t n)",language:"c"},{label:"strcat",kind:"fn",detail:"char *strcat(char *dst, const char *src)",language:"c"},{label:"strcmp",kind:"fn",detail:"int strcmp(const char *a, const char *b)",language:"c"},{label:"strchr",kind:"fn",detail:"char *strchr(const char *s, int c)",language:"c"},{label:"memcpy",kind:"fn",detail:"void *memcpy(void *dst, const void *src, size_t n)",language:"c"},{label:"memset",kind:"fn",detail:"void *memset(void *s, int c, size_t n)",language:"c"},{label:"sqrt",kind:"fn",detail:"double sqrt(double x)",language:"c"},{label:"pow",kind:"fn",detail:"double pow(double base, double exp)",language:"c"},{label:"fabs",kind:"fn",detail:"double fabs(double x)",language:"c"},{label:"floor",kind:"fn",detail:"double floor(double x)",language:"c"},{label:"ceil",kind:"fn",detail:"double ceil(double x)",language:"c"},{label:"size_t",kind:"typ",detail:"stddef.h",language:"c"},{label:"int8_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"int16_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"int32_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"int64_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"uint8_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"uint32_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"uint64_t",kind:"typ",detail:"stdint.h",language:"c"},{label:"main",kind:"snip",detail:"main function",body:`int main(int argc, char *argv[]) {
|
|
79
80
|
$1
|
|
80
81
|
return 0;
|
|
81
82
|
}`,language:"c"},{label:"include",kind:"snip",detail:"#include <header>",body:"#include <$1>",language:"c"},{label:"define",kind:"snip",detail:"#define macro",body:"#define $1 $2",language:"c"},{label:"struct",kind:"snip",detail:"struct definition",body:`typedef struct {
|
|
@@ -95,7 +96,7 @@ except $2 as e:
|
|
|
95
96
|
|
|
96
97
|
$2
|
|
97
98
|
|
|
98
|
-
#endif /* $1_H */`,language:"c"}],
|
|
99
|
+
#endif /* $1_H */`,language:"c"}],Se={lineCommentToken:"//",keywords:St,types:$t,completions:bn},yn=new Set([...St,"class","public","private","protected","virtual","override","final","namespace","using","template","typename","explicit","mutable","friend","constexpr","consteval","constinit","noexcept","operator","new","delete","this","throw","try","catch","static_assert","nullptr","and","or","not","bitand","bitor","xor"]),xn=new Set([...$t,"string","wstring","vector","map","unordered_map","set","unordered_set","list","deque","array","pair","tuple","unique_ptr","shared_ptr","weak_ptr","optional","variant","any","function","thread","mutex","atomic","ostream","istream","iostream","stringstream","fstream","exception","runtime_error","logic_error"]),kn=[{label:"std::cout",kind:"var",detail:"std::ostream",language:"cpp"},{label:"std::cin",kind:"var",detail:"std::istream",language:"cpp"},{label:"std::cerr",kind:"var",detail:"std::ostream",language:"cpp"},{label:"std::endl",kind:"var",detail:"ostream manipulator",language:"cpp"},{label:"std::string",kind:"typ",detail:"<string>",language:"cpp"},{label:"std::to_string",kind:"fn",detail:"std::string",language:"cpp"},{label:"std::stoi",kind:"fn",detail:"int",language:"cpp"},{label:"std::stod",kind:"fn",detail:"double",language:"cpp"},{label:"std::vector",kind:"typ",detail:"<vector>",language:"cpp"},{label:"std::array",kind:"typ",detail:"<array>",language:"cpp"},{label:"std::deque",kind:"typ",detail:"<deque>",language:"cpp"},{label:"std::map",kind:"typ",detail:"<map>",language:"cpp"},{label:"std::unordered_map",kind:"typ",detail:"<unordered_map>",language:"cpp"},{label:"std::set",kind:"typ",detail:"<set>",language:"cpp"},{label:"std::unordered_set",kind:"typ",detail:"<unordered_set>",language:"cpp"},{label:"std::unique_ptr",kind:"typ",detail:"<memory>",language:"cpp"},{label:"std::shared_ptr",kind:"typ",detail:"<memory>",language:"cpp"},{label:"std::weak_ptr",kind:"typ",detail:"<memory>",language:"cpp"},{label:"std::make_unique",kind:"fn",detail:"std::unique_ptr<T>",language:"cpp"},{label:"std::make_shared",kind:"fn",detail:"std::shared_ptr<T>",language:"cpp"},{label:"std::optional",kind:"typ",detail:"<optional>",language:"cpp"},{label:"std::variant",kind:"typ",detail:"<variant>",language:"cpp"},{label:"std::get",kind:"fn",detail:"T&",language:"cpp"},{label:"std::holds_alternative",kind:"fn",detail:"bool",language:"cpp"},{label:"std::sort",kind:"fn",detail:"<algorithm>",language:"cpp"},{label:"std::find",kind:"fn",detail:"Iterator",language:"cpp"},{label:"std::find_if",kind:"fn",detail:"Iterator",language:"cpp"},{label:"std::count",kind:"fn",detail:"ptrdiff_t",language:"cpp"},{label:"std::transform",kind:"fn",detail:"OutputIt",language:"cpp"},{label:"std::for_each",kind:"fn",detail:"Function",language:"cpp"},{label:"std::accumulate",kind:"fn",detail:"T",language:"cpp"},{label:"std::min",kind:"fn",detail:"T",language:"cpp"},{label:"std::max",kind:"fn",detail:"T",language:"cpp"},{label:"std::move",kind:"fn",detail:"T&&",language:"cpp"},{label:"std::forward",kind:"fn",detail:"T&&",language:"cpp"},{label:"std::swap",kind:"fn",detail:"void",language:"cpp"},{label:"std::pair",kind:"typ",detail:"<utility>",language:"cpp"},{label:"std::tuple",kind:"typ",detail:"<tuple>",language:"cpp"},{label:"std::make_pair",kind:"fn",detail:"std::pair<T1,T2>",language:"cpp"},{label:"main",kind:"snip",detail:"main function",body:`int main(int argc, char* argv[]) {
|
|
99
100
|
$1
|
|
100
101
|
return 0;
|
|
101
102
|
}`,language:"cpp"},{label:"include",kind:"snip",detail:"#include <header>",body:"#include <$1>",language:"cpp"},{label:"classdef",kind:"snip",detail:"class definition",body:`class $1 {
|
|
@@ -126,7 +127,7 @@ $2 $3($4) {
|
|
|
126
127
|
$3
|
|
127
128
|
}`,language:"cpp"},{label:"guardheader",kind:"snip",detail:"include guard",body:`#pragma once
|
|
128
129
|
|
|
129
|
-
$1`,language:"cpp"}]
|
|
130
|
+
$1`,language:"cpp"}],$e={lineCommentToken:"//",keywords:yn,types:xn,completions:kn},wn=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"]),_n=new Set,vn=[{label:"display",kind:"kw",detail:"display: flex | grid | block",language:"css"},{label:"position",kind:"kw",detail:"position: static | relative | absolute | fixed | sticky",language:"css"},{label:"flex-direction",kind:"kw",detail:"flex-direction: row | column",language:"css"},{label:"justify-content",kind:"kw",detail:"justify-content: center | space-between",language:"css"},{label:"align-items",kind:"kw",detail:"align-items: center | stretch | flex-start",language:"css"},{label:"gap",kind:"kw",detail:"gap: <length>",language:"css"},{label:"grid-template-columns",kind:"kw",detail:"grid-template-columns: repeat(...)",language:"css"},{label:"margin",kind:"kw",detail:"margin: <length>",language:"css"},{label:"padding",kind:"kw",detail:"padding: <length>",language:"css"},{label:"border",kind:"kw",detail:"border: <width> <style> <color>",language:"css"},{label:"border-radius",kind:"kw",detail:"border-radius: <length>",language:"css"},{label:"box-shadow",kind:"kw",detail:"box-shadow: <x> <y> <blur> <color>",language:"css"},{label:"box-sizing",kind:"kw",detail:"box-sizing: border-box",language:"css"},{label:"font-size",kind:"kw",detail:"font-size: <length>",language:"css"},{label:"font-weight",kind:"kw",detail:"font-weight: bold | normal | 400-900",language:"css"},{label:"font-family",kind:"kw",detail:"font-family: 'Font', sans-serif",language:"css"},{label:"line-height",kind:"kw",detail:"line-height: <number>",language:"css"},{label:"text-align",kind:"kw",detail:"text-align: left | right | center",language:"css"},{label:"color",kind:"kw",detail:"color: <color>",language:"css"},{label:"background",kind:"kw",detail:"background: <color> | url(...)",language:"css"},{label:"background-color",kind:"kw",detail:"background-color: <color>",language:"css"},{label:"background-image",kind:"kw",detail:"background-image: url(...)",language:"css"},{label:"width",kind:"kw",detail:"width: <length> | auto | 100%",language:"css"},{label:"height",kind:"kw",detail:"height: <length> | auto | 100%",language:"css"},{label:"max-width",kind:"kw",detail:"max-width: <length>",language:"css"},{label:"min-width",kind:"kw",detail:"min-width: <length>",language:"css"},{label:"overflow",kind:"kw",detail:"overflow: hidden | scroll | auto",language:"css"},{label:"transform",kind:"kw",detail:"transform: translate() | scale() | rotate()",language:"css"},{label:"transition",kind:"kw",detail:"transition: <property> <duration> <easing>",language:"css"},{label:"animation",kind:"kw",detail:"animation: <name> <duration> <timing>",language:"css"},{label:"opacity",kind:"kw",detail:"opacity: 0..1",language:"css"},{label:"z-index",kind:"kw",detail:"z-index: <integer>",language:"css"},{label:"cursor",kind:"kw",detail:"cursor: pointer | default | not-allowed",language:"css"},{label:"var",kind:"fn",detail:"var(--custom-property)",language:"css"},{label:"calc",kind:"fn",detail:"calc(expression)",language:"css"},{label:"clamp",kind:"fn",detail:"clamp(min, val, max)",language:"css"},{label:"flexcenter",kind:"snip",detail:"flex centering",body:`display: flex;
|
|
130
131
|
justify-content: center;
|
|
131
132
|
align-items: center;`,language:"css"},{label:"gridcols",kind:"snip",detail:"responsive grid columns",body:`display: grid;
|
|
132
133
|
grid-template-columns: repeat(auto-fit, minmax($1px, 1fr));
|
|
@@ -135,13 +136,13 @@ gap: $2rem;`,language:"css"},{label:"keyframe",kind:"snip",detail:"@keyframes an
|
|
|
135
136
|
to { $3 }
|
|
136
137
|
}`,language:"css"},{label:"media",kind:"snip",detail:"@media query",body:`@media (max-width: $1px) {
|
|
137
138
|
$2
|
|
138
|
-
}`,language:"css"}]
|
|
139
|
+
}`,language:"css"}],Re={lineCommentToken:"//",keywords:wn,types:_n,completions:vn},Cn=new Set(["null","true","false"]),Tn=new Set,En=[{label:"true",kind:"kw",detail:"boolean",language:"json"},{label:"false",kind:"kw",detail:"boolean",language:"json"},{label:"null",kind:"kw",detail:"null value",language:"json"},{label:"obj",kind:"snip",detail:"empty object",body:`{
|
|
139
140
|
"$1": $2
|
|
140
141
|
}`,language:"json"},{label:"arr",kind:"snip",detail:"empty array",body:`[
|
|
141
142
|
$1
|
|
142
|
-
]`,language:"json"}],
|
|
143
|
+
]`,language:"json"}],Me={lineCommentToken:"",keywords:Cn,types:Tn,completions:En},Sn=new Set,$n=new Set,Rn=[{label:"link",kind:"snip",detail:"[text](url)",body:"[$1]($2)",language:"markdown"},{label:"image",kind:"snip",detail:"",body:"",language:"markdown"},{label:"code",kind:"snip",detail:"fenced code block",body:"```$1\n$2\n```",language:"markdown"},{label:"table",kind:"snip",detail:"GFM table",body:`| $1 | $2 |
|
|
143
144
|
| --- | --- |
|
|
144
|
-
| $3 | $4 |`,language:"markdown"},{label:"blockquote",kind:"snip",detail:"> blockquote",body:"> $1",language:"markdown"},{label:"h1",kind:"snip",detail:"# Heading 1",body:"# $1",language:"markdown"},{label:"h2",kind:"snip",detail:"## Heading 2",body:"## $1",language:"markdown"},{label:"h3",kind:"snip",detail:"### Heading 3",body:"### $1",language:"markdown"}],
|
|
145
|
+
| $3 | $4 |`,language:"markdown"},{label:"blockquote",kind:"snip",detail:"> blockquote",body:"> $1",language:"markdown"},{label:"h1",kind:"snip",detail:"# Heading 1",body:"# $1",language:"markdown"},{label:"h2",kind:"snip",detail:"## Heading 2",body:"## $1",language:"markdown"},{label:"h3",kind:"snip",detail:"### Heading 3",body:"### $1",language:"markdown"}],de={lineCommentToken:"",keywords:Sn,types:$n,completions:Rn},Mn=new Set(["SELECT","FROM","WHERE","INSERT","INTO","VALUES","UPDATE","SET","DELETE","MERGE","UPSERT","JOIN","INNER","LEFT","RIGHT","FULL","OUTER","CROSS","ON","GROUP","BY","ORDER","HAVING","LIMIT","OFFSET","FETCH","NEXT","ROWS","ONLY","ASC","DESC","NULLS","FIRST","LAST","CREATE","TABLE","VIEW","INDEX","DATABASE","SCHEMA","ALTER","DROP","TRUNCATE","RENAME","PRIMARY","KEY","FOREIGN","REFERENCES","UNIQUE","CHECK","DEFAULT","NOT","NULL","AUTO_INCREMENT","IDENTITY","SERIAL","CONSTRAINT","COLUMN","ADD","MODIFY","BEGIN","COMMIT","ROLLBACK","SAVEPOINT","TRANSACTION","AND","OR","IN","NOT","LIKE","ILIKE","BETWEEN","EXISTS","CASE","WHEN","THEN","ELSE","END","IF","AS","DISTINCT","ALL","UNION","INTERSECT","EXCEPT","OVER","PARTITION","ROWS","RANGE","UNBOUNDED","PRECEDING","FOLLOWING","CURRENT","ROW_NUMBER","RANK","DENSE_RANK","LAG","LEAD","NTILE","WITH","RECURSIVE","RETURNING","USING","TO","FOR","GRANT","EXPLAIN","ANALYZE","select","from","where","insert","into","values","update","set","delete","join","inner","left","right","full","outer","on","group","by","order","having","limit","offset","and","or","in","not","like","between","exists","case","when","then","else","end","as","distinct","null"]),Ln=new Set(["INT","INTEGER","BIGINT","SMALLINT","TINYINT","DECIMAL","NUMERIC","FLOAT","DOUBLE","REAL","MONEY","SMALLMONEY","CHAR","VARCHAR","TEXT","NCHAR","NVARCHAR","NTEXT","CLOB","BINARY","VARBINARY","BLOB","BYTEA","DATE","TIME","TIMESTAMP","DATETIME","INTERVAL","TIMESTAMPTZ","BOOLEAN","BOOL","BIT","JSON","JSONB","UUID","XML","ARRAY","SERIAL","BIGSERIAL","int","integer","bigint","varchar","text","boolean","float","date","timestamp","json","uuid"]),An=[{label:"SELECT",kind:"kw",detail:"retrieve rows",language:"sql"},{label:"FROM",kind:"kw",detail:"source table",language:"sql"},{label:"WHERE",kind:"kw",detail:"filter predicate",language:"sql"},{label:"JOIN",kind:"kw",detail:"table join",language:"sql"},{label:"LEFT JOIN",kind:"kw",detail:"left outer join",language:"sql"},{label:"GROUP BY",kind:"kw",detail:"aggregate grouping",language:"sql"},{label:"ORDER BY",kind:"kw",detail:"sort result set",language:"sql"},{label:"HAVING",kind:"kw",detail:"filter on aggregation",language:"sql"},{label:"LIMIT",kind:"kw",detail:"limit rows returned",language:"sql"},{label:"INSERT INTO",kind:"kw",detail:"insert rows",language:"sql"},{label:"UPDATE",kind:"kw",detail:"update rows",language:"sql"},{label:"DELETE FROM",kind:"kw",detail:"delete rows",language:"sql"},{label:"COUNT",kind:"fn",detail:"COUNT(*) → bigint",language:"sql"},{label:"SUM",kind:"fn",detail:"SUM(col) → numeric",language:"sql"},{label:"AVG",kind:"fn",detail:"AVG(col) → numeric",language:"sql"},{label:"MIN",kind:"fn",detail:"MIN(col) → T",language:"sql"},{label:"MAX",kind:"fn",detail:"MAX(col) → T",language:"sql"},{label:"UPPER",kind:"fn",detail:"UPPER(str) → varchar",language:"sql"},{label:"LOWER",kind:"fn",detail:"LOWER(str) → varchar",language:"sql"},{label:"TRIM",kind:"fn",detail:"TRIM(str) → varchar",language:"sql"},{label:"LENGTH",kind:"fn",detail:"LENGTH(str) → int",language:"sql"},{label:"CONCAT",kind:"fn",detail:"CONCAT(a, b, ...) → varchar",language:"sql"},{label:"SUBSTRING",kind:"fn",detail:"SUBSTRING(str, pos, len)",language:"sql"},{label:"REPLACE",kind:"fn",detail:"REPLACE(str, from, to)",language:"sql"},{label:"COALESCE",kind:"fn",detail:"COALESCE(a, b, ...) → first non-null",language:"sql"},{label:"NULLIF",kind:"fn",detail:"NULLIF(a, b) → null if equal",language:"sql"},{label:"CAST",kind:"fn",detail:"CAST(expr AS type)",language:"sql"},{label:"NOW",kind:"fn",detail:"NOW() → timestamp",language:"sql"},{label:"CURRENT_DATE",kind:"fn",detail:"current date",language:"sql"},{label:"CURRENT_TIMESTAMP",kind:"fn",detail:"current timestamp",language:"sql"},{label:"DATE_TRUNC",kind:"fn",detail:"DATE_TRUNC('unit', ts)",language:"sql"},{label:"EXTRACT",kind:"fn",detail:"EXTRACT(field FROM source)",language:"sql"},{label:"ROW_NUMBER",kind:"fn",detail:"ROW_NUMBER() OVER (...)",language:"sql"},{label:"RANK",kind:"fn",detail:"RANK() OVER (...)",language:"sql"},{label:"DENSE_RANK",kind:"fn",detail:"DENSE_RANK() OVER (...)",language:"sql"},{label:"LAG",kind:"fn",detail:"LAG(col, offset, default) OVER (...)",language:"sql"},{label:"LEAD",kind:"fn",detail:"LEAD(col, offset, default) OVER (...)",language:"sql"},{label:"INT",kind:"typ",detail:"integer type",language:"sql"},{label:"VARCHAR",kind:"typ",detail:"variable-length string",language:"sql"},{label:"TEXT",kind:"typ",detail:"unlimited-length string",language:"sql"},{label:"BOOLEAN",kind:"typ",detail:"boolean type",language:"sql"},{label:"TIMESTAMP",kind:"typ",detail:"date + time",language:"sql"},{label:"DECIMAL",kind:"typ",detail:"DECIMAL(precision, scale)",language:"sql"},{label:"UUID",kind:"typ",detail:"universally unique identifier",language:"sql"},{label:"JSONB",kind:"typ",detail:"binary JSON (PostgreSQL)",language:"sql"},{label:"sel",kind:"snip",detail:"SELECT ... FROM ...",body:`SELECT $1
|
|
145
146
|
FROM $2
|
|
146
147
|
WHERE $3;`,language:"sql"},{label:"cte",kind:"snip",detail:"Common Table Expression",body:`WITH $1 AS (
|
|
147
148
|
SELECT $2
|
|
@@ -152,7 +153,7 @@ FROM $1;`,language:"sql"},{label:"ins",kind:"snip",detail:"INSERT INTO",body:`IN
|
|
|
152
153
|
VALUES ($3);`,language:"sql"},{label:"ct",kind:"snip",detail:"CREATE TABLE",body:`CREATE TABLE $1 (
|
|
153
154
|
id SERIAL PRIMARY KEY,
|
|
154
155
|
$2
|
|
155
|
-
);`,language:"sql"}],
|
|
156
|
+
);`,language:"sql"}],Le={lineCommentToken:"--",keywords:Mn,types:Ln,completions:An},In=new Set(["if","else","switch","case","default","for","foreach","while","do","break","continue","return","goto","try","catch","finally","throw","class","interface","struct","enum","record","delegate","event","new","this","base","static","abstract","virtual","override","sealed","public","private","protected","internal","readonly","const","partial","extern","volatile","unsafe","fixed","namespace","using","global","is","as","typeof","sizeof","default","checked","unchecked","implicit","explicit","operator","in","out","ref","params","var","dynamic","async","await","from","where","select","group","by","into","orderby","join","null","true","false","lock","stackalloc","nameof","with","init","required","file"]),Bn=new Set(["int","uint","long","ulong","short","ushort","byte","sbyte","float","double","decimal","bool","char","string","object","dynamic","void","nint","nuint","List","Dictionary","HashSet","Queue","Stack","LinkedList","Array","Span","Memory","ReadOnlySpan","Task","ValueTask","CancellationToken","IEnumerable","ICollection","IList","IDictionary","IReadOnlyList","IReadOnlyDictionary","Action","Func","Predicate","EventHandler","Exception","InvalidOperationException","ArgumentException","ArgumentNullException","NotImplementedException","NullReferenceException","Nullable","Guid","DateTime","DateTimeOffset","TimeSpan","StringBuilder","Stream","FileStream","StreamReader","StreamWriter","HttpClient","JsonSerializer","Regex","Console","Math","Environment","GC"]),Dn=[{label:"Console.WriteLine",kind:"fn",detail:"void Console.WriteLine(object?)",language:"csharp"},{label:"Console.Write",kind:"fn",detail:"void Console.Write(object?)",language:"csharp"},{label:"Console.ReadLine",kind:"fn",detail:"string? Console.ReadLine()",language:"csharp"},{label:"Select",kind:"fn",detail:"IEnumerable<TResult> Select<T, TResult>(Func<T, TResult>)",language:"csharp"},{label:"Where",kind:"fn",detail:"IEnumerable<T> Where<T>(Func<T, bool>)",language:"csharp"},{label:"FirstOrDefault",kind:"fn",detail:"T? FirstOrDefault<T>(Func<T, bool>?)",language:"csharp"},{label:"ToList",kind:"fn",detail:"List<T> ToList<T>()",language:"csharp"},{label:"ToArray",kind:"fn",detail:"T[] ToArray<T>()",language:"csharp"},{label:"ToDictionary",kind:"fn",detail:"Dictionary<K, V> ToDictionary(...)",language:"csharp"},{label:"OrderBy",kind:"fn",detail:"IOrderedEnumerable<T> OrderBy<T, K>(Func<T, K>)",language:"csharp"},{label:"GroupBy",kind:"fn",detail:"IEnumerable<IGrouping<K, T>> GroupBy<T, K>(...)",language:"csharp"},{label:"Any",kind:"fn",detail:"bool Any<T>(Func<T, bool>?)",language:"csharp"},{label:"All",kind:"fn",detail:"bool All<T>(Func<T, bool>)",language:"csharp"},{label:"Count",kind:"fn",detail:"int Count<T>(Func<T, bool>?)",language:"csharp"},{label:"Sum",kind:"fn",detail:"T Sum<T>(Func<T, T>)",language:"csharp"},{label:"Task.Run",kind:"fn",detail:"Task Task.Run(Func<Task>)",language:"csharp"},{label:"Task.WhenAll",kind:"fn",detail:"Task Task.WhenAll(IEnumerable<Task>)",language:"csharp"},{label:"Task.WhenAny",kind:"fn",detail:"Task<Task> Task.WhenAny(IEnumerable<Task>)",language:"csharp"},{label:"ConfigureAwait",kind:"fn",detail:"ConfiguredTaskAwaitable ConfigureAwait(bool)",language:"csharp"},{label:"string.IsNullOrEmpty",kind:"fn",detail:"bool string.IsNullOrEmpty(string?)",language:"csharp"},{label:"string.IsNullOrWhiteSpace",kind:"fn",detail:"bool string.IsNullOrWhiteSpace(string?)",language:"csharp"},{label:"string.Format",kind:"fn",detail:"string string.Format(string, params object?[])",language:"csharp"},{label:"List<T>",kind:"typ",detail:"System.Collections.Generic.List<T>",language:"csharp"},{label:"Dictionary<K,V>",kind:"typ",detail:"System.Collections.Generic.Dictionary<TKey, TValue>",language:"csharp"},{label:"Task",kind:"typ",detail:"System.Threading.Tasks.Task",language:"csharp"},{label:"CancellationToken",kind:"typ",detail:"System.Threading.CancellationToken",language:"csharp"},{label:"IEnumerable<T>",kind:"typ",detail:"System.Collections.Generic.IEnumerable<T>",language:"csharp"},{label:"ctor",kind:"snip",detail:"constructor",body:`public $1($2)
|
|
156
157
|
{
|
|
157
158
|
$3
|
|
158
159
|
}`,language:"csharp"},{label:"prop",kind:"snip",detail:"auto-property",body:"public $1 $2 { get; set; }",language:"csharp"},{label:"method",kind:"snip",detail:"method",body:`public $1 $2($3)
|
|
@@ -174,7 +175,7 @@ catch ($2 ex)
|
|
|
174
175
|
}`,language:"csharp"},{label:"foreach",kind:"snip",detail:"foreach loop",body:`foreach (var $1 in $2)
|
|
175
176
|
{
|
|
176
177
|
$3
|
|
177
|
-
}`,language:"csharp"},{label:"using",kind:"snip",detail:"using statement",body:"using var $1 = $2;",language:"csharp"}],
|
|
178
|
+
}`,language:"csharp"},{label:"using",kind:"snip",detail:"using statement",body:"using var $1 = $2;",language:"csharp"}],Ae={lineCommentToken:"//",keywords:In,types:Bn,completions:Dn},Pn=new Set(["func","var","const","type","package","import","if","else","for","range","switch","case","default","select","break","continue","return","goto","fallthrough","struct","interface","map","chan","make","new","delete","copy","append","len","cap","close","go","defer","nil","true","false","iota"]),On=new Set(["int","int8","int16","int32","int64","uint","uint8","uint16","uint32","uint64","uintptr","float32","float64","complex64","complex128","bool","byte","rune","string","error","Context","WaitGroup","Mutex","RWMutex","Reader","Writer","ReadWriter","ReadCloser","WriteCloser","Buffer","Scanner","Time","Duration","Handler","HandlerFunc","Request","ResponseWriter"]),Hn=[{label:"fmt.Println",kind:"fn",detail:"fmt.Println(a ...any) (int, error)",language:"go"},{label:"fmt.Printf",kind:"fn",detail:"fmt.Printf(format string, a ...any)",language:"go"},{label:"fmt.Sprintf",kind:"fn",detail:"fmt.Sprintf(format string, a ...any) string",language:"go"},{label:"fmt.Errorf",kind:"fn",detail:"fmt.Errorf(format string, a ...any) error",language:"go"},{label:"fmt.Fprintf",kind:"fn",detail:"fmt.Fprintf(w io.Writer, format string, ...) (int, error)",language:"go"},{label:"errors.New",kind:"fn",detail:"errors.New(text string) error",language:"go"},{label:"errors.Is",kind:"fn",detail:"errors.Is(err, target error) bool",language:"go"},{label:"errors.As",kind:"fn",detail:"errors.As(err error, target any) bool",language:"go"},{label:"os.Open",kind:"fn",detail:"os.Open(name string) (*os.File, error)",language:"go"},{label:"os.Create",kind:"fn",detail:"os.Create(name string) (*os.File, error)",language:"go"},{label:"os.ReadFile",kind:"fn",detail:"os.ReadFile(name string) ([]byte, error)",language:"go"},{label:"os.WriteFile",kind:"fn",detail:"os.WriteFile(name string, data []byte, perm fs.FileMode) error",language:"go"},{label:"os.Exit",kind:"fn",detail:"os.Exit(code int)",language:"go"},{label:"make",kind:"fn",detail:"make(t Type, size ...IntegerType) Type",language:"go"},{label:"append",kind:"fn",detail:"append(slice []Type, elems ...Type) []Type",language:"go"},{label:"len",kind:"fn",detail:"len(v Type) int",language:"go"},{label:"cap",kind:"fn",detail:"cap(v Type) int",language:"go"},{label:"copy",kind:"fn",detail:"copy(dst, src []Type) int",language:"go"},{label:"delete",kind:"fn",detail:"delete(m map[Type]Type1, key Type)",language:"go"},{label:"close",kind:"fn",detail:"close(c chan<- Type)",language:"go"},{label:"panic",kind:"fn",detail:"panic(v any)",language:"go"},{label:"recover",kind:"fn",detail:"recover() any",language:"go"},{label:"new",kind:"fn",detail:"new(Type) *Type",language:"go"},{label:"error",kind:"typ",detail:"built-in error interface",language:"go"},{label:"context.Context",kind:"typ",detail:"context.Context interface",language:"go"},{label:"sync.WaitGroup",kind:"typ",detail:"sync.WaitGroup",language:"go"},{label:"sync.Mutex",kind:"typ",detail:"sync.Mutex",language:"go"},{label:"fn",kind:"snip",detail:"function declaration",body:`func $1($2) $3 {
|
|
178
179
|
$4
|
|
179
180
|
}`,language:"go"},{label:"iferr",kind:"snip",detail:"if err != nil",body:`if err != nil {
|
|
180
181
|
return $1err
|
|
@@ -192,7 +193,7 @@ func main() {
|
|
|
192
193
|
$4
|
|
193
194
|
}`,language:"go"},{label:"interface",kind:"snip",detail:"interface type",body:`type $1 interface {
|
|
194
195
|
$2
|
|
195
|
-
}`,language:"go"}],
|
|
196
|
+
}`,language:"go"}],Ie={lineCommentToken:"//",keywords:Pn,types:On,completions:Hn},jn=new Set(["let","mut","const","static","fn","return","struct","enum","trait","impl","type","where","dyn","Self","if","else","match","loop","while","for","in","break","continue","ref","move","mod","use","pub","crate","super","self","extern","async","await","unsafe","Box","Rc","Arc","Cell","RefCell","drop","as","in","true","false"]),Nn=new Set(["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","bool","char","str","String","Vec","Box","Rc","Arc","Cell","RefCell","Mutex","RwLock","Option","Result","Some","None","Ok","Err","HashMap","HashSet","BTreeMap","BTreeSet","VecDeque","LinkedList","File","BufReader","BufWriter","Read","Write","BufRead","Iterator","IntoIterator","FromIterator","Extend","Display","Debug","Clone","Copy","Drop","Default","Send","Sync","Sized","Unpin","Error","From","Into","TryFrom","TryInto","Future","Stream","Pin"]),Wn=[{label:"println!",kind:"fn",detail:'println!("{}", value)',language:"rust"},{label:"print!",kind:"fn",detail:'print!("{}", value)',language:"rust"},{label:"eprintln!",kind:"fn",detail:'eprintln!("{}", err)',language:"rust"},{label:"format!",kind:"fn",detail:'format!("{}", value) -> String',language:"rust"},{label:"vec!",kind:"fn",detail:"vec![a, b, c]",language:"rust"},{label:"panic!",kind:"fn",detail:'panic!("message")',language:"rust"},{label:"assert!",kind:"fn",detail:"assert!(expr)",language:"rust"},{label:"assert_eq!",kind:"fn",detail:"assert_eq!(left, right)",language:"rust"},{label:"assert_ne!",kind:"fn",detail:"assert_ne!(left, right)",language:"rust"},{label:"todo!",kind:"fn",detail:"todo!() — marks unimplemented",language:"rust"},{label:"unreachable!",kind:"fn",detail:"unreachable!()",language:"rust"},{label:"unimplemented!",kind:"fn",detail:"unimplemented!()",language:"rust"},{label:"dbg!",kind:"fn",detail:"dbg!(expr) — prints to stderr",language:"rust"},{label:"iter",kind:"fn",detail:".iter() -> Iterator<Item = &T>",language:"rust"},{label:"iter_mut",kind:"fn",detail:".iter_mut() -> Iterator<Item = &mut T>",language:"rust"},{label:"into_iter",kind:"fn",detail:".into_iter() -> Iterator<Item = T>",language:"rust"},{label:"map",kind:"fn",detail:".map(|x| ...) -> Iterator",language:"rust"},{label:"filter",kind:"fn",detail:".filter(|x| ...) -> Iterator",language:"rust"},{label:"collect",kind:"fn",detail:".collect::<T>() -> T",language:"rust"},{label:"fold",kind:"fn",detail:".fold(init, |acc, x| ...) -> T",language:"rust"},{label:"enumerate",kind:"fn",detail:".enumerate() -> Iterator<(usize, T)>",language:"rust"},{label:"flatten",kind:"fn",detail:".flatten() -> Iterator<Item = T::Item>",language:"rust"},{label:"flat_map",kind:"fn",detail:".flat_map(|x| ...) -> Iterator",language:"rust"},{label:"chain",kind:"fn",detail:".chain(other) -> Iterator",language:"rust"},{label:"zip",kind:"fn",detail:".zip(other) -> Iterator<(A, B)>",language:"rust"},{label:"take",kind:"fn",detail:".take(n) -> Iterator",language:"rust"},{label:"skip",kind:"fn",detail:".skip(n) -> Iterator",language:"rust"},{label:"find",kind:"fn",detail:".find(|x| ...) -> Option<T>",language:"rust"},{label:"position",kind:"fn",detail:".position(|x| ...) -> Option<usize>",language:"rust"},{label:"count",kind:"fn",detail:".count() -> usize",language:"rust"},{label:"any",kind:"fn",detail:".any(|x| ...) -> bool",language:"rust"},{label:"all",kind:"fn",detail:".all(|x| ...) -> bool",language:"rust"},{label:"unwrap",kind:"fn",detail:".unwrap() -> T",language:"rust"},{label:"unwrap_or",kind:"fn",detail:".unwrap_or(default) -> T",language:"rust"},{label:"unwrap_or_else",kind:"fn",detail:".unwrap_or_else(|| ...) -> T",language:"rust"},{label:"expect",kind:"fn",detail:'.expect("msg") -> T',language:"rust"},{label:"is_some",kind:"fn",detail:".is_some() -> bool",language:"rust"},{label:"is_none",kind:"fn",detail:".is_none() -> bool",language:"rust"},{label:"is_ok",kind:"fn",detail:".is_ok() -> bool",language:"rust"},{label:"is_err",kind:"fn",detail:".is_err() -> bool",language:"rust"},{label:"map_err",kind:"fn",detail:".map_err(|e| ...) -> Result",language:"rust"},{label:"String",kind:"typ",detail:"owned UTF-8 string",language:"rust"},{label:"Vec<T>",kind:"typ",detail:"growable heap array",language:"rust"},{label:"Option<T>",kind:"typ",detail:"nullable value",language:"rust"},{label:"Result<T, E>",kind:"typ",detail:"fallible operation",language:"rust"},{label:"HashMap<K, V>",kind:"typ",detail:"hash map",language:"rust"},{label:"Arc<T>",kind:"typ",detail:"atomic reference counted",language:"rust"},{label:"Mutex<T>",kind:"typ",detail:"mutual exclusion lock",language:"rust"},{label:"fn",kind:"snip",detail:"function definition",body:`fn $1($2) -> $3 {
|
|
196
197
|
$4
|
|
197
198
|
}`,language:"rust"},{label:"impl",kind:"snip",detail:"impl block",body:`impl $1 {
|
|
198
199
|
$2
|
|
@@ -210,7 +211,7 @@ func main() {
|
|
|
210
211
|
}`,language:"rust"},{label:"test",kind:"snip",detail:"#[test] function",body:`#[test]
|
|
211
212
|
fn $1() {
|
|
212
213
|
$2
|
|
213
|
-
}`,language:"rust"}],
|
|
214
|
+
}`,language:"rust"}],Be={lineCommentToken:"//",keywords:jn,types:Nn,completions:Wn},Fn=new Set(["if","elsif","else","unless","then","end","case","when","in","while","until","for","do","loop","break","next","redo","retry","return","def","class","module","include","extend","prepend","attr_accessor","attr_reader","attr_writer","initialize","new","begin","rescue","ensure","raise","fail","public","private","protected","self","super","nil","true","false","defined?","respond_to?","send","method","instance_of?","is_a?","kind_of?","proc","lambda","yield","require","require_relative","load","autoload","freeze","frozen?","dup","clone","and","or","not"]),zn=new Set(["Integer","Float","String","Symbol","Array","Hash","Range","Regexp","NilClass","TrueClass","FalseClass","Numeric","IO","File","Dir","Pathname","Proc","Method","UnboundMethod","Fiber","Thread","Process","StandardError","RuntimeError","TypeError","ArgumentError","NameError","NoMethodError","IndexError","KeyError","StopIteration","IOError","SystemExit","Interrupt","Enumerable","Enumerator","Comparable","Struct","OpenStruct","Data","Time","Date","DateTime"]),qn=[{label:"puts",kind:"fn",detail:"puts(obj, ...) → nil",language:"ruby"},{label:"print",kind:"fn",detail:"print(obj, ...) → nil",language:"ruby"},{label:"p",kind:"fn",detail:"p(obj) → obj (inspect & print)",language:"ruby"},{label:"pp",kind:"fn",detail:"pp(obj) → obj (pretty-print)",language:"ruby"},{label:"gets",kind:"fn",detail:"gets(sep=$/) → String",language:"ruby"},{label:"raise",kind:"fn",detail:"raise(exception)",language:"ruby"},{label:"map",kind:"fn",detail:"array.map { |x| } → Array",language:"ruby"},{label:"select",kind:"fn",detail:"array.select { |x| } → Array",language:"ruby"},{label:"reject",kind:"fn",detail:"array.reject { |x| } → Array",language:"ruby"},{label:"reduce",kind:"fn",detail:"array.reduce(memo) { |acc, x| } → T",language:"ruby"},{label:"each",kind:"fn",detail:"array.each { |x| }",language:"ruby"},{label:"flat_map",kind:"fn",detail:"array.flat_map { |x| } → Array",language:"ruby"},{label:"any?",kind:"fn",detail:"array.any? { |x| } → bool",language:"ruby"},{label:"all?",kind:"fn",detail:"array.all? { |x| } → bool",language:"ruby"},{label:"none?",kind:"fn",detail:"array.none? { |x| } → bool",language:"ruby"},{label:"find",kind:"fn",detail:"array.find { |x| } → T",language:"ruby"},{label:"sort_by",kind:"fn",detail:"array.sort_by { |x| } → Array",language:"ruby"},{label:"group_by",kind:"fn",detail:"array.group_by { |x| } → Hash",language:"ruby"},{label:"first",kind:"fn",detail:"array.first(n?) → T | Array",language:"ruby"},{label:"last",kind:"fn",detail:"array.last(n?) → T | Array",language:"ruby"},{label:"flatten",kind:"fn",detail:"array.flatten(depth?) → Array",language:"ruby"},{label:"uniq",kind:"fn",detail:"array.uniq → Array",language:"ruby"},{label:"compact",kind:"fn",detail:"array.compact → Array (removes nil)",language:"ruby"},{label:"each_with_object",kind:"fn",detail:"enum.each_with_object(obj) { |x, acc| } → obj",language:"ruby"},{label:"merge",kind:"fn",detail:"hash.merge(other) → Hash",language:"ruby"},{label:"transform_values",kind:"fn",detail:"hash.transform_values { |v| } → Hash",language:"ruby"},{label:"transform_keys",kind:"fn",detail:"hash.transform_keys { |k| } → Hash",language:"ruby"},{label:"filter_map",kind:"fn",detail:"enum.filter_map { |x| x if ... } → Array",language:"ruby"},{label:"gsub",kind:"fn",detail:"str.gsub(pattern, replacement) → String",language:"ruby"},{label:"split",kind:"fn",detail:"str.split(sep) → Array",language:"ruby"},{label:"strip",kind:"fn",detail:"str.strip → String",language:"ruby"},{label:"chomp",kind:"fn",detail:"str.chomp → String",language:"ruby"},{label:"chars",kind:"fn",detail:"str.chars → Array<String>",language:"ruby"},{label:"String",kind:"typ",detail:"Ruby String class",language:"ruby"},{label:"Array",kind:"typ",detail:"Ruby Array class",language:"ruby"},{label:"Hash",kind:"typ",detail:"Ruby Hash class",language:"ruby"},{label:"Integer",kind:"typ",detail:"Ruby Integer class",language:"ruby"},{label:"Symbol",kind:"typ",detail:"Ruby Symbol class",language:"ruby"},{label:"def",kind:"snip",detail:"method definition",body:`def $1($2)
|
|
214
215
|
$3
|
|
215
216
|
end`,language:"ruby"},{label:"class",kind:"snip",detail:"class definition",body:`class $1
|
|
216
217
|
def initialize($2)
|
|
@@ -222,7 +223,7 @@ end`,language:"ruby"},{label:"trycatch",kind:"snip",detail:"begin/rescue",body:`
|
|
|
222
223
|
$1
|
|
223
224
|
rescue $2 => e
|
|
224
225
|
$3
|
|
225
|
-
end`,language:"ruby"}],
|
|
226
|
+
end`,language:"ruby"}],De={lineCommentToken:"#",keywords:Fn,types:zn,completions:qn},Un=new Set(["var","if","elseif","else","endif","switch","case","default","endswitch","while","endwhile","for","endfor","foreach","endforeach","do","break","continue","return","match","function","fn","static","abstract","final","class","interface","trait","enum","extends","implements","new","clone","instanceof","self","parent","static","public","protected","private","readonly","try","catch","finally","throw","namespace","use","as","require","include","require_once","include_once","echo","print","isset","unset","empty","list","yield","yield from","goto","declare","global","null","true","false","NULL","TRUE","FALSE"]),Gn=new Set(["int","float","string","bool","array","object","callable","iterable","void","null","never","mixed","static","self","parent","DateTime","DateTimeImmutable","DateInterval","Exception","InvalidArgumentException","RuntimeException","LogicException","ArrayObject","SplStack","SplQueue","SplFixedArray","PDO","PDOStatement","Closure","Generator","Fiber","Throwable","Error","TypeError","ValueError"]),Vn=[{label:"echo",kind:"kw",detail:'echo "string"',language:"php"},{label:"var_dump",kind:"fn",detail:"var_dump(mixed ...$value): void",language:"php"},{label:"print_r",kind:"fn",detail:"print_r(mixed $value, bool $return = false)",language:"php"},{label:"array_map",kind:"fn",detail:"array_map(?callable $callback, array $array): array",language:"php"},{label:"array_filter",kind:"fn",detail:"array_filter(array $array, ?callable $callback): array",language:"php"},{label:"array_reduce",kind:"fn",detail:"array_reduce(array $array, callable $callback, mixed $initial): mixed",language:"php"},{label:"array_merge",kind:"fn",detail:"array_merge(array ...$arrays): array",language:"php"},{label:"array_push",kind:"fn",detail:"array_push(array &$array, mixed ...$values): int",language:"php"},{label:"array_pop",kind:"fn",detail:"array_pop(array &$array): mixed",language:"php"},{label:"array_keys",kind:"fn",detail:"array_keys(array $array): array",language:"php"},{label:"array_values",kind:"fn",detail:"array_values(array $array): array",language:"php"},{label:"array_unique",kind:"fn",detail:"array_unique(array $array): array",language:"php"},{label:"array_slice",kind:"fn",detail:"array_slice(array $array, int $offset, ?int $length): array",language:"php"},{label:"in_array",kind:"fn",detail:"in_array(mixed $needle, array $haystack, bool $strict = false): bool",language:"php"},{label:"count",kind:"fn",detail:"count(array|Countable $value): int",language:"php"},{label:"implode",kind:"fn",detail:"implode(string $sep, array $array): string",language:"php"},{label:"explode",kind:"fn",detail:"explode(string $sep, string $str): array",language:"php"},{label:"strlen",kind:"fn",detail:"strlen(string $string): int",language:"php"},{label:"str_contains",kind:"fn",detail:"str_contains(string $haystack, string $needle): bool",language:"php"},{label:"str_starts_with",kind:"fn",detail:"str_starts_with(string $haystack, string $needle): bool",language:"php"},{label:"str_ends_with",kind:"fn",detail:"str_ends_with(string $haystack, string $needle): bool",language:"php"},{label:"str_replace",kind:"fn",detail:"str_replace(mixed $search, mixed $replace, mixed $subject): mixed",language:"php"},{label:"preg_match",kind:"fn",detail:"preg_match(string $pattern, string $subject, array &$matches): int",language:"php"},{label:"substr",kind:"fn",detail:"substr(string $string, int $offset, ?int $length): string",language:"php"},{label:"trim",kind:"fn",detail:"trim(string $string): string",language:"php"},{label:"strtolower",kind:"fn",detail:"strtolower(string $string): string",language:"php"},{label:"strtoupper",kind:"fn",detail:"strtoupper(string $string): string",language:"php"},{label:"sprintf",kind:"fn",detail:"sprintf(string $format, mixed ...$values): string",language:"php"},{label:"json_encode",kind:"fn",detail:"json_encode(mixed $value, int $flags = 0): string|false",language:"php"},{label:"json_decode",kind:"fn",detail:"json_decode(string $json, bool $assoc = false): mixed",language:"php"},{label:"int",kind:"typ",detail:"integer type",language:"php"},{label:"string",kind:"typ",detail:"string type",language:"php"},{label:"bool",kind:"typ",detail:"boolean type",language:"php"},{label:"array",kind:"typ",detail:"array type",language:"php"},{label:"mixed",kind:"typ",detail:"any type",language:"php"},{label:"fn",kind:"snip",detail:"function definition",body:`function $1($2): $3
|
|
226
227
|
{
|
|
227
228
|
$4
|
|
228
229
|
}`,language:"php"},{label:"class",kind:"snip",detail:"class definition",body:`class $1
|
|
@@ -237,7 +238,7 @@ end`,language:"ruby"}],Be={lineCommentToken:"#",keywords:Pn,types:On,completions
|
|
|
237
238
|
$3
|
|
238
239
|
}`,language:"php"},{label:"foreach",kind:"snip",detail:"foreach loop",body:`foreach ($1 as $2 => $3) {
|
|
239
240
|
$4
|
|
240
|
-
}`,language:"php"}],
|
|
241
|
+
}`,language:"php"}],Pe={lineCommentToken:"//",keywords:Un,types:Gn,completions:Vn},Kn=new Set(["func","var","let","const","class","struct","enum","protocol","extension","typealias","associatedtype","actor","macro","init","deinit","subscript","operator","precedencegroup","open","public","internal","fileprivate","private","static","class","final","override","required","convenience","lazy","weak","unowned","dynamic","mutating","nonmutating","indirect","nonisolated","if","else","guard","switch","case","default","for","in","while","repeat","break","continue","return","throw","fallthrough","defer","where","is","as","do","try","catch","throws","rethrows","async","await","import","nil","true","false","self","Self","super","any","some","inout","consuming","borrowing"]),Yn=new Set(["Int","Int8","Int16","Int32","Int64","UInt","UInt8","UInt16","UInt32","UInt64","Float","Double","Bool","Character","String","Optional","Result","Array","Dictionary","Set","Sequence","Collection","ArraySlice","Substring","Void","Date","URL","UUID","Data","Codable","Encodable","Decodable","Hashable","Equatable","Comparable","Identifiable","ObservableObject","Published","View","Text","Button","Image","VStack","HStack","ZStack","List","Error","LocalizedError","Task","TaskGroup","Actor","MainActor","AsyncStream"]),Xn=[{label:"print",kind:"fn",detail:'print(_ items: Any..., separator: String = " ")',language:"swift"},{label:"debugPrint",kind:"fn",detail:"debugPrint(_ items: Any...)",language:"swift"},{label:"map",kind:"fn",detail:".map { element in } → [T]",language:"swift"},{label:"filter",kind:"fn",detail:".filter { condition } → [T]",language:"swift"},{label:"reduce",kind:"fn",detail:".reduce(initial) { acc, x in } → T",language:"swift"},{label:"forEach",kind:"fn",detail:".forEach { element in }",language:"swift"},{label:"compactMap",kind:"fn",detail:".compactMap { element in } → [T]",language:"swift"},{label:"flatMap",kind:"fn",detail:".flatMap { element in } → [T]",language:"swift"},{label:"sorted",kind:"fn",detail:".sorted(by: { a, b in a < b }) → [T]",language:"swift"},{label:"first",kind:"fn",detail:".first(where: { condition }) → T?",language:"swift"},{label:"contains",kind:"fn",detail:".contains(where: { condition }) → Bool",language:"swift"},{label:"map",kind:"fn",detail:"optional.map { value in } → T?",language:"swift"},{label:"flatMap",kind:"fn",detail:"optional.flatMap { value in } → T?",language:"swift"},{label:"String",kind:"fn",detail:"String(describing:) → String",language:"swift"},{label:"hasPrefix",kind:"fn",detail:"str.hasPrefix(_ prefix: String) → Bool",language:"swift"},{label:"hasSuffix",kind:"fn",detail:"str.hasSuffix(_ suffix: String) → Bool",language:"swift"},{label:"contains",kind:"fn",detail:"str.contains(_ substring: String) → Bool",language:"swift"},{label:"JSONEncoder",kind:"fn",detail:"JSONEncoder().encode(value) throws → Data",language:"swift"},{label:"JSONDecoder",kind:"fn",detail:"JSONDecoder().decode(T.self, from: data) throws → T",language:"swift"},{label:"Int",kind:"typ",detail:"signed integer",language:"swift"},{label:"String",kind:"typ",detail:"Unicode string",language:"swift"},{label:"Bool",kind:"typ",detail:"boolean value",language:"swift"},{label:"Double",kind:"typ",detail:"64-bit floating point",language:"swift"},{label:"Array",kind:"typ",detail:"ordered collection",language:"swift"},{label:"Dictionary",kind:"typ",detail:"key-value collection",language:"swift"},{label:"Optional",kind:"typ",detail:"nullable value",language:"swift"},{label:"fn",kind:"snip",detail:"function definition",body:`func $1($2) -> $3 {
|
|
241
242
|
$4
|
|
242
243
|
}`,language:"swift"},{label:"struct",kind:"snip",detail:"struct definition",body:`struct $1 {
|
|
243
244
|
$2
|
|
@@ -262,12 +263,12 @@ default:
|
|
|
262
263
|
$1
|
|
263
264
|
} catch {
|
|
264
265
|
$2
|
|
265
|
-
}`,language:"swift"}],
|
|
266
|
-
`)}function
|
|
266
|
+
}`,language:"swift"}],Oe={lineCommentToken:"//",keywords:Kn,types:Yn,completions:Xn},et={typescript:Ce.keywords,javascript:ve.keywords,python:Te.keywords,java:Ee.keywords,c:Se.keywords,cpp:$e.keywords,css:Re.keywords,json:Me.keywords,markdown:de.keywords,text:de.keywords,sql:Le.keywords,csharp:Ae.keywords,go:Ie.keywords,rust:Be.keywords,ruby:De.keywords,php:Pe.keywords,swift:Oe.keywords},tt={typescript:Ce.types,javascript:ve.types,python:Te.types,java:Ee.types,c:Se.types,cpp:$e.types,css:Re.types,json:Me.types,markdown:de.types,text:de.types,sql:Le.types,csharp:Ae.types,go:Ie.types,rust:Be.types,ruby:De.types,php:Pe.types,swift:Oe.types},Jn={typescript:Ce.lineCommentToken,javascript:ve.lineCommentToken,python:Te.lineCommentToken,java:Ee.lineCommentToken,c:Se.lineCommentToken,cpp:$e.lineCommentToken,css:Re.lineCommentToken,json:Me.lineCommentToken,markdown:de.lineCommentToken,text:"",sql:Le.lineCommentToken,csharp:Ae.lineCommentToken,go:Ie.lineCommentToken,rust:Be.lineCommentToken,ruby:De.lineCommentToken,php:Pe.lineCommentToken,swift:Oe.lineCommentToken},Zn={typescript:Ce.completions,javascript:ve.completions,python:Te.completions,java:Ee.completions,c:Se.completions,cpp:$e.completions,css:Re.completions,json:Me.completions,markdown:de.completions,text:[],sql:Le.completions,csharp:Ae.completions,go:Ie.completions,rust:Be.completions,ruby:De.completions,php:Pe.completions,swift:Oe.completions};function it(s,e={}){var t,i;if(e.provideTokens)return e.provideTokens(s,e.language??"typescript");const n=[],a=s.length;let r=0;const o=(u,m,g)=>{g>m&&n.push({cls:u,start:m,end:g})},c=e.language??"typescript",d=et[c]??et.typescript,l=tt[c]??tt.typescript,h=(t=e.extraKeywords)!=null&&t.size?new Set([...d,...e.extraKeywords]):d,p=(i=e.extraTypes)!=null&&i.size?new Set([...l,...e.extraTypes]):l;for(;r<a;){if(s[r]==="/"&&s[r+1]==="/"){o("cmt",r,a);break}if(s[r]==="*"||s[r]==="/"&&s[r+1]==="*"){o("cmt",r,a);break}if(s[r]==="#"&&c==="python"){o("cmt",r,a);break}if(s[r]==="#"&&(c==="c"||c==="cpp")){let u=r+1;for(;u<a&&/\w/.test(s[u]);)u++;o("dec",r,u),r=u;continue}if(s[r]==="@"){let u=r+1;for(;u<a&&/\w/.test(s[u]);)u++;o("dec",r,u),r=u;continue}if(s[r]==='"'||s[r]==="'"||s[r]==="`"){const u=s[r];let m=r+1;for(;m<a;){if(s[m]==="\\"){m+=2;continue}if(s[m]===u){m++;break}m++}o("str",r,m),r=m;continue}if(/\d/.test(s[r])&&(r===0||!/\w/.test(s[r-1]))){let u=r;for(;u<a&&/[\d._xXa-fA-F]/.test(s[u]);)u++;o("num",r,u),r=u;continue}if(/[a-zA-Z_$]/.test(s[r])){let u=r;for(;u<a&&/[\w$]/.test(s[u]);)u++;const m=s.slice(r,u);h.has(m)?o("kw",r,u):p.has(m)?o("typ",r,u):u<a&&s[u]==="("?o("fn",r,u):/^[A-Z]/.test(m)&&o("cls",r,u),r=u;continue}if(/[=<>!&|+\-*/%^~?:,;.[\]{}()]/.test(s[r])){o("op",r,r+1),r++;continue}r++}return n}function Rt(s,e){const t=new Array(s.length).fill("");for(const i of e)for(let n=i.start;n<i.end;n++)t[n]=i.cls;return t}class Qn{constructor(e=5e3){_(this,"_cache",new Map),_(this,"_maxSize"),_(this,"_hits",0),_(this,"_misses",0),_(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 ea=22,nt=6,Mt=100,ta=60,ee=14,Lt=20,X=7.82,ia=13,na=2,aa=80,z=2,J=1.1,ge=3,sa=120,ra=700,oa=120,ce=15e6;function j(s,e,t){const i=document.createElement(s);return e&&(i.className=e),i}function me(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function He(s,e=document.documentElement){return getComputedStyle(e).getPropertyValue(s).trim()}function At(s,e){const t=s.replace("#",""),i=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return`rgba(${i},${n},${a},${e})`}function at(s,e,t,i,n){const a=Math.max(0,s*n-t),r=Math.max(0,s*z-i),o=(a>0?e/a:0)*r,c=Math.max(20,t/n*z),d=e/n*z-o;return{mmScroll:o,sliderTop:d,sliderHeight:c}}function la(s,e,t,i,n){const a=Math.max(0,e*n-t),r=Math.max(0,e*z-i);if(a<=0)return 0;const o=z/n-r/a;if(Math.abs(o)<1e-9){const c=Math.max(20,t/n*z);return Math.max(0,Math.min(a,s/Math.max(1,i-c)*a))}return Math.max(0,Math.min(a,s/o))}function da(s,e,t,i,n,a){const r=Math.max(0,e*a-i),o=Math.max(0,e*z-n);if(r<=0)return 0;const c=t/r*o,d=(s+c)/z;return Math.max(0,Math.min(r,d*a-i/2))}function st(s){const e=t=>{const i=s(t);return i.startsWith("#")&&i.length===7?At(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=s("--text2");return t.startsWith("#")&&t.length===7?At(t,.28):"rgba(150,148,140,0.28)"})()}}function ca(s){var e,t,i,n;const{canvas:a,doc:r,firstLine:o,lastLine:c,subPx:d,wrapperWidth:l,canvasHeight:h,cursorRow:p,sel:u,findMatches:m,findIdx:g,sliderTop:w,sliderHeight:k,colors:C,getCssVar:y,dpr:f}=s,b=a.getContext("2d");if(!b)return;b.setTransform(f,0,0,f,0,0);const x=y("--mm-bg")||"#0d0d0f",$=y("--mm-dim")||"rgba(0,0,0,.30)",S=y("--mm-edge")||"rgba(255,255,255,.18)",T=y("--mm-slider")||"rgba(255,255,255,.07)",L=y("--sel-bg")||"rgba(110,159,255,.22)",M=y("--cur-line-bg")||"rgba(255,255,255,.05)",B=y("--find-border")||"rgba(234,180,86,.50)",te=y("--find-cur-bg")||"rgba(234,180,86,.80)",re=H=>(H-o)*z;if(b.fillStyle=x,b.fillRect(0,0,l,h),p>=o&&p<c&&(b.fillStyle=M,b.fillRect(0,re(p),l,z)),u){const H=Math.max(o,u.ar),q=Math.min(c-1,u.fr);q>=H&&(b.fillStyle=L,b.fillRect(0,re(H),l,(q-H+1)*z))}for(const H of m){if(H.row<o||H.row>=c)continue;const q=g>=0&&((e=m[g])==null?void 0:e.row)===H.row&&((t=m[g])==null?void 0:t.col)===H.col;b.fillStyle=q?te:B,b.fillRect(ge+H.col*J,re(H.row),Math.max(3,H.len*J),z)}const Z=Math.floor((l-ge)/J);for(let H=o;H<c;H++){const q=r[H]??"";if(!q.trim())continue;const oe=re(H),ue=1.5,ye=`${H}:0:none`;let le=((i=s.tokenCache)==null?void 0:i.get(ye,q))??null;le||(le=it(q,{language:s.language,provideTokens:s.provideTokens}),(n=s.tokenCache)==null||n.set(ye,q,le));let V=0;for(const K of le){if(K.start>=Z)break;K.start>V&&(b.fillStyle=C.txt,b.fillRect(ge+V*J,oe,(Math.min(K.start,Z)-V)*J,ue));const yt=C[K.cls]??C.txt,xe=Math.min(K.end,Z)-K.start;xe>0&&(b.fillStyle=yt,b.fillRect(ge+K.start*J,oe,xe*J,ue)),V=Math.max(V,Math.min(K.end,Z))}const Xe=Math.min(q.length,Z);V<Xe&&(b.fillStyle=C.txt,b.fillRect(ge+V*J,oe,(Xe-V)*J,ue))}const Q=w+d,ie=Q+k;b.fillStyle=$,Q>0&&b.fillRect(0,0,l,Q),ie<h&&b.fillRect(0,ie,l,h-ie),b.fillStyle=T,b.fillRect(0,Q,l,k),b.fillStyle=S,b.fillRect(0,Math.max(0,Q),l,1),b.fillRect(0,Math.max(0,ie-1),l,1)}function It(s,e){return{fileId:s,doc:[...e],cur:{row:0,col:0},sel:null,dirty:!1,undoStack:[],redoStack:[],scrollTop:0}}function ha(s,e){switch(s.kind){case"insert":e.splice(s.row,0,...s.lines);break;case"delete":e.splice(s.row,s.count);break;case"replace":e.splice(s.row,s.oldLines.length,...s.newLines);break}}function pa(s,e){switch(s.kind){case"insert":e.splice(s.row,s.lines.length);break;case"delete":e.splice(s.row,0,...s.removed);break;case"replace":e.splice(s.row,s.newLines.length,...s.oldLines);break}}function E(s,e=Mt,t,i,n,a=[],r=[]){const o={op:t,beforeCur:{...i},beforeSel:n?{...n}:null,afterCur:{...s.cur},afterSel:s.sel?{...s.sel}:null,beforeExtra:a.map(c=>({...c,sel:c.sel?{...c.sel}:null})),afterExtra:r.map(c=>({...c,sel:c.sel?{...c.sel}:null}))};s.undoStack.push(o),s.undoStack.length>e&&s.undoStack.shift(),s.redoStack=[],s.dirty=!0}function ua(s){if(!s.undoStack.length)return null;const e=s.undoStack.pop();return s.redoStack.push(e),pa(e.op,s.doc),s.cur={...e.beforeCur},s.sel=e.beforeSel?{...e.beforeSel}:null,e.beforeExtra.map(t=>({...t,sel:t.sel?{...t.sel}:null}))}function ga(s){if(!s.redoStack.length)return null;const e=s.redoStack.pop();return s.undoStack.push(e),ha(e.op,s.doc),s.cur={...e.afterCur},s.sel=e.afterSel?{...e.afterSel}:null,e.afterExtra.map(t=>({...t,sel:t.sel?{...t.sel}:null}))}function R(s){const{doc:e,cur:t}=s;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 O(s){const{ar:e,ac:t,fr:i,fc:n}=s;return e<i||e===i&&t<=n?s:{ar:i,ac:n,fr:e,fc:t}}function Bt(s,e,t){if(!s)return null;const i=O(s);return e<i.ar||e>i.fr?null:{start:e===i.ar?i.ac:0,end:e===i.fr?i.fc:t}}function ma(s){if(!s.sel)return 0;const e=O(s.sel);let t=0;for(let i=e.ar;i<=e.fr;i++){const n=s.doc[i]??"",a=i===e.ar?e.ac:0,r=i===e.fr?e.fc:n.length;t+=r-a}return t}function Dt(s){if(!s.sel)return"";const e=O(s.sel),t=[];for(let i=e.ar;i<=e.fr;i++){const n=s.doc[i]??"";t.push(n.slice(i===e.ar?e.ac:0,i===e.fr?e.fc:n.length))}return t.join(`
|
|
267
|
+
`)}function he(s,e){const t=Math.min(s.length,e.length);let i=0;for(;i<t&&s[i]===e[i];)i++;if(i===s.length&&i===e.length)return{row:i,oldLines:[],newLines:[]};let n=s.length-1,a=e.length-1;for(;n>i&&a>i&&s[n]===e[a];)n--,a--;return{row:i,oldLines:s.slice(i,n+1),newLines:e.slice(i,a+1)}}function U(s){const e=s.sel;if(!e)return s.cur;const t=O(e),i=(s.doc[t.ar]??"").slice(0,t.ac),n=(s.doc[t.fr]??"").slice(t.fc);return s.doc.splice(t.ar,t.fr-t.ar+1,i+n),s.sel=null,{row:t.ar,col:t.ac}}function Pt(s){return s.split(`
|
|
267
268
|
`)}function D(s){return s.join(`
|
|
268
|
-
`)}function He(s){return(s.match(/^(\s*)/)??["",""])[1]}function je(s){return" ".repeat(Math.max(0,s))}function Lt(s){return/[\w$]/.test(s)}function At(s,e,t=Lt){let i=e;for(;i>0&&t(s[i-1]);)i--;return i}function It(s,e,t=Lt){let i=e;for(;i<s.length&&t(s[i]);)i++;return i}function nt(s,e){let t=0,i=null;return(...n)=>{const a=Date.now(),r=e-(a-t);r<=0?(i!==null&&(clearTimeout(i),i=null),t=a,s(...n)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,s(...n)},r))}}function ca(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function Bt(s,e,t,i){s.cursors.some(n=>n.row===e&&n.col===t)||s.cursors.push({row:e,col:t,sel:i})}function at(s){s.cursors=[],s.searchWord="",s.lastMatchRow=-1,s.lastMatchCol=-1}function ha(s,e,t,i,n){const a=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((l,h)=>({row:l.row,col:l.col,isPrimary:!1,idx:h+1}))];a.sort((l,h)=>h.row!==l.row?h.row-l.row:h.col-l.col);const r=s.map(l=>l);let o=e,c=t;const d=i.map(l=>({...l}));for(const l of a){const h=r[l.row]??"";r[l.row]=h.slice(0,l.col)+n+h.slice(l.col);for(const p of a)p!==l&&p.row===l.row&&p.col>=l.col&&(p.col+=n.length);l.col+=n.length}for(const l of a)l.isPrimary?(o=l.row,c=l.col):(d[l.idx-1].row=l.row,d[l.idx-1].col=l.col);return{doc:r,primaryRow:o,primaryCol:c,extraCursors:d}}function st(s,e,t,i,n,a){const r=[{row:e,col:t,sel:i,isPrimary:!0,idx:0},...n.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 o=s.slice();let c=e,d=t;const l=n.map(h=>({...h}));for(const h of r){const p=a(o,h.row,h.col,h.sel);if(!p)continue;const{fromRow:u,fromCol:m,toRow:g,toCol:w}=p;if(u===g){const k=o[u]??"";o[u]=k.slice(0,m)+k.slice(w)}else{const k=o[u]??"",C=o[g]??"";o[u]=k.slice(0,m)+C.slice(w),o.splice(u+1,g-u)}h.isPrimary?(c=u,d=m):(l[h.idx-1].row=u,l[h.idx-1].col=m,l[h.idx-1].sel=null)}return{doc:o,primaryRow:c,primaryCol:d,extraCursors:l}}function pa(s,e,t,i,n,a){let r=s.searchWord;if(!r){if(n&&n.ar===n.fr&&(r=(e[n.ar]??"").slice(n.ac,n.fc),r))return s.searchWord=r,s.lastMatchRow=n.fr,s.lastMatchCol=n.fc,{word:r,sel:{ar:n.ar,ac:n.ac,fr:n.fr,fc:n.fc},row:n.fr,col:n.fc};if(a!=null&&a(t))return null;const d=e[t]??"",l=At(d,i),h=It(d,i);return r=d.slice(l,h),r?(s.searchWord=r,s.lastMatchRow=t,s.lastMatchCol=h,{word:r,sel:{ar:t,ac:l,fr:t,fc:h},row:t,col:h}):null}const o=s.lastMatchRow,c=s.lastMatchCol;for(let d=o;d<e.length;d++){if(a!=null&&a(d))continue;const l=e[d]??"";let h=d===o?c:0;for(;h<=l.length-r.length;){const p=l.indexOf(r,h);if(p<0)break;const u=p===0||!/\w/.test(l[p-1]),m=p+r.length>=l.length||!/\w/.test(l[p+r.length]);if(u&&m)return s.lastMatchRow=d,s.lastMatchCol=p+r.length,{word:r,sel:{ar:d,ac:p,fr:d,fc:p+r.length},row:d,col:p+r.length};h=p+1}}for(let d=0;d<=o;d++){if(a!=null&&a(d))continue;const l=e[d]??"",h=d===o?c:l.length;let p=0;for(;p<h;){const u=l.indexOf(r,p);if(u<0||u>=h)break;const m=u===0||!/\w/.test(l[u-1]),g=u+r.length>=l.length||!/\w/.test(l[u+r.length]);if(m&&g)return s.lastMatchRow=d,s.lastMatchCol=u+r.length,{word:r,sel:{ar:d,ac:u,fr:d,fc:u+r.length},row:d,col:u+r.length};p=u+1}}return null}function ua(s,e,t){if(!t||s.length<=e)return[s];const i=[];let n=0;for(;n<s.length;){if(s.length-n<=e){i.push(s.slice(n));break}const a=n+e;let r=-1;for(let o=a;o>n;o--)if(s[o-1]===" "){r=o;break}r===-1?(i.push(s.slice(n,a)),n=a):(i.push(s.slice(n,r)),n=r)}return i}function ga(s,e,t){return!t||s.length<=e?1:Math.max(1,Math.ceil(s.length/e))}function Dt(s,e,t,i,n,a){const r=n!==void 0&&a!==void 0,o=n??0,c=a??s.length-1;if(r&&!t&&i.size===0){const g=[],w=[];for(let k=o;k<=c&&k<s.length;k++){const C=s[k]??"";g[k]=[C],w.push({docLine:k,segIdx:0,text:C})}return{segments:g,visualRows:w,docToVisArr:null,totalVisualRows:s.length,windowVisStart:o}}const d=new Array(s.length),l=new Array(s.length),h=[];let p=0,u=-1,m=0;for(let g=0;g<s.length;g++){if(l[g]=p,g>0&&g<=u){d[g]=[s[g]??""];continue}if(r&&g===o&&(m=p),!r||g>=o&&g<=c){const w=ua(s[g]??"",e,t);d[g]=w,w.forEach((k,C)=>h.push({docLine:g,segIdx:C,text:k})),p+=w.length}else d[g]=[],p+=ga(s[g]??"",e,t);i.has(g)&&(u=i.get(g))}return{segments:d,visualRows:h,docToVisArr:l,totalVisualRows:p,windowVisStart:m}}function ae(s,e,t){const i=s.segments[e];if(!i||i.length===0)return{visRow:s.docToVisArr!==null?s.docToVisArr[e]??e:e,colInSeg:0};const n=s.docToVisArr!==null?s.docToVisArr[e]??e:e;let a=t;for(let r=0;r<i.length;r++){if(a<=i[r].length||r===i.length-1)return{visRow:n+r,colInSeg:Math.min(a,i[r].length)};a-=i[r].length}return{visRow:n,colInSeg:0}}function me(s,e,t){var i,n;const a=e-s.windowVisStart,r=s.visualRows[a];if(!r)return s.docToVisArr===null?{row:Math.max(0,Math.min(s.totalVisualRows-1,e)),col:t}:{row:0,col:0};const o=s.segments[r.docLine]??[""];let c=Math.min(t,((i=o[r.segIdx])==null?void 0:i.length)??0);for(let d=0;d<r.segIdx;d++)c+=((n=o[d])==null?void 0:n.length)??0;return{row:r.docLine,col:c}}function ma(s,e){const t=a=>/[\w$]/.test(a);let i=e;for(;i<s.length&&t(s[i]);)i++;let n=e;for(;n>0&&t(s[n-1]);)n--;if(n===i)return"";if(n>0&&s[n-1]==="."){let a=n-1,r=a;for(;r>0&&t(s[r-1]);)r--;if(r<a)return s.slice(r,i)}return s.slice(n,i)}const ba={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 fa(s,e){const t=ba[s];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}const ya=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function Pt(s){const e=s.trim();if(!e)return null;try{const t=rt(e);return t===e?null:t}catch{return null}}function rt(s){if(s.includes(">")){const t=s.indexOf(">");return ot(s.slice(0,t),rt(s.slice(t+1)))}if(s.includes("+"))return s.split("+").map(t=>rt(t.trim())).join(`
|
|
269
|
-
`);const e=s.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,n)=>
|
|
270
|
-
`)}return
|
|
269
|
+
`)}function je(s){return(s.match(/^(\s*)/)??["",""])[1]}function Ne(s){return" ".repeat(Math.max(0,s))}function Ot(s){return/[\w$]/.test(s)}function Ht(s,e,t=Ot){let i=e;for(;i>0&&t(s[i-1]);)i--;return i}function jt(s,e,t=Ot){let i=e;for(;i<s.length&&t(s[i]);)i++;return i}function rt(s,e){let t=0,i=null;return(...n)=>{const a=Date.now(),r=e-(a-t);r<=0?(i!==null&&(clearTimeout(i),i=null),t=a,s(...n)):i===null&&(i=setTimeout(()=>{t=Date.now(),i=null,s(...n)},r))}}function fa(){return{cursors:[],searchWord:"",lastMatchRow:-1,lastMatchCol:-1}}function Nt(s,e,t,i){s.cursors.some(n=>n.row===e&&n.col===t)||s.cursors.push({row:e,col:t,sel:i})}function ot(s){s.cursors=[],s.searchWord="",s.lastMatchRow=-1,s.lastMatchCol=-1}function ba(s,e,t,i,n){const a=[{row:e,col:t,isPrimary:!0,idx:0},...i.map((l,h)=>({row:l.row,col:l.col,isPrimary:!1,idx:h+1}))];a.sort((l,h)=>h.row!==l.row?h.row-l.row:h.col-l.col);const r=s.map(l=>l);let o=e,c=t;const d=i.map(l=>({...l}));for(const l of a){const h=r[l.row]??"";r[l.row]=h.slice(0,l.col)+n+h.slice(l.col);for(const p of a)p!==l&&p.row===l.row&&p.col>=l.col&&(p.col+=n.length);l.col+=n.length}for(const l of a)l.isPrimary?(o=l.row,c=l.col):(d[l.idx-1].row=l.row,d[l.idx-1].col=l.col);return{doc:r,primaryRow:o,primaryCol:c,extraCursors:d}}function lt(s,e,t,i,n,a){const r=[{row:e,col:t,sel:i,isPrimary:!0,idx:0},...n.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 o=s.slice();let c=e,d=t;const l=n.map(h=>({...h}));for(const h of r){const p=a(o,h.row,h.col,h.sel);if(!p)continue;const{fromRow:u,fromCol:m,toRow:g,toCol:w}=p;if(u===g){const k=o[u]??"";o[u]=k.slice(0,m)+k.slice(w)}else{const k=o[u]??"",C=o[g]??"";o[u]=k.slice(0,m)+C.slice(w),o.splice(u+1,g-u)}h.isPrimary?(c=u,d=m):(l[h.idx-1].row=u,l[h.idx-1].col=m,l[h.idx-1].sel=null)}return{doc:o,primaryRow:c,primaryCol:d,extraCursors:l}}function ya(s,e,t,i,n,a){let r=s.searchWord;if(!r){if(n&&n.ar===n.fr&&(r=(e[n.ar]??"").slice(n.ac,n.fc),r))return s.searchWord=r,s.lastMatchRow=n.fr,s.lastMatchCol=n.fc,{word:r,sel:{ar:n.ar,ac:n.ac,fr:n.fr,fc:n.fc},row:n.fr,col:n.fc};if(a!=null&&a(t))return null;const d=e[t]??"",l=Ht(d,i),h=jt(d,i);return r=d.slice(l,h),r?(s.searchWord=r,s.lastMatchRow=t,s.lastMatchCol=h,{word:r,sel:{ar:t,ac:l,fr:t,fc:h},row:t,col:h}):null}const o=s.lastMatchRow,c=s.lastMatchCol;for(let d=o;d<e.length;d++){if(a!=null&&a(d))continue;const l=e[d]??"";let h=d===o?c:0;for(;h<=l.length-r.length;){const p=l.indexOf(r,h);if(p<0)break;const u=p===0||!/\w/.test(l[p-1]),m=p+r.length>=l.length||!/\w/.test(l[p+r.length]);if(u&&m)return s.lastMatchRow=d,s.lastMatchCol=p+r.length,{word:r,sel:{ar:d,ac:p,fr:d,fc:p+r.length},row:d,col:p+r.length};h=p+1}}for(let d=0;d<=o;d++){if(a!=null&&a(d))continue;const l=e[d]??"",h=d===o?c:l.length;let p=0;for(;p<h;){const u=l.indexOf(r,p);if(u<0||u>=h)break;const m=u===0||!/\w/.test(l[u-1]),g=u+r.length>=l.length||!/\w/.test(l[u+r.length]);if(m&&g)return s.lastMatchRow=d,s.lastMatchCol=u+r.length,{word:r,sel:{ar:d,ac:u,fr:d,fc:u+r.length},row:d,col:u+r.length};p=u+1}}return null}function xa(s,e,t){if(!t||s.length<=e)return[s];const i=[];let n=0;for(;n<s.length;){if(s.length-n<=e){i.push(s.slice(n));break}const a=n+e;let r=-1;for(let o=a;o>n;o--)if(s[o-1]===" "){r=o;break}r===-1?(i.push(s.slice(n,a)),n=a):(i.push(s.slice(n,r)),n=r)}return i}function ka(s,e,t){return!t||s.length<=e?1:Math.max(1,Math.ceil(s.length/e))}function Wt(s,e,t,i,n,a){const r=n!==void 0&&a!==void 0,o=n??0,c=a??s.length-1;if(r&&!t&&i.size===0){const g=[],w=[];for(let k=o;k<=c&&k<s.length;k++){const C=s[k]??"";g[k]=[C],w.push({docLine:k,segIdx:0,text:C})}return{segments:g,visualRows:w,docToVisArr:null,totalVisualRows:s.length,windowVisStart:o}}const d=new Array(s.length),l=new Array(s.length),h=[];let p=0,u=-1,m=0;for(let g=0;g<s.length;g++){if(l[g]=p,g>0&&g<=u){d[g]=[s[g]??""];continue}if(r&&g===o&&(m=p),!r||g>=o&&g<=c){const w=xa(s[g]??"",e,t);d[g]=w,w.forEach((k,C)=>h.push({docLine:g,segIdx:C,text:k})),p+=w.length}else d[g]=[],p+=ka(s[g]??"",e,t);i.has(g)&&(u=i.get(g))}return{segments:d,visualRows:h,docToVisArr:l,totalVisualRows:p,windowVisStart:m}}function se(s,e,t){const i=s.segments[e];if(!i||i.length===0)return{visRow:s.docToVisArr!==null?s.docToVisArr[e]??e:e,colInSeg:0};const n=s.docToVisArr!==null?s.docToVisArr[e]??e:e;let a=t;for(let r=0;r<i.length;r++){if(a<=i[r].length||r===i.length-1)return{visRow:n+r,colInSeg:Math.min(a,i[r].length)};a-=i[r].length}return{visRow:n,colInSeg:0}}function fe(s,e,t){var i,n;const a=e-s.windowVisStart,r=s.visualRows[a];if(!r)return s.docToVisArr===null?{row:Math.max(0,Math.min(s.totalVisualRows-1,e)),col:t}:{row:0,col:0};const o=s.segments[r.docLine]??[""];let c=Math.min(t,((i=o[r.segIdx])==null?void 0:i.length)??0);for(let d=0;d<r.segIdx;d++)c+=((n=o[d])==null?void 0:n.length)??0;return{row:r.docLine,col:c}}function wa(s,e){const t=a=>/[\w$]/.test(a);let i=e;for(;i<s.length&&t(s[i]);)i++;let n=e;for(;n>0&&t(s[n-1]);)n--;if(n===i)return"";if(n>0&&s[n-1]==="."){let a=n-1,r=a;for(;r>0&&t(s[r-1]);)r--;if(r<a)return s.slice(r,i)}return s.slice(n,i)}const _a={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 va(s,e){const t=_a[s];return!t||t.language&&!(Array.isArray(t.language)?t.language:[t.language]).includes(e)?null:t}const Ca=new Set(["img","input","br","hr","meta","link","area","base","col","embed","param","source","track","wbr"]);function Ft(s){const e=s.trim();if(!e)return null;try{const t=dt(e);return t===e?null:t}catch{return null}}function dt(s){if(s.includes(">")){const t=s.indexOf(">");return ct(s.slice(0,t),dt(s.slice(t+1)))}if(s.includes("+"))return s.split("+").map(t=>dt(t.trim())).join(`
|
|
270
|
+
`);const e=s.match(/^(.+)\*(\d+)$/);if(e){const t=parseInt(e[2],10);return Array.from({length:t},(i,n)=>ct(e[1],`$${n+1}`)).join(`
|
|
271
|
+
`)}return ct(s,"$1")}function ct(s,e){const t=s.match(/#([\w-]+)/),i=s.match(/\.([\w.-]+)/g),n=s.match(/\[([^\]]+)\]/);let a=s.replace(/#[\w-]+/g,"").replace(/\.[\w.-]+/g,"").replace(/\[[^\]]+\]/g,"").trim()||"div",r="";return t&&(r+=` id="${t[1]}"`),i&&(r+=` class="${i.map(o=>o.slice(1)).join(" ")}"`),n&&(r+=` ${n[1]}`),Ca.has(a)?`<${a}${r}>`:`<${a}${r}>${e}</${a}>`}function zt(s,e){let t=e;for(;t>0&&/[\w#.[\]*>+{}()$@:-]/.test(s[t-1]);)t--;const i=s.slice(t,e);return i.length<2?null:{abbr:i,start:t}}const Ta=[{label:"fn",kind:"snip",detail:"function declaration",description:`Declares a named function.
|
|
271
272
|
|
|
272
273
|
function name(params) {
|
|
273
274
|
// body
|
|
@@ -343,7 +344,7 @@ switch (expr) {
|
|
|
343
344
|
break;
|
|
344
345
|
default:
|
|
345
346
|
$4
|
|
346
|
-
}`}],
|
|
347
|
+
}`}],Ea=[{label:"flex",kind:"snip",detail:"flexbox container",description:`Sets up a flex container with centered alignment.
|
|
347
348
|
|
|
348
349
|
display: flex;
|
|
349
350
|
align-items: center;
|
|
@@ -371,7 +372,7 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
371
372
|
to { $3 }
|
|
372
373
|
}`,language:["css"]},{label:"var",kind:"snip",detail:"CSS custom property",description:`Declares a CSS custom property (variable).
|
|
373
374
|
|
|
374
|
-
--name: value;`,body:"--$1: $2;",language:["css"]}],
|
|
375
|
+
--name: value;`,body:"--$1: $2;",language:["css"]}],Sa=[{label:"accordion",kind:"snip",detail:"HTML details/summary",description:`An accessible accordion using the native <details> and <summary> elements.
|
|
375
376
|
|
|
376
377
|
<details>
|
|
377
378
|
<summary>Title</summary>
|
|
@@ -419,7 +420,7 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
419
420
|
<td>$2</td>
|
|
420
421
|
</tr>
|
|
421
422
|
</tbody>
|
|
422
|
-
</table>`}];function _a(s){const e=[...wa];return(s==="typescript"||s==="javascript")&&e.push(...xa.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(s):t.language===s))),s==="css"&&e.push(...ka),e}function va(s,e,t){let i=e;for(;i>0&&/\w/.test(s[i-1]);)i--;const n=s.slice(i,e);if(!n)return null;const a=t.find(r=>r.kind==="snip"&&r.label===n);return a?{snippet:a,start:i}:null}function Ht(s,e,t){const i=Je[s]??new Set,n=Ze[s]??new Set,a=Gn[s]??[],r=[...i,...e].map(l=>({label:l,kind:"kw",detail:"keyword"})),o=[...n,...t].map(l=>({label:l,kind:"typ",detail:"type"})),c=new Set,d=[];for(const l of[...a,...r,...o])c.has(l.label)||(c.add(l.label),d.push(l));return d}function Ca(s,e){const t=new Set;for(const i of s){const n=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const a of n)a!==e&&a.length>2&&t.add(a)}return t}function jt(s,e){return s.language?Array.isArray(s.language)?s.language.includes(e):s.language===e:!0}function Ta(s,e,t={},i=0,n=0){if(e.length<2)return[];const a=e.toLowerCase(),{language:r="typescript",extraKeywords:o=[],extraTypes:c=[],completions:d=[],replaceBuiltins:l=!1,maxResults:h=14}=t,p=d.filter(b=>b.kind==="snip"&&!!b.body&&jt(b,r)),u=d.filter(b=>!(b.kind==="snip"&&b.body)&&jt(b,r)),m=p.filter(b=>b.label.toLowerCase().startsWith(a));let g;if(t.provideCompletions){const b={line:s[i]??"",col:n,prefix:e,language:r,doc:s};let f;try{f=t.provideCompletions(b)}catch(x){console.error("[syncline-editor] provideCompletions threw an error:",x),f=null}g=f!=null?[...f,...u]:[...l?[]:Ht(r,o,c),...u]}else g=l?u:[...Ht(r,o,c),...u];{const b=new Set;g=g.filter(f=>b.has(f.label)?!1:(b.add(f.label),!0))}const w=new Set(g.map(b=>b.label)),k=g.filter(b=>b.label.toLowerCase().startsWith(a)?b.kind==="snip"&&!!b.body||b.label!==e:!1),C=new Set(m.map(b=>b.label)),y=[...Ca(s,e)].filter(b=>b.toLowerCase().startsWith(a)&&!w.has(b)&&!C.has(b)).slice(0,8).map(b=>({label:b,kind:"var",detail:"in file"}));return[...m,...k.filter(b=>!C.has(b.label)),...y].slice(0,h)}function Ea(s,e,t=!1){let i=e;for(;i>0&&(t?/[\w$.\-]/:/[\w$.]/).test(s[i-1]);)i--;return{prefix:s.slice(i,e),start:i}}function Sa(s,e,t){if(!e)return[];const i=[];for(let n=0;n<s.length;n++){const a=s[n]??"";if(t.useRegex)try{const r=new RegExp(e,t.caseSensitive?"g":"gi");let o;for(;(o=r.exec(a))!==null&&(i.push({row:n,col:o.index,len:o[0].length}),!!o[0].length););}catch{}else{const r=t.caseSensitive?a:a.toLowerCase(),o=t.caseSensitive?e:e.toLowerCase();let c=0;for(;;){const d=r.indexOf(o,c);if(d===-1)break;i.push({row:n,col:d,len:e.length}),c=d+1}}}return i}function $a(s,e,t,i){const n=e[t];if(!n)return s;const a=[...s],r=a[n.row]??"";return a[n.row]=r.slice(0,n.col)+i+r.slice(n.col+n.len),a}function Ra(s,e,t){const i=[...s];for(let n=e.length-1;n>=0;n--){const a=e[n],r=i[a.row]??"";i[a.row]=r.slice(0,a.col)+t+r.slice(a.col+a.len)}return i}function Ma(s,e){const t=s[e]??"";let i=0;for(const n of t)n==="{"?i++:n==="}"&&i--;return i>0}function La(s,e){let t=0;for(let i=e;i<s.length;i++)for(const n of s[i]??"")if(n==="{")t++;else if(n==="}"&&(t--,t===0&&i>e))return i;return null}function Aa(s,e,t){const i=new Map(s);if(i.has(t))i.delete(t);else{const n=La(e,t);n!==null&&n>t&&i.set(t,n)}return i}function Ia(s){var e,t,i,n,a,r,o,c,d,l,h,p;const{vr:u,visIdx:m,curVisRow:g,wm:w,foldedLines:k,isFoldable:C,opts:y}=s,{docLine:b,segIdx:f,text:x}=u,$=m===g,S=b===((e=w.visualRows[g-w.windowVisStart])==null?void 0:e.docLine),T=f>0,L=((t=w.segments[b])==null?void 0:t.slice(0,f).reduce((I,P)=>I+P.length,0))??0,M=s.docSel?$t(s.docSel,b,((i=(w.segments[b]??[""])[f])==null?void 0:i.length)??0):null;let B=null;if(M){const I=((n=(w.segments[b]??[""])[f])==null?void 0:n.length)??0,P=$t(s.docSel,b,I+L);if(P){const W=P.start-L,Y=P.end-L;Y>0&&W<x.length&&(B={start:Math.max(0,W),end:Math.min(x.length,Y)})}}const te=s.findMatches.filter(I=>I.row===b).map(I=>{var P,W;const Y=I.col-L,xe=I.col+I.len-L;if(xe<=0||Y>=x.length)return null;const Qs=s.findIdx>=0&&((P=s.findMatches[s.findIdx])==null?void 0:P.row)===I.row&&((W=s.findMatches[s.findIdx])==null?void 0:W.col)===I.col;return{start:Math.max(0,Y),end:Math.min(x.length,xe),isCur:Qs}}).filter(Boolean),se=s.wordHighlights.filter(I=>I.row===b).map(I=>{const P=I.col-L,W=I.col+I.len-L;return W<=0||P>=x.length?null:{start:Math.max(0,P),end:Math.min(x.length,W)}}).filter(Boolean),Z=[];if(s.bracketMatch){for(const I of[s.bracketMatch.open,s.bracketMatch.close])if(I.row===b){const P=I.col-L;P>=0&&P<x.length&&Z.push({start:P,end:P+1})}}const Q=[],ie=[];for(const I of s.extraCursors){const P=ae(w,I.row,I.col);if(P.visRow===m&&Q.push(P.colInSeg),I.sel){const W=Da(I.sel);if(b>=W.ar&&b<=W.fr){const Y=b===W.ar?W.ac-L:-L,xe=b===W.fr?W.fc-L:x.length+999;xe>0&&Y<x.length&&ie.push({start:Math.max(0,Y),end:Math.min(x.length,xe)})}}}const H=Ba(x,y.renderWhitespace),U=$||B||te.length||Q.length||se.length||Z.length||ie.length||s.snippetStopCols.length>0;let re;if(U)re=Oa(H,$?s.curColInSeg:-1,B,te,Q,s.snippetStopCols,se,Z,ie,y.tokeniserOpts);else{const I=`${b}:${f}:${y.renderWhitespace}`;let P=s.tokenCache.get(I,H);P||(P=Qe(H,y.tokeniserOpts),s.tokenCache.set(I,H,P)),re=Pa(H,P)||"​"}let pe="";if(f===0&&y.showIndentGuides){const I=(x.match(/^(\s*)/)??["",""])[1].length,P=Math.floor(I/y.tabSize);for(let W=1;W<P;W++){const Y=y.codePaddingLeft+W*y.tabSize*y.charWidth;pe+=`<span class="sl-ig" style="left:${Y}px"></span>`}}let fe="";if(f===0&&C){const I=k.has(b);fe=`<span class="sl-fold-btn" data-row="${b}">${I?"▸":"▾"}</span>`}const oe=((a=w.segments[b])==null?void 0:a.length)??1,V=(r=s.roFirstRows)!=null&&r.has(b)&&f===0?`<span class="sl-ro-ins" data-row="${b}" data-pos="above" title="Insert line above"></span>`:"",Ve=(o=s.roLastRows)!=null&&o.has(b)&&f===oe-1?`<span class="sl-ro-ins" data-row="${b}" data-pos="below" title="Insert line below"></span>`:"",K=k.has(b)&&f===0,ut=f===0?String(b+1):"",ye=(c=s.roBlkIdx)==null?void 0:c.get(b),Zs=ye!==void 0?` data-ro-blk="${ye}"`:"";return`<div class="${["sl-er",y.highlightActiveLine&&S?"sl-cur-row":"",T?"sl-wrap-cont":"",K?"sl-folded":"",(d=s.readOnlyLines)!=null&&d.has(b)?"sl-ro-row":"",(l=s.roFirstRows)!=null&&l.has(b)&&f===0?"sl-ro-first":"",(h=s.roLastRows)!=null&&h.has(b)&&f===oe-1?"sl-ro-last":"",(p=s.selFullRows)!=null&&p.has(b)?"sl-sel-full":""].filter(Boolean).join(" ")}" style="height:${y.lineHeight}px"${Zs} data-v="${m}" data-doc="${b}"><div class="sl-eg" style="position:relative">${fe}<span class="sl-egn">${ut}</span></div><div class="sl-el"><span class="sl-cl">${pe}${re}</span></div>${V}${Ve}</div>`}function Ba(s,e){if(e==="none")return s;if(e==="all")return s.replace(/ /g,"·").replace(/\t/g,"→");const t=(s.match(/^ +/)??[""])[0].length,i=(s.match(/ +$/)??[""])[0].length;let n=s;return t&&(n="·".repeat(t)+n.slice(t)),i&&(n=n.slice(0,n.length-i)+"·".repeat(i)),n.replace(/\t/g,"→")}function Da(s){return s.ar<s.fr||s.ar===s.fr&&s.ac<=s.fc?s:{ar:s.fr,ac:s.fc,fr:s.ar,fc:s.ac}}function Pa(s,e){if(!s)return"";const t=vt(s,e);let i="",n=0,a=t[0];const r=o=>{if(o<=n)return;const c=ge(s.slice(n,o));i+=a?`<span class="${a}">${c}</span>`:c};for(let o=1;o<=s.length;o++){const c=o<s.length?t[o]:null;c!==a&&(r(o),n=o,a=c??"")}return i}function Oa(s,e,t,i,n,a,r,o,c,d){if(s.length===0){let k=e>=0?'<span class="sl-cur"></span>':"";for(const C of n)k+='<span class="sl-cur-extra"></span>';for(const C of a)k+='<span class="sl-snip-stop"></span>';return k||"​"}const l=Qe(s,d),h=vt(s,l);let p="",u=0,m="",g="";const w=k=>{if(k<=u)return;const C=ge(s.slice(u,k)),y=[m,g].filter(Boolean).join(" ");p+=y?`<span class="${y}">${C}</span>`:C};for(let k=0;k<=s.length;k++){e===k&&(w(k),u=k,p+='<span class="sl-cur"></span>');for(const S of n)S===k&&(w(k),u=k,p+='<span class="sl-cur-extra"></span>');for(const S of a)S===k&&(w(k),u=k,p+='<span class="sl-snip-stop"></span>');if(k===s.length){w(k);break}const C=h[k],y=i.find(S=>k>=S.start&&k<S.end),b=t&&k>=t.start&&k<t.end||c.some(S=>k>=S.start&&k<S.end),f=!b&&!y&&r.some(S=>k>=S.start&&k<S.end),x=!b&&!y&&o.some(S=>k>=S.start&&k<S.end);let $="";b?$="sl-sh":y?$="sl-fh"+(y.isCur?" sl-fh-cur":""):x?$="sl-bm":f&&($="sl-wh"),($!==m||C!==g)&&(w(k),u=k,m=$,g=C)}return p||"​"}const lt={"(":")","{":"}","[":"]"},dt={")":"(","}":"{","]":"["};function Ha(s,e){const{row:t,col:i}=e,n=s[t]??"";let a=n[i],r=i;if(!lt[a]&&!dt[a]&&(a=n[i-1],r=i-1),!a)return null;if(lt[a]){const o=lt[a];let c=0;for(let d=t;d<Math.min(s.length,t+500);d++){const l=s[d]??"",h=d===t?r:0;for(let p=h;p<l.length;p++)if(l[p]===a)c++;else if(l[p]===o&&(c--,c===0))return{open:{row:t,col:r},close:{row:d,col:p}}}}else if(dt[a]){const o=dt[a];let c=0;for(let d=t;d>=Math.max(0,t-500);d--){const l=s[d]??"",h=d===t?r:l.length-1;for(let p=h;p>=0;p--)if(l[p]===a)c++;else if(l[p]===o&&(c--,c===0))return{open:{row:d,col:p},close:{row:t,col:r}}}}return null}function ja(s,e,t,i,n=0,a=s.length-1){if(i)return[];const r=s[e]??"",o=At(r,t),c=It(r,t),d=r.slice(o,c);if(!d||d.length<2)return[];const l=[],h=Math.min(a,s.length-1);for(let p=Math.max(0,n);p<=h;p++){const u=s[p]??"";let m=0;for(;m<=u.length-d.length;){const g=u.indexOf(d,m);if(g<0)break;const w=g===0||!/\w/.test(u[g-1]),k=g+d.length>=u.length||!/\w/.test(u[g+d.length]);w&&k&&!(p===e&&g===o)&&l.push({row:p,col:g,len:d.length}),m=g+1}}return l}const Na={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)",roBg:"rgba(212,151,110,.09)",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"}},Wa={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)",roBg:"rgba(206,145,120,.08)",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"}},Fa={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)",roBg:"rgba(253,151,31,.08)",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"}},za={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)",roBg:"rgba(255,184,108,.07)",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"}},Ua={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)",roBg:"rgba(188,76,0,.09)",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"}},qa={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)",roBg:"rgba(203,75,22,.09)",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"}},Ga={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)",roBg:"rgba(247,140,108,.08)",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"}},Va={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)",roBg:"rgba(194,65,12,.09)",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"}},Ka=[Na,Wa,Fa,za,Ua,qa,Ga,Va],Ya={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",roBg:"--ro-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 Xa{constructor(e){_(this,"_registry",new Map),_(this,"_activeId",""),_(this,"_root"),this._root=e;for(const t of Ka)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,n]of Object.entries(Ya))t.setProperty(n,e[i])}}const Ja=`
|
|
423
|
+
</table>`}];function $a(s){const e=[...Sa];return(s==="typescript"||s==="javascript")&&e.push(...Ta.filter(t=>!t.language||(Array.isArray(t.language)?t.language.includes(s):t.language===s))),s==="css"&&e.push(...Ea),e}function Ra(s,e,t){let i=e;for(;i>0&&/\w/.test(s[i-1]);)i--;const n=s.slice(i,e);if(!n)return null;const a=t.find(r=>r.kind==="snip"&&r.label===n);return a?{snippet:a,start:i}:null}function qt(s,e,t){const i=et[s]??new Set,n=tt[s]??new Set,a=Zn[s]??[],r=[...i,...e].map(l=>({label:l,kind:"kw",detail:"keyword"})),o=[...n,...t].map(l=>({label:l,kind:"typ",detail:"type"})),c=new Set,d=[];for(const l of[...a,...r,...o])c.has(l.label)||(c.add(l.label),d.push(l));return d}function Ma(s,e){const t=new Set;for(const i of s){const n=i.match(/[a-zA-Z_$][\w$]*/g)??[];for(const a of n)a!==e&&a.length>2&&t.add(a)}return t}function Ut(s,e){return s.language?Array.isArray(s.language)?s.language.includes(e):s.language===e:!0}function La(s,e,t={},i=0,n=0){if(e.length<2)return[];const a=e.toLowerCase(),{language:r="typescript",extraKeywords:o=[],extraTypes:c=[],completions:d=[],replaceBuiltins:l=!1,maxResults:h=14}=t,p=d.filter(f=>f.kind==="snip"&&!!f.body&&Ut(f,r)),u=d.filter(f=>!(f.kind==="snip"&&f.body)&&Ut(f,r)),m=p.filter(f=>f.label.toLowerCase().startsWith(a));let g;if(t.provideCompletions){const f={line:s[i]??"",col:n,prefix:e,language:r,doc:s};let b;try{b=t.provideCompletions(f)}catch(x){console.error("[syncline-editor] provideCompletions threw an error:",x),b=null}g=b!=null?[...b,...u]:[...l?[]:qt(r,o,c),...u]}else g=l?u:[...qt(r,o,c),...u];{const f=new Set;g=g.filter(b=>f.has(b.label)?!1:(f.add(b.label),!0))}const w=new Set(g.map(f=>f.label)),k=g.filter(f=>f.label.toLowerCase().startsWith(a)?f.kind==="snip"&&!!f.body||f.label!==e:!1),C=new Set(m.map(f=>f.label)),y=[...Ma(s,e)].filter(f=>f.toLowerCase().startsWith(a)&&!w.has(f)&&!C.has(f)).slice(0,8).map(f=>({label:f,kind:"var",detail:"in file"}));return[...m,...k.filter(f=>!C.has(f.label)),...y].slice(0,h)}function Aa(s,e,t=!1){let i=e;for(;i>0&&(t?/[\w$.\-]/:/[\w$.]/).test(s[i-1]);)i--;return{prefix:s.slice(i,e),start:i}}function Ia(s,e,t){if(!e)return[];const i=[];for(let n=0;n<s.length;n++){const a=s[n]??"";if(t.useRegex)try{const r=new RegExp(e,t.caseSensitive?"g":"gi");let o;for(;(o=r.exec(a))!==null&&(i.push({row:n,col:o.index,len:o[0].length}),!!o[0].length););}catch{}else{const r=t.caseSensitive?a:a.toLowerCase(),o=t.caseSensitive?e:e.toLowerCase();let c=0;for(;;){const d=r.indexOf(o,c);if(d===-1)break;i.push({row:n,col:d,len:e.length}),c=d+1}}}return i}function Ba(s,e,t,i){const n=e[t];if(!n)return s;const a=[...s],r=a[n.row]??"";return a[n.row]=r.slice(0,n.col)+i+r.slice(n.col+n.len),a}function Da(s,e,t){const i=[...s];for(let n=e.length-1;n>=0;n--){const a=e[n],r=i[a.row]??"";i[a.row]=r.slice(0,a.col)+t+r.slice(a.col+a.len)}return i}function Pa(s,e){const t=s[e]??"";let i=0;for(const n of t)n==="{"?i++:n==="}"&&i--;return i>0}function Oa(s,e){let t=0;for(let i=e;i<s.length;i++)for(const n of s[i]??"")if(n==="{")t++;else if(n==="}"&&(t--,t===0&&i>e))return i;return null}function Ha(s,e,t){const i=new Map(s);if(i.has(t))i.delete(t);else{const n=Oa(e,t);n!==null&&n>t&&i.set(t,n)}return i}function ja(s){var e,t,i,n,a,r,o,c,d,l,h,p;const{vr:u,visIdx:m,curVisRow:g,wm:w,foldedLines:k,isFoldable:C,opts:y}=s,{docLine:f,segIdx:b,text:x}=u,$=m===g,S=f===((e=w.visualRows[g-w.windowVisStart])==null?void 0:e.docLine),T=b>0,L=((t=w.segments[f])==null?void 0:t.slice(0,b).reduce((I,P)=>I+P.length,0))??0,M=s.docSel?Bt(s.docSel,f,((i=(w.segments[f]??[""])[b])==null?void 0:i.length)??0):null;let B=null;if(M){const I=((n=(w.segments[f]??[""])[b])==null?void 0:n.length)??0,P=Bt(s.docSel,f,I+L);if(P){const W=P.start-L,Y=P.end-L;Y>0&&W<x.length&&(B={start:Math.max(0,W),end:Math.min(x.length,Y)})}}const te=s.findMatches.filter(I=>I.row===f).map(I=>{var P,W;const Y=I.col-L,ke=I.col+I.len-L;if(ke<=0||Y>=x.length)return null;const or=s.findIdx>=0&&((P=s.findMatches[s.findIdx])==null?void 0:P.row)===I.row&&((W=s.findMatches[s.findIdx])==null?void 0:W.col)===I.col;return{start:Math.max(0,Y),end:Math.min(x.length,ke),isCur:or}}).filter(Boolean),re=s.wordHighlights.filter(I=>I.row===f).map(I=>{const P=I.col-L,W=I.col+I.len-L;return W<=0||P>=x.length?null:{start:Math.max(0,P),end:Math.min(x.length,W)}}).filter(Boolean),Z=[];if(s.bracketMatch){for(const I of[s.bracketMatch.open,s.bracketMatch.close])if(I.row===f){const P=I.col-L;P>=0&&P<x.length&&Z.push({start:P,end:P+1})}}const Q=[],ie=[];for(const I of s.extraCursors){const P=se(w,I.row,I.col);if(P.visRow===m&&Q.push(P.colInSeg),I.sel){const W=Wa(I.sel);if(f>=W.ar&&f<=W.fr){const Y=f===W.ar?W.ac-L:-L,ke=f===W.fr?W.fc-L:x.length+999;ke>0&&Y<x.length&&ie.push({start:Math.max(0,Y),end:Math.min(x.length,ke)})}}}const H=Na(x,y.renderWhitespace),q=$||B||te.length||Q.length||re.length||Z.length||ie.length||s.snippetStopCols.length>0;let oe;if(q)oe=za(H,$?s.curColInSeg:-1,B,te,Q,s.snippetStopCols,re,Z,ie,y.tokeniserOpts);else{const I=`${f}:${b}:${y.renderWhitespace}`;let P=s.tokenCache.get(I,H);P||(P=it(H,y.tokeniserOpts),s.tokenCache.set(I,H,P)),oe=Fa(H,P)||"​"}let ue="";if(b===0&&y.showIndentGuides){const I=(x.match(/^(\s*)/)??["",""])[1].length,P=Math.floor(I/y.tabSize);for(let W=1;W<P;W++){const Y=y.codePaddingLeft+W*y.tabSize*y.charWidth;ue+=`<span class="sl-ig" style="left:${Y}px"></span>`}}let ye="";if(b===0&&C){const I=k.has(f);ye=`<span class="sl-fold-btn" data-row="${f}">${I?"▸":"▾"}</span>`}const le=((a=w.segments[f])==null?void 0:a.length)??1,V=(r=s.roFirstRows)!=null&&r.has(f)&&b===0?`<span class="sl-ro-ins" data-row="${f}" data-pos="above" title="Insert line above"></span>`:"",Xe=(o=s.roLastRows)!=null&&o.has(f)&&b===le-1?`<span class="sl-ro-ins" data-row="${f}" data-pos="below" title="Insert line below"></span>`:"",K=k.has(f)&&b===0,yt=b===0?String(f+1):"",xe=(c=s.roBlkIdx)==null?void 0:c.get(f),rr=xe!==void 0?` data-ro-blk="${xe}"`:"";return`<div class="${["sl-er",y.highlightActiveLine&&S?"sl-cur-row":"",T?"sl-wrap-cont":"",K?"sl-folded":"",(d=s.readOnlyLines)!=null&&d.has(f)?"sl-ro-row":"",(l=s.roFirstRows)!=null&&l.has(f)&&b===0?"sl-ro-first":"",(h=s.roLastRows)!=null&&h.has(f)&&b===le-1?"sl-ro-last":"",(p=s.selFullRows)!=null&&p.has(f)?"sl-sel-full":""].filter(Boolean).join(" ")}" style="height:${y.lineHeight}px"${rr} data-v="${m}" data-doc="${f}"><div class="sl-eg" style="position:relative">${ye}<span class="sl-egn">${yt}</span></div><div class="sl-el"><span class="sl-cl">${ue}${oe}</span></div>${V}${Xe}</div>`}function Na(s,e){if(e==="none")return s;if(e==="all")return s.replace(/ /g,"·").replace(/\t/g,"→");const t=(s.match(/^ +/)??[""])[0].length,i=(s.match(/ +$/)??[""])[0].length;let n=s;return t&&(n="·".repeat(t)+n.slice(t)),i&&(n=n.slice(0,n.length-i)+"·".repeat(i)),n.replace(/\t/g,"→")}function Wa(s){return s.ar<s.fr||s.ar===s.fr&&s.ac<=s.fc?s:{ar:s.fr,ac:s.fc,fr:s.ar,fc:s.ac}}function Fa(s,e){if(!s)return"";const t=Rt(s,e);let i="",n=0,a=t[0];const r=o=>{if(o<=n)return;const c=me(s.slice(n,o));i+=a?`<span class="${a}">${c}</span>`:c};for(let o=1;o<=s.length;o++){const c=o<s.length?t[o]:null;c!==a&&(r(o),n=o,a=c??"")}return i}function za(s,e,t,i,n,a,r,o,c,d){if(s.length===0){let k=e>=0?'<span class="sl-cur"></span>':"";for(const C of n)k+='<span class="sl-cur-extra"></span>';for(const C of a)k+='<span class="sl-snip-stop"></span>';return k||"​"}const l=it(s,d),h=Rt(s,l);let p="",u=0,m="",g="";const w=k=>{if(k<=u)return;const C=me(s.slice(u,k)),y=[m,g].filter(Boolean).join(" ");p+=y?`<span class="${y}">${C}</span>`:C};for(let k=0;k<=s.length;k++){e===k&&(w(k),u=k,p+='<span class="sl-cur"></span>');for(const S of n)S===k&&(w(k),u=k,p+='<span class="sl-cur-extra"></span>');for(const S of a)S===k&&(w(k),u=k,p+='<span class="sl-snip-stop"></span>');if(k===s.length){w(k);break}const C=h[k],y=i.find(S=>k>=S.start&&k<S.end),f=t&&k>=t.start&&k<t.end||c.some(S=>k>=S.start&&k<S.end),b=!f&&!y&&r.some(S=>k>=S.start&&k<S.end),x=!f&&!y&&o.some(S=>k>=S.start&&k<S.end);let $="";f?$="sl-sh":y?$="sl-fh"+(y.isCur?" sl-fh-cur":""):x?$="sl-bm":b&&($="sl-wh"),($!==m||C!==g)&&(w(k),u=k,m=$,g=C)}return p||"​"}const ht={"(":")","{":"}","[":"]"},pt={")":"(","}":"{","]":"["};function qa(s,e){const{row:t,col:i}=e,n=s[t]??"";let a=n[i],r=i;if(!ht[a]&&!pt[a]&&(a=n[i-1],r=i-1),!a)return null;if(ht[a]){const o=ht[a];let c=0;for(let d=t;d<Math.min(s.length,t+500);d++){const l=s[d]??"",h=d===t?r:0;for(let p=h;p<l.length;p++)if(l[p]===a)c++;else if(l[p]===o&&(c--,c===0))return{open:{row:t,col:r},close:{row:d,col:p}}}}else if(pt[a]){const o=pt[a];let c=0;for(let d=t;d>=Math.max(0,t-500);d--){const l=s[d]??"",h=d===t?r:l.length-1;for(let p=h;p>=0;p--)if(l[p]===a)c++;else if(l[p]===o&&(c--,c===0))return{open:{row:d,col:p},close:{row:t,col:r}}}}return null}function Ua(s,e,t,i,n=0,a=s.length-1){if(i)return[];const r=s[e]??"",o=Ht(r,t),c=jt(r,t),d=r.slice(o,c);if(!d||d.length<2)return[];const l=[],h=Math.min(a,s.length-1);for(let p=Math.max(0,n);p<=h;p++){const u=s[p]??"";let m=0;for(;m<=u.length-d.length;){const g=u.indexOf(d,m);if(g<0)break;const w=g===0||!/\w/.test(u[g-1]),k=g+d.length>=u.length||!/\w/.test(u[g+d.length]);w&&k&&!(p===e&&g===o)&&l.push({row:p,col:g,len:d.length}),m=g+1}}return l}const Ga={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)",roBg:"rgba(212,151,110,.09)",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"}},Va={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)",roBg:"rgba(206,145,120,.08)",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"}},Ka={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)",roBg:"rgba(253,151,31,.08)",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"}},Ya={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)",roBg:"rgba(255,184,108,.07)",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"}},Xa={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)",roBg:"rgba(188,76,0,.09)",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"}},Ja={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)",roBg:"rgba(203,75,22,.09)",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"}},Za={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)",roBg:"rgba(247,140,108,.08)",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"}},Qa={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)",roBg:"rgba(194,65,12,.09)",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=[Ga,Va,Ka,Ya,Xa,Ja,Za,Qa],ts={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",roBg:"--ro-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 is{constructor(e){_(this,"_registry",new Map),_(this,"_activeId",""),_(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,n]of Object.entries(ts))t.setProperty(n,e[i])}}const ns=`
|
|
423
424
|
/* ── Reset ── */
|
|
424
425
|
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
|
425
426
|
|
|
@@ -784,7 +785,7 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
784
785
|
.sl-tm-btn:active,.sl-tm-btn:hover{background:var(--border3)}
|
|
785
786
|
.sl-tm-btn:disabled{opacity:0.35;cursor:default}
|
|
786
787
|
.sl-tm-sep{width:1px;background:var(--border);margin:8px 0;flex-shrink:0}
|
|
787
|
-
`,Za={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 Qa(s,e,t,i){const n=Number(s);return Number.isFinite(n)?Math.max(e,Math.min(t,Math.round(n))):i}function Nt(s){const e={...s};for(const[t,i]of Object.entries(Za))if(t in s&&s[t]!==void 0){const[n,a,r]=i;e[t]=Qa(s[t],n,a,r)}return e}const es={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:Zn,fontFamily:"'JetBrains Mono', monospace",fontSize:Xn,lineHeight:Kn,tabSize:Jn,insertSpaces:!0,maxUndoHistory:Ct,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,readOnlyRanges:[],extraKeywords:[],extraTypes:[],completions:[],replaceBuiltins:!1,maxCompletions:14,autoClosePairs:{"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},lineCommentToken:"",wordSeparators:"",undoBatchMs:ea,gutterWidth:Yn,minimapWidth:Qn,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0,placeholder:"",goToLine:!1};class ts{constructor(e,t={}){_(this,"_host"),_(this,"_shadow"),_(this,"_editorEl"),_(this,"_spacerEl"),_(this,"_vpEl"),_(this,"_inputEl"),_(this,"_minimapWrap"),_(this,"_mmCanvas"),_(this,"_mmSlider"),_(this,"_statusBar"),_(this,"_findBar"),_(this,"_findInput"),_(this,"_replaceInput"),_(this,"_findCount"),_(this,"_replaceRow"),_(this,"_acPopup"),_(this,"_emmetTip"),_(this,"_snippetTip"),_(this,"_hoverTip"),_(this,"_themeOverlay"),_(this,"_themePanel"),_(this,"_placeholderEl"),_(this,"_goToLineBar"),_(this,"_goToLineInput"),_(this,"_goToLineHint"),_(this,"_config"),_(this,"_tab",St(1,[""])),_(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0],totalVisualRows:1,windowVisStart:0}),_(this,"_foldedLines",new Map),_(this,"_tokenCache",new Vn),_(this,"_themeManager"),_(this,"_findMatches",[]),_(this,"_findIdx",-1),_(this,"_findCaseSensitive",!1),_(this,"_findRegex",!1),_(this,"_wordHighlights",[]),_(this,"_bracketMatch",null),_(this,"_acItems",[]),_(this,"_acSel",0),_(this,"_acPrefix",""),_(this,"_acStartCol",0),_(this,"_emmetAcStartCol",0),_(this,"_mc",ca()),_(this,"_extraCursors",[]),_(this,"_isDragging",!1),_(this,"_dragAnchor",null),_(this,"_wordDragMode",!1),_(this,"_wordDragAnchorRow",0),_(this,"_wordDragAnchorStart",0),_(this,"_wordDragAnchorEnd",0),_(this,"_lineDragMode",!1),_(this,"_lineDragAnchorRow",0),_(this,"_hoverTimer",null),_(this,"_hoverLeaveTimer",null),_(this,"_hoverPinned",!1),_(this,"_readOnlyRanges",[]),_(this,"_mmDragMode","none"),_(this,"_mmDragStartY",0),_(this,"_mmDragStartScroll",0),_(this,"_mmSliderOffset",0),_(this,"_mmColors"),_(this,"_lastInputTime",0),_(this,"_linewiseCopy",!1),_(this,"_ariaId"),_(this,"_ariaLiveEl"),_(this,"_ariaLiveAssertEl"),_(this,"_touchMenu"),_(this,"_touchState",{id:-1,startX:0,startY:0,startScrollTop:0,lastX:0,lastY:0,startTime:0,lastTapTime:0,lastTapX:0,lastTapY:0,longPressTimer:null,isDragging:!1,isLongPress:!1,pinchStartDist:0,pinchStartFontSize:0}),_(this,"_isComposing",!1),_(this,"_dynamicStyleEl"),_(this,"_emmetExpanded",null),_(this,"_snippetExpanded",null),_(this,"_snippetSession",null),_(this,"_acDebounceTimer",null),_(this,"_rafId",null),_(this,"_renderedRowCount",0),_(this,"_lastRenderScroll",-1),_(this,"_onWinMouseUp"),_(this,"_onWinResize"),_(this,"_onEditorScroll"),_(this,"_onWinMmMouseMove"),_(this,"_onWinMmMouseUp"),_(this,"_ro",null),this._config={...es,...Nt(t)},this._readOnlyRanges=(this._config.readOnlyRanges??[]).map(o=>({...o})),this._ariaId=`sl-${Math.random().toString(36).slice(2,9)}`,this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null,this._wordDragMode=!1,this._lineDragMode=!1},this._onEditorScroll=nt(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=nt(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=o=>{if(this._mmDragMode==="none")return;const c=this._minimapWrap.clientHeight,d=this._tab.doc.length,l=this._config.lineHeight;if(this._mmDragMode==="slider"){const h=o.clientY-this._minimapWrap.getBoundingClientRect().top,p=ia(h-this._mmSliderOffset,d,this._editorEl.clientHeight,c,l);this._editorEl.scrollTop=this._domScroll(p)}else{const h=o.clientY-this._mmDragStartY,p=this._logicalScroll(this._mmDragStartScroll),u=Math.max(0,d*l-this._editorEl.clientHeight),m=Math.max(0,Math.min(u,p+h/2*l));this._editorEl.scrollTop=this._domScroll(m)}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=j("style");i.textContent=Ja,this._shadow.appendChild(i),this._dynamicStyleEl=j("style"),this._shadow.appendChild(this._dynamicStyleEl),this._ariaLiveEl=j("div","sl-sr-only"),this._ariaLiveEl.id=`${this._ariaId}-sr`,this._ariaLiveEl.setAttribute("aria-live","polite"),this._ariaLiveEl.setAttribute("aria-atomic","true"),this._ariaLiveEl.setAttribute("role","status"),this._shadow.appendChild(this._ariaLiveEl),this._ariaLiveAssertEl=j("div","sl-sr-only"),this._ariaLiveAssertEl.setAttribute("aria-live","assertive"),this._ariaLiveAssertEl.setAttribute("aria-atomic","true"),this._ariaLiveAssertEl.setAttribute("role","alert"),this._shadow.appendChild(this._ariaLiveAssertEl),this._themeManager=new Xa(this._host),this._themeManager.apply(this._config.theme);const n=j("div","sl-layout"),a=j("div","sl-ed-pane");this._inputEl=j("textarea","sl-input"),this._inputEl.id=`${this._ariaId}-inp`,this._inputEl.setAttribute("autocomplete","off"),this._inputEl.setAttribute("autocorrect","off"),this._inputEl.setAttribute("autocapitalize","off"),this._inputEl.setAttribute("spellcheck","false"),this._inputEl.setAttribute("inputmode","text"),this._inputEl.setAttribute("role","textbox"),this._inputEl.setAttribute("aria-multiline","true"),this._inputEl.setAttribute("aria-label",`Code editor — ${this._config.language}`),this._inputEl.setAttribute("aria-description","Type to edit. Use arrow keys to navigate lines. Ctrl+F to find."),this._inputEl.setAttribute("aria-readonly",String(!!this._config.readOnly)),this._inputEl.setAttribute("aria-haspopup","listbox"),this._inputEl.setAttribute("aria-expanded","false"),this._inputEl.setAttribute("aria-activedescendant",""),this._inputEl.setAttribute("aria-controls",`${this._ariaId}-ac`),this._inputEl.setAttribute("aria-autocomplete","list"),this._inputEl.setAttribute("aria-describedby",`${this._ariaId}-sr`),this._editorEl=j("div","sl-editor"),this._editorEl.id=`${this._ariaId}-ed`,this._editorEl.setAttribute("aria-hidden","true"),this._spacerEl=j("div","sl-spacer"),this._vpEl=j("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=j("div","sl-placeholder"),this._placeholderEl.textContent=this._config.placeholder,this._placeholderEl.style.display="none",a.appendChild(this._inputEl),a.appendChild(this._findBar),a.appendChild(this._goToLineBar),a.appendChild(this._placeholderEl),a.appendChild(this._editorEl),this._minimapWrap=j("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._minimapWrap.setAttribute("role","region"),this._minimapWrap.setAttribute("aria-label","Minimap"),this._mmCanvas=j("canvas",""),this._mmCanvas.setAttribute("aria-hidden","true"),this._mmSlider=j("div","sl-mm-slider"),this._mmSlider.setAttribute("role","scrollbar"),this._mmSlider.setAttribute("aria-orientation","vertical"),this._mmSlider.setAttribute("aria-valuenow","0"),this._mmSlider.setAttribute("aria-valuemin","0"),this._mmSlider.setAttribute("aria-valuemax","100"),this._mmSlider.setAttribute("aria-controls",`${this._ariaId}-ed`),this._mmSlider.setAttribute("aria-label","Scroll position"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),n.appendChild(a),this._config.showMinimap&&n.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=j("div","sl-ac-popup"),this._acPopup.id=`${this._ariaId}-ac`,this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.setAttribute("aria-live","off"),this._acPopup.style.display="none",this._emmetTip=j("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=j("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=j("div","sl-hover-tip"),this._hoverTip.style.display="none",this._hoverTip.addEventListener("mouseenter",()=>{this._hoverLeaveTimer!==null&&(clearTimeout(this._hoverLeaveTimer),this._hoverLeaveTimer=null),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!0}),this._hoverTip.addEventListener("mouseleave",()=>{this._hoverPinned=!1,this._hideHover()}),this._themeOverlay=j("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=j("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(n),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"?Mt(this._config.value):this._config.value;this._tab=St(1,r.length?r:[""]),this._mmColors=it(o=>Oe(o,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(nt(()=>{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<=de)return e;const i=this._editorEl.clientHeight,n=de-i,a=t-i;return n<=0?0:e/n*a}_domScroll(e){const t=this._tab.doc.length*this._config.lineHeight;if(t<=de)return e;const i=this._editorEl.clientHeight,n=de-i,a=t-i;return a<=0?0:e/a*n}_isRangeReadOnly(e,t=e){for(const i of this._readOnlyRanges)if(e<=i.end&&t>=i.start)return!0;return!1}_shiftRanges(e,t){if(t!==0)for(const i of this._readOnlyRanges)i.start>=e&&(i.start+=t,i.end+=t)}_shiftRangesForOpForward(e){switch(e.kind){case"insert":this._shiftRanges(e.row,e.lines.length);break;case"delete":this._shiftRanges(e.row+e.count,-e.count);break;case"replace":this._shiftRanges(e.row+e.oldLines.length,e.newLines.length-e.oldLines.length);break}}_shiftRangesForOpInverse(e){switch(e.kind){case"insert":this._shiftRanges(e.row+e.lines.length,-e.lines.length);break;case"delete":this._shiftRanges(e.row,e.count);break;case"replace":this._shiftRanges(e.row+e.newLines.length,e.oldLines.length-e.newLines.length);break}}_buildFindBar(){const e=j("div","sl-find-bar");return e.setAttribute("role","search"),e.setAttribute("aria-label","Find in editor"),e.innerHTML=`
|
|
788
|
+
`,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 ss(s,e,t,i){const n=Number(s);return Number.isFinite(n)?Math.max(e,Math.min(t,Math.round(n))):i}function Gt(s){const e={...s};for(const[t,i]of Object.entries(as))if(t in s&&s[t]!==void 0){const[n,a,r]=i;e[t]=ss(s[t],n,a,r)}return e}const rs={value:"",language:"typescript",theme:"",showGutter:!0,showMinimap:!0,showStatusBar:!0,wordWrap:!1,wrapColumn:aa,fontFamily:"'JetBrains Mono', monospace",fontSize:ia,lineHeight:ea,tabSize:na,insertSpaces:!0,maxUndoHistory:Mt,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,readOnlyRanges:[],extraKeywords:[],extraTypes:[],completions:[],replaceBuiltins:!1,maxCompletions:14,autoClosePairs:{"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},lineCommentToken:"",wordSeparators:"",undoBatchMs:ra,gutterWidth:ta,minimapWidth:sa,cursorBlinkRate:1050,cursorStyle:"line",renderWhitespace:"none",tokenColors:{},hover:!0,placeholder:"",goToLine:!1};class os{constructor(e,t={}){_(this,"_host"),_(this,"_shadow"),_(this,"_editorEl"),_(this,"_spacerEl"),_(this,"_vpEl"),_(this,"_inputEl"),_(this,"_minimapWrap"),_(this,"_mmCanvas"),_(this,"_mmSlider"),_(this,"_statusBar"),_(this,"_findBar"),_(this,"_findInput"),_(this,"_replaceInput"),_(this,"_findCount"),_(this,"_replaceRow"),_(this,"_acPopup"),_(this,"_emmetTip"),_(this,"_snippetTip"),_(this,"_hoverTip"),_(this,"_themeOverlay"),_(this,"_themePanel"),_(this,"_placeholderEl"),_(this,"_goToLineBar"),_(this,"_goToLineInput"),_(this,"_goToLineHint"),_(this,"_config"),_(this,"_tab",It(1,[""])),_(this,"_wm",{segments:[[""]],visualRows:[{docLine:0,segIdx:0,text:""}],docToVisArr:[0],totalVisualRows:1,windowVisStart:0}),_(this,"_foldedLines",new Map),_(this,"_tokenCache",new Qn),_(this,"_themeManager"),_(this,"_findMatches",[]),_(this,"_findIdx",-1),_(this,"_findCaseSensitive",!1),_(this,"_findRegex",!1),_(this,"_wordHighlights",[]),_(this,"_bracketMatch",null),_(this,"_acItems",[]),_(this,"_acSel",0),_(this,"_acPrefix",""),_(this,"_acStartCol",0),_(this,"_emmetAcStartCol",0),_(this,"_mc",fa()),_(this,"_extraCursors",[]),_(this,"_isDragging",!1),_(this,"_dragAnchor",null),_(this,"_wordDragMode",!1),_(this,"_wordDragAnchorRow",0),_(this,"_wordDragAnchorStart",0),_(this,"_wordDragAnchorEnd",0),_(this,"_lineDragMode",!1),_(this,"_lineDragAnchorRow",0),_(this,"_hoverTimer",null),_(this,"_hoverLeaveTimer",null),_(this,"_hoverPinned",!1),_(this,"_readOnlyRanges",[]),_(this,"_mmDragMode","none"),_(this,"_mmDragStartY",0),_(this,"_mmDragStartScroll",0),_(this,"_mmSliderOffset",0),_(this,"_mmColors"),_(this,"_lastInputTime",0),_(this,"_linewiseCopy",!1),_(this,"_ariaId"),_(this,"_ariaLiveEl"),_(this,"_ariaLiveAssertEl"),_(this,"_touchMenu"),_(this,"_touchState",{id:-1,startX:0,startY:0,startScrollTop:0,lastX:0,lastY:0,startTime:0,lastTapTime:0,lastTapX:0,lastTapY:0,longPressTimer:null,isDragging:!1,isLongPress:!1,pinchStartDist:0,pinchStartFontSize:0}),_(this,"_isComposing",!1),_(this,"_dynamicStyleEl"),_(this,"_emmetExpanded",null),_(this,"_snippetExpanded",null),_(this,"_snippetSession",null),_(this,"_acDebounceTimer",null),_(this,"_rafId",null),_(this,"_renderedRowCount",0),_(this,"_lastRenderScroll",-1),_(this,"_onWinMouseUp"),_(this,"_onWinResize"),_(this,"_onEditorScroll"),_(this,"_onWinMmMouseMove"),_(this,"_onWinMmMouseUp"),_(this,"_ro",null),this._config={...rs,...Gt(t)},this._readOnlyRanges=(this._config.readOnlyRanges??[]).map(o=>({...o})),this._ariaId=`sl-${Math.random().toString(36).slice(2,9)}`,this._onWinMouseUp=()=>{this._isDragging=!1,this._dragAnchor=null,this._wordDragMode=!1,this._lineDragMode=!1},this._onEditorScroll=rt(()=>{this._hideHover(),this._scheduleRender(),this._updateMinimap()},16),this._onWinResize=rt(()=>{this._config.wordWrap&&this._rebuildWrapMap(),this._scheduleRender()},100),this._onWinMmMouseMove=o=>{if(this._mmDragMode==="none")return;const c=this._minimapWrap.clientHeight,d=this._tab.doc.length,l=this._config.lineHeight;if(this._mmDragMode==="slider"){const h=o.clientY-this._minimapWrap.getBoundingClientRect().top,p=la(h-this._mmSliderOffset,d,this._editorEl.clientHeight,c,l);this._editorEl.scrollTop=this._domScroll(p)}else{const h=o.clientY-this._mmDragStartY,p=this._logicalScroll(this._mmDragStartScroll),u=Math.max(0,d*l-this._editorEl.clientHeight),m=Math.max(0,Math.min(u,p+h/2*l));this._editorEl.scrollTop=this._domScroll(m)}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=j("style");i.textContent=ns,this._shadow.appendChild(i),this._dynamicStyleEl=j("style"),this._shadow.appendChild(this._dynamicStyleEl),this._ariaLiveEl=j("div","sl-sr-only"),this._ariaLiveEl.id=`${this._ariaId}-sr`,this._ariaLiveEl.setAttribute("aria-live","polite"),this._ariaLiveEl.setAttribute("aria-atomic","true"),this._ariaLiveEl.setAttribute("role","status"),this._shadow.appendChild(this._ariaLiveEl),this._ariaLiveAssertEl=j("div","sl-sr-only"),this._ariaLiveAssertEl.setAttribute("aria-live","assertive"),this._ariaLiveAssertEl.setAttribute("aria-atomic","true"),this._ariaLiveAssertEl.setAttribute("role","alert"),this._shadow.appendChild(this._ariaLiveAssertEl),this._themeManager=new is(this._host),this._themeManager.apply(this._config.theme);const n=j("div","sl-layout"),a=j("div","sl-ed-pane");this._inputEl=j("textarea","sl-input"),this._inputEl.id=`${this._ariaId}-inp`,this._inputEl.setAttribute("autocomplete","off"),this._inputEl.setAttribute("autocorrect","off"),this._inputEl.setAttribute("autocapitalize","off"),this._inputEl.setAttribute("spellcheck","false"),this._inputEl.setAttribute("inputmode","text"),this._inputEl.setAttribute("role","textbox"),this._inputEl.setAttribute("aria-multiline","true"),this._inputEl.setAttribute("aria-label",`Code editor — ${this._config.language}`),this._inputEl.setAttribute("aria-description","Type to edit. Use arrow keys to navigate lines. Ctrl+F to find."),this._inputEl.setAttribute("aria-readonly",String(!!this._config.readOnly)),this._inputEl.setAttribute("aria-haspopup","listbox"),this._inputEl.setAttribute("aria-expanded","false"),this._inputEl.setAttribute("aria-activedescendant",""),this._inputEl.setAttribute("aria-controls",`${this._ariaId}-ac`),this._inputEl.setAttribute("aria-autocomplete","list"),this._inputEl.setAttribute("aria-describedby",`${this._ariaId}-sr`),this._editorEl=j("div","sl-editor"),this._editorEl.id=`${this._ariaId}-ed`,this._editorEl.setAttribute("aria-hidden","true"),this._spacerEl=j("div","sl-spacer"),this._vpEl=j("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=j("div","sl-placeholder"),this._placeholderEl.textContent=this._config.placeholder,this._placeholderEl.style.display="none",a.appendChild(this._inputEl),a.appendChild(this._findBar),a.appendChild(this._goToLineBar),a.appendChild(this._placeholderEl),a.appendChild(this._editorEl),this._minimapWrap=j("div","sl-minimap"),this._minimapWrap.style.width=`${this._config.minimapWidth}px`,this._minimapWrap.setAttribute("role","region"),this._minimapWrap.setAttribute("aria-label","Minimap"),this._mmCanvas=j("canvas",""),this._mmCanvas.setAttribute("aria-hidden","true"),this._mmSlider=j("div","sl-mm-slider"),this._mmSlider.setAttribute("role","scrollbar"),this._mmSlider.setAttribute("aria-orientation","vertical"),this._mmSlider.setAttribute("aria-valuenow","0"),this._mmSlider.setAttribute("aria-valuemin","0"),this._mmSlider.setAttribute("aria-valuemax","100"),this._mmSlider.setAttribute("aria-controls",`${this._ariaId}-ed`),this._mmSlider.setAttribute("aria-label","Scroll position"),this._minimapWrap.appendChild(this._mmCanvas),this._minimapWrap.appendChild(this._mmSlider),n.appendChild(a),this._config.showMinimap&&n.appendChild(this._minimapWrap),this._statusBar=this._buildStatusBar(),this._acPopup=j("div","sl-ac-popup"),this._acPopup.id=`${this._ariaId}-ac`,this._acPopup.setAttribute("role","listbox"),this._acPopup.setAttribute("aria-label","Code suggestions"),this._acPopup.setAttribute("aria-live","off"),this._acPopup.style.display="none",this._emmetTip=j("div","sl-emmet-tip"),this._emmetTip.style.display="none",this._snippetTip=j("div","sl-emmet-tip"),this._snippetTip.style.display="none",this._hoverTip=j("div","sl-hover-tip"),this._hoverTip.style.display="none",this._hoverTip.addEventListener("mouseenter",()=>{this._hoverLeaveTimer!==null&&(clearTimeout(this._hoverLeaveTimer),this._hoverLeaveTimer=null),this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPinned=!0}),this._hoverTip.addEventListener("mouseleave",()=>{this._hoverPinned=!1,this._hideHover()}),this._themeOverlay=j("div","sl-theme-overlay"),this._themeOverlay.style.display="none",this._themePanel=j("div","sl-theme-panel"),this._themeOverlay.appendChild(this._themePanel),this._shadow.appendChild(n),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"?Pt(this._config.value):this._config.value;this._tab=It(1,r.length?r:[""]),this._mmColors=st(o=>He(o,this._host)),this._bindEditorEvents(),this._bindMinimapEvents(),this._bindFindEvents(),this._applyDynamicStyles(),typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(rt(()=>{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<=ce)return e;const i=this._editorEl.clientHeight,n=ce-i,a=t-i;return n<=0?0:e/n*a}_domScroll(e){const t=this._tab.doc.length*this._config.lineHeight;if(t<=ce)return e;const i=this._editorEl.clientHeight,n=ce-i,a=t-i;return a<=0?0:e/a*n}_isRangeReadOnly(e,t=e){for(const i of this._readOnlyRanges)if(e<=i.end&&t>=i.start)return!0;return!1}_shiftRanges(e,t){if(t!==0)for(const i of this._readOnlyRanges)i.start>=e&&(i.start+=t,i.end+=t)}_shiftRangesForOpForward(e){switch(e.kind){case"insert":this._shiftRanges(e.row,e.lines.length);break;case"delete":this._shiftRanges(e.row+e.count,-e.count);break;case"replace":this._shiftRanges(e.row+e.oldLines.length,e.newLines.length-e.oldLines.length);break}}_shiftRangesForOpInverse(e){switch(e.kind){case"insert":this._shiftRanges(e.row+e.lines.length,-e.lines.length);break;case"delete":this._shiftRanges(e.row,e.count);break;case"replace":this._shiftRanges(e.row+e.newLines.length,e.oldLines.length-e.newLines.length);break}}_buildFindBar(){const e=j("div","sl-find-bar");return e.setAttribute("role","search"),e.setAttribute("aria-label","Find in editor"),e.innerHTML=`
|
|
788
789
|
<div class="sl-find-row">
|
|
789
790
|
<input class="sl-find-input" placeholder="Find…" autocomplete="off" spellcheck="false"
|
|
790
791
|
aria-label="Find" aria-autocomplete="list">
|
|
@@ -827,20 +828,20 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
827
828
|
<div class="sl-sb-sep"></div>
|
|
828
829
|
<div class="sl-sb-item sl-no-click sl-sb-undo">↩0 ↪0</div>
|
|
829
830
|
</div>
|
|
830
|
-
`,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._touchState.longPressTimer!==null&&(clearTimeout(this._touchState.longPressTimer),this._touchState.longPressTimer=null),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
|
|
831
|
+
`,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._touchState.longPressTimer!==null&&(clearTimeout(this._touchState.longPressTimer),this._touchState.longPressTimer=null),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 ls extends os{_applyDynamicStyles(){const{fontFamily:e,fontSize:t,lineHeight:i,cursorBlinkRate:n,cursorStyle:a,gutterWidth:r,minimapWidth:o,showGutter:c}=this._config,d=Math.max(2,i-4),l=Math.floor((i-d)/2);let h="";a==="block"?h=`width:${X}px;opacity:.5;border-radius:1px;`:a==="underline"&&(h=`width:${X}px;height:2px;top:${i-2}px;border-radius:0;`);const p=c?r:0;this._dynamicStyleEl.textContent=`
|
|
831
832
|
.sl-el{font-family:${e};font-size:${t}px;line-height:${i}px}
|
|
832
833
|
.sl-cl{height:${i}px;line-height:${i}px}
|
|
833
834
|
.sl-egn{height:${i}px;line-height:${i}px}
|
|
834
835
|
.sl-eg{min-width:${p}px;width:${p}px;${c?"":"display:none"}}
|
|
835
836
|
.sl-cur::after{height:${d}px;top:${l}px;animation-duration:${n}ms;${h}}
|
|
836
837
|
.sl-cur-extra::after{height:${d}px;top:${l}px;animation-duration:${n}ms;${h}}
|
|
837
|
-
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${o}px`,this._placeholderEl.style.left=`${p+ee}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,n=(r,o,c)=>{i.setProperty(r,o||c)},a=t==null?void 0:t.tokens;n("--tok-kw",e.keyword,(a==null?void 0:a.tokKw)??""),n("--tok-str",e.string,(a==null?void 0:a.tokStr)??""),n("--tok-cmt",e.comment,(a==null?void 0:a.tokCmt)??""),n("--tok-fn",e.function,(a==null?void 0:a.tokFn)??""),n("--tok-num",e.number,(a==null?void 0:a.tokNum)??""),n("--tok-cls",e.class,(a==null?void 0:a.tokCls)??""),n("--tok-op",e.operator,(a==null?void 0:a.tokOp)??""),n("--tok-typ",e.type,(a==null?void 0:a.tokTyp)??""),n("--tok-dec",e.decorator,(a==null?void 0:a.tokDec)??"")}_refreshMinimapColors(){this._mmColors=
|
|
838
|
-
`),m=h[p.row]??"",g=m.slice(0,p.col),w=m.slice(p.col);if(u.length===1)h[p.row]=g+e+w,p.col+=e.length;else{const k=[g+u[0]];for(let C=1;C<u.length-1;C++)k.push(u[C]);k.push(u[u.length-1]+w),h.splice(p.row,1,...k),p.row+=u.length-1,p.col=u[u.length-1].length}if(r){const k=h.slice(d,p.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d,oldLines:l,newLines:k},o,c);const C=k.length-l.length;C!==0&&this._shiftRanges(d+l.length,C)}this._tokenCache.invalidateLine(p.row,(this._wm.segments[p.row]??[""]).length),this._tab.dirty=!0,(n=(i=this._config).onChange)==null||n.call(i,D(h))}_doBackspace(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const r=O(this._tab.sel);if(this._isRangeReadOnly(r.ar,r.fr)){this._partialDeleteSelection();return}const o=this._tab.doc.slice(r.ar,r.fr+1);this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const c=[this._tab.doc[r.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r.ar,oldLines:o,newLines:c},t,i);const d=1-o.length;d!==0&&this._shiftRanges(r.ar+o.length,d);return}const{doc:n,cur:a}=this._tab;if(a.col>0){if(this._isRangeReadOnly(a.row))return;const r=n[a.row]??"",o=r.slice(0,a.col),c=o.length>=2&&o.endsWith(" ")&&!o.trim()?2:1;n[a.row]=r.slice(0,a.col-c)+r.slice(a.col),a.col-=c,this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r],newLines:[n[a.row]]},t,i)}else if(a.row>0){if(this._isRangeReadOnly(a.row-1,a.row)){if(!this._isRangeReadOnly(a.row)&&(n[a.row]??"")===""){const l=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:l,count:1,removed:[""]},t,i),this._shiftRanges(l+1,-1);let h=l-1;for(;h>0&&this._isRangeReadOnly(h);)h--;if(this._isRangeReadOnly(h))for(h=Math.min(l,n.length-1);h<n.length-1&&this._isRangeReadOnly(h);)h++;a.row=Math.max(0,Math.min(h,n.length-1)),a.col=this._isRangeReadOnly(a.row)?0:(n[a.row]??"").length,R(this._tab)}else if(!this._isRangeReadOnly(a.row)){let l=a.row-1;for(;l>0&&this._isRangeReadOnly(l);)l--;if(!this._isRangeReadOnly(l)){const h=[...n],p=n[l]??"",u=n[a.row]??"",m=a.row;n[l]=p+u,n.splice(m,1),a.row=l,a.col=p.length,this._tokenCache.clear(),this._tab.dirty=!0;const g=ce(h,n);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:g.row,oldLines:g.oldLines,newLines:g.newLines},t,i),this._shiftRanges(m+1,-1),R(this._tab)}}return}const r=n[a.row-1]??"",o=n[a.row]??"",c=r.length,d=a.row;n[a.row-1]=r+o,n.splice(a.row,1),a.row--,a.col=c,this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r,o],newLines:[n[a.row]]},t,i),this._shiftRanges(d+1,-1)}else return;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 o=O(this._tab.sel);if(this._isRangeReadOnly(o.ar,o.fr)){this._partialDeleteSelection();return}const c=this._tab.doc.slice(o.ar,o.fr+1);this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[o.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.ar,oldLines:c,newLines:d},t,i);const l=1-c.length;l!==0&&this._shiftRanges(o.ar+c.length,l);return}const{doc:n,cur:a}=this._tab,r=n[a.row]??"";if(a.col<r.length){if(this._isRangeReadOnly(a.row))return;const o=r;n[a.row]=r.slice(0,a.col)+r.slice(a.col+1),this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o],newLines:[n[a.row]]},t,i)}else if(a.row<n.length-1){if(this._isRangeReadOnly(a.row,a.row+1)){if(!this._isRangeReadOnly(a.row)&&(n[a.row]??"")===""){const d=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:d,count:1,removed:[""]},t,i),this._shiftRanges(d+1,-1);let l=Math.min(d,n.length-1);for(;l<n.length-1&&this._isRangeReadOnly(l);)l++;if(this._isRangeReadOnly(l))for(l=d-1;l>0&&this._isRangeReadOnly(l);)l--;a.row=Math.max(0,Math.min(l,n.length-1)),a.col=(this._isRangeReadOnly(a.row),0),R(this._tab)}return}const o=r,c=n[a.row+1]??"";n[a.row]=o+c,n.splice(a.row+1,1),this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o,c],newLines:[n[a.row]]},t,i),this._shiftRanges(a.row+2,-1)}else return;this._tab.dirty=!0}_doEnter(){const e={...this._tab.cur},t=this._tab.sel?{...this._tab.sel}:null;let i,n;if(this._tab.sel){const m=O(this._tab.sel);if(this._isRangeReadOnly(m.ar,m.fr))return;i=m.ar,n=this._tab.doc.slice(m.ar,m.fr+1),this._tab.cur=q(this._tab)}else{if(this._isRangeReadOnly(this._tab.cur.row))return;i=this._tab.cur.row,n=[this._tab.doc[i]??""]}const{doc:a,cur:r}=this._tab,o=a[r.row]??"",c=o.slice(0,r.col),d=o.slice(r.col),l=He(o),h=c.trimEnd().endsWith("{")?je(this._config.tabSize):"";a[r.row]=c,c.trimEnd().endsWith("{")&&d.trimStart()==="}"?a.splice(r.row+1,0,l+h,l+d):a.splice(r.row+1,0,l+h+d),r.row++,r.col=l.length+h.length,this._tokenCache.clear();const p=a.slice(i,r.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:i,oldLines:n,newLines:p},e,t);const u=p.length-n.length;u!==0&&this._shiftRanges(i+n.length,u),this._tab.dirty=!0}_partialDeleteSelection(){if(!this._tab.sel)return!1;const e=this._tab.doc,t=O(this._tab.sel),i=[];let n=null;for(let m=t.ar;m<=t.fr;m++)if(!this._isRangeReadOnly(m))n||(n={row:m,col:m===t.ar?t.ac:0});else if(n){const g=m-1,w=g===t.fr?t.fc:(e[g]??"").length;i.push({ar:n.row,ac:n.col,fr:g,fc:w}),n=null}if(n&&i.push({ar:n.row,ac:n.col,fr:t.fr,fc:t.fc}),i.length===0)return!1;const a={...this._tab.cur},r={...this._tab.sel},o=e.slice(t.ar,t.fr+1),c=this._readOnlyRanges.map(m=>({...m}));let d={...this._tab.cur};for(let m=i.length-1;m>=0;m--){const g=i[m];this._tab.sel={ar:g.ar,ac:g.ac,fr:g.fr,fc:g.fc},d=q(this._tab);const w=g.fr-g.ar;w>0&&this._shiftRanges(g.ar+1,-w)}this._tab.sel=null,this._tab.cur=d;const l=i.reduce((m,g)=>m+(g.fr-g.ar),0),h=t.fr-l,p=this._tab.doc.slice(t.ar,h+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:t.ar,oldLines:o,newLines:p},a,r);const u=this._tab.undoStack[this._tab.undoStack.length-1];return u.beforeRanges=c,u.afterRanges=this._readOnlyRanges.map(m=>({...m})),this._tokenCache.clear(),this._tab.dirty=!0,!0}}class ss extends as{_wordSkipRight(e,t){let i=t;const n=e.length;for(;i<n&&/\s/.test(e[i]);)i++;if(i>=n)return i;if(/\w/.test(e[i]))for(;i<n&&/\w/.test(e[i]);)i++;else for(;i<n&&/[^\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 o=O(this._tab.sel);if(this._isRangeReadOnly(o.ar,o.fr))return;const c=this._tab.doc.slice(o.ar,o.fr+1);this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[o.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.ar,oldLines:c,newLines:d},t,i);const l=1-c.length;l!==0&&this._shiftRanges(o.ar+c.length,l);return}const{doc:n,cur:a}=this._tab;if(a.col===0){if(a.row===0)return;if(this._isRangeReadOnly(a.row-1,a.row)){if(!this._isRangeReadOnly(a.row)){const h=n[a.row]??"";if(h===""){const p=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:p,count:1,removed:[""]},t,i),this._shiftRanges(p+1,-1);let u=p-1;for(;u>0&&this._isRangeReadOnly(u);)u--;if(this._isRangeReadOnly(u))for(u=Math.min(p,n.length-1);u<n.length-1&&this._isRangeReadOnly(u);)u++;a.row=Math.max(0,Math.min(u,n.length-1)),a.col=this._isRangeReadOnly(a.row)?0:(n[a.row]??"").length,R(this._tab)}else{let p=a.row-1;for(;p>0&&this._isRangeReadOnly(p);)p--;if(!this._isRangeReadOnly(p)){const u=[...n],m=n[p]??"",g=a.row;n[p]=m+h,n.splice(g,1),a.row=p,a.col=m.length,this._tokenCache.clear(),this._tab.dirty=!0;const w=ce(u,n);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:w.row,oldLines:w.oldLines,newLines:w.newLines},t,i),this._shiftRanges(g+1,-1),R(this._tab)}}}return}const o=n[a.row-1]??"",c=n[a.row]??"",d=o.length,l=a.row;n[a.row-1]=o+c,n.splice(a.row,1),a.row--,a.col=d,this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o,c],newLines:[n[a.row]]},t,i),this._shiftRanges(l+1,-1),this._tab.dirty=!0;return}if(this._isRangeReadOnly(a.row))return;const r=n[a.row]??"";n[a.row]=r.slice(a.col),a.col=0,this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r],newLines:[n[a.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 d=O(this._tab.sel);if(this._isRangeReadOnly(d.ar,d.fr))return;const l=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[d.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:l,newLines:h},t,i);const p=1-l.length;p!==0&&this._shiftRanges(d.ar+l.length,p);return}const{doc:n,cur:a}=this._tab;if(a.col===0){if(a.row>0){if(this._isRangeReadOnly(a.row-1,a.row)){if(!this._isRangeReadOnly(a.row)&&(n[a.row]??"")===""){const u=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:u,count:1,removed:[""]},t,i),this._shiftRanges(u+1,-1);let m=u-1;for(;m>0&&this._isRangeReadOnly(m);)m--;if(this._isRangeReadOnly(m))for(m=Math.min(u,n.length-1);m<n.length-1&&this._isRangeReadOnly(m);)m++;a.row=Math.max(0,Math.min(m,n.length-1)),a.col=this._isRangeReadOnly(a.row)?0:(n[a.row]??"").length,R(this._tab)}else if(!this._isRangeReadOnly(a.row)){let u=a.row-1;for(;u>0&&this._isRangeReadOnly(u);)u--;if(!this._isRangeReadOnly(u)){const m=[...n],g=n[u]??"",w=n[a.row]??"",k=a.row;n[u]=g+w,n.splice(k,1),a.row=u,a.col=g.length,this._tokenCache.clear(),this._tab.dirty=!0;const C=ce(m,n);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:C.row,oldLines:C.oldLines,newLines:C.newLines},t,i),this._shiftRanges(k+1,-1),R(this._tab)}}return}const d=n[a.row-1]??"",l=n[a.row]??"",h=d.length,p=a.row;n[a.row-1]=d+l,n.splice(a.row,1),a.row--,a.col=h,this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[d,l],newLines:[n[a.row]]},t,i),this._shiftRanges(p+1,-1),this._tab.dirty=!0}return}if(this._isRangeReadOnly(a.row))return;const r=n[a.row]??"",o=this._wordSkipLeft(r,a.col),c=r;n[a.row]=r.slice(0,o)+r.slice(a.col),a.col=o,this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[c],newLines:[n[a.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 c=O(this._tab.sel);if(this._isRangeReadOnly(c.ar,c.fr))return;const d=this._tab.doc.slice(c.ar,c.fr+1);this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const l=[this._tab.doc[c.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c.ar,oldLines:d,newLines:l},t,i);const h=1-d.length;h!==0&&this._shiftRanges(c.ar+d.length,h);return}const{doc:n,cur:a}=this._tab,r=n[a.row]??"";if(a.col>=r.length){if(a.row>=n.length-1)return;if(this._isRangeReadOnly(a.row,a.row+1)){if(!this._isRangeReadOnly(a.row)&&r===""){const d=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:d,count:1,removed:[""]},t,i),this._shiftRanges(d+1,-1);let l=Math.min(d,n.length-1);for(;l<n.length-1&&this._isRangeReadOnly(l);)l++;if(this._isRangeReadOnly(l))for(l=d-1;l>0&&this._isRangeReadOnly(l);)l--;a.row=Math.max(0,Math.min(l,n.length-1)),a.col=0,R(this._tab)}return}const c=n[a.row+1]??"";n[a.row]=r+c,n.splice(a.row+1,1),this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r,c],newLines:[n[a.row]]},t,i),this._shiftRanges(a.row+2,-1),this._tab.dirty=!0;return}if(this._isRangeReadOnly(a.row))return;const o=r;n[a.row]=r.slice(0,a.col),this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o],newLines:[n[a.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 d=O(this._tab.sel);if(this._isRangeReadOnly(d.ar,d.fr))return;const l=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=q(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[d.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:l,newLines:h},t,i);const p=1-l.length;p!==0&&this._shiftRanges(d.ar+l.length,p);return}const{doc:n,cur:a}=this._tab,r=n[a.row]??"";if(a.col>=r.length){if(a.row<n.length-1){if(this._isRangeReadOnly(a.row,a.row+1)){if(!this._isRangeReadOnly(a.row)&&r===""){const h=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:h,count:1,removed:[""]},t,i),this._shiftRanges(h+1,-1);let p=Math.min(h,n.length-1);for(;p<n.length-1&&this._isRangeReadOnly(p);)p++;if(this._isRangeReadOnly(p))for(p=h-1;p>0&&this._isRangeReadOnly(p);)p--;a.row=Math.max(0,Math.min(p,n.length-1)),a.col=0,R(this._tab)}return}const d=n[a.row+1]??"",l=r;n[a.row]=r+d,n.splice(a.row+1,1),this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[l,d],newLines:[n[a.row]]},t,i),this._shiftRanges(a.row+2,-1),this._tab.dirty=!0}return}if(this._isRangeReadOnly(a.row))return;const o=this._wordSkipRight(r,a.col),c=r;n[a.row]=r.slice(0,a.col)+r.slice(o),this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[c],newLines:[n[a.row]]},t,i),this._tab.dirty=!0}}class rs extends ss{_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=Rt(this._tab);if(i)this._linewiseCopy=!1,(e=navigator.clipboard)==null||e.writeText(i).catch(()=>{});else{this._linewiseCopy=!0;const n=(this._tab.doc[this._tab.cur.row]??"")+`
|
|
839
|
-
`;(t=navigator.clipboard)==null||t.writeText(n).catch(()=>{})}}_doCut(){var e,t,i,n,a,r;const o=
|
|
840
|
-
`).catch(()=>{}),c.length>1?(c.splice(d.row,1),R(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:l.row,count:1,removed:[h]},l,null),this._shiftRanges(l.row+1,-1)):(c[0]="",d.col=0,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[h],newLines:[""]},l,null)),this._rebuildWrapMap(),R(this._tab),this._render(),(r=(a=this._config).onChange)==null||r.call(a,D(this._tab.doc))}}}class os extends rs{_doInsertLineBelow(){var e,t,i,n;if(this._isRangeReadOnly(this._tab.cur.row))return;const a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,c=He(this._tab.doc[o]??"");this._tab.doc.splice(o+1,0,c),this._tab.cur.row=o+1,this._tab.cur.col=c.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:o+1,lines:[c]},a,r),this._shiftRanges(o+1,1),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)),(n=(i=this._config).onCursorChange)==null||n.call(i,{...this._tab.cur})}_doInsertLineAbove(){var e,t,i,n;if(this._isRangeReadOnly(this._tab.cur.row))return;const a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,c=He(this._tab.doc[o]??"");this._tab.doc.splice(o,0,c),this._tab.cur.row=o,this._tab.cur.col=c.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:o,lines:[c]},a,r),this._shiftRanges(o,1),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)),(n=(i=this._config).onCursorChange)==null||n.call(i,{...this._tab.cur})}_insertLineAtROBoundary(e,t){var i,n,a,r;const o={...this._tab.cur},c=this._tab.sel?{...this._tab.sel}:null,d=t?e+1:e;this._tab.doc.splice(d,0,""),this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[""]},o,c),this._shiftRanges(d,1),this._tab.cur={row:d,col:0},this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc)),(r=(a=this._config).onCursorChange)==null||r.call(a,{...this._tab.cur})}_duplicateLine(){var e,t;if(this._isRangeReadOnly(this._tab.cur.row))return;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,r=this._tab.doc[a]??"";this._tab.doc.splice(a+1,0,r),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:a+1,lines:[r]},i,n),this._shiftRanges(a+1,1),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_deleteLine(){var e,t;if(this._isRangeReadOnly(this._tab.cur.row))return;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,{doc:a,cur:r}=this._tab;if(a.length>1){const o=r.row,c=[a[o]??""];a.splice(o,1),R(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:o,count:1,removed:c},i,n),this._shiftRanges(o+1,-1)}else{const o=a[0]??"";a[0]="",r.col=0,E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[o],newLines:[""]},i,n)}this._tokenCache.clear(),this._tab.dirty=!0,R(this._tab),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_duplicateLines(e){var t,i,n,a;const{doc:r,cur:o}=this._tab,c=this._tab.sel;let d=o.row,l=o.row;if(c){const m=O(c);d=m.ar,l=m.fr,m.fc===0&&m.fr>m.ar&&l--}if(this._isRangeReadOnly(d,l))return;const h={...this._tab.cur},p=c?{...c}:null,u=r.slice(d,l+1);e?(r.splice(l+1,0,...u),o.row+=u.length,c&&(c.ar+=u.length,c.fr+=u.length),E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:l+1,lines:[...u]},h,p),this._shiftRanges(l+1,u.length)):(r.splice(d,0,...u),E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[...u]},h,p),this._shiftRanges(d,u.length)),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc)),(a=(n=this._config).onCursorChange)==null||a.call(n,{...this._tab.cur})}_moveLines(e){var t,i,n,a;const{doc:r,cur:o}=this._tab,c=this._tab.sel;let d=o.row,l=o.row;if(c){const h=O(c);d=h.ar,l=h.fr,h.fc===0&&h.fr>h.ar&&l--}if(e){if(this._isRangeReadOnly(d,l)||d===0)return;let h=d-1;const p=this._isRangeReadOnly(h);for(;h>0&&this._isRangeReadOnly(h);)h--;const u={...this._tab.cur},m=c?{...c}:null,g=l-d+1,w=this._readOnlyRanges.map(x=>({...x})),k=r.slice(h,l+1),C=r.splice(d,g);this._shiftRanges(d+g,-g);let y;p?this._isRangeReadOnly(h)?y=0:y=h+1:y=h,r.splice(y,0,...C),this._shiftRanges(y,g);const b=d-y;o.row-=b,c&&(c.ar-=b,c.fr-=b);const f=r.slice(h,l+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:h,oldLines:k,newLines:f},u,m);{const x=this._tab.undoStack[this._tab.undoStack.length-1];x.beforeRanges=w,x.afterRanges=this._readOnlyRanges.map($=>({...$}))}}else{if(this._isRangeReadOnly(d,l))return;let h=l+1;const p=this._isRangeReadOnly(h);for(;h<r.length&&this._isRangeReadOnly(h);)h++;const u={...this._tab.cur},m=c?{...c}:null,g=l-d+1,w=this._readOnlyRanges.map(x=>({...x})),k=h<r.length?r.slice(d,h+1):r.slice(d);h>=r.length&&(r.push(""),h=r.length-1);const C=r.splice(d,g);this._shiftRanges(d+g,-g);const y=p?h-g:h-g+1;r.splice(y,0,...C),this._shiftRanges(y,g);const b=y-d;o.row+=b,c&&(c.ar+=b,c.fr+=b);const f=r.slice(d,h+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d,oldLines:k,newLines:f},u,m);{const x=this._tab.undoStack[this._tab.undoStack.length-1];x.beforeRanges=w,x.afterRanges=this._readOnlyRanges.map($=>({...$}))}}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc)),(a=(n=this._config).onCursorChange)==null||a.call(n,{...this._tab.cur})}}class ls extends os{_getSelRows(){if(!this._tab.sel)return[this._tab.cur.row];const e=O(this._tab.sel),t=[];for(let i=e.ar;i<=e.fr;i++)t.push(i);return t}_indentSel(){var e,t;if(!this._tab.sel){this._insertStr(je(this._config.tabSize),!1);return}const i={...this._tab.cur},n={...this._tab.sel},a=je(this._config.tabSize),r=this._getSelRows(),o=r[0],c=r[r.length-1];if(this._isRangeReadOnly(o,c))return;const d=this._tab.doc.slice(o,c+1);r.forEach(h=>{var p;this._tab.doc[h]=a+(this._tab.doc[h]??""),this._tokenCache.invalidateLine(h,((p=this._wm.segments[h])==null?void 0:p.length)??1)}),this._tab.dirty=!0;const l=this._tab.doc.slice(o,c+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:d,newLines:l},i,n),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_unindentSel(){var e,t;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._config.tabSize,r=this._getSelRows(),o=r[0],c=r[r.length-1];if(this._isRangeReadOnly(o,c))return;const d=this._tab.doc.slice(o,c+1);r.forEach(h=>{var p;const u=this._tab.doc[h]??"";u.startsWith(je(a))?this._tab.doc[h]=u.slice(a):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 l=this._tab.doc.slice(o,c+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:d,newLines:l},i,n),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_toggleComment(){var e,t;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._getSelRows(),r=a[0],o=a[a.length-1];if(this._isRangeReadOnly(r,o))return;const c=this._tab.doc.slice(r,o+1),d=this._config.lineCommentToken||qn[this._config.language]||"";if(!d)return;const l=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=a.every(u=>(this._tab.doc[u]??"").trimStart().startsWith(d));a.forEach(u=>{var m;const g=this._tab.doc[u]??"";this._tab.doc[u]=h?g.replace(new RegExp(`^(\\s*)${l}\\s?`),"$1"):g.replace(/^(\s*)/,`$1${d} `),this._tokenCache.invalidateLine(u,((m=this._wm.segments[u])==null?void 0:m.length)??1)}),this._tab.dirty=!0;const p=this._tab.doc.slice(r,o+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r,oldLines:c,newLines:p},i,n),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(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()}}class ds extends ls{_doUndo(){var e,t;this._snippetSession=null;const i=this._tab.undoStack[this._tab.undoStack.length-1],n=oa(this._tab);n!==null&&(this._extraCursors=n,this._mc.cursors=n,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,i&&(i.beforeRanges?this._readOnlyRanges=i.beforeRanges.map(a=>({...a})):this._shiftRangesForOpInverse(i.op)),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}_doRedo(){var e,t;this._snippetSession=null;const i=this._tab.redoStack[this._tab.redoStack.length-1],n=la(this._tab);n!==null&&(this._extraCursors=n,this._mc.cursors=n,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,i&&(i.afterRanges?this._readOnlyRanges=i.afterRanges.map(a=>({...a})):this._shiftRangesForOpForward(i.op)),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}}class cs extends ds{}class hs extends cs{_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=Sa(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}const t=this._findMatches.map((d,l)=>({m:d,i:l})).filter(({m:d})=>!this._isRangeReadOnly(d.row)),i=this._findMatches.length-t.length,n=i?` (+${i} locked)`:"";if(!t.length){this._findCount.textContent=`0/0${n}`,this._render();return}const a=t.findIndex(({i:d})=>d===this._findIdx),r=a===-1?e===1?0:t.length-1:(a+e+t.length)%t.length,{m:o,i:c}=t[r];this._findIdx=c,this._tab.cur={row:o.row,col:o.col},this._tab.sel={ar:o.row,ac:o.col,fr:o.row,fc:o.col+o.len},this._scrollIntoView(),this._render(),this._findCount.textContent=`${r+1}/${t.length}${n}`}_doReplaceOne(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches[this._findIdx];if(!i||this._isRangeReadOnly(i.row)){this._navFind(1);const d=this._findMatches[this._findIdx];if(!d||this._isRangeReadOnly(d.row))return}const n=this._findMatches[this._findIdx];if(this._isRangeReadOnly(n.row))return;const a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=this._tab.doc[n.row]??"";this._tab.doc=$a(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const c=this._tab.doc[n.row]??"";E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n.row,oldLines:[o],newLines:[c]},a,r),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._rebuildWrapMap(),this._render()),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_doReplaceAll(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches.filter(p=>!this._isRangeReadOnly(p.row));if(!i.length)return;const n=i.length,a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=i[0].row,c=i[i.length-1].row,d=this._tab.doc.slice(o,c+1);this._tab.doc=Ra(this._tab.doc,i,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const l=this._tab.doc.slice(o,c+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:d,newLines:l},a,r),this._runFind(this._findInput.value),this._findIdx=-1;const h=this._findMatches.filter(p=>this._isRangeReadOnly(p.row)).length;this._findCount.textContent=h?`0/0 (${n} replaced, ${h} locked)`:`0/0 (${n} replaced)`,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_bindFindEvents(){var e,t,i,n,a,r,o;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",c=>{c.key==="Enter"?c.shiftKey?this._navFind(-1):this._navFind(1):c.key==="Escape"&&this._closeFind(),c.stopPropagation()}),this._replaceInput.addEventListener("keydown",c=>{c.key==="Enter"?this._doReplaceOne():c.key==="Escape"&&this._closeFind(),c.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()),(n=this._findBar.querySelector(".sl-find-case"))==null||n.addEventListener("click",c=>{this._findCaseSensitive=!this._findCaseSensitive,c.target.classList.toggle("sl-active",this._findCaseSensitive),c.target.setAttribute("aria-pressed",String(this._findCaseSensitive)),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(a=this._findBar.querySelector(".sl-find-regex"))==null||a.addEventListener("click",c=>{this._findRegex=!this._findRegex,c.target.classList.toggle("sl-active",this._findRegex),c.target.setAttribute("aria-pressed",String(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()),(o=this._findBar.querySelector(".sl-replace-all"))==null||o.addEventListener("click",()=>this._doReplaceAll())}}class ps extends hs{_acVisible(){return this._acPopup.style.display!=="none"}_acHide(){this._acPopup.style.display="none",this._acItems=[],this._inputEl.setAttribute("aria-expanded","false"),this._inputEl.setAttribute("aria-activedescendant","")}_acTrigger(){if(!this._config.autocomplete){this._acHide();return}this._acDebounceTimer!==null&&clearTimeout(this._acDebounceTimer),this._acDebounceTimer=setTimeout(()=>{this._acDebounceTimer=null,this._acTriggerNow()},ta)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}if(this._isRangeReadOnly(this._tab.cur.row)){this._acHide();return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",n=this._config.language==="css",{prefix:a,start:r}=Ea(i,e.col,n);this._acPrefix=a,this._acStartCol=r;const o=new Set(["html","xml"]),c=[];if(this._config.emmet&&o.has(this._config.language??"typescript")){const l=Ot(i,e.col);if(l){const h=Pt(l.abbr);if(h){this._emmetAcStartCol=l.start;const p=h.replace(/\n/g,"↵ ").slice(0,60);c.push({label:l.abbr,kind:"emmet",detail:p,body:h})}}}const d=a.length>=this._config.autocompletePrefixLength?Ta(t,a,{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=[...c,...d],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const e=d=>{switch(d){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 n=this._acItems.map((d,l)=>{const h=l===this._acSel,p=`${this._ariaId}-ac-${l}`;return`<div class="sl-ac-item${h?" sl-sel":""}" data-i="${l}" id="${p}" role="option" aria-selected="${h}"><span class="sl-ac-badge ${d.kind}">${e(d.kind)}</span><span class="sl-ac-label">${d.label}</span><span class="sl-ac-detail">${d.detail??""}</span></div>`}).join(""),a=i?`<div class="sl-ac-desc"><pre class="sl-ac-desc-body">${i.replace(/</g,"<")}</pre></div>`:"";this._acPopup.innerHTML=`<div class="sl-ac-list">${n}</div>`+a,this._acPopup.style.display="flex",this._inputEl.setAttribute("aria-expanded","true");const r=`${this._ariaId}-ac-${this._acSel}`;this._inputEl.setAttribute("aria-activedescendant",r),this._posAcPopup();const o=this._acPopup.querySelector(".sl-ac-list"),c=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(o&&c){const d=c.offsetTop,l=d+c.offsetHeight;l>o.scrollTop+o.clientHeight?o.scrollTop=l-o.clientHeight:d<o.scrollTop&&(o.scrollTop=d)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(d=>{d.addEventListener("mousedown",l=>{l.preventDefault(),this._acSel=parseInt(d.dataset.i??"0",10),this._acAccept()}),d.addEventListener("touchend",l=>{l.preventDefault(),this._acSel=parseInt(d.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=ae(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,n=e.left+i+ee+this._acStartCol*X,a=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,r=this._acPopup.querySelector(".sl-ac-desc")?620:300,o=Math.min(this._acItems.length*28+8,320),c=a+o>window.innerHeight-16;this._acPopup.style.left=`${Math.min(n,window.innerWidth-r-16)}px`,this._acPopup.style.top=`${c?a-this._config.lineHeight-2-o:a}px`}_acAccept(){const e=this._acItems[this._acSel];if(!e)return;if(this._acHide(),e.kind==="emmet"&&e.body){const r={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,c=this._tab.cur.row,d=this._tab.doc[c]??"";this._expandBodyAt(e.body,this._emmetAcStartCol);const l=this._tab.doc.slice(c,this._tab.cur.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c,oldLines:[d],newLines:l},r,o);return}if(e.body){const r={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,c=this._tab.cur.row,d=this._tab.doc[c]??"";this._expandBodyAt(e.body,this._acStartCol);const l=this._tab.doc.slice(c,this._tab.cur.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c,oldLines:[d],newLines:l},r,o);return}const t=this._tab.cur.row,i=this._tab.doc[t]??"",n=i.slice(0,this._acStartCol),a=i.slice(this._acStartCol+this._acPrefix.length);this._tab.doc[t]=n+e.label+a,this._tab.cur.col=this._acStartCol+e.label.length,this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render()}_allCompletions(){return[...this._config.replaceBuiltins?[]:_a(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;if(this._isRangeReadOnly(e.row)){this._emmetExpanded=null;return}const i=t[e.row]??"",n=Ot(i,e.col);if(!n){this._emmetExpanded=null;return}const a=Pt(n.abbr);if(!a){this._emmetExpanded=null;return}this._emmetExpanded={abbr:n.abbr,result:a,start:n.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{result:e,start:t}=this._emmetExpanded,i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,r=this._tab.doc[a]??"";this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(e,t);const o=this._tab.doc.slice(a,this._tab.cur.row+1);return E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a,oldLines:[r],newLines:o},i,n),!0}_snippetCheck(){if(this._snippetTip.style.display="none",!this._config.snippetExpansion){this._snippetExpanded=null;return}const{cur:e,doc:t}=this._tab;if(this._isRangeReadOnly(e.row)){this._snippetExpanded=null;return}const i=t[e.row]??"",n=va(i,e.col,this._allCompletions());if(!n){this._snippetExpanded=null;return}this._snippetExpanded={snippet:n.snippet,start:n.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},n=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,r=this._tab.doc[a]??"";this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t);const o=this._tab.doc.slice(a,this._tab.cur.row+1);return E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a,oldLines:[r],newLines:o},i,n),!0}_expandBodyAt(e,t){var i,n;const{doc:a,cur:r}=this._tab,o=r.row,c=a[r.row]??"",d=c.slice(0,t),l=c.slice(r.col),h=He(c),p=" ".repeat(this._config.tabSize??4),u=e.replace(/^\t+/gm,f=>p.repeat(f.length)).split(`
|
|
841
|
-
`).map((
|
|
842
|
-
`),g=[],w=/\$(\d+)/g;let k;for(;(k=w.exec(m))!==null;){const
|
|
843
|
-
`),$=x.length-1,S=x[$].length,T=(x[$].match(/\$\d+/g)??[]).join("").length,L=o+$,M=($===0?t:h.length)+(S-T);g.push({n:
|
|
838
|
+
`,this._applyTokenOverrides(),this._minimapWrap.style.width=`${o}px`,this._placeholderEl.style.left=`${p+ee}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,n=(r,o,c)=>{i.setProperty(r,o||c)},a=t==null?void 0:t.tokens;n("--tok-kw",e.keyword,(a==null?void 0:a.tokKw)??""),n("--tok-str",e.string,(a==null?void 0:a.tokStr)??""),n("--tok-cmt",e.comment,(a==null?void 0:a.tokCmt)??""),n("--tok-fn",e.function,(a==null?void 0:a.tokFn)??""),n("--tok-num",e.number,(a==null?void 0:a.tokNum)??""),n("--tok-cls",e.class,(a==null?void 0:a.tokCls)??""),n("--tok-op",e.operator,(a==null?void 0:a.tokOp)??""),n("--tok-typ",e.type,(a==null?void 0:a.tokTyp)??""),n("--tok-dec",e.decorator,(a==null?void 0:a.tokDec)??"")}_refreshMinimapColors(){this._mmColors=st(e=>He(e,this._host))}}const be=1e4,We=nt*4;class ds extends ls{constructor(){super(...arguments),_(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=Ha(this._foldedLines,this._tab.doc,i),this._foldedLines.has(i)){const n=this._foldedLines.get(i),a=this._tab.cur;a.row>i&&a.row<=n&&(this._tab.cur={row:i,col:(this._tab.doc[i]??"").length},this._tab.sel=null)}this._rebuildWrapMap(),this._render()}),_(this,"_onROInsertBtnClick",e=>{const t=e.target.closest(".sl-ro-ins");if(!t)return;e.preventDefault(),e.stopPropagation();const i=parseInt(t.dataset.row??"0",10),n=t.dataset.pos==="below";this._insertLineAtROBoundary(i,n)}),_(this,"_onROBlockMouseover",e=>{const t=e.target.closest(".sl-ro-row[data-ro-blk]");if(this._vpEl.querySelectorAll(".sl-ro-blk-hov").forEach(i=>i.classList.remove("sl-ro-blk-hov")),t){const i=t.dataset.roBlk;this._vpEl.querySelectorAll(`.sl-ro-row[data-ro-blk="${i}"]`).forEach(n=>n.classList.add("sl-ro-blk-hov"))}}),_(this,"_onROBlockMouseleave",e=>{this._vpEl.querySelectorAll(".sl-ro-blk-hov").forEach(t=>t.classList.remove("sl-ro-blk-hov"))})}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._render()}))}_render(){const{doc:e,cur:t,sel:i}=this._tab,{lineHeight:n}=this._config,a=e.length,r=a*n,o=Math.min(r,ce);this._spacerEl.style.height=`${o}px`;const c=this._editorEl.scrollTop,d=this._logicalScroll(c);a>be&&c!==this._lastRenderScroll&&(this._lastRenderScroll=c,this._rebuildWrapMap());const l=this._wm.totalVisualRows,h=this._editorEl.clientHeight,p=Math.max(0,Math.floor(d/n)-nt),u=Math.min(l-1,Math.ceil((d+h)/n)+nt),m=a>be?p:0,g=a>be?u:a-1;if(this._wordHighlights=this._config.wordHighlight?Ua(e,t.row,t.col,i,m,g).filter(T=>!this._isRangeReadOnly(T.row)):[],this._bracketMatch=this._config.bracketMatching?qa(e,t):null,this._config.wordWrap)this._spacerEl.style.width="",this._vpEl.style.width="";else{const T=a>be?this._wm.visualRows.reduce((B,te)=>Math.max(B,(e[te.docLine]??"").length),0):e.reduce((B,te)=>Math.max(B,te.length),0),L=this._config.showGutter?this._config.gutterWidth:0,M=Math.max(this._editorEl.clientWidth,L+ee+Math.ceil(T*X)+Lt+64);this._spacerEl.style.width=`${M}px`,this._vpEl.style.width=`${M}px`}this._vpEl.style.transform=`translateY(${c+(p*n-d)}px)`;const w=se(this._wm,t.row,t.col),k=new Map;if(this._snippetSession)for(let T=this._snippetSession.idx+1;T<this._snippetSession.stops.length;T++){const L=this._snippetSession.stops[T],M=se(this._wm,L.row,L.col),B=k.get(M.visRow)??[];B.push(M.colInSeg),k.set(M.visRow,B)}const C=this._wm.windowVisStart,y=new Set;for(const T of this._readOnlyRanges)for(let L=T.start;L<=T.end;L++)y.add(L);const f=new Set,b=new Set,x=new Map;this._readOnlyRanges.forEach((T,L)=>{f.add(T.start),b.add(T.end);for(let M=T.start;M<=T.end;M++)x.set(M,L)});const $=new Set;if(i){const T=O(i);for(let L=T.ar+1;L<T.fr;L++)$.add(L);T.ac===0&&T.fr>T.ar&&$.add(T.ar),T.fc>=(e[T.fr]??"").length&&T.fr>T.ar&&$.add(T.fr),T.ar===T.fr&&T.ac===0&&T.fc>=(e[T.ar]??"").length&&$.add(T.ar)}let S="";for(let T=p;T<=u;T++){const L=this._wm.visualRows[T-C];L&&(S+=ja({vr:L,visIdx:T,curVisRow:w.visRow,curColInSeg:w.colInSeg,docSel:i,findMatches:this._findMatches,findIdx:this._findIdx,wordHighlights:this._wordHighlights,bracketMatch:this._bracketMatch,extraCursors:this._extraCursors,snippetStopCols:k.get(T)??[],foldedLines:this._foldedLines,isFoldable:this._config.codeFolding&&Pa(e,L.docLine),readOnlyLines:y,roFirstRows:f,roLastRows:b,roBlkIdx:x,selFullRows:$,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:X,codePaddingLeft:ee,tabSize:this._config.tabSize,lineHeight:n,renderWhitespace:this._config.renderWhitespace}}))}if(this._renderedRowCount=Math.max(0,u-p+1),this._vpEl.innerHTML=S,this._updateStatusBar(),this._updateMinimap(),this._config.placeholder){const T=this._tab.doc.length===1&&this._tab.doc[0]==="";this._placeholderEl.style.display=T?"":"none"}else this._placeholderEl.style.display="none"}_updateStatusBar(){if(!this._config.showStatusBar)return;const{cur:e,doc:t,undoStack:i,redoStack:n}=this._tab,a=this._config.language,r={typescript:"TypeScript",javascript:"JavaScript",css:"CSS",json:"JSON",markdown:"Markdown",text:"Text"},o=p=>this._statusBar.querySelector(p);o(".sl-sb-lang").textContent=`⬡ ${r[a]??a}`,o(".sl-sb-pos").textContent=`Ln ${e.row+1}, Col ${e.col+1}`,o(".sl-sb-lines").textContent=`${t.length.toLocaleString()} lines`;const c=ma(this._tab),d=o(".sl-sb-sel"),l=o(".sl-sb-sel-sep");d.textContent=c?`${c.toLocaleString()} selected`:"",l.style.display=c?"":"none",o(".sl-sb-undo").textContent=`↩${i.length} ↪${n.length}`;const h=o(".sl-sb-mc");this._extraCursors.length?(h.style.display="",o(".sl-sb-mc-count").textContent=String(this._extraCursors.length+1)):h.style.display="none",o(".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,n=i.length,a=Math.min(window.devicePixelRatio||1,2),r=this._config.lineHeight,{mmScroll:o,sliderTop:c,sliderHeight:d}=at(n,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,t,r),l=o/2,h=Math.floor(l),p=Math.ceil(t/2)+2,u=Math.min(n,h+p),m=(u-h)*2,g=(l-h)*2,w=Math.round(e*a),k=Math.round(m*a);(this._mmCanvas.width!==w||this._mmCanvas.height!==k)&&(this._mmCanvas.width=w,this._mmCanvas.height=k,this._mmCanvas.style.width=`${e}px`,this._mmCanvas.style.height=`${m}px`),this._mmCanvas.style.transform=`translateY(${-g}px)`,ca({canvas:this._mmCanvas,doc:i,firstLine:h,lastLine:u,subPx:g,wrapperWidth:e,canvasHeight:m,cursorRow:this._tab.cur.row,sel:this._tab.sel,findMatches:this._findMatches,findIdx:this._findIdx,sliderTop:c,sliderHeight:d,colors:this._mmColors,getCssVar:f=>He(f,this._host),dpr:a,tokenCache:this._tokenCache,language:this._config.language,provideTokens:this._config.provideTokens});const C=Math.max(0,Math.min(t-d,c));this._mmSlider.style.top=`${C}px`,this._mmSlider.style.height=`${d}px`;const y=t>0?Math.round(C/t*100):0;this._mmSlider.setAttribute("aria-valuenow",String(y))}_rebuildWrapMap(){let e;if(this._config.wordWrap){const i=this._config.showGutter?this._config.gutterWidth:0,n=this._editorEl.clientWidth;if(n>0){const a=n-i-ee-Lt;e=Math.max(20,Math.floor(a/X))}else e=this._config.wrapColumn}else e=9999;const t=this._tab.doc.length;if(t>be){const i=this._config.lineHeight,n=this._editorEl.scrollTop,a=this._logicalScroll(n),r=this._editorEl.clientHeight,o=this._tab.cur.row,c=Math.max(0,Math.floor(a/i)-We),d=Math.min(t-1,Math.ceil((a+r)/i)+We),l=this._config.wordWrap||this._foldedLines.size>0,h=l?Math.max(0,Math.min(c,o-We)):c,p=l?Math.min(t-1,Math.max(d,o+We)):d;this._wm=Wt(this._tab.doc,e,this._config.wordWrap,this._foldedLines,h,p)}else this._wm=Wt(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,n=Math.min(i,ce);this._spacerEl.style.height=`${n}px`;const a=se(this._wm,e.row,e.col).visRow*t,r=a+t,o=this._domScroll(a),c=this._domScroll(r),d=this._editorEl.scrollTop,l=this._editorEl.clientHeight,h=t*3;o<d+h?this._editorEl.scrollTop=Math.max(0,o-h):c>d+l-h&&(this._editorEl.scrollTop=c-l+h)}}class cs extends ds{_insertStr(e,t){var i,n;const a=Date.now(),r=!t||a-this._lastInputTime>this._config.undoBatchMs;this._lastInputTime=a;const o={...this._tab.cur},c=this._tab.sel?{...this._tab.sel}:null;let d,l;if(this._tab.sel){const k=O(this._tab.sel);if(d=k.ar,l=this._tab.doc.slice(k.ar,k.fr+1),this._isRangeReadOnly(k.ar,k.fr))return;this._tab.cur=U(this._tab)}else if(d=this._tab.cur.row,l=[this._tab.doc[d]??""],this._isRangeReadOnly(d))return;const{doc:h,cur:p}=this._tab,u=e.split(`
|
|
839
|
+
`),m=h[p.row]??"",g=m.slice(0,p.col),w=m.slice(p.col);if(u.length===1)h[p.row]=g+e+w,p.col+=e.length;else{const k=[g+u[0]];for(let C=1;C<u.length-1;C++)k.push(u[C]);k.push(u[u.length-1]+w),h.splice(p.row,1,...k),p.row+=u.length-1,p.col=u[u.length-1].length}if(r){const k=h.slice(d,p.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d,oldLines:l,newLines:k},o,c);const C=k.length-l.length;C!==0&&this._shiftRanges(d+l.length,C)}this._tokenCache.invalidateLine(p.row,(this._wm.segments[p.row]??[""]).length),this._tab.dirty=!0,(n=(i=this._config).onChange)==null||n.call(i,D(h))}_doBackspace(){var e;const t={...this._tab.cur},i=this._tab.sel?{...this._tab.sel}:null;if(this._tab.sel){const r=O(this._tab.sel);if(this._isRangeReadOnly(r.ar,r.fr)){this._partialDeleteSelection();return}const o=this._tab.doc.slice(r.ar,r.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const c=[this._tab.doc[r.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r.ar,oldLines:o,newLines:c},t,i);const d=1-o.length;d!==0&&this._shiftRanges(r.ar+o.length,d);return}const{doc:n,cur:a}=this._tab;if(a.col>0){if(this._isRangeReadOnly(a.row))return;const r=n[a.row]??"",o=r.slice(0,a.col),c=o.length>=2&&o.endsWith(" ")&&!o.trim()?2:1;n[a.row]=r.slice(0,a.col-c)+r.slice(a.col),a.col-=c,this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r],newLines:[n[a.row]]},t,i)}else if(a.row>0){if(this._isRangeReadOnly(a.row-1,a.row)){if(!this._isRangeReadOnly(a.row)&&(n[a.row]??"")===""){const l=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:l,count:1,removed:[""]},t,i),this._shiftRanges(l+1,-1);let h=l-1;for(;h>0&&this._isRangeReadOnly(h);)h--;if(this._isRangeReadOnly(h))for(h=Math.min(l,n.length-1);h<n.length-1&&this._isRangeReadOnly(h);)h++;a.row=Math.max(0,Math.min(h,n.length-1)),a.col=this._isRangeReadOnly(a.row)?0:(n[a.row]??"").length,R(this._tab)}else if(!this._isRangeReadOnly(a.row)){let l=a.row-1;for(;l>0&&this._isRangeReadOnly(l);)l--;if(!this._isRangeReadOnly(l)){const h=[...n],p=n[l]??"",u=n[a.row]??"",m=a.row;n[l]=p+u,n.splice(m,1),a.row=l,a.col=p.length,this._tokenCache.clear(),this._tab.dirty=!0;const g=he(h,n);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:g.row,oldLines:g.oldLines,newLines:g.newLines},t,i),this._shiftRanges(m+1,-1),R(this._tab)}}return}const r=n[a.row-1]??"",o=n[a.row]??"",c=r.length,d=a.row;n[a.row-1]=r+o,n.splice(a.row,1),a.row--,a.col=c,this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r,o],newLines:[n[a.row]]},t,i),this._shiftRanges(d+1,-1)}else return;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 o=O(this._tab.sel);if(this._isRangeReadOnly(o.ar,o.fr)){this._partialDeleteSelection();return}const c=this._tab.doc.slice(o.ar,o.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[o.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.ar,oldLines:c,newLines:d},t,i);const l=1-c.length;l!==0&&this._shiftRanges(o.ar+c.length,l);return}const{doc:n,cur:a}=this._tab,r=n[a.row]??"";if(a.col<r.length){if(this._isRangeReadOnly(a.row))return;const o=r;n[a.row]=r.slice(0,a.col)+r.slice(a.col+1),this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o],newLines:[n[a.row]]},t,i)}else if(a.row<n.length-1){if(this._isRangeReadOnly(a.row,a.row+1)){if(!this._isRangeReadOnly(a.row)&&(n[a.row]??"")===""){const d=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:d,count:1,removed:[""]},t,i),this._shiftRanges(d+1,-1);let l=Math.min(d,n.length-1);for(;l<n.length-1&&this._isRangeReadOnly(l);)l++;if(this._isRangeReadOnly(l))for(l=d-1;l>0&&this._isRangeReadOnly(l);)l--;a.row=Math.max(0,Math.min(l,n.length-1)),a.col=(this._isRangeReadOnly(a.row),0),R(this._tab)}return}const o=r,c=n[a.row+1]??"";n[a.row]=o+c,n.splice(a.row+1,1),this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o,c],newLines:[n[a.row]]},t,i),this._shiftRanges(a.row+2,-1)}else return;this._tab.dirty=!0}_doEnter(){const e={...this._tab.cur},t=this._tab.sel?{...this._tab.sel}:null;let i,n;if(this._tab.sel){const m=O(this._tab.sel);if(this._isRangeReadOnly(m.ar,m.fr))return;i=m.ar,n=this._tab.doc.slice(m.ar,m.fr+1),this._tab.cur=U(this._tab)}else{if(this._isRangeReadOnly(this._tab.cur.row))return;i=this._tab.cur.row,n=[this._tab.doc[i]??""]}const{doc:a,cur:r}=this._tab,o=a[r.row]??"",c=o.slice(0,r.col),d=o.slice(r.col),l=je(o),h=c.trimEnd().endsWith("{")?Ne(this._config.tabSize):"";a[r.row]=c,c.trimEnd().endsWith("{")&&d.trimStart()==="}"?a.splice(r.row+1,0,l+h,l+d):a.splice(r.row+1,0,l+h+d),r.row++,r.col=l.length+h.length,this._tokenCache.clear();const p=a.slice(i,r.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:i,oldLines:n,newLines:p},e,t);const u=p.length-n.length;u!==0&&this._shiftRanges(i+n.length,u),this._tab.dirty=!0}_partialDeleteSelection(){if(!this._tab.sel)return!1;const e=this._tab.doc,t=O(this._tab.sel),i=[];let n=null;for(let m=t.ar;m<=t.fr;m++)if(!this._isRangeReadOnly(m))n||(n={row:m,col:m===t.ar?t.ac:0});else if(n){const g=m-1,w=g===t.fr?t.fc:(e[g]??"").length;i.push({ar:n.row,ac:n.col,fr:g,fc:w}),n=null}if(n&&i.push({ar:n.row,ac:n.col,fr:t.fr,fc:t.fc}),i.length===0)return!1;const a={...this._tab.cur},r={...this._tab.sel},o=e.slice(t.ar,t.fr+1),c=this._readOnlyRanges.map(m=>({...m}));let d={...this._tab.cur};for(let m=i.length-1;m>=0;m--){const g=i[m];this._tab.sel={ar:g.ar,ac:g.ac,fr:g.fr,fc:g.fc},d=U(this._tab);const w=g.fr-g.ar;w>0&&this._shiftRanges(g.ar+1,-w)}this._tab.sel=null,this._tab.cur=d;const l=i.reduce((m,g)=>m+(g.fr-g.ar),0),h=t.fr-l,p=this._tab.doc.slice(t.ar,h+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:t.ar,oldLines:o,newLines:p},a,r);const u=this._tab.undoStack[this._tab.undoStack.length-1];return u.beforeRanges=c,u.afterRanges=this._readOnlyRanges.map(m=>({...m})),this._tokenCache.clear(),this._tab.dirty=!0,!0}}class hs extends cs{_wordSkipRight(e,t){let i=t;const n=e.length;for(;i<n&&/\s/.test(e[i]);)i++;if(i>=n)return i;if(/\w/.test(e[i]))for(;i<n&&/\w/.test(e[i]);)i++;else for(;i<n&&/[^\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 o=O(this._tab.sel);if(this._isRangeReadOnly(o.ar,o.fr))return;const c=this._tab.doc.slice(o.ar,o.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const d=[this._tab.doc[o.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o.ar,oldLines:c,newLines:d},t,i);const l=1-c.length;l!==0&&this._shiftRanges(o.ar+c.length,l);return}const{doc:n,cur:a}=this._tab;if(a.col===0){if(a.row===0)return;if(this._isRangeReadOnly(a.row-1,a.row)){if(!this._isRangeReadOnly(a.row)){const h=n[a.row]??"";if(h===""){const p=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:p,count:1,removed:[""]},t,i),this._shiftRanges(p+1,-1);let u=p-1;for(;u>0&&this._isRangeReadOnly(u);)u--;if(this._isRangeReadOnly(u))for(u=Math.min(p,n.length-1);u<n.length-1&&this._isRangeReadOnly(u);)u++;a.row=Math.max(0,Math.min(u,n.length-1)),a.col=this._isRangeReadOnly(a.row)?0:(n[a.row]??"").length,R(this._tab)}else{let p=a.row-1;for(;p>0&&this._isRangeReadOnly(p);)p--;if(!this._isRangeReadOnly(p)){const u=[...n],m=n[p]??"",g=a.row;n[p]=m+h,n.splice(g,1),a.row=p,a.col=m.length,this._tokenCache.clear(),this._tab.dirty=!0;const w=he(u,n);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:w.row,oldLines:w.oldLines,newLines:w.newLines},t,i),this._shiftRanges(g+1,-1),R(this._tab)}}}return}const o=n[a.row-1]??"",c=n[a.row]??"",d=o.length,l=a.row;n[a.row-1]=o+c,n.splice(a.row,1),a.row--,a.col=d,this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o,c],newLines:[n[a.row]]},t,i),this._shiftRanges(l+1,-1),this._tab.dirty=!0;return}if(this._isRangeReadOnly(a.row))return;const r=n[a.row]??"";n[a.row]=r.slice(a.col),a.col=0,this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r],newLines:[n[a.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 d=O(this._tab.sel);if(this._isRangeReadOnly(d.ar,d.fr))return;const l=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[d.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:l,newLines:h},t,i);const p=1-l.length;p!==0&&this._shiftRanges(d.ar+l.length,p);return}const{doc:n,cur:a}=this._tab;if(a.col===0){if(a.row>0){if(this._isRangeReadOnly(a.row-1,a.row)){if(!this._isRangeReadOnly(a.row)&&(n[a.row]??"")===""){const u=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:u,count:1,removed:[""]},t,i),this._shiftRanges(u+1,-1);let m=u-1;for(;m>0&&this._isRangeReadOnly(m);)m--;if(this._isRangeReadOnly(m))for(m=Math.min(u,n.length-1);m<n.length-1&&this._isRangeReadOnly(m);)m++;a.row=Math.max(0,Math.min(m,n.length-1)),a.col=this._isRangeReadOnly(a.row)?0:(n[a.row]??"").length,R(this._tab)}else if(!this._isRangeReadOnly(a.row)){let u=a.row-1;for(;u>0&&this._isRangeReadOnly(u);)u--;if(!this._isRangeReadOnly(u)){const m=[...n],g=n[u]??"",w=n[a.row]??"",k=a.row;n[u]=g+w,n.splice(k,1),a.row=u,a.col=g.length,this._tokenCache.clear(),this._tab.dirty=!0;const C=he(m,n);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:C.row,oldLines:C.oldLines,newLines:C.newLines},t,i),this._shiftRanges(k+1,-1),R(this._tab)}}return}const d=n[a.row-1]??"",l=n[a.row]??"",h=d.length,p=a.row;n[a.row-1]=d+l,n.splice(a.row,1),a.row--,a.col=h,this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[d,l],newLines:[n[a.row]]},t,i),this._shiftRanges(p+1,-1),this._tab.dirty=!0}return}if(this._isRangeReadOnly(a.row))return;const r=n[a.row]??"",o=this._wordSkipLeft(r,a.col),c=r;n[a.row]=r.slice(0,o)+r.slice(a.col),a.col=o,this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[c],newLines:[n[a.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 c=O(this._tab.sel);if(this._isRangeReadOnly(c.ar,c.fr))return;const d=this._tab.doc.slice(c.ar,c.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const l=[this._tab.doc[c.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c.ar,oldLines:d,newLines:l},t,i);const h=1-d.length;h!==0&&this._shiftRanges(c.ar+d.length,h);return}const{doc:n,cur:a}=this._tab,r=n[a.row]??"";if(a.col>=r.length){if(a.row>=n.length-1)return;if(this._isRangeReadOnly(a.row,a.row+1)){if(!this._isRangeReadOnly(a.row)&&r===""){const d=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:d,count:1,removed:[""]},t,i),this._shiftRanges(d+1,-1);let l=Math.min(d,n.length-1);for(;l<n.length-1&&this._isRangeReadOnly(l);)l++;if(this._isRangeReadOnly(l))for(l=d-1;l>0&&this._isRangeReadOnly(l);)l--;a.row=Math.max(0,Math.min(l,n.length-1)),a.col=0,R(this._tab)}return}const c=n[a.row+1]??"";n[a.row]=r+c,n.splice(a.row+1,1),this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[r,c],newLines:[n[a.row]]},t,i),this._shiftRanges(a.row+2,-1),this._tab.dirty=!0;return}if(this._isRangeReadOnly(a.row))return;const o=r;n[a.row]=r.slice(0,a.col),this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[o],newLines:[n[a.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 d=O(this._tab.sel);if(this._isRangeReadOnly(d.ar,d.fr))return;const l=this._tab.doc.slice(d.ar,d.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const h=[this._tab.doc[d.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d.ar,oldLines:l,newLines:h},t,i);const p=1-l.length;p!==0&&this._shiftRanges(d.ar+l.length,p);return}const{doc:n,cur:a}=this._tab,r=n[a.row]??"";if(a.col>=r.length){if(a.row<n.length-1){if(this._isRangeReadOnly(a.row,a.row+1)){if(!this._isRangeReadOnly(a.row)&&r===""){const h=a.row;n.splice(a.row,1),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:h,count:1,removed:[""]},t,i),this._shiftRanges(h+1,-1);let p=Math.min(h,n.length-1);for(;p<n.length-1&&this._isRangeReadOnly(p);)p++;if(this._isRangeReadOnly(p))for(p=h-1;p>0&&this._isRangeReadOnly(p);)p--;a.row=Math.max(0,Math.min(p,n.length-1)),a.col=0,R(this._tab)}return}const d=n[a.row+1]??"",l=r;n[a.row]=r+d,n.splice(a.row+1,1),this._tokenCache.clear(),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[l,d],newLines:[n[a.row]]},t,i),this._shiftRanges(a.row+2,-1),this._tab.dirty=!0}return}if(this._isRangeReadOnly(a.row))return;const o=this._wordSkipRight(r,a.col),c=r;n[a.row]=r.slice(0,a.col)+r.slice(o),this._tokenCache.invalidateLine(a.row,((e=this._wm.segments[a.row])==null?void 0:e.length)??1),E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a.row,oldLines:[c],newLines:[n[a.row]]},t,i),this._tab.dirty=!0}}class ps extends hs{_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=Dt(this._tab);if(i)this._linewiseCopy=!1,(e=navigator.clipboard)==null||e.writeText(i).catch(()=>{});else{this._linewiseCopy=!0;const n=(this._tab.doc[this._tab.cur.row]??"")+`
|
|
840
|
+
`;(t=navigator.clipboard)==null||t.writeText(n).catch(()=>{})}}_doCut(){var e,t,i,n,a,r;const o=Dt(this._tab);if(o){const c=O(this._tab.sel);if(this._isRangeReadOnly(c.ar,c.fr))return;this._linewiseCopy=!1,(e=navigator.clipboard)==null||e.writeText(o).catch(()=>{});const d={...this._tab.cur},l=this._tab.sel?{...this._tab.sel}:null,h=this._tab.doc.slice(c.ar,c.fr+1);this._tab.cur=U(this._tab),this._tokenCache.clear(),this._tab.dirty=!0;const p=[this._tab.doc[c.ar]??""];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c.ar,oldLines:h,newLines:p},d,l);const u=1-h.length;u!==0&&this._shiftRanges(c.ar+h.length,u),this._rebuildWrapMap(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc))}else{if(this._isRangeReadOnly(this._tab.cur.row))return;this._linewiseCopy=!0;const{doc:c,cur:d}=this._tab,l={...d},h=c[d.row]??"";(n=navigator.clipboard)==null||n.writeText(h+`
|
|
841
|
+
`).catch(()=>{}),c.length>1?(c.splice(d.row,1),R(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:l.row,count:1,removed:[h]},l,null),this._shiftRanges(l.row+1,-1)):(c[0]="",d.col=0,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[h],newLines:[""]},l,null)),this._rebuildWrapMap(),R(this._tab),this._render(),(r=(a=this._config).onChange)==null||r.call(a,D(this._tab.doc))}}}class us extends ps{_doInsertLineBelow(){var e,t,i,n;if(this._isRangeReadOnly(this._tab.cur.row))return;const a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,c=je(this._tab.doc[o]??"");this._tab.doc.splice(o+1,0,c),this._tab.cur.row=o+1,this._tab.cur.col=c.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:o+1,lines:[c]},a,r),this._shiftRanges(o+1,1),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)),(n=(i=this._config).onCursorChange)==null||n.call(i,{...this._tab.cur})}_doInsertLineAbove(){var e,t,i,n;if(this._isRangeReadOnly(this._tab.cur.row))return;const a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=this._tab.cur.row,c=je(this._tab.doc[o]??"");this._tab.doc.splice(o,0,c),this._tab.cur.row=o,this._tab.cur.col=c.length,this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:o,lines:[c]},a,r),this._shiftRanges(o,1),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)),(n=(i=this._config).onCursorChange)==null||n.call(i,{...this._tab.cur})}_insertLineAtROBoundary(e,t){var i,n,a,r;const o={...this._tab.cur},c=this._tab.sel?{...this._tab.sel}:null,d=t?e+1:e;this._tab.doc.splice(d,0,""),this._tab.sel=null,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[""]},o,c),this._shiftRanges(d,1),this._tab.cur={row:d,col:0},this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc)),(r=(a=this._config).onCursorChange)==null||r.call(a,{...this._tab.cur})}_duplicateLine(){var e,t;if(this._isRangeReadOnly(this._tab.cur.row))return;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,r=this._tab.doc[a]??"";this._tab.doc.splice(a+1,0,r),this._tab.cur.row++,this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:a+1,lines:[r]},i,n),this._shiftRanges(a+1,1),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_deleteLine(){var e,t;if(this._isRangeReadOnly(this._tab.cur.row))return;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,{doc:a,cur:r}=this._tab;if(a.length>1){const o=r.row,c=[a[o]??""];a.splice(o,1),R(this._tab),this._tokenCache.clear(),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"delete",row:o,count:1,removed:c},i,n),this._shiftRanges(o+1,-1)}else{const o=a[0]??"";a[0]="",r.col=0,E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:[o],newLines:[""]},i,n)}this._tokenCache.clear(),this._tab.dirty=!0,R(this._tab),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_duplicateLines(e){var t,i,n,a;const{doc:r,cur:o}=this._tab,c=this._tab.sel;let d=o.row,l=o.row;if(c){const m=O(c);d=m.ar,l=m.fr,m.fc===0&&m.fr>m.ar&&l--}if(this._isRangeReadOnly(d,l))return;const h={...this._tab.cur},p=c?{...c}:null,u=r.slice(d,l+1);e?(r.splice(l+1,0,...u),o.row+=u.length,c&&(c.ar+=u.length,c.fr+=u.length),E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:l+1,lines:[...u]},h,p),this._shiftRanges(l+1,u.length)):(r.splice(d,0,...u),E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[...u]},h,p),this._shiftRanges(d,u.length)),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc)),(a=(n=this._config).onCursorChange)==null||a.call(n,{...this._tab.cur})}_moveLines(e){var t,i,n,a;const{doc:r,cur:o}=this._tab,c=this._tab.sel;let d=o.row,l=o.row;if(c){const h=O(c);d=h.ar,l=h.fr,h.fc===0&&h.fr>h.ar&&l--}if(e){if(this._isRangeReadOnly(d,l)||d===0)return;let h=d-1;const p=this._isRangeReadOnly(h);for(;h>0&&this._isRangeReadOnly(h);)h--;const u={...this._tab.cur},m=c?{...c}:null,g=l-d+1,w=this._readOnlyRanges.map(x=>({...x})),k=r.slice(h,l+1),C=r.splice(d,g);this._shiftRanges(d+g,-g);let y;p?this._isRangeReadOnly(h)?y=0:y=h+1:y=h,r.splice(y,0,...C),this._shiftRanges(y,g);const f=d-y;o.row-=f,c&&(c.ar-=f,c.fr-=f);const b=r.slice(h,l+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:h,oldLines:k,newLines:b},u,m);{const x=this._tab.undoStack[this._tab.undoStack.length-1];x.beforeRanges=w,x.afterRanges=this._readOnlyRanges.map($=>({...$}))}}else{if(this._isRangeReadOnly(d,l))return;let h=l+1;const p=this._isRangeReadOnly(h);for(;h<r.length&&this._isRangeReadOnly(h);)h++;const u={...this._tab.cur},m=c?{...c}:null,g=l-d+1,w=this._readOnlyRanges.map(x=>({...x})),k=h<r.length?r.slice(d,h+1):r.slice(d);h>=r.length&&(r.push(""),h=r.length-1);const C=r.splice(d,g);this._shiftRanges(d+g,-g);const y=p?h-g:h-g+1;r.splice(y,0,...C),this._shiftRanges(y,g);const f=y-d;o.row+=f,c&&(c.ar+=f,c.fr+=f);const b=r.slice(d,h+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:d,oldLines:k,newLines:b},u,m);{const x=this._tab.undoStack[this._tab.undoStack.length-1];x.beforeRanges=w,x.afterRanges=this._readOnlyRanges.map($=>({...$}))}}this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc)),(a=(n=this._config).onCursorChange)==null||a.call(n,{...this._tab.cur})}}class gs extends us{_getSelRows(){if(!this._tab.sel)return[this._tab.cur.row];const e=O(this._tab.sel),t=[];for(let i=e.ar;i<=e.fr;i++)t.push(i);return t}_indentSel(){var e,t;if(!this._tab.sel){this._insertStr(Ne(this._config.tabSize),!1);return}const i={...this._tab.cur},n={...this._tab.sel},a=Ne(this._config.tabSize),r=this._getSelRows(),o=r[0],c=r[r.length-1];if(this._isRangeReadOnly(o,c))return;const d=this._tab.doc.slice(o,c+1);r.forEach(h=>{var p;this._tab.doc[h]=a+(this._tab.doc[h]??""),this._tokenCache.invalidateLine(h,((p=this._wm.segments[h])==null?void 0:p.length)??1)}),this._tab.dirty=!0;const l=this._tab.doc.slice(o,c+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:d,newLines:l},i,n),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_unindentSel(){var e,t;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._config.tabSize,r=this._getSelRows(),o=r[0],c=r[r.length-1];if(this._isRangeReadOnly(o,c))return;const d=this._tab.doc.slice(o,c+1);r.forEach(h=>{var p;const u=this._tab.doc[h]??"";u.startsWith(Ne(a))?this._tab.doc[h]=u.slice(a):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 l=this._tab.doc.slice(o,c+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:d,newLines:l},i,n),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_toggleComment(){var e,t;const i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._getSelRows(),r=a[0],o=a[a.length-1];if(this._isRangeReadOnly(r,o))return;const c=this._tab.doc.slice(r,o+1),d=this._config.lineCommentToken||Jn[this._config.language]||"";if(!d)return;const l=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=a.every(u=>(this._tab.doc[u]??"").trimStart().startsWith(d));a.forEach(u=>{var m;const g=this._tab.doc[u]??"";this._tab.doc[u]=h?g.replace(new RegExp(`^(\\s*)${l}\\s?`),"$1"):g.replace(/^(\s*)/,`$1${d} `),this._tokenCache.invalidateLine(u,((m=this._wm.segments[u])==null?void 0:m.length)??1)}),this._tab.dirty=!0;const p=this._tab.doc.slice(r,o+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:r,oldLines:c,newLines:p},i,n),this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(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()}}class ms extends gs{_doUndo(){var e,t;this._snippetSession=null;const i=this._tab.undoStack[this._tab.undoStack.length-1],n=ua(this._tab);n!==null&&(this._extraCursors=n,this._mc.cursors=n,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,i&&(i.beforeRanges?this._readOnlyRanges=i.beforeRanges.map(a=>({...a})):this._shiftRangesForOpInverse(i.op)),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}_doRedo(){var e,t;this._snippetSession=null;const i=this._tab.redoStack[this._tab.redoStack.length-1],n=ga(this._tab);n!==null&&(this._extraCursors=n,this._mc.cursors=n,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1,i&&(i.afterRanges?this._readOnlyRanges=i.afterRanges.map(a=>({...a})):this._shiftRangesForOpForward(i.op)),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc)))}}class fs extends ms{}class bs extends fs{_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=Ia(this._tab.doc,e,{caseSensitive:this._findCaseSensitive,useRegex:this._findRegex})}_navFind(e){if(!this._findMatches.length){this._findCount.textContent="0/0";return}const t=this._findMatches.map((d,l)=>({m:d,i:l})).filter(({m:d})=>!this._isRangeReadOnly(d.row)),i=this._findMatches.length-t.length,n=i?` (+${i} locked)`:"";if(!t.length){this._findCount.textContent=`0/0${n}`,this._render();return}const a=t.findIndex(({i:d})=>d===this._findIdx),r=a===-1?e===1?0:t.length-1:(a+e+t.length)%t.length,{m:o,i:c}=t[r];this._findIdx=c,this._tab.cur={row:o.row,col:o.col},this._tab.sel={ar:o.row,ac:o.col,fr:o.row,fc:o.col+o.len},this._scrollIntoView(),this._render(),this._findCount.textContent=`${r+1}/${t.length}${n}`}_doReplaceOne(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches[this._findIdx];if(!i||this._isRangeReadOnly(i.row)){this._navFind(1);const d=this._findMatches[this._findIdx];if(!d||this._isRangeReadOnly(d.row))return}const n=this._findMatches[this._findIdx];if(this._isRangeReadOnly(n.row))return;const a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=this._tab.doc[n.row]??"";this._tab.doc=Ba(this._tab.doc,this._findMatches,this._findIdx,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const c=this._tab.doc[n.row]??"";E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:n.row,oldLines:[o],newLines:[c]},a,r),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._rebuildWrapMap(),this._render()),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_doReplaceAll(){var e,t;if(!this._findMatches.length)return;const i=this._findMatches.filter(p=>!this._isRangeReadOnly(p.row));if(!i.length)return;const n=i.length,a={...this._tab.cur},r=this._tab.sel?{...this._tab.sel}:null,o=i[0].row,c=i[i.length-1].row,d=this._tab.doc.slice(o,c+1);this._tab.doc=Da(this._tab.doc,i,this._replaceInput.value),this._tokenCache.clear(),this._tab.dirty=!0;const l=this._tab.doc.slice(o,c+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:o,oldLines:d,newLines:l},a,r),this._runFind(this._findInput.value),this._findIdx=-1;const h=this._findMatches.filter(p=>this._isRangeReadOnly(p.row)).length;this._findCount.textContent=h?`0/0 (${n} replaced, ${h} locked)`:`0/0 (${n} replaced)`,this._rebuildWrapMap(),this._render(),(t=(e=this._config).onChange)==null||t.call(e,D(this._tab.doc))}_bindFindEvents(){var e,t,i,n,a,r,o;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",c=>{c.key==="Enter"?c.shiftKey?this._navFind(-1):this._navFind(1):c.key==="Escape"&&this._closeFind(),c.stopPropagation()}),this._replaceInput.addEventListener("keydown",c=>{c.key==="Enter"?this._doReplaceOne():c.key==="Escape"&&this._closeFind(),c.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()),(n=this._findBar.querySelector(".sl-find-case"))==null||n.addEventListener("click",c=>{this._findCaseSensitive=!this._findCaseSensitive,c.target.classList.toggle("sl-active",this._findCaseSensitive),c.target.setAttribute("aria-pressed",String(this._findCaseSensitive)),this._runFind(this._findInput.value),this._findIdx=-1,this._findMatches.length?this._navFind(1):(this._findCount.textContent="0/0",this._render())}),(a=this._findBar.querySelector(".sl-find-regex"))==null||a.addEventListener("click",c=>{this._findRegex=!this._findRegex,c.target.classList.toggle("sl-active",this._findRegex),c.target.setAttribute("aria-pressed",String(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()),(o=this._findBar.querySelector(".sl-replace-all"))==null||o.addEventListener("click",()=>this._doReplaceAll())}}class ys extends bs{_acVisible(){return this._acPopup.style.display!=="none"}_acHide(){this._acPopup.style.display="none",this._acItems=[],this._inputEl.setAttribute("aria-expanded","false"),this._inputEl.setAttribute("aria-activedescendant","")}_acTrigger(){if(!this._config.autocomplete){this._acHide();return}this._acDebounceTimer!==null&&clearTimeout(this._acDebounceTimer),this._acDebounceTimer=setTimeout(()=>{this._acDebounceTimer=null,this._acTriggerNow()},oa)}_acTriggerNow(){if(!this._config.autocomplete){this._acHide();return}if(this._isRangeReadOnly(this._tab.cur.row)){this._acHide();return}const{cur:e,doc:t}=this._tab,i=t[e.row]??"",n=this._config.language==="css",{prefix:a,start:r}=Aa(i,e.col,n);this._acPrefix=a,this._acStartCol=r;const o=new Set(["html","xml"]),c=[];if(this._config.emmet&&o.has(this._config.language??"typescript")){const l=zt(i,e.col);if(l){const h=Ft(l.abbr);if(h){this._emmetAcStartCol=l.start;const p=h.replace(/\n/g,"↵ ").slice(0,60);c.push({label:l.abbr,kind:"emmet",detail:p,body:h})}}}const d=a.length>=this._config.autocompletePrefixLength?La(t,a,{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=[...c,...d],!this._acItems.length){this._acHide();return}this._acSel=0,this._renderAcPopup()}_renderAcPopup(){const e=d=>{switch(d){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 n=this._acItems.map((d,l)=>{const h=l===this._acSel,p=`${this._ariaId}-ac-${l}`;return`<div class="sl-ac-item${h?" sl-sel":""}" data-i="${l}" id="${p}" role="option" aria-selected="${h}"><span class="sl-ac-badge ${d.kind}">${e(d.kind)}</span><span class="sl-ac-label">${d.label}</span><span class="sl-ac-detail">${d.detail??""}</span></div>`}).join(""),a=i?`<div class="sl-ac-desc"><pre class="sl-ac-desc-body">${i.replace(/</g,"<")}</pre></div>`:"";this._acPopup.innerHTML=`<div class="sl-ac-list">${n}</div>`+a,this._acPopup.style.display="flex",this._inputEl.setAttribute("aria-expanded","true");const r=`${this._ariaId}-ac-${this._acSel}`;this._inputEl.setAttribute("aria-activedescendant",r),this._posAcPopup();const o=this._acPopup.querySelector(".sl-ac-list"),c=this._acPopup.querySelector(".sl-ac-item.sl-sel");if(o&&c){const d=c.offsetTop,l=d+c.offsetHeight;l>o.scrollTop+o.clientHeight?o.scrollTop=l-o.clientHeight:d<o.scrollTop&&(o.scrollTop=d)}this._acPopup.querySelectorAll(".sl-ac-item").forEach(d=>{d.addEventListener("mousedown",l=>{l.preventDefault(),this._acSel=parseInt(d.dataset.i??"0",10),this._acAccept()}),d.addEventListener("touchend",l=>{l.preventDefault(),this._acSel=parseInt(d.dataset.i??"0",10),this._acAccept()})})}_posAcPopup(){const e=this._editorEl.getBoundingClientRect(),t=se(this._wm,this._tab.cur.row,this._tab.cur.col),i=this._config.showGutter?this._config.gutterWidth:0,n=e.left+i+ee+this._acStartCol*X,a=e.top+(t.visRow*this._config.lineHeight-this._editorEl.scrollTop)+this._config.lineHeight+2,r=this._acPopup.querySelector(".sl-ac-desc")?620:300,o=Math.min(this._acItems.length*28+8,320),c=a+o>window.innerHeight-16;this._acPopup.style.left=`${Math.min(n,window.innerWidth-r-16)}px`,this._acPopup.style.top=`${c?a-this._config.lineHeight-2-o:a}px`}_acAccept(){const e=this._acItems[this._acSel];if(!e)return;if(this._acHide(),e.kind==="emmet"&&e.body){const r={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,c=this._tab.cur.row,d=this._tab.doc[c]??"";this._expandBodyAt(e.body,this._emmetAcStartCol);const l=this._tab.doc.slice(c,this._tab.cur.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c,oldLines:[d],newLines:l},r,o);return}if(e.body){const r={...this._tab.cur},o=this._tab.sel?{...this._tab.sel}:null,c=this._tab.cur.row,d=this._tab.doc[c]??"";this._expandBodyAt(e.body,this._acStartCol);const l=this._tab.doc.slice(c,this._tab.cur.row+1);E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:c,oldLines:[d],newLines:l},r,o);return}const t=this._tab.cur.row,i=this._tab.doc[t]??"",n=i.slice(0,this._acStartCol),a=i.slice(this._acStartCol+this._acPrefix.length);this._tab.doc[t]=n+e.label+a,this._tab.cur.col=this._acStartCol+e.label.length,this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render()}_allCompletions(){return[...this._config.replaceBuiltins?[]:$a(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;if(this._isRangeReadOnly(e.row)){this._emmetExpanded=null;return}const i=t[e.row]??"",n=zt(i,e.col);if(!n){this._emmetExpanded=null;return}const a=Ft(n.abbr);if(!a){this._emmetExpanded=null;return}this._emmetExpanded={abbr:n.abbr,result:a,start:n.start}}_emmetAccept(){if(!this._emmetExpanded||this._emmetTip.style.display==="none")return!1;const{result:e,start:t}=this._emmetExpanded,i={...this._tab.cur},n=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,r=this._tab.doc[a]??"";this._emmetExpanded=null,this._emmetTip.style.display="none",this._expandBodyAt(e,t);const o=this._tab.doc.slice(a,this._tab.cur.row+1);return E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a,oldLines:[r],newLines:o},i,n),!0}_snippetCheck(){if(this._snippetTip.style.display="none",!this._config.snippetExpansion){this._snippetExpanded=null;return}const{cur:e,doc:t}=this._tab;if(this._isRangeReadOnly(e.row)){this._snippetExpanded=null;return}const i=t[e.row]??"",n=Ra(i,e.col,this._allCompletions());if(!n){this._snippetExpanded=null;return}this._snippetExpanded={snippet:n.snippet,start:n.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},n=this._tab.sel?{...this._tab.sel}:null,a=this._tab.cur.row,r=this._tab.doc[a]??"";this._snippetExpanded=null,this._snippetTip.style.display="none",this._expandBodyAt(e.body,t);const o=this._tab.doc.slice(a,this._tab.cur.row+1);return E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:a,oldLines:[r],newLines:o},i,n),!0}_expandBodyAt(e,t){var i,n;const{doc:a,cur:r}=this._tab,o=r.row,c=a[r.row]??"",d=c.slice(0,t),l=c.slice(r.col),h=je(c),p=" ".repeat(this._config.tabSize??4),u=e.replace(/^\t+/gm,b=>p.repeat(b.length)).split(`
|
|
842
|
+
`).map((b,x)=>x===0?b:h+b),m=u.join(`
|
|
843
|
+
`),g=[],w=/\$(\d+)/g;let k;for(;(k=w.exec(m))!==null;){const b=parseInt(k[1],10),x=m.slice(0,k.index).split(`
|
|
844
|
+
`),$=x.length-1,S=x[$].length,T=(x[$].match(/\$\d+/g)??[]).join("").length,L=o+$,M=($===0?t:h.length)+(S-T);g.push({n:b,row:L,col:M})}g.sort((b,x)=>b.n===0?1:x.n===0?-1:b.n-x.n);const C=u.map(b=>b.replace(/\$\d+/g,"")),y=C.length===1?[d+C[0]+l]:[d+C[0],...C.slice(1,-1),C[C.length-1]+l];a.splice(r.row,1,...y);const f=y.length-1;f!==0&&this._shiftRanges(o+1,f),g.length>0?(this._snippetSession={stops:g.map(b=>({row:b.row,col:b.col})),idx:0},r.row=g[0].row,r.col=g[0].col):(this._snippetSession=null,r.row+=y.length-1,r.col=(y[y.length-1]??"").length-l.length),this._tokenCache.clear(),this._tab.dirty=!0,this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc))}_ctrlD(){if(!this._config.multiCursor)return;const e=!this._mc.searchWord,t=!!this._tab.sel;if(e&&t){const n=this._tab.sel,a=Math.min(n.ac,n.fc),r=Math.max(n.ac,n.fc);if(n.ar===n.fr){const o=(this._tab.doc[n.ar]??"").slice(a,r);o&&(this._mc.searchWord=o,this._mc.lastMatchRow=n.fr,this._mc.lastMatchCol=r)}}const i=ya(this._mc,this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,n=>this._isRangeReadOnly(n));if(i){if(e&&!t){if(this._isRangeReadOnly(i.row))return;this._tab.sel=i.sel,this._tab.cur.row=i.row,this._tab.cur.col=i.col}else(i.row!==this._tab.cur.row||i.col!==this._tab.cur.col)&&(Nt(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 xs extends ys{_scheduleHover(e){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,n,a;if(!this._config.hover||this._hoverPinned)return;const r=this._editorEl.getBoundingClientRect(),o=this._logicalScroll(this._editorEl.scrollTop),c=t-r.top+o,d=this._config.showGutter?this._config.gutterWidth:0,l=e-r.left-d-ee;if(l<0){this._hoverTip.style.display!=="none"&&this._hideHover();return}const h=this._config.lineHeight,p=this._wm.windowVisStart,u=p+this._wm.visualRows.length-1,m=Math.max(p,Math.min(u,Math.floor(c/h))),g=Math.max(0,Math.min((((i=this._wm.visualRows[m-p])==null?void 0:i.text)??"").length,Math.round(l/X))),w=fe(this._wm,m,g),k=this._tab.doc[w.row]??"",C=wa(k,w.col);if(!C){this._hoverTip.style.display!=="none"&&this._hideHover();return}let y=va(C,this._config.language);if(!y){const f=this._config.completions.find(b=>b.label===C);f&&(f.description||f.detail)&&(y={title:f.label,type:f.detail,body:f.description??""})}if(!y){const f=(a=(n=this._config).provideHover)==null?void 0:a.call(n,{word:C,row:w.row,col:w.col,line:k,language:this._config.language,doc:this._tab.doc});f&&(y=f)}if(!y){this._hoverTip.style.display!=="none"&&this._hideHover();return}this._showHoverTip(y,e,t)}_showHoverTip(e,t,i){const n=this._hoverTip;let a='<div class="sl-ht-sig">';a+=`<span class="sl-ht-title">${me(e.title)}</span>`,e.type&&(a+=`<code class="sl-ht-type">${me(e.type)}</code>`),a+="</div>",e.title&&e.body&&(a+='<div class="sl-ht-divider"></div>'),e.body&&(a+=`<div class="sl-ht-body">${me(e.body)}</div>`),n.innerHTML=a,n.style.display="block";const r=12,o=18,c=n.offsetWidth||300,d=n.offsetHeight||80;let l=t,h=i+o;h+d>window.innerHeight-r&&(h=i-d-8),l+c>window.innerWidth-r&&(l=window.innerWidth-c-r),l<r&&(l=r),n.style.left=`${l}px`,n.style.top=`${Math.max(r,h)}px`}_hideHover(){this._hoverTimer!==null&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverLeaveTimer!==null&&(clearTimeout(this._hoverLeaveTimer),this._hoverLeaveTimer=null),this._hoverPinned=!1,this._hoverTip.style.display="none"}_openThemePicker(){var e;const t=this._themeManager.all;this._themePanel.innerHTML=`
|
|
844
845
|
<div class="sl-theme-header">
|
|
845
846
|
<div class="sl-theme-title">Color Theme</div>
|
|
846
847
|
<div class="sl-theme-close">✕</div>
|
|
@@ -862,8 +863,8 @@ gap: $2;`,language:["css"]},{label:"media",kind:"snip",detail:"@media query",des
|
|
|
862
863
|
</div>
|
|
863
864
|
`).join("")}
|
|
864
865
|
</div>
|
|
865
|
-
`,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 n=i.dataset.id??"";this._applyTheme(n),this._themePanel.querySelectorAll(".sl-theme-item").forEach(a=>a.classList.remove("sl-active")),i.classList.add("sl-active")})})}_applyTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=it(t=>Oe(t,this._host)),this._tokenCache.clear(),this._render()}}class gs extends us{_posFromMouse(e){var t;const i=this._editorEl.getBoundingClientRect(),n=this._logicalScroll(this._editorEl.scrollTop),a=e.clientY-i.top+n,r=this._config.showGutter?this._config.gutterWidth:0,o=e.clientX-i.left-r-ee,c=this._config.lineHeight,d=this._wm.windowVisStart,l=d+this._wm.visualRows.length-1,h=Math.max(d,Math.min(l,Math.floor(a/c))),p=Math.max(0,Math.min((((t=this._wm.visualRows[h-d])==null?void 0:t.text)??"").length,Math.round(o/X)));return me(this._wm,h,p)}_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}_bindMouseEvents(){this._vpEl.addEventListener("mousedown",e=>this._onFoldBtnClick(e)),this._vpEl.addEventListener("mousedown",e=>this._onROInsertBtnClick(e)),this._vpEl.addEventListener("mouseover",e=>this._onROBlockMouseover(e)),this._vpEl.addEventListener("mouseleave",e=>this._onROBlockMouseleave(e)),this._editorEl.addEventListener("mousedown",e=>{var t,i,n,a;if(e.button!==0)return;if(e.preventDefault(),this._focusInput(),this._acHide(),this._snippetSession=null,this._emmetTip.style.display="none",e.altKey||(at(this._mc),this._extraCursors=[]),this._config.showGutter){const o=this._editorEl.getBoundingClientRect();if(e.clientX-o.left<this._config.gutterWidth){const c=this._posFromMouse(e);if(this._isRangeReadOnly(c.row))return;const d=(this._tab.doc[c.row]??"").length;this._tab.cur={row:c.row,col:d},this._tab.sel={ar:c.row,ac:0,fr:c.row,fc:d},this._isDragging=!0,this._dragAnchor={row:c.row,col:0},this._lineDragMode=!0,this._lineDragAnchorRow=c.row,R(this._tab),this._render(),(i=(t=this._config).onSelectionChange)==null||i.call(t,this._tab.sel?{...this._tab.sel}:null);return}}const r=this._posFromMouse(e);if(!(!e.shiftKey&&this._isRangeReadOnly(r.row))){if(e.altKey&&e.detail===1&&!e.shiftKey&&this._config.multiCursor){Bt(this._mc,r.row,r.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={...r},this._tab.sel={ar:o.row,ac:o.col,fr:r.row,fc:r.col},o.row===r.row&&o.col===r.col&&(this._tab.sel=null),this._isDragging=!1,R(this._tab),this._render(),(a=(n=this._config).onSelectionChange)==null||a.call(n,this._tab.sel?{...this._tab.sel}:null);return}if(this._tab.cur={...r},e.detail===3)this._tab.sel={ar:r.row,ac:0,fr:r.row,fc:(this._tab.doc[r.row]??"").length},this._tab.cur.col=this._tab.sel.fc,this._isDragging=!0,this._dragAnchor={row:r.row,col:0},this._lineDragMode=!0,this._lineDragAnchorRow=r.row;else if(e.detail===2&&this._config.wordSelection){const o=this._tab.doc[r.row]??"",c=this._wordStart(o,r.col),d=this._wordEnd(o,r.col);c!==d?(this._tab.sel={ar:r.row,ac:c,fr:r.row,fc:d},this._tab.cur.col=d):this._tab.sel=null,this._isDragging=!0,this._dragAnchor={row:r.row,col:c},this._wordDragMode=!0,this._wordDragAnchorRow=r.row,this._wordDragAnchorStart=c,this._wordDragAnchorEnd=d}else this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...r};R(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);if(this._lineDragMode){if(t.row>=this._lineDragAnchorRow){const i=(this._tab.doc[t.row]??"").length;this._tab.cur={row:t.row,col:i},this._tab.sel={ar:this._lineDragAnchorRow,ac:0,fr:t.row,fc:i}}else{const i=(this._tab.doc[this._lineDragAnchorRow]??"").length;this._tab.cur={row:t.row,col:0},this._tab.sel={ar:this._lineDragAnchorRow,ac:i,fr:t.row,fc:0}}R(this._tab),this._render();return}if(this._wordDragMode){const i=this._tab.doc[t.row]??"";if(t.row>this._wordDragAnchorRow||t.row===this._wordDragAnchorRow&&t.col>=this._wordDragAnchorStart){const n=this._wordEnd(i,t.col);this._tab.cur={row:t.row,col:n},this._tab.sel={ar:this._wordDragAnchorRow,ac:this._wordDragAnchorStart,fr:t.row,fc:n}}else{const n=this._wordStart(i,t.col);this._tab.cur={row:t.row,col:n},this._tab.sel={ar:this._wordDragAnchorRow,ac:this._wordDragAnchorEnd,fr:t.row,fc:n}}R(this._tab),this._render();return}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,R(this._tab),this._render()}),this._editorEl.addEventListener("mouseleave",()=>{this._hoverTip.style.display!=="none"&&this._hoverLeaveTimer===null&&(this._hoverLeaveTimer=setTimeout(()=>{this._hoverLeaveTimer=null,this._hoverPinned||this._hideHover()},300))}),window.addEventListener("mouseup",this._onWinMouseUp),this._editorEl.addEventListener("scroll",this._onEditorScroll,{passive:!0}),window.addEventListener("resize",this._onWinResize)}}class ms extends gs{_posFromTouch(e){var t;const i=this._editorEl.getBoundingClientRect(),n=this._logicalScroll(this._editorEl.scrollTop),a=e.clientY-i.top+n,r=this._config.showGutter?this._config.gutterWidth:0,o=e.clientX-i.left-r-ee,c=this._config.lineHeight,d=this._wm.windowVisStart,l=d+this._wm.visualRows.length-1,h=Math.max(d,Math.min(l,Math.floor(a/c))),p=Math.max(0,Math.min((((t=this._wm.visualRows[h-d])==null?void 0:t.text)??"").length,Math.round(o/X)));return me(this._wm,h,p)}_buildTouchMenu(){const e=document.createElement("div");e.className="sl-touch-menu",e.setAttribute("role","menu"),e.setAttribute("aria-label","Editor context menu"),e.addEventListener("touchstart",n=>n.stopPropagation(),{passive:!1});const t=(n,a)=>{const r=document.createElement("button");return r.className="sl-tm-btn",r.setAttribute("role","menuitem"),r.textContent=n,r.addEventListener("touchend",o=>{o.preventDefault(),this._hideTouchMenu(),a()}),r},i=()=>{const n=document.createElement("div");return n.className="sl-tm-sep",n};e.appendChild(t("Cut",()=>{this._config.readOnly||this._doCut()})),e.appendChild(i()),e.appendChild(t("Copy",()=>this._doCopy())),e.appendChild(i()),e.appendChild(t("Paste",()=>{navigator.clipboard.readText().then(n=>{var a,r;n&&(this._insertStr(n,!1),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(r=(a=this._config).onChange)==null||r.call(a,D(this._tab.doc)))}).catch(()=>{})})),e.appendChild(i()),e.appendChild(t("Select All",()=>this._selectAll())),this._touchMenu=e,document.body.appendChild(e)}_showTouchMenu(e,t){this._touchMenu||this._buildTouchMenu();const i=this._touchMenu,n=!!this._tab.sel,a=i.querySelectorAll(".sl-tm-btn")[0],r=i.querySelectorAll(".sl-tm-btn")[1];a&&(a.disabled=!n||this._config.readOnly,a.style.opacity=a.disabled?"0.4":""),r&&(r.disabled=!n,r.style.opacity=r.disabled?"0.4":"");const o=260,c=54;i.style.left=`${Math.min(e,window.innerWidth-o-8)}px`,i.style.top=`${t>c+8?t-c-8:t+12}px`,i.style.display="flex";const d=l=>{i.contains(l.target)||(this._hideTouchMenu(),document.removeEventListener("touchstart",d))};setTimeout(()=>document.addEventListener("touchstart",d,{passive:!0}),0)}_hideTouchMenu(){this._touchMenu&&(this._touchMenu.style.display="none")}_onTouchStart(e){const t=this._touchState;if(e.touches.length===2){e.preventDefault();const n=e.touches[0],a=e.touches[1];t.pinchStartDist=Math.hypot(a.clientX-n.clientX,a.clientY-n.clientY),t.pinchStartFontSize=this._config.fontSize,t.id=-1,t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null);return}if(e.touches.length>2)return;const i=e.touches[0];e.preventDefault(),t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null),t.id=i.identifier,t.startX=t.lastX=i.clientX,t.startY=t.lastY=i.clientY,t.startScrollTop=this._editorEl.scrollTop,t.startTime=Date.now(),t.isDragging=!1,t.isLongPress=!1,t.longPressTimer=setTimeout(()=>{t.longPressTimer=null,t.isLongPress=!0;const n=this._posFromTouch(i),a=this._tab.doc[n.row]??"",r=this._wordStart(a,n.col),o=this._wordEnd(a,n.col);this._tab.cur={row:n.row,col:o},this._tab.sel=r!==o?{ar:n.row,ac:r,fr:n.row,fc:o}:null,R(this._tab),this._focusInput(),this._render(),navigator.vibrate&&navigator.vibrate(30),this._showTouchMenu(i.clientX,i.clientY)},450)}_onTouchMove(e){const t=this._touchState;if(e.touches.length===2){e.preventDefault();const o=e.touches[0],c=e.touches[1],d=Math.hypot(c.clientX-o.clientX,c.clientY-o.clientY);if(t.pinchStartDist>0){const l=d/t.pinchStartDist,h=Math.max(8,Math.min(32,Math.round(t.pinchStartFontSize*l)));h!==this._config.fontSize&&(this._config.fontSize=h,this._applyDynamicStyles(),this._rebuildWrapMap(),this._scrollIntoView(),this._render())}return}if(e.touches.length!==1)return;const i=[...e.touches].find(o=>o.identifier===t.id);if(!i)return;e.preventDefault();const n=i.clientX-t.startX,a=i.clientY-t.startY,r=Math.hypot(n,a);if(t.lastX=i.clientX,t.lastY=i.clientY,r>8&&t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null),t.isDragging){if(t.isLongPress){const o=this._posFromTouch(i),c=this._tab.sel?{row:this._tab.sel.ar,col:this._tab.sel.ac}:this._tab.cur;this._tab.cur={...o},this._tab.sel={ar:c.row,ac:c.col,fr:o.row,fc:o.col},R(this._tab),this._render()}return}r>8&&!t.isLongPress?(t.isDragging=!0,this._editorEl.scrollTop=Math.max(0,t.startScrollTop-a)):t.isDragging&&(this._editorEl.scrollTop=Math.max(0,t.startScrollTop-a))}_onTouchEnd(e){const t=this._touchState;t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null);const i=[...e.changedTouches].find(c=>c.identifier===t.id);if(!i){t.id=-1;return}const n=Date.now()-t.startTime,a=i.clientX-t.startX,r=i.clientY-t.startY,o=Math.hypot(a,r);if(t.isDragging||t.isLongPress){t.id=-1;return}if(e.preventDefault(),n<300&&o<8){const c=Date.now(),d=Math.hypot(i.clientX-t.lastTapX,i.clientY-t.lastTapY);if(c-t.lastTapTime<350&&d<40&&this._config.wordSelection){const l=this._posFromTouch(i),h=this._tab.doc[l.row]??"",p=this._wordStart(h,l.col),u=this._wordEnd(h,l.col);this._tab.cur={row:l.row,col:u},this._tab.sel=p!==u?{ar:l.row,ac:p,fr:l.row,fc:u}:null,R(this._tab),this._focusInput(),this._render(),t.lastTapTime=0}else{const l=this._posFromTouch(i);this._isRangeReadOnly(l.row)||(this._tab.cur={...l},this._tab.sel=null,at(this._mc),this._extraCursors=[],R(this._tab)),this._hideTouchMenu(),this._focusInput(),this._acHide(),this._render(),t.lastTapTime=c,t.lastTapX=i.clientX,t.lastTapY=i.clientY}}t.id=-1}_onTouchCancel(){const e=this._touchState;e.longPressTimer!==null&&(clearTimeout(e.longPressTimer),e.longPressTimer=null),e.id=-1,e.isDragging=!1,e.isLongPress=!1,e.pinchStartDist=0}_bindTouchEvents(){this._editorEl.addEventListener("touchstart",e=>this._onTouchStart(e),{passive:!1}),this._editorEl.addEventListener("touchmove",e=>this._onTouchMove(e),{passive:!1}),this._editorEl.addEventListener("touchend",e=>this._onTouchEnd(e),{passive:!1}),this._editorEl.addEventListener("touchcancel",()=>this._onTouchCancel()),this._inputEl.addEventListener("compositionstart",()=>{this._isComposing=!0}),this._inputEl.addEventListener("compositionend",()=>{this._isComposing=!1})}}class bs extends ms{_onKeyDown(e){var t,i,n,a,r,o,c,d,l;const h=e.ctrlKey||e.metaKey,p=e.shiftKey,u=e.altKey,m=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(),m||(this._acHide(),this._doUndo());return}if(h&&(e.key==="y"||p&&e.key==="z")){e.preventDefault(),m||(this._acHide(),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(),m||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(),!m&&this._config.multiCursor&&this._ctrlD();return}if(h&&p&&e.key==="d"){e.preventDefault(),m||this._duplicateLine();return}if(h&&e.key==="/"){e.preventDefault(),m||this._toggleComment();return}if(h&&e.key==="k"){e.preventDefault(),m||this._deleteLine();return}if(h&&e.key==="Enter"){e.preventDefault(),m||(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,at(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(m){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 g=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=g.row,this._tab.cur.col=g.col,this._tab.sel=null,R(this._tab),this._scrollIntoView(),this._render()}}else if(this._snippetSession.idx++,this._snippetSession.idx>=this._snippetSession.stops.length)this._snippetSession=null;else{const g=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=g.row,this._tab.cur.col=g.col,this._tab.sel=null,R(this._tab),this._scrollIntoView(),this._render()}return}if(!p&&this._emmetAccept()||!p&&this._snippetAccept())return;p?this._unindentSel():this._indentSel(),R(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){this._snippetSession=null;const g=e.metaKey,w=e.altKey||e.ctrlKey,k=this._tab.doc.slice(),C={...this._tab.cur},y=this._tab.sel?{...this._tab.sel}:null,b=this._extraCursors.map($=>({...$,sel:$.sel?{...$.sel}:null})),f=st(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,($,S,T,L)=>{let M=null;if(L){const B=O(L);M={fromRow:B.ar,fromCol:B.ac,toRow:B.fr,toCol:B.fc}}else g?M=T===0?null:{fromRow:S,fromCol:0,toRow:S,toCol:T}:w?T===0?M=S===0?null:{fromRow:S-1,fromCol:($[S-1]??"").length,toRow:S,toCol:0}:M={fromRow:S,fromCol:this._wordSkipLeft($[S]??"",T),toRow:S,toCol:T}:T===0?M=S===0?null:{fromRow:S-1,fromCol:($[S-1]??"").length,toRow:S,toCol:0}:M={fromRow:S,fromCol:T-1,toRow:S,toCol:T};return!M||this._isRangeReadOnly(M.fromRow,M.toRow)?null:M});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 x=ce(k,this._tab.doc);if(x.oldLines.length||x.newLines.length){E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:x.row,oldLines:x.oldLines,newLines:x.newLines},C,y,b,f.extraCursors);const $=x.newLines.length-x.oldLines.length;$!==0&&this._shiftRanges(x.row+x.oldLines.length,$)}}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 g=this._snippetSession.stops[this._snippetSession.idx];if(this._tab.cur.row===g.row&&this._tab.cur.col>g.col){for(let w=this._snippetSession.idx+1;w<this._snippetSession.stops.length;w++){const k=this._snippetSession.stops[w];k.row===g.row&&k.col>=this._tab.cur.col&&k.col--}g.col--}else this._snippetSession=null}this._doBackspace()}this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc));return}if(e.key==="Delete"){if(e.preventDefault(),this._snippetSession=null,this._extraCursors.length){const g=e.metaKey,w=e.altKey||e.ctrlKey,k=this._tab.doc.slice(),C={...this._tab.cur},y=this._tab.sel?{...this._tab.sel}:null,b=this._extraCursors.map($=>({...$,sel:$.sel?{...$.sel}:null})),f=st(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,($,S,T,L)=>{let M=null;if(L){const B=O(L);M={fromRow:B.ar,fromCol:B.ac,toRow:B.fr,toCol:B.fc}}else{const B=$[S]??"";g?M=T>=B.length?null:{fromRow:S,fromCol:T,toRow:S,toCol:B.length}:w?T>=B.length?M=S>=$.length-1?null:{fromRow:S,fromCol:T,toRow:S+1,toCol:0}:M={fromRow:S,fromCol:T,toRow:S,toCol:this._wordSkipRight(B,T)}:T<B.length?M={fromRow:S,fromCol:T,toRow:S,toCol:T+1}:M=S<$.length-1?{fromRow:S,fromCol:T,toRow:S+1,toCol:0}:null}return!M||this._isRangeReadOnly(M.fromRow,M.toRow)?null:M});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 x=ce(k,this._tab.doc);if(x.oldLines.length||x.newLines.length){E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:x.row,oldLines:x.oldLines,newLines:x.newLines},C,y,b,f.extraCursors);const $=x.newLines.length-x.oldLines.length;$!==0&&this._shiftRanges(x.row+x.oldLines.length,$)}}else e.metaKey?this._deleteToLineEnd():e.altKey||e.ctrlKey?this._deleteWordRight():this._doDelete();this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(a=(n=this._config).onChange)==null||a.call(n,D(this._tab.doc));return}if(e.key==="Enter"){e.preventDefault(),this._snippetSession=null,this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(o=(r=this._config).onChange)==null||o.call(r,D(this._tab.doc));return}if(!h&&!u&&this._config.autoClosePairs[e.key]){e.preventDefault();const g={...this._tab.cur},w=this._tab.sel?{...this._tab.sel}:null;let k,C;if(this._tab.sel){const x=O(this._tab.sel);if(this._isRangeReadOnly(x.ar,x.fr))return;k=x.ar,C=this._tab.doc.slice(x.ar,x.fr+1),this._tab.cur=q(this._tab)}else{if(this._isRangeReadOnly(this._tab.cur.row))return;k=this._tab.cur.row,C=[this._tab.doc[k]??""]}const{doc:y,cur:b}=this._tab,f=y[b.row]??"";y[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,((c=this._wm.segments[b.row])==null?void 0:c.length)??1),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:k,oldLines:C,newLines:[y[b.row]]},g,w),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(l=(d=this._config).onChange)==null||l.call(d,D(this._tab.doc));return}if(!h&&!u&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:g,cur:w}=this._tab;if((g[w.row]??"")[w.col]===e.key){e.preventDefault(),w.col++,R(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 n,a,r,o,c,d;const{doc:l,cur:h}=this._tab,p=this._config.lineHeight,u=e.metaKey,m=e.ctrlKey,g=e.altKey,w=(y,b)=>{if(i){this._tab.sel||(this._tab.sel={ar:h.row,ac:h.col,fr:h.row,fc:h.col}),h.row=y,h.col=b;const f=this._tab.sel;f.fr=y,f.fc=b,f.ar===f.fr&&f.ac===f.fc&&(this._tab.sel=null)}else this._tab.sel=null,h.row=y,h.col=b},k=y=>{const b=(l[y]??"").search(/\S/);return b===-1||h.col===b?0:b},C=()=>({row:l.length-1,col:(l[l.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const y=O(this._tab.sel);h.row=y.fr,h.col=y.fc,this._tab.sel=null;break}if(u)w(h.row,(l[h.row]??"").length);else if(m||g){const y=l[h.row]??"";if(h.col>=y.length)h.row<l.length-1&&w(h.row+1,0);else{const b=this._wordSkipRight(y,h.col);w(h.row,b)}}else h.col<(l[h.row]??"").length?w(h.row,h.col+1):h.row<l.length-1&&w(h.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const y=O(this._tab.sel);h.row=y.ar,h.col=y.ac,this._tab.sel=null;break}if(u)w(h.row,k(h.row));else if(m||g)if(h.col===0)h.row>0&&w(h.row-1,(l[h.row-1]??"").length);else{const y=this._wordSkipLeft(l[h.row]??"",h.col);w(h.row,y)}else h.col>0?w(h.row,h.col-1):h.row>0&&w(h.row-1,(l[h.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),u){const y=C();w(y.row,y.col)}else if(this._config.wordWrap){const y=ae(this._wm,h.row,h.col),b=this._wm.windowVisStart,f=Math.min(this._wm.totalVisualRows-1,y.visRow+1),x=me(this._wm,f,Math.min(y.colInSeg,(((n=this._wm.visualRows[f-b])==null?void 0:n.text)??"").length));w(x.row,x.col)}else{let y=Math.min(l.length-1,h.row+1);for(const[b,f]of this._foldedLines)if(y>b&&y<=f){y=Math.min(l.length-1,f+1);break}if(!i&&this._isRangeReadOnly(y)){for(;y<l.length-1&&this._isRangeReadOnly(y);)y++;this._isRangeReadOnly(y)&&(y=h.row)}w(y,Math.min(h.col,(l[y]??"").length))}break;case"ArrowUp":if(e.preventDefault(),u)w(0,0);else if(this._config.wordWrap){const y=ae(this._wm,h.row,h.col),b=this._wm.windowVisStart,f=Math.max(0,y.visRow-1),x=me(this._wm,f,Math.min(y.colInSeg,(((a=this._wm.visualRows[f-b])==null?void 0:a.text)??"").length));w(x.row,x.col)}else{let y=Math.max(0,h.row-1);for(const[b,f]of this._foldedLines)if(y>b&&y<=f){y=b;break}if(!i&&this._isRangeReadOnly(y)){for(;y>0&&this._isRangeReadOnly(y);)y--;this._isRangeReadOnly(y)&&(y=h.row)}w(y,Math.min(h.col,(l[y]??"").length))}break;case"Home":e.preventDefault(),m?w(0,0):w(h.row,k(h.row));break;case"End":if(e.preventDefault(),m){const y=C();w(y.row,y.col)}else w(h.row,(l[h.row]??"").length);break;case"PageDown":e.preventDefault();{const y=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),b=Math.min(l.length-1,h.row+y);w(b,Math.min(h.col,(l[b]??"").length)),this._editorEl.scrollTop+=this._editorEl.clientHeight-p;break}case"PageUp":e.preventDefault();{const y=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),b=Math.max(0,h.row-y);w(b,Math.min(h.col,(l[b]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-p;break}default:return}if(this._extraCursors.length){const y=(b,f)=>{const x=(l[b]??"").search(/\S/);return x===-1||f===x?0:x};this._extraCursors=this._extraCursors.map(b=>{let f=b.row,x=b.col;if(!i&&b.sel){const $=O(b.sel);if(e.key==="ArrowLeft")return{row:$.ar,col:$.ac,sel:null};if(e.key==="ArrowRight")return{row:$.fr,col:$.fc,sel:null}}switch(e.key){case"ArrowRight":u?x=(l[f]??"").length:m||g?x>=(l[f]??"").length?f<l.length-1&&(f++,x=0):x=this._wordSkipRight(l[f]??"",x):x<(l[f]??"").length?x++:f<l.length-1&&(f++,x=0);break;case"ArrowLeft":u?x=y(f,x):m||g?x===0?f>0&&(f--,x=(l[f]??"").length):x=this._wordSkipLeft(l[f]??"",x):x>0?x--:f>0&&(f--,x=(l[f]??"").length);break;case"ArrowDown":u?(f=l.length-1,x=(l[f]??"").length):(f=Math.min(l.length-1,f+1),x=Math.min(b.col,(l[f]??"").length));break;case"ArrowUp":u?(f=0,x=0):(f=Math.max(0,f-1),x=Math.min(b.col,(l[f]??"").length));break;case"Home":m?(f=0,x=0):x=y(f,x);break;case"End":m&&(f=l.length-1),x=(l[f]??"").length;break}return x=Math.max(0,Math.min(x,(l[f]??"").length)),{row:f,col:x,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}R(this._tab),this._scrollIntoView(),this._acHide(),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur}),(d=(c=this._config).onSelectionChange)==null||d.call(c,this._tab.sel?{...this._tab.sel}:null),this._render()}}class fs extends bs{_onInput(e){var t,i,n,a,r,o;if(this._config.readOnly){e.target.value="";return}const c=e.target,d=c.value;if(c.value="",!d||d==="Ω")return;const l=d.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(l){if(this._extraCursors.length){this._snippetSession=null;const h=this._tab.doc.slice(),p={...this._tab.cur},u=this._tab.sel?{...this._tab.sel}:null,m=this._extraCursors.map(x=>({...x,sel:x.sel?{...x.sel}:null}));let g=this._tab.doc,w=this._tab.cur.row,k=this._tab.cur.col,C=this._extraCursors;if(this._tab.sel||this._extraCursors.some(x=>x.sel)){const x=st(g,w,k,this._tab.sel,C,($,S,T,L)=>{if(!L)return null;const M=O(L);return this._isRangeReadOnly(M.ar,M.fr)?null:{fromRow:M.ar,fromCol:M.ac,toRow:M.fr,toCol:M.fc}});g=x.doc,w=x.primaryRow,k=x.primaryCol,C=x.extraCursors,this._tab.sel=null,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1}if(this._isRangeReadOnly(w)){this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc));return}const y=C.filter(x=>!this._isRangeReadOnly(x.row)),b=ha(g,w,k,y,l);this._tab.doc=b.doc,this._tab.cur.row=b.primaryRow,this._tab.cur.col=b.primaryCol,this._extraCursors=b.extraCursors,this._mc.cursors=b.extraCursors,this._tab.dirty=!0;const f=ce(h,this._tab.doc);if(f.oldLines.length||f.newLines.length){E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:f.row,oldLines:f.oldLines,newLines:f.newLines},p,u,m,this._extraCursors);const x=f.newLines.length-f.oldLines.length;x!==0&&this._shiftRanges(f.row+f.oldLines.length,x)}(a=(n=this._config).onChange)==null||a.call(n,D(this._tab.doc))}else{const h=this._tab.cur.row,p=this._tab.cur.col;if(this._insertStr(l,!0),this._snippetSession){const u=this._snippetSession,m=u.stops[u.idx];if(this._tab.cur.row===m.row){const g=this._tab.cur.col-p;for(let w=u.idx+1;w<u.stops.length;w++){const k=u.stops[w];k.row===h&&k.col>=p&&(k.col+=g)}m.col=this._tab.cur.col}else this._snippetSession=null}}this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur})}}_onPaste(e){var t,i,n,a,r;if(e.preventDefault(),this._config.readOnly)return;const o=(t=e.clipboardData??window.clipboardData)==null?void 0:t.getData("text/plain");if(o){if(this._linewiseCopy&&!this._tab.sel){if(this._isRangeReadOnly(this._tab.cur.row))return;const c={...this._tab.cur},d=this._tab.cur.row,l=o.endsWith(`
|
|
866
|
-
`)?o.slice(0,-1):o;this._tab.doc.splice(d,0,l),this._tab.cur.row=d+1,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[l]},c,null),this._shiftRanges(d,1),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc)),(r=(a=this._config).onCursorChange)==null||r.call(a,{...this._tab.cur});return}this._insertStr(o,!1),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render()}}}class ys extends fs{_bindMinimapEvents(){const e=this._minimapWrap;e.addEventListener("mousemove",t=>{if(this._mmDragMode!=="none")return;const i=t.clientY-e.getBoundingClientRect().top,{sliderTop:n,sliderHeight:a}=tt(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=n&&i<=n+a?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,n=t.clientY-e.getBoundingClientRect().top,{sliderTop:a,sliderHeight:r}=tt(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);if(n>=a&&n<=a+r)this._mmDragMode="slider",this._mmSliderOffset=n-a,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const o=na(n,this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=this._domScroll(o),this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}class xs extends ys{_bindEditorEvents(){this._bindMouseEvents(),this._bindTouchEvents(),this._bindMinimapEvents(),this._inputEl.addEventListener("keydown",e=>this._onKeyDown(e)),this._inputEl.addEventListener("input",e=>this._onInput(e)),this._inputEl.addEventListener("paste",e=>this._onPaste(e)),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)})}}class ks extends xs{getValue(){return D(this._tab.doc)}setValue(e){var t,i;const n={...this._tab.cur},a=this._tab.sel?{...this._tab.sel}:null,r=[...this._tab.doc];this._tab.doc=Mt(e),this._tab.cur={row:0,col:0},this._tab.sel=null;const o=[...this._tab.doc];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:r,newLines:o},n,a),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},R(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(),R(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._applyTheme(e)}updateConfig(e){const t=Nt(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:n,...a}=t;Object.assign(this._config,a)}else Object.assign(this._config,t);if(t.readOnly!==void 0&&this._inputEl.setAttribute("aria-readonly",String(!!t.readOnly)),e.readOnlyRanges!==void 0&&(this._readOnlyRanges=(e.readOnlyRanges??[]).map(i=>({...i}))),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 We={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)",roBg:"rgba(129,140,248,.07)",tokKw:"#c792ea",tokStr:"#c3e88d",tokCmt:"#636e8a",tokFn:"#82aaff",tokNum:"#f78c6c",tokCls:"#ffcb6b",tokOp:"#89ddff",tokTyp:"#82aaff",tokDec:"#f07178"}},Fe={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)",roBg:"rgba(99,102,241,.05)",tokKw:"#7c3aed",tokStr:"#15803d",tokCmt:"#94a3b8",tokFn:"#2563eb",tokNum:"#c2410c",tokCls:"#b45309",tokOp:"#0891b2",tokTyp:"#2563eb",tokDec:"#dc2626"}};function N(s){const e=s.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 n=!1;const a=(r,o,c)=>{i.lastIndex=0;for(const d of r.matchAll(i))d[1]!==void 0?c.push({cls:"fn",start:o+d.index,end:o+d.index+d[1].length}):d[2]!==void 0?c.push({cls:"fn",start:o+d.index,end:o+d.index+d[2].length}):d[3]!==void 0&&c.push({cls:"str",start:o+d.index,end:o+d.index+d[3].length})};return r=>{const o=[];if(n){const c=r.indexOf(">"),d=c===-1?r.length:c;return a(r.slice(0,d),0,o),c!==-1&&(n=!1),o}t.lastIndex=0;for(const c of r.matchAll(t))if(c[1]){const d=c.index+2;o.push({cls:"cls",start:d,end:d+c[2].length})}else{const d=c.index+1;o.push({cls:"cls",start:d,end:d+c[2].length});const l=d+c[2].length,h=r.indexOf(">",l),p=h===-1?r.length:h;if(a(r.slice(l,p),l,o),h===-1){n=!0;break}}return o}}function ws(s,e){const t=[],i=s.match(/^(#{1,6}) /);if(i)return t.push({cls:"kw",start:0,end:i[1].length}),t;const n=s.match(/^(`{3,}|~{3,})([\w-]*)/);if(n)return t.push({cls:"kw",start:0,end:n[1].length}),n[2]&&t.push({cls:"typ",start:n[1].length,end:n[1].length+n[2].length}),t;if(/^(\s*)(---+|\*\*\*+|___+)\s*$/.test(s))return t.push({cls:"kw",start:0,end:s.length}),t;const a=s.match(/^(\s*>+\s?)/);a&&t.push({cls:"kw",start:0,end:a[1].length});const r=s.match(/^(\s*)([-*+]) (\[[ x]\] )?/);if(r){const l=r[1].length;if(t.push({cls:"op",start:l,end:l+1}),r[3]){const h=l+2;t.push({cls:"kw",start:h,end:h+r[3].trimEnd().length})}}const o=s.match(/^(\s*)(\d+\.) /);if(o){const l=o[1].length;t.push({cls:"op",start:l,end:l+o[2].length})}const c=s.match(/^(import|export)(\s)/);if(c&&t.push({cls:"kw",start:0,end:c[1].length}),/^\s*\|/.test(s)){for(const l of s.matchAll(/\|/g))t.push({cls:"op",start:l.index,end:l.index+1});return t}const d=new Set;for(const l of s.matchAll(/`([^`]+)`/g)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"str",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(new RegExp("(\\*\\*|__)(?!\\s)(.+?)(?<!\\s)\\1","g")))if(!d.has(l.index)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"num",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(new RegExp("(?<!\\*)\\*(?!\\*)(?!\\s)(.+?)(?<!\\s)\\*(?!\\*)|(?<!_)_(?!_)(?!\\s)(.+?)(?<!\\s)_(?!_)","g")))if(!d.has(l.index)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"fn",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(/~~(.+?)~~/g))if(!d.has(l.index)){for(let h=l.index;h<l.index+l[0].length;h++)d.add(h);t.push({cls:"cmt",start:l.index,end:l.index+l[0].length})}for(const l of s.matchAll(/!\[([^\]]*)\]\(([^)]*)\)/g)){if(d.has(l.index))continue;const h=l.index+2+l[1].length+1;t.push({cls:"fn",start:l.index,end:h}),t.push({cls:"str",start:h,end:l.index+l[0].length});for(let p=l.index;p<l.index+l[0].length;p++)d.add(p)}for(const l of s.matchAll(/\[([^\]]+)\]\(([^)]*)\)/g)){if(d.has(l.index))continue;const h=l.index+1+l[1].length+1;t.push({cls:"fn",start:l.index,end:h}),t.push({cls:"str",start:h,end:l.index+l[0].length});for(let p=l.index;p<l.index+l[0].length;p++)d.add(p)}return t}function Wt(s,e){return(t,i)=>{const n=[];for(const a of s){const r=a(t,i);r.length&&n.push(...r)}for(const a of e){const r=a(t,i);r.length&&n.push(...r)}return n}}function Ft(s){const e=s.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 ze={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},_s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ue=[{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"}],zt=[{label:"h1",kind:"snip",detail:"Heading 1",body:"# $1Heading"},{label:"h2",kind:"snip",detail:"Heading 2",body:"## $1Heading"},{label:"h3",kind:"snip",detail:"Heading 3",body:"### $1Heading"},{label:"h4",kind:"snip",detail:"Heading 4",body:"#### $1Heading"},{label:"h5",kind:"snip",detail:"Heading 5",body:"##### $1Heading"},{label:"h6",kind:"snip",detail:"Heading 6",body:"###### $1Heading"},{label:"bold",kind:"snip",detail:"bold text",body:"**$1bold text**"},{label:"italic",kind:"snip",detail:"italic text",body:"*$1italic text*"},{label:"strike",kind:"snip",detail:"strikethrough",body:"~~$1strikethrough~~"},{label:"code",kind:"snip",detail:"inline code",body:"`$1code`"},{label:"link",kind:"snip",detail:"markdown link",body:"[link text](url)"},{label:"img",kind:"snip",detail:"image",body:""},{label:"cb",kind:"snip",detail:"fenced code block",description:"Inserts a fenced code block. Replace `language` with e.g. `ts`, `py`, `bash`.",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
|
|
866
|
+
`,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 n=i.dataset.id??"";this._applyTheme(n),this._themePanel.querySelectorAll(".sl-theme-item").forEach(a=>a.classList.remove("sl-active")),i.classList.add("sl-active")})})}_applyTheme(e){this._themeManager.apply(e),this._applyTokenOverrides(),this._mmColors=st(t=>He(t,this._host)),this._tokenCache.clear(),this._render()}}class ks extends xs{_posFromMouse(e){var t;const i=this._editorEl.getBoundingClientRect(),n=this._logicalScroll(this._editorEl.scrollTop),a=e.clientY-i.top+n,r=this._config.showGutter?this._config.gutterWidth:0,o=e.clientX-i.left-r-ee,c=this._config.lineHeight,d=this._wm.windowVisStart,l=d+this._wm.visualRows.length-1,h=Math.max(d,Math.min(l,Math.floor(a/c))),p=Math.max(0,Math.min((((t=this._wm.visualRows[h-d])==null?void 0:t.text)??"").length,Math.round(o/X)));return fe(this._wm,h,p)}_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}_bindMouseEvents(){this._vpEl.addEventListener("mousedown",e=>this._onFoldBtnClick(e)),this._vpEl.addEventListener("mousedown",e=>this._onROInsertBtnClick(e)),this._vpEl.addEventListener("mouseover",e=>this._onROBlockMouseover(e)),this._vpEl.addEventListener("mouseleave",e=>this._onROBlockMouseleave(e)),this._editorEl.addEventListener("mousedown",e=>{var t,i,n,a;if(e.button!==0)return;if(e.preventDefault(),this._focusInput(),this._acHide(),this._snippetSession=null,this._emmetTip.style.display="none",e.altKey||(ot(this._mc),this._extraCursors=[]),this._config.showGutter){const o=this._editorEl.getBoundingClientRect();if(e.clientX-o.left<this._config.gutterWidth){const c=this._posFromMouse(e);if(this._isRangeReadOnly(c.row))return;const d=(this._tab.doc[c.row]??"").length;this._tab.cur={row:c.row,col:d},this._tab.sel={ar:c.row,ac:0,fr:c.row,fc:d},this._isDragging=!0,this._dragAnchor={row:c.row,col:0},this._lineDragMode=!0,this._lineDragAnchorRow=c.row,R(this._tab),this._render(),(i=(t=this._config).onSelectionChange)==null||i.call(t,this._tab.sel?{...this._tab.sel}:null);return}}const r=this._posFromMouse(e);if(!(!e.shiftKey&&this._isRangeReadOnly(r.row))){if(e.altKey&&e.detail===1&&!e.shiftKey&&this._config.multiCursor){Nt(this._mc,r.row,r.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={...r},this._tab.sel={ar:o.row,ac:o.col,fr:r.row,fc:r.col},o.row===r.row&&o.col===r.col&&(this._tab.sel=null),this._isDragging=!1,R(this._tab),this._render(),(a=(n=this._config).onSelectionChange)==null||a.call(n,this._tab.sel?{...this._tab.sel}:null);return}if(this._tab.cur={...r},e.detail===3)this._tab.sel={ar:r.row,ac:0,fr:r.row,fc:(this._tab.doc[r.row]??"").length},this._tab.cur.col=this._tab.sel.fc,this._isDragging=!0,this._dragAnchor={row:r.row,col:0},this._lineDragMode=!0,this._lineDragAnchorRow=r.row;else if(e.detail===2&&this._config.wordSelection){const o=this._tab.doc[r.row]??"",c=this._wordStart(o,r.col),d=this._wordEnd(o,r.col);c!==d?(this._tab.sel={ar:r.row,ac:c,fr:r.row,fc:d},this._tab.cur.col=d):this._tab.sel=null,this._isDragging=!0,this._dragAnchor={row:r.row,col:c},this._wordDragMode=!0,this._wordDragAnchorRow=r.row,this._wordDragAnchorStart=c,this._wordDragAnchorEnd=d}else this._tab.sel=null,this._isDragging=!0,this._dragAnchor={...r};R(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);if(this._lineDragMode){if(t.row>=this._lineDragAnchorRow){const i=(this._tab.doc[t.row]??"").length;this._tab.cur={row:t.row,col:i},this._tab.sel={ar:this._lineDragAnchorRow,ac:0,fr:t.row,fc:i}}else{const i=(this._tab.doc[this._lineDragAnchorRow]??"").length;this._tab.cur={row:t.row,col:0},this._tab.sel={ar:this._lineDragAnchorRow,ac:i,fr:t.row,fc:0}}R(this._tab),this._render();return}if(this._wordDragMode){const i=this._tab.doc[t.row]??"";if(t.row>this._wordDragAnchorRow||t.row===this._wordDragAnchorRow&&t.col>=this._wordDragAnchorStart){const n=this._wordEnd(i,t.col);this._tab.cur={row:t.row,col:n},this._tab.sel={ar:this._wordDragAnchorRow,ac:this._wordDragAnchorStart,fr:t.row,fc:n}}else{const n=this._wordStart(i,t.col);this._tab.cur={row:t.row,col:n},this._tab.sel={ar:this._wordDragAnchorRow,ac:this._wordDragAnchorEnd,fr:t.row,fc:n}}R(this._tab),this._render();return}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,R(this._tab),this._render()}),this._editorEl.addEventListener("mouseleave",()=>{this._hoverTip.style.display!=="none"&&this._hoverLeaveTimer===null&&(this._hoverLeaveTimer=setTimeout(()=>{this._hoverLeaveTimer=null,this._hoverPinned||this._hideHover()},300))}),window.addEventListener("mouseup",this._onWinMouseUp),this._editorEl.addEventListener("scroll",this._onEditorScroll,{passive:!0}),window.addEventListener("resize",this._onWinResize)}}class ws extends ks{_posFromTouch(e){var t;const i=this._editorEl.getBoundingClientRect(),n=this._logicalScroll(this._editorEl.scrollTop),a=e.clientY-i.top+n,r=this._config.showGutter?this._config.gutterWidth:0,o=e.clientX-i.left-r-ee,c=this._config.lineHeight,d=this._wm.windowVisStart,l=d+this._wm.visualRows.length-1,h=Math.max(d,Math.min(l,Math.floor(a/c))),p=Math.max(0,Math.min((((t=this._wm.visualRows[h-d])==null?void 0:t.text)??"").length,Math.round(o/X)));return fe(this._wm,h,p)}_buildTouchMenu(){const e=document.createElement("div");e.className="sl-touch-menu",e.setAttribute("role","menu"),e.setAttribute("aria-label","Editor context menu"),e.addEventListener("touchstart",n=>n.stopPropagation(),{passive:!1});const t=(n,a)=>{const r=document.createElement("button");return r.className="sl-tm-btn",r.setAttribute("role","menuitem"),r.textContent=n,r.addEventListener("touchend",o=>{o.preventDefault(),this._hideTouchMenu(),a()}),r},i=()=>{const n=document.createElement("div");return n.className="sl-tm-sep",n};e.appendChild(t("Cut",()=>{this._config.readOnly||this._doCut()})),e.appendChild(i()),e.appendChild(t("Copy",()=>this._doCopy())),e.appendChild(i()),e.appendChild(t("Paste",()=>{navigator.clipboard.readText().then(n=>{var a,r;n&&(this._insertStr(n,!1),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(r=(a=this._config).onChange)==null||r.call(a,D(this._tab.doc)))}).catch(()=>{})})),e.appendChild(i()),e.appendChild(t("Select All",()=>this._selectAll())),this._touchMenu=e,document.body.appendChild(e)}_showTouchMenu(e,t){this._touchMenu||this._buildTouchMenu();const i=this._touchMenu,n=!!this._tab.sel,a=i.querySelectorAll(".sl-tm-btn")[0],r=i.querySelectorAll(".sl-tm-btn")[1];a&&(a.disabled=!n||this._config.readOnly,a.style.opacity=a.disabled?"0.4":""),r&&(r.disabled=!n,r.style.opacity=r.disabled?"0.4":"");const o=260,c=54;i.style.left=`${Math.min(e,window.innerWidth-o-8)}px`,i.style.top=`${t>c+8?t-c-8:t+12}px`,i.style.display="flex";const d=l=>{i.contains(l.target)||(this._hideTouchMenu(),document.removeEventListener("touchstart",d))};setTimeout(()=>document.addEventListener("touchstart",d,{passive:!0}),0)}_hideTouchMenu(){this._touchMenu&&(this._touchMenu.style.display="none")}_onTouchStart(e){const t=this._touchState;if(e.touches.length===2){e.preventDefault();const n=e.touches[0],a=e.touches[1];t.pinchStartDist=Math.hypot(a.clientX-n.clientX,a.clientY-n.clientY),t.pinchStartFontSize=this._config.fontSize,t.id=-1,t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null);return}if(e.touches.length>2)return;const i=e.touches[0];e.preventDefault(),t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null),t.id=i.identifier,t.startX=t.lastX=i.clientX,t.startY=t.lastY=i.clientY,t.startScrollTop=this._editorEl.scrollTop,t.startTime=Date.now(),t.isDragging=!1,t.isLongPress=!1,t.longPressTimer=setTimeout(()=>{t.longPressTimer=null,t.isLongPress=!0;const n=this._posFromTouch(i),a=this._tab.doc[n.row]??"",r=this._wordStart(a,n.col),o=this._wordEnd(a,n.col);this._tab.cur={row:n.row,col:o},this._tab.sel=r!==o?{ar:n.row,ac:r,fr:n.row,fc:o}:null,R(this._tab),this._focusInput(),this._render(),navigator.vibrate&&navigator.vibrate(30),this._showTouchMenu(i.clientX,i.clientY)},450)}_onTouchMove(e){const t=this._touchState;if(e.touches.length===2){e.preventDefault();const o=e.touches[0],c=e.touches[1],d=Math.hypot(c.clientX-o.clientX,c.clientY-o.clientY);if(t.pinchStartDist>0){const l=d/t.pinchStartDist,h=Math.max(8,Math.min(32,Math.round(t.pinchStartFontSize*l)));h!==this._config.fontSize&&(this._config.fontSize=h,this._applyDynamicStyles(),this._rebuildWrapMap(),this._scrollIntoView(),this._render())}return}if(e.touches.length!==1)return;const i=[...e.touches].find(o=>o.identifier===t.id);if(!i)return;e.preventDefault();const n=i.clientX-t.startX,a=i.clientY-t.startY,r=Math.hypot(n,a);if(t.lastX=i.clientX,t.lastY=i.clientY,r>8&&t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null),t.isDragging){if(t.isLongPress){const o=this._posFromTouch(i),c=this._tab.sel?{row:this._tab.sel.ar,col:this._tab.sel.ac}:this._tab.cur;this._tab.cur={...o},this._tab.sel={ar:c.row,ac:c.col,fr:o.row,fc:o.col},R(this._tab),this._render()}return}r>8&&!t.isLongPress?(t.isDragging=!0,this._editorEl.scrollTop=Math.max(0,t.startScrollTop-a)):t.isDragging&&(this._editorEl.scrollTop=Math.max(0,t.startScrollTop-a))}_onTouchEnd(e){const t=this._touchState;t.longPressTimer!==null&&(clearTimeout(t.longPressTimer),t.longPressTimer=null);const i=[...e.changedTouches].find(c=>c.identifier===t.id);if(!i){t.id=-1;return}const n=Date.now()-t.startTime,a=i.clientX-t.startX,r=i.clientY-t.startY,o=Math.hypot(a,r);if(t.isDragging||t.isLongPress){t.id=-1;return}if(e.preventDefault(),n<300&&o<8){const c=Date.now(),d=Math.hypot(i.clientX-t.lastTapX,i.clientY-t.lastTapY);if(c-t.lastTapTime<350&&d<40&&this._config.wordSelection){const l=this._posFromTouch(i),h=this._tab.doc[l.row]??"",p=this._wordStart(h,l.col),u=this._wordEnd(h,l.col);this._tab.cur={row:l.row,col:u},this._tab.sel=p!==u?{ar:l.row,ac:p,fr:l.row,fc:u}:null,R(this._tab),this._focusInput(),this._render(),t.lastTapTime=0}else{const l=this._posFromTouch(i);this._isRangeReadOnly(l.row)||(this._tab.cur={...l},this._tab.sel=null,ot(this._mc),this._extraCursors=[],R(this._tab)),this._hideTouchMenu(),this._focusInput(),this._acHide(),this._render(),t.lastTapTime=c,t.lastTapX=i.clientX,t.lastTapY=i.clientY}}t.id=-1}_onTouchCancel(){const e=this._touchState;e.longPressTimer!==null&&(clearTimeout(e.longPressTimer),e.longPressTimer=null),e.id=-1,e.isDragging=!1,e.isLongPress=!1,e.pinchStartDist=0}_bindTouchEvents(){this._editorEl.addEventListener("touchstart",e=>this._onTouchStart(e),{passive:!1}),this._editorEl.addEventListener("touchmove",e=>this._onTouchMove(e),{passive:!1}),this._editorEl.addEventListener("touchend",e=>this._onTouchEnd(e),{passive:!1}),this._editorEl.addEventListener("touchcancel",()=>this._onTouchCancel()),this._inputEl.addEventListener("compositionstart",()=>{this._isComposing=!0}),this._inputEl.addEventListener("compositionend",()=>{this._isComposing=!1})}}class _s extends ws{_onKeyDown(e){var t,i,n,a,r,o,c,d,l;const h=e.ctrlKey||e.metaKey,p=e.shiftKey,u=e.altKey,m=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(),m||(this._acHide(),this._doUndo());return}if(h&&(e.key==="y"||p&&e.key==="z")){e.preventDefault(),m||(this._acHide(),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(),m||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(),!m&&this._config.multiCursor&&this._ctrlD();return}if(h&&p&&e.key==="d"){e.preventDefault(),m||this._duplicateLine();return}if(h&&e.key==="/"){e.preventDefault(),m||this._toggleComment();return}if(h&&e.key==="k"){e.preventDefault(),m||this._deleteLine();return}if(h&&e.key==="Enter"){e.preventDefault(),m||(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,ot(this._mc),this._extraCursors=[],this._mc.searchWord="",this._render();return}if(m){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 g=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=g.row,this._tab.cur.col=g.col,this._tab.sel=null,R(this._tab),this._scrollIntoView(),this._render()}}else if(this._snippetSession.idx++,this._snippetSession.idx>=this._snippetSession.stops.length)this._snippetSession=null;else{const g=this._snippetSession.stops[this._snippetSession.idx];this._tab.cur.row=g.row,this._tab.cur.col=g.col,this._tab.sel=null,R(this._tab),this._scrollIntoView(),this._render()}return}if(!p&&this._emmetAccept()||!p&&this._snippetAccept())return;p?this._unindentSel():this._indentSel(),R(this._tab),this._scrollIntoView(),this._rebuildWrapMap(),this._render();return}if(e.key==="Backspace"){if(e.preventDefault(),this._extraCursors.length){this._snippetSession=null;const g=e.metaKey,w=e.altKey||e.ctrlKey,k=this._tab.doc.slice(),C={...this._tab.cur},y=this._tab.sel?{...this._tab.sel}:null,f=this._extraCursors.map($=>({...$,sel:$.sel?{...$.sel}:null})),b=lt(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,($,S,T,L)=>{let M=null;if(L){const B=O(L);M={fromRow:B.ar,fromCol:B.ac,toRow:B.fr,toCol:B.fc}}else g?M=T===0?null:{fromRow:S,fromCol:0,toRow:S,toCol:T}:w?T===0?M=S===0?null:{fromRow:S-1,fromCol:($[S-1]??"").length,toRow:S,toCol:0}:M={fromRow:S,fromCol:this._wordSkipLeft($[S]??"",T),toRow:S,toCol:T}:T===0?M=S===0?null:{fromRow:S-1,fromCol:($[S-1]??"").length,toRow:S,toCol:0}:M={fromRow:S,fromCol:T-1,toRow:S,toCol:T};return!M||this._isRangeReadOnly(M.fromRow,M.toRow)?null:M});this._tab.doc=b.doc,this._tab.cur.row=b.primaryRow,this._tab.cur.col=b.primaryCol,this._tab.sel=null,this._extraCursors=b.extraCursors,this._mc.cursors=b.extraCursors,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1;const x=he(k,this._tab.doc);if(x.oldLines.length||x.newLines.length){E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:x.row,oldLines:x.oldLines,newLines:x.newLines},C,y,f,b.extraCursors);const $=x.newLines.length-x.oldLines.length;$!==0&&this._shiftRanges(x.row+x.oldLines.length,$)}}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 g=this._snippetSession.stops[this._snippetSession.idx];if(this._tab.cur.row===g.row&&this._tab.cur.col>g.col){for(let w=this._snippetSession.idx+1;w<this._snippetSession.stops.length;w++){const k=this._snippetSession.stops[w];k.row===g.row&&k.col>=this._tab.cur.col&&k.col--}g.col--}else this._snippetSession=null}this._doBackspace()}this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc));return}if(e.key==="Delete"){if(e.preventDefault(),this._snippetSession=null,this._extraCursors.length){const g=e.metaKey,w=e.altKey||e.ctrlKey,k=this._tab.doc.slice(),C={...this._tab.cur},y=this._tab.sel?{...this._tab.sel}:null,f=this._extraCursors.map($=>({...$,sel:$.sel?{...$.sel}:null})),b=lt(this._tab.doc,this._tab.cur.row,this._tab.cur.col,this._tab.sel,this._extraCursors,($,S,T,L)=>{let M=null;if(L){const B=O(L);M={fromRow:B.ar,fromCol:B.ac,toRow:B.fr,toCol:B.fc}}else{const B=$[S]??"";g?M=T>=B.length?null:{fromRow:S,fromCol:T,toRow:S,toCol:B.length}:w?T>=B.length?M=S>=$.length-1?null:{fromRow:S,fromCol:T,toRow:S+1,toCol:0}:M={fromRow:S,fromCol:T,toRow:S,toCol:this._wordSkipRight(B,T)}:T<B.length?M={fromRow:S,fromCol:T,toRow:S,toCol:T+1}:M=S<$.length-1?{fromRow:S,fromCol:T,toRow:S+1,toCol:0}:null}return!M||this._isRangeReadOnly(M.fromRow,M.toRow)?null:M});this._tab.doc=b.doc,this._tab.cur.row=b.primaryRow,this._tab.cur.col=b.primaryCol,this._tab.sel=null,this._extraCursors=b.extraCursors,this._mc.cursors=b.extraCursors,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1;const x=he(k,this._tab.doc);if(x.oldLines.length||x.newLines.length){E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:x.row,oldLines:x.oldLines,newLines:x.newLines},C,y,f,b.extraCursors);const $=x.newLines.length-x.oldLines.length;$!==0&&this._shiftRanges(x.row+x.oldLines.length,$)}}else e.metaKey?this._deleteToLineEnd():e.altKey||e.ctrlKey?this._deleteWordRight():this._doDelete();this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(a=(n=this._config).onChange)==null||a.call(n,D(this._tab.doc));return}if(e.key==="Enter"){e.preventDefault(),this._snippetSession=null,this._doEnter(),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(o=(r=this._config).onChange)==null||o.call(r,D(this._tab.doc));return}if(!h&&!u&&this._config.autoClosePairs[e.key]){e.preventDefault();const g={...this._tab.cur},w=this._tab.sel?{...this._tab.sel}:null;let k,C;if(this._tab.sel){const x=O(this._tab.sel);if(this._isRangeReadOnly(x.ar,x.fr))return;k=x.ar,C=this._tab.doc.slice(x.ar,x.fr+1),this._tab.cur=U(this._tab)}else{if(this._isRangeReadOnly(this._tab.cur.row))return;k=this._tab.cur.row,C=[this._tab.doc[k]??""]}const{doc:y,cur:f}=this._tab,b=y[f.row]??"";y[f.row]=b.slice(0,f.col)+e.key+this._config.autoClosePairs[e.key]+b.slice(f.col),f.col++,this._tokenCache.invalidateLine(f.row,((c=this._wm.segments[f.row])==null?void 0:c.length)??1),this._tab.dirty=!0,E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:k,oldLines:C,newLines:[y[f.row]]},g,w),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(l=(d=this._config).onChange)==null||l.call(d,D(this._tab.doc));return}if(!h&&!u&&Object.values(this._config.autoClosePairs).includes(e.key)){const{doc:g,cur:w}=this._tab;if((g[w.row]??"")[w.col]===e.key){e.preventDefault(),w.col++,R(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 n,a,r,o,c,d;const{doc:l,cur:h}=this._tab,p=this._config.lineHeight,u=e.metaKey,m=e.ctrlKey,g=e.altKey,w=(y,f)=>{if(i){this._tab.sel||(this._tab.sel={ar:h.row,ac:h.col,fr:h.row,fc:h.col}),h.row=y,h.col=f;const b=this._tab.sel;b.fr=y,b.fc=f,b.ar===b.fr&&b.ac===b.fc&&(this._tab.sel=null)}else this._tab.sel=null,h.row=y,h.col=f},k=y=>{const f=(l[y]??"").search(/\S/);return f===-1||h.col===f?0:f},C=()=>({row:l.length-1,col:(l[l.length-1]??"").length});switch(e.key){case"ArrowRight":if(e.preventDefault(),this._tab.sel&&!i){const y=O(this._tab.sel);h.row=y.fr,h.col=y.fc,this._tab.sel=null;break}if(u)w(h.row,(l[h.row]??"").length);else if(m||g){const y=l[h.row]??"";if(h.col>=y.length)h.row<l.length-1&&w(h.row+1,0);else{const f=this._wordSkipRight(y,h.col);w(h.row,f)}}else h.col<(l[h.row]??"").length?w(h.row,h.col+1):h.row<l.length-1&&w(h.row+1,0);break;case"ArrowLeft":if(e.preventDefault(),this._tab.sel&&!i){const y=O(this._tab.sel);h.row=y.ar,h.col=y.ac,this._tab.sel=null;break}if(u)w(h.row,k(h.row));else if(m||g)if(h.col===0)h.row>0&&w(h.row-1,(l[h.row-1]??"").length);else{const y=this._wordSkipLeft(l[h.row]??"",h.col);w(h.row,y)}else h.col>0?w(h.row,h.col-1):h.row>0&&w(h.row-1,(l[h.row-1]??"").length);break;case"ArrowDown":if(e.preventDefault(),u){const y=C();w(y.row,y.col)}else if(this._config.wordWrap){const y=se(this._wm,h.row,h.col),f=this._wm.windowVisStart,b=Math.min(this._wm.totalVisualRows-1,y.visRow+1),x=fe(this._wm,b,Math.min(y.colInSeg,(((n=this._wm.visualRows[b-f])==null?void 0:n.text)??"").length));w(x.row,x.col)}else{let y=Math.min(l.length-1,h.row+1);for(const[f,b]of this._foldedLines)if(y>f&&y<=b){y=Math.min(l.length-1,b+1);break}if(!i&&this._isRangeReadOnly(y)){for(;y<l.length-1&&this._isRangeReadOnly(y);)y++;this._isRangeReadOnly(y)&&(y=h.row)}w(y,Math.min(h.col,(l[y]??"").length))}break;case"ArrowUp":if(e.preventDefault(),u)w(0,0);else if(this._config.wordWrap){const y=se(this._wm,h.row,h.col),f=this._wm.windowVisStart,b=Math.max(0,y.visRow-1),x=fe(this._wm,b,Math.min(y.colInSeg,(((a=this._wm.visualRows[b-f])==null?void 0:a.text)??"").length));w(x.row,x.col)}else{let y=Math.max(0,h.row-1);for(const[f,b]of this._foldedLines)if(y>f&&y<=b){y=f;break}if(!i&&this._isRangeReadOnly(y)){for(;y>0&&this._isRangeReadOnly(y);)y--;this._isRangeReadOnly(y)&&(y=h.row)}w(y,Math.min(h.col,(l[y]??"").length))}break;case"Home":e.preventDefault(),m?w(0,0):w(h.row,k(h.row));break;case"End":if(e.preventDefault(),m){const y=C();w(y.row,y.col)}else w(h.row,(l[h.row]??"").length);break;case"PageDown":e.preventDefault();{const y=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),f=Math.min(l.length-1,h.row+y);w(f,Math.min(h.col,(l[f]??"").length)),this._editorEl.scrollTop+=this._editorEl.clientHeight-p;break}case"PageUp":e.preventDefault();{const y=Math.max(1,Math.floor(this._editorEl.clientHeight/p)-1),f=Math.max(0,h.row-y);w(f,Math.min(h.col,(l[f]??"").length)),this._editorEl.scrollTop-=this._editorEl.clientHeight-p;break}default:return}if(this._extraCursors.length){const y=(f,b)=>{const x=(l[f]??"").search(/\S/);return x===-1||b===x?0:x};this._extraCursors=this._extraCursors.map(f=>{let b=f.row,x=f.col;if(!i&&f.sel){const $=O(f.sel);if(e.key==="ArrowLeft")return{row:$.ar,col:$.ac,sel:null};if(e.key==="ArrowRight")return{row:$.fr,col:$.fc,sel:null}}switch(e.key){case"ArrowRight":u?x=(l[b]??"").length:m||g?x>=(l[b]??"").length?b<l.length-1&&(b++,x=0):x=this._wordSkipRight(l[b]??"",x):x<(l[b]??"").length?x++:b<l.length-1&&(b++,x=0);break;case"ArrowLeft":u?x=y(b,x):m||g?x===0?b>0&&(b--,x=(l[b]??"").length):x=this._wordSkipLeft(l[b]??"",x):x>0?x--:b>0&&(b--,x=(l[b]??"").length);break;case"ArrowDown":u?(b=l.length-1,x=(l[b]??"").length):(b=Math.min(l.length-1,b+1),x=Math.min(f.col,(l[b]??"").length));break;case"ArrowUp":u?(b=0,x=0):(b=Math.max(0,b-1),x=Math.min(f.col,(l[b]??"").length));break;case"Home":m?(b=0,x=0):x=y(b,x);break;case"End":m&&(b=l.length-1),x=(l[b]??"").length;break}return x=Math.max(0,Math.min(x,(l[b]??"").length)),{row:b,col:x,sel:i?f.sel:null}}),this._extraCursors=this._extraCursors.filter(f=>!(f.row===this._tab.cur.row&&f.col===this._tab.cur.col)),this._mc.cursors=this._extraCursors}R(this._tab),this._scrollIntoView(),this._acHide(),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur}),(d=(c=this._config).onSelectionChange)==null||d.call(c,this._tab.sel?{...this._tab.sel}:null),this._render()}}class vs extends _s{_onInput(e){var t,i,n,a,r,o;if(this._config.readOnly){e.target.value="";return}const c=e.target,d=c.value;if(c.value="",!d||d==="Ω")return;const l=d.replace(/[\x00-\x08\x0a-\x1f\x7f]/g,"");if(l){if(this._extraCursors.length){this._snippetSession=null;const h=this._tab.doc.slice(),p={...this._tab.cur},u=this._tab.sel?{...this._tab.sel}:null,m=this._extraCursors.map(x=>({...x,sel:x.sel?{...x.sel}:null}));let g=this._tab.doc,w=this._tab.cur.row,k=this._tab.cur.col,C=this._extraCursors;if(this._tab.sel||this._extraCursors.some(x=>x.sel)){const x=lt(g,w,k,this._tab.sel,C,($,S,T,L)=>{if(!L)return null;const M=O(L);return this._isRangeReadOnly(M.ar,M.fr)?null:{fromRow:M.ar,fromCol:M.ac,toRow:M.fr,toCol:M.fc}});g=x.doc,w=x.primaryRow,k=x.primaryCol,C=x.extraCursors,this._tab.sel=null,this._mc.searchWord="",this._mc.lastMatchRow=-1,this._mc.lastMatchCol=-1}if(this._isRangeReadOnly(w)){this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(i=(t=this._config).onChange)==null||i.call(t,D(this._tab.doc));return}const y=C.filter(x=>!this._isRangeReadOnly(x.row)),f=ba(g,w,k,y,l);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,this._tab.dirty=!0;const b=he(h,this._tab.doc);if(b.oldLines.length||b.newLines.length){E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:b.row,oldLines:b.oldLines,newLines:b.newLines},p,u,m,this._extraCursors);const x=b.newLines.length-b.oldLines.length;x!==0&&this._shiftRanges(b.row+b.oldLines.length,x)}(a=(n=this._config).onChange)==null||a.call(n,D(this._tab.doc))}else{const h=this._tab.cur.row,p=this._tab.cur.col;if(this._insertStr(l,!0),this._snippetSession){const u=this._snippetSession,m=u.stops[u.idx];if(this._tab.cur.row===m.row){const g=this._tab.cur.col-p;for(let w=u.idx+1;w<u.stops.length;w++){const k=u.stops[w];k.row===h&&k.col>=p&&(k.col+=g)}m.col=this._tab.cur.col}else this._snippetSession=null}}this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),this._acTrigger(),this._emmetCheck(),this._snippetCheck(),(o=(r=this._config).onCursorChange)==null||o.call(r,{...this._tab.cur})}}_onPaste(e){var t,i,n,a,r;if(e.preventDefault(),this._config.readOnly)return;const o=(t=e.clipboardData??window.clipboardData)==null?void 0:t.getData("text/plain");if(o){if(this._linewiseCopy&&!this._tab.sel){if(this._isRangeReadOnly(this._tab.cur.row))return;const c={...this._tab.cur},d=this._tab.cur.row,l=o.endsWith(`
|
|
867
|
+
`)?o.slice(0,-1):o;this._tab.doc.splice(d,0,l),this._tab.cur.row=d+1,E(this._tab,this._config.maxUndoHistory,{kind:"insert",row:d,lines:[l]},c,null),this._shiftRanges(d,1),this._tab.dirty=!0,this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render(),(n=(i=this._config).onChange)==null||n.call(i,D(this._tab.doc)),(r=(a=this._config).onCursorChange)==null||r.call(a,{...this._tab.cur});return}this._insertStr(o,!1),this._tokenCache.clear(),this._rebuildWrapMap(),R(this._tab),this._scrollIntoView(),this._render()}}}class Cs extends vs{_bindMinimapEvents(){const e=this._minimapWrap;e.addEventListener("mousemove",t=>{if(this._mmDragMode!=="none")return;const i=t.clientY-e.getBoundingClientRect().top,{sliderTop:n,sliderHeight:a}=at(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,e.clientHeight,this._config.lineHeight);e.style.cursor=i>=n&&i<=n+a?"grab":"pointer"}),e.addEventListener("mousedown",t=>{t.preventDefault();const i=e.clientHeight,n=t.clientY-e.getBoundingClientRect().top,{sliderTop:a,sliderHeight:r}=at(this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);if(n>=a&&n<=a+r)this._mmDragMode="slider",this._mmSliderOffset=n-a,this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,e.style.cursor="grabbing";else{this._mmDragMode="jump";const o=da(n,this._tab.doc.length,this._logicalScroll(this._editorEl.scrollTop),this._editorEl.clientHeight,i,this._config.lineHeight);this._editorEl.scrollTop=this._domScroll(o),this._mmDragStartY=t.clientY,this._mmDragStartScroll=this._editorEl.scrollTop,this._render()}}),window.addEventListener("mousemove",this._onWinMmMouseMove),window.addEventListener("mouseup",this._onWinMmMouseUp)}}class Ts extends Cs{_bindEditorEvents(){this._bindMouseEvents(),this._bindTouchEvents(),this._bindMinimapEvents(),this._inputEl.addEventListener("keydown",e=>this._onKeyDown(e)),this._inputEl.addEventListener("input",e=>this._onInput(e)),this._inputEl.addEventListener("paste",e=>this._onPaste(e)),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)})}}class Es extends Ts{getValue(){return D(this._tab.doc)}setValue(e){var t,i;const n={...this._tab.cur},a=this._tab.sel?{...this._tab.sel}:null,r=[...this._tab.doc];this._tab.doc=Pt(e),this._tab.cur={row:0,col:0},this._tab.sel=null;const o=[...this._tab.doc];E(this._tab,this._config.maxUndoHistory,{kind:"replace",row:0,oldLines:r,newLines:o},n,a),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},R(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(),R(this._tab),this._scrollIntoView(),this._render())}setTheme(e){this._applyTheme(e)}updateConfig(e){const t=Gt(e);if(t.autoClosePairs!==void 0){const i=t.autoClosePairs;this._config.autoClosePairs=Object.keys(i).length===0?{}:{...this._config.autoClosePairs,...i};const{autoClosePairs:n,...a}=t;Object.assign(this._config,a)}else Object.assign(this._config,t);if(t.readOnly!==void 0&&this._inputEl.setAttribute("aria-readonly",String(!!t.readOnly)),e.readOnlyRanges!==void 0&&(this._readOnlyRanges=(e.readOnlyRanges??[]).map(i=>({...i}))),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 Fe={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)",roBg:"rgba(129,140,248,.07)",tokKw:"#c792ea",tokStr:"#c3e88d",tokCmt:"#636e8a",tokFn:"#82aaff",tokNum:"#f78c6c",tokCls:"#ffcb6b",tokOp:"#89ddff",tokTyp:"#82aaff",tokDec:"#f07178"}},ze={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)",roBg:"rgba(99,102,241,.05)",tokKw:"#7c3aed",tokStr:"#15803d",tokCmt:"#94a3b8",tokFn:"#2563eb",tokNum:"#c2410c",tokCls:"#b45309",tokOp:"#0891b2",tokTyp:"#2563eb",tokDec:"#dc2626"}};function Vt(s){const e=s.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 qe={"(":")","[":"]","{":"}",'"':'"',"'":"'","`":"`"},Ss=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ue=[{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"}],Kt=[{label:"h1",kind:"snip",detail:"Heading 1",body:"# $1Heading"},{label:"h2",kind:"snip",detail:"Heading 2",body:"## $1Heading"},{label:"h3",kind:"snip",detail:"Heading 3",body:"### $1Heading"},{label:"h4",kind:"snip",detail:"Heading 4",body:"#### $1Heading"},{label:"h5",kind:"snip",detail:"Heading 5",body:"##### $1Heading"},{label:"h6",kind:"snip",detail:"Heading 6",body:"###### $1Heading"},{label:"bold",kind:"snip",detail:"bold text",body:"**$1bold text**"},{label:"italic",kind:"snip",detail:"italic text",body:"*$1italic text*"},{label:"strike",kind:"snip",detail:"strikethrough",body:"~~$1strikethrough~~"},{label:"code",kind:"snip",detail:"inline code",body:"`$1code`"},{label:"link",kind:"snip",detail:"markdown link",body:"[link text](url)"},{label:"img",kind:"snip",detail:"image",body:""},{label:"cb",kind:"snip",detail:"fenced code block",description:"Inserts a fenced code block. Replace `language` with e.g. `ts`, `py`, `bash`.",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
|
|
867
868
|
- $2Item 2
|
|
868
869
|
- $3Item 3`},{label:"ol",kind:"snip",detail:"ordered list",body:`1. $1Item 1
|
|
869
870
|
2. $2Item 2
|
|
@@ -1100,7 +1101,7 @@ $$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<C
|
|
|
1100
1101
|
"status": "deleted"
|
|
1101
1102
|
}
|
|
1102
1103
|
\`\`\`
|
|
1103
|
-
</Endpoint>`}];class
|
|
1104
|
+
</Endpoint>`}];class Yt{constructor(e){this.tocCollapsed=!1,this.themeObserver=null,this.events=new xt,this.renderer=new we,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 Je(this,this.events);const t=this.config.toolbar||[this.getDefaultToolbar()];this.toolbar=new Qe(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",n=>{var o;if(!(n.metaKey||n.ctrlKey))return;const r=((o=this.pluginManager)==null?void 0:o.getShortcuts())??[];for(const c of r)if(this.matchShortcut(n,c.key)){n.preventDefault(),n.stopPropagation(),c.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",n=>{typeof n=="string"&&this.config.onChange(n)})}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 n=e.dataset.theme;if(n==="dark")return!0;if(n==="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?Fe:ze),this.codeEditor.updateConfig({tokenColors:Vt(e?Fe:ze)})}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 Es(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,goToLine:!1,placeholder:this.config.placeholder,value:e,language:"markdown",theme:this.isDarkMode()?Fe:ze,showStatusBar:!1,extraKeywords:["import","export","default","from","as","true","false","null","undefined"],completions:[...Ue,...Kt],replaceBuiltins:!0,provideCompletions:i=>{const n=i.line.slice(0,i.col),a=n.match(/<([A-Za-z]*)$/);if(a){const o=a[1].toLowerCase();return Ue.filter(c=>c.kind==="cls"&&(o===""||c.label.toLowerCase().startsWith(o)))}const r=n.match(/<[A-Za-z][\w.]*(?:\s+[\w-]*="[^"]*"\s*)*\s+([A-Za-z]*)$/);if(r){const o=r[1].toLowerCase();return Ue.filter(c=>c.kind==="var"&&(o===""||c.label.toLowerCase().startsWith(o)))}return null},tokenColors:Vt(this.isDarkMode()?Fe:ze),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(qe[i.key]){const n=this.getSelection();if(n.text){i.preventDefault(),i.stopImmediatePropagation();const a=i.key,r=qe[a],o=this.codeEditor.getValue(),c=o.substring(0,n.start)+a+n.text+r+o.substring(n.end);this.codeEditor.setValue(c),this.setSelection(n.start+1,n.end+1);return}}if(i.key==="Backspace"){const n=this.getSelection();if(n.start===n.end&&n.start>0){const a=this.codeEditor.getValue(),r=a[n.start-1],o=a[n.start];if(qe[r]&&qe[r]===o){i.preventDefault(),i.stopImmediatePropagation();const c=a.substring(0,n.start-1)+a.substring(n.start+1);this.codeEditor.setValue(c),this.setSelection(n.start-1,n.start-1);return}}}if(i.key===">"){const n=this.getSelection(),a=this.codeEditor.getValue(),o=a.substring(0,n.start).match(/<([A-Za-z][A-Za-z0-9.-]*)(?:\s[^>]*)?\s*$/);if(o){const c=o[1];if(!Ss.has(c.toLowerCase())){i.preventDefault(),i.stopImmediatePropagation();const d=`></${c}>`,l=a.substring(0,n.start)+d+a.substring(n.end);this.codeEditor.setValue(l),this.setSelection(n.start+1,n.start+1);return}}}}},!0),this.textarea.value=e,this.setupThemeObserver(),this.updateStatusBar()}_refreshCompletions(){!this.codeEditor||!this.pluginManager||this.codeEditor.updateConfig({completions:[...Ue,...Kt,...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:kt(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",n=>{const a=n.target,r=a.closest("[data-smdx-tab-btn]");if(r){const l=r.closest(".smdx-tabs");if(l){const h=parseInt(r.dataset.tabIndex??"0",10);l.querySelectorAll(".smdx-tab-btn").forEach(p=>p.classList.remove("smdx-active")),r.classList.add("smdx-active"),l.querySelectorAll(".smdx-tab-panel").forEach((p,u)=>{p.style.display=u===h?"block":"none"})}return}const o=a.closest("[data-copy-btn]");if(!o)return;const c=o.closest(".smdx-code-block"),d=c==null?void 0:c.querySelector("code");d&&navigator.clipboard.writeText(d.textContent||"").then(()=>{o.classList.add("smdx-copied"),setTimeout(()=>o.classList.remove("smdx-copied"),2e3)}).catch(()=>{})}),this.previewPane.appendChild(this.previewContent),i.appendChild(this.editorPane),i.appendChild(this.previewPane),this.splitterController=new _e(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,n=0;for(let a=0;a<e&&a<t.length;a++)t[a]===`
|
|
1104
1105
|
`?(i++,n=0):n++;return{row:i,col:n}}posToOffset(e,t){const i=this.codeEditor.getValue().split(`
|
|
1105
1106
|
`);let n=0;for(let a=0;a<e&&a<i.length;a++)n+=i[a].length+1;return n+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("+"),n=i.includes("cmd")||i.includes("meta")||i.includes("ctrl"),a=i.includes("shift"),r=i.includes("alt"),o=i.find(d=>!["cmd","meta","ctrl","shift","alt"].includes(d));return o?(e.metaKey||e.ctrlKey)===n&&e.shiftKey===a&&e.altKey===r&&e.key.toLowerCase()===o:!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 c;const e=((c=this.codeEditor)==null?void 0:c.getValue())??"",t=this.getWordCount(),i=this.getLineCount(),n=e.length,{lineNum:a,colNum:r}=this.getCursorPosition(),o=this.config.readOnly?'<span class="smdx-status-sep">|</span><span class="smdx-status-item smdx-status-readonly">Read Only</span>':"";this.statusBar.innerHTML=`
|
|
1106
1107
|
<span class="smdx-status-item">Ln ${a}, Col ${r}</span>
|
|
@@ -1134,10 +1135,12 @@ $$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<C
|
|
|
1134
1135
|
`)[e.row]??""}getCurrentLineNumber(){return this.codeEditor.getCursor().row+1}replaceCurrentLine(e){const t=this.codeEditor.getCursor(),i=this.codeEditor.getValue().split(`
|
|
1135
1136
|
`);i[t.row]=e,this.codeEditor.setValue(i.join(`
|
|
1136
1137
|
`)),this.codeEditor.setCursor({row:t.row,col:e.length})}insertAt(e,t){const i=this.codeEditor.getValue(),n=i.substring(0,e)+t+i.substring(e);this.codeEditor.setValue(n);const a=this.offsetToPos(e+t.length);this.codeEditor.setCursor(a)}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(`
|
|
1137
|
-
`).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 A={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 qt(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:A.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(s=>({id:`h${s}`,label:`Heading ${s}`,icon:A[`h${s}`],tooltip:`Heading ${s}`,...s<=3?{shortcutLabel:`⌘${s}`}:{},action:({editor:e})=>{const t="#".repeat(s)+" ",n=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+n)}})),action:({editor:s})=>{const e=s.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),n=e.replace(/^#{1,6}\s*/,"");s.replaceCurrentLine("#".repeat(i)+" "+n)}else s.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:s})=>s.replaceCurrentLine("# "+s.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:s})=>s.replaceCurrentLine("## "+s.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:s})=>s.replaceCurrentLine("### "+s.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}],provideTokens:s=>{const e=s.match(/^(#{1,6}) /);return e?[{cls:"kw",start:0,end:e[1].length}]:[]}}}function Gt(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:A.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:s})=>s.wrapSelection("**","**"),isActive:({selection:s})=>{const{beforeText:e,afterText:t,text:i}=s;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(i)}}],shortcuts:[{key:"Ctrl+b",action:({editor:s})=>s.wrapSelection("**","**"),description:"Bold"}],provideTokens:s=>{const e=[];for(const t of s.matchAll(new RegExp("(\\*\\*|__)(?!\\s)(.+?)(?<!\\s)\\1","g")))e.push({cls:"num",start:t.index,end:t.index+t[0].length});return e}}}function Vt(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:A.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:s})=>s.wrapSelection("*","*"),isActive:({selection:s})=>{const{beforeText:e,afterText:t,text:i}=s;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(i)}}],shortcuts:[{key:"Ctrl+i",action:({editor:s})=>s.wrapSelection("*","*"),description:"Italic"}],provideTokens:s=>{const e=[];for(const t of s.matchAll(new RegExp("(?<!\\*)\\*(?!\\*)(?!\\s)(.+?)(?<!\\s)\\*(?!\\*)|(?<!_)_(?!_)(?!\\s)(.+?)(?<!\\s)_(?!_)","g")))e.push({cls:"fn",start:t.index,end:t.index+t[0].length});return e}}}function Kt(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:A.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:s})=>s.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:s})=>s.wrapSelection("~~","~~"),description:"Strikethrough"}],provideTokens:s=>{const e=[];for(const t of s.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:A.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:s})=>{const e=s.getCurrentLine();e.startsWith("> ")?s.replaceCurrentLine(e.substring(2)):s.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:s})=>{const e=s.getCurrentLine();s.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}],provideTokens:s=>{const e=s.match(/^(\s*>+\s?)/);return e?[{cls:"kw",start:0,end:e[1].length}]:[]}}}function Xt(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:A.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:s,selection:e})=>{e.text?s.replaceSelection(`[${e.text}](url)`):s.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:s,selection:e})=>{e.text?s.replaceSelection(`[${e.text}](url)`):s.insertText("[link text](url)")},description:"Insert Link"}],provideTokens:s=>{const e=[];for(const t of s.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 Jt(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:A.image,tooltip:"Insert Image",shortcutLabel:"⌘⇧I",action:({editor:s,selection:e})=>{const t=e.text||"alt text";s.replaceSelection(``)}}],shortcuts:[{key:"Ctrl+Shift+i",action:({editor:s,selection:e})=>{const t=e.text||"alt text";s.replaceSelection(``)},description:"Insert Image"}],provideTokens:s=>{const e=[];for(const t of s.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 Zt(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:A.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:s})=>s.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:A.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:s,selection:e})=>{s.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:s})=>s.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:s,selection:e})=>{s.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}],provideTokens:s=>{const e=[],t=s.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 s.matchAll(/`([^`]+)`/g))e.push({cls:"str",start:i.index,end:i.index+i[0].length});return e}}}function Qt(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:A.unorderedList,tooltip:"Bullet List",action:({editor:s})=>{const e=s.getCurrentLine();e.match(/^[-*]\s/)?s.replaceCurrentLine(e.replace(/^[-*]\s/,"")):s.replaceCurrentLine("- "+e)}}],provideTokens:s=>{const e=s.match(/^(\s*)([-*+]) /);return e?[{cls:"op",start:e[1].length,end:e[1].length+1}]:[]}}}function ei(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:A.orderedList,tooltip:"Numbered List",action:({editor:s})=>{const e=s.getCurrentLine();e.match(/^\d+\.\s/)?s.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):s.replaceCurrentLine("1. "+e)}}],provideTokens:s=>{const e=s.match(/^(\s*)(\d+\.) /);return e?[{cls:"op",start:e[1].length,end:e[1].length+e[2].length}]:[]}}}function ti(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:A.taskList,tooltip:"Task List",action:({editor:s})=>{const e=s.getCurrentLine();e.match(/^- \[[ x]\]\s/)?s.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):s.replaceCurrentLine("- [ ] "+e)}}],provideTokens:s=>{const e=[],t=s.match(/^(\s*)([-*+]) (\[[ x]\] )/);if(t){const i=t[1].length;e.push({cls:"op",start:i,end:i+1});const n=i+2;e.push({cls:"kw",start:n,end:n+t[3].trimEnd().length})}return e}}}function ii(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:A.table,tooltip:"Insert Table",action:({editor:s})=>{s.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
1138
|
+
`).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 $s{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 A={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 ut(s,e,t){const i={};for(const[a,r]of Object.entries(e))r.default!==void 0&&(i[a]=r.default);let n=` ${s} `;n=n.replace(/([a-zA-Z][\w-]*)=["']([^"']*)["']/g,(a,r,o)=>{const c=e[r];return i[r]=(c==null?void 0:c.type)==="number"?parseFloat(o)||0:o," "}),n=n.replace(/([a-zA-Z][\w-]*)=\{([^}]*)\}/g,(a,r,o)=>{const c=o.trim().replace(/^["']|["']$/g,"");return c==="true"?i[r]=!0:c==="false"?i[r]=!1:c!==""&&!isNaN(Number(c))?i[r]=Number(c):i[r]=c," "}),n.replace(/\b([a-zA-Z][\w-]+)\b/g,(a,r)=>{const o=e[r];return((o==null?void 0:o.type)==="boolean"||i[r]===void 0&&!o)&&(i[r]=!0)," "});for(const[a,r]of Object.entries(e))r.required&&i[a]===void 0&&console.warn(`[SynclineMDX] Required attribute "${a}" is missing on <${t??"component"}> and has no default value. The component may not render correctly.`);return i}function gt(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rs(s,e){const t=gt(s);return e?new RegExp(`<${t}((?:\\s[^>]*?)?)\\s*/?>`,"gi"):new RegExp(`<${t}((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/${t}>`,"gi")}function Ge(s,e,t){const i=gt(e),n=new RegExp(`<${i}((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/${i}>`,"gi"),a=[];for(const r of s.matchAll(n)){const o=ut(r[1]??"",t??{},e),c=(r[2]??"").trim();a.push({attrs:o,children:c})}return a}function Ms(s){var r;const{tag:e,attrs:t={},selfClosing:i=!0}=s,n=[];for(const[o,c]of Object.entries(t)){if(c.type==="boolean"){c.default===!0&&n.push(o);continue}let d;c.type==="enum"&&"options"in c&&((r=c.options)!=null&&r.length)?d=c.options[0]:c.default!==void 0?d=String(c.default):c.type==="number"?d="1":d=o,n.push(`${o}="${d}"`)}const a=n.length?" "+n.join(" "):"";return i?`<${e}${a} />`:`<${e}${a}>
|
|
1139
|
+
|
|
1140
|
+
</${e}>`}function N(s){const{tag:e,attrs:t={},selfClosing:i=!0,render:n,priority:a=10}=s,r=gt(e),o=Rs(e,i),c=t;return{name:e.charAt(0).toLowerCase()+e.slice(1),tag:e,label:s.label,description:s.description,completions:s.completions,pattern:o,priority:a,render:d=>{try{if(i){const l=d.match(new RegExp(`<${r}((?:\\s[^>]*?)?)\\s*/?>`,"i")),h=ut((l==null?void 0:l[1])??"",c,e);return n(h)}else{const l=d.match(new RegExp(`<${r}((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/${r}>`,"i")),h=ut((l==null?void 0:l[1])??"",c,e),p=((l==null?void 0:l[2])??"").trim();return n({...h,children:p})}}catch{return d}}}}function Xt(){return{name:"heading",toolbarItems:[{id:"heading",label:"Heading",icon:A.heading,tooltip:"Heading",children:[1,2,3,4,5,6].map(s=>({id:`h${s}`,label:`Heading ${s}`,icon:A[`h${s}`],tooltip:`Heading ${s}`,...s<=3?{shortcutLabel:`⌘${s}`}:{},action:({editor:e})=>{const t="#".repeat(s)+" ",n=e.getCurrentLine().replace(/^#{1,6}\s*/,"");e.replaceCurrentLine(t+n)}})),action:({editor:s})=>{const e=s.getCurrentLine(),t=e.match(/^(#{1,6})\s/);if(t){const i=Math.min(t[1].length+1,6),n=e.replace(/^#{1,6}\s*/,"");s.replaceCurrentLine("#".repeat(i)+" "+n)}else s.replaceCurrentLine("# "+e)}}],shortcuts:[{key:"Ctrl+1",action:({editor:s})=>s.replaceCurrentLine("# "+s.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 1"},{key:"Ctrl+2",action:({editor:s})=>s.replaceCurrentLine("## "+s.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 2"},{key:"Ctrl+3",action:({editor:s})=>s.replaceCurrentLine("### "+s.getCurrentLine().replace(/^#{1,6}\s*/,"")),description:"Heading 3"}],provideTokens:s=>{const e=s.match(/^(#{1,6}) /);return e?[{cls:"kw",start:0,end:e[1].length}]:[]}}}function Jt(){return{name:"bold",toolbarItems:[{id:"bold",label:"Bold",icon:A.bold,tooltip:"Bold",shortcutLabel:"⌘B",action:({editor:s})=>s.wrapSelection("**","**"),isActive:({selection:s})=>{const{beforeText:e,afterText:t,text:i}=s;return e.endsWith("**")&&t.startsWith("**")||/^\*\*.+\*\*$/.test(i)}}],shortcuts:[{key:"Ctrl+b",action:({editor:s})=>s.wrapSelection("**","**"),description:"Bold"}],provideTokens:s=>{const e=[];for(const t of s.matchAll(new RegExp("(\\*\\*|__)(?!\\s)(.+?)(?<!\\s)\\1","g")))e.push({cls:"num",start:t.index,end:t.index+t[0].length});return e}}}function Zt(){return{name:"italic",toolbarItems:[{id:"italic",label:"Italic",icon:A.italic,tooltip:"Italic",shortcutLabel:"⌘I",action:({editor:s})=>s.wrapSelection("*","*"),isActive:({selection:s})=>{const{beforeText:e,afterText:t,text:i}=s;return e.endsWith("*")&&!e.endsWith("**")&&t.startsWith("*")&&!t.startsWith("**")||/^\*[^*]+\*$/.test(i)}}],shortcuts:[{key:"Ctrl+i",action:({editor:s})=>s.wrapSelection("*","*"),description:"Italic"}],provideTokens:s=>{const e=[];for(const t of s.matchAll(new RegExp("(?<!\\*)\\*(?!\\*)(?!\\s)(.+?)(?<!\\s)\\*(?!\\*)|(?<!_)_(?!_)(?!\\s)(.+?)(?<!\\s)_(?!_)","g")))e.push({cls:"fn",start:t.index,end:t.index+t[0].length});return e}}}function Qt(){return{name:"strikethrough",toolbarItems:[{id:"strikethrough",label:"Strikethrough",icon:A.strikethrough,tooltip:"Strikethrough",shortcutLabel:"⌘⇧X",action:({editor:s})=>s.wrapSelection("~~","~~")}],shortcuts:[{key:"Ctrl+Shift+x",action:({editor:s})=>s.wrapSelection("~~","~~"),description:"Strikethrough"}],provideTokens:s=>{const e=[];for(const t of s.matchAll(/~~(.+?)~~/g))e.push({cls:"cmt",start:t.index,end:t.index+t[0].length});return e}}}function ei(){return{name:"quote",toolbarItems:[{id:"quote",label:"Quote",icon:A.quote,tooltip:"Blockquote",shortcutLabel:"⌘⇧.",action:({editor:s})=>{const e=s.getCurrentLine();e.startsWith("> ")?s.replaceCurrentLine(e.substring(2)):s.replaceCurrentLine("> "+e)}}],shortcuts:[{key:"Ctrl+Shift+.",action:({editor:s})=>{const e=s.getCurrentLine();s.replaceCurrentLine(e.startsWith("> ")?e.substring(2):"> "+e)},description:"Blockquote"}],provideTokens:s=>{const e=s.match(/^(\s*>+\s?)/);return e?[{cls:"kw",start:0,end:e[1].length}]:[]}}}function ti(){return{name:"link",toolbarItems:[{id:"link",label:"Link",icon:A.link,tooltip:"Insert Link",shortcutLabel:"⌘K",action:({editor:s,selection:e})=>{e.text?s.replaceSelection(`[${e.text}](url)`):s.insertText("[link text](url)")}}],shortcuts:[{key:"Ctrl+k",action:({editor:s,selection:e})=>{e.text?s.replaceSelection(`[${e.text}](url)`):s.insertText("[link text](url)")},description:"Insert Link"}],provideTokens:s=>{const e=[];for(const t of s.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 ii(){return{name:"image",toolbarItems:[{id:"image",label:"Image",icon:A.image,tooltip:"Insert Image",shortcutLabel:"⌘⇧I",action:({editor:s,selection:e})=>{const t=e.text||"alt text";s.replaceSelection(``)}}],shortcuts:[{key:"Ctrl+Shift+i",action:({editor:s,selection:e})=>{const t=e.text||"alt text";s.replaceSelection(``)},description:"Insert Image"}],provideTokens:s=>{const e=[];for(const t of s.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 ni(){return{name:"code",toolbarItems:[{id:"code",label:"Inline Code",icon:A.code,tooltip:"Inline Code",shortcutLabel:"⌘E",action:({editor:s})=>s.wrapSelection("`","`")},{id:"codeBlock",label:"Code Block",icon:A.codeBlock,tooltip:"Code Block",shortcutLabel:"⌘⇧C",action:({editor:s,selection:e})=>{s.insertBlock("```language\n"+(e.text||"code here")+"\n```")}}],shortcuts:[{key:"Ctrl+e",action:({editor:s})=>s.wrapSelection("`","`"),description:"Inline Code"},{key:"Ctrl+Shift+c",action:({editor:s,selection:e})=>{s.insertBlock("```language\n"+(e.text||"code here")+"\n```")},description:"Code Block"}],provideTokens:s=>{const e=[],t=s.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 s.matchAll(/`([^`]+)`/g))e.push({cls:"str",start:i.index,end:i.index+i[0].length});return e}}}function ai(){return{name:"unorderedList",toolbarItems:[{id:"unorderedList",label:"Unordered List",icon:A.unorderedList,tooltip:"Bullet List",action:({editor:s})=>{const e=s.getCurrentLine();e.match(/^[-*]\s/)?s.replaceCurrentLine(e.replace(/^[-*]\s/,"")):s.replaceCurrentLine("- "+e)}}],provideTokens:s=>{const e=s.match(/^(\s*)([-*+]) /);return e?[{cls:"op",start:e[1].length,end:e[1].length+1}]:[]}}}function si(){return{name:"orderedList",toolbarItems:[{id:"orderedList",label:"Ordered List",icon:A.orderedList,tooltip:"Numbered List",action:({editor:s})=>{const e=s.getCurrentLine();e.match(/^\d+\.\s/)?s.replaceCurrentLine(e.replace(/^\d+\.\s/,"")):s.replaceCurrentLine("1. "+e)}}],provideTokens:s=>{const e=s.match(/^(\s*)(\d+\.) /);return e?[{cls:"op",start:e[1].length,end:e[1].length+e[2].length}]:[]}}}function ri(){return{name:"taskList",toolbarItems:[{id:"taskList",label:"Task List",icon:A.taskList,tooltip:"Task List",action:({editor:s})=>{const e=s.getCurrentLine();e.match(/^- \[[ x]\]\s/)?s.replaceCurrentLine(e.replace(/^- \[[ x]\]\s/,"")):s.replaceCurrentLine("- [ ] "+e)}}],provideTokens:s=>{const e=[],t=s.match(/^(\s*)([-*+]) (\[[ x]\] )/);if(t){const i=t[1].length;e.push({cls:"op",start:i,end:i+1});const n=i+2;e.push({cls:"kw",start:n,end:n+t[3].trimEnd().length})}return e}}}function oi(){return{name:"table",toolbarItems:[{id:"table",label:"Table",icon:A.table,tooltip:"Insert Table",action:({editor:s})=>{s.insertBlock(`| Header 1 | Header 2 | Header 3 |
|
|
1138
1141
|
| -------- | -------- | -------- |
|
|
1139
1142
|
| Cell 1 | Cell 2 | Cell 3 |
|
|
1140
|
-
| Cell 4 | Cell 5 | Cell 6 |`)}}],provideTokens:s=>{if(!s.trim().startsWith("|"))return[];const e=[];for(const t of s.matchAll(/\|/g))e.push({cls:"op",start:t.index,end:t.index+1});return e}}}const
|
|
1143
|
+
| Cell 4 | Cell 5 | Cell 6 |`)}}],provideTokens:s=>{if(!s.trim().startsWith("|"))return[];const e=[];for(const t of s.matchAll(/\|/g))e.push({cls:"op",start:t.index,end:t.index+1});return e}}}const Ls=[{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 li(){return{name:"highlight",toolbarItems:[{id:"highlight",label:"Highlight",icon:A.highlight,tooltip:"Highlight Text",children:Ls.map(s=>({id:`highlight-${s.class}`,label:s.name,icon:`<span class="smdx-color-dot" style="background:${s.color}"></span>`,tooltip:`${s.name} Highlight`,action:({editor:e})=>{e.wrapSelection(`<Highlight color="${s.class}">`,"</Highlight>")}})),action:({editor:s})=>{s.wrapSelection('<Highlight color="yellow">',"</Highlight>")}}],components:[N({tag:"Highlight",selfClosing:!1,attrs:{color:{type:"enum",options:["yellow","green","blue","purple","pink","red","orange","cyan"],default:"yellow"}},render:({color:s,children:e})=>`<mark class="smdx-highlight smdx-highlight-${s}">${e}</mark>`})],styles:`
|
|
1141
1144
|
.smdx-highlight { padding: 2px 4px; border-radius: 3px; }
|
|
1142
1145
|
.smdx-highlight-yellow { background-color: #fef08a; }
|
|
1143
1146
|
.smdx-highlight-green { background-color: #bbf7d0; }
|
|
@@ -1156,11 +1159,11 @@ $$`},{label:"copy",kind:"snip",detail:"<CopyText> clickable copy block",body:"<C
|
|
|
1156
1159
|
.smdx-dark .smdx-highlight-orange { background-color: #9a3412; color: #fed7aa; }
|
|
1157
1160
|
.smdx-dark .smdx-highlight-cyan { background-color: #155e75; color: #a5f3fc; }
|
|
1158
1161
|
.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; }
|
|
1159
|
-
`}}const
|
|
1162
|
+
`}}const mt=[{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 di(){const s=mt.map(t=>t.type).join("|"),e=new RegExp(`^(:::)(${s})`);return{name:"admonition",toolbarItems:[{id:"admonition",label:"Admonition",icon:A.admonition,tooltip:"Admonition / Callout",children:mt.map(t=>({id:`admonition-${t.type}`,label:t.label,icon:t.icon,tooltip:`${t.label} callout`,action:({editor:i})=>{i.insertBlock(`:::${t.type}
|
|
1160
1163
|
${t.label}: Your message here
|
|
1161
1164
|
:::`)}})),action:({editor:t})=>{t.insertBlock(`:::info
|
|
1162
1165
|
INFO: Your message here
|
|
1163
|
-
:::`)}}],
|
|
1166
|
+
:::`)}}],patterns:[{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 n=mt.find(r=>r.type===i[1]),a=i[2]||n.label;return`<div class="smdx-admonition smdx-admonition-${i[1]}"><div class="smdx-admonition-title"><span class="smdx-admonition-icon">${n.icon}</span>${a}</div><div class="smdx-admonition-content">${i[3]}</div></div>`},priority:10,provideTokens:t=>{const i=[],n=t.match(e);return n?(i.push({cls:"kw",start:0,end:3}),i.push({cls:"cls",start:3,end:3+n[2].length})):t===":::"&&i.push({cls:"kw",start:0,end:3}),i}}],styles:`
|
|
1164
1167
|
.smdx-admonition { padding: 14px 16px; border-radius: 6px; margin: 12px 0; border-left: 4px solid; }
|
|
1165
1168
|
.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; }
|
|
1166
1169
|
.smdx-admonition-icon { display: flex; align-items: center; flex-shrink: 0; }
|
|
@@ -1189,42 +1192,37 @@ INFO: Your message here
|
|
|
1189
1192
|
.smdx-dark .smdx-admonition-info { background: #172554; }
|
|
1190
1193
|
.smdx-dark .smdx-admonition-note { background: #2e1065; }
|
|
1191
1194
|
.smdx-dark .smdx-admonition-content { color: var(--smdx-text, #e2e8f0); }
|
|
1192
|
-
|
|
1195
|
+
`}}function As(s){const e=s.split(`
|
|
1193
1196
|
`),t=e.filter(n=>n.trim().length>0),i=t.length>0?Math.min(...t.map(n=>n.match(/^\s*/)[0].length)):0;return i>0?e.map(n=>n.slice(i)).join(`
|
|
1194
|
-
`).trim():s.trim()}function
|
|
1197
|
+
`).trim():s.trim()}function ci(){return{name:"tab",toolbarItems:[{id:"tab",label:"Tab",icon:A.tab,tooltip:"Insert Tabs",action:({editor:s})=>{s.insertBlock(`<Tabs>
|
|
1195
1198
|
<Tab title="Tab 1">
|
|
1196
1199
|
Content for tab 1
|
|
1197
1200
|
</Tab>
|
|
1198
1201
|
<Tab title="Tab 2">
|
|
1199
1202
|
Content for tab 2
|
|
1200
1203
|
</Tab>
|
|
1201
|
-
</Tabs>`)}}],
|
|
1204
|
+
</Tabs>`)}}],provideTokens:ae(["Tab"]),components:[N({tag:"Tabs",selfClosing:!1,attrs:{},render:({children:s})=>{const e=Ge(s??"","Tab",{title:{type:"string",default:"Tab"}});if(e.length===0)return s??"";let i=`<div class="smdx-tabs" data-tab-id="${"tab-"+Math.random().toString(36).substring(2,8)}"><div class="smdx-tabs-header">`;return e.forEach((n,a)=>{i+=`<button class="smdx-tab-btn${a===0?" smdx-active":""}" data-smdx-tab-btn="true" data-tab-index="${a}">${n.attrs.title}</button>`}),i+="</div>",e.forEach((n,a)=>{i+=`<div class="smdx-tab-panel" style="display:${a===0?"block":"none"}">${As(n.children)}</div>`}),i+="</div>",i},priority:15})],styles:`
|
|
1202
1205
|
.smdx-tabs { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
1203
1206
|
.smdx-tabs-header { display: flex; background: var(--smdx-bg-muted, #f8fafc); border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
1204
1207
|
.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; }
|
|
1205
1208
|
.smdx-tab-btn:hover { color: var(--smdx-text, #1e293b); }
|
|
1206
1209
|
.smdx-tab-btn.smdx-active { color: var(--smdx-primary, #6366f1); border-bottom-color: var(--smdx-primary, #6366f1); background: var(--smdx-bg, #fff); }
|
|
1207
1210
|
.smdx-tab-panel { padding: 16px; }
|
|
1208
|
-
|
|
1211
|
+
`}}function hi(){return{name:"imageBackground",toolbarItems:[{id:"imageBackground",label:"Image Background",icon:A.imageBackground,tooltip:"Image with Background",action:({editor:s})=>{s.insertBlock(`<ImageBackground src="image-url" alt="description" background="#f0f0f0">
|
|
1209
1212
|
Content overlaying the image
|
|
1210
|
-
</ImageBackground>`)}}],
|
|
1211
|
-
<div class="smdx-image-bg-overlay">${e[4].trim()}</div>
|
|
1212
|
-
</div>`:s}}],styles:`
|
|
1213
|
+
</ImageBackground>`)}}],components:[N({tag:"ImageBackground",selfClosing:!1,attrs:{src:{type:"string",default:""},alt:{type:"string",default:""},background:{type:"string",default:""}},render:({src:s,alt:e,background:t,children:i})=>`<div class="smdx-image-bg" style="${t?`background-image:url(${s});background-color:${t}`:`background-image:url(${s})`}"><div class="smdx-image-bg-overlay">${(i??"").trim()}</div></div>`})],styles:`
|
|
1213
1214
|
.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); }
|
|
1214
1215
|
.smdx-image-bg-overlay { background: rgba(0,0,0,0.5); color: white; padding: 24px; width: 100%; text-align: center; }
|
|
1215
1216
|
.smdx-dark .smdx-image-bg-overlay { background: rgba(0,0,0,0.6); }
|
|
1216
|
-
|
|
1217
|
-
<img src="${e[1]}" alt="${e[2]||""}" />
|
|
1218
|
-
${e[3]?`<figcaption>${e[3]}</figcaption>`:""}
|
|
1219
|
-
</figure>`:s}}],styles:`
|
|
1217
|
+
`}}function pi(){return{name:"imageFrame",toolbarItems:[{id:"imageFrame",label:"Image Frame",icon:A.imageFrame,tooltip:"Image in Frame",action:({editor:s})=>{s.insertBlock('<ImageFrame src="image-url" alt="description" caption="Image caption" />')}}],components:[N({tag:"ImageFrame",selfClosing:!0,attrs:{src:{type:"string",default:""},alt:{type:"string",default:""},caption:{type:"string",default:""}},render:({src:s,alt:e,caption:t})=>`<figure class="smdx-image-frame"><img src="${s}" alt="${e}" />${t?`<figcaption>${t}</figcaption>`:""}</figure>`})],styles:`
|
|
1220
1218
|
.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); }
|
|
1221
1219
|
.smdx-image-frame img { width: 100%; border-radius: 4px; display: block; }
|
|
1222
1220
|
.smdx-image-frame figcaption { text-align: center; padding: 8px 0 4px; font-size: 0.85em; color: var(--smdx-text-muted, #64748b); }
|
|
1223
|
-
|
|
1221
|
+
`}}function ui(s){const e=s.split(`
|
|
1224
1222
|
`),t=e.filter(n=>n.trim().length>0),i=t.length>0?Math.min(...t.map(n=>n.match(/^\s*/)[0].length)):0;return i>0?e.map(n=>n.slice(i)).join(`
|
|
1225
|
-
`).trim():s.trim()}function
|
|
1226
|
-
Your content here.
|
|
1227
|
-
</Accordion>`)}}],
|
|
1223
|
+
`).trim():s.trim()}function gi(){return{name:"accordion",toolbarItems:[{id:"accordion",label:"Accordion",icon:A.accordion,tooltip:"Insert Accordion",action:({editor:s})=>{s.insertBlock(`<Accordion title="Accordion Title" defaultOpen>
|
|
1224
|
+
Your content here.
|
|
1225
|
+
</Accordion>`)}}],components:[N({tag:"Accordion",selfClosing:!1,attrs:{title:{type:"string",default:"Accordion Title"},defaultOpen:{type:"boolean",default:!1}},render:({title:s,defaultOpen:e,children:t})=>`<details class="smdx-accordion"${e?" open":""}><summary class="smdx-accordion-header"><span class="smdx-accordion-arrow"></span><span class="smdx-accordion-title">${s}</span></summary><div class="smdx-accordion-content">${ui(t??"")}</div></details>`,priority:12})],styles:`
|
|
1228
1226
|
.smdx-accordion { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; margin: 8px 0; overflow: hidden; background: var(--smdx-bg, #fff); }
|
|
1229
1227
|
.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); }
|
|
1230
1228
|
.smdx-accordion-header::-webkit-details-marker { display: none; }
|
|
@@ -1234,7 +1232,7 @@ INFO: Your message here
|
|
|
1234
1232
|
.smdx-accordion-content { padding: 14px 18px 18px 18px; border-top: 1px solid var(--smdx-border, #e2e8f0); }
|
|
1235
1233
|
.smdx-accordion-content p { margin: 6px 0; }
|
|
1236
1234
|
.smdx-accordion-content > :last-child { margin-bottom: 0; }
|
|
1237
|
-
|
|
1235
|
+
`}}function mi(){return{name:"accordionGroup",dependencies:["accordion"],toolbarItems:[{id:"accordionGroup",label:"Accordion Group",icon:A.accordionGroup,tooltip:"Insert Accordion Group",action:({editor:s})=>{s.insertBlock(`<AccordionGroup>
|
|
1238
1236
|
<Accordion title="Section 1" defaultOpen>
|
|
1239
1237
|
Content for section 1
|
|
1240
1238
|
</Accordion>
|
|
@@ -1244,13 +1242,13 @@ INFO: Your message here
|
|
|
1244
1242
|
<Accordion title="Section 3">
|
|
1245
1243
|
Content for section 3
|
|
1246
1244
|
</Accordion>
|
|
1247
|
-
</AccordionGroup>`)}}],
|
|
1245
|
+
</AccordionGroup>`)}}],components:[N({tag:"AccordionGroup",selfClosing:!1,attrs:{},render:({children:s})=>`<div class="smdx-accordion-group">${s}</div>`,priority:14})],styles:`
|
|
1248
1246
|
.smdx-accordion-group { display: flex; flex-direction: column; gap: 0; margin: 12px 0; }
|
|
1249
1247
|
.smdx-accordion-group > :not(.smdx-accordion) { display: none; }
|
|
1250
1248
|
.smdx-accordion-group .smdx-accordion { margin: 0; border-radius: 0; border-bottom: none; }
|
|
1251
1249
|
.smdx-accordion-group .smdx-accordion:first-of-type { border-radius: 8px 8px 0 0; }
|
|
1252
1250
|
.smdx-accordion-group .smdx-accordion:last-of-type { border-radius: 0 0 8px 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
1253
|
-
|
|
1251
|
+
`}}function fi(){return{name:"multiColumn",toolbarItems:[{id:"multiColumn",label:"Columns",icon:A.multiColumn,tooltip:"Multiple Columns",children:[2,3,4,5].map(s=>({id:`columns-${s}`,label:`${s} Columns`,tooltip:`${s} column layout`,action:({editor:e})=>{const t=Array.from({length:s},(i,n)=>` <Column>
|
|
1254
1252
|
Column ${n+1} content
|
|
1255
1253
|
</Column>`).join(`
|
|
1256
1254
|
`);e.insertBlock(`<Columns count="${s}">
|
|
@@ -1262,18 +1260,19 @@ ${t}
|
|
|
1262
1260
|
<Column>
|
|
1263
1261
|
Column 2 content
|
|
1264
1262
|
</Column>
|
|
1265
|
-
</Columns>`)}}],
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1263
|
+
</Columns>`)}}],provideTokens:ae(["Column"]),components:[N({tag:"Columns",selfClosing:!1,attrs:{count:{type:"number",default:2}},render:({count:s,children:e})=>{const i=Ge(e??"","Column").map(n=>`<div class="smdx-column">
|
|
1264
|
+
${ui(n.children)}
|
|
1265
|
+
</div>`).join(`
|
|
1266
|
+
`);return`<div class="smdx-columns" style="grid-template-columns:repeat(${s},1fr)">
|
|
1267
|
+
${i}
|
|
1268
|
+
</div>`},priority:13})],styles:`
|
|
1270
1269
|
.smdx-columns { display: grid; gap: 16px; margin: 12px 0; }
|
|
1271
1270
|
.smdx-column { padding: 12px; border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 6px; }
|
|
1272
|
-
|
|
1271
|
+
`}}function Is(s){const e=s.split(`
|
|
1273
1272
|
`),t=e.filter(n=>n.trim().length>0),i=t.length>0?Math.min(...t.map(n=>n.match(/^\s*/)[0].length)):0;return i>0?e.map(n=>n.slice(i)).join(`
|
|
1274
|
-
`).trim():s.trim()}function
|
|
1273
|
+
`).trim():s.trim()}function bi(){return{name:"card",toolbarItems:[{id:"card",label:"Card",icon:A.card,tooltip:"Insert Card",action:({editor:s})=>{s.insertBlock(`<Card title="Card Title" icon="📄" href="/link">
|
|
1275
1274
|
Card description or content goes here.
|
|
1276
|
-
</Card>`)}}],
|
|
1275
|
+
</Card>`)}}],components:[N({tag:"Card",selfClosing:!1,attrs:{title:{type:"string",default:"Card Title"},icon:{type:"string",default:""},href:{type:"string",default:""}},render:({title:s,icon:e,href:t,children:i})=>{const n=t?"a":"div",a=t?` href="${t}" target="_blank" rel="noopener noreferrer"`:"",r=e?`<span class="smdx-card-icon">${e}</span>`:"";return`<${n} class="smdx-card"${a}><div class="smdx-card-header">${r}<span class="smdx-card-title">${s}</span>${t?'<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>':""}</div><div class="smdx-card-content">${Is(i??"")}</div></${n}>`},priority:11})],styles:`
|
|
1277
1276
|
.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); }
|
|
1278
1277
|
a.smdx-card { cursor: pointer; }
|
|
1279
1278
|
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); }
|
|
@@ -1283,7 +1282,7 @@ ${o}
|
|
|
1283
1282
|
.smdx-card-arrow { margin-left: auto; flex-shrink: 0; color: var(--smdx-text-muted, #94a3b8); transition: transform 0.2s, color 0.2s; }
|
|
1284
1283
|
a.smdx-card:hover .smdx-card-arrow { transform: translateX(2px); color: var(--smdx-primary, #6366f1); }
|
|
1285
1284
|
.smdx-card-content { font-size: 0.9em; color: var(--smdx-text-muted, #64748b); line-height: 1.5; }
|
|
1286
|
-
|
|
1285
|
+
`}}function yi(){return{name:"cardGroup",dependencies:["card"],toolbarItems:[{id:"cardGroup",label:"Card Group",icon:A.cardGroup,tooltip:"Insert Card Group",action:({editor:s})=>{s.insertBlock(`<CardGroup cols="2">
|
|
1287
1286
|
<Card title="Card 1" icon="📄">
|
|
1288
1287
|
Description for card 1
|
|
1289
1288
|
</Card>
|
|
@@ -1296,12 +1295,12 @@ ${o}
|
|
|
1296
1295
|
<Card title="Card 4" icon="💡">
|
|
1297
1296
|
Description for card 4
|
|
1298
1297
|
</Card>
|
|
1299
|
-
</CardGroup>`)}}],
|
|
1298
|
+
</CardGroup>`)}}],components:[N({tag:"CardGroup",selfClosing:!1,attrs:{cols:{type:"number",default:2}},render:({cols:s,children:e})=>`<div class="smdx-card-group" style="grid-template-columns:repeat(${s},1fr)">${e}</div>`,priority:13})],styles:`
|
|
1300
1299
|
.smdx-card-group { display: grid; gap: 12px; margin: 12px 0; }
|
|
1301
1300
|
.smdx-card-group .smdx-card { margin: 0; }
|
|
1302
|
-
|
|
1301
|
+
`}}function xi(s){const e=s.split(`
|
|
1303
1302
|
`),t=e.filter(n=>n.trim().length>0),i=t.length>0?Math.min(...t.map(n=>n.match(/^\s*/)[0].length)):0;return i>0?e.map(n=>n.slice(i)).join(`
|
|
1304
|
-
`).trim():s.trim()}function
|
|
1303
|
+
`).trim():s.trim()}function ki(){return{name:"step",toolbarItems:[{id:"steps",label:"Steps",icon:A.step,tooltip:"Insert Steps",action:({editor:s})=>{s.insertBlock(`<Steps>
|
|
1305
1304
|
<Step title="First Step">
|
|
1306
1305
|
These are instructions or content that only pertain to the first step.
|
|
1307
1306
|
</Step>
|
|
@@ -1311,7 +1310,7 @@ ${o}
|
|
|
1311
1310
|
<Step title="Third Step">
|
|
1312
1311
|
These are instructions or content that only pertain to the third step.
|
|
1313
1312
|
</Step>
|
|
1314
|
-
</Steps>`)}}],
|
|
1313
|
+
</Steps>`)}}],provideTokens:ae(["Step"]),components:[N({tag:"Steps",selfClosing:!1,attrs:{},render:({children:s})=>{const e=Ge(s??"","Step",{title:{type:"string",default:"Step"}});let t='<div class="smdx-steps">';return e.forEach((i,n)=>{const a=n===e.length-1;t+=`<div class="smdx-step"><div class="smdx-step-indicator"><div class="smdx-step-number">${n+1}</div>${a?"":'<div class="smdx-step-line"></div>'}</div><div class="smdx-step-content"><div class="smdx-step-title">${i.attrs.title}</div><div class="smdx-step-body">${xi(i.children)}</div></div></div>`}),t+="</div>",t},priority:15})],styles:`
|
|
1315
1314
|
.smdx-steps { margin: 20px 0; }
|
|
1316
1315
|
.smdx-step { display: flex; gap: 20px; position: relative; }
|
|
1317
1316
|
.smdx-step-indicator { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 34px; position: relative; }
|
|
@@ -1321,7 +1320,7 @@ ${o}
|
|
|
1321
1320
|
.smdx-step:last-child .smdx-step-content { padding-bottom: 0; }
|
|
1322
1321
|
.smdx-step-title { font-weight: 700; font-size: 1.05em; color: var(--smdx-text, #1e293b); margin-bottom: 8px; }
|
|
1323
1322
|
.smdx-step-body { color: var(--smdx-text-muted, #64748b); font-size: 0.95em; line-height: 1.7; }
|
|
1324
|
-
|
|
1323
|
+
`}}const wi=[{type:"good",label:"Good",tag:"TipGood",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",tag:"TipBad",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",tag:"TipInfo",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 _i(){return{name:"tip",toolbarItems:[{id:"tip",label:"Tip",icon:A.tip,tooltip:"Insert Tip",children:wi.map(s=>({id:`tip-${s.type}`,label:s.label,icon:s.icon,tooltip:`${s.label} tip`,action:({editor:e})=>{e.insertBlock(`<${s.tag}>Your tip message here</${s.tag}>`)}})),action:({editor:s})=>{s.insertBlock("<TipGood>Your tip message here</TipGood>")}}],components:wi.map(s=>N({tag:s.tag,selfClosing:!1,attrs:{},render:({children:e})=>`<div class="smdx-tip smdx-tip-${s.type}"><span class="smdx-tip-icon">${s.icon}</span><span class="smdx-tip-text">${(e??"").trim()}</span></div>`,priority:10})),styles:`
|
|
1325
1324
|
.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; }
|
|
1326
1325
|
.smdx-tip-icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 1px; }
|
|
1327
1326
|
.smdx-tip-icon svg { display: block; }
|
|
@@ -1332,12 +1331,12 @@ ${o}
|
|
|
1332
1331
|
.smdx-dark .smdx-tip-good { background: #052e16; }
|
|
1333
1332
|
.smdx-dark .smdx-tip-bad { background: #450a0a; }
|
|
1334
1333
|
.smdx-dark .smdx-tip-info { background: #172554; }
|
|
1335
|
-
|
|
1334
|
+
`}}function vi(){return{name:"container",toolbarItems:[{id:"container",label:"Container",icon:A.container,tooltip:"Insert Container",action:({editor:s})=>{s.insertBlock(`<Container>
|
|
1336
1335
|
Content inside a styled container.
|
|
1337
|
-
</Container>`)}}],
|
|
1336
|
+
</Container>`)}}],components:[N({tag:"Container",selfClosing:!1,attrs:{title:{type:"string",default:""}},render:({title:s,children:e})=>`<div class="smdx-container">${s?`<div class="smdx-container-title">${s}</div>`:""}<div class="smdx-container-content">${xi(e??"")}</div></div>`})],styles:`
|
|
1338
1337
|
.smdx-container { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; padding: 16px; margin: 12px 0; background: var(--smdx-bg-muted, #f8fafc); }
|
|
1339
1338
|
.smdx-container-title { font-weight: 600; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--smdx-border, #e2e8f0); }
|
|
1340
|
-
|
|
1339
|
+
`}}function Ci(){return{name:"copyText",toolbarItems:[{id:"copyText",label:"Copy Text",icon:A.copyText,tooltip:"Copyable Text Block",action:({editor:s})=>{s.insertBlock("<CopyText>Text that users can click to copy</CopyText>")}}],components:[N({tag:"CopyText",selfClosing:!1,attrs:{},render:({children:s})=>{const e=(s??"").trim();return`<div class="smdx-copy-text" data-copy-text-div="true" data-text="${e.replace(/"/g,""")}"><code class="smdx-copy-text-content">${e}</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:`
|
|
1341
1340
|
.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; }
|
|
1342
1341
|
.smdx-copy-text:hover { border-color: var(--smdx-primary, #6366f1); }
|
|
1343
1342
|
.smdx-copy-text.smdx-copied { border-color: #22c55e; background: #f0fdf4; }
|
|
@@ -1346,7 +1345,7 @@ ${o}
|
|
|
1346
1345
|
.smdx-copy-text:hover .smdx-copy-text-btn { color: var(--smdx-text, #1e293b); }
|
|
1347
1346
|
.smdx-copy-text.smdx-copied .smdx-copy-text-btn { color: #22c55e; }
|
|
1348
1347
|
.smdx-dark .smdx-copy-text.smdx-copied { background: #052e16; border-color: #166534; }
|
|
1349
|
-
|
|
1348
|
+
`}}function Ti(){return{name:"tooltip",toolbarItems:[{id:"tooltip",label:"Tooltip",icon:A.tooltip,tooltip:"Insert Tooltip",action:({editor:s})=>{const t=s.getSelection().text||"hover text";s.replaceSelection(`<Tooltip tip="Tooltip content">${t}</Tooltip>`)}}],components:[N({tag:"Tooltip",selfClosing:!1,attrs:{tip:{type:"string",default:""}},render:({tip:s,children:e})=>`<span class="smdx-tooltip-wrapper"><span class="smdx-tooltip-trigger">${e}<span class="smdx-tooltip-popup">${s}</span></span></span>`})],styles:`
|
|
1350
1349
|
.smdx-tooltip-wrapper { position: relative; display: inline; }
|
|
1351
1350
|
.smdx-tooltip-trigger { position: relative; border-bottom: 1px dashed var(--smdx-primary, #6366f1); cursor: help; text-decoration: none; }
|
|
1352
1351
|
.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; }
|
|
@@ -1354,16 +1353,10 @@ ${o}
|
|
|
1354
1353
|
.smdx-tooltip-trigger:hover .smdx-tooltip-popup { visibility: visible; opacity: 1; }
|
|
1355
1354
|
.smdx-dark .smdx-tooltip-popup { background: #e2e8f0; color: #1e293b; }
|
|
1356
1355
|
.smdx-dark .smdx-tooltip-popup::after { border-top-color: #e2e8f0; }
|
|
1357
|
-
|
|
1358
|
-
<iframe src="https://www.youtube.com/embed/${encodeURIComponent(a)}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
|
|
1359
|
-
</div>`}return`<div class="smdx-embed-video">
|
|
1360
|
-
<video controls src="${i}" class="smdx-video-player">
|
|
1361
|
-
Your browser does not support the video tag.
|
|
1362
|
-
</video>
|
|
1363
|
-
</div>`}}],styles:`
|
|
1356
|
+
`}}function Ei(){return{name:"embedVideo",toolbarItems:[{id:"embedVideo",label:"Embed Video",icon:A.embedVideo,tooltip:"Embed Video",children:[{id:"embed-youtube",label:"YouTube",tooltip:"Embed YouTube video",action:({editor:s})=>{s.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:s})=>{s.insertBlock('<EmbedVideo type="file" src="video.mp4" />')}}],action:({editor:s})=>{s.insertBlock('<EmbedVideo type="youtube" src="https://www.youtube.com/watch?v=VIDEO_ID" />')}}],components:[N({tag:"EmbedVideo",selfClosing:!0,attrs:{type:{type:"enum",options:["youtube","file"],default:"youtube"},src:{type:"string",default:""}},render:({type:s,src:e})=>{if(s==="youtube"){const t=e.match(/(?:v=|\/embed\/|youtu\.be\/)([\w-]+)/),i=t?t[1]:e;return`<div class="smdx-embed-video"><iframe src="https://www.youtube.com/embed/${encodeURIComponent(i)}" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe></div>`}return`<div class="smdx-embed-video"><video controls src="${e}" class="smdx-video-player">Your browser does not support the video tag.</video></div>`}})],styles:`
|
|
1364
1357
|
.smdx-embed-video { position: relative; width: 100%; padding-top: 56.25%; margin: 12px 0; border-radius: 8px; overflow: hidden; background: #000; }
|
|
1365
1358
|
.smdx-embed-video iframe, .smdx-embed-video video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
|
1366
|
-
|
|
1359
|
+
`}}const Bs='<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>';function Ve(s,e,t){return`<div class="smdx-embed smdx-embed-card"><div class="smdx-embed-card-icon">${s}</div><div class="smdx-embed-card-body"><div class="smdx-embed-card-title">${e}</div><div class="smdx-embed-card-url">${t}</div></div><a href="${t}" target="_blank" rel="noopener noreferrer" class="smdx-embed-card-link">Open ${Bs}</a></div>`}function Si(){return{name:"embedOthers",toolbarItems:[{id:"embedOthers",label:"Embed",icon:A.embedOthers,tooltip:"Embed External Content",children:[{id:"embed-github",label:"GitHub Gist",tooltip:"Embed GitHub Gist",action:({editor:s})=>s.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')},{id:"embed-twitter",label:"Twitter/X Post",tooltip:"Embed Tweet",action:({editor:s})=>s.insertBlock('<Embed type="twitter" src="https://twitter.com/user/status/TWEET_ID" />')},{id:"embed-codepen",label:"CodePen",tooltip:"Embed CodePen",action:({editor:s})=>s.insertBlock('<Embed type="codepen" src="https://codepen.io/user/pen/PEN_ID" />')},{id:"embed-codesandbox",label:"CodeSandbox",tooltip:"Embed CodeSandbox",action:({editor:s})=>s.insertBlock('<Embed type="codesandbox" src="https://codesandbox.io/s/SANDBOX_ID" />')}],action:({editor:s})=>s.insertBlock('<Embed type="github" src="https://gist.github.com/USER/GIST_ID" />')}],components:[N({tag:"Embed",selfClosing:!0,attrs:{type:{type:"enum",options:["github","twitter","codepen","codesandbox"],default:"github"},src:{type:"string",default:""},label:{type:"string",default:""}},render:({type:s,src:e,label:t})=>{switch(s){case"github":return Ve('<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>',t||"GitHub Gist",e);case"twitter":return Ve('<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>',t||"Post on X (Twitter)",e);case"codepen":{const i=e.match(/codepen\.io\/([^/]+)\/pen\/([^/?]+)/);return i?`<div class="smdx-embed smdx-embed-codepen"><iframe height="400" style="width:100%" scrolling="no" src="https://codepen.io/${encodeURIComponent(i[1])}/embed/${encodeURIComponent(i[2])}?default-tab=result" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"></iframe></div>`:Ve('<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>',t||"CodePen",e)}case"codesandbox":{const i=e.split("/").pop()??"";return`<div class="smdx-embed smdx-embed-codesandbox"><iframe src="https://codesandbox.io/embed/${encodeURIComponent(i)}" 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 Ve('<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>',t||"Embedded Content",e)}}})],styles:`
|
|
1367
1360
|
.smdx-embed { margin: 12px 0; border-radius: 8px; overflow: hidden; }
|
|
1368
1361
|
.smdx-embed iframe { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; }
|
|
1369
1362
|
.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; }
|
|
@@ -1376,7 +1369,7 @@ ${o}
|
|
|
1376
1369
|
.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; }
|
|
1377
1370
|
.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; }
|
|
1378
1371
|
.smdx-embed-card-link:hover { background: var(--smdx-bg-muted, #f8fafc); text-decoration: none; }
|
|
1379
|
-
|
|
1372
|
+
`}}const $i=[{id:"flowchart",label:"Flowchart",template:`graph TD
|
|
1380
1373
|
Start --> Stop`},{id:"sequence",label:"Sequence Diagram",template:`sequenceDiagram
|
|
1381
1374
|
Alice->>John: Hello John, how are you?
|
|
1382
1375
|
John-->>Alice: Great!
|
|
@@ -1426,7 +1419,7 @@ ${o}
|
|
|
1426
1419
|
Another task :after a1 , 20d
|
|
1427
1420
|
section Another
|
|
1428
1421
|
Task in sec :2014-01-12 , 12d
|
|
1429
|
-
another task : 24d`}];function
|
|
1422
|
+
another task : 24d`}];function Ri(){return{name:"mermaid",toolbarItems:[{id:"mermaid",label:"Mermaid",icon:A.mermaid,tooltip:"Insert Mermaid Diagram",children:$i.map(s=>({id:`mermaid-${s.id}`,label:s.label,tooltip:`Insert ${s.label}`,action:({editor:e})=>{e.insertBlock("```mermaid\n"+s.template+"\n```")}})),action:({editor:s})=>{s.insertBlock("```mermaid\n"+$i[0].template+"\n```")}}],patterns:[{name:"mermaid",pattern:/```mermaid\n([\s\S]*?)```/g,render:s=>{const e=s.match(/```mermaid\n([\s\S]*?)```/);if(!e)return s;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,provideTokens:s=>{const e=[],t=s.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(s)&&e.push({cls:"kw",start:0,end:s.length}),e}}],async init(s){const e=async()=>{try{const t=window.mermaid;if(!t)return;const i=s.editor.getRoot().classList.contains("smdx-dark");t.initialize({startOnLoad:!1,theme:i?"dark":"default"});const n=s.editor.getPreview();if(!n)return;const a=n.querySelectorAll(".smdx-mermaid[data-mermaid-code]");for(const r of Array.from(a)){const o=decodeURIComponent(r.getAttribute("data-mermaid-code")),c=r.getAttribute("data-mermaid-id");try{const{svg:d}=await t.render(c,o);r.innerHTML=d,r.removeAttribute("data-mermaid-code")}catch{r.innerHTML=`<pre class="smdx-mermaid-error">${o.replace(/</g,"<").replace(/>/g,">")}</pre>`,r.removeAttribute("data-mermaid-code")}}}catch{}};s.on("render",e)},styles:`
|
|
1430
1423
|
.smdx-mermaid { margin: 12px 0; text-align: center; }
|
|
1431
1424
|
.smdx-mermaid svg { max-width: 100%; height: auto; }
|
|
1432
1425
|
.smdx-mermaid-placeholder { padding: 24px; color: var(--smdx-text-muted, #94a3b8); font-size: 0.9em; }
|
|
@@ -1477,9 +1470,9 @@ ${o}
|
|
|
1477
1470
|
.smdx-dark .smdx-mermaid .section0,
|
|
1478
1471
|
.smdx-dark .smdx-mermaid .section1 { fill: #374151 !important; }
|
|
1479
1472
|
.smdx-dark .smdx-mermaid .today { stroke: #818cf8 !important; }
|
|
1480
|
-
|
|
1473
|
+
`}}const ft=[["😀","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 Mi(){return{name:"emoji",toolbarItems:[{id:"emoji",label:"Emoji",icon:A.emoji,tooltip:"Insert Emoji",action:s=>{},render:(s,e)=>{s.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),Ds(s,e.editor)})}}]}}function Ds(s,e){var d;(d=document.querySelector(".smdx-emoji-picker"))==null||d.remove();const t=document.createElement("div");t.className="smdx-emoji-picker";const i=s.closest(".smdx-editor");i!=null&&i.classList.contains("smdx-dark")&&t.classList.add("smdx-dark");const n=document.createElement("input");n.type="text",n.placeholder="Search emoji...",n.className="smdx-emoji-search",t.appendChild(n);const a=document.createElement("div");a.className="smdx-emoji-grid";const r=l=>{a.innerHTML="";for(const[h]of l){const p=document.createElement("button");p.type="button",p.className="smdx-emoji-btn",p.textContent=h,p.addEventListener("click",()=>{e.insertText(h),t.remove()}),a.appendChild(p)}};r(ft),n.addEventListener("input",()=>{const l=n.value.toLowerCase().trim();if(!l){r(ft);return}r(ft.filter(([,h])=>h.includes(l)))}),t.appendChild(a);const o=s.getBoundingClientRect();t.style.position="fixed",t.style.top=`${o.bottom+4}px`,t.style.left=`${o.left}px`,document.body.appendChild(t);const c=l=>{!t.contains(l.target)&&l.target!==s&&(t.remove(),document.removeEventListener("click",c))};setTimeout(()=>document.addEventListener("click",c),0),n.focus()}function Li(){return{name:"formula",toolbarItems:[{id:"formula",label:"Formula",icon:A.formula,tooltip:"Insert Formula",children:[{id:"formula-inline",label:"Inline Formula",tooltip:"Inline math: $formula$",action:({editor:s})=>{s.wrapSelection("$","$")}},{id:"formula-block",label:"Block Formula",tooltip:"Block math: $$formula$$",action:({editor:s,selection:e})=>{s.insertBlock(`$$
|
|
1481
1474
|
`+(e.text||"E = mc^2")+`
|
|
1482
|
-
$$`)}}],action:({editor:s})=>{s.wrapSelection("$","$")}}],
|
|
1475
|
+
$$`)}}],action:({editor:s})=>{s.wrapSelection("$","$")}}],patterns:[{name:"formula-block",pattern:/\$\$([\s\S]*?)\$\$/g,render:s=>{const e=s.match(/\$\$([\s\S]*?)\$\$/);if(!e)return s;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,provideTokens:s=>/^\$\$\s*$/.test(s)?[{cls:"num",start:0,end:s.trimEnd().length||s.length}]:[]},{name:"formula-inline",pattern:new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$","g"),render:s=>{const e=s.match(new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$"));if(!e)return s;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,provideTokens:s=>{const e=[];for(const t of s.matchAll(new RegExp("(?<!\\$)\\$(?!\\$)((?:[^$\\\\]|\\\\.)+)\\$","g")))e.push({cls:"num",start:t.index,end:t.index+t[0].length});return e}}],styles:`
|
|
1483
1476
|
.smdx-formula-block { text-align: center; margin: 16px 0; font-size: 1.2em; overflow-x: auto; }
|
|
1484
1477
|
.smdx-formula-fallback { background: var(--smdx-bg-muted, #f8fafc); padding: 12px; border-radius: 6px; border: 1px solid var(--smdx-border, #e2e8f0); }
|
|
1485
1478
|
.smdx-formula-inline { font-size: 0.95em; }
|
|
@@ -1494,7 +1487,7 @@ $$`)}}],action:({editor:s})=>{s.wrapSelection("$","$")}}],renderers:[{name:"form
|
|
|
1494
1487
|
.smdx-dark .smdx-emoji-search, .smdx-emoji-picker.smdx-dark .smdx-emoji-search { background: #2a2a3c; color: #e2e8f0; border-color: #374151; }
|
|
1495
1488
|
.smdx-dark .smdx-emoji-search:focus, .smdx-emoji-picker.smdx-dark .smdx-emoji-search:focus { border-color: #818cf8; }
|
|
1496
1489
|
.smdx-dark .smdx-emoji-btn:hover, .smdx-emoji-picker.smdx-dark .smdx-emoji-btn:hover { background: #2a2a3c; }
|
|
1497
|
-
|
|
1490
|
+
`}}function F(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ai(){const s=new Map;async function e(n){if(s.has(n))return s.get(n);try{let a=await fetch(n+"?raw");if(a.ok||(a=await fetch(n)),!a.ok){const l={content:null,error:`File not found: ${n} (${a.status})`};return s.set(n,l),l}let r=await a.text();const o=r.trimStart();if(o.startsWith("<!DOCTYPE")||o.startsWith("<!doctype")||o.startsWith("<html")){const l={content:null,error:`File not found: ${n}`};return s.set(n,l),l}const c=r.match(/^export default (?:\/\*(?:[^*]|\*(?!\/))*\*\/\s*)?["']([\s\S]*)["']\s*;?\s*$/);c&&(r=c[1].replace(/\\n/g,`
|
|
1498
1491
|
`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\").replace(/\\u([\da-fA-F]{4})/g,(l,h)=>String.fromCharCode(parseInt(h,16))));const d={content:r};return s.set(n,d),d}catch{const a={content:null,error:`Failed to load: ${n}`};return s.set(n,a),a}}function t(n,a){const r=a.match(/^(\d+)-(\d+)$/);if(!r)return n;const o=Math.max(1,parseInt(r[1],10)),c=parseInt(r[2],10);return n.split(`
|
|
1499
1492
|
`).slice(o-1,c).join(`
|
|
1500
1493
|
`)}async function i(n){const a=n.querySelectorAll(".smdx-import[data-src]");for(const o of a){if(o.dataset.loaded==="true")continue;o.dataset.loaded="true";const c=o.dataset.src,{content:d,error:l}=await e(c);l?(o.innerHTML=`<span class="smdx-import-icon">⚠️</span> <span class="smdx-import-error">${F(l)}</span>`,o.classList.add("smdx-import-failed")):(o.innerHTML=`<div class="smdx-import-header"><span class="smdx-import-icon">📄</span> <code>${F(c)}</code></div><div class="smdx-import-content">${F(d)}</div>`,o.classList.add("smdx-import-loaded"))}const r=n.querySelectorAll(".smdx-snippet[data-src]");for(const o of r){if(o.dataset.loaded==="true")continue;o.dataset.loaded="true";const c=o.dataset.src,d=o.dataset.lines||"",{content:l,error:h}=await e(c);if(h)o.innerHTML=`<span class="smdx-snippet-icon">⚠️</span> <span class="smdx-snippet-error">${F(h)}</span>`,o.classList.add("smdx-snippet-failed");else{const p=d?t(l,d):l,u=c.split(".").pop()||"text",m=d?` <span class="smdx-snippet-lines">(lines ${F(d)})</span>`:"";o.innerHTML=`<div class="smdx-snippet-header"><span class="smdx-snippet-icon">📋</span> <code>${F(c)}</code>${m}</div><pre class="smdx-snippet-code"><code class="language-${F(u)}">${F(p)}</code></pre>`,o.classList.add("smdx-snippet-loaded")}}}return{name:"insert",init(n){n.on("render",()=>{const a=n.editor.getPreview();a&&i(a)})},toolbarItems:(()=>{const n={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("---")}},a={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">
|
|
@@ -1557,13 +1550,7 @@ Column 4 here.
|
|
|
1557
1550
|
"data": {}
|
|
1558
1551
|
}
|
|
1559
1552
|
\`\`\`
|
|
1560
|
-
</Endpoint>`),description:"Insert API Endpoint"},{key:"Ctrl+Shift+m",action:({editor:n})=>n.insertBlock('<Import src="./path/to/file.md" />'),description:"Insert Markdown Import"},{key:"Ctrl+Shift+s",action:({editor:n})=>n.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />'),description:"Insert Code Snippet"}],
|
|
1561
|
-
<div class="smdx-endpoint-header">
|
|
1562
|
-
<span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[r]||"#64748b"}">${r}</span>
|
|
1563
|
-
<code class="smdx-endpoint-path">${o}</code>
|
|
1564
|
-
</div>
|
|
1565
|
-
<div class="smdx-endpoint-body">${a[3].trim()}</div>
|
|
1566
|
-
</div>`},priority:10},{name:"import",pattern:/<Import\s+src="([^"]*)"(?:\s*\/)?>/gi,render:n=>{const a=n.match(/<Import\s+src="([^"]*)"(?:\s*\/)?>/i);if(!a)return n;const r=a[1];return`<div class="smdx-import" data-src="${F(r)}"><span class="smdx-import-icon">📄</span> Loading <code>${F(r)}</code>…</div>`}},{name:"snippet",pattern:/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/gi,render:n=>{const a=n.match(/<Snippet\s+src="([^"]*)"(?:\s+lines="([^"]*)")?\s*\/?>/i);if(!a)return n;const r=a[1],o=a[2]||"";return`<div class="smdx-snippet" data-src="${F(r)}"${o?` data-lines="${F(o)}"`:""}><span class="smdx-snippet-icon">📋</span> Loading <code>${F(r)}</code>…</div>`}}],styles:`
|
|
1553
|
+
</Endpoint>`),description:"Insert API Endpoint"},{key:"Ctrl+Shift+m",action:({editor:n})=>n.insertBlock('<Import src="./path/to/file.md" />'),description:"Insert Markdown Import"},{key:"Ctrl+Shift+s",action:({editor:n})=>n.insertBlock('<Snippet src="./snippets/example.ts" lines="1-20" />'),description:"Insert Code Snippet"}],components:[N({tag:"Endpoint",selfClosing:!1,attrs:{method:{type:"string",default:"GET"},path:{type:"string",default:""}},render:({method:n,path:a,children:r})=>{const o=n.toUpperCase();return`<div class="smdx-endpoint"><div class="smdx-endpoint-header"><span class="smdx-endpoint-method" style="background:${{GET:"#22c55e",POST:"#3b82f6",PUT:"#f59e0b",PATCH:"#a855f7",DELETE:"#ef4444"}[o]??"#64748b"}">${o}</span><code class="smdx-endpoint-path">${F(a)}</code></div><div class="smdx-endpoint-body">${(r??"").trim()}</div></div>`},priority:10}),N({tag:"Import",selfClosing:!0,attrs:{src:{type:"string",default:""}},render:({src:n})=>`<div class="smdx-import" data-src="${F(n)}"><span class="smdx-import-icon">📄</span> Loading <code>${F(n)}</code>…</div>`}),N({tag:"Snippet",selfClosing:!0,attrs:{src:{type:"string",default:""},lines:{type:"string",default:""}},render:({src:n,lines:a})=>{const r=a?` data-lines="${F(a)}"`:"";return`<div class="smdx-snippet" data-src="${F(n)}"${r}><span class="smdx-snippet-icon">📋</span> Loading <code>${F(n)}</code>…</div>`}})],styles:`
|
|
1567
1554
|
.smdx-endpoint { border: 1px solid var(--smdx-border, #e2e8f0); border-radius: 8px; overflow: hidden; margin: 12px 0; }
|
|
1568
1555
|
.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); }
|
|
1569
1556
|
.smdx-endpoint-method { color: white; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.8em; letter-spacing: 0.05em; }
|
|
@@ -1582,11 +1569,11 @@ Column 4 here.
|
|
|
1582
1569
|
.smdx-import-error, .smdx-snippet-error { color: #b91c1c; }
|
|
1583
1570
|
.smdx-dark .smdx-import-failed, .smdx-dark .smdx-snippet-failed { background: #450a0a; border-color: #991b1b; }
|
|
1584
1571
|
.smdx-dark .smdx-import-error, .smdx-dark .smdx-snippet-error { color: #fca5a5; }
|
|
1585
|
-
`,provideTokens:
|
|
1586
|
-
`)}}],provideTokens:
|
|
1572
|
+
`,provideTokens:ae(["Import","Snippet","Endpoint"])}}function Ii(){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:s})=>{var e;(e=s.toggleToc)==null||e.call(s)}}],styles:".smdx-toc-container { /* built-in TOC panel — see toc.css */ }"}}function Bi(){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:s})=>{s.insertText(`<br/>
|
|
1573
|
+
`)}}],provideTokens:ae(["br"])}}function Di(){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:s})=>{s.insertBlock("---")}}],provideTokens:s=>{const e=[];return(/^-{3,}\s*$/.test(s)||/^\*{3,}\s*$/.test(s)||/^_{3,}\s*$/.test(s))&&e.push({cls:"kw",start:0,end:s.trimEnd().length}),e}}}function Ps(){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:s})=>{s.undo()},isDisabled:()=>!1}]}}function Os(){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:s})=>{s.redo()},isDisabled:()=>!1}]}}function Pi(){return[Ps(),Os(),Xt(),Jt(),Zt(),Qt(),ei(),ti(),ii(),ni(),ai(),si(),ri(),oi(),li(),di(),ci(),hi(),pi(),gi(),mi(),fi(),bi(),yi(),ki(),_i(),vi(),Ci(),Ti(),Ei(),Si(),Ri(),Mi(),Li(),Ai(),Ii(),Bi(),Di()]}function Oi(){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 Hs{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 Hi(s){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=`#${s}-textarea`,t.textContent="Skip to editor";const i=document.createElement("div");i.className="smdx-toolbar-container";const n=document.createElement("div");n.className="smdx-main";const a=document.createElement("div");return e.appendChild(t),e.appendChild(i),e.appendChild(n),e.appendChild(a),{root:e,skipLink:t,toolbarSlot:i,main:n,statusBarSlot:a}}function ji(s){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 n=document.createElement("textarea");return n.className="smdx-textarea",n.id=`${s}-textarea`,n.setAttribute("aria-label","Markdown input"),n.setAttribute("aria-multiline","true"),n.spellcheck=!1,t.appendChild(i),t.appendChild(n),e.appendChild(t),{pane:e,scrollWrapper:t,gutter:i,textarea:n}}function Ni(s){const e=document.createElement("div");e.className="smdx-preview-pane",e.id=`${s}-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 Wi(s={}){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 n=document.createElement("span");n.className="smdx-char-count";const a=document.createElement("div");return a.className="smdx-mode-switch",s.showWordCount!==!1&&e.appendChild(t),s.showLineCount!==!1&&e.appendChild(i),e.appendChild(n),s.showModeSwitcher!==!1&&e.appendChild(a),{bar:e,wordCount:t,lineCount:i,charCount:n,modeSwitcher:a}}class Fi{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 zi{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 qi{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 n=document.createElement("button");n.className="smdx-mode-btn",n.type="button",n.textContent=t[i],n.dataset.mode=i,n.addEventListener("click",()=>this.opts.onModeChange(i)),this.opts.modeSwitcher.appendChild(n)}}updateCounts(e){const t=e.trim()?e.trim().split(/\s+/).length:0,i=e.split(`
|
|
1587
1574
|
`).length,n=e.length;this.opts.wordCount.textContent=`${t} words`,this.opts.lineCount.textContent=`${i} lines`,this.opts.charCount.textContent=`${n} chars`}updateActiveMode(e){this.opts.modeSwitcher.querySelectorAll(".smdx-mode-btn").forEach(t=>{t.classList.toggle("smdx-active",t.dataset.mode===e)})}}const G=class G{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,n=parseFloat(e.paddingTop)||16,a=this.textarea.clientWidth-t-i;if(a<=0)return null;const r=parseFloat(e.lineHeight)||27.2;this.paddingTop=n,this.contentWidth=a,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:a+"px"});try{const c=document.createElement("canvas").getContext("2d");if(c){c.font=`${e.fontSize} ${e.fontFamily}`;const d="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _.,;:()[]{}";this.avgCharWidth=c.measureText(d).width/d.length||8.4}}catch{}return{lineHeightPx:r,contentWidth:a}}rowCount(e,t){return!e||e.length*this.avgCharWidth<this.contentWidth*G.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,n=parseFloat(t.paddingRight)||0,a=this.textarea.clientWidth-i-n;if(a>0&&Math.abs(a-this.cachedContentWidth)>G.WIDTH_CHANGE_THRESHOLD_PX){this.cachedContentWidth=a,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(`
|
|
1588
1575
|
`),t=e.length;this.lineCount=t;const i=t>G.LARGE_DOC_THRESHOLD,n=this.syncMirror();if(n){this.rafPending=!1;const{lineHeightPx:r}=n;this.cachedContentWidth=this.contentWidth;const o=new Float32Array(t+1),c=new Float32Array(t);let d=0;if(i){const l=this.contentWidth,h=this.avgCharWidth;for(let p=0;p<t;p++){o[p]=d;const m=e[p].length*h,w=(l>0?Math.max(1,Math.ceil(m/l)):1)*r;c[p]=w,d+=w}this.deferredUpdateTimer&&clearTimeout(this.deferredUpdateTimer),this.deferredUpdateTimer=setTimeout(()=>{this.deferredUpdateTimer=null,this.enabled&&this.refineLargeDoc(e,r)},G.DEFERRED_UPDATE_DELAY_MS)}else for(let l=0;l<t;l++){o[l]=d;const p=this.rowCount(e[l],r)*r;c[l]=p,d+=p}o[t]=d,this.offsets=o,this.heights=c,this.totalHeight=d}else{!this.rafPending&&typeof requestAnimationFrame<"u"&&(this.rafPending=!0,requestAnimationFrame(()=>{this.rafPending=!1,this.enabled&&this.update()}));const r=this.lineHeightPx,o=new Float32Array(t+1),c=new Float32Array(t).fill(r);for(let d=0;d<=t;d++)o[d]=d*r;this.offsets=o,this.heights=c,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 a=this.scrollEl||this.textarea;this.cachedClientHeight=a.clientHeight,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible()}refineLargeDoc(e,t){const i=e.length,n=this.contentWidth,a=this.avgCharWidth,r=n*G.WRAP_THRESHOLD;let o=!1;const c=new Float32Array(i+1),d=new Float32Array(i);let l=0;for(let h=0;h<i;h++){c[h]=l;const u=e[h].length*a;let m;u>=r&&this.mirror?m=this.rowCount(e[h],t):m=n>0?Math.max(1,Math.ceil(u/n)):1;const g=m*t;Math.abs(g-this.heights[h])>.5&&(o=!0),d[h]=g,l+=g}c[i]=l,o&&(this.offsets=c,this.heights=d,this.totalHeight=l,this.poolStart=-1,this.poolEnd=-1,this.inner.style.height=this.totalHeight+this.paddingTop+"px",this.renderVisible())}autoResizeTextarea(){var o;const e=this.textarea,t=this.scrollEl,i=t?t.clientHeight:((o=e.parentElement)==null?void 0:o.clientHeight)||200,n=parseFloat(e.style.height)||0;if(n>0&&n>=i&&e.scrollHeight<=n+2)return;e.style.height="1px";const a=e.scrollHeight,r=Math.max(a,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,n=Math.max(0,e-i),a=e-i+t,r=Math.max(0,this.lineIndexAtOffset(n)-this.OVERSCAN),o=Math.min(this.lineCount-1,this.lineIndexAtOffset(a)+this.OVERSCAN);if(r===this.poolStart&&o===this.poolEnd)return;this.poolStart=r,this.poolEnd=o;const c=this.lineCount>0?o-r+1:0,d=this.lineHeightPx;for(;this.spanPool.length<c;){const l=document.createElement("span");l.className="smdx-line-num",l.style.position="absolute",l.style.left="0",l.style.right="0",this.inner.appendChild(l),this.spanPool.push(l)}for(let l=0;l<c;l++){const h=r+l,p=this.spanPool[l],m=this.offsets[h]+i+"px";p.style.top!==m&&(p.style.top=m);const g=d+"px";p.style.height!==g&&(p.style.height=g,p.style.lineHeight=g);const w=String(h+1);p.textContent!==w&&(p.textContent=w),p.style.visibility!==""&&(p.style.visibility="")}for(let l=c;l<this.spanPool.length;l++)this.spanPool[l].style.visibility!=="hidden"&&(this.spanPool[l].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 n=0,a=t-1;for(;n<a;){const r=n+a+1>>1;i[r]<=e?n=r:a=r-1}return n}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,n=this.textarea.value.substring(0,t).split(`
|
|
1589
|
-
`).length-1,a=this.lineHeightPx,r=this.paddingTop,o=(n<this.lineCount?this.offsets[n]:this.totalHeight)+r,c=o+a,d=e.scrollTop,l=d+e.clientHeight;c>l?e.scrollTop=c-e.clientHeight:o<d&&(e.scrollTop=Math.max(0,o))}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()}};G.WRAP_THRESHOLD=.85,G.LARGE_DOC_THRESHOLD=500,G.DEFERRED_UPDATE_DELAY_MS=50,G.WIDTH_CHANGE_THRESHOLD_PX=1;let
|
|
1576
|
+
`).length-1,a=this.lineHeightPx,r=this.paddingTop,o=(n<this.lineCount?this.offsets[n]:this.totalHeight)+r,c=o+a,d=e.scrollTop,l=d+e.clientHeight;c>l?e.scrollTop=c-e.clientHeight:o<d&&(e.scrollTop=Math.max(0,o))}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()}};G.WRAP_THRESHOLD=.85,G.LARGE_DOC_THRESHOLD=500,G.DEFERRED_UPDATE_DELAY_MS=50,G.WIDTH_CHANGE_THRESHOLD_PX=1;let Ke=G;class Ui{constructor(e,t=150){this.renderTimer=null,this.contentEl=e,this.delay=t,this.renderer=new we}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 n=i.getAttribute("data-text")||"";try{await navigator.clipboard.writeText(n),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 a;const n=(a=i.closest(".smdx-code-block"))==null?void 0:a.querySelector("pre code");if(n)try{await navigator.clipboard.writeText(n.textContent||""),i.classList.add("smdx-copied"),setTimeout(()=>i.classList.remove("smdx-copied"),2e3)}catch{}})})}destroy(){this.renderTimer&&clearTimeout(this.renderTimer)}}const pe=class pe{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<=pe.MOBILE_BREAKPOINT,i=!t&&e<=pe.TABLET_BREAKPOINT;this.root.classList.toggle("smdx-is-mobile",t),this.root.classList.toggle("smdx-is-tablet",i)}};pe.MOBILE_BREAKPOINT=640,pe.TABLET_BREAKPOINT=1024;let bt=pe;class js{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:n,toolbarSlot:a,main:r,statusBarSlot:o}=Hi(this.editorId),{pane:c,scrollWrapper:d,gutter:l,textarea:h}=ji(this.editorId),{pane:p,content:u}=Ni(this.editorId),{bar:m,wordCount:g,lineCount:w,charCount:k,modeSwitcher:C}=Wi();r.appendChild(c),r.appendChild(p),o.replaceWith(m),e.appendChild(n),this.elements={root:n,toolbarEl:a,editorPane:c,previewPane:p,textarea:h,previewContent:u,statusBar:m},this.modeController=new Fi(n,this.config.mode??"split"),this.themeController=new zi(n),this.lineNumberController=new Ke(l,h),this.lineNumberController.setScrollElement(d),this.previewController=new Ui(u),this.statusBarController=new qi({bar:m,wordCount:g,lineCount:w,charCount:k,modeSwitcher:C,onModeChange:f=>i.setMode(f)}),this.statusBarController.updateActiveMode(this.config.mode??"split"),this.config.theme&&this.themeController.applyTheme(this.config.theme);const y=this.config.toolbar||[];return y.length>0&&(this.toolbar=new Qe(y,t,i,this.events),this.toolbar.render(a)),this.responsiveController=new bt(n),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 Ns{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,n;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",(n=t.querySelector(".smdx-toolbar-dropdown-trigger"))==null||n.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 Ws=[{label:"Accordion",kind:"tag",detail:"Expandable section",insertText:`<Accordion title="Title">
|
|
1590
1577
|
Content
|
|
1591
1578
|
</Accordion>`},{label:"AccordionGroup",kind:"tag",detail:"Group of accordions",insertText:`<AccordionGroup>
|
|
1592
1579
|
<Accordion title="Section 1">
|
|
@@ -1630,7 +1617,7 @@ Tip message
|
|
|
1630
1617
|
Warning message
|
|
1631
1618
|
</TipBad>`},{label:"TipInfo",kind:"tag",detail:"Info tip callout",insertText:`<TipInfo>
|
|
1632
1619
|
Info message
|
|
1633
|
-
</TipInfo>`},{label:"Tooltip",kind:"tag",detail:"Hover tooltip",insertText:'<Tooltip tip="Tooltip text">hover text</Tooltip>'}],
|
|
1620
|
+
</TipInfo>`},{label:"Tooltip",kind:"tag",detail:"Hover tooltip",insertText:'<Tooltip tip="Tooltip text">hover text</Tooltip>'}],Fs=[{label:"# Heading 1",kind:"md",detail:"H1 heading",insertText:"# "},{label:"## Heading 2",kind:"md",detail:"H2 heading",insertText:"## "},{label:"### Heading 3",kind:"md",detail:"H3 heading",insertText:"### "},{label:"#### Heading 4",kind:"md",detail:"H4 heading",insertText:"#### "},{label:"**bold**",kind:"md",detail:"Bold text",insertText:"**bold**"},{label:"*italic*",kind:"md",detail:"Italic text",insertText:"*italic*"},{label:"~~strike~~",kind:"md",detail:"Strikethrough",insertText:"~~text~~"},{label:"`inline code`",kind:"md",detail:"Inline code",insertText:"`code`"},{label:"```code block```",kind:"md",detail:"Code block",insertText:"```\ncode\n```"},{label:"> blockquote",kind:"md",detail:"Blockquote",insertText:"> "},{label:"- list item",kind:"md",detail:"Unordered list",insertText:"- "},{label:"1. ordered item",kind:"md",detail:"Ordered list",insertText:"1. "},{label:"- [ ] task",kind:"md",detail:"Task list item",insertText:"- [ ] "},{label:"[link](url)",kind:"md",detail:"Hyperlink",insertText:"[text](url)"},{label:"",kind:"md",detail:"Image",insertText:""},{label:"---",kind:"md",detail:"Horizontal rule",insertText:`---
|
|
1634
1621
|
`},{label:"| Table |",kind:"md",detail:"Table",insertText:`| Column 1 | Column 2 |
|
|
1635
1622
|
|----------|----------|
|
|
1636
1623
|
| Cell 1 | Cell 2 |`},{label:":::tip",kind:"md",detail:"Tip admonition",insertText:`:::tip
|
|
@@ -1645,7 +1632,7 @@ Danger content
|
|
|
1645
1632
|
Note content
|
|
1646
1633
|
:::`},{label:"$formula$",kind:"md",detail:"Inline math",insertText:"$E = mc^2$"},{label:"$$block math$$",kind:"md",detail:"Math block",insertText:`$$
|
|
1647
1634
|
E = mc^2
|
|
1648
|
-
$$`},{label:"```mermaid",kind:"md",detail:"Mermaid diagram",insertText:"```mermaid\ngraph TD\n A --> B\n```"}],
|
|
1635
|
+
$$`},{label:"```mermaid",kind:"md",detail:"Mermaid diagram",insertText:"```mermaid\ngraph TD\n A --> B\n```"}],zs=[{label:"<div>",kind:"html",detail:"Division",insertText:`<div>
|
|
1649
1636
|
|
|
1650
1637
|
</div>`},{label:"<span>",kind:"html",detail:"Inline span",insertText:"<span></span>"},{label:"<p>",kind:"html",detail:"Paragraph",insertText:`<p>
|
|
1651
1638
|
|
|
@@ -1667,9 +1654,9 @@ Content
|
|
|
1667
1654
|
|
|
1668
1655
|
</blockquote>`},{label:"<section>",kind:"html",detail:"Section",insertText:`<section>
|
|
1669
1656
|
|
|
1670
|
-
</section>`}],
|
|
1671
|
-
`,e-1)+1,n=t.substring(i,e);let a=n.length;for(;a>0&&
|
|
1672
|
-
`,t-1)+1,a=t-n,r=getComputedStyle(this.textarea),o=parseFloat(r.lineHeight)||22,d=(parseFloat(r.fontSize)||14)*
|
|
1673
|
-
`).length,p=this.textarea.getBoundingClientRect(),u=((C=this.textarea.parentElement)==null?void 0:C.scrollTop)||0,m=p.left-e.left+a*d+16,g=p.top-e.top+h*o-u+4,w=this.items.length*30+8,k=g+w>e.height-16;this.popup.style.left=Math.min(m,e.width-360)+"px",this.popup.style.top=(k?Math.max(0,g-o-w):g)+"px"}destroy(){this.popup.remove()}}const
|
|
1674
|
-
`)&&(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 o=this.caseSensitive?"g":"gi";i=new RegExp(r,o)}}catch{this.countLabel.textContent="Invalid regex";return}let n,a=0;for(;(n=i.exec(t))!==null&&a<
|
|
1675
|
-
`).length,n=parseFloat(getComputedStyle(this.textarea).lineHeight)||22,a=(i-1)*n-t.clientHeight/3;t.scrollTop=Math.max(0,a)}}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="",n=0;for(const a of this.matches)i+=t.substring(n,a.start)+e,n=a.end;i+=t.substring(n),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
|
|
1657
|
+
</section>`}],Gi=[...Ws,...Fs,...zs],qs=new Set(Gi.map(s=>s.label.toLowerCase())),Us={tag:"⚛",md:"M",html:"<>",var:"·",snippet:"{}"};function Vi(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Gs=/[\w</.:#*\-$![\]>(){}~|`@]/,Vs=.6;class Ks{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 n=i.target.closest(".smdx-ac-item");n&&n.dataset.i&&(this.selected=parseInt(n.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(`
|
|
1658
|
+
`,e-1)+1,n=t.substring(i,e);let a=n.length;for(;a>0&&Gs.test(n[a-1]);)a--;const r=n.substring(a);if(r.length<1){this.hide();return}this.prefix=r,this.startPos=i+a;const o=r.startsWith("<")?r.substring(1):r;if(o.length<1){this.hide();return}const c=o.toLowerCase(),d=new Set,h=t.match(/[a-zA-Z_$][\w$]*/g);if(h)for(const g of h)g!==o&&g.length>2&&d.add(g);const p=[...d].filter(g=>g.toLowerCase().startsWith(c)&&!qs.has(g.toLowerCase())).slice(0,8).map(g=>({label:g,kind:"var",detail:"in document"})),m=[...Gi,...this.extraItems].filter(g=>g.label.toLowerCase().includes(c)&&g.label.toLowerCase()!==c).concat(p).slice(0,14);if(!m.length){this.hide();return}this.items=m,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,n=this.textarea.selectionStart;this.textarea.value=t.substring(0,this.startPos)+i+t.substring(n);const a=this.startPos+i.length;this.textarea.selectionStart=this.textarea.selectionEnd=a,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}">${Us[t.kind]||"·"}</span><span class="smdx-ac-label">${Vi(t.label)}</span><span class="smdx-ac-detail">${Vi(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 C;const e=this.editorRoot.getBoundingClientRect(),t=this.textarea.selectionStart,i=this.textarea.value,n=i.lastIndexOf(`
|
|
1659
|
+
`,t-1)+1,a=t-n,r=getComputedStyle(this.textarea),o=parseFloat(r.lineHeight)||22,d=(parseFloat(r.fontSize)||14)*Vs,h=i.substring(0,t).split(`
|
|
1660
|
+
`).length,p=this.textarea.getBoundingClientRect(),u=((C=this.textarea.parentElement)==null?void 0:C.scrollTop)||0,m=p.left-e.left+a*d+16,g=p.top-e.top+h*o-u+4,w=this.items.length*30+8,k=g+w>e.height-16;this.popup.style.left=Math.min(m,e.width-360)+"px",this.popup.style.top=(k?Math.max(0,g-o-w):g)+"px"}destroy(){this.popup.remove()}}const Ys=1e4;class Xs{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 n=this.createActionBtn("❮","Previous match"),a=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(n),i.appendChild(a),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 o=this.createActionBtn("Replace","Replace current");o.classList.add("smdx-find-action-text");const c=this.createActionBtn("All","Replace all");c.classList.add("smdx-find-action-text"),this.replaceRow.appendChild(this.replaceInput),this.replaceRow.appendChild(o),this.replaceRow.appendChild(c),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()}),n.addEventListener("click",()=>this.prev()),a.addEventListener("click",()=>this.next()),r.addEventListener("click",()=>this.close()),o.addEventListener("click",()=>this.replaceCurrent()),c.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(`
|
|
1661
|
+
`)&&(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 o=this.caseSensitive?"g":"gi";i=new RegExp(r,o)}}catch{this.countLabel.textContent="Invalid regex";return}let n,a=0;for(;(n=i.exec(t))!==null&&a<Ys;){if(a++,n[0].length===0){i.lastIndex++;continue}this.matches.push({start:n.index,end:n.index+n[0].length})}if(this.matches.length>0){const r=this.textarea.selectionStart;this.currentMatch=this.matches.findIndex(o=>o.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(`
|
|
1662
|
+
`).length,n=parseFloat(getComputedStyle(this.textarea).lineHeight)||22,a=(i-1)*n-t.clientHeight/3;t.scrollTop=Math.max(0,a)}}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="",n=0;for(const a of this.matches)i+=t.substring(n,a.start)+e,n=a.end;i+=t.substring(n),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 Js="split",Zs="Start writing markdown...",Qs={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}},er={splitterPosition:50,minEditorWidth:200,minPreviewWidth:200,resizableSplitter:!0};function tr(s){return{container:s.container,value:s.value??"",plugins:s.plugins??[],toolbar:s.toolbar,theme:s.theme,mode:s.mode??Js,placeholder:s.placeholder??Zs,readOnly:s.readOnly??!1,locale:s.locale,onChange:s.onChange}}function ir(s){if(!s.container)throw new Error("[SynclineMDX] Container is required");return tr(s)}function nr(){const s=document.createElement("div");s.className="smdx-toolbar-container";const e=document.createElement("div");return e.className="smdx-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label","Editor toolbar"),s.appendChild(e),{container:s,toolbar:e}}function ar(s){const e=document.createElement("a");return e.className="smdx-skip-link",e.href=`#${s}`,e.textContent="Skip to editor",e}function sr(s){return new Yt({plugins:Pi(),toolbar:Oi(),placeholder:"Start writing markdown...",mode:"split",...s})}v.AutocompleteController=Ks,v.CodeRenderer=_t,v.DEFAULT_FEATURES=Qs,v.DEFAULT_LAYOUT=er,v.DropdownController=Ns,v.EventEmitter=xt,v.FindReplaceController=Xs,v.History=$s,v.LineNumberController=Ke,v.ListRenderer=Ct,v.MarkdownRenderer=Tt,v.MdxValidator=Et,v.ModeController=Fi,v.PluginContextClass=Hs,v.PluginManager=Je,v.PluginManagerNew=Je,v.PreviewController=Ui,v.Renderer=we,v.RendererPipeline=we,v.SplitterController=_e,v.StatusBarController=qi,v.SynclineMDXEditor=Yt,v.TableRenderer=vt,v.ThemeController=zi,v.Toolbar=Qe,v.UIController=js,v.accordionGroupPlugin=mi,v.accordionPlugin=gi,v.admonitionPlugin=di,v.allPlugins=Pi,v.boldPlugin=Jt,v.breakLinePlugin=Bi,v.buildInsertTemplate=Ms,v.cardGroupPlugin=yi,v.cardPlugin=bi,v.codePlugin=ni,v.componentTagTokens=ae,v.composeTokenProviders=kt,v.containerPlugin=vi,v.copyTextPlugin=Ci,v.createEditor=sr,v.createEditorPane=ji,v.createEditorRoot=Hi,v.createPreviewPane=Ni,v.createSkipLink=ar,v.createStatusBar=Wi,v.createToolbarDOM=nr,v.defaultToolbar=Oi,v.defineComponent=N,v.embedOthersPlugin=Si,v.embedVideoPlugin=Ei,v.emojiPlugin=Mi,v.formulaPlugin=Li,v.headingPlugin=Xt,v.highlightPlugin=li,v.horizontalRulePlugin=Di,v.icons=A,v.imageBackgroundPlugin=hi,v.imageFramePlugin=pi,v.imagePlugin=ii,v.insertPlugin=Ai,v.italicPlugin=Zt,v.linkPlugin=ti,v.mdxBaseTokens=Ki,v.mermaidPlugin=Ri,v.multiColumnPlugin=fi,v.orderedListPlugin=si,v.parseInnerComponents=Ge,v.quotePlugin=ei,v.resolveConfig=ir,v.stepPlugin=ki,v.strikethroughPlugin=Qt,v.tabPlugin=ci,v.tablePlugin=oi,v.taskListPlugin=ri,v.tipPlugin=_i,v.tocPlugin=Ii,v.tooltipPlugin=Ti,v.unorderedListPlugin=ai,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|