import{p as b}from"./vendor-lezer-go-CXK1UKk8.js";import{L as w,b as S,c as g,f as h,d as m,e as I,g as C,h as L,s as D}from"./vendor-codemirror-language-BgPj_McA.js";import{i as B,c as v,s as o}from"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import{d as N,I as F}from"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";const T=[o("func ${name}(${params}) ${type} {\n	${}\n}",{label:"func",detail:"declaration",type:"keyword"}),o("func (${receiver}) ${name}(${params}) ${type} {\n	${}\n}",{label:"func",detail:"method declaration",type:"keyword"}),o("var ${name} = ${value}",{label:"var",detail:"declaration",type:"keyword"}),o("type ${name} ${type}",{label:"type",detail:"declaration",type:"keyword"}),o("const ${name} = ${value}",{label:"const",detail:"declaration",type:"keyword"}),o("type ${name} = ${type}",{label:"type",detail:"alias declaration",type:"keyword"}),o("for ${init}; ${test}; ${update} {\n	${}\n}",{label:"for",detail:"loop",type:"keyword"}),o("for ${i} := range ${value} {\n	${}\n}",{label:"for",detail:"range",type:"keyword"}),o(`select {
	\${}
}`,{label:"select",detail:"statement",type:"keyword"}),o("case ${}:\n${}",{label:"case",type:"keyword"}),o("switch ${} {\n	${}\n}",{label:"switch",detail:"statement",type:"keyword"}),o("switch ${}.(${type}) {\n	${}\n}",{label:"switch",detail:"type statement",type:"keyword"}),o("if ${} {\n	${}\n}",{label:"if",detail:"block",type:"keyword"}),o(`if \${} {
	\${}
} else {
	\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),o('import ${name} "${module}"\n${}',{label:"import",detail:"declaration",type:"keyword"})],f=new N,u=new Set(["SourceFile","Block","FunctionDecl","MethodDecl","FunctionLiteral","ForStatement","SwitchStatement","TypeSwitchStatement","IfStatement"]);function s(e,a){return(r,l)=>{e:for(let t=r.node.firstChild,c=0,n=null;;){for(;!t;){if(!c)break e;c--,t=n.nextSibling,n=n.parent}a&&t.name==a||t.name=="SpecList"?(c++,n=t,t=t.firstChild):(t.name=="DefName"&&l(t,e),t=t.nextSibling)}return!0}}const x={FunctionDecl:s("function"),VarDecl:s("var","VarSpec"),ConstDecl:s("constant","ConstSpec"),TypeDecl:s("type","TypeSpec"),ImportDecl:s("constant","ImportSpec"),Parameter:s("var"),__proto__:null};function y(e,a){let r=f.get(a);if(r)return r;let l=[],t=!0;function c(n,i){let k=e.sliceString(n.from,n.to);l.push({label:k,type:i})}return a.cursor(F.IncludeAnonymous).iterate(n=>{if(t)t=!1;else if(n.name){let i=x[n.name];if(i&&i(n,c)||u.has(n.name))return!1}else if(n.to-n.from>8192){for(let i of y(e,n.node))l.push(i);return!1}}),f.set(a,l),l}const d=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,$=["String","LineComment","BlockComment","DefName","LabelName","FieldName",".","?."],V=e=>{let a=D(e.state).resolveInner(e.pos,-1);if($.indexOf(a.name)>-1)return null;let r=a.name=="VariableName"||a.to-a.from<20&&d.test(e.state.sliceDoc(a.from,a.to));if(!r&&!e.explicit)return null;let l=[];for(let t=a;t;t=t.parent)u.has(t.name)&&(l=l.concat(y(e.state.doc,t)));return{options:l,from:r?a.from:e.pos,validFor:d}},p=S.define({name:"go",parser:b.configure({props:[g.add({IfStatement:m({except:/^\s*({|else\b)/}),LabeledStatement:h,"SwitchBlock SelectBlock":e=>{let a=e.textAfter,r=/^\s*\}/.test(a),l=/^\s*(case|default)\b/.test(a);return e.baseIndent+(r||l?0:e.unit)},Block:I({closing:"}"}),BlockComment:()=>null,Statement:m({except:/^{/})}),C.add({"Block SwitchBlock SelectBlock LiteralValue InterfaceType StructType SpecList":L,BlockComment(e){return{from:e.from+2,to:e.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case\b|default\b|\})$/}});let _=e=>({label:e,type:"keyword"});const M="interface struct chan map package go return break continue goto fallthrough else defer range true false nil".split(" ").map(_);function K(){let e=T.concat(M);return new w(p,[p.data.of({autocomplete:B($,v(e))}),p.data.of({autocomplete:V})])}export{K as go,p as goLanguage,V as localCompletionSource,T as snippets};
