/*!
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{LanguageSupport as e,LRLanguage as t,indentNodeProp as n,continuedIndent as a,foldNodeProp as i,syntaxTree as r}from"../../language/dist/index.js";import{styleTags as o,tags as s}from"../../../@lezer/highlight/dist/index.js";import{ExternalTokenizer as l,LRParser as c}from"../../../@lezer/lr/dist/index.js";import{ifNotIn as d,completeFromList as u}from"../../autocomplete/dist/index.js";function f(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function O(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function p(e,t,n){for(let a=!1;;){if(e.next<0)return;if(e.next==t&&!a)return void e.advance();a=n&&!a&&92==e.next,e.advance()}}function m(e,t){for(;95==e.next||f(e.next);)null!=t&&(t+=String.fromCharCode(e.next)),e.advance();return t}function h(e,t){for(;48==e.next||49==e.next;)e.advance();t&&e.next==t&&e.advance()}function k(e,t){for(;;){if(46==e.next){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(69==e.next||101==e.next)for(e.advance(),43!=e.next&&45!=e.next||e.advance();e.next>=48&&e.next<=57;)e.advance()}function v(e){for(;!(e.next<0||10==e.next);)e.advance()}function Q(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}const g=" \t\r\n";function x(e,t,n){let a=/* @__PURE__ */Object.create(null);a.true=a.false=5,a.null=a.unknown=6;for(let i of e.split(" "))i&&(a[i]=20);for(let i of t.split(" "))i&&(a[i]=21);for(let i of(n||"").split(" "))i&&(a[i]=24);return a}const b={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:/* @__PURE__ */x("absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ","array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ")};function C(e){return new l(t=>{var n;let{next:a}=t;if(t.advance(),Q(a,g)){for(;Q(t.next,g);)t.advance();t.acceptToken(36)}else if(36==a&&e.doubleDollarQuotedStrings){let e=m(t,"");36==t.next&&(t.advance(),function(e,t){e:for(;;){if(e.next<0)return;if(36==e.next){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue e;e.advance()}if(36==e.next)return void e.advance()}else e.advance()}}(t,e),t.acceptToken(3))}else if(39==a||34==a&&e.doubleQuotedStrings)p(t,a,e.backslashEscapes),t.acceptToken(3);else if(35==a&&e.hashComments||47==a&&47==t.next&&e.slashComments)v(t),t.acceptToken(1);else if(45!=a||45!=t.next||e.spaceAfterDashes&&32!=t.peek(1))if(47==a&&42==t.next){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),42==n&&47==t.next){if(e--,t.advance(),!e)break}else 47==n&&42==t.next&&(e++,t.advance())}t.acceptToken(2)}else if(101!=a&&69!=a||39!=t.next)if(110!=a&&78!=a||39!=t.next||!e.charSetCasts)if(95==a&&e.charSetCasts)for(let i=0;;i++){if(39==t.next&&i>1){t.advance(),p(t,39,e.backslashEscapes),t.acceptToken(3);break}if(!f(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(113==a||81==a)&&39==t.next&&t.peek(1)>0&&!Q(t.peek(1),g)){let e=t.peek(1);t.advance(2),function(e,t){let n="[{<(".indexOf(String.fromCharCode(t)),a=n<0?t:"]}>)".charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==a&&39==e.peek(1))return void e.advance(2);e.advance()}}(t,e),t.acceptToken(3)}else if(Q(a,e.identifierQuotes)){p(t,91==a?93:a,!1),t.acceptToken(19)}else if(40==a)t.acceptToken(7);else if(41==a)t.acceptToken(8);else if(123==a)t.acceptToken(9);else if(125==a)t.acceptToken(10);else if(91==a)t.acceptToken(11);else if(93==a)t.acceptToken(12);else if(59==a)t.acceptToken(13);else if(e.unquotedBitLiterals&&48==a&&98==t.next)t.advance(),h(t),t.acceptToken(22);else if(98!=a&&66!=a||39!=t.next&&34!=t.next){if(48==a&&(120==t.next||88==t.next)||(120==a||88==a)&&39==t.next){let e=39==t.next;for(t.advance();O(t.next);)t.advance();e&&39==t.next&&t.advance(),t.acceptToken(4)}else if(46==a&&t.next>=48&&t.next<=57)k(t,!0),t.acceptToken(4);else if(46==a)t.acceptToken(14);else if(a>=48&&a<=57)k(t,!1),t.acceptToken(4);else if(Q(a,e.operatorChars)){for(;Q(t.next,e.operatorChars);)t.advance();t.acceptToken(15)}else if(Q(a,e.specialVar))t.next==a&&t.advance(),function(e){if(39==e.next||34==e.next||96==e.next){let t=e.next;e.advance(),p(e,t,!1)}else m(e)}(t),t.acceptToken(17);else if(58==a||44==a)t.acceptToken(16);else if(f(a)){let i=m(t,String.fromCharCode(a));t.acceptToken(46==t.next||46==t.peek(-i.length-1)?18:null!==(n=e.words[i.toLowerCase()])&&void 0!==n?n:18)}}else{const n=t.next;t.advance(),e.treatBitsAsBytes?(p(t,n,e.backslashEscapes),t.acceptToken(23)):(h(t,n),t.acceptToken(22))}else t.advance(),p(t,39,e.backslashEscapes),t.acceptToken(3);else t.advance(),p(t,39,!0),t.acceptToken(3);else v(t),t.acceptToken(1)})}const P=/* @__PURE__ */C(b),y=/* @__PURE__ */c.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,P],topRules:{Script:[0,25]},tokenPrec:0});function S(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function T(e,t){let n=e.sliceString(t.from,t.to),a=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return a?a[2]:n}function w(e){return e&&("Identifier"==e.name||"QuotedIdentifier"==e.name)}function U(e,t){if("CompositeIdentifier"==t.name){let n=[];for(let a=t.firstChild;a;a=a.nextSibling)w(a)&&n.push(T(e,a));return n}return[T(e,t)]}function X(e,t){for(let n=[];;){if(!t||"."!=t.name)return n;let a=S(t);if(!w(a))return n;n.unshift(T(e,a)),t=S(a)}}function _(e,t){let n=r(e).resolveInner(t,-1),a=function(e,t){let n;for(let i=t;!n;i=i.parent){if(!i)return null;"Statement"==i.name&&(n=i)}let a=null;for(let i=n.firstChild,r=!1,o=null;i;i=i.nextSibling){let t="Keyword"==i.name?e.sliceString(i.from,i.to).toLowerCase():null,n=null;if(r)if("as"==t&&o&&w(i.nextSibling))n=T(e,i.nextSibling);else{if(t&&I.has(t))break;o&&w(i)&&(n=T(e,i))}else r="from"==t;n&&(a||(a=/* @__PURE__ */Object.create(null)),a[n]=U(e,o)),o=/Identifier$/.test(i.name)?i:null}return a}(e.doc,n);return"Identifier"==n.name||"QuotedIdentifier"==n.name||"Keyword"==n.name?{from:n.from,quoted:"QuotedIdentifier"==n.name?e.doc.sliceString(n.from,n.from+1):null,parents:X(e.doc,S(n)),aliases:a}:"."==n.name?{from:t,quoted:null,parents:X(e.doc,n),aliases:a}:{from:t,quoted:null,parents:[],empty:!0,aliases:a}}const I=/* @__PURE__ */new Set(/* @__PURE__ */"where group having order union intersect except all distinct limit offset fetch for".split(" "));function j(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}const B=/^\w*$/,R=/^[`'"\[]?\w*[`'"\]]?$/;function Z(e){return e.self&&"string"==typeof e.self.label}class q{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(e){let t=this.children||(this.children=/* @__PURE__ */Object.create(null)),n=t[e];return n||(e&&!this.list.some(t=>t.label==e)&&this.list.push(z(e,"type",this.idQuote,this.idCaseInsensitive)),t[e]=new q(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion("string"==typeof t?z(t,"property",this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):Z(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],a=null,i=t.replace(/\\?\./g,e=>"."==e?"\0":e).split("\0"),r=this;Z(n)&&(a=n.self,n=n.children);for(let e=0;e<i.length;e++)a&&e==i.length-1&&r.addCompletion(a),r=r.child(i[e].replace(/\\\./g,"."));r.addNamespace(n)}}}function z(e,t,n,a){return new RegExp("^[a-z_][a-z_\\d]*$",a?"i":"").test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+N(n)}}function N(e){return"["===e?"]":e}let D=/* @__PURE__ */y.configure({props:[
/* @__PURE__ */n.add({Statement:/* @__PURE__ */a()}),
/* @__PURE__ */i.add({Statement:(e,t)=>({from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}),BlockComment:e=>({from:e.from+2,to:e.to-2})}),
/* @__PURE__ */o({Keyword:s.keyword,Type:s.typeName,Builtin:/* @__PURE__ */s.standard(s.name),Bits:s.number,Bytes:s.string,Bool:s.bool,Null:s.null,Number:s.number,String:s.string,Identifier:s.name,QuotedIdentifier:/* @__PURE__ */s.special(s.string),SpecialVar:/* @__PURE__ */s.special(s.name),LineComment:s.lineComment,BlockComment:s.blockComment,Operator:s.operator,"Semi Punctuation":s.punctuation,"( )":s.paren,"{ }":s.brace,"[ ]":s.squareBracket})]});class ${constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(e,t){return new $(this.dialect,this.language.configure(e,t),this.spec)}static define(e){let n=function(e,t,n,a){let i={};for(let r in b)i[r]=(e.hasOwnProperty(r)?e:b)[r];return t&&(i.words=x(t,n||"",a)),i}(e,e.keywords,e.types,e.builtin),a=t.define({name:"sql",parser:D.configure({tokenizers:[{from:P,to:C(n)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new $(n,a,e)}}function E(e,t){return{label:e,type:t,boost:-1}}function V(e,t=!1,n){return function(e,t,n){let a=Object.keys(e).map(a=>{return n(t?a.toUpperCase():a,21==(i=e[a])?"type":20==i?"keyword":"variable");var i});return d(["QuotedIdentifier","String","LineComment","BlockComment","."],u(a))}(e.dialect.words,t,n||E)}function A(e){return e.schema?function(e,t,n,a,i,r){var o;let s=(null===(o=null==r?void 0:r.spec.identifierQuotes)||void 0===o?void 0:o[0])||'"',l=new q(s,!!(null==r?void 0:r.spec.caseInsensitiveIdentifiers)),c=i?l.child(i):null;return l.addNamespace(e),t&&(c||l).addCompletions(t),n&&l.addCompletions(n),c&&l.addCompletions(c.list),a&&l.addCompletions((c||l).child(a).list),e=>{let{parents:t,from:n,quoted:i,empty:r,aliases:o}=_(e.state,e.pos);if(r&&!e.explicit)return null;o&&1==t.length&&(t=o[t[0]]||t);let s=l;for(let u of t){for(;!s.children||!s.children[u];)if(s==l&&c)s=c;else{if(s!=c||!a)return null;s=s.child(a)}let e=s.maybeChild(u);if(!e)return null;s=e}let d=s.list;if(s==l&&o&&(d=d.concat(Object.keys(o).map(e=>({label:e,type:"constant"})))),i){let t=i[0],a=N(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==a?e.pos+1:void 0,options:j(t,a,d),validFor:R}}return{from:n,options:d,validFor:B}}}(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||L):()=>null}function W(e){return e.schema?(e.dialect||L).language.data.of({autocomplete:A(e)}):[]}function G(t={}){let n=t.dialect||L;return new e(n.language,[W(t),n.language.data.of({autocomplete:V(n,t.upperCaseKeywords,t.keywordCompletion)})])}const L=/* @__PURE__ */$.define({});export{$ as SQLDialect,L as StandardSQL,V as keywordCompletionSource,A as schemaCompletionSource,G as sql};