import{g1 as j,fT as x,g2 as B,fJ as N,fK as P,fL as F,fM as L,g8 as V,fN as M,fO as _,fP as S,fQ as R,fR as G,fS as Z,g9 as J,fU as c,ga as z,fZ as H,f_ as Q}from"./index-C6OVXshM.js";const X=[c("function ${name}(${params}) {\n	${}\n}",{label:"function",detail:"definition",type:"keyword"}),c("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n	${}\n}",{label:"for",detail:"loop",type:"keyword"}),c("for (let ${name} of ${collection}) {\n	${}\n}",{label:"for",detail:"of loop",type:"keyword"}),c("do {\n	${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),c("while (${}) {\n	${}\n}",{label:"while",detail:"loop",type:"keyword"}),c(`try {
	\${}
} catch (\${error}) {
	\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),c("if (${}) {\n	${}\n}",{label:"if",detail:"block",type:"keyword"}),c(`if (\${}) {
	\${}
} else {
	\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),c(`class \${name} {
	constructor(\${params}) {
		\${}
	}
}`,{label:"class",detail:"definition",type:"keyword"}),c('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),c('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],U=X.concat([c("interface ${name} {\n	${}\n}",{label:"interface",detail:"definition",type:"keyword"}),c("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),c("enum ${name} {\n	${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),k=new H,A=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function g(e){return(n,a)=>{let t=n.node.getChild("VariableDefinition");return t&&a(t,e),!0}}const q=["FunctionDeclaration"],K={FunctionDeclaration:g("function"),ClassDeclaration:g("class"),ClassExpression:()=>!0,EnumDeclaration:g("constant"),TypeAliasDeclaration:g("type"),NamespaceDeclaration:g("namespace"),VariableDefinition(e,n){e.matchContext(q)||n(e,"variable")},TypeDefinition(e,n){n(e,"type")},__proto__:null};function D(e,n){let a=k.get(n);if(a)return a;let t=[],r=!0;function i(o,l){let f=e.sliceString(o.from,o.to);t.push({label:f,type:l})}return n.cursor(Q.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=K[o.name];if(l&&l(o,i)||A.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of D(e,o.node))t.push(l);return!1}}),k.set(n,t),t}const b=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,w=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function W(e){let n=x(e.state).resolveInner(e.pos,-1);if(w.indexOf(n.name)>-1)return null;let a=n.name=="VariableName"||n.to-n.from<20&&b.test(e.state.sliceDoc(n.from,n.to));if(!a&&!e.explicit)return null;let t=[];for(let r=n;r;r=r.parent)A.has(r.name)&&(t=t.concat(D(e.state.doc,r)));return{options:t,from:a?n.from:e.pos,validFor:b}}function $(e,n,a){var t;let r=[];for(;;){let i=n.firstChild,o;if((i==null?void 0:i.name)=="VariableName")return r.push(e(i)),{path:r.reverse(),name:a};if((i==null?void 0:i.name)=="MemberExpression"&&((t=o=i.lastChild)===null||t===void 0?void 0:t.name)=="PropertyName")r.push(e(o)),n=i;else return null}}function Y(e){let n=t=>e.state.doc.sliceString(t.from,t.to),a=x(e.state).resolveInner(e.pos,-1);return a.name=="PropertyName"?$(n,a.parent,n(a)):(a.name=="."||a.name=="?.")&&a.parent.name=="MemberExpression"?$(n,a.parent,""):w.indexOf(a.name)>-1?null:a.name=="VariableName"||a.to-a.from<20&&b.test(n(a))?{path:[],name:n(a)}:a.name=="MemberExpression"?$(n,a,""):e.explicit?{path:[],name:""}:null}function ee(e,n){let a=[],t=new Set;for(let r=0;;r++){for(let o of(Object.getOwnPropertyNames||Object.keys)(e)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(o)||t.has(o))continue;t.add(o);let l;try{l=e[o]}catch{continue}a.push({label:o,type:typeof l=="function"?/^[A-Z]/.test(o)?"class":n?"function":"method":n?"variable":"property",boost:-r})}let i=Object.getPrototypeOf(e);if(!i)return a;e=i}}function fe(e){let n=new Map;return a=>{let t=Y(a);if(!t)return null;let r=e;for(let o of t.path)if(r=r[o],!r)return null;let i=n.get(r);return i||n.set(r,i=ee(r,!t.path.length)),{from:a.pos-t.name.length,options:i,validFor:b}}}const u=L.define({name:"javascript",parser:V.configure({props:[M.add({IfStatement:S({except:/^\s*({|else\b)/}),TryStatement:S({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:_,SwitchBody:e=>{let n=e.textAfter,a=/^\s*\}/.test(n),t=/^\s*(case|default)\b/.test(n);return e.baseIndent+(a?0:t?1:2)*e.unit},Block:R({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":S({except:/^\s*{/}),JSXElement(e){let n=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(n?0:e.unit)},JSXEscape(e){let n=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(n?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),G.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Z,BlockComment(e){return{from:e.from+2,to:e.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),E={test:e=>/^JSX/.test(e.name),facet:z({commentTokens:{block:{open:"{/*",close:"*/}"}}})},te=u.configure({dialect:"ts"},"typescript"),ne=u.configure({dialect:"jsx",props:[J.add(e=>e.isTop?[E]:void 0)]}),ae=u.configure({dialect:"jsx ts",props:[J.add(e=>e.isTop?[E]:void 0)]},"typescript");let O=e=>({label:e,type:"keyword"});const I="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(O),re=I.concat(["declare","implements","private","protected","public"].map(O));function pe(e={}){let n=e.jsx?e.typescript?ae:ne:e.typescript?te:u,a=e.typescript?U.concat(re):X.concat(I);return new N(n,[u.data.of({autocomplete:P(w,F(a))}),u.data.of({autocomplete:W}),e.jsx?le:[]])}function oe(e){for(;;){if(e.name=="JSXOpenTag"||e.name=="JSXSelfClosingTag"||e.name=="JSXFragmentTag")return e;if(e.name=="JSXEscape"||!e.parent)return null;e=e.parent}}function T(e,n,a=e.length){for(let t=n==null?void 0:n.firstChild;t;t=t.nextSibling)if(t.name=="JSXIdentifier"||t.name=="JSXBuiltin"||t.name=="JSXNamespacedName"||t.name=="JSXMemberExpression")return e.sliceString(t.from,Math.min(t.to,a));return""}const ie=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),le=j.inputHandler.of((e,n,a,t,r)=>{if((ie?e.composing:e.compositionStarted)||e.state.readOnly||n!=a||t!=">"&&t!="/"||!u.isActiveAt(e.state,n,-1))return!1;let i=r(),{state:o}=i,l=o.changeByRange(f=>{var m;let{head:s}=f,p=x(o).resolveInner(s-1,-1),y;if(p.name=="JSXStartTag"&&(p=p.parent),!(o.doc.sliceString(s-1,s)!=t||p.name=="JSXAttributeValue"&&p.to>s)){if(t==">"&&p.name=="JSXFragmentTag")return{range:f,changes:{from:s,insert:"</>"}};if(t=="/"&&p.name=="JSXStartCloseTag"){let d=p.parent,h=d.parent;if(h&&d.from==s-2&&((y=T(o.doc,h.firstChild,s))||((m=h.firstChild)===null||m===void 0?void 0:m.name)=="JSXFragmentTag")){let v=`${y}>`;return{range:B.cursor(s+v.length,-1),changes:{from:s,insert:v}}}}else if(t==">"){let d=oe(p);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(s,s+2))&&(y=T(o.doc,d,s)))return{range:f,changes:{from:s,insert:`</${y}>`}}}}return{range:f}});return l.changes.empty?!1:(e.dispatch([i,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function ue(e,n){return n||(n={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},e.getRules().forEach((a,t)=>{var r;!((r=a.meta.docs)===null||r===void 0)&&r.recommended&&(n.rules[t]=2)})),a=>{let{state:t}=a,r=[];for(let{from:i,to:o}of u.findRegions(t)){let l=t.doc.lineAt(i),f={line:l.number-1,col:i-l.from,pos:i};for(let m of e.verify(t.sliceDoc(i,o),n))r.push(se(m,t.doc,f))}return r}}function C(e,n,a,t){return a.line(e+t.line).from+n+(e==1?t.col-1:-1)}function se(e,n,a){let t=C(e.line,e.column,n,a),r={from:t,to:e.endLine!=null&&e.endColumn!=1?C(e.endLine,e.endColumn,n,a):t,message:e.message,source:e.ruleId?"eslint:"+e.ruleId:"eslint",severity:e.severity==1?"warning":"error"};if(e.fix){let{range:i,text:o}=e.fix,l=i[0]+a.pos-t,f=i[1]+a.pos-t;r.actions=[{name:"fix",apply(m,s){m.dispatch({changes:{from:s+l,to:s+f,insert:o},scrollIntoView:!0})}}]}return r}export{le as autoCloseTags,Y as completionPath,ue as esLint,pe as javascript,u as javascriptLanguage,ne as jsxLanguage,W as localCompletionSource,fe as scopeCompletionSource,X as snippets,ae as tsxLanguage,te as typescriptLanguage,U as typescriptSnippets};
