/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{parser as e}from"../../../@lezer/python/dist/index.js";import{LanguageSupport as r,LRLanguage as t,indentNodeProp as n,delimitedIndent as o,foldNodeProp as i,foldInside as a,syntaxTree as s}from"../../language/dist/index.js";import{NodeWeakMap as l,IterMode as m}from"../../../@lezer/common/dist/index.js";import{ifNotIn as c,completeFromList as d,snippetCompletion as p}from"../../autocomplete/dist/index.js";const f=/* @__PURE__ */new l,u=/* @__PURE__ */new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function E(e){return(r,t,n)=>{if(n)return!1;let o=r.node.getChild("VariableName");return o&&t(o,e),!0}}const b={FunctionDefinition:/* @__PURE__ */E("function"),ClassDefinition:/* @__PURE__ */E("class"),ForStatement(e,r,t){if(t)for(let n=e.node.firstChild;n;n=n.nextSibling)if("VariableName"==n.name)r(n,"variable");else if("in"==n.name)break},ImportStatement(e,r){var t,n;let{node:o}=e,i="from"==(null===(t=o.firstChild)||void 0===t?void 0:t.name);for(let a=o.getChild("import");a;a=a.nextSibling)"VariableName"==a.name&&"as"!=(null===(n=a.nextSibling)||void 0===n?void 0:n.name)&&r(a,i?"variable":"namespace")},AssignStatement(e,r){for(let t=e.node.firstChild;t;t=t.nextSibling)if("VariableName"==t.name)r(t,"variable");else if(":"==t.name||"AssignOp"==t.name)break},ParamList(e,r){for(let t=null,n=e.node.firstChild;n;n=n.nextSibling)"VariableName"!=n.name||t&&/\*|AssignOp/.test(t.name)||r(n,"variable"),t=n},CapturePattern:/* @__PURE__ */E("variable"),AsPattern:/* @__PURE__ */E("variable"),__proto__:null};function y(e,r){let t=f.get(r);if(t)return t;let n=[],o=!0;function i(r,t){let o=e.sliceString(r.from,r.to);n.push({label:o,type:t})}return r.cursor(m.IncludeAnonymous).iterate(r=>{if(r.name){let e=b[r.name];if(e&&e(r,i,o)||!o&&u.has(r.name))return!1;o=!1}else if(r.to-r.from>8192){for(let t of y(e,r.node))n.push(t);return!1}}),f.set(r,n),n}const x=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,g=["String","FormatString","Comment","PropertyName"];function _(e){let r=s(e.state).resolveInner(e.pos,-1);if(g.indexOf(r.name)>-1)return null;let t="VariableName"==r.name||r.to-r.from<20&&x.test(e.state.sliceDoc(r.from,r.to));if(!t&&!e.explicit)return null;let n=[];for(let o=r;o;o=o.parent)u.has(o.name)&&(n=n.concat(y(e.state.doc,o)));return{options:n,from:t?r.from:e.pos,validFor:x}}const h=/* @__PURE__ */["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(e=>({label:e,type:"constant"})).concat(/* @__PURE__ */["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(e=>({label:e,type:"type"}))).concat(/* @__PURE__ */["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(e=>({label:e,type:"class"}))).concat(/* @__PURE__ */["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(e=>({label:e,type:"function"}))),S=[
/* @__PURE__ */p("def ${name}(${params}):\n\t${}",{label:"def",detail:"function",type:"keyword"}),
/* @__PURE__ */p("for ${name} in ${collection}:\n\t${}",{label:"for",detail:"loop",type:"keyword"}),
/* @__PURE__ */p("while ${}:\n\t${}",{label:"while",detail:"loop",type:"keyword"}),
/* @__PURE__ */p("try:\n\t${}\nexcept ${error}:\n\t${}",{label:"try",detail:"/ except block",type:"keyword"}),
/* @__PURE__ */p("if ${}:\n\t\n",{label:"if",detail:"block",type:"keyword"}),
/* @__PURE__ */p("if ${}:\n\t${}\nelse:\n\t${}",{label:"if",detail:"/ else block",type:"keyword"}),
/* @__PURE__ */p("class ${name}:\n\tdef __init__(self, ${params}):\n\t\t\t${}",{label:"class",detail:"definition",type:"keyword"}),
/* @__PURE__ */p("import ${module}",{label:"import",detail:"statement",type:"keyword"}),
/* @__PURE__ */p("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],I=/* @__PURE__ */c(g,/* @__PURE__ */d(/* @__PURE__ */h.concat(S)));function v(e){let{node:r,pos:t}=e,n=e.lineIndent(t,-1),o=null;for(;;){let i=r.childBefore(t);if(!i)break;if("Comment"==i.name)t=i.from;else if("Body"==i.name||"MatchBody"==i.name)e.baseIndentFor(i)+e.unit<=n&&(o=i),r=i;else if("MatchClause"==i.name)r=i;else{if(!i.type.is("Statement"))break;r=i}}return o}function k(e,r){let t=e.baseIndentFor(r),n=e.lineAt(e.pos,-1),o=n.from+n.text.length;return/^\s*($|#)/.test(n.text)&&e.node.to<o+100&&!/\S/.test(e.state.sliceDoc(o,e.node.to))&&e.lineIndent(e.pos,-1)<=t||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(e.textAfter)&&e.lineIndent(e.pos,-1)>t?null:t+e.unit}const $=/* @__PURE__ */t.define({name:"python",parser:/* @__PURE__ */e.configure({props:[
/* @__PURE__ */n.add({Body:e=>{var r;return null!==(r=k(e,/^\s*(#|$)/.test(e.textAfter)&&v(e)||e.node))&&void 0!==r?r:e.continue()},MatchBody:e=>{var r;return null!==(r=k(e,v(e)||e.node))&&void 0!==r?r:e.continue()},IfStatement:e=>/^\s*(else:|elif )/.test(e.textAfter)?e.baseIndent:e.continue(),"ForStatement WhileStatement":e=>/^\s*else:/.test(e.textAfter)?e.baseIndent:e.continue(),TryStatement:e=>/^\s*(except[ :]|finally:|else:)/.test(e.textAfter)?e.baseIndent:e.continue(),MatchStatement:e=>/^\s*case /.test(e.textAfter)?e.baseIndent+e.unit:e.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":/* @__PURE__ */o({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":/* @__PURE__ */o({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":/* @__PURE__ */o({closing:"]"}),MemberExpression:e=>e.baseIndent+e.unit,"String FormatString":()=>null,Script:e=>{var r;let t=v(e);return null!==(r=t&&k(e,t))&&void 0!==r?r:e.continue()}}),
/* @__PURE__ */i.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":a,Body:(e,r)=>({from:e.from+1,to:e.to-(e.to==r.doc.length?0:1)}),"String FormatString":(e,r)=>({from:r.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function A(){return new r($,[$.data.of({autocomplete:_}),$.data.of({autocomplete:I})])}export{I as globalCompletion,_ as localCompletionSource,A as python,$ as pythonLanguage};