import { C as e, N as t, P as n, d as r, j as i, o as a, r as o, y as s } from "./dist-DgSmYkuV.js";
import { a as c, o as l } from "./dist-CC_emMZy.js";
import { i as u, r as d } from "./json-D8YcUjFo.js";
//#region node_modules/@codemirror/lang-sql/dist/index.js
var f = 36, p = 1, ee = 2, m = 3, h = 4, g = 5, _ = 6, v = 7, y = 8, b = 9, te = 10, ne = 11, re = 12, ie = 13, ae = 14, oe = 15, x = 16, se = 17, S = 18, C = 19, w = 20, T = 21, E = 22, D = 23, O = 24;
function k(e) {
	return e >= 65 && e <= 90 || e >= 97 && e <= 122 || e >= 48 && e <= 57;
}
function ce(e) {
	return e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70;
}
function A(e, t, n) {
	for (let r = !1;;) {
		if (e.next < 0) return;
		if (e.next == t && !r) {
			e.advance();
			return;
		}
		r = n && !r && e.next == 92, e.advance();
	}
}
function le(e, t) {
	scan: for (;;) {
		if (e.next < 0) return;
		if (e.next == 36) {
			e.advance();
			for (let n = 0; n < t.length; n++) {
				if (e.next != t.charCodeAt(n)) continue scan;
				e.advance();
			}
			if (e.next == 36) {
				e.advance();
				return;
			}
		} else e.advance();
	}
}
function ue(e, t) {
	let n = "[{<(".indexOf(String.fromCharCode(t)), r = n < 0 ? t : "]}>)".charCodeAt(n);
	for (;;) {
		if (e.next < 0) return;
		if (e.next == r && e.peek(1) == 39) {
			e.advance(2);
			return;
		}
		e.advance();
	}
}
function j(e, t) {
	for (; !(e.next != 95 && !k(e.next));) t != null && (t += String.fromCharCode(e.next)), e.advance();
	return t;
}
function M(e) {
	if (e.next == 39 || e.next == 34 || e.next == 96) {
		let t = e.next;
		e.advance(), A(e, t, !1);
	} else j(e);
}
function N(e, t) {
	for (; e.next == 48 || e.next == 49;) e.advance();
	t && e.next == t && e.advance();
}
function P(e, t) {
	for (;;) {
		if (e.next == 46) {
			if (t) break;
			t = !0;
		} else if (e.next < 48 || e.next > 57) break;
		e.advance();
	}
	if (e.next == 69 || e.next == 101) for (e.advance(), (e.next == 43 || e.next == 45) && e.advance(); e.next >= 48 && e.next <= 57;) e.advance();
}
function F(e) {
	for (; !(e.next < 0 || e.next == 10);) e.advance();
}
function I(e, t) {
	for (let n = 0; n < t.length; n++) if (t.charCodeAt(n) == e) return !0;
	return !1;
}
var L = " 	\r\n";
function R(e, t, n) {
	let r = Object.create(null);
	r.true = r.false = g, r.null = r.unknown = _;
	for (let t of e.split(" ")) t && (r[t] = w);
	for (let e of t.split(" ")) e && (r[e] = T);
	for (let e of (n || "").split(" ")) e && (r[e] = O);
	return r;
}
var z = "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 ", B = "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 ", V = {
	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__ */ R(B, z)
};
function H(e, t, n, r) {
	let i = {};
	for (let t in V) i[t] = (e.hasOwnProperty(t) ? e : V)[t];
	return t && (i.words = R(t, n || "", r)), i;
}
function U(e) {
	return new d((t) => {
		let { next: n } = t;
		if (t.advance(), I(n, L)) {
			for (; I(t.next, L);) t.advance();
			t.acceptToken(f);
		} else if (n == 36 && e.doubleDollarQuotedStrings) {
			let e = j(t, "");
			t.next == 36 && (t.advance(), le(t, e), t.acceptToken(m));
		} else if (n == 39 || n == 34 && e.doubleQuotedStrings) A(t, n, e.backslashEscapes), t.acceptToken(m);
		else if (n == 35 && e.hashComments || n == 47 && t.next == 47 && e.slashComments) F(t), t.acceptToken(p);
		else if (n == 45 && t.next == 45 && (!e.spaceAfterDashes || t.peek(1) == 32)) F(t), t.acceptToken(p);
		else if (n == 47 && t.next == 42) {
			t.advance();
			for (let e = 1;;) {
				let n = t.next;
				if (t.next < 0) break;
				if (t.advance(), n == 42 && t.next == 47) {
					if (e--, t.advance(), !e) break;
				} else n == 47 && t.next == 42 && (e++, t.advance());
			}
			t.acceptToken(ee);
		} else if ((n == 101 || n == 69) && t.next == 39) t.advance(), A(t, 39, !0), t.acceptToken(m);
		else if ((n == 110 || n == 78) && t.next == 39 && e.charSetCasts) t.advance(), A(t, 39, e.backslashEscapes), t.acceptToken(m);
		else if (n == 95 && e.charSetCasts) for (let n = 0;; n++) {
			if (t.next == 39 && n > 1) {
				t.advance(), A(t, 39, e.backslashEscapes), t.acceptToken(m);
				break;
			}
			if (!k(t.next)) break;
			t.advance();
		}
		else if (e.plsqlQuotingMechanism && (n == 113 || n == 81) && t.next == 39 && t.peek(1) > 0 && !I(t.peek(1), L)) {
			let e = t.peek(1);
			t.advance(2), ue(t, e), t.acceptToken(m);
		} else if (I(n, e.identifierQuotes)) A(t, n == 91 ? 93 : n, !1), t.acceptToken(C);
		else if (n == 40) t.acceptToken(v);
		else if (n == 41) t.acceptToken(y);
		else if (n == 123) t.acceptToken(b);
		else if (n == 125) t.acceptToken(te);
		else if (n == 91) t.acceptToken(ne);
		else if (n == 93) t.acceptToken(re);
		else if (n == 59) t.acceptToken(ie);
		else if (e.unquotedBitLiterals && n == 48 && t.next == 98) t.advance(), N(t), t.acceptToken(E);
		else if ((n == 98 || n == 66) && (t.next == 39 || t.next == 34)) {
			let n = t.next;
			t.advance(), e.treatBitsAsBytes ? (A(t, n, e.backslashEscapes), t.acceptToken(D)) : (N(t, n), t.acceptToken(E));
		} else if (n == 48 && (t.next == 120 || t.next == 88) || (n == 120 || n == 88) && t.next == 39) {
			let e = t.next == 39;
			for (t.advance(); ce(t.next);) t.advance();
			e && t.next == 39 && t.advance(), t.acceptToken(h);
		} else if (n == 46 && t.next >= 48 && t.next <= 57) P(t, !0), t.acceptToken(h);
		else if (n == 46) t.acceptToken(ae);
		else if (n >= 48 && n <= 57) P(t, !1), t.acceptToken(h);
		else if (I(n, e.operatorChars)) {
			for (; I(t.next, e.operatorChars);) t.advance();
			t.acceptToken(oe);
		} else if (I(n, e.specialVar)) t.next == n && t.advance(), M(t), t.acceptToken(se);
		else if (n == 58 || n == 44) t.acceptToken(x);
		else if (k(n)) {
			let r = j(t, String.fromCharCode(n));
			t.acceptToken(t.next == 46 || t.peek(-r.length - 1) == 46 ? S : e.words[r.toLowerCase()] ?? S);
		}
	});
}
var W = /* @__PURE__ */ U(V), de = /* @__PURE__ */ u.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, W],
	topRules: { Script: [0, 25] },
	tokenPrec: 0
});
function G(e) {
	let t = e.cursor().moveTo(e.from, -1);
	for (; /Comment/.test(t.name);) t.moveTo(t.from, -1);
	return t.node;
}
function K(e, t) {
	let n = e.sliceString(t.from, t.to), r = /^([`'"\[])(.*)([`'"\]])$/.exec(n);
	return r ? r[2] : n;
}
function q(e) {
	return e && (e.name == "Identifier" || e.name == "QuotedIdentifier");
}
function fe(e, t) {
	if (t.name == "CompositeIdentifier") {
		let n = [];
		for (let r = t.firstChild; r; r = r.nextSibling) q(r) && n.push(K(e, r));
		return n;
	}
	return [K(e, t)];
}
function J(e, t) {
	for (let n = [];;) {
		if (!t || t.name != ".") return n;
		let r = G(t);
		if (!q(r)) return n;
		n.unshift(K(e, r)), t = G(r);
	}
}
function pe(e, t) {
	let n = i(e).resolveInner(t, -1), r = he(e.doc, n);
	return n.name == "Identifier" || n.name == "QuotedIdentifier" || n.name == "Keyword" ? {
		from: n.from,
		quoted: n.name == "QuotedIdentifier" ? e.doc.sliceString(n.from, n.from + 1) : null,
		parents: J(e.doc, G(n)),
		aliases: r
	} : n.name == "." ? {
		from: t,
		quoted: null,
		parents: J(e.doc, n),
		aliases: r
	} : {
		from: t,
		quoted: null,
		parents: [],
		empty: !0,
		aliases: r
	};
}
var me = /* @__PURE__ */ new Set(/* @__PURE__ */ "where group having order union intersect except all distinct limit offset fetch for".split(" "));
function he(e, t) {
	let n;
	for (let e = t; !n; e = e.parent) {
		if (!e) return null;
		e.name == "Statement" && (n = e);
	}
	let r = null;
	for (let t = n.firstChild, i = !1, a = null; t; t = t.nextSibling) {
		let n = t.name == "Keyword" ? e.sliceString(t.from, t.to).toLowerCase() : null, o = null;
		if (!i) i = n == "from";
		else if (n == "as" && a && q(t.nextSibling)) o = K(e, t.nextSibling);
		else if (n && me.has(n)) break;
		else a && q(t) && (o = K(e, t));
		o && (r ||= Object.create(null), r[o] = fe(e, a)), a = /Identifier$/.test(t.name) ? t : null;
	}
	return r;
}
function ge(e, t, n) {
	return n.map((n) => ({
		...n,
		label: n.label[0] == e ? n.label : e + n.label + t,
		apply: void 0
	}));
}
var _e = /^\w*$/, ve = /^[`'"\[]?\w*[`'"\]]?$/;
function Y(e) {
	return e.self && typeof e.self.label == "string";
}
var ye = class e {
	constructor(e, t) {
		this.idQuote = e, this.idCaseInsensitive = t, this.list = [], this.children = void 0;
	}
	child(t) {
		let n = this.children ||= Object.create(null);
		return n[t] || (t && !this.list.some((e) => e.label == t) && this.list.push(X(t, "type", this.idQuote, this.idCaseInsensitive)), n[t] = new e(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(typeof t == "string" ? X(t, "property", this.idQuote, this.idCaseInsensitive) : t);
	}
	addNamespace(e) {
		Array.isArray(e) ? this.addCompletions(e) : Y(e) ? this.addNamespace(e.children) : this.addNamespaceObject(e);
	}
	addNamespaceObject(e) {
		for (let t of Object.keys(e)) {
			let n = e[t], r = null, i = t.replace(/\\?\./g, (e) => e == "." ? "\0" : e).split("\0"), a = this;
			Y(n) && (r = n.self, n = n.children);
			for (let e = 0; e < i.length; e++) r && e == i.length - 1 && a.addCompletion(r), a = a.child(i[e].replace(/\\\./g, "."));
			a.addNamespace(n);
		}
	}
};
function X(e, t, n, r) {
	return RegExp("^[a-z_][a-z_\\d]*$", r ? "i" : "").test(e) ? {
		label: e,
		type: t
	} : {
		label: e,
		type: t,
		apply: n + e + Z(n)
	};
}
function Z(e) {
	return e === "[" ? "]" : e;
}
function be(e, t, n, r, i, a) {
	let o = new ye(a?.spec.identifierQuotes?.[0] || "\"", !!a?.spec.caseInsensitiveIdentifiers), s = i ? o.child(i) : null;
	return o.addNamespace(e), t && (s || o).addCompletions(t), n && o.addCompletions(n), s && o.addCompletions(s.list), r && o.addCompletions((s || o).child(r).list), (e) => {
		let { parents: t, from: n, quoted: i, empty: a, aliases: c } = pe(e.state, e.pos);
		if (a && !e.explicit) return null;
		c && t.length == 1 && (t = c[t[0]] || t);
		let l = o;
		for (let e of t) {
			for (; !l.children || !l.children[e];) if (l == o && s) l = s;
			else if (l == s && r) l = l.child(r);
			else return null;
			let t = l.maybeChild(e);
			if (!t) return null;
			l = t;
		}
		let u = l.list;
		if (l == o && c && (u = u.concat(Object.keys(c).map((e) => ({
			label: e,
			type: "constant"
		})))), i) {
			let t = i[0], r = Z(t);
			return {
				from: n,
				to: e.state.sliceDoc(e.pos, e.pos + 1) == r ? e.pos + 1 : void 0,
				options: ge(t, r, u),
				validFor: ve
			};
		} else return {
			from: n,
			options: u,
			validFor: _e
		};
	};
}
function xe(e) {
	return e == T ? "type" : e == w ? "keyword" : "variable";
}
function Se(e, t, n) {
	return l([
		"QuotedIdentifier",
		"String",
		"LineComment",
		"BlockComment",
		"."
	], c(Object.keys(e).map((r) => n(t ? r.toUpperCase() : r, xe(e[r])))));
}
var Q = /* @__PURE__ */ de.configure({ props: [
	/* @__PURE__ */ e.add({ Statement: /* @__PURE__ */ r() }),
	/* @__PURE__ */ s.add({
		Statement(e, t) {
			return {
				from: Math.min(e.from + 100, t.doc.lineAt(e.from).to),
				to: e.to
			};
		},
		BlockComment(e) {
			return {
				from: e.from + 2,
				to: e.to - 2
			};
		}
	}),
	/* @__PURE__ */ t({
		Keyword: n.keyword,
		Type: n.typeName,
		Builtin: /* @__PURE__ */ n.standard(n.name),
		Bits: n.number,
		Bytes: n.string,
		Bool: n.bool,
		Null: n.null,
		Number: n.number,
		String: n.string,
		Identifier: n.name,
		QuotedIdentifier: /* @__PURE__ */ n.special(n.string),
		SpecialVar: /* @__PURE__ */ n.special(n.name),
		LineComment: n.lineComment,
		BlockComment: n.blockComment,
		Operator: n.operator,
		"Semi Punctuation": n.punctuation,
		"( )": n.paren,
		"{ }": n.brace,
		"[ ]": n.squareBracket
	})
] }), Ce = class e {
	constructor(e, t, n) {
		this.dialect = e, this.language = t, this.spec = n;
	}
	get extension() {
		return this.language.extension;
	}
	configureLanguage(t, n) {
		return new e(this.dialect, this.language.configure(t, n), this.spec);
	}
	static define(t) {
		let n = H(t, t.keywords, t.types, t.builtin);
		return new e(n, o.define({
			name: "sql",
			parser: Q.configure({ tokenizers: [{
				from: W,
				to: U(n)
			}] }),
			languageData: {
				commentTokens: {
					line: "--",
					block: {
						open: "/*",
						close: "*/"
					}
				},
				closeBrackets: { brackets: [
					"(",
					"[",
					"{",
					"'",
					"\"",
					"`"
				] }
			}
		}), t);
	}
};
function we(e, t) {
	return {
		label: e,
		type: t,
		boost: -1
	};
}
function Te(e, t = !1, n) {
	return Se(e.dialect.words, t, n || we);
}
function Ee(e) {
	return e.schema ? be(e.schema, e.tables, e.schemas, e.defaultTable, e.defaultSchema, e.dialect || $) : () => null;
}
function De(e) {
	return e.schema ? (e.dialect || $).language.data.of({ autocomplete: Ee(e) }) : [];
}
function Oe(e = {}) {
	let t = e.dialect || $;
	return new a(t.language, [De(e), t.language.data.of({ autocomplete: Te(t, e.upperCaseKeywords, e.keywordCompletion) })]);
}
var $ = /* @__PURE__ */ Ce.define({});
B + "", z + "", z + "", B + "", B + "", B + "", z + "", B + "", z + "", z + "", B + "", z + "";
//#endregion
//#region src/editors/languages/sql.ts
function ke(e) {
	return Oe(e);
}
var Ae = [
	{
		label: "SELECT",
		type: "keyword"
	},
	{
		label: "FROM",
		type: "keyword"
	},
	{
		label: "WHERE",
		type: "keyword"
	},
	{
		label: "INSERT",
		type: "keyword"
	},
	{
		label: "UPDATE",
		type: "keyword"
	},
	{
		label: "DELETE",
		type: "keyword"
	},
	{
		label: "CREATE",
		type: "keyword"
	},
	{
		label: "ALTER",
		type: "keyword"
	},
	{
		label: "DROP",
		type: "keyword"
	},
	{
		label: "JOIN",
		type: "keyword"
	},
	{
		label: "LEFT JOIN",
		type: "keyword"
	},
	{
		label: "RIGHT JOIN",
		type: "keyword"
	},
	{
		label: "INNER JOIN",
		type: "keyword"
	},
	{
		label: "OUTER JOIN",
		type: "keyword"
	},
	{
		label: "ON",
		type: "keyword"
	},
	{
		label: "GROUP BY",
		type: "keyword"
	},
	{
		label: "ORDER BY",
		type: "keyword"
	},
	{
		label: "HAVING",
		type: "keyword"
	},
	{
		label: "LIMIT",
		type: "keyword"
	},
	{
		label: "OFFSET",
		type: "keyword"
	},
	{
		label: "DISTINCT",
		type: "keyword"
	},
	{
		label: "AS",
		type: "keyword"
	},
	{
		label: "AND",
		type: "keyword"
	},
	{
		label: "OR",
		type: "keyword"
	},
	{
		label: "NOT",
		type: "keyword"
	},
	{
		label: "IN",
		type: "keyword"
	},
	{
		label: "BETWEEN",
		type: "keyword"
	},
	{
		label: "LIKE",
		type: "keyword"
	},
	{
		label: "IS NULL",
		type: "keyword"
	},
	{
		label: "IS NOT NULL",
		type: "keyword"
	},
	{
		label: "ASC",
		type: "keyword"
	},
	{
		label: "DESC",
		type: "keyword"
	},
	{
		label: "COUNT()",
		type: "function"
	},
	{
		label: "SUM()",
		type: "function"
	},
	{
		label: "AVG()",
		type: "function"
	},
	{
		label: "MIN()",
		type: "function"
	},
	{
		label: "MAX()",
		type: "function"
	},
	{
		label: "COALESCE()",
		type: "function"
	},
	{
		label: "CAST()",
		type: "function"
	},
	{
		label: "NOW()",
		type: "function"
	}
];
//#endregion
export { Ae as n, ke as t };

//# sourceMappingURL=sql-BTWxpluA.js.map