prettier-plugin-embed 0.3.0-rc.0 → 0.3.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,203 +1,46 @@
1
+ import { utils as X, builders as $ } from "prettier/doc";
1
2
  import Qe from "prettier/parser-babel";
2
3
  import Ze from "prettier/parser-espree";
3
4
  import et from "prettier/parser-flow";
4
- import tt from "prettier/parser-typescript";
5
- import nt from "prettier/parser-meriyah";
6
- import { utils as X, builders as $ } from "prettier/doc";
7
- import { isAbsolute as rt } from "node:path";
8
- import { readFileSync as st } from "node:fs";
9
- import { printers as ot } from "prettier/plugins/estree.mjs";
10
- const Ce = "embeddedCss";
11
- var it = {
12
- isEqual: !0,
13
- isMatchingKey: !0,
14
- isPromise: !0,
15
- maxSize: !0,
16
- onCacheAdd: !0,
17
- onCacheChange: !0,
18
- onCacheHit: !0,
19
- transformKey: !0
20
- }, at = Array.prototype.slice;
21
- function W(t) {
22
- var n = t.length;
23
- return n ? n === 1 ? [t[0]] : n === 2 ? [t[0], t[1]] : n === 3 ? [t[0], t[1], t[2]] : at.call(t, 0) : [];
24
- }
25
- function dt(t) {
26
- var n = {};
27
- for (var r in t)
28
- it[r] || (n[r] = t[r]);
29
- return n;
30
- }
31
- function ct(t) {
32
- return typeof t == "function" && t.isMemoized;
33
- }
34
- function lt(t, n) {
35
- return t === n || t !== t && n !== n;
36
- }
37
- function Z(t, n) {
38
- var r = {};
39
- for (var e in t)
40
- r[e] = t[e];
41
- for (var e in n)
42
- r[e] = n[e];
43
- return r;
44
- }
45
- var ut = (
46
- /** @class */
47
- function() {
48
- function t(n) {
49
- this.keys = [], this.values = [], this.options = n;
50
- var r = typeof n.isMatchingKey == "function";
51
- r ? this.getKeyIndex = this._getKeyIndexFromMatchingKey : n.maxSize > 1 ? this.getKeyIndex = this._getKeyIndexForMany : this.getKeyIndex = this._getKeyIndexForSingle, this.canTransformKey = typeof n.transformKey == "function", this.shouldCloneArguments = this.canTransformKey || r, this.shouldUpdateOnAdd = typeof n.onCacheAdd == "function", this.shouldUpdateOnChange = typeof n.onCacheChange == "function", this.shouldUpdateOnHit = typeof n.onCacheHit == "function";
52
- }
53
- return Object.defineProperty(t.prototype, "size", {
54
- /**
55
- * The number of cached [key,value] results.
56
- */
57
- get: function() {
58
- return this.keys.length;
59
- },
60
- enumerable: !1,
61
- configurable: !0
62
- }), Object.defineProperty(t.prototype, "snapshot", {
63
- /**
64
- * A copy of the cache at a moment in time. This is useful
65
- * to compare changes over time, since the cache mutates
66
- * internally for performance reasons.
67
- */
68
- get: function() {
69
- return {
70
- keys: W(this.keys),
71
- size: this.size,
72
- values: W(this.values)
73
- };
74
- },
75
- enumerable: !1,
76
- configurable: !0
77
- }), t.prototype._getKeyIndexFromMatchingKey = function(n) {
78
- var r = this.options, e = r.isMatchingKey, s = r.maxSize, o = this.keys, d = o.length;
79
- if (!d)
80
- return -1;
81
- if (e(o[0], n))
82
- return 0;
83
- if (s > 1) {
84
- for (var i = 1; i < d; i++)
85
- if (e(o[i], n))
86
- return i;
87
- }
88
- return -1;
89
- }, t.prototype._getKeyIndexForMany = function(n) {
90
- var r = this.options.isEqual, e = this.keys, s = e.length;
91
- if (!s)
92
- return -1;
93
- if (s === 1)
94
- return this._getKeyIndexForSingle(n);
95
- var o = n.length, d, i;
96
- if (o > 1) {
97
- for (var a = 0; a < s; a++)
98
- if (d = e[a], d.length === o) {
99
- for (i = 0; i < o && r(d[i], n[i]); i++)
100
- ;
101
- if (i === o)
102
- return a;
103
- }
104
- } else
105
- for (var a = 0; a < s; a++)
106
- if (d = e[a], d.length === o && r(d[0], n[0]))
107
- return a;
108
- return -1;
109
- }, t.prototype._getKeyIndexForSingle = function(n) {
110
- var r = this.keys;
111
- if (!r.length)
112
- return -1;
113
- var e = r[0], s = e.length;
114
- if (n.length !== s)
115
- return -1;
116
- var o = this.options.isEqual;
117
- if (s > 1) {
118
- for (var d = 0; d < s; d++)
119
- if (!o(e[d], n[d]))
120
- return -1;
121
- return 0;
122
- }
123
- return o(e[0], n[0]) ? 0 : -1;
124
- }, t.prototype.orderByLru = function(n, r, e) {
125
- for (var s = this.keys, o = this.values, d = s.length, i = e; i--; )
126
- s[i + 1] = s[i], o[i + 1] = o[i];
127
- s[0] = n, o[0] = r;
128
- var a = this.options.maxSize;
129
- d === a && e === d ? (s.pop(), o.pop()) : e >= a && (s.length = o.length = a);
130
- }, t.prototype.updateAsyncCache = function(n) {
131
- var r = this, e = this.options, s = e.onCacheChange, o = e.onCacheHit, d = this.keys[0], i = this.values[0];
132
- this.values[0] = i.then(function(a) {
133
- return r.shouldUpdateOnHit && o(r, r.options, n), r.shouldUpdateOnChange && s(r, r.options, n), a;
134
- }, function(a) {
135
- var l = r.getKeyIndex(d);
136
- throw l !== -1 && (r.keys.splice(l, 1), r.values.splice(l, 1)), a;
137
- });
138
- }, t;
139
- }()
140
- );
141
- function Y(t, n) {
142
- if (n === void 0 && (n = {}), ct(t))
143
- return Y(t.fn, Z(t.options, n));
144
- if (typeof t != "function")
145
- throw new TypeError("You must pass a function to `memoize`.");
146
- var r = n.isEqual, e = r === void 0 ? lt : r, s = n.isMatchingKey, o = n.isPromise, d = o === void 0 ? !1 : o, i = n.maxSize, a = i === void 0 ? 1 : i, l = n.onCacheAdd, g = n.onCacheChange, y = n.onCacheHit, h = n.transformKey, u = Z({
147
- isEqual: e,
148
- isMatchingKey: s,
149
- isPromise: d,
150
- maxSize: a,
151
- onCacheAdd: l,
152
- onCacheChange: g,
153
- onCacheHit: y,
154
- transformKey: h
155
- }, dt(n)), c = new ut(u), b = c.keys, m = c.values, p = c.canTransformKey, f = c.shouldCloneArguments, _ = c.shouldUpdateOnAdd, v = c.shouldUpdateOnChange, x = c.shouldUpdateOnHit, E = function() {
156
- var S = f ? W(arguments) : arguments;
157
- p && (S = h(S));
158
- var O = b.length ? c.getKeyIndex(S) : -1;
159
- if (O !== -1)
160
- x && y(c, u, E), O && (c.orderByLru(b[O], m[O], O), v && g(c, u, E));
161
- else {
162
- var Ve = t.apply(this, arguments), Je = f ? S : W(arguments);
163
- c.orderByLru(Je, Ve, b.length), d && c.updateAsyncCache(E), _ && l(c, u, E), v && g(c, u, E);
164
- }
165
- return m[0];
166
- };
167
- return E.cache = c, E.fn = t, E.isMemoized = !0, E.options = u, E;
168
- }
169
- const { group: gt, indent: mt, softline: ee, lineSuffixBoundary: pt } = $, { mapDoc: ft } = X;
170
- function ht(t, n) {
5
+ import tt from "prettier/parser-meriyah";
6
+ import nt from "prettier/parser-typescript";
7
+ import { printers as rt } from "prettier/plugins/estree.mjs";
8
+ import { readFile as st } from "node:fs/promises";
9
+ import { isAbsolute as ot, dirname as it, resolve as at, extname as dt } from "node:path";
10
+ import { Worker as ct } from "node:worker_threads";
11
+ import { resolveConfigFile as lt } from "prettier";
12
+ const Me = "embeddedCss", { group: ut, indent: mt, softline: Q, lineSuffixBoundary: gt } = $, { mapDoc: pt } = X;
13
+ function ft(t, n) {
171
14
  const { node: r } = t;
172
15
  let e = n();
173
- return r?.comments?.length && (e = gt([mt([ee, e]), ee])), ["${", e, pt, "}"];
16
+ return r?.comments?.length && (e = ut([mt([Q, e]), Q])), ["${", e, gt, "}"];
174
17
  }
175
- function L(t, n) {
18
+ function O(t, n) {
176
19
  return t.map(
177
- (r) => ht(r, n),
20
+ (r) => ft(r, n),
178
21
  "expressions"
179
22
  );
180
23
  }
181
- function D(t, n, r) {
182
- return ft(t, (s) => {
24
+ function T(t, n, r) {
25
+ return pt(t, (s) => {
183
26
  if (typeof s != "string")
184
27
  return s;
185
- const o = [], d = s.split(n);
186
- for (let i = 0; i < d.length; i++) {
187
- let a = d[i];
28
+ const o = [], a = s.split(n);
29
+ for (let i = 0; i < a.length; i++) {
30
+ let c = a[i];
188
31
  if (i % 2 == 0) {
189
- if (!a)
32
+ if (!c)
190
33
  continue;
191
- a = a.replaceAll(/([\\`]|\${)/g, "\\$1"), o.push(a);
34
+ c = c.replaceAll(/([\\`]|\${)/g, "\\$1"), o.push(c);
192
35
  } else {
193
- const l = Number(a);
36
+ const l = Number(c);
194
37
  o.push(r[l]);
195
38
  }
196
39
  }
197
40
  return o;
198
41
  });
199
42
  }
200
- function B(t, n, r) {
43
+ function q(t, n, r) {
201
44
  if (!(n.plugins?.some(
202
45
  (e) => e.name?.includes(t) ?? !1
203
46
  ) ?? !1))
@@ -205,7 +48,7 @@ function B(t, n, r) {
205
48
  `Cannot format embedded language identified by "${r}", because plugin "${t}" is not loaded.`
206
49
  );
207
50
  }
208
- function bt(t, n, r) {
51
+ function ht(t, n, r) {
209
52
  if (n === r) {
210
53
  t.unshift(n);
211
54
  return;
@@ -221,7 +64,7 @@ function bt(t, n, r) {
221
64
  }
222
65
  t.splice(e, 0, n);
223
66
  }
224
- const te = (() => {
67
+ const Z = (() => {
225
68
  const t = [...Array(26).keys()].map((n) => String.fromCharCode(n + 97)).concat([...Array(10).keys()].map((n) => `${n}`));
226
69
  return () => {
227
70
  let r = "";
@@ -231,112 +74,90 @@ const te = (() => {
231
74
  };
232
75
  })();
233
76
  function k(t = "p", n = "") {
234
- const r = te(), e = te(), s = ne(t), o = ne(n), d = (a) => `${t}${r}${a}${e}${n}`, i = new RegExp(
77
+ const r = Z(), e = Z(), s = ee(t), o = ee(n), a = (c) => `${t}${r}${c}${e}${n}`, i = new RegExp(
235
78
  `${s}${r}(\\d+)${e}${o}`,
236
79
  "g"
237
80
  );
238
81
  return {
239
- createPlaceholder: d,
82
+ createPlaceholder: a,
240
83
  placeholderRegex: i
241
84
  };
242
85
  }
243
- function ne(t) {
86
+ function ee(t) {
244
87
  return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
245
88
  }
246
89
  function I(t) {
247
90
  return `${t}Identifiers`;
248
91
  }
249
- function yt(t) {
92
+ function bt(t) {
250
93
  return `${t}Parser`;
251
94
  }
252
- const vt = Y((t) => {
253
- const n = rt(t) ? st(t, { encoding: "utf-8" }) : t;
254
- try {
255
- return JSON.parse(n);
256
- } catch {
257
- console.error("Error parsing embedded overrides.");
258
- }
259
- }), T = Y(
260
- (t, n) => {
261
- if (typeof t == "string") {
262
- const r = vt(t);
263
- if (typeof r > "u")
264
- return;
265
- try {
266
- for (const { identifiers: e, options: s } of r)
267
- if (e.includes(n))
268
- return s;
269
- } catch {
270
- console.error("Error parsing embedded override options.");
271
- }
272
- }
273
- }
274
- ), { line: re, group: R, indent: se, softline: oe } = $, _t = async (t, n, r, e, s) => {
95
+ const { line: te, group: D, indent: ne, softline: re } = $, yt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
275
96
  e = {
276
97
  ...e,
277
- ...T(e.embeddedOverrides, s)
98
+ ...o
278
99
  };
279
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k("@p"), a = o.quasis.map(
280
- (m, p, { length: f }) => p === f - 1 ? m.value.cooked : m.value.cooked + d(p)
281
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = L(r, n), h = await t(a, {
100
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k("@p"), l = a.quasis.map(
101
+ (f, h, { length: p }) => h === p - 1 ? f.value.cooked : f.value.cooked + i(h)
102
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = O(r, n), b = await t(l, {
282
103
  ...e,
283
104
  parser: "scss"
284
- }), u = D(h, i, y);
105
+ }), d = T(b, c, _);
285
106
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
286
- return R([
107
+ return D([
287
108
  "`",
288
- l,
289
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [R(u)] : se([R(u)]),
290
- g,
109
+ u,
110
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [D(d)] : ne([D(d)]),
111
+ m,
291
112
  "`"
292
113
  ]);
293
- const c = l.length ? re : oe, b = g.length ? re : oe;
294
- return R([
114
+ const g = u.length ? te : re, y = m.length ? te : re;
115
+ return D([
295
116
  "`",
296
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [c, R(u)] : se([c, R(u)]),
297
- b,
117
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [g, D(d)] : ne([g, D(d)]),
118
+ y,
298
119
  "`"
299
120
  ]);
300
- }, Et = ["css"], xt = I(Ce), $t = {
301
- [xt]: {
121
+ }, vt = ["css"], _t = I(Me), Et = {
122
+ [_t]: {
302
123
  category: "Global",
303
124
  type: "string",
304
125
  array: !0,
305
- default: [{ value: [...Et] }],
126
+ default: [{ value: [...vt] }],
306
127
  description: "Specify embedded CSS language identifiers."
307
128
  }
308
- }, It = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
129
+ }, xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
309
130
  __proto__: null,
310
- embeddedLanguage: Ce,
311
- embedder: _t,
312
- options: $t
313
- }, Symbol.toStringTag, { value: "Module" })), V = "embeddedEs", { line: ie, group: P, indent: ae, softline: de } = $, St = async (t, n, r, e, s) => {
131
+ embeddedLanguage: Me,
132
+ embedder: yt,
133
+ options: Et
134
+ }, Symbol.toStringTag, { value: "Module" })), J = "embeddedEs", { line: se, group: w, indent: oe, softline: ie } = $, $t = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
314
135
  e = {
315
136
  ...e,
316
- ...T(e.embeddedOverrides, s)
137
+ ...o
317
138
  };
318
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k(), a = o.quasis.map(
319
- (m, p, { length: f }) => p === f - 1 ? m.value.cooked : m.value.cooked + d(p)
320
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = L(r, n), h = await t(a, {
139
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k(), l = a.quasis.map(
140
+ (f, h, { length: p }) => h === p - 1 ? f.value.cooked : f.value.cooked + i(h)
141
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = O(r, n), b = await t(l, {
321
142
  ...e,
322
143
  parser: e.embeddedEsParser ?? "babel"
323
- }), u = D(h, i, y);
144
+ }), d = T(b, c, _);
324
145
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
325
- return P([
146
+ return w([
326
147
  "`",
327
- l,
328
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [P(u)] : ae([P(u)]),
329
- g,
148
+ u,
149
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [w(d)] : oe([w(d)]),
150
+ m,
330
151
  "`"
331
152
  ]);
332
- const c = l.length ? ie : de, b = g.length ? ie : de;
333
- return P([
153
+ const g = u.length ? se : ie, y = m.length ? se : ie;
154
+ return w([
334
155
  "`",
335
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [c, P(u)] : ae([c, P(u)]),
336
- b,
156
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [g, w(d)] : oe([g, w(d)]),
157
+ y,
337
158
  "`"
338
159
  ]);
339
- }, Ot = [
160
+ }, It = [
340
161
  "js",
341
162
  "jsx",
342
163
  "es",
@@ -345,56 +166,56 @@ const vt = Y((t) => {
345
166
  "cjs",
346
167
  "pac",
347
168
  "javascript"
348
- ], Lt = I(V), kt = yt(V), Tt = {
349
- [Lt]: {
169
+ ], St = I(J), Lt = bt(J), Ot = {
170
+ [St]: {
350
171
  category: "Global",
351
172
  type: "string",
352
173
  array: !0,
353
- default: [{ value: [...Ot] }],
174
+ default: [{ value: [...It] }],
354
175
  description: "Specify embedded ES language identifiers."
355
176
  },
356
- [kt]: {
177
+ [Lt]: {
357
178
  category: "Global",
358
179
  type: "string",
359
180
  array: !1,
360
181
  default: "babel",
361
182
  description: "Specify the embedded ES language parser."
362
183
  }
363
- }, Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
184
+ }, kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
364
185
  __proto__: null,
365
- embeddedLanguage: V,
366
- embedder: St,
367
- options: Tt
368
- }, Symbol.toStringTag, { value: "Module" })), Ne = "embeddedGlsl", { line: ce, group: M, indent: le, softline: ue } = $, Rt = async (t, n, r, e, s) => {
369
- B("prettier-plugin-glsl", e, s), e = {
186
+ embeddedLanguage: J,
187
+ embedder: $t,
188
+ options: Ot
189
+ }, Symbol.toStringTag, { value: "Module" })), Fe = "embeddedGlsl", { line: ae, group: P, indent: de, softline: ce } = $, Tt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
190
+ q("prettier-plugin-glsl", e, s), e = {
370
191
  ...e,
371
- ...T(e.embeddedOverrides, s)
192
+ ...o
372
193
  };
373
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k(), a = o.quasis.map(
374
- (p, f, { length: _ }) => f === _ - 1 ? p.value.cooked : p.value.cooked + d(f)
375
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = a.slice(
376
- l.length,
377
- -g.length || void 0
378
- ), h = L(r, n), u = await t(y, {
194
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k(), l = a.quasis.map(
195
+ (h, p, { length: v }) => p === v - 1 ? h.value.cooked : h.value.cooked + i(p)
196
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = l.slice(
197
+ u.length,
198
+ -m.length || void 0
199
+ ), b = O(r, n), d = await t(_, {
379
200
  ...e,
380
201
  parser: "glsl-parser"
381
- }), c = D(u, i, h);
202
+ }), g = T(d, c, b);
382
203
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
383
- return M([
204
+ return P([
384
205
  "`",
385
- l,
386
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [M(c)] : le([M(c)]),
387
- g,
206
+ u,
207
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [P(g)] : de([P(g)]),
208
+ m,
388
209
  "`"
389
210
  ]);
390
- const b = l.length ? ce : ue, m = g.length ? ce : ue;
391
- return M([
211
+ const y = u.length ? ae : ce, f = m.length ? ae : ce;
212
+ return P([
392
213
  "`",
393
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [b, M(c)] : le([b, M(c)]),
394
- m,
214
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [y, P(g)] : de([y, P(g)]),
215
+ f,
395
216
  "`"
396
217
  ]);
397
- }, Pt = [
218
+ }, Dt = [
398
219
  "glsl",
399
220
  "fp",
400
221
  "frag",
@@ -417,63 +238,63 @@ const vt = Y((t) => {
417
238
  "vrx",
418
239
  "vsh",
419
240
  "vshader"
420
- ], Mt = I(Ne), Ct = {
421
- [Mt]: {
241
+ ], wt = I(Fe), Pt = {
242
+ [wt]: {
422
243
  category: "Global",
423
244
  type: "string",
424
245
  array: !0,
425
- default: [{ value: [...Pt] }],
246
+ default: [{ value: [...Dt] }],
426
247
  description: 'Specify embedded GLSL language identifiers. This requires "prettier-plugin-glsl".'
427
248
  }
428
- }, Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
249
+ }, Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
429
250
  __proto__: null,
430
- embeddedLanguage: Ne,
431
- embedder: Rt,
432
- options: Ct
433
- }, Symbol.toStringTag, { value: "Module" })), we = "embeddedHtml", { line: ge, group: C, indent: me, softline: pe } = $, { mapDoc: wt } = X, Ft = async (t, n, r, e, s) => {
251
+ embeddedLanguage: Fe,
252
+ embedder: Tt,
253
+ options: Pt
254
+ }, Symbol.toStringTag, { value: "Module" })), Ce = "embeddedHtml", { line: le, group: R, indent: ue, softline: me } = $, { mapDoc: Mt } = X, Ft = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
434
255
  e = {
435
256
  ...e,
436
- ...T(e.embeddedOverrides, s)
257
+ ...o
437
258
  };
438
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k(), a = o.quasis.map(
439
- (m, p, { length: f }) => p === f - 1 ? m.value.cooked : m.value.cooked + d(p)
440
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = L(r, n), h = await t(a, {
259
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k(), l = a.quasis.map(
260
+ (f, h, { length: p }) => h === p - 1 ? f.value.cooked : f.value.cooked + i(h)
261
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = O(r, n), b = await t(l, {
441
262
  ...e,
442
263
  parser: "html"
443
- }), u = wt(h, (m) => {
444
- if (typeof m != "string")
445
- return m;
446
- const p = [], f = m.split(i);
447
- for (let _ = 0; _ < f.length; _++) {
448
- let v = f[_];
449
- if (_ % 2 == 0) {
450
- if (!v)
264
+ }), d = Mt(b, (f) => {
265
+ if (typeof f != "string")
266
+ return f;
267
+ const h = [], p = f.split(c);
268
+ for (let v = 0; v < p.length; v++) {
269
+ let E = p[v];
270
+ if (v % 2 == 0) {
271
+ if (!E)
451
272
  continue;
452
- v = v.replaceAll(/([\\`]|\${)/g, "\\$1"), e.__embeddedInHtml && (v = v.replaceAll(/<\/(?=script\b)/gi, "<\\/")), p.push(v);
273
+ E = E.replaceAll(/([\\`]|\${)/g, "\\$1"), e.__embeddedInHtml && (E = E.replaceAll(/<\/(?=script\b)/gi, "<\\/")), h.push(E);
453
274
  } else {
454
- const x = Number(v);
455
- p.push(y[x]);
275
+ const x = Number(E);
276
+ h.push(_[x]);
456
277
  }
457
278
  }
458
- return p;
279
+ return h;
459
280
  });
460
281
  if (e.htmlWhitespaceSensitivity === "strict" || // TODO: is css mode should be included here?
461
282
  e.htmlWhitespaceSensitivity === "css" || e.preserveEmbeddedExteriorWhitespaces?.includes(s))
462
- return C([
283
+ return R([
463
284
  "`",
464
- l,
465
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [C(u)] : me([C(u)]),
466
- g,
285
+ u,
286
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [R(d)] : ue([R(d)]),
287
+ m,
467
288
  "`"
468
289
  ]);
469
- const c = l.length ? ge : pe, b = g.length ? ge : pe;
470
- return C([
290
+ const g = u.length ? le : me, y = m.length ? le : me;
291
+ return R([
471
292
  "`",
472
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [c, C(u)] : me([c, C(u)]),
473
- b,
293
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [g, R(d)] : ue([g, R(d)]),
294
+ y,
474
295
  "`"
475
296
  ]);
476
- }, At = [
297
+ }, Ct = [
477
298
  "html",
478
299
  "htm",
479
300
  "shtml",
@@ -486,47 +307,47 @@ const vt = Y((t) => {
486
307
  "jshtm",
487
308
  "volt",
488
309
  "rhtml"
489
- ], jt = I(we), qt = {
490
- [jt]: {
310
+ ], Nt = I(Ce), jt = {
311
+ [Nt]: {
491
312
  category: "Global",
492
313
  type: "string",
493
314
  array: !0,
494
- default: [{ value: [...At] }],
315
+ default: [{ value: [...Ct] }],
495
316
  description: "Specify embedded HTML language identifiers."
496
317
  }
497
- }, Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
318
+ }, At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
498
319
  __proto__: null,
499
- embeddedLanguage: we,
320
+ embeddedLanguage: Ce,
500
321
  embedder: Ft,
501
- options: qt
502
- }, Symbol.toStringTag, { value: "Module" })), Fe = "embeddedMarkdown", { line: fe, group: N, indent: he, softline: be } = $, Wt = async (t, n, r, e, s) => {
322
+ options: jt
323
+ }, Symbol.toStringTag, { value: "Module" })), Ne = "embeddedMarkdown", { line: ge, group: M, indent: pe, softline: fe } = $, qt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
503
324
  e = {
504
325
  ...e,
505
- ...T(e.embeddedOverrides, s)
326
+ ...o
506
327
  };
507
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k(), a = o.quasis.map(
508
- (m, p, { length: f }) => p === f - 1 ? m.value.cooked : m.value.cooked + d(p)
509
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = L(r, n), h = await t(a, {
328
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k(), l = a.quasis.map(
329
+ (f, h, { length: p }) => h === p - 1 ? f.value.cooked : f.value.cooked + i(h)
330
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = O(r, n), b = await t(l, {
510
331
  ...e,
511
332
  parser: "markdown",
512
333
  __inJsTemplate: !0
513
- }), u = D(h, i, y);
334
+ }), d = T(b, c, _);
514
335
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
515
- return N([
336
+ return M([
516
337
  "`",
517
- l,
518
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [N(u)] : he([N(u)]),
519
- g,
338
+ u,
339
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [M(d)] : pe([M(d)]),
340
+ m,
520
341
  "`"
521
342
  ]);
522
- const c = l.length ? fe : be, b = g.length ? fe : be;
523
- return N([
343
+ const g = u.length ? ge : fe, y = m.length ? ge : fe;
344
+ return M([
524
345
  "`",
525
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [c, N(u)] : he([c, N(u)]),
526
- b,
346
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [g, M(d)] : pe([g, M(d)]),
347
+ y,
527
348
  "`"
528
349
  ]);
529
- }, Kt = [
350
+ }, Bt = [
530
351
  "md",
531
352
  "livemd",
532
353
  "markdown",
@@ -538,74 +359,74 @@ const vt = Y((t) => {
538
359
  "ronn",
539
360
  "scd",
540
361
  "workbook"
541
- ], zt = I(Fe), Ut = {
542
- [zt]: {
362
+ ], Wt = I(Ne), Kt = {
363
+ [Wt]: {
543
364
  category: "Global",
544
365
  type: "string",
545
366
  array: !0,
546
- default: [{ value: [...Kt] }],
367
+ default: [{ value: [...Bt] }],
547
368
  description: "Specify embedded Markdown language identifiers."
548
369
  }
549
- }, Gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
370
+ }, Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
550
371
  __proto__: null,
551
- embeddedLanguage: Fe,
552
- embedder: Wt,
553
- options: Ut
554
- }, Symbol.toStringTag, { value: "Module" })), J = "embeddedNoop", Ht = I(J), Xt = {
555
- [Ht]: {
372
+ embeddedLanguage: Ne,
373
+ embedder: qt,
374
+ options: Kt
375
+ }, Symbol.toStringTag, { value: "Module" })), Y = "embeddedNoop", zt = I(Y), Gt = {
376
+ [zt]: {
556
377
  category: "Global",
557
378
  type: "string",
558
379
  array: !0,
559
380
  default: [{ value: [] }],
560
381
  description: "Specify embedded language identifiers that will not be formatted."
561
382
  }
562
- }, Yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
383
+ }, Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
563
384
  __proto__: null,
564
- embeddedLanguage: J,
565
- options: Xt
566
- }, Symbol.toStringTag, { value: "Module" })), Ae = "embeddedPhp", { line: ye, group: w, indent: ve, softline: _e } = $, Vt = async (t, n, r, e, s) => {
567
- B("@prettier/plugin-php", e, s), e = {
385
+ embeddedLanguage: Y,
386
+ options: Gt
387
+ }, Symbol.toStringTag, { value: "Module" })), je = "embeddedPhp", { line: he, group: F, indent: be, softline: ye } = $, Xt = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
388
+ q("@prettier/plugin-php", e, s), e = {
568
389
  ...e,
569
- ...T(e.embeddedOverrides, s)
390
+ ...o
570
391
  };
571
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k("$p"), a = o.quasis.map(
572
- (p, f, { length: _ }) => f === _ - 1 ? p.value.cooked : p.value.cooked + d(f)
573
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = a.slice(
574
- l.length,
575
- -g.length || void 0
576
- ), h = L(r, n), u = await t(y, {
392
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k("$p"), l = a.quasis.map(
393
+ (h, p, { length: v }) => p === v - 1 ? h.value.cooked : h.value.cooked + i(p)
394
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = l.slice(
395
+ u.length,
396
+ -m.length || void 0
397
+ ), b = O(r, n), d = await t(_, {
577
398
  ...e,
578
399
  parser: "php"
579
- }), c = D(u, i, h);
400
+ }), g = T(d, c, b);
580
401
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
581
- return w([
402
+ return F([
582
403
  "`",
583
- l,
584
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [w(c)] : ve([w(c)]),
585
- g,
404
+ u,
405
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [F(g)] : be([F(g)]),
406
+ m,
586
407
  "`"
587
408
  ]);
588
- const b = l.length ? ye : _e, m = g.length ? ye : _e;
589
- return w([
409
+ const y = u.length ? he : ye, f = m.length ? he : ye;
410
+ return F([
590
411
  "`",
591
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [b, w(c)] : ve([b, w(c)]),
592
- m,
412
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [y, F(g)] : be([y, F(g)]),
413
+ f,
593
414
  "`"
594
415
  ]);
595
- }, Jt = ["php", "php5", "phtml", "ctp"], Qt = I(Ae), Zt = {
596
- [Qt]: {
416
+ }, Jt = ["php", "php5", "phtml", "ctp"], Yt = I(je), Vt = {
417
+ [Yt]: {
597
418
  category: "Global",
598
419
  type: "string",
599
420
  array: !0,
600
421
  default: [{ value: [...Jt] }],
601
422
  description: 'Specify embedded PHP language identifiers. This requires "@prettier/plugin-php".'
602
423
  }
603
- }, en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
424
+ }, Qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
604
425
  __proto__: null,
605
- embeddedLanguage: Ae,
606
- embedder: Vt,
607
- options: Zt
608
- }, Symbol.toStringTag, { value: "Module" })), je = "embeddedRuby", K = [
426
+ embeddedLanguage: je,
427
+ embedder: Xt,
428
+ options: Vt
429
+ }, Symbol.toStringTag, { value: "Module" })), Ae = "embeddedRuby", K = [
609
430
  "ruby",
610
431
  "arb",
611
432
  "axlsx",
@@ -631,87 +452,87 @@ const vt = Y((t) => {
631
452
  "ru",
632
453
  "thor",
633
454
  "watchr"
634
- ], z = ["rbs"], U = ["haml"], tn = [
455
+ ], U = ["rbs"], z = ["haml"], Zt = [
635
456
  ...K,
636
- ...z,
637
- ...U
638
- ], nn = "embeddedRubyParser", rn = I(je), sn = {
639
- [rn]: {
457
+ ...U,
458
+ ...z
459
+ ], en = "embeddedRubyParser", tn = I(Ae), nn = {
460
+ [tn]: {
640
461
  category: "Global",
641
462
  type: "string",
642
463
  array: !0,
643
- default: [{ value: [...tn] }],
464
+ default: [{ value: [...Zt] }],
644
465
  description: 'Specify embedded Ruby language identifiers. This requires "@prettier/plugin-ruby".'
645
466
  },
646
- [nn]: {
467
+ [en]: {
647
468
  category: "Global",
648
469
  type: "string",
649
470
  array: !1,
650
471
  default: void 0,
651
472
  description: "Specify the embedded Ruby language parser."
652
473
  }
653
- }, { line: Ee, group: F, indent: xe, softline: $e } = $, on = async (t, n, r, e, s, o) => {
654
- B("@prettier/plugin-ruby", e, s), e = {
474
+ }, { line: ve, group: C, indent: _e, softline: Ee } = $, rn = async (t, n, r, e, { identifier: s, identifiers: o, embeddedOverrideOptions: a }) => {
475
+ q("@prettier/plugin-ruby", e, s), e = {
655
476
  ...e,
656
- ...T(e.embeddedOverrides, s)
477
+ ...a
657
478
  };
658
- const { node: d } = r, { createPlaceholder: i, placeholderRegex: a } = k(), l = d.quasis.map(
659
- (_, v, { length: x }) => v === x - 1 ? _.value.cooked : _.value.cooked + i(v)
660
- ).join(""), g = l.match(/^\s+/)?.[0] ?? "", y = l.match(/\s+$/)?.[0] ?? "", h = l.slice(
661
- g.length,
662
- -y.length || void 0
663
- ), u = L(r, n), c = an(e, s, o), b = await t(h, {
479
+ const { node: i } = r, { createPlaceholder: c, placeholderRegex: l } = k(), u = i.quasis.map(
480
+ (v, E, { length: x }) => E === x - 1 ? v.value.cooked : v.value.cooked + c(E)
481
+ ).join(""), m = u.match(/^\s+/)?.[0] ?? "", _ = u.match(/\s+$/)?.[0] ?? "", b = u.slice(
482
+ m.length,
483
+ -_.length || void 0
484
+ ), d = O(r, n), g = sn(e, s, o), y = await t(b, {
664
485
  ...e,
665
- parser: c
666
- }), m = D(b, a, u);
486
+ parser: g
487
+ }), f = T(y, l, d);
667
488
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
668
- return F([
489
+ return C([
669
490
  "`",
670
- g,
671
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [F(m)] : xe([F(m)]),
672
- y,
491
+ m,
492
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [C(f)] : _e([C(f)]),
493
+ _,
673
494
  "`"
674
495
  ]);
675
- const p = g.length ? Ee : $e, f = y.length ? Ee : $e;
676
- return F([
496
+ const h = m.length ? ve : Ee, p = _.length ? ve : Ee;
497
+ return C([
677
498
  "`",
678
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [p, F(m)] : xe([p, F(m)]),
679
- f,
499
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [h, C(f)] : _e([h, C(f)]),
500
+ p,
680
501
  "`"
681
502
  ]);
682
503
  };
683
- function an(t, n, r) {
504
+ function sn(t, n, r) {
684
505
  if (typeof t.embeddedRubyParser == "string")
685
506
  return t.embeddedRubyParser;
686
507
  const e = r.indexOf(n);
687
508
  for (let s = e; s >= 0; --s) {
688
- if (dn(n))
509
+ if (on(n))
689
510
  return K[0];
690
- if (cn(n))
691
- return z[0];
692
- if (ln(n))
511
+ if (an(n))
693
512
  return U[0];
513
+ if (dn(n))
514
+ return z[0];
694
515
  }
695
516
  throw new SyntaxError(`Unrecognized ruby identifier: ${n}`);
696
517
  }
697
- function dn(t) {
518
+ function on(t) {
698
519
  return K.includes(t);
699
520
  }
700
- function cn(t) {
701
- return z.includes(t);
702
- }
703
- function ln(t) {
521
+ function an(t) {
704
522
  return U.includes(t);
705
523
  }
706
- const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
524
+ function dn(t) {
525
+ return z.includes(t);
526
+ }
527
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
707
528
  __proto__: null,
708
- HAML_PARSER_IDENTIFIERS: U,
709
- RBS_PARSER_IDENTIFIERS: z,
529
+ HAML_PARSER_IDENTIFIERS: z,
530
+ RBS_PARSER_IDENTIFIERS: U,
710
531
  RUBY_PARSER_IDENTIFIERS: K,
711
- embeddedLanguage: je,
712
- embedder: on,
713
- options: sn
714
- }, Symbol.toStringTag, { value: "Module" })), qe = "embeddedSql", Be = [
532
+ embeddedLanguage: Ae,
533
+ embedder: rn,
534
+ options: nn
535
+ }, Symbol.toStringTag, { value: "Module" })), qe = "embeddedSql", H = [
715
536
  "sql",
716
537
  "bigquery",
717
538
  "db2",
@@ -730,7 +551,7 @@ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
730
551
  "transactsql",
731
552
  "tsql",
732
553
  "trino"
733
- ], We = [
554
+ ], Be = [
734
555
  "bigquery",
735
556
  "db2",
736
557
  "hive",
@@ -740,8 +561,8 @@ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
740
561
  "transactsql",
741
562
  "flinksql",
742
563
  "snowflake"
743
- ], gn = I(qe), mn = {
744
- [gn]: {
564
+ ], ln = I(qe), un = {
565
+ [ln]: {
745
566
  category: "Global",
746
567
  type: "string",
747
568
  array: !0,
@@ -749,66 +570,63 @@ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
749
570
  default: [{ value: ["sql", "mysql", "mariadb", "postgresql"] }],
750
571
  description: 'Specify embedded SQL language identifiers. This requires "prettier-plugin-sql".'
751
572
  }
752
- }, { hardline: pn, group: A, line: Ie, softline: Se, indent: Oe } = $, { mapDoc: fn } = X, hn = async (t, n, r, e, s, o) => {
753
- B("prettier-plugin-sql", e, s);
754
- const d = T(
755
- e.embeddedOverrides,
756
- s
757
- );
758
- e = {
573
+ }, { hardline: mn, group: N, line: xe, softline: $e, indent: Ie } = $, { mapDoc: gn } = X, pn = async (t, n, r, e, { identifier: s, identifiers: o, embeddedOverrideOptions: a }) => {
574
+ q("prettier-plugin-sql", e, s), e = {
759
575
  ...e,
760
- ...d
576
+ ...a
761
577
  };
762
- const { node: i } = r, { createPlaceholder: a, placeholderRegex: l } = k(), g = i.quasis.map(
763
- (_, v, { length: x }) => v === x - 1 ? _.value.cooked : _.value.cooked + a(v)
764
- ).join(""), y = g.match(/^\s+/)?.[0] ?? "", h = g.match(/\s+$/)?.[0] ?? "", u = L(r, n), c = yn(e, s, o);
765
- if (typeof c > "u")
578
+ const { node: i } = r, { createPlaceholder: c, placeholderRegex: l } = k(), u = i.quasis.map(
579
+ (p, v, { length: E }) => v === E - 1 ? p.value.cooked : p.value.cooked + c(v)
580
+ ).join(""), m = u.match(/^\s+/)?.[0] ?? "", _ = u.match(/\s+$/)?.[0] ?? "", b = O(r, n), d = hn(e, s, o);
581
+ if (typeof d > "u")
766
582
  throw new SyntaxError(`Unrecognized identifier: ${s}`);
767
- const b = await t(g, {
583
+ const g = await t(u, {
768
584
  ...e,
769
585
  parser: "sql",
770
- ...c,
771
- ...d
772
- }), m = fn(b, (_) => {
773
- if (typeof _ != "string")
774
- return _;
775
- const v = [], x = _.split(l);
776
- for (let E = 0; E < x.length; E++) {
777
- let S = x[E];
778
- if (E % 2 == 0) {
586
+ ...d,
587
+ ...a
588
+ }), y = gn(g, (p) => {
589
+ if (typeof p != "string")
590
+ return p;
591
+ const v = [], E = p.split(l);
592
+ for (let x = 0; x < E.length; x++) {
593
+ let S = E[x];
594
+ if (x % 2 == 0) {
779
595
  if (!S)
780
596
  continue;
781
- S = S.replaceAll(/([\\`]|\${)/g, "\\$1"), S.split(/(\n)/).forEach((O) => O === `
782
- ` ? v.push(pn) : v.push(O));
597
+ S = S.replaceAll(/([\\`]|\${)/g, "\\$1"), S.split(/(\n)/).forEach((L) => L === `
598
+ ` ? v.push(mn) : v.push(L));
783
599
  } else {
784
- const O = Number(S);
785
- v.push(u[O]);
600
+ const L = Number(S);
601
+ v.push(b[L]);
786
602
  }
787
603
  }
788
604
  return v;
789
605
  });
790
606
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
791
- return A([
607
+ return N([
792
608
  "`",
793
- y,
794
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [A(m)] : Oe([A(m)]),
795
- h,
609
+ m,
610
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [N(y)] : Ie([N(y)]),
611
+ _,
796
612
  "`"
797
613
  ]);
798
- const p = y.length ? Ie : Se, f = h.length ? Ie : Se;
799
- return A([
614
+ const f = m.length ? xe : $e, h = _.length ? xe : $e;
615
+ return N([
800
616
  "`",
801
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [p, A(m)] : Oe([p, A(m)]),
802
- f,
617
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [f, N(y)] : Ie([f, N(y)]),
618
+ h,
803
619
  "`"
804
620
  ]);
805
- }, bn = {
806
- "sql-formatter": (t) => Be.includes(t),
807
- "node-sql-parser": (t) => We.includes(t)
621
+ }, fn = {
622
+ "sql-formatter": (t) => H.includes(t),
623
+ "node-sql-parser": (t) => Be.includes(t),
624
+ // TODO: This seems not implemented yet
625
+ "sql-cst": (t) => H.includes(t)
808
626
  };
809
- function Le(t, n) {
627
+ function Se(t, n) {
810
628
  for (const r of n)
811
- if (bn[r](t))
629
+ if (fn[r](t))
812
630
  switch (r) {
813
631
  case "sql-formatter":
814
632
  return {
@@ -822,255 +640,146 @@ function Le(t, n) {
822
640
  };
823
641
  }
824
642
  }
825
- function G(t, n, r) {
826
- let e = Le(t, r);
643
+ function B(t, n, r) {
644
+ let e = Se(t, r);
827
645
  if (e)
828
646
  return e;
829
647
  const s = n.indexOf(t);
830
648
  for (let o = s - 1; o >= 0; --o)
831
- if (e = Le(
649
+ if (e = Se(
832
650
  n[o],
833
651
  r
834
652
  ), e)
835
653
  return e;
836
654
  }
837
- function yn(t, n, r) {
655
+ function hn(t, n, r) {
838
656
  switch (t.formatter ?? "sql-formatter") {
839
657
  case "sql-formatter":
840
- return G(
658
+ return B(
841
659
  n,
842
660
  r,
843
661
  ["sql-formatter", "node-sql-parser"]
844
662
  );
845
663
  case "node-sql-parser":
846
- return G(
664
+ return B(
847
665
  n,
848
666
  r,
849
667
  ["node-sql-parser", "sql-formatter"]
850
668
  );
669
+ case "sql-cst":
670
+ return B(
671
+ n,
672
+ r,
673
+ ["sql-formatter", "node-sql-parser"]
674
+ );
851
675
  default:
852
- return G(
676
+ return B(
853
677
  n,
854
678
  r,
855
679
  ["sql-formatter", "node-sql-parser"]
856
680
  );
857
681
  }
858
682
  }
859
- const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
683
+ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
860
684
  __proto__: null,
861
- NODE_SQL_PARSER_DATABASES: We,
862
- SQL_FORMATTER_LANGUAGES: Be,
685
+ NODE_SQL_PARSER_DATABASES: Be,
686
+ SQL_FORMATTER_LANGUAGES: H,
863
687
  embeddedLanguage: qe,
864
- embedder: hn,
865
- options: mn
866
- }, Symbol.toStringTag, { value: "Module" })), Ke = "embeddedTs", { line: ke, group: j, indent: Te, softline: De } = $, _n = async (t, n, r, e, s) => {
688
+ embedder: pn,
689
+ options: un
690
+ }, Symbol.toStringTag, { value: "Module" })), We = "embeddedTs", { line: Le, group: j, indent: Oe, softline: ke } = $, yn = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
867
691
  e = {
868
692
  ...e,
869
- ...T(e.embeddedOverrides, s)
693
+ ...o
870
694
  };
871
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k(), a = o.quasis.map(
872
- (m, p, { length: f }) => p === f - 1 ? m.value.cooked : m.value.cooked + d(p)
873
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = L(r, n), h = await t(a, {
695
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k(), l = a.quasis.map(
696
+ (f, h, { length: p }) => h === p - 1 ? f.value.cooked : f.value.cooked + i(h)
697
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = O(r, n), b = await t(l, {
874
698
  ...e,
875
699
  parser: e.embeddedTsParser ?? "typescript",
876
700
  // set filepath to undefined to enable jsx auto detection:
877
701
  // https://github.com/prettier/prettier/blob/427a84d24203e2d54160cde153a1e6a6390fe65a/src/language-js/parse/typescript.js#L49-L53
878
702
  filepath: void 0
879
- }), u = D(h, i, y);
703
+ }), d = T(b, c, _);
880
704
  if (e.preserveEmbeddedExteriorWhitespaces?.includes(s))
881
705
  return j([
882
706
  "`",
883
- l,
884
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [j(u)] : Te([j(u)]),
885
- g,
707
+ u,
708
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [j(d)] : Oe([j(d)]),
709
+ m,
886
710
  "`"
887
711
  ]);
888
- const c = l.length ? ke : De, b = g.length ? ke : De;
712
+ const g = u.length ? Le : ke, y = m.length ? Le : ke;
889
713
  return j([
890
714
  "`",
891
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [c, j(u)] : Te([c, j(u)]),
892
- b,
715
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [g, j(d)] : Oe([g, j(d)]),
716
+ y,
893
717
  "`"
894
718
  ]);
895
- }, En = ["ts", "tsx", "cts", "mts", "typescript"], xn = "embeddedTsParser", $n = I(Ke), In = {
896
- [$n]: {
719
+ }, vn = ["ts", "tsx", "cts", "mts", "typescript"], _n = "embeddedTsParser", En = I(We), xn = {
720
+ [En]: {
897
721
  category: "Global",
898
722
  type: "string",
899
723
  array: !0,
900
- default: [{ value: [...En] }],
724
+ default: [{ value: [...vn] }],
901
725
  description: "Specify embedded TS language parsers."
902
726
  },
903
- [xn]: {
727
+ [_n]: {
904
728
  category: "Global",
905
729
  type: "string",
906
730
  array: !1,
907
731
  default: "typescript",
908
732
  description: "Specify the embedded TS language parser."
909
733
  }
910
- }, Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
734
+ }, $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
911
735
  __proto__: null,
912
- embeddedLanguage: Ke,
913
- embedder: _n,
914
- options: In
915
- }, Symbol.toStringTag, { value: "Module" })), Q = "embeddedXml";
916
- function On(t) {
917
- const n = {
918
- loc: {
919
- start: {
920
- line: t.line,
921
- column: t.column
922
- },
923
- end: {
924
- line: t.line,
925
- column: t.column + t.length
926
- }
927
- }
928
- }, r = new SyntaxError(
929
- `${t.message} (${n.loc.start.line}:${n.loc.start.column})`,
930
- {
931
- cause: t
932
- }
933
- );
934
- return Object.assign(r, n), r;
935
- }
936
- function Re(t) {
937
- const n = {
938
- loc: {
939
- start: {
940
- line: t.token.startLine ?? NaN,
941
- column: t.token.startColumn ?? NaN
942
- },
943
- end: {
944
- line: t.token.endLine ?? NaN,
945
- column: t.token.endColumn ?? NaN
946
- }
947
- }
948
- }, r = new SyntaxError(
949
- `${t.message} (${n.loc.start.line}:${n.loc.start.column})`,
950
- {
951
- cause: t
952
- }
953
- );
954
- return Object.assign(r, n), r;
955
- }
956
- const Ln = {
957
- async parse(t, n) {
958
- const { parse: r } = await import("@xml-tools/parser"), { lexErrors: e, parseErrors: s, cst: o } = r(t);
959
- if (e.length > 0) {
960
- const d = e[0];
961
- throw On(d);
962
- }
963
- if (s.length > 0) {
964
- let d = !1;
965
- for (const i of s) {
966
- if (!["MismatchedTokenException", "NotAllInputParsedException"].includes(
967
- i.name
968
- ))
969
- throw Re(i);
970
- if (i.message === "Expecting token of type --> OPEN <-- but found --> '' <--") {
971
- d = !0;
972
- continue;
973
- }
974
- if (/Expecting token of type --> EOF <-- but found --> '[\s\S]+' <--/.test(
975
- i.message
976
- ) || /Redundant input, expecting EOF but found: /.test(i.message)) {
977
- n.__embeddedXmlFragmentRecoverIndex?.splice(
978
- 0,
979
- n.__embeddedXmlFragmentRecoverIndex.length,
980
- i.token.startOffset
981
- );
982
- break;
983
- }
984
- if (/Expecting token of type --> OPEN <-- but found --> '[\s\S]+' <--/.test(
985
- i.message
986
- )) {
987
- if (i.token.endOffset === void 0 || Number.isNaN(i.token.endOffset))
988
- break;
989
- n.__embeddedXmlFragmentRecoverIndex?.splice(
990
- 0,
991
- n.__embeddedXmlFragmentRecoverIndex.length,
992
- i.token.startOffset,
993
- i.token.endOffset
994
- ), d = !0;
995
- break;
996
- }
997
- throw Re(i);
998
- }
999
- d && ze(o);
1000
- }
1001
- return o;
1002
- },
1003
- astFormat: "xml",
1004
- locStart(t) {
1005
- return t.location.startOffset;
1006
- },
1007
- locEnd(t) {
1008
- return t.location.endOffset ?? NaN;
1009
- }
1010
- };
1011
- function ze(t) {
1012
- const n = t.children;
1013
- for (const r in n) {
1014
- const e = n[r] ?? [];
1015
- for (let s = e.length - 1; s >= 0; --s) {
1016
- const o = e[s];
1017
- if (kn(o)) {
1018
- if (Object.keys(o.children).length === 0) {
1019
- e.splice(s, 1), e.length === 0 && delete n[r];
1020
- continue;
1021
- }
1022
- ze(o);
1023
- }
1024
- }
1025
- }
1026
- }
1027
- function kn(t) {
1028
- return "name" in t && "children" in t && "location" in t;
1029
- }
1030
- const { line: Pe, group: q, indent: Me, softline: H } = $, Tn = async (t, n, r, e, s) => {
1031
- B("@prettier/plugin-xml", e, s), e = {
736
+ embeddedLanguage: We,
737
+ embedder: yn,
738
+ options: xn
739
+ }, Symbol.toStringTag, { value: "Module" })), V = "embeddedXml", { line: Te, group: A, indent: De, softline: G } = $, In = async (t, n, r, e, { identifier: s, embeddedOverrideOptions: o }) => {
740
+ q("@prettier/plugin-xml", e, s), e = {
1032
741
  ...e,
1033
- ...T(e.embeddedOverrides, s)
742
+ ...o
1034
743
  };
1035
- const { node: o } = r, { createPlaceholder: d, placeholderRegex: i } = k(), a = o.quasis.map(
1036
- (f, _, { length: v }) => _ === v - 1 ? f.value.cooked : f.value.cooked + d(_)
1037
- ).join(""), l = a.match(/^\s+/)?.[0] ?? "", g = a.match(/\s+$/)?.[0] ?? "", y = a.slice(
1038
- l.length,
1039
- -g.length || void 0
1040
- ), h = L(r, n), u = [];
1041
- let c = 0;
1042
- for (; c !== void 0; ) {
1043
- const f = y.slice(c);
1044
- if (f.length === 0)
744
+ const { node: a } = r, { createPlaceholder: i, placeholderRegex: c } = k(), l = a.quasis.map(
745
+ (p, v, { length: E }) => v === E - 1 ? p.value.cooked : p.value.cooked + i(v)
746
+ ).join(""), u = l.match(/^\s+/)?.[0] ?? "", m = l.match(/\s+$/)?.[0] ?? "", _ = l.slice(
747
+ u.length,
748
+ -m.length || void 0
749
+ ), b = O(r, n), d = [];
750
+ let g = 0;
751
+ for (; g !== void 0; ) {
752
+ const p = _.slice(g);
753
+ if (p.length === 0)
1045
754
  break;
1046
- c > 0 && e.xmlWhitespaceSensitivity !== "strict" && u.push(H), e.__embeddedXmlFragmentRecoverIndex?.splice(
755
+ g > 0 && e.xmlWhitespaceSensitivity !== "strict" && d.push(G), e.__embeddedXmlFragmentRecoverIndex?.splice(
1047
756
  0,
1048
757
  e.__embeddedXmlFragmentRecoverIndex.length
1049
758
  );
1050
- let _ = await t(f, {
759
+ let v = await t(p, {
1051
760
  ...e,
1052
- parser: Q
761
+ parser: V
1053
762
  });
1054
- const [v, x] = e.__embeddedXmlFragmentRecoverIndex ?? [];
1055
- v === void 0 ? c = void 0 : x === void 0 ? c += v : (_ = f.slice(v, x + 1), c += x + 1), u.push(_);
763
+ const [E, x] = e.__embeddedXmlFragmentRecoverIndex ?? [];
764
+ E === void 0 ? g = void 0 : x === void 0 ? g += E : (v = p.slice(E, x + 1), g += x + 1), d.push(v);
1056
765
  }
1057
- const b = D(u, i, h);
766
+ const y = T(d, c, b);
1058
767
  if (e.xmlWhitespaceSensitivity === "strict" || e.preserveEmbeddedExteriorWhitespaces?.includes(s))
1059
- return q([
768
+ return A([
1060
769
  "`",
1061
- l,
1062
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [q(b)] : Me([q(b)]),
1063
- g,
770
+ u,
771
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [A(y)] : De([A(y)]),
772
+ m,
1064
773
  "`"
1065
774
  ]);
1066
- const m = l.length ? Pe : H, p = g.length ? Pe : H;
1067
- return q([
775
+ const f = u.length ? Te : G, h = m.length ? Te : G;
776
+ return A([
1068
777
  "`",
1069
- e.noEmbeddedMultiLineIndentation?.includes(s) ? [m, q(b)] : Me([m, q(b)]),
1070
- p,
778
+ e.noEmbeddedMultiLineIndentation?.includes(s) ? [f, A(y)] : De([f, A(y)]),
779
+ h,
1071
780
  "`"
1072
781
  ]);
1073
- }, Dn = [
782
+ }, Sn = [
1074
783
  "xml",
1075
784
  "xsd",
1076
785
  "ascx",
@@ -1127,12 +836,12 @@ const { line: Pe, group: q, indent: Me, softline: H } = $, Tn = async (t, n, r,
1127
836
  "xpdl",
1128
837
  "xul",
1129
838
  "xoml"
1130
- ], Rn = I(Q), Pn = {
1131
- [Rn]: {
839
+ ], Ln = I(V), On = {
840
+ [Ln]: {
1132
841
  category: "Global",
1133
842
  type: "string",
1134
843
  array: !0,
1135
- default: [{ value: [...Dn] }],
844
+ default: [{ value: [...Sn] }],
1136
845
  description: 'Specify embedded XML language identifiers. This requires "@prettier/plugin-xml".'
1137
846
  },
1138
847
  /** @internal */
@@ -1143,84 +852,437 @@ const { line: Pe, group: q, indent: Me, softline: H } = $, Tn = async (t, n, r,
1143
852
  default: [{ value: [] }],
1144
853
  description: "This option is read only and used as a workaround to support xml fragments"
1145
854
  }
1146
- }, Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
855
+ };
856
+ function kn(t) {
857
+ const n = {
858
+ loc: {
859
+ start: {
860
+ line: t.line,
861
+ column: t.column
862
+ },
863
+ end: {
864
+ line: t.line,
865
+ column: t.column + t.length
866
+ }
867
+ }
868
+ }, r = new SyntaxError(
869
+ `${t.message} (${n.loc.start.line}:${n.loc.start.column})`,
870
+ {
871
+ cause: t
872
+ }
873
+ );
874
+ return Object.assign(r, n), r;
875
+ }
876
+ function we(t) {
877
+ const n = {
878
+ loc: {
879
+ start: {
880
+ line: t.token.startLine ?? NaN,
881
+ column: t.token.startColumn ?? NaN
882
+ },
883
+ end: {
884
+ line: t.token.endLine ?? NaN,
885
+ column: t.token.endColumn ?? NaN
886
+ }
887
+ }
888
+ }, r = new SyntaxError(
889
+ `${t.message} (${n.loc.start.line}:${n.loc.start.column})`,
890
+ {
891
+ cause: t
892
+ }
893
+ );
894
+ return Object.assign(r, n), r;
895
+ }
896
+ const Tn = {
897
+ async parse(t, n) {
898
+ const { parse: r } = await import("@xml-tools/parser"), { lexErrors: e, parseErrors: s, cst: o } = r(t);
899
+ if (e.length > 0) {
900
+ const a = e[0];
901
+ throw kn(a);
902
+ }
903
+ if (s.length > 0) {
904
+ let a = !1;
905
+ for (const i of s) {
906
+ if (!["MismatchedTokenException", "NotAllInputParsedException"].includes(
907
+ i.name
908
+ ))
909
+ throw we(i);
910
+ if (i.message === "Expecting token of type --> OPEN <-- but found --> '' <--") {
911
+ a = !0;
912
+ continue;
913
+ }
914
+ if (/Expecting token of type --> EOF <-- but found --> '[\s\S]+' <--/.test(
915
+ i.message
916
+ ) || /Redundant input, expecting EOF but found: /.test(i.message)) {
917
+ n.__embeddedXmlFragmentRecoverIndex?.splice(
918
+ 0,
919
+ n.__embeddedXmlFragmentRecoverIndex.length,
920
+ i.token.startOffset
921
+ );
922
+ break;
923
+ }
924
+ if (/Expecting token of type --> OPEN <-- but found --> '[\s\S]+' <--/.test(
925
+ i.message
926
+ )) {
927
+ if (i.token.endOffset === void 0 || Number.isNaN(i.token.endOffset))
928
+ break;
929
+ n.__embeddedXmlFragmentRecoverIndex?.splice(
930
+ 0,
931
+ n.__embeddedXmlFragmentRecoverIndex.length,
932
+ i.token.startOffset,
933
+ i.token.endOffset
934
+ ), a = !0;
935
+ break;
936
+ }
937
+ throw we(i);
938
+ }
939
+ a && Ke(o);
940
+ }
941
+ return o;
942
+ },
943
+ astFormat: "xml",
944
+ locStart(t) {
945
+ return t.location.startOffset;
946
+ },
947
+ locEnd(t) {
948
+ return t.location.endOffset ?? NaN;
949
+ }
950
+ };
951
+ function Ke(t) {
952
+ const n = t.children;
953
+ for (const r in n) {
954
+ const e = n[r] ?? [];
955
+ for (let s = e.length - 1; s >= 0; --s) {
956
+ const o = e[s];
957
+ if (Dn(o)) {
958
+ if (Object.keys(o.children).length === 0) {
959
+ e.splice(s, 1), e.length === 0 && delete n[r];
960
+ continue;
961
+ }
962
+ Ke(o);
963
+ }
964
+ }
965
+ }
966
+ }
967
+ function Dn(t) {
968
+ return "name" in t && "children" in t && "location" in t;
969
+ }
970
+ const wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1147
971
  __proto__: null,
1148
- embeddedLanguage: Q,
1149
- embedder: Tn,
1150
- options: Pn,
1151
- parser: Ln
1152
- }, Symbol.toStringTag, { value: "Module" })), Ue = [], Ge = {}, He = {}, Xe = {}, Cn = /* @__PURE__ */ Object.assign({
1153
- "./css/index.ts": It,
1154
- "./es/index.ts": Dt,
1155
- "./glsl/index.ts": Nt,
1156
- "./html/index.ts": Bt,
1157
- "./markdown/index.ts": Gt,
1158
- "./noop/index.ts": Yt,
1159
- "./php/index.ts": en,
1160
- "./ruby/index.ts": un,
1161
- "./sql/index.ts": vn,
1162
- "./ts/index.ts": Sn,
1163
- "./xml/index.ts": Mn
972
+ embeddedLanguage: V,
973
+ embedder: In,
974
+ options: On,
975
+ parser: Tn
976
+ }, Symbol.toStringTag, { value: "Module" })), Ue = [], ze = {}, Ge = {}, He = {}, Pn = /* @__PURE__ */ Object.assign({
977
+ "./css/index.ts": xt,
978
+ "./es/index.ts": kt,
979
+ "./glsl/index.ts": Rt,
980
+ "./html/index.ts": At,
981
+ "./markdown/index.ts": Ut,
982
+ "./noop/index.ts": Ht,
983
+ "./php/index.ts": Qt,
984
+ "./ruby/index.ts": cn,
985
+ "./sql/index.ts": bn,
986
+ "./ts/index.ts": $n,
987
+ "./xml/index.ts": wn
1164
988
  });
1165
- Object.values(Cn).forEach(
989
+ Object.values(Pn).forEach(
1166
990
  ({ embeddedLanguage: t, parser: n, embedder: r, options: e }) => {
1167
- bt(Ue, t, J), n && (Ge[t] = n), r && (He[t] = r), Object.assign(Xe, e);
991
+ ht(Ue, t, Y), n && (ze[t] = n), r && (Ge[t] = r), Object.assign(He, e);
1168
992
  }
1169
993
  );
1170
- const Qn = {
994
+ const Rn = "noEmbeddedIdentificationByComment", Mn = "noEmbeddedIdentificationByTag", Fn = "preserveEmbeddedExteriorWhitespaces", Cn = "noEmbeddedMultiLineIndentation", Nn = "embeddedOverrides", lr = {
995
+ ...He,
996
+ [Rn]: {
997
+ category: "Global",
998
+ type: "string",
999
+ array: !0,
1000
+ default: [{ value: [] }],
1001
+ description: 'This option turns off "/* identifier */ `...`" comment-based language identification for the specified identifiers.'
1002
+ },
1003
+ [Mn]: {
1004
+ category: "Global",
1005
+ type: "string",
1006
+ array: !0,
1007
+ default: [{ value: [] }],
1008
+ description: 'This option turns off "identifier`...`" tag-based language identification for the specified identifiers.'
1009
+ },
1010
+ [Fn]: {
1011
+ category: "Config",
1012
+ type: "string",
1013
+ array: !0,
1014
+ default: [{ value: [] }],
1015
+ description: "This option preserves leading and trailing whitespaces in the formatting results for the specified identifiers."
1016
+ },
1017
+ [Cn]: {
1018
+ category: "Global",
1019
+ type: "string",
1020
+ array: !0,
1021
+ default: [{ value: [] }],
1022
+ description: "This option turns off auto indentation in the formatting results for the specified identifiers when they are formatted to span multi lines."
1023
+ },
1024
+ [Nn]: {
1025
+ category: "Global",
1026
+ type: "string",
1027
+ array: !1,
1028
+ default: void 0,
1029
+ description: "This option accepts option overrides for the specified identifiers. It should either be a stringified JSON or an absolute filepath to the option overrides file."
1030
+ }
1031
+ }, ur = {
1171
1032
  // parsers from internal
1172
1033
  ...Qe.parsers,
1173
1034
  ...Ze.parsers,
1174
1035
  ...et.parsers,
1175
- ...tt.parsers,
1176
1036
  ...nt.parsers,
1037
+ ...tt.parsers,
1177
1038
  // parsers from this plugin
1178
- ...Ge
1179
- }, { estree: Ye } = ot, Nn = function(t, n) {
1180
- const { node: r } = t;
1181
- if (r.type !== "TemplateLiteral" || r.quasis.some(({ value: { cooked: e } }) => e === null))
1182
- return null;
1183
- for (const e of Ue) {
1184
- const s = n[I(e)];
1185
- if (!s)
1186
- continue;
1187
- const o = wn(
1188
- t,
1189
- s,
1190
- n.noEmbeddedIdentificationByComment ?? []
1191
- ) ?? Fn(
1192
- t,
1193
- s,
1194
- n.noEmbeddedIdentificationByTag ?? []
1195
- );
1196
- if (o === void 0)
1197
- continue;
1198
- const d = He[e];
1199
- if (!d)
1200
- return null;
1201
- const i = t.node;
1202
- return i.quasis.length === 1 && i.quasis[0].value.raw.trim() === "" ? "``" : async (a, l, g, y) => {
1203
- try {
1204
- const h = await d(
1205
- a,
1206
- l,
1207
- g,
1208
- y,
1209
- o,
1210
- s
1211
- );
1212
- return $.label(
1213
- { embed: !0, ...h.label },
1214
- h
1215
- );
1216
- } catch (h) {
1217
- throw console.error(h), h;
1039
+ ...ze
1040
+ };
1041
+ var jn = {
1042
+ isEqual: !0,
1043
+ isMatchingKey: !0,
1044
+ isPromise: !0,
1045
+ maxSize: !0,
1046
+ onCacheAdd: !0,
1047
+ onCacheChange: !0,
1048
+ onCacheHit: !0,
1049
+ transformKey: !0
1050
+ }, An = Array.prototype.slice;
1051
+ function W(t) {
1052
+ var n = t.length;
1053
+ return n ? n === 1 ? [t[0]] : n === 2 ? [t[0], t[1]] : n === 3 ? [t[0], t[1], t[2]] : An.call(t, 0) : [];
1054
+ }
1055
+ function qn(t) {
1056
+ var n = {};
1057
+ for (var r in t)
1058
+ jn[r] || (n[r] = t[r]);
1059
+ return n;
1060
+ }
1061
+ function Bn(t) {
1062
+ return typeof t == "function" && t.isMemoized;
1063
+ }
1064
+ function Wn(t, n) {
1065
+ return t === n || t !== t && n !== n;
1066
+ }
1067
+ function Pe(t, n) {
1068
+ var r = {};
1069
+ for (var e in t)
1070
+ r[e] = t[e];
1071
+ for (var e in n)
1072
+ r[e] = n[e];
1073
+ return r;
1074
+ }
1075
+ var Kn = (
1076
+ /** @class */
1077
+ function() {
1078
+ function t(n) {
1079
+ this.keys = [], this.values = [], this.options = n;
1080
+ var r = typeof n.isMatchingKey == "function";
1081
+ r ? this.getKeyIndex = this._getKeyIndexFromMatchingKey : n.maxSize > 1 ? this.getKeyIndex = this._getKeyIndexForMany : this.getKeyIndex = this._getKeyIndexForSingle, this.canTransformKey = typeof n.transformKey == "function", this.shouldCloneArguments = this.canTransformKey || r, this.shouldUpdateOnAdd = typeof n.onCacheAdd == "function", this.shouldUpdateOnChange = typeof n.onCacheChange == "function", this.shouldUpdateOnHit = typeof n.onCacheHit == "function";
1082
+ }
1083
+ return Object.defineProperty(t.prototype, "size", {
1084
+ /**
1085
+ * The number of cached [key,value] results.
1086
+ */
1087
+ get: function() {
1088
+ return this.keys.length;
1089
+ },
1090
+ enumerable: !1,
1091
+ configurable: !0
1092
+ }), Object.defineProperty(t.prototype, "snapshot", {
1093
+ /**
1094
+ * A copy of the cache at a moment in time. This is useful
1095
+ * to compare changes over time, since the cache mutates
1096
+ * internally for performance reasons.
1097
+ */
1098
+ get: function() {
1099
+ return {
1100
+ keys: W(this.keys),
1101
+ size: this.size,
1102
+ values: W(this.values)
1103
+ };
1104
+ },
1105
+ enumerable: !1,
1106
+ configurable: !0
1107
+ }), t.prototype._getKeyIndexFromMatchingKey = function(n) {
1108
+ var r = this.options, e = r.isMatchingKey, s = r.maxSize, o = this.keys, a = o.length;
1109
+ if (!a)
1110
+ return -1;
1111
+ if (e(o[0], n))
1112
+ return 0;
1113
+ if (s > 1) {
1114
+ for (var i = 1; i < a; i++)
1115
+ if (e(o[i], n))
1116
+ return i;
1218
1117
  }
1219
- };
1118
+ return -1;
1119
+ }, t.prototype._getKeyIndexForMany = function(n) {
1120
+ var r = this.options.isEqual, e = this.keys, s = e.length;
1121
+ if (!s)
1122
+ return -1;
1123
+ if (s === 1)
1124
+ return this._getKeyIndexForSingle(n);
1125
+ var o = n.length, a, i;
1126
+ if (o > 1) {
1127
+ for (var c = 0; c < s; c++)
1128
+ if (a = e[c], a.length === o) {
1129
+ for (i = 0; i < o && r(a[i], n[i]); i++)
1130
+ ;
1131
+ if (i === o)
1132
+ return c;
1133
+ }
1134
+ } else
1135
+ for (var c = 0; c < s; c++)
1136
+ if (a = e[c], a.length === o && r(a[0], n[0]))
1137
+ return c;
1138
+ return -1;
1139
+ }, t.prototype._getKeyIndexForSingle = function(n) {
1140
+ var r = this.keys;
1141
+ if (!r.length)
1142
+ return -1;
1143
+ var e = r[0], s = e.length;
1144
+ if (n.length !== s)
1145
+ return -1;
1146
+ var o = this.options.isEqual;
1147
+ if (s > 1) {
1148
+ for (var a = 0; a < s; a++)
1149
+ if (!o(e[a], n[a]))
1150
+ return -1;
1151
+ return 0;
1152
+ }
1153
+ return o(e[0], n[0]) ? 0 : -1;
1154
+ }, t.prototype.orderByLru = function(n, r, e) {
1155
+ for (var s = this.keys, o = this.values, a = s.length, i = e; i--; )
1156
+ s[i + 1] = s[i], o[i + 1] = o[i];
1157
+ s[0] = n, o[0] = r;
1158
+ var c = this.options.maxSize;
1159
+ a === c && e === a ? (s.pop(), o.pop()) : e >= c && (s.length = o.length = c);
1160
+ }, t.prototype.updateAsyncCache = function(n) {
1161
+ var r = this, e = this.options, s = e.onCacheChange, o = e.onCacheHit, a = this.keys[0], i = this.values[0];
1162
+ this.values[0] = i.then(function(c) {
1163
+ return r.shouldUpdateOnHit && o(r, r.options, n), r.shouldUpdateOnChange && s(r, r.options, n), c;
1164
+ }, function(c) {
1165
+ var l = r.getKeyIndex(a);
1166
+ throw l !== -1 && (r.keys.splice(l, 1), r.values.splice(l, 1)), c;
1167
+ });
1168
+ }, t;
1169
+ }()
1170
+ );
1171
+ function Xe(t, n) {
1172
+ if (n === void 0 && (n = {}), Bn(t))
1173
+ return Xe(t.fn, Pe(t.options, n));
1174
+ if (typeof t != "function")
1175
+ throw new TypeError("You must pass a function to `memoize`.");
1176
+ var r = n.isEqual, e = r === void 0 ? Wn : r, s = n.isMatchingKey, o = n.isPromise, a = o === void 0 ? !1 : o, i = n.maxSize, c = i === void 0 ? 1 : i, l = n.onCacheAdd, u = n.onCacheChange, m = n.onCacheHit, _ = n.transformKey, b = Pe({
1177
+ isEqual: e,
1178
+ isMatchingKey: s,
1179
+ isPromise: a,
1180
+ maxSize: c,
1181
+ onCacheAdd: l,
1182
+ onCacheChange: u,
1183
+ onCacheHit: m,
1184
+ transformKey: _
1185
+ }, qn(n)), d = new Kn(b), g = d.keys, y = d.values, f = d.canTransformKey, h = d.shouldCloneArguments, p = d.shouldUpdateOnAdd, v = d.shouldUpdateOnChange, E = d.shouldUpdateOnHit, x = function() {
1186
+ var S = h ? W(arguments) : arguments;
1187
+ f && (S = _(S));
1188
+ var L = g.length ? d.getKeyIndex(S) : -1;
1189
+ if (L !== -1)
1190
+ E && m(d, b, x), L && (d.orderByLru(g[L], y[L], L), v && u(d, b, x));
1191
+ else {
1192
+ var Ye = t.apply(this, arguments), Ve = h ? S : W(arguments);
1193
+ d.orderByLru(Ve, Ye, g.length), a && d.updateAsyncCache(x), p && l(d, b, x), v && u(d, b, x);
1194
+ }
1195
+ return y[0];
1196
+ };
1197
+ return x.cache = d, x.fn = t, x.isMemoized = !0, x.options = b, x;
1198
+ }
1199
+ async function Re(t) {
1200
+ try {
1201
+ const n = await st(t, { encoding: "utf-8" });
1202
+ return JSON.parse(n);
1203
+ } catch {
1204
+ }
1205
+ }
1206
+ const Un = /* @__PURE__ */ new URL(
1207
+ "data:text/javascript," + encodeURIComponent('import{pathToFileURL as r}from"node:url";import{parentPort as t,workerData as a}from"node:worker_threads";const s=async({absolutePath:o})=>{try{const e=await import(r(o).href);t?.postMessage(e.embeddedOverrides??e.default??void 0)}catch{t?.postMessage(void 0)}};s(a);')
1208
+ );
1209
+ async function zn(t) {
1210
+ return new Promise((n) => {
1211
+ const r = new ct(Un, {
1212
+ workerData: {
1213
+ absolutePath: t
1214
+ }
1215
+ });
1216
+ r.once("message", (e) => {
1217
+ n(e);
1218
+ }), r.once("error", (e) => {
1219
+ console.error(e), n(void 0);
1220
+ });
1221
+ });
1222
+ }
1223
+ async function Gn(t) {
1224
+ console.error(
1225
+ "Ts module type embeddedOverrides has not been implemented yet."
1226
+ );
1227
+ }
1228
+ const Hn = Xe(
1229
+ async (t, n) => {
1230
+ if (ot(t))
1231
+ return t;
1232
+ const r = await lt(n);
1233
+ let e;
1234
+ return typeof r != "string" ? e = process.env.PWD ?? process.cwd() : e = it(r), at(e, t);
1235
+ }
1236
+ ), Xn = async (t, n) => {
1237
+ const r = Hn(
1238
+ t,
1239
+ n
1240
+ ), e = dt(t);
1241
+ if (e === ".json") {
1242
+ const s = await r, o = await Re(s);
1243
+ if (o !== void 0)
1244
+ return o;
1245
+ console.error(`Failed to parse the json file: ${s}`);
1246
+ return;
1247
+ } else if (e === ".mjs" || e === ".cjs" || e === ".js") {
1248
+ const s = await r, o = await zn(s);
1249
+ if (o !== void 0)
1250
+ return o;
1251
+ console.error(`Failed to parse the js module file: ${s}`);
1252
+ return;
1253
+ } else if (e === ".mts" || e === ".cts" || e === ".ts") {
1254
+ const s = await r, o = await Gn();
1255
+ if (o !== void 0)
1256
+ return o;
1257
+ console.error(`Failed to parse the ts module file: ${s}`);
1258
+ return;
1259
+ } else if (e === "") {
1260
+ const s = await r, o = await Re(s);
1261
+ if (o !== void 0)
1262
+ return o;
1263
+ }
1264
+ try {
1265
+ return JSON.parse(t);
1266
+ } catch {
1267
+ console.error("Failed to parse embeddedOverrides as a json object");
1220
1268
  }
1221
- return Ye.embed?.(t, n) ?? null;
1269
+ }, Jn = async (t, n, r) => {
1270
+ if (t === void 0)
1271
+ return;
1272
+ const e = await Xn(
1273
+ t,
1274
+ r
1275
+ );
1276
+ if (e !== void 0)
1277
+ try {
1278
+ for (const { identifiers: s, options: o } of e)
1279
+ if (s.includes(n))
1280
+ return o;
1281
+ } catch {
1282
+ console.error("Error parsing embedded override options.");
1283
+ }
1222
1284
  };
1223
- function wn({ node: t, parent: n }, r, e) {
1285
+ function Yn({ node: t, parent: n }, r, e) {
1224
1286
  if (r.length === 0 || t.type !== "TemplateLiteral")
1225
1287
  return;
1226
1288
  const s = t.comments ?? n?.comments;
@@ -1235,68 +1297,76 @@ function wn({ node: t, parent: n }, r, e) {
1235
1297
  "CommentBlock"
1236
1298
  // babel, babel-flow, babel-ts
1237
1299
  ].includes(o.type) || !o.leading)) {
1238
- for (const d of r)
1239
- if (` ${d} ` === o.value && !e.includes(d))
1240
- return d;
1300
+ for (const a of r)
1301
+ if (` ${a} ` === o.value && !e.includes(a))
1302
+ return a;
1241
1303
  }
1242
1304
  }
1243
- function Fn({ node: t, parent: n }, r, e) {
1305
+ function Vn({ node: t, parent: n }, r, e) {
1244
1306
  if (r.length !== 0 && !(t.type !== "TemplateLiteral" || n?.type !== "TaggedTemplateExpression" || n.tag.type !== "Identifier")) {
1245
1307
  for (const s of r)
1246
1308
  if (n.tag.name === s && !e.includes(s))
1247
1309
  return s;
1248
1310
  }
1249
1311
  }
1250
- const Zn = {
1251
- estree: {
1252
- ...Ye,
1253
- embed: Nn
1312
+ const { estree: Je } = rt, Qn = function(t, n) {
1313
+ const { node: r } = t;
1314
+ if (r.type !== "TemplateLiteral" || r.quasis.some(({ value: { cooked: e } }) => e === null))
1315
+ return null;
1316
+ for (const e of Ue) {
1317
+ const s = n[I(e)];
1318
+ if (!s)
1319
+ continue;
1320
+ const o = Yn(
1321
+ t,
1322
+ s,
1323
+ n.noEmbeddedIdentificationByComment ?? []
1324
+ ) ?? Vn(
1325
+ t,
1326
+ s,
1327
+ n.noEmbeddedIdentificationByTag ?? []
1328
+ );
1329
+ if (o === void 0)
1330
+ continue;
1331
+ const a = Ge[e];
1332
+ if (!a)
1333
+ return null;
1334
+ const i = t.node;
1335
+ return i.quasis.length === 1 && i.quasis[0].value.raw.trim() === "" ? "``" : async (c, l, u, m) => {
1336
+ const _ = await Jn(
1337
+ m.embeddedOverrides,
1338
+ o,
1339
+ m.filepath
1340
+ );
1341
+ try {
1342
+ const b = await a(c, l, u, m, {
1343
+ identifier: o,
1344
+ identifiers: s,
1345
+ embeddedOverrideOptions: _
1346
+ });
1347
+ return $.label(
1348
+ { embed: !0, ...b.label },
1349
+ b
1350
+ );
1351
+ } catch (b) {
1352
+ throw console.error(b), b;
1353
+ }
1354
+ };
1254
1355
  }
1255
- }, An = "noEmbeddedIdentificationByComment", jn = "noEmbeddedIdentificationByTag", qn = "preserveEmbeddedExteriorWhitespaces", Bn = "noEmbeddedMultiLineIndentation", Wn = "embeddedOverrides", er = {
1256
- ...Xe,
1257
- [An]: {
1258
- category: "Global",
1259
- type: "string",
1260
- array: !0,
1261
- default: [{ value: [] }],
1262
- description: 'This option turns off "/* identifier */ `...`" comment-based language identification for the specified identifiers.'
1263
- },
1264
- [jn]: {
1265
- category: "Global",
1266
- type: "string",
1267
- array: !0,
1268
- default: [{ value: [] }],
1269
- description: 'This option turns off "identifier`...`" tag-based language identification for the specified identifiers.'
1270
- },
1271
- [qn]: {
1272
- category: "Config",
1273
- type: "string",
1274
- array: !0,
1275
- default: [{ value: [] }],
1276
- description: "This option preserves leading and trailing whitespaces in the formatting results for the specified identifiers."
1277
- },
1278
- [Bn]: {
1279
- category: "Global",
1280
- type: "string",
1281
- array: !0,
1282
- default: [{ value: [] }],
1283
- description: "This option turns off auto indentation in the formatting results for the specified identifiers when they are formatted to span multi lines."
1284
- },
1285
- [Wn]: {
1286
- category: "Global",
1287
- type: "string",
1288
- array: !1,
1289
- default: void 0,
1290
- description: "This option accepts option overrides for the specified identifiers. It should either be a stringified JSON or an absolute filepath to the option overrides file."
1356
+ return Je.embed?.(t, n) ?? null;
1357
+ }, mr = {
1358
+ estree: {
1359
+ ...Je,
1360
+ embed: Qn
1291
1361
  }
1292
1362
  };
1293
1363
  export {
1294
- He as embeddedEmbedders,
1364
+ Ge as embeddedEmbedders,
1295
1365
  Ue as embeddedLanguages,
1296
- Xe as embeddedOptions,
1297
- Ge as embeddedParsers,
1366
+ He as embeddedOptions,
1367
+ ze as embeddedParsers,
1298
1368
  I as makeIdentifiersOptionName,
1299
- er as options,
1300
- Qn as parsers,
1301
- Zn as printers
1369
+ lr as options,
1370
+ ur as parsers,
1371
+ mr as printers
1302
1372
  };