lingo.dev 0.113.5 → 0.113.7

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/build/cli.cjs CHANGED
@@ -2151,7 +2151,13 @@ function _isMetadataKey(key) {
2151
2151
  }
2152
2152
 
2153
2153
  // src/cli/loaders/android.ts
2154
+ var _module = require('module');
2154
2155
  var _xml2js = require('xml2js');
2156
+ var require2 = _module.createRequire.call(void 0, import.meta.url);
2157
+ var sax = require2("sax");
2158
+ var defaultAndroidResourcesXml = `<?xml version="1.0" encoding="utf-8"?>
2159
+ <resources>
2160
+ </resources>`;
2155
2161
  function createAndroidLoader() {
2156
2162
  return createLoader({
2157
2163
  async pull(locale, input2) {
@@ -2159,173 +2165,1053 @@ function createAndroidLoader() {
2159
2165
  if (!input2) {
2160
2166
  return {};
2161
2167
  }
2162
- const result = {};
2163
- const stringRegex = /<string\s+name="([^"]+)"(?:\s+translatable="([^"]+)")?[^>]*>([\s\S]*?)<\/string>/gi;
2164
- let stringMatch;
2165
- while ((stringMatch = stringRegex.exec(input2)) !== null) {
2166
- const name = stringMatch[1];
2167
- const translatable = stringMatch[2];
2168
- let value = stringMatch[3];
2169
- if (translatable === "false") {
2168
+ const document = await parseAndroidDocument(input2);
2169
+ return buildPullResult(document);
2170
+ } catch (error) {
2171
+ console.error("Error parsing Android resource file:", error);
2172
+ throw new CLIError({
2173
+ message: "Failed to parse Android resource file",
2174
+ docUrl: "androidResouceError"
2175
+ });
2176
+ }
2177
+ },
2178
+ async push(locale, payload, originalInput, originalLocale, pullInput, pullOutput) {
2179
+ try {
2180
+ const selectedBase = selectBaseXml(
2181
+ locale,
2182
+ originalLocale,
2183
+ pullInput,
2184
+ originalInput
2185
+ );
2186
+ const existingDocument = await parseAndroidDocument(selectedBase);
2187
+ const sourceDocument = await parseAndroidDocument(originalInput);
2188
+ const translatedDocument = buildTranslatedDocument(
2189
+ payload,
2190
+ existingDocument,
2191
+ sourceDocument
2192
+ );
2193
+ const referenceXml = selectedBase || originalInput || defaultAndroidResourcesXml;
2194
+ const declaration = resolveXmlDeclaration(referenceXml);
2195
+ return buildAndroidXml(translatedDocument, declaration);
2196
+ } catch (error) {
2197
+ console.error("Error generating Android resource file:", error);
2198
+ throw new CLIError({
2199
+ message: "Failed to generate Android resource file",
2200
+ docUrl: "androidResouceError"
2201
+ });
2202
+ }
2203
+ }
2204
+ });
2205
+ }
2206
+ function resolveXmlDeclaration(xml) {
2207
+ if (!xml) {
2208
+ const xmldec = {
2209
+ version: "1.0",
2210
+ encoding: "utf-8"
2211
+ };
2212
+ return {
2213
+ xmldec,
2214
+ headless: false
2215
+ };
2216
+ }
2217
+ const match2 = xml.match(
2218
+ /<\?xml\s+version="([^"]+)"(?:\s+encoding="([^"]+)")?\s*\?>/
2219
+ );
2220
+ if (match2) {
2221
+ const version = match2[1] && match2[1].trim().length > 0 ? match2[1] : "1.0";
2222
+ const encoding = match2[2] && match2[2].trim().length > 0 ? match2[2] : void 0;
2223
+ const xmldec = encoding ? { version, encoding } : { version };
2224
+ return {
2225
+ xmldec,
2226
+ headless: false
2227
+ };
2228
+ }
2229
+ return { headless: true };
2230
+ }
2231
+ async function parseAndroidDocument(input2) {
2232
+ const xmlToParse = input2 && input2.trim().length > 0 ? input2 : defaultAndroidResourcesXml;
2233
+ const parsed = await _xml2js.parseStringPromise.call(void 0, xmlToParse, {
2234
+ explicitArray: true,
2235
+ explicitChildren: true,
2236
+ preserveChildrenOrder: true,
2237
+ charsAsChildren: true,
2238
+ includeWhiteChars: true,
2239
+ mergeAttrs: false,
2240
+ normalize: false,
2241
+ normalizeTags: false,
2242
+ trim: false,
2243
+ attrkey: "$",
2244
+ charkey: "_",
2245
+ childkey: "$$"
2246
+ });
2247
+ if (!parsed || !parsed.resources) {
2248
+ return {
2249
+ resources: { $$: [] },
2250
+ resourceNodes: []
2251
+ };
2252
+ }
2253
+ const resourcesNode = parsed.resources;
2254
+ resourcesNode["#name"] = _nullishCoalesce(resourcesNode["#name"], () => ( "resources"));
2255
+ resourcesNode.$$ = _nullishCoalesce(resourcesNode.$$, () => ( []));
2256
+ const metadata = extractResourceMetadata(xmlToParse);
2257
+ const resourceNodes = [];
2258
+ let metaIndex = 0;
2259
+ for (const child of resourcesNode.$$) {
2260
+ const elementName = _optionalChain([child, 'optionalAccess', _111 => _111["#name"]]);
2261
+ if (!isResourceElementName(elementName)) {
2262
+ continue;
2263
+ }
2264
+ const meta = metadata[metaIndex++];
2265
+ if (!meta || meta.type !== elementName) {
2266
+ continue;
2267
+ }
2268
+ const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _112 => _112.$, 'optionalAccess', _113 => _113.name]), () => ( meta.name));
2269
+ if (!name) {
2270
+ continue;
2271
+ }
2272
+ const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess', _114 => _114.$, 'optionalAccess', _115 => _115.translatable]), () => ( ""))).toLowerCase() !== "false";
2273
+ switch (meta.type) {
2274
+ case "string": {
2275
+ resourceNodes.push({
2276
+ type: "string",
2277
+ name,
2278
+ translatable,
2279
+ node: child,
2280
+ meta: cloneTextMeta(meta.meta)
2281
+ });
2282
+ break;
2283
+ }
2284
+ case "string-array": {
2285
+ const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _116 => _116.item]), () => ( []));
2286
+ const items = [];
2287
+ const templateItems = meta.items;
2288
+ for (let i = 0; i < Math.max(itemNodes.length, templateItems.length); i++) {
2289
+ const nodeItem = itemNodes[i];
2290
+ const templateItem = _nullishCoalesce(templateItems[i], () => ( templateItems[templateItems.length - 1]));
2291
+ if (!nodeItem) {
2170
2292
  continue;
2171
2293
  }
2172
- const cdataRegex = /<!\[CDATA\[([\s\S]*?)\]\]>/g;
2173
- value = value.replace(cdataRegex, (match2, content) => content);
2174
- value = value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/\\'/g, "'");
2175
- result[name] = value;
2294
+ items.push({
2295
+ node: nodeItem,
2296
+ meta: cloneTextMeta(templateItem.meta)
2297
+ });
2176
2298
  }
2177
- const parsed = await _xml2js.parseStringPromise.call(void 0, input2, {
2178
- explicitArray: true,
2179
- mergeAttrs: false,
2180
- normalize: true,
2181
- normalizeTags: false,
2182
- trim: true,
2183
- attrkey: "$",
2184
- charkey: "_"
2299
+ resourceNodes.push({
2300
+ type: "string-array",
2301
+ name,
2302
+ translatable,
2303
+ node: child,
2304
+ items
2185
2305
  });
2186
- if (!parsed || !parsed.resources) {
2187
- return result;
2188
- }
2189
- if (parsed.resources["string-array"]) {
2190
- parsed.resources["string-array"].forEach((arrayItem) => {
2191
- if (arrayItem.$ && arrayItem.$.translatable === "false") {
2192
- return;
2193
- }
2194
- const name = arrayItem.$.name;
2195
- const items = [];
2196
- if (arrayItem.item) {
2197
- arrayItem.item.forEach((item) => {
2198
- let itemValue = "";
2199
- if (typeof item === "string") {
2200
- itemValue = item;
2201
- } else if (item._) {
2202
- itemValue = item._;
2203
- } else if (item._ === "") {
2204
- itemValue = "";
2205
- }
2206
- items.push(
2207
- itemValue === "" || /^\s+$/.test(itemValue) ? itemValue : itemValue.trim()
2208
- );
2209
- });
2210
- }
2211
- result[name] = items;
2306
+ break;
2307
+ }
2308
+ case "plurals": {
2309
+ const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _117 => _117.item]), () => ( []));
2310
+ const templateItems = meta.items;
2311
+ const items = [];
2312
+ for (const templateItem of templateItems) {
2313
+ const quantity = templateItem.quantity;
2314
+ if (!quantity) {
2315
+ continue;
2316
+ }
2317
+ const nodeItem = itemNodes.find(
2318
+ (item) => _optionalChain([item, 'optionalAccess', _118 => _118.$, 'optionalAccess', _119 => _119.quantity]) === quantity
2319
+ );
2320
+ if (!nodeItem) {
2321
+ continue;
2322
+ }
2323
+ items.push({
2324
+ node: nodeItem,
2325
+ quantity,
2326
+ meta: cloneTextMeta(templateItem.meta)
2212
2327
  });
2213
2328
  }
2214
- if (parsed.resources.plurals) {
2215
- parsed.resources.plurals.forEach((pluralItem) => {
2216
- if (pluralItem.$ && pluralItem.$.translatable === "false") {
2217
- return;
2218
- }
2219
- const name = pluralItem.$.name;
2220
- const pluralObj = {};
2221
- if (pluralItem.item) {
2222
- pluralItem.item.forEach((item) => {
2223
- if (item.$ && item.$.quantity) {
2224
- let value = "";
2225
- if (item._) {
2226
- value = item._;
2227
- } else if (item._ === "") {
2228
- value = "";
2229
- }
2230
- pluralObj[item.$.quantity] = value === "" || /^\s+$/.test(value) ? value : value.trim();
2231
- }
2232
- });
2233
- }
2234
- result[name] = pluralObj;
2235
- });
2329
+ resourceNodes.push({
2330
+ type: "plurals",
2331
+ name,
2332
+ translatable,
2333
+ node: child,
2334
+ items
2335
+ });
2336
+ break;
2337
+ }
2338
+ case "bool": {
2339
+ resourceNodes.push({
2340
+ type: "bool",
2341
+ name,
2342
+ translatable,
2343
+ node: child,
2344
+ meta: cloneTextMeta(meta.meta)
2345
+ });
2346
+ break;
2347
+ }
2348
+ case "integer": {
2349
+ resourceNodes.push({
2350
+ type: "integer",
2351
+ name,
2352
+ translatable,
2353
+ node: child,
2354
+ meta: cloneTextMeta(meta.meta)
2355
+ });
2356
+ break;
2357
+ }
2358
+ }
2359
+ }
2360
+ return { resources: resourcesNode, resourceNodes };
2361
+ }
2362
+ function buildPullResult(document) {
2363
+ const result = {};
2364
+ for (const resource of document.resourceNodes) {
2365
+ if (!resource.translatable) {
2366
+ continue;
2367
+ }
2368
+ switch (resource.type) {
2369
+ case "string": {
2370
+ result[resource.name] = decodeAndroidText(
2371
+ segmentsToString(resource.meta.segments)
2372
+ );
2373
+ break;
2374
+ }
2375
+ case "string-array": {
2376
+ result[resource.name] = resource.items.map(
2377
+ (item) => decodeAndroidText(segmentsToString(item.meta.segments))
2378
+ );
2379
+ break;
2380
+ }
2381
+ case "plurals": {
2382
+ const pluralMap = {};
2383
+ for (const item of resource.items) {
2384
+ pluralMap[item.quantity] = decodeAndroidText(
2385
+ segmentsToString(item.meta.segments)
2386
+ );
2236
2387
  }
2237
- if (parsed.resources.bool) {
2238
- parsed.resources.bool.forEach((boolItem) => {
2239
- if (boolItem.$ && boolItem.$.translatable === "false") {
2240
- return;
2241
- }
2242
- const name = boolItem.$.name;
2243
- result[name] = boolItem._ === "true";
2244
- });
2388
+ result[resource.name] = pluralMap;
2389
+ break;
2390
+ }
2391
+ case "bool": {
2392
+ const value = segmentsToString(resource.meta.segments).trim();
2393
+ result[resource.name] = value === "true";
2394
+ break;
2395
+ }
2396
+ case "integer": {
2397
+ const value = parseInt(
2398
+ segmentsToString(resource.meta.segments).trim(),
2399
+ 10
2400
+ );
2401
+ result[resource.name] = Number.isNaN(value) ? 0 : value;
2402
+ break;
2403
+ }
2404
+ }
2405
+ }
2406
+ return result;
2407
+ }
2408
+ function buildTranslatedDocument(payload, existingDocument, sourceDocument) {
2409
+ const templateDocument = sourceDocument;
2410
+ const finalDocument = cloneDocumentStructure(templateDocument);
2411
+ const templateMap = createResourceMap(templateDocument);
2412
+ const existingMap = createResourceMap(existingDocument);
2413
+ const payloadEntries = _nullishCoalesce(payload, () => ( {}));
2414
+ const finalMap = createResourceMap(finalDocument);
2415
+ for (const resource of finalDocument.resourceNodes) {
2416
+ if (!resource.translatable) {
2417
+ continue;
2418
+ }
2419
+ const templateResource = templateMap.get(resource.name);
2420
+ let translationValue;
2421
+ if (Object.prototype.hasOwnProperty.call(payloadEntries, resource.name) && payloadEntries[resource.name] !== void 0 && payloadEntries[resource.name] !== null) {
2422
+ translationValue = payloadEntries[resource.name];
2423
+ } else if (existingMap.has(resource.name)) {
2424
+ translationValue = extractValueFromResource(
2425
+ existingMap.get(resource.name)
2426
+ );
2427
+ } else {
2428
+ translationValue = extractValueFromResource(_nullishCoalesce(templateResource, () => ( resource)));
2429
+ }
2430
+ updateResourceNode(resource, translationValue, templateResource);
2431
+ }
2432
+ for (const resource of existingDocument.resourceNodes) {
2433
+ if (finalMap.has(resource.name)) {
2434
+ continue;
2435
+ }
2436
+ const cloned = cloneResourceNode(resource);
2437
+ appendResourceNode(finalDocument, cloned);
2438
+ finalMap.set(cloned.name, cloned);
2439
+ }
2440
+ for (const [name, value] of Object.entries(payloadEntries)) {
2441
+ if (finalMap.has(name)) {
2442
+ continue;
2443
+ }
2444
+ try {
2445
+ const inferred = createResourceNodeFromValue(name, value);
2446
+ appendResourceNode(finalDocument, inferred);
2447
+ finalMap.set(name, inferred);
2448
+ } catch (error) {
2449
+ if (error instanceof CLIError) {
2450
+ throw error;
2451
+ }
2452
+ }
2453
+ }
2454
+ return finalDocument;
2455
+ }
2456
+ function buildAndroidXml(document, declaration) {
2457
+ const xmlBody = serializeElement(document.resources);
2458
+ if (declaration.headless) {
2459
+ return xmlBody;
2460
+ }
2461
+ if (declaration.xmldec) {
2462
+ const { version, encoding } = declaration.xmldec;
2463
+ const encodingPart = encoding ? ` encoding="${encoding}"` : "";
2464
+ return `<?xml version="${version}"${encodingPart}?>
2465
+ ${xmlBody}`;
2466
+ }
2467
+ return `<?xml version="1.0" encoding="utf-8"?>
2468
+ ${xmlBody}`;
2469
+ }
2470
+ function selectBaseXml(locale, originalLocale, pullInput, originalInput) {
2471
+ if (locale === originalLocale) {
2472
+ return _nullishCoalesce(pullInput, () => ( originalInput));
2473
+ }
2474
+ return _nullishCoalesce(pullInput, () => ( originalInput));
2475
+ }
2476
+ function updateResourceNode(target, rawValue, template) {
2477
+ switch (target.type) {
2478
+ case "string": {
2479
+ const value = asString(rawValue, target.name);
2480
+ const templateMeta = template && template.type === "string" ? template.meta : target.meta;
2481
+ const useCdata = templateMeta.hasCdata;
2482
+ setTextualNodeContent(target.node, value, useCdata);
2483
+ target.meta = makeTextMeta([
2484
+ { kind: useCdata ? "cdata" : "text", value }
2485
+ ]);
2486
+ break;
2487
+ }
2488
+ case "string-array": {
2489
+ const values = asStringArray(rawValue, target.name);
2490
+ const templateItems = template && template.type === "string-array" ? template.items : target.items;
2491
+ const maxLength = Math.max(target.items.length, templateItems.length);
2492
+ for (let index = 0; index < maxLength; index++) {
2493
+ const targetItem = target.items[index];
2494
+ const templateItem = _nullishCoalesce(_nullishCoalesce(templateItems[index], () => ( templateItems[templateItems.length - 1])), () => ( target.items[index]));
2495
+ if (!targetItem || !templateItem) {
2496
+ continue;
2245
2497
  }
2246
- if (parsed.resources.integer) {
2247
- parsed.resources.integer.forEach((intItem) => {
2248
- if (intItem.$ && intItem.$.translatable === "false") {
2249
- return;
2250
- }
2251
- const name = intItem.$.name;
2252
- result[name] = parseInt(intItem._ || "0", 10);
2253
- });
2498
+ const translation = index < values.length ? values[index] : segmentsToString(templateItem.meta.segments);
2499
+ const useCdata = templateItem.meta.hasCdata;
2500
+ setTextualNodeContent(targetItem.node, translation, useCdata);
2501
+ targetItem.meta = makeTextMeta([
2502
+ { kind: useCdata ? "cdata" : "text", value: translation }
2503
+ ]);
2504
+ }
2505
+ break;
2506
+ }
2507
+ case "plurals": {
2508
+ const pluralValues = asPluralMap(rawValue, target.name);
2509
+ const templateItems = template && template.type === "plurals" ? template.items : target.items;
2510
+ const templateMap = new Map(
2511
+ templateItems.map((item) => [item.quantity, item])
2512
+ );
2513
+ for (const item of target.items) {
2514
+ const templateItem = _nullishCoalesce(templateMap.get(item.quantity), () => ( templateMap.values().next().value));
2515
+ const fallback = templateItem ? segmentsToString(templateItem.meta.segments) : segmentsToString(item.meta.segments);
2516
+ const translation = typeof pluralValues[item.quantity] === "string" ? pluralValues[item.quantity] : fallback;
2517
+ const useCdata = templateItem ? templateItem.meta.hasCdata : item.meta.hasCdata;
2518
+ setTextualNodeContent(item.node, translation, useCdata);
2519
+ item.meta = makeTextMeta([
2520
+ { kind: useCdata ? "cdata" : "text", value: translation }
2521
+ ]);
2522
+ }
2523
+ break;
2524
+ }
2525
+ case "bool": {
2526
+ const boolValue = asBoolean(rawValue, target.name);
2527
+ const strValue = boolValue ? "true" : "false";
2528
+ setTextualNodeContent(target.node, strValue, false);
2529
+ target.meta = makeTextMeta([{ kind: "text", value: strValue }]);
2530
+ break;
2531
+ }
2532
+ case "integer": {
2533
+ const intValue = asInteger(rawValue, target.name);
2534
+ const strValue = intValue.toString();
2535
+ setTextualNodeContent(target.node, strValue, false);
2536
+ target.meta = makeTextMeta([{ kind: "text", value: strValue }]);
2537
+ break;
2538
+ }
2539
+ }
2540
+ }
2541
+ function appendResourceNode(document, resourceNode) {
2542
+ document.resources.$$ = _nullishCoalesce(document.resources.$$, () => ( []));
2543
+ const children = document.resources.$$;
2544
+ if (children.length === 0 || children[children.length - 1]["#name"] !== "__text__" && children[children.length - 1]["#name"] !== "__comment__") {
2545
+ children.push({ "#name": "__text__", _: "\n " });
2546
+ }
2547
+ children.push(resourceNode.node);
2548
+ children.push({ "#name": "__text__", _: "\n" });
2549
+ document.resourceNodes.push(resourceNode);
2550
+ }
2551
+ function setTextualNodeContent(node, value, useCdata) {
2552
+ const escapedValue = useCdata ? value : escapeAndroidString(value);
2553
+ node._ = escapedValue;
2554
+ node.$$ = _nullishCoalesce(node.$$, () => ( []));
2555
+ let textNode = node.$$.find(
2556
+ (child) => child["#name"] === "__text__" || child["#name"] === "__cdata"
2557
+ );
2558
+ if (!textNode) {
2559
+ textNode = {};
2560
+ node.$$.push(textNode);
2561
+ }
2562
+ textNode["#name"] = useCdata ? "__cdata" : "__text__";
2563
+ textNode._ = useCdata ? value : escapedValue;
2564
+ }
2565
+ function buildResourceNameMap(document) {
2566
+ const map = /* @__PURE__ */ new Map();
2567
+ for (const node of document.resourceNodes) {
2568
+ if (!map.has(node.name)) {
2569
+ map.set(node.name, node);
2570
+ }
2571
+ }
2572
+ return map;
2573
+ }
2574
+ function createResourceMap(document) {
2575
+ return buildResourceNameMap(document);
2576
+ }
2577
+ function cloneResourceNode(resource) {
2578
+ switch (resource.type) {
2579
+ case "string": {
2580
+ const nodeClone = deepClone(resource.node);
2581
+ return {
2582
+ type: "string",
2583
+ name: resource.name,
2584
+ translatable: resource.translatable,
2585
+ node: nodeClone,
2586
+ meta: cloneTextMeta(resource.meta)
2587
+ };
2588
+ }
2589
+ case "string-array": {
2590
+ const nodeClone = deepClone(resource.node);
2591
+ const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
2592
+ const items = itemNodes.map((itemNode, index) => {
2593
+ const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access', _120 => _120.items, 'access', _121 => _121[index], 'optionalAccess', _122 => _122.meta]), () => ( _optionalChain([resource, 'access', _123 => _123.items, 'access', _124 => _124[resource.items.length - 1], 'optionalAccess', _125 => _125.meta]))), () => ( makeTextMeta([])));
2594
+ return {
2595
+ node: itemNode,
2596
+ meta: cloneTextMeta(templateMeta)
2597
+ };
2598
+ });
2599
+ return {
2600
+ type: "string-array",
2601
+ name: resource.name,
2602
+ translatable: resource.translatable,
2603
+ node: nodeClone,
2604
+ items
2605
+ };
2606
+ }
2607
+ case "plurals": {
2608
+ const nodeClone = deepClone(resource.node);
2609
+ const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
2610
+ const items = [];
2611
+ for (const templateItem of resource.items) {
2612
+ const cloneNode = itemNodes.find(
2613
+ (item) => _optionalChain([item, 'optionalAccess', _126 => _126.$, 'optionalAccess', _127 => _127.quantity]) === templateItem.quantity
2614
+ );
2615
+ if (!cloneNode) {
2616
+ continue;
2254
2617
  }
2255
- return result;
2256
- } catch (error) {
2257
- console.error("Error parsing Android resource file:", error);
2618
+ items.push({
2619
+ node: cloneNode,
2620
+ quantity: templateItem.quantity,
2621
+ meta: cloneTextMeta(templateItem.meta)
2622
+ });
2623
+ }
2624
+ return {
2625
+ type: "plurals",
2626
+ name: resource.name,
2627
+ translatable: resource.translatable,
2628
+ node: nodeClone,
2629
+ items
2630
+ };
2631
+ }
2632
+ case "bool": {
2633
+ const nodeClone = deepClone(resource.node);
2634
+ return {
2635
+ type: "bool",
2636
+ name: resource.name,
2637
+ translatable: resource.translatable,
2638
+ node: nodeClone,
2639
+ meta: cloneTextMeta(resource.meta)
2640
+ };
2641
+ }
2642
+ case "integer": {
2643
+ const nodeClone = deepClone(resource.node);
2644
+ return {
2645
+ type: "integer",
2646
+ name: resource.name,
2647
+ translatable: resource.translatable,
2648
+ node: nodeClone,
2649
+ meta: cloneTextMeta(resource.meta)
2650
+ };
2651
+ }
2652
+ }
2653
+ }
2654
+ function cloneTextMeta(meta) {
2655
+ return {
2656
+ hasCdata: meta.hasCdata,
2657
+ segments: meta.segments.map((segment) => ({ ...segment }))
2658
+ };
2659
+ }
2660
+ function asString(value, name) {
2661
+ if (typeof value === "string") {
2662
+ return value;
2663
+ }
2664
+ throw new CLIError({
2665
+ message: `Expected string value for resource "${name}"`,
2666
+ docUrl: "androidResouceError"
2667
+ });
2668
+ }
2669
+ function asStringArray(value, name) {
2670
+ if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
2671
+ return value;
2672
+ }
2673
+ throw new CLIError({
2674
+ message: `Expected array of strings for resource "${name}"`,
2675
+ docUrl: "androidResouceError"
2676
+ });
2677
+ }
2678
+ function asPluralMap(value, name) {
2679
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2680
+ const result = {};
2681
+ for (const [quantity, pluralValue] of Object.entries(value)) {
2682
+ if (typeof pluralValue !== "string") {
2258
2683
  throw new CLIError({
2259
- message: "Failed to parse Android resource file",
2684
+ message: `Expected plural item "${quantity}" of "${name}" to be a string`,
2260
2685
  docUrl: "androidResouceError"
2261
2686
  });
2262
2687
  }
2263
- },
2264
- async push(locale, payload) {
2265
- try {
2266
- const xmlObj = {
2267
- resources: {
2268
- string: [],
2269
- "string-array": [],
2270
- plurals: [],
2271
- bool: [],
2272
- integer: []
2273
- }
2688
+ result[quantity] = pluralValue;
2689
+ }
2690
+ return result;
2691
+ }
2692
+ throw new CLIError({
2693
+ message: `Expected object value for plurals resource "${name}"`,
2694
+ docUrl: "androidResouceError"
2695
+ });
2696
+ }
2697
+ function asBoolean(value, name) {
2698
+ if (typeof value === "boolean") {
2699
+ return value;
2700
+ }
2701
+ if (typeof value === "string") {
2702
+ if (value === "true" || value === "false") {
2703
+ return value === "true";
2704
+ }
2705
+ }
2706
+ throw new CLIError({
2707
+ message: `Expected boolean value for resource "${name}"`,
2708
+ docUrl: "androidResouceError"
2709
+ });
2710
+ }
2711
+ function asInteger(value, name) {
2712
+ if (typeof value === "number" && Number.isInteger(value)) {
2713
+ return value;
2714
+ }
2715
+ throw new CLIError({
2716
+ message: `Expected number value for resource "${name}"`,
2717
+ docUrl: "androidResouceError"
2718
+ });
2719
+ }
2720
+ function escapeAndroidString(value) {
2721
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/(?<!\\)'/g, "\\'");
2722
+ }
2723
+ function segmentsToString(segments) {
2724
+ return segments.map((segment) => segment.value).join("");
2725
+ }
2726
+ function makeTextMeta(segments) {
2727
+ return {
2728
+ segments,
2729
+ hasCdata: segments.some((segment) => segment.kind === "cdata")
2730
+ };
2731
+ }
2732
+ function createResourceNodeFromValue(name, value) {
2733
+ const inferredType = inferTypeFromValue(value);
2734
+ switch (inferredType) {
2735
+ case "string": {
2736
+ const stringValue = asString(value, name);
2737
+ const escaped = escapeAndroidString(stringValue);
2738
+ const node = {
2739
+ "#name": "string",
2740
+ $: { name },
2741
+ _: escaped,
2742
+ $$: [{ "#name": "__text__", _: escaped }]
2743
+ };
2744
+ return {
2745
+ type: "string",
2746
+ name,
2747
+ translatable: true,
2748
+ node,
2749
+ meta: makeTextMeta([{ kind: "text", value: stringValue }])
2750
+ };
2751
+ }
2752
+ case "string-array": {
2753
+ const items = asStringArray(value, name);
2754
+ const node = {
2755
+ "#name": "string-array",
2756
+ $: { name },
2757
+ $$: [],
2758
+ item: []
2759
+ };
2760
+ const itemNodes = [];
2761
+ for (const itemValue of items) {
2762
+ const escaped = escapeAndroidString(itemValue);
2763
+ const itemNode = {
2764
+ "#name": "item",
2765
+ _: escaped,
2766
+ $$: [{ "#name": "__text__", _: escaped }]
2274
2767
  };
2275
- const processHtmlContent = (str) => {
2276
- if (typeof str !== "string") return { _: String(str) };
2277
- const processedStr = str.replace(/(?<!\\)'/g, "\\'");
2278
- return { _: processedStr };
2768
+ node.$$.push(itemNode);
2769
+ node.item.push(itemNode);
2770
+ itemNodes.push({
2771
+ node: itemNode,
2772
+ meta: makeTextMeta([{ kind: "text", value: itemValue }])
2773
+ });
2774
+ }
2775
+ return {
2776
+ type: "string-array",
2777
+ name,
2778
+ translatable: true,
2779
+ node,
2780
+ items: itemNodes
2781
+ };
2782
+ }
2783
+ case "plurals": {
2784
+ const pluralMap = asPluralMap(value, name);
2785
+ const node = {
2786
+ "#name": "plurals",
2787
+ $: { name },
2788
+ $$: [],
2789
+ item: []
2790
+ };
2791
+ const items = [];
2792
+ for (const [quantity, pluralValue] of Object.entries(pluralMap)) {
2793
+ const escaped = escapeAndroidString(pluralValue);
2794
+ const itemNode = {
2795
+ "#name": "item",
2796
+ $: { quantity },
2797
+ _: escaped,
2798
+ $$: [{ "#name": "__text__", _: escaped }]
2279
2799
  };
2280
- for (const [key, value] of Object.entries(payload)) {
2281
- if (typeof value === "string") {
2282
- xmlObj.resources.string.push({
2283
- $: { name: key },
2284
- ...processHtmlContent(value)
2285
- });
2286
- } else if (Array.isArray(value)) {
2287
- xmlObj.resources["string-array"].push({
2288
- $: { name: key },
2289
- item: value.map((item) => processHtmlContent(item))
2290
- });
2291
- } else if (typeof value === "object") {
2292
- xmlObj.resources.plurals.push({
2293
- $: { name: key },
2294
- item: Object.entries(value).map(([quantity, text]) => ({
2295
- $: { quantity },
2296
- ...processHtmlContent(text)
2297
- }))
2298
- });
2299
- } else if (typeof value === "boolean") {
2300
- xmlObj.resources.bool.push({
2301
- $: { name: key },
2302
- _: value.toString()
2303
- });
2304
- } else if (typeof value === "number") {
2305
- xmlObj.resources.integer.push({
2306
- $: { name: key },
2307
- _: value.toString()
2308
- });
2309
- }
2800
+ node.$$.push(itemNode);
2801
+ node.item.push(itemNode);
2802
+ items.push({
2803
+ node: itemNode,
2804
+ quantity,
2805
+ meta: makeTextMeta([{ kind: "text", value: pluralValue }])
2806
+ });
2807
+ }
2808
+ return {
2809
+ type: "plurals",
2810
+ name,
2811
+ translatable: true,
2812
+ node,
2813
+ items
2814
+ };
2815
+ }
2816
+ case "bool": {
2817
+ const boolValue = asBoolean(value, name);
2818
+ const textValue = boolValue ? "true" : "false";
2819
+ const node = {
2820
+ "#name": "bool",
2821
+ $: { name },
2822
+ _: textValue,
2823
+ $$: [{ "#name": "__text__", _: textValue }]
2824
+ };
2825
+ return {
2826
+ type: "bool",
2827
+ name,
2828
+ translatable: true,
2829
+ node,
2830
+ meta: makeTextMeta([{ kind: "text", value: textValue }])
2831
+ };
2832
+ }
2833
+ case "integer": {
2834
+ const intValue = asInteger(value, name);
2835
+ const textValue = intValue.toString();
2836
+ const node = {
2837
+ "#name": "integer",
2838
+ $: { name },
2839
+ _: textValue,
2840
+ $$: [{ "#name": "__text__", _: textValue }]
2841
+ };
2842
+ return {
2843
+ type: "integer",
2844
+ name,
2845
+ translatable: true,
2846
+ node,
2847
+ meta: makeTextMeta([{ kind: "text", value: textValue }])
2848
+ };
2849
+ }
2850
+ }
2851
+ }
2852
+ function cloneDocumentStructure(document) {
2853
+ const resourcesClone = deepClone(document.resources);
2854
+ const lookup = buildResourceLookup(resourcesClone);
2855
+ const resourceNodes = [];
2856
+ for (const resource of document.resourceNodes) {
2857
+ const cloned = cloneResourceNodeFromLookup(resource, lookup);
2858
+ resourceNodes.push(cloned);
2859
+ }
2860
+ return {
2861
+ resources: resourcesClone,
2862
+ resourceNodes
2863
+ };
2864
+ }
2865
+ function buildResourceLookup(resources) {
2866
+ const lookup = /* @__PURE__ */ new Map();
2867
+ const children = Array.isArray(resources.$$) ? resources.$$ : [];
2868
+ for (const child of children) {
2869
+ const type = _optionalChain([child, 'optionalAccess', _128 => _128["#name"]]);
2870
+ const name = _optionalChain([child, 'optionalAccess', _129 => _129.$, 'optionalAccess', _130 => _130.name]);
2871
+ if (!type || !name || !isResourceElementName(type)) {
2872
+ continue;
2873
+ }
2874
+ const key = resourceLookupKey(type, name);
2875
+ if (!lookup.has(key)) {
2876
+ lookup.set(key, []);
2877
+ }
2878
+ lookup.get(key).push(child);
2879
+ }
2880
+ return lookup;
2881
+ }
2882
+ function cloneResourceNodeFromLookup(resource, lookup) {
2883
+ const node = takeResourceNode(lookup, resource.type, resource.name);
2884
+ if (!node) {
2885
+ return cloneResourceNode(resource);
2886
+ }
2887
+ switch (resource.type) {
2888
+ case "string": {
2889
+ return {
2890
+ type: "string",
2891
+ name: resource.name,
2892
+ translatable: resource.translatable,
2893
+ node,
2894
+ meta: cloneTextMeta(resource.meta)
2895
+ };
2896
+ }
2897
+ case "string-array": {
2898
+ const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
2899
+ (child) => _optionalChain([child, 'optionalAccess', _131 => _131["#name"]]) === "item"
2900
+ );
2901
+ node.item = childItems;
2902
+ if (childItems.length < resource.items.length) {
2903
+ return cloneResourceNode(resource);
2904
+ }
2905
+ const items = resource.items.map((item, index) => {
2906
+ const nodeItem = childItems[index];
2907
+ if (!nodeItem) {
2908
+ return {
2909
+ node: deepClone(item.node),
2910
+ meta: cloneTextMeta(item.meta)
2911
+ };
2310
2912
  }
2311
- const builder = new (0, _xml2js.Builder)({
2312
- headless: true,
2313
- renderOpts: {
2314
- pretty: true,
2315
- indent: " ",
2316
- newline: "\n"
2913
+ return {
2914
+ node: nodeItem,
2915
+ meta: cloneTextMeta(item.meta)
2916
+ };
2917
+ });
2918
+ return {
2919
+ type: "string-array",
2920
+ name: resource.name,
2921
+ translatable: resource.translatable,
2922
+ node,
2923
+ items
2924
+ };
2925
+ }
2926
+ case "plurals": {
2927
+ const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
2928
+ (child) => _optionalChain([child, 'optionalAccess', _132 => _132["#name"]]) === "item"
2929
+ );
2930
+ node.item = childItems;
2931
+ const itemMap = /* @__PURE__ */ new Map();
2932
+ for (const item of childItems) {
2933
+ if (_optionalChain([item, 'optionalAccess', _133 => _133.$, 'optionalAccess', _134 => _134.quantity])) {
2934
+ itemMap.set(item.$.quantity, item);
2935
+ }
2936
+ }
2937
+ const items = [];
2938
+ for (const templateItem of resource.items) {
2939
+ const nodeItem = itemMap.get(templateItem.quantity);
2940
+ if (!nodeItem) {
2941
+ return cloneResourceNode(resource);
2942
+ }
2943
+ items.push({
2944
+ node: nodeItem,
2945
+ quantity: templateItem.quantity,
2946
+ meta: cloneTextMeta(templateItem.meta)
2947
+ });
2948
+ }
2949
+ return {
2950
+ type: "plurals",
2951
+ name: resource.name,
2952
+ translatable: resource.translatable,
2953
+ node,
2954
+ items
2955
+ };
2956
+ }
2957
+ case "bool": {
2958
+ return {
2959
+ type: "bool",
2960
+ name: resource.name,
2961
+ translatable: resource.translatable,
2962
+ node,
2963
+ meta: cloneTextMeta(resource.meta)
2964
+ };
2965
+ }
2966
+ case "integer": {
2967
+ return {
2968
+ type: "integer",
2969
+ name: resource.name,
2970
+ translatable: resource.translatable,
2971
+ node,
2972
+ meta: cloneTextMeta(resource.meta)
2973
+ };
2974
+ }
2975
+ }
2976
+ }
2977
+ function takeResourceNode(lookup, type, name) {
2978
+ const key = resourceLookupKey(type, name);
2979
+ const list = lookup.get(key);
2980
+ if (!list || list.length === 0) {
2981
+ return void 0;
2982
+ }
2983
+ return list.shift();
2984
+ }
2985
+ function resourceLookupKey(type, name) {
2986
+ return `${type}:${name}`;
2987
+ }
2988
+ function extractValueFromResource(resource) {
2989
+ switch (resource.type) {
2990
+ case "string":
2991
+ return decodeAndroidText(segmentsToString(resource.meta.segments));
2992
+ case "string-array":
2993
+ return resource.items.map(
2994
+ (item) => decodeAndroidText(segmentsToString(item.meta.segments))
2995
+ );
2996
+ case "plurals": {
2997
+ const result = {};
2998
+ for (const item of resource.items) {
2999
+ result[item.quantity] = decodeAndroidText(
3000
+ segmentsToString(item.meta.segments)
3001
+ );
3002
+ }
3003
+ return result;
3004
+ }
3005
+ case "bool": {
3006
+ const value = segmentsToString(resource.meta.segments).trim();
3007
+ return value === "true";
3008
+ }
3009
+ case "integer": {
3010
+ const value = parseInt(
3011
+ segmentsToString(resource.meta.segments).trim(),
3012
+ 10
3013
+ );
3014
+ return Number.isNaN(value) ? 0 : value;
3015
+ }
3016
+ }
3017
+ }
3018
+ function inferTypeFromValue(value) {
3019
+ if (typeof value === "string") {
3020
+ return "string";
3021
+ }
3022
+ if (Array.isArray(value)) {
3023
+ return "string-array";
3024
+ }
3025
+ if (value && typeof value === "object") {
3026
+ return "plurals";
3027
+ }
3028
+ if (typeof value === "boolean") {
3029
+ return "bool";
3030
+ }
3031
+ if (typeof value === "number" && Number.isInteger(value)) {
3032
+ return "integer";
3033
+ }
3034
+ throw new CLIError({
3035
+ message: "Unable to infer Android resource type from payload",
3036
+ docUrl: "androidResouceError"
3037
+ });
3038
+ }
3039
+ function extractResourceMetadata(xml) {
3040
+ const parser = sax.parser(true, {
3041
+ trim: false,
3042
+ normalize: false,
3043
+ lowercase: false
3044
+ });
3045
+ const stack = [];
3046
+ const result = [];
3047
+ parser.onopentag = (node) => {
3048
+ const lowerName = node.name.toLowerCase();
3049
+ const attributes = {};
3050
+ for (const [key, value] of Object.entries(_nullishCoalesce(node.attributes, () => ( {})))) {
3051
+ attributes[key.toLowerCase()] = String(value);
3052
+ }
3053
+ stack.push({
3054
+ name: lowerName,
3055
+ rawName: node.name,
3056
+ attributes,
3057
+ segments: [],
3058
+ items: []
3059
+ });
3060
+ if (lowerName !== "resources" && lowerName !== "item" && !isResourceElementName(lowerName)) {
3061
+ const attrString = Object.entries(_nullishCoalesce(node.attributes, () => ( {}))).map(
3062
+ ([key, value]) => ` ${key}="${escapeAttributeValue(String(value))}"`
3063
+ ).join("");
3064
+ appendSegmentToNearestResource(stack, {
3065
+ kind: "text",
3066
+ value: `<${node.name}${attrString}>`
3067
+ });
3068
+ }
3069
+ };
3070
+ parser.ontext = (text) => {
3071
+ if (!text) {
3072
+ return;
3073
+ }
3074
+ appendSegmentToNearestResource(stack, { kind: "text", value: text });
3075
+ };
3076
+ parser.oncdata = (cdata) => {
3077
+ appendSegmentToNearestResource(stack, { kind: "cdata", value: cdata });
3078
+ };
3079
+ parser.onclosetag = () => {
3080
+ const entry = stack.pop();
3081
+ if (!entry) {
3082
+ return;
3083
+ }
3084
+ const parent = stack[stack.length - 1];
3085
+ if (entry.name === "item" && parent) {
3086
+ const meta = makeTextMeta(entry.segments);
3087
+ parent.items.push({
3088
+ quantity: entry.attributes.quantity,
3089
+ meta
3090
+ });
3091
+ return;
3092
+ }
3093
+ if (entry.name !== "resources" && entry.name !== "item" && !isResourceElementName(entry.name)) {
3094
+ appendSegmentToNearestResource(stack, {
3095
+ kind: "text",
3096
+ value: `</${entry.rawName}>`
3097
+ });
3098
+ return;
3099
+ }
3100
+ if (!isResourceElementName(entry.name)) {
3101
+ return;
3102
+ }
3103
+ const name = entry.attributes.name;
3104
+ if (!name) {
3105
+ return;
3106
+ }
3107
+ const translatable = (_nullishCoalesce(entry.attributes.translatable, () => ( ""))).toLowerCase() !== "false";
3108
+ switch (entry.name) {
3109
+ case "string": {
3110
+ result.push({
3111
+ type: "string",
3112
+ name,
3113
+ translatable,
3114
+ meta: makeTextMeta(entry.segments)
3115
+ });
3116
+ break;
3117
+ }
3118
+ case "string-array": {
3119
+ result.push({
3120
+ type: "string-array",
3121
+ name,
3122
+ translatable,
3123
+ items: entry.items.map((item) => ({
3124
+ meta: cloneTextMeta(item.meta)
3125
+ }))
3126
+ });
3127
+ break;
3128
+ }
3129
+ case "plurals": {
3130
+ const items = [];
3131
+ for (const item of entry.items) {
3132
+ if (!item.quantity) {
3133
+ continue;
2317
3134
  }
3135
+ items.push({
3136
+ quantity: item.quantity,
3137
+ meta: cloneTextMeta(item.meta)
3138
+ });
3139
+ }
3140
+ result.push({
3141
+ type: "plurals",
3142
+ name,
3143
+ translatable,
3144
+ items
2318
3145
  });
2319
- return builder.buildObject(xmlObj);
2320
- } catch (error) {
2321
- console.error("Error generating Android resource file:", error);
2322
- throw new CLIError({
2323
- message: "Failed to generate Android resource file",
2324
- docUrl: "androidResouceError"
3146
+ break;
3147
+ }
3148
+ case "bool": {
3149
+ result.push({
3150
+ type: "bool",
3151
+ name,
3152
+ translatable,
3153
+ meta: makeTextMeta(entry.segments)
3154
+ });
3155
+ break;
3156
+ }
3157
+ case "integer": {
3158
+ result.push({
3159
+ type: "integer",
3160
+ name,
3161
+ translatable,
3162
+ meta: makeTextMeta(entry.segments)
2325
3163
  });
3164
+ break;
2326
3165
  }
2327
3166
  }
2328
- });
3167
+ };
3168
+ parser.write(xml).close();
3169
+ return result;
3170
+ }
3171
+ function appendSegmentToNearestResource(stack, segment) {
3172
+ for (let index = stack.length - 1; index >= 0; index--) {
3173
+ const entry = stack[index];
3174
+ if (entry.name === "string" || entry.name === "item" || entry.name === "bool" || entry.name === "integer") {
3175
+ entry.segments.push(segment);
3176
+ return;
3177
+ }
3178
+ }
3179
+ }
3180
+ function isResourceElementName(value) {
3181
+ return value === "string" || value === "string-array" || value === "plurals" || value === "bool" || value === "integer";
3182
+ }
3183
+ function deepClone(value) {
3184
+ return value === void 0 ? value : JSON.parse(JSON.stringify(value));
3185
+ }
3186
+ function serializeElement(node) {
3187
+ if (!node) {
3188
+ return "";
3189
+ }
3190
+ const name = _nullishCoalesce(node["#name"], () => ( "resources"));
3191
+ if (name === "__text__") {
3192
+ return _nullishCoalesce(node._, () => ( ""));
3193
+ }
3194
+ if (name === "__cdata") {
3195
+ return `<![CDATA[${_nullishCoalesce(node._, () => ( ""))}]]>`;
3196
+ }
3197
+ if (name === "__comment__") {
3198
+ return `<!--${_nullishCoalesce(node._, () => ( ""))}-->`;
3199
+ }
3200
+ const attributes = _nullishCoalesce(node.$, () => ( {}));
3201
+ const attrString = Object.entries(attributes).map(([key, value]) => ` ${key}="${escapeAttributeValue(String(value))}"`).join("");
3202
+ const children = Array.isArray(node.$$) ? node.$$ : [];
3203
+ if (children.length === 0) {
3204
+ const textContent = _nullishCoalesce(node._, () => ( ""));
3205
+ return `<${name}${attrString}>${textContent}</${name}>`;
3206
+ }
3207
+ const childContent = children.map(serializeElement).join("");
3208
+ return `<${name}${attrString}>${childContent}</${name}>`;
3209
+ }
3210
+ function escapeAttributeValue(value) {
3211
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&apos;");
3212
+ }
3213
+ function decodeAndroidText(value) {
3214
+ return value.replace(/\\'/g, "'");
2329
3215
  }
2330
3216
 
2331
3217
  // src/cli/loaders/csv.ts
@@ -2334,7 +3220,7 @@ var _sync3 = require('csv-stringify/sync');
2334
3220
 
2335
3221
  function detectKeyColumnName(csvString) {
2336
3222
  const row = _sync.parse.call(void 0, csvString)[0];
2337
- const firstColumn = _optionalChain([row, 'optionalAccess', _111 => _111[0], 'optionalAccess', _112 => _112.trim, 'call', _113 => _113()]);
3223
+ const firstColumn = _optionalChain([row, 'optionalAccess', _135 => _135[0], 'optionalAccess', _136 => _136.trim, 'call', _137 => _137()]);
2338
3224
  return firstColumn || "KEY";
2339
3225
  }
2340
3226
  function createCsvLoader() {
@@ -2436,7 +3322,7 @@ function createHtmlLoader() {
2436
3322
  break;
2437
3323
  }
2438
3324
  const siblings = Array.from(parent.childNodes).filter(
2439
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _114 => _114.textContent, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()])
3325
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _138 => _138.textContent, 'optionalAccess', _139 => _139.trim, 'call', _140 => _140()])
2440
3326
  );
2441
3327
  const index = siblings.indexOf(current);
2442
3328
  if (index !== -1) {
@@ -2472,15 +3358,15 @@ function createHtmlLoader() {
2472
3358
  }
2473
3359
  });
2474
3360
  Array.from(element.childNodes).filter(
2475
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _117 => _117.textContent, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()])
3361
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _141 => _141.textContent, 'optionalAccess', _142 => _142.trim, 'call', _143 => _143()])
2476
3362
  ).forEach(processNode);
2477
3363
  }
2478
3364
  };
2479
3365
  Array.from(document.head.childNodes).filter(
2480
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _120 => _120.textContent, 'optionalAccess', _121 => _121.trim, 'call', _122 => _122()])
3366
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _144 => _144.textContent, 'optionalAccess', _145 => _145.trim, 'call', _146 => _146()])
2481
3367
  ).forEach(processNode);
2482
3368
  Array.from(document.body.childNodes).filter(
2483
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _123 => _123.textContent, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()])
3369
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _147 => _147.textContent, 'optionalAccess', _148 => _148.trim, 'call', _149 => _149()])
2484
3370
  ).forEach(processNode);
2485
3371
  return result;
2486
3372
  },
@@ -2505,7 +3391,7 @@ function createHtmlLoader() {
2505
3391
  for (let i = 0; i < indices.length; i++) {
2506
3392
  const index = parseInt(indices[i]);
2507
3393
  const siblings = Array.from(parent.childNodes).filter(
2508
- (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _126 => _126.textContent, 'optionalAccess', _127 => _127.trim, 'call', _128 => _128()])
3394
+ (n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _150 => _150.textContent, 'optionalAccess', _151 => _151.trim, 'call', _152 => _152()])
2509
3395
  );
2510
3396
  if (index >= siblings.length) {
2511
3397
  if (i === indices.length - 1) {
@@ -2556,7 +3442,7 @@ function createMarkdownLoader() {
2556
3442
  yaml: yamlEngine
2557
3443
  }
2558
3444
  });
2559
- const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _129 => _129.trim, 'call', _130 => _130()]), () => ( ""))).filter(Boolean);
3445
+ const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _153 => _153.trim, 'call', _154 => _154()]), () => ( ""))).filter(Boolean);
2560
3446
  return {
2561
3447
  ...Object.fromEntries(
2562
3448
  sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
@@ -2575,7 +3461,7 @@ function createMarkdownLoader() {
2575
3461
  );
2576
3462
  let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
2577
3463
  ([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
2578
- ).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _131 => _131.trim, 'call', _132 => _132()]), () => ( ""))).filter(Boolean).join("\n\n");
3464
+ ).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _155 => _155.trim, 'call', _156 => _156()]), () => ( ""))).filter(Boolean).join("\n\n");
2579
3465
  if (Object.keys(frontmatter).length > 0) {
2580
3466
  content = `
2581
3467
  ${content}`;
@@ -2600,7 +3486,7 @@ function createMarkdocLoader() {
2600
3486
  const result = {};
2601
3487
  const counters = {};
2602
3488
  traverseAndExtract(ast, "", result, counters);
2603
- if (_optionalChain([ast, 'access', _133 => _133.attributes, 'optionalAccess', _134 => _134.frontmatter])) {
3489
+ if (_optionalChain([ast, 'access', _157 => _157.attributes, 'optionalAccess', _158 => _158.frontmatter])) {
2604
3490
  const frontmatter = _yaml2.default.parse(ast.attributes.frontmatter);
2605
3491
  Object.entries(frontmatter).forEach(([key, value]) => {
2606
3492
  if (typeof value === "string") {
@@ -2646,7 +3532,7 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
2646
3532
  if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
2647
3533
  semanticType = nodeSemanticType;
2648
3534
  }
2649
- if (node.type === "text" && _optionalChain([node, 'access', _135 => _135.attributes, 'optionalAccess', _136 => _136.content])) {
3535
+ if (node.type === "text" && _optionalChain([node, 'access', _159 => _159.attributes, 'optionalAccess', _160 => _160.content])) {
2650
3536
  const content = node.attributes.content;
2651
3537
  if (typeof content === "string" && content.trim()) {
2652
3538
  if (semanticType) {
@@ -2673,7 +3559,7 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
2673
3559
  if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
2674
3560
  semanticType = nodeSemanticType;
2675
3561
  }
2676
- if (node.type === "text" && _optionalChain([node, 'access', _137 => _137.attributes, 'optionalAccess', _138 => _138.content])) {
3562
+ if (node.type === "text" && _optionalChain([node, 'access', _161 => _161.attributes, 'optionalAccess', _162 => _162.content])) {
2677
3563
  const content = node.attributes.content;
2678
3564
  if (typeof content === "string" && content.trim()) {
2679
3565
  if (semanticType) {
@@ -2696,7 +3582,7 @@ function applyTranslations(node, path19, data, pathMap) {
2696
3582
  if (!node || typeof node !== "object") {
2697
3583
  return;
2698
3584
  }
2699
- if (node.type === "text" && _optionalChain([node, 'access', _139 => _139.attributes, 'optionalAccess', _140 => _140.content])) {
3585
+ if (node.type === "text" && _optionalChain([node, 'access', _163 => _163.attributes, 'optionalAccess', _164 => _164.content])) {
2700
3586
  const content = node.attributes.content;
2701
3587
  if (typeof content === "string") {
2702
3588
  const contentPath = path19 ? `${path19}/attributes/content` : "attributes/content";
@@ -2746,44 +3632,325 @@ function isSkippableLine(line) {
2746
3632
  function parsePropertyLine(line) {
2747
3633
  const [key, ...valueParts] = line.split("=");
2748
3634
  return {
2749
- key: _optionalChain([key, 'optionalAccess', _141 => _141.trim, 'call', _142 => _142()]) || "",
3635
+ key: _optionalChain([key, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166()]) || "",
2750
3636
  value: valueParts.join("=").trim()
2751
3637
  };
2752
3638
  }
2753
3639
 
3640
+ // src/cli/loaders/xcode-strings/tokenizer.ts
3641
+ var Tokenizer = class {
3642
+
3643
+
3644
+
3645
+
3646
+ constructor(input2) {
3647
+ this.input = input2;
3648
+ this.pos = 0;
3649
+ this.line = 1;
3650
+ this.column = 1;
3651
+ }
3652
+ tokenize() {
3653
+ const tokens = [];
3654
+ while (this.pos < this.input.length) {
3655
+ const char = this.current();
3656
+ if (this.isWhitespace(char)) {
3657
+ this.advance();
3658
+ continue;
3659
+ }
3660
+ if (char === "/" && this.peek() === "/") {
3661
+ tokens.push(this.scanSingleLineComment());
3662
+ continue;
3663
+ }
3664
+ if (char === "/" && this.peek() === "*") {
3665
+ tokens.push(this.scanMultiLineComment());
3666
+ continue;
3667
+ }
3668
+ if (char === '"') {
3669
+ tokens.push(this.scanString());
3670
+ continue;
3671
+ }
3672
+ if (char === "=") {
3673
+ tokens.push(this.makeToken("EQUALS" /* EQUALS */, "="));
3674
+ this.advance();
3675
+ continue;
3676
+ }
3677
+ if (char === ";") {
3678
+ tokens.push(this.makeToken("SEMICOLON" /* SEMICOLON */, ";"));
3679
+ this.advance();
3680
+ continue;
3681
+ }
3682
+ this.advance();
3683
+ }
3684
+ tokens.push(this.makeToken("EOF" /* EOF */, ""));
3685
+ return tokens;
3686
+ }
3687
+ scanString() {
3688
+ const start = this.getPosition();
3689
+ let value = "";
3690
+ this.advance();
3691
+ while (this.pos < this.input.length) {
3692
+ const char = this.current();
3693
+ if (char === "\\") {
3694
+ this.advance();
3695
+ if (this.pos < this.input.length) {
3696
+ const nextChar = this.current();
3697
+ value += "\\" + nextChar;
3698
+ this.advance();
3699
+ }
3700
+ continue;
3701
+ }
3702
+ if (char === '"') {
3703
+ this.advance();
3704
+ return {
3705
+ type: "STRING" /* STRING */,
3706
+ value,
3707
+ ...start
3708
+ };
3709
+ }
3710
+ value += char;
3711
+ this.advance();
3712
+ }
3713
+ return {
3714
+ type: "STRING" /* STRING */,
3715
+ value,
3716
+ ...start
3717
+ };
3718
+ }
3719
+ scanSingleLineComment() {
3720
+ const start = this.getPosition();
3721
+ let value = "";
3722
+ this.advance();
3723
+ this.advance();
3724
+ while (this.pos < this.input.length && this.current() !== "\n") {
3725
+ value += this.current();
3726
+ this.advance();
3727
+ }
3728
+ return {
3729
+ type: "COMMENT_SINGLE" /* COMMENT_SINGLE */,
3730
+ value,
3731
+ ...start
3732
+ };
3733
+ }
3734
+ scanMultiLineComment() {
3735
+ const start = this.getPosition();
3736
+ let value = "";
3737
+ this.advance();
3738
+ this.advance();
3739
+ while (this.pos < this.input.length) {
3740
+ if (this.current() === "*" && this.peek() === "/") {
3741
+ this.advance();
3742
+ this.advance();
3743
+ return {
3744
+ type: "COMMENT_MULTI" /* COMMENT_MULTI */,
3745
+ value,
3746
+ ...start
3747
+ };
3748
+ }
3749
+ value += this.current();
3750
+ this.advance();
3751
+ }
3752
+ return {
3753
+ type: "COMMENT_MULTI" /* COMMENT_MULTI */,
3754
+ value,
3755
+ ...start
3756
+ };
3757
+ }
3758
+ current() {
3759
+ return this.input[this.pos];
3760
+ }
3761
+ peek() {
3762
+ if (this.pos + 1 < this.input.length) {
3763
+ return this.input[this.pos + 1];
3764
+ }
3765
+ return null;
3766
+ }
3767
+ advance() {
3768
+ if (this.pos < this.input.length) {
3769
+ if (this.current() === "\n") {
3770
+ this.line++;
3771
+ this.column = 1;
3772
+ } else {
3773
+ this.column++;
3774
+ }
3775
+ this.pos++;
3776
+ }
3777
+ }
3778
+ isWhitespace(char) {
3779
+ return char === " " || char === " " || char === "\n" || char === "\r";
3780
+ }
3781
+ getPosition() {
3782
+ return {
3783
+ line: this.line,
3784
+ column: this.column
3785
+ };
3786
+ }
3787
+ makeToken(type, value) {
3788
+ return {
3789
+ type,
3790
+ value,
3791
+ ...this.getPosition()
3792
+ };
3793
+ }
3794
+ };
3795
+
3796
+ // src/cli/loaders/xcode-strings/escape.ts
3797
+ function unescapeString(raw) {
3798
+ let result = "";
3799
+ let i = 0;
3800
+ while (i < raw.length) {
3801
+ if (raw[i] === "\\" && i + 1 < raw.length) {
3802
+ const nextChar = raw[i + 1];
3803
+ switch (nextChar) {
3804
+ case '"':
3805
+ result += '"';
3806
+ i += 2;
3807
+ break;
3808
+ case "\\":
3809
+ result += "\\";
3810
+ i += 2;
3811
+ break;
3812
+ case "n":
3813
+ result += "\n";
3814
+ i += 2;
3815
+ break;
3816
+ case "t":
3817
+ result += " ";
3818
+ i += 2;
3819
+ break;
3820
+ case "r":
3821
+ result += "\r";
3822
+ i += 2;
3823
+ break;
3824
+ default:
3825
+ result += raw[i];
3826
+ i++;
3827
+ break;
3828
+ }
3829
+ } else {
3830
+ result += raw[i];
3831
+ i++;
3832
+ }
3833
+ }
3834
+ return result;
3835
+ }
3836
+ function escapeString(str) {
3837
+ if (str == null) {
3838
+ return "";
3839
+ }
3840
+ let result = "";
3841
+ for (let i = 0; i < str.length; i++) {
3842
+ const char = str[i];
3843
+ switch (char) {
3844
+ case "\\":
3845
+ result += "\\\\";
3846
+ break;
3847
+ case '"':
3848
+ result += '\\"';
3849
+ break;
3850
+ case "\n":
3851
+ result += "\\n";
3852
+ break;
3853
+ case "\r":
3854
+ result += "\\r";
3855
+ break;
3856
+ case " ":
3857
+ result += "\\t";
3858
+ break;
3859
+ default:
3860
+ result += char;
3861
+ break;
3862
+ }
3863
+ }
3864
+ return result;
3865
+ }
3866
+
3867
+ // src/cli/loaders/xcode-strings/parser.ts
3868
+ var Parser = class {
3869
+
3870
+
3871
+ constructor(tokens) {
3872
+ this.tokens = tokens;
3873
+ this.pos = 0;
3874
+ }
3875
+ parse() {
3876
+ const result = {};
3877
+ while (this.pos < this.tokens.length) {
3878
+ const token = this.current();
3879
+ if (token.type === "COMMENT_SINGLE" /* COMMENT_SINGLE */ || token.type === "COMMENT_MULTI" /* COMMENT_MULTI */) {
3880
+ this.advance();
3881
+ continue;
3882
+ }
3883
+ if (token.type === "EOF" /* EOF */) {
3884
+ break;
3885
+ }
3886
+ if (token.type === "STRING" /* STRING */) {
3887
+ const entry = this.parseEntry();
3888
+ if (entry) {
3889
+ result[entry.key] = entry.value;
3890
+ }
3891
+ continue;
3892
+ }
3893
+ this.advance();
3894
+ }
3895
+ return result;
3896
+ }
3897
+ parseEntry() {
3898
+ const keyToken = this.current();
3899
+ if (keyToken.type !== "STRING" /* STRING */) {
3900
+ return null;
3901
+ }
3902
+ const key = keyToken.value;
3903
+ this.advance();
3904
+ if (!this.expect("EQUALS" /* EQUALS */)) {
3905
+ return null;
3906
+ }
3907
+ const valueToken = this.current();
3908
+ if (valueToken.type !== "STRING" /* STRING */) {
3909
+ return null;
3910
+ }
3911
+ const rawValue = valueToken.value;
3912
+ this.advance();
3913
+ if (!this.expect("SEMICOLON" /* SEMICOLON */)) {
3914
+ }
3915
+ const value = unescapeString(rawValue);
3916
+ return { key, value };
3917
+ }
3918
+ current() {
3919
+ return this.tokens[this.pos];
3920
+ }
3921
+ advance() {
3922
+ if (this.pos < this.tokens.length) {
3923
+ this.pos++;
3924
+ }
3925
+ }
3926
+ expect(type) {
3927
+ if (_optionalChain([this, 'access', _167 => _167.current, 'call', _168 => _168(), 'optionalAccess', _169 => _169.type]) === type) {
3928
+ this.advance();
3929
+ return true;
3930
+ }
3931
+ return false;
3932
+ }
3933
+ };
3934
+
2754
3935
  // src/cli/loaders/xcode-strings.ts
2755
3936
  function createXcodeStringsLoader() {
2756
3937
  return createLoader({
2757
3938
  async pull(locale, input2) {
2758
- const lines = input2.split("\n");
2759
- const result = {};
2760
- for (const line of lines) {
2761
- const trimmedLine = line.trim();
2762
- if (trimmedLine && !trimmedLine.startsWith("//")) {
2763
- const match2 = trimmedLine.match(/^"(.+)"\s*=\s*"(.+)";$/);
2764
- if (match2) {
2765
- const [, key, value] = match2;
2766
- result[key] = unescapeXcodeString(value);
2767
- }
2768
- }
2769
- }
3939
+ const tokenizer = new Tokenizer(input2);
3940
+ const tokens = tokenizer.tokenize();
3941
+ const parser = new Parser(tokens);
3942
+ const result = parser.parse();
2770
3943
  return result;
2771
3944
  },
2772
3945
  async push(locale, payload) {
2773
- const lines = Object.entries(payload).map(([key, value]) => {
2774
- const escapedValue = escapeXcodeString(value);
3946
+ const lines = Object.entries(payload).filter(([_36, value]) => value != null).map(([key, value]) => {
3947
+ const escapedValue = escapeString(value);
2775
3948
  return `"${key}" = "${escapedValue}";`;
2776
3949
  });
2777
3950
  return lines.join("\n");
2778
3951
  }
2779
3952
  });
2780
3953
  }
2781
- function unescapeXcodeString(str) {
2782
- return str.replace(/\\"/g, '"').replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
2783
- }
2784
- function escapeXcodeString(str) {
2785
- return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
2786
- }
2787
3954
 
2788
3955
  // src/cli/loaders/xcode-stringsdict.ts
2789
3956
  var _plist = require('plist'); var _plist2 = _interopRequireDefault(_plist);
@@ -2834,7 +4001,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
2834
4001
  if (rootTranslationEntity.shouldTranslate === false) {
2835
4002
  continue;
2836
4003
  }
2837
- const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _143 => _143.localizations, 'optionalAccess', _144 => _144[locale]]);
4004
+ const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _170 => _170.localizations, 'optionalAccess', _171 => _171[locale]]);
2838
4005
  if (langTranslationEntity) {
2839
4006
  if ("stringUnit" in langTranslationEntity) {
2840
4007
  resultData[translationKey] = langTranslationEntity.stringUnit.value;
@@ -2843,7 +4010,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
2843
4010
  resultData[translationKey] = {};
2844
4011
  const pluralForms = langTranslationEntity.variations.plural;
2845
4012
  for (const form in pluralForms) {
2846
- if (_optionalChain([pluralForms, 'access', _145 => _145[form], 'optionalAccess', _146 => _146.stringUnit, 'optionalAccess', _147 => _147.value])) {
4013
+ if (_optionalChain([pluralForms, 'access', _172 => _172[form], 'optionalAccess', _173 => _173.stringUnit, 'optionalAccess', _174 => _174.value])) {
2847
4014
  resultData[translationKey][form] = pluralForms[form].stringUnit.value;
2848
4015
  }
2849
4016
  }
@@ -2869,7 +4036,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
2869
4036
  const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
2870
4037
  if (typeof value === "string") {
2871
4038
  langDataToMerge.strings[key] = {
2872
- extractionState: _optionalChain([originalInput, 'optionalAccess', _148 => _148.strings, 'optionalAccess', _149 => _149[key], 'optionalAccess', _150 => _150.extractionState]),
4039
+ extractionState: _optionalChain([originalInput, 'optionalAccess', _175 => _175.strings, 'optionalAccess', _176 => _176[key], 'optionalAccess', _177 => _177.extractionState]),
2873
4040
  localizations: {
2874
4041
  [locale]: {
2875
4042
  stringUnit: {
@@ -2927,7 +4094,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
2927
4094
  for (const [locale, localization] of Object.entries(
2928
4095
  entity.localizations
2929
4096
  )) {
2930
- if (_optionalChain([localization, 'access', _151 => _151.variations, 'optionalAccess', _152 => _152.plural])) {
4097
+ if (_optionalChain([localization, 'access', _178 => _178.variations, 'optionalAccess', _179 => _179.plural])) {
2931
4098
  const pluralForms = localization.variations.plural;
2932
4099
  for (const form in pluralForms) {
2933
4100
  const pluralKey = `${translationKey}/${form}`;
@@ -2947,7 +4114,7 @@ function _removeLocale(input2, locale) {
2947
4114
  const { strings } = input2;
2948
4115
  const newStrings = _lodash2.default.cloneDeep(strings);
2949
4116
  for (const [key, value] of Object.entries(newStrings)) {
2950
- if (_optionalChain([value, 'access', _153 => _153.localizations, 'optionalAccess', _154 => _154[locale]])) {
4117
+ if (_optionalChain([value, 'access', _180 => _180.localizations, 'optionalAccess', _181 => _181[locale]])) {
2951
4118
  delete value.localizations[locale];
2952
4119
  }
2953
4120
  }
@@ -3139,14 +4306,14 @@ function pluralWithMetaToXcstrings(data) {
3139
4306
  if (element.type === "literal") {
3140
4307
  text += element.value;
3141
4308
  } else if (element.type === "pound") {
3142
- const pluralVar = Object.entries(_optionalChain([data, 'access', _155 => _155._meta, 'optionalAccess', _156 => _156.variables]) || {}).find(
4309
+ const pluralVar = Object.entries(_optionalChain([data, 'access', _182 => _182._meta, 'optionalAccess', _183 => _183.variables]) || {}).find(
3143
4310
  ([_36, meta]) => meta.role === "plural"
3144
4311
  );
3145
- text += _optionalChain([pluralVar, 'optionalAccess', _157 => _157[1], 'access', _158 => _158.format]) || "%lld";
4312
+ text += _optionalChain([pluralVar, 'optionalAccess', _184 => _184[1], 'access', _185 => _185.format]) || "%lld";
3146
4313
  } else if (element.type === "argument") {
3147
4314
  const varName = element.value;
3148
- const varMeta = _optionalChain([data, 'access', _159 => _159._meta, 'optionalAccess', _160 => _160.variables, 'optionalAccess', _161 => _161[varName]]);
3149
- text += _optionalChain([varMeta, 'optionalAccess', _162 => _162.format]) || "%@";
4315
+ const varMeta = _optionalChain([data, 'access', _186 => _186._meta, 'optionalAccess', _187 => _187.variables, 'optionalAccess', _188 => _188[varName]]);
4316
+ text += _optionalChain([varMeta, 'optionalAccess', _189 => _189.format]) || "%@";
3150
4317
  }
3151
4318
  }
3152
4319
  let xcstringsFormName = form;
@@ -3524,8 +4691,8 @@ async function formatDataWithBiome(data, filePath, options) {
3524
4691
  });
3525
4692
  return formatted.content;
3526
4693
  } catch (error) {
3527
- const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _163 => _163.stackTrace, 'optionalAccess', _164 => _164.toString, 'call', _165 => _165(), 'access', _166 => _166.split, 'call', _167 => _167("\n"), 'access', _168 => _168[0]]) : "";
3528
- if (_optionalChain([errorMessage, 'optionalAccess', _169 => _169.includes, 'call', _170 => _170("does not exist in the workspace")])) {
4694
+ const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _190 => _190.stackTrace, 'optionalAccess', _191 => _191.toString, 'call', _192 => _192(), 'access', _193 => _193.split, 'call', _194 => _194("\n"), 'access', _195 => _195[0]]) : "";
4695
+ if (_optionalChain([errorMessage, 'optionalAccess', _196 => _196.includes, 'call', _197 => _197("does not exist in the workspace")])) {
3529
4696
  } else {
3530
4697
  console.log(`\u26A0\uFE0F Biome skipped ${path14.default.basename(filePath)}`);
3531
4698
  if (errorMessage) {
@@ -3572,7 +4739,7 @@ function createPoDataLoader(params) {
3572
4739
  Object.entries(entries).forEach(([msgid, entry]) => {
3573
4740
  if (msgid && entry.msgid) {
3574
4741
  const context = entry.msgctxt || "";
3575
- const fullEntry = _optionalChain([parsedPo, 'access', _171 => _171.translations, 'access', _172 => _172[context], 'optionalAccess', _173 => _173[msgid]]);
4742
+ const fullEntry = _optionalChain([parsedPo, 'access', _198 => _198.translations, 'access', _199 => _199[context], 'optionalAccess', _200 => _200[msgid]]);
3576
4743
  if (fullEntry) {
3577
4744
  result[msgid] = fullEntry;
3578
4745
  }
@@ -3582,8 +4749,8 @@ function createPoDataLoader(params) {
3582
4749
  return result;
3583
4750
  },
3584
4751
  async push(locale, data, originalInput, originalLocale, pullInput) {
3585
- const currentSections = _optionalChain([pullInput, 'optionalAccess', _174 => _174.split, 'call', _175 => _175("\n\n"), 'access', _176 => _176.filter, 'call', _177 => _177(Boolean)]) || [];
3586
- const originalSections = _optionalChain([originalInput, 'optionalAccess', _178 => _178.split, 'call', _179 => _179("\n\n"), 'access', _180 => _180.filter, 'call', _181 => _181(Boolean)]) || [];
4752
+ const currentSections = _optionalChain([pullInput, 'optionalAccess', _201 => _201.split, 'call', _202 => _202("\n\n"), 'access', _203 => _203.filter, 'call', _204 => _204(Boolean)]) || [];
4753
+ const originalSections = _optionalChain([originalInput, 'optionalAccess', _205 => _205.split, 'call', _206 => _206("\n\n"), 'access', _207 => _207.filter, 'call', _208 => _208(Boolean)]) || [];
3587
4754
  const result = originalSections.map((section) => {
3588
4755
  const sectionPo = _gettextparser2.default.po.parse(section);
3589
4756
  if (Object.keys(sectionPo.translations).length === 0) {
@@ -3652,8 +4819,8 @@ function createPoContentLoader() {
3652
4819
  {
3653
4820
  ...entry,
3654
4821
  msgstr: [
3655
- _optionalChain([data, 'access', _182 => _182[entry.msgid], 'optionalAccess', _183 => _183.singular]),
3656
- _optionalChain([data, 'access', _184 => _184[entry.msgid], 'optionalAccess', _185 => _185.plural]) || null
4822
+ _optionalChain([data, 'access', _209 => _209[entry.msgid], 'optionalAccess', _210 => _210.singular]),
4823
+ _optionalChain([data, 'access', _211 => _211[entry.msgid], 'optionalAccess', _212 => _212.plural]) || null
3657
4824
  ].filter(Boolean)
3658
4825
  }
3659
4826
  ]).fromPairs().value();
@@ -3775,7 +4942,7 @@ function pullV1(xliffElement, locale, originalLocale) {
3775
4942
  let key = getTransUnitKey(unit);
3776
4943
  if (!key) return;
3777
4944
  if (seenKeys.has(key)) {
3778
- const id = _optionalChain([unit, 'access', _186 => _186.getAttribute, 'call', _187 => _187("id"), 'optionalAccess', _188 => _188.trim, 'call', _189 => _189()]);
4945
+ const id = _optionalChain([unit, 'access', _213 => _213.getAttribute, 'call', _214 => _214("id"), 'optionalAccess', _215 => _215.trim, 'call', _216 => _216()]);
3779
4946
  if (id) {
3780
4947
  key = `${key}#${id}`;
3781
4948
  } else {
@@ -3823,7 +4990,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
3823
4990
  let key = getTransUnitKey(unit);
3824
4991
  if (!key) return;
3825
4992
  if (seenKeys.has(key)) {
3826
- const id = _optionalChain([unit, 'access', _190 => _190.getAttribute, 'call', _191 => _191("id"), 'optionalAccess', _192 => _192.trim, 'call', _193 => _193()]);
4993
+ const id = _optionalChain([unit, 'access', _217 => _217.getAttribute, 'call', _218 => _218("id"), 'optionalAccess', _219 => _219.trim, 'call', _220 => _220()]);
3827
4994
  if (id) {
3828
4995
  key = `${key}#${id}`;
3829
4996
  } else {
@@ -3865,7 +5032,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
3865
5032
  const translationKeys = new Set(Object.keys(translations));
3866
5033
  existingUnits.forEach((unit, key) => {
3867
5034
  if (!translationKeys.has(key)) {
3868
- _optionalChain([unit, 'access', _194 => _194.parentNode, 'optionalAccess', _195 => _195.removeChild, 'call', _196 => _196(unit)]);
5035
+ _optionalChain([unit, 'access', _221 => _221.parentNode, 'optionalAccess', _222 => _222.removeChild, 'call', _223 => _223(unit)]);
3869
5036
  }
3870
5037
  });
3871
5038
  return serializeWithDeclaration(
@@ -3908,18 +5075,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
3908
5075
  Array.from(container.children).forEach((child) => {
3909
5076
  const tagName = child.tagName;
3910
5077
  if (tagName === "unit") {
3911
- const unitId = _optionalChain([child, 'access', _197 => _197.getAttribute, 'call', _198 => _198("id"), 'optionalAccess', _199 => _199.trim, 'call', _200 => _200()]);
5078
+ const unitId = _optionalChain([child, 'access', _224 => _224.getAttribute, 'call', _225 => _225("id"), 'optionalAccess', _226 => _226.trim, 'call', _227 => _227()]);
3912
5079
  if (!unitId) return;
3913
5080
  const key = `resources/${fileId}/${currentPath}${unitId}/source`;
3914
5081
  const segment = child.querySelector("segment");
3915
- const source = _optionalChain([segment, 'optionalAccess', _201 => _201.querySelector, 'call', _202 => _202("source")]);
5082
+ const source = _optionalChain([segment, 'optionalAccess', _228 => _228.querySelector, 'call', _229 => _229("source")]);
3916
5083
  if (source) {
3917
5084
  result[key] = extractTextContent(source);
3918
5085
  } else {
3919
5086
  result[key] = unitId;
3920
5087
  }
3921
5088
  } else if (tagName === "group") {
3922
- const groupId = _optionalChain([child, 'access', _203 => _203.getAttribute, 'call', _204 => _204("id"), 'optionalAccess', _205 => _205.trim, 'call', _206 => _206()]);
5089
+ const groupId = _optionalChain([child, 'access', _230 => _230.getAttribute, 'call', _231 => _231("id"), 'optionalAccess', _232 => _232.trim, 'call', _233 => _233()]);
3923
5090
  const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
3924
5091
  traverseUnitsV2(child, fileId, newPath, result);
3925
5092
  }
@@ -3955,12 +5122,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
3955
5122
  Array.from(container.children).forEach((child) => {
3956
5123
  const tagName = child.tagName;
3957
5124
  if (tagName === "unit") {
3958
- const unitId = _optionalChain([child, 'access', _207 => _207.getAttribute, 'call', _208 => _208("id"), 'optionalAccess', _209 => _209.trim, 'call', _210 => _210()]);
5125
+ const unitId = _optionalChain([child, 'access', _234 => _234.getAttribute, 'call', _235 => _235("id"), 'optionalAccess', _236 => _236.trim, 'call', _237 => _237()]);
3959
5126
  if (!unitId) return;
3960
5127
  const key = `resources/${fileId}/${currentPath}${unitId}/source`;
3961
5128
  index.set(key, child);
3962
5129
  } else if (tagName === "group") {
3963
- const groupId = _optionalChain([child, 'access', _211 => _211.getAttribute, 'call', _212 => _212("id"), 'optionalAccess', _213 => _213.trim, 'call', _214 => _214()]);
5130
+ const groupId = _optionalChain([child, 'access', _238 => _238.getAttribute, 'call', _239 => _239("id"), 'optionalAccess', _240 => _240.trim, 'call', _241 => _241()]);
3964
5131
  const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
3965
5132
  indexUnitsV2(child, fileId, newPath, index);
3966
5133
  }
@@ -3981,9 +5148,9 @@ function updateUnitV2(unit, value) {
3981
5148
  setTextContent(source, value);
3982
5149
  }
3983
5150
  function getTransUnitKey(transUnit) {
3984
- const resname = _optionalChain([transUnit, 'access', _215 => _215.getAttribute, 'call', _216 => _216("resname"), 'optionalAccess', _217 => _217.trim, 'call', _218 => _218()]);
5151
+ const resname = _optionalChain([transUnit, 'access', _242 => _242.getAttribute, 'call', _243 => _243("resname"), 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]);
3985
5152
  if (resname) return resname;
3986
- const id = _optionalChain([transUnit, 'access', _219 => _219.getAttribute, 'call', _220 => _220("id"), 'optionalAccess', _221 => _221.trim, 'call', _222 => _222()]);
5153
+ const id = _optionalChain([transUnit, 'access', _246 => _246.getAttribute, 'call', _247 => _247("id"), 'optionalAccess', _248 => _248.trim, 'call', _249 => _249()]);
3987
5154
  if (id) return id;
3988
5155
  const sourceElement = transUnit.querySelector("source");
3989
5156
  if (sourceElement) {
@@ -4040,7 +5207,7 @@ function formatXml(xml) {
4040
5207
  if (cdataNode) {
4041
5208
  return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
4042
5209
  }
4043
- const textContent = _optionalChain([element, 'access', _223 => _223.textContent, 'optionalAccess', _224 => _224.trim, 'call', _225 => _225()]) || "";
5210
+ const textContent = _optionalChain([element, 'access', _250 => _250.textContent, 'optionalAccess', _251 => _251.trim, 'call', _252 => _252()]) || "";
4044
5211
  const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
4045
5212
  if (hasOnlyText && textContent) {
4046
5213
  return `${indent2}${openTag}${textContent}</${tagName}>`;
@@ -4333,7 +5500,7 @@ function createDatoClient(params) {
4333
5500
  ids: !records.length ? void 0 : records.join(",")
4334
5501
  }
4335
5502
  }).catch(
4336
- (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _226 => _226.response, 'optionalAccess', _227 => _227.body, 'optionalAccess', _228 => _228.data, 'optionalAccess', _229 => _229[0]]) || error)
5503
+ (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _253 => _253.response, 'optionalAccess', _254 => _254.body, 'optionalAccess', _255 => _255.data, 'optionalAccess', _256 => _256[0]]) || error)
4337
5504
  );
4338
5505
  },
4339
5506
  findRecordsForModel: async (modelId, records) => {
@@ -4344,10 +5511,10 @@ function createDatoClient(params) {
4344
5511
  filter: {
4345
5512
  type: modelId,
4346
5513
  only_valid: "true",
4347
- ids: !_optionalChain([records, 'optionalAccess', _230 => _230.length]) ? void 0 : records.join(",")
5514
+ ids: !_optionalChain([records, 'optionalAccess', _257 => _257.length]) ? void 0 : records.join(",")
4348
5515
  }
4349
5516
  }).catch(
4350
- (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _231 => _231.response, 'optionalAccess', _232 => _232.body, 'optionalAccess', _233 => _233.data, 'optionalAccess', _234 => _234[0]]) || error)
5517
+ (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _258 => _258.response, 'optionalAccess', _259 => _259.body, 'optionalAccess', _260 => _260.data, 'optionalAccess', _261 => _261[0]]) || error)
4351
5518
  );
4352
5519
  return result;
4353
5520
  } catch (_error) {
@@ -4363,10 +5530,10 @@ function createDatoClient(params) {
4363
5530
  updateRecord: async (id, payload) => {
4364
5531
  try {
4365
5532
  await dato.items.update(id, payload).catch(
4366
- (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _235 => _235.response, 'optionalAccess', _236 => _236.body, 'optionalAccess', _237 => _237.data, 'optionalAccess', _238 => _238[0]]) || error)
5533
+ (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _262 => _262.response, 'optionalAccess', _263 => _263.body, 'optionalAccess', _264 => _264.data, 'optionalAccess', _265 => _265[0]]) || error)
4367
5534
  );
4368
5535
  } catch (_error) {
4369
- if (_optionalChain([_error, 'optionalAccess', _239 => _239.attributes, 'optionalAccess', _240 => _240.details, 'optionalAccess', _241 => _241.message])) {
5536
+ if (_optionalChain([_error, 'optionalAccess', _266 => _266.attributes, 'optionalAccess', _267 => _267.details, 'optionalAccess', _268 => _268.message])) {
4370
5537
  throw new Error(
4371
5538
  [
4372
5539
  `${_error.attributes.details.message}`,
@@ -4388,10 +5555,10 @@ function createDatoClient(params) {
4388
5555
  enableFieldLocalization: async (args) => {
4389
5556
  try {
4390
5557
  await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
4391
- (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _242 => _242.response, 'optionalAccess', _243 => _243.body, 'optionalAccess', _244 => _244.data, 'optionalAccess', _245 => _245[0]]) || error)
5558
+ (error) => Promise.reject(_optionalChain([error, 'optionalAccess', _269 => _269.response, 'optionalAccess', _270 => _270.body, 'optionalAccess', _271 => _271.data, 'optionalAccess', _272 => _272[0]]) || error)
4392
5559
  );
4393
5560
  } catch (_error) {
4394
- if (_optionalChain([_error, 'optionalAccess', _246 => _246.attributes, 'optionalAccess', _247 => _247.code]) === "NOT_FOUND") {
5561
+ if (_optionalChain([_error, 'optionalAccess', _273 => _273.attributes, 'optionalAccess', _274 => _274.code]) === "NOT_FOUND") {
4395
5562
  throw new Error(
4396
5563
  [
4397
5564
  `Field "${args.fieldId}" not found in model "${args.modelId}".`,
@@ -4399,7 +5566,7 @@ function createDatoClient(params) {
4399
5566
  ].join("\n\n")
4400
5567
  );
4401
5568
  }
4402
- if (_optionalChain([_error, 'optionalAccess', _248 => _248.attributes, 'optionalAccess', _249 => _249.details, 'optionalAccess', _250 => _250.message])) {
5569
+ if (_optionalChain([_error, 'optionalAccess', _275 => _275.attributes, 'optionalAccess', _276 => _276.details, 'optionalAccess', _277 => _277.message])) {
4403
5570
  throw new Error(
4404
5571
  [
4405
5572
  `${_error.attributes.details.message}`,
@@ -4477,7 +5644,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
4477
5644
  const records = await dato.findRecordsForModel(modelId);
4478
5645
  const recordChoices = createRecordChoices(
4479
5646
  records,
4480
- _optionalChain([config, 'access', _251 => _251.models, 'access', _252 => _252[modelId], 'optionalAccess', _253 => _253.records]) || [],
5647
+ _optionalChain([config, 'access', _278 => _278.models, 'access', _279 => _279[modelId], 'optionalAccess', _280 => _280.records]) || [],
4481
5648
  project
4482
5649
  );
4483
5650
  const selectedRecords = await promptRecordSelection(
@@ -4496,14 +5663,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
4496
5663
  },
4497
5664
  async pull(locale, input2, initCtx) {
4498
5665
  const result = {};
4499
- for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _254 => _254.models]) || {})) {
4500
- let records = _optionalChain([initCtx, 'optionalAccess', _255 => _255.models, 'access', _256 => _256[modelId], 'access', _257 => _257.records]) || [];
5666
+ for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _281 => _281.models]) || {})) {
5667
+ let records = _optionalChain([initCtx, 'optionalAccess', _282 => _282.models, 'access', _283 => _283[modelId], 'access', _284 => _284.records]) || [];
4501
5668
  const recordIds = records.map((record) => record.id);
4502
5669
  records = await dato.findRecords(recordIds);
4503
5670
  console.log(`Fetched ${records.length} records for model ${modelId}`);
4504
5671
  if (records.length > 0) {
4505
5672
  result[modelId] = {
4506
- fields: _optionalChain([initCtx, 'optionalAccess', _258 => _258.models, 'optionalAccess', _259 => _259[modelId], 'optionalAccess', _260 => _260.fields]) || [],
5673
+ fields: _optionalChain([initCtx, 'optionalAccess', _285 => _285.models, 'optionalAccess', _286 => _286[modelId], 'optionalAccess', _287 => _287.fields]) || [],
4507
5674
  records
4508
5675
  };
4509
5676
  }
@@ -4566,7 +5733,7 @@ function createRecordChoices(records, selectedIds = [], project) {
4566
5733
  return records.map((record) => ({
4567
5734
  name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
4568
5735
  value: record.id,
4569
- checked: _optionalChain([selectedIds, 'optionalAccess', _261 => _261.includes, 'call', _262 => _262(record.id)])
5736
+ checked: _optionalChain([selectedIds, 'optionalAccess', _288 => _288.includes, 'call', _289 => _289(record.id)])
4570
5737
  }));
4571
5738
  }
4572
5739
  async function promptRecordSelection(modelName, choices) {
@@ -4885,7 +6052,7 @@ function createVttLoader() {
4885
6052
  if (!input2) {
4886
6053
  return "";
4887
6054
  }
4888
- const vtt = _optionalChain([_nodewebvtt2.default, 'access', _263 => _263.parse, 'call', _264 => _264(input2), 'optionalAccess', _265 => _265.cues]);
6055
+ const vtt = _optionalChain([_nodewebvtt2.default, 'access', _290 => _290.parse, 'call', _291 => _291(input2), 'optionalAccess', _292 => _292.cues]);
4889
6056
  if (Object.keys(vtt).length === 0) {
4890
6057
  return {};
4891
6058
  } else {
@@ -4948,7 +6115,7 @@ function variableExtractLoader(params) {
4948
6115
  for (let i = 0; i < matches.length; i++) {
4949
6116
  const match2 = matches[i];
4950
6117
  const currentValue = result[key].value;
4951
- const newValue = _optionalChain([currentValue, 'optionalAccess', _266 => _266.replace, 'call', _267 => _267(match2, `{variable:${i}}`)]);
6118
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _293 => _293.replace, 'call', _294 => _294(match2, `{variable:${i}}`)]);
4952
6119
  result[key].value = newValue;
4953
6120
  result[key].variables[i] = match2;
4954
6121
  }
@@ -4961,7 +6128,7 @@ function variableExtractLoader(params) {
4961
6128
  result[key] = valueObj.value;
4962
6129
  const resultValue = result[key];
4963
6130
  if (isICUPluralObject(resultValue)) {
4964
- const originalValue = _optionalChain([originalInput, 'optionalAccess', _268 => _268[key]]);
6131
+ const originalValue = _optionalChain([originalInput, 'optionalAccess', _295 => _295[key]]);
4965
6132
  if (isICUPluralObject(originalValue) && originalValue._meta) {
4966
6133
  resultValue._meta = originalValue._meta;
4967
6134
  resultValue[Symbol.for("@lingo.dev/icu-plural-object")] = true;
@@ -4971,7 +6138,7 @@ function variableExtractLoader(params) {
4971
6138
  const variable = valueObj.variables[i];
4972
6139
  const currentValue = result[key];
4973
6140
  if (typeof currentValue === "string") {
4974
- const newValue = _optionalChain([currentValue, 'optionalAccess', _269 => _269.replace, 'call', _270 => _270(`{variable:${i}}`, variable)]);
6141
+ const newValue = _optionalChain([currentValue, 'optionalAccess', _296 => _296.replace, 'call', _297 => _297(`{variable:${i}}`, variable)]);
4975
6142
  result[key] = newValue;
4976
6143
  }
4977
6144
  }
@@ -5172,7 +6339,7 @@ function createVueJsonLoader() {
5172
6339
  return createLoader({
5173
6340
  pull: async (locale, input2, ctx) => {
5174
6341
  const parsed = parseVueFile(input2);
5175
- return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _271 => _271.i18n, 'optionalAccess', _272 => _272[locale]]), () => ( {}));
6342
+ return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _298 => _298.i18n, 'optionalAccess', _299 => _299[locale]]), () => ( {}));
5176
6343
  },
5177
6344
  push: async (locale, data, originalInput) => {
5178
6345
  const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
@@ -5357,7 +6524,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
5357
6524
  objectExpression.properties.forEach((prop) => {
5358
6525
  if (!t.isObjectProperty(prop)) return;
5359
6526
  const key = getPropertyKey(prop);
5360
- const incomingVal = _optionalChain([data, 'optionalAccess', _273 => _273[key]]);
6527
+ const incomingVal = _optionalChain([data, 'optionalAccess', _300 => _300[key]]);
5361
6528
  if (incomingVal === void 0) {
5362
6529
  return;
5363
6530
  }
@@ -5393,7 +6560,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
5393
6560
  let modified = false;
5394
6561
  arrayExpression.elements.forEach((element, index) => {
5395
6562
  if (!element) return;
5396
- const incomingVal = _optionalChain([incoming, 'optionalAccess', _274 => _274[index]]);
6563
+ const incomingVal = _optionalChain([incoming, 'optionalAccess', _301 => _301[index]]);
5397
6564
  if (incomingVal === void 0) return;
5398
6565
  if (t.isStringLiteral(element) && typeof incomingVal === "string") {
5399
6566
  if (element.value !== incomingVal) {
@@ -5884,7 +7051,7 @@ var AST = class _AST {
5884
7051
  const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
5885
7052
  if (this.isStart() && !this.type)
5886
7053
  ret.unshift([]);
5887
- if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _275 => _275.#parent, 'optionalAccess', _276 => _276.type]) === "!")) {
7054
+ if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _302 => _302.#parent, 'optionalAccess', _303 => _303.type]) === "!")) {
5888
7055
  ret.push({});
5889
7056
  }
5890
7057
  return ret;
@@ -5892,7 +7059,7 @@ var AST = class _AST {
5892
7059
  isStart() {
5893
7060
  if (this.#root === this)
5894
7061
  return true;
5895
- if (!_optionalChain([this, 'access', _277 => _277.#parent, 'optionalAccess', _278 => _278.isStart, 'call', _279 => _279()]))
7062
+ if (!_optionalChain([this, 'access', _304 => _304.#parent, 'optionalAccess', _305 => _305.isStart, 'call', _306 => _306()]))
5896
7063
  return false;
5897
7064
  if (this.#parentIndex === 0)
5898
7065
  return true;
@@ -5908,12 +7075,12 @@ var AST = class _AST {
5908
7075
  isEnd() {
5909
7076
  if (this.#root === this)
5910
7077
  return true;
5911
- if (_optionalChain([this, 'access', _280 => _280.#parent, 'optionalAccess', _281 => _281.type]) === "!")
7078
+ if (_optionalChain([this, 'access', _307 => _307.#parent, 'optionalAccess', _308 => _308.type]) === "!")
5912
7079
  return true;
5913
- if (!_optionalChain([this, 'access', _282 => _282.#parent, 'optionalAccess', _283 => _283.isEnd, 'call', _284 => _284()]))
7080
+ if (!_optionalChain([this, 'access', _309 => _309.#parent, 'optionalAccess', _310 => _310.isEnd, 'call', _311 => _311()]))
5914
7081
  return false;
5915
7082
  if (!this.type)
5916
- return _optionalChain([this, 'access', _285 => _285.#parent, 'optionalAccess', _286 => _286.isEnd, 'call', _287 => _287()]);
7083
+ return _optionalChain([this, 'access', _312 => _312.#parent, 'optionalAccess', _313 => _313.isEnd, 'call', _314 => _314()]);
5917
7084
  const pl = this.#parent ? this.#parent.#parts.length : 0;
5918
7085
  return this.#parentIndex === pl - 1;
5919
7086
  }
@@ -6158,7 +7325,7 @@ var AST = class _AST {
6158
7325
  }
6159
7326
  }
6160
7327
  let end = "";
6161
- if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _288 => _288.#parent, 'optionalAccess', _289 => _289.type]) === "!") {
7328
+ if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _315 => _315.#parent, 'optionalAccess', _316 => _316.type]) === "!") {
6162
7329
  end = "(?:$|\\/)";
6163
7330
  }
6164
7331
  const final2 = start2 + src + end;
@@ -7248,7 +8415,7 @@ function createMdxSectionsSplit2Loader() {
7248
8415
  const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
7249
8416
  const result = {
7250
8417
  frontmatter: data.frontmatter,
7251
- codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _290 => _290.codePlaceholders]) || {},
8418
+ codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _317 => _317.codePlaceholders]) || {},
7252
8419
  content
7253
8420
  };
7254
8421
  return result;
@@ -8281,7 +9448,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
8281
9448
  ]
8282
9449
  });
8283
9450
  const result = JSON.parse(response.text);
8284
- return _optionalChain([result, 'optionalAccess', _291 => _291.data]) || {};
9451
+ return _optionalChain([result, 'optionalAccess', _318 => _318.data]) || {};
8285
9452
  }
8286
9453
  }
8287
9454
  function extractPayloadChunks(payload) {
@@ -8364,7 +9531,7 @@ function getPureModelProvider(provider) {
8364
9531
 
8365
9532
  ${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
8366
9533
  `;
8367
- switch (_optionalChain([provider, 'optionalAccess', _292 => _292.id])) {
9534
+ switch (_optionalChain([provider, 'optionalAccess', _319 => _319.id])) {
8368
9535
  case "openai": {
8369
9536
  if (!process.env.OPENAI_API_KEY) {
8370
9537
  throw new Error(
@@ -8422,7 +9589,7 @@ function getPureModelProvider(provider) {
8422
9589
  })(provider.model);
8423
9590
  }
8424
9591
  default: {
8425
- throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _293 => _293.id])));
9592
+ throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _320 => _320.id])));
8426
9593
  }
8427
9594
  }
8428
9595
  }
@@ -8707,7 +9874,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
8707
9874
  validateParams(i18nConfig, flags);
8708
9875
  ora.succeed("Localization configuration is valid");
8709
9876
  ora.start("Connecting to Lingo.dev Localization Engine...");
8710
- const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _294 => _294.provider]);
9877
+ const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _321 => _321.provider]);
8711
9878
  if (isByokMode) {
8712
9879
  authId = null;
8713
9880
  ora.succeed("Using external provider (BYOK mode)");
@@ -8721,16 +9888,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
8721
9888
  flags
8722
9889
  });
8723
9890
  let buckets = getBuckets(i18nConfig);
8724
- if (_optionalChain([flags, 'access', _295 => _295.bucket, 'optionalAccess', _296 => _296.length])) {
9891
+ if (_optionalChain([flags, 'access', _322 => _322.bucket, 'optionalAccess', _323 => _323.length])) {
8725
9892
  buckets = buckets.filter(
8726
9893
  (bucket) => flags.bucket.includes(bucket.type)
8727
9894
  );
8728
9895
  }
8729
9896
  ora.succeed("Buckets retrieved");
8730
- if (_optionalChain([flags, 'access', _297 => _297.file, 'optionalAccess', _298 => _298.length])) {
9897
+ if (_optionalChain([flags, 'access', _324 => _324.file, 'optionalAccess', _325 => _325.length])) {
8731
9898
  buckets = buckets.map((bucket) => {
8732
9899
  const paths = bucket.paths.filter(
8733
- (path19) => flags.file.find((file) => _optionalChain([path19, 'access', _299 => _299.pathPattern, 'optionalAccess', _300 => _300.includes, 'call', _301 => _301(file)]))
9900
+ (path19) => flags.file.find((file) => _optionalChain([path19, 'access', _326 => _326.pathPattern, 'optionalAccess', _327 => _327.includes, 'call', _328 => _328(file)]))
8734
9901
  );
8735
9902
  return { ...bucket, paths };
8736
9903
  }).filter((bucket) => bucket.paths.length > 0);
@@ -8751,7 +9918,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
8751
9918
  });
8752
9919
  }
8753
9920
  }
8754
- const targetLocales = _optionalChain([flags, 'access', _302 => _302.locale, 'optionalAccess', _303 => _303.length]) ? flags.locale : i18nConfig.locale.targets;
9921
+ const targetLocales = _optionalChain([flags, 'access', _329 => _329.locale, 'optionalAccess', _330 => _330.length]) ? flags.locale : i18nConfig.locale.targets;
8755
9922
  ora.start("Setting up localization cache...");
8756
9923
  const checkLockfileProcessor = createDeltaProcessor("");
8757
9924
  const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
@@ -9037,7 +10204,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
9037
10204
  }
9038
10205
  const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
9039
10206
  const checksums = await deltaProcessor.createChecksums(sourceData);
9040
- if (!_optionalChain([flags, 'access', _304 => _304.locale, 'optionalAccess', _305 => _305.length])) {
10207
+ if (!_optionalChain([flags, 'access', _331 => _331.locale, 'optionalAccess', _332 => _332.length])) {
9041
10208
  await deltaProcessor.saveChecksums(checksums);
9042
10209
  }
9043
10210
  }
@@ -9161,12 +10328,12 @@ function validateParams(i18nConfig, flags) {
9161
10328
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
9162
10329
  docUrl: "bucketNotFound"
9163
10330
  });
9164
- } else if (_optionalChain([flags, 'access', _306 => _306.locale, 'optionalAccess', _307 => _307.some, 'call', _308 => _308((locale) => !i18nConfig.locale.targets.includes(locale))])) {
10331
+ } else if (_optionalChain([flags, 'access', _333 => _333.locale, 'optionalAccess', _334 => _334.some, 'call', _335 => _335((locale) => !i18nConfig.locale.targets.includes(locale))])) {
9165
10332
  throw new ValidationError({
9166
10333
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
9167
10334
  docUrl: "localeTargetNotFound"
9168
10335
  });
9169
- } else if (_optionalChain([flags, 'access', _309 => _309.bucket, 'optionalAccess', _310 => _310.some, 'call', _311 => _311(
10336
+ } else if (_optionalChain([flags, 'access', _336 => _336.bucket, 'optionalAccess', _337 => _337.some, 'call', _338 => _338(
9170
10337
  (bucket) => !i18nConfig.buckets[bucket]
9171
10338
  )])) {
9172
10339
  throw new ValidationError({
@@ -9692,7 +10859,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
9692
10859
  const response = await engine.whoami();
9693
10860
  return {
9694
10861
  authenticated: !!response,
9695
- username: _optionalChain([response, 'optionalAccess', _312 => _312.email])
10862
+ username: _optionalChain([response, 'optionalAccess', _339 => _339.email])
9696
10863
  };
9697
10864
  } catch (error) {
9698
10865
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -9808,7 +10975,7 @@ function createExplicitLocalizer(provider) {
9808
10975
  }
9809
10976
  function createAiSdkLocalizer(params) {
9810
10977
  const skipAuth = params.skipAuth === true;
9811
- const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _313 => _313.apiKeyName]), () => ( ""))];
10978
+ const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _340 => _340.apiKeyName]), () => ( ""))];
9812
10979
  if (!skipAuth && !apiKey || !params.apiKeyName) {
9813
10980
  throw new Error(
9814
10981
  _dedent2.default`
@@ -9942,8 +11109,8 @@ async function setup(input2) {
9942
11109
  throw new Error(
9943
11110
  "No buckets found in i18n.json. Please add at least one bucket containing i18n content."
9944
11111
  );
9945
- } else if (_optionalChain([ctx, 'access', _314 => _314.flags, 'access', _315 => _315.bucket, 'optionalAccess', _316 => _316.some, 'call', _317 => _317(
9946
- (bucket) => !_optionalChain([ctx, 'access', _318 => _318.config, 'optionalAccess', _319 => _319.buckets, 'access', _320 => _320[bucket]])
11112
+ } else if (_optionalChain([ctx, 'access', _341 => _341.flags, 'access', _342 => _342.bucket, 'optionalAccess', _343 => _343.some, 'call', _344 => _344(
11113
+ (bucket) => !_optionalChain([ctx, 'access', _345 => _345.config, 'optionalAccess', _346 => _346.buckets, 'access', _347 => _347[bucket]])
9947
11114
  )])) {
9948
11115
  throw new Error(
9949
11116
  `One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
@@ -9956,7 +11123,7 @@ async function setup(input2) {
9956
11123
  title: "Selecting localization provider",
9957
11124
  task: async (ctx, task) => {
9958
11125
  ctx.localizer = createLocalizer(
9959
- _optionalChain([ctx, 'access', _321 => _321.config, 'optionalAccess', _322 => _322.provider]),
11126
+ _optionalChain([ctx, 'access', _348 => _348.config, 'optionalAccess', _349 => _349.provider]),
9960
11127
  ctx.flags.apiKey
9961
11128
  );
9962
11129
  if (!ctx.localizer) {
@@ -9969,7 +11136,7 @@ async function setup(input2) {
9969
11136
  },
9970
11137
  {
9971
11138
  title: "Checking authentication",
9972
- enabled: (ctx) => _optionalChain([ctx, 'access', _323 => _323.localizer, 'optionalAccess', _324 => _324.id]) === "Lingo.dev",
11139
+ enabled: (ctx) => _optionalChain([ctx, 'access', _350 => _350.localizer, 'optionalAccess', _351 => _351.id]) === "Lingo.dev",
9973
11140
  task: async (ctx, task) => {
9974
11141
  const authStatus = await ctx.localizer.checkAuth();
9975
11142
  if (!authStatus.authenticated) {
@@ -9982,7 +11149,7 @@ async function setup(input2) {
9982
11149
  },
9983
11150
  {
9984
11151
  title: "Validating configuration",
9985
- enabled: (ctx) => _optionalChain([ctx, 'access', _325 => _325.localizer, 'optionalAccess', _326 => _326.id]) !== "Lingo.dev",
11152
+ enabled: (ctx) => _optionalChain([ctx, 'access', _352 => _352.localizer, 'optionalAccess', _353 => _353.id]) !== "Lingo.dev",
9986
11153
  task: async (ctx, task) => {
9987
11154
  const validationStatus = await ctx.localizer.validateSettings();
9988
11155
  if (!validationStatus.valid) {
@@ -10299,7 +11466,7 @@ function createWorkerTask(args) {
10299
11466
  const processableData = _lodash2.default.chain(sourceData).entries().filter(
10300
11467
  ([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
10301
11468
  ).filter(
10302
- ([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _327 => _327.onlyKeys, 'optionalAccess', _328 => _328.some, 'call', _329 => _329(
11469
+ ([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _354 => _354.onlyKeys, 'optionalAccess', _355 => _355.some, 'call', _356 => _356(
10303
11470
  (pattern) => minimatch(key, pattern)
10304
11471
  )])
10305
11472
  ).fromPairs().value();
@@ -10367,7 +11534,7 @@ function createWorkerTask(args) {
10367
11534
  finalRenamedTargetData
10368
11535
  );
10369
11536
  const checksums = await deltaProcessor.createChecksums(sourceData);
10370
- if (!_optionalChain([args, 'access', _330 => _330.ctx, 'access', _331 => _331.flags, 'access', _332 => _332.targetLocale, 'optionalAccess', _333 => _333.length])) {
11537
+ if (!_optionalChain([args, 'access', _357 => _357.ctx, 'access', _358 => _358.flags, 'access', _359 => _359.targetLocale, 'optionalAccess', _360 => _360.length])) {
10371
11538
  await deltaProcessor.saveChecksums(checksums);
10372
11539
  }
10373
11540
  });
@@ -10572,10 +11739,10 @@ var flagsSchema2 = _zod.z.object({
10572
11739
  async function frozen(input2) {
10573
11740
  console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
10574
11741
  let buckets = getBuckets(input2.config);
10575
- if (_optionalChain([input2, 'access', _334 => _334.flags, 'access', _335 => _335.bucket, 'optionalAccess', _336 => _336.length])) {
11742
+ if (_optionalChain([input2, 'access', _361 => _361.flags, 'access', _362 => _362.bucket, 'optionalAccess', _363 => _363.length])) {
10576
11743
  buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
10577
11744
  }
10578
- if (_optionalChain([input2, 'access', _337 => _337.flags, 'access', _338 => _338.file, 'optionalAccess', _339 => _339.length])) {
11745
+ if (_optionalChain([input2, 'access', _364 => _364.flags, 'access', _365 => _365.file, 'optionalAccess', _366 => _366.length])) {
10579
11746
  buckets = buckets.map((bucket) => {
10580
11747
  const paths = bucket.paths.filter(
10581
11748
  (p) => input2.flags.file.some(
@@ -10712,13 +11879,13 @@ async function frozen(input2) {
10712
11879
 
10713
11880
  // src/cli/cmd/run/_utils.ts
10714
11881
  async function determineAuthId(ctx) {
10715
- const isByokMode = !!_optionalChain([ctx, 'access', _340 => _340.config, 'optionalAccess', _341 => _341.provider]);
11882
+ const isByokMode = !!_optionalChain([ctx, 'access', _367 => _367.config, 'optionalAccess', _368 => _368.provider]);
10716
11883
  if (isByokMode) {
10717
11884
  return null;
10718
11885
  } else {
10719
11886
  try {
10720
- const authStatus = await _optionalChain([ctx, 'access', _342 => _342.localizer, 'optionalAccess', _343 => _343.checkAuth, 'call', _344 => _344()]);
10721
- return _optionalChain([authStatus, 'optionalAccess', _345 => _345.username]) || null;
11887
+ const authStatus = await _optionalChain([ctx, 'access', _369 => _369.localizer, 'optionalAccess', _370 => _370.checkAuth, 'call', _371 => _371()]);
11888
+ return _optionalChain([authStatus, 'optionalAccess', _372 => _372.username]) || null;
10722
11889
  } catch (e3) {
10723
11890
  return null;
10724
11891
  }
@@ -10915,7 +12082,7 @@ var InBranchFlow = class extends IntegrationFlow {
10915
12082
  _child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
10916
12083
  _child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
10917
12084
  _child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
10918
- _optionalChain([this, 'access', _346 => _346.platformKit, 'optionalAccess', _347 => _347.gitConfig, 'call', _348 => _348()]);
12085
+ _optionalChain([this, 'access', _373 => _373.platformKit, 'optionalAccess', _374 => _374.gitConfig, 'call', _375 => _375()]);
10919
12086
  _child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
10920
12087
  _child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
10921
12088
  if (!processOwnCommits) {
@@ -10947,7 +12114,7 @@ var InBranchFlow = class extends IntegrationFlow {
10947
12114
  // src/cli/cmd/ci/flows/pull-request.ts
10948
12115
  var PullRequestFlow = class extends InBranchFlow {
10949
12116
  async preRun() {
10950
- const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _349 => _349()]);
12117
+ const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _376 => _376()]);
10951
12118
  if (!canContinue) {
10952
12119
  return false;
10953
12120
  }
@@ -11210,10 +12377,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
11210
12377
  repo_slug: this.platformConfig.repositoryName,
11211
12378
  state: "OPEN"
11212
12379
  }).then(({ data: { values } }) => {
11213
- return _optionalChain([values, 'optionalAccess', _350 => _350.find, 'call', _351 => _351(
11214
- ({ source, destination }) => _optionalChain([source, 'optionalAccess', _352 => _352.branch, 'optionalAccess', _353 => _353.name]) === branch && _optionalChain([destination, 'optionalAccess', _354 => _354.branch, 'optionalAccess', _355 => _355.name]) === this.platformConfig.baseBranchName
12380
+ return _optionalChain([values, 'optionalAccess', _377 => _377.find, 'call', _378 => _378(
12381
+ ({ source, destination }) => _optionalChain([source, 'optionalAccess', _379 => _379.branch, 'optionalAccess', _380 => _380.name]) === branch && _optionalChain([destination, 'optionalAccess', _381 => _381.branch, 'optionalAccess', _382 => _382.name]) === this.platformConfig.baseBranchName
11215
12382
  )]);
11216
- }).then((pr) => _optionalChain([pr, 'optionalAccess', _356 => _356.id]));
12383
+ }).then((pr) => _optionalChain([pr, 'optionalAccess', _383 => _383.id]));
11217
12384
  }
11218
12385
  async closePullRequest({ pullRequestNumber }) {
11219
12386
  await this.bb.repositories.declinePullRequest({
@@ -11309,7 +12476,7 @@ var GitHubPlatformKit = class extends PlatformKit {
11309
12476
  repo: this.platformConfig.repositoryName,
11310
12477
  base: this.platformConfig.baseBranchName,
11311
12478
  state: "open"
11312
- }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _357 => _357.number]));
12479
+ }).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _384 => _384.number]));
11313
12480
  }
11314
12481
  async closePullRequest({ pullRequestNumber }) {
11315
12482
  await this.octokit.rest.pulls.update({
@@ -11436,7 +12603,7 @@ var GitlabPlatformKit = class extends PlatformKit {
11436
12603
  sourceBranch: branch,
11437
12604
  state: "opened"
11438
12605
  });
11439
- return _optionalChain([mergeRequests, 'access', _358 => _358[0], 'optionalAccess', _359 => _359.iid]);
12606
+ return _optionalChain([mergeRequests, 'access', _385 => _385[0], 'optionalAccess', _386 => _386.iid]);
11440
12607
  }
11441
12608
  async closePullRequest({
11442
12609
  pullRequestNumber
@@ -11542,7 +12709,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
11542
12709
  }
11543
12710
  const env = {
11544
12711
  LINGODOTDEV_API_KEY: settings.auth.apiKey,
11545
- LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _360 => _360.pullRequest, 'optionalAccess', _361 => _361.toString, 'call', _362 => _362()]) || "false",
12712
+ LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _387 => _387.pullRequest, 'optionalAccess', _388 => _388.toString, 'call', _389 => _389()]) || "false",
11546
12713
  ...options.commitMessage && {
11547
12714
  LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
11548
12715
  },
@@ -11562,7 +12729,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
11562
12729
  const { isPullRequestMode } = platformKit.config;
11563
12730
  ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
11564
12731
  const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
11565
- const canRun = await _optionalChain([flow, 'access', _363 => _363.preRun, 'optionalCall', _364 => _364()]);
12732
+ const canRun = await _optionalChain([flow, 'access', _390 => _390.preRun, 'optionalCall', _391 => _391()]);
11566
12733
  if (canRun === false) {
11567
12734
  return;
11568
12735
  }
@@ -11572,7 +12739,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
11572
12739
  if (!hasChanges) {
11573
12740
  return;
11574
12741
  }
11575
- await _optionalChain([flow, 'access', _365 => _365.postRun, 'optionalCall', _366 => _366()]);
12742
+ await _optionalChain([flow, 'access', _392 => _392.postRun, 'optionalCall', _393 => _393()]);
11576
12743
  });
11577
12744
  function parseBooleanArg(val) {
11578
12745
  if (val === true) return true;
@@ -11609,8 +12776,8 @@ function exitGracefully(elapsedMs = 0) {
11609
12776
  }
11610
12777
  }
11611
12778
  function checkForPendingOperations() {
11612
- const activeHandles = _optionalChain([process, 'access', _367 => _367._getActiveHandles, 'optionalCall', _368 => _368()]) || [];
11613
- const activeRequests = _optionalChain([process, 'access', _369 => _369._getActiveRequests, 'optionalCall', _370 => _370()]) || [];
12779
+ const activeHandles = _optionalChain([process, 'access', _394 => _394._getActiveHandles, 'optionalCall', _395 => _395()]) || [];
12780
+ const activeRequests = _optionalChain([process, 'access', _396 => _396._getActiveRequests, 'optionalCall', _397 => _397()]) || [];
11614
12781
  const nonStandardHandles = activeHandles.filter((handle) => {
11615
12782
  if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
11616
12783
  return false;
@@ -11679,17 +12846,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
11679
12846
  flags
11680
12847
  });
11681
12848
  let buckets = getBuckets(i18nConfig);
11682
- if (_optionalChain([flags, 'access', _371 => _371.bucket, 'optionalAccess', _372 => _372.length])) {
12849
+ if (_optionalChain([flags, 'access', _398 => _398.bucket, 'optionalAccess', _399 => _399.length])) {
11683
12850
  buckets = buckets.filter(
11684
12851
  (bucket) => flags.bucket.includes(bucket.type)
11685
12852
  );
11686
12853
  }
11687
12854
  ora.succeed("Buckets retrieved");
11688
- if (_optionalChain([flags, 'access', _373 => _373.file, 'optionalAccess', _374 => _374.length])) {
12855
+ if (_optionalChain([flags, 'access', _400 => _400.file, 'optionalAccess', _401 => _401.length])) {
11689
12856
  buckets = buckets.map((bucket) => {
11690
12857
  const paths = bucket.paths.filter(
11691
12858
  (path19) => flags.file.find(
11692
- (file) => _optionalChain([path19, 'access', _375 => _375.pathPattern, 'optionalAccess', _376 => _376.includes, 'call', _377 => _377(file)]) || _optionalChain([path19, 'access', _378 => _378.pathPattern, 'optionalAccess', _379 => _379.match, 'call', _380 => _380(file)]) || minimatch(path19.pathPattern, file)
12859
+ (file) => _optionalChain([path19, 'access', _402 => _402.pathPattern, 'optionalAccess', _403 => _403.includes, 'call', _404 => _404(file)]) || _optionalChain([path19, 'access', _405 => _405.pathPattern, 'optionalAccess', _406 => _406.match, 'call', _407 => _407(file)]) || minimatch(path19.pathPattern, file)
11693
12860
  )
11694
12861
  );
11695
12862
  return { ...bucket, paths };
@@ -11709,7 +12876,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
11709
12876
  });
11710
12877
  }
11711
12878
  }
11712
- const targetLocales = _optionalChain([flags, 'access', _381 => _381.locale, 'optionalAccess', _382 => _382.length]) ? flags.locale : i18nConfig.locale.targets;
12879
+ const targetLocales = _optionalChain([flags, 'access', _408 => _408.locale, 'optionalAccess', _409 => _409.length]) ? flags.locale : i18nConfig.locale.targets;
11713
12880
  let totalSourceKeyCount = 0;
11714
12881
  let uniqueKeysToTranslate = 0;
11715
12882
  let totalExistingTranslations = 0;
@@ -12115,12 +13282,12 @@ function validateParams2(i18nConfig, flags) {
12115
13282
  message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
12116
13283
  docUrl: "bucketNotFound"
12117
13284
  });
12118
- } else if (_optionalChain([flags, 'access', _383 => _383.locale, 'optionalAccess', _384 => _384.some, 'call', _385 => _385((locale) => !i18nConfig.locale.targets.includes(locale))])) {
13285
+ } else if (_optionalChain([flags, 'access', _410 => _410.locale, 'optionalAccess', _411 => _411.some, 'call', _412 => _412((locale) => !i18nConfig.locale.targets.includes(locale))])) {
12119
13286
  throw new CLIError({
12120
13287
  message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
12121
13288
  docUrl: "localeTargetNotFound"
12122
13289
  });
12123
- } else if (_optionalChain([flags, 'access', _386 => _386.bucket, 'optionalAccess', _387 => _387.some, 'call', _388 => _388(
13290
+ } else if (_optionalChain([flags, 'access', _413 => _413.bucket, 'optionalAccess', _414 => _414.some, 'call', _415 => _415(
12124
13291
  (bucket) => !i18nConfig.buckets[bucket]
12125
13292
  )])) {
12126
13293
  throw new CLIError({
@@ -12212,7 +13379,7 @@ async function renderHero2() {
12212
13379
  // package.json
12213
13380
  var package_default = {
12214
13381
  name: "lingo.dev",
12215
- version: "0.113.5",
13382
+ version: "0.113.7",
12216
13383
  description: "Lingo.dev CLI",
12217
13384
  private: false,
12218
13385
  publishConfig: {
@@ -12419,6 +13586,7 @@ var package_default = {
12419
13586
  "remark-parse": "^11.0.0",
12420
13587
  "remark-rehype": "^11.1.2",
12421
13588
  "remark-stringify": "^11.0.0",
13589
+ sax: "^1.4.1",
12422
13590
  "srt-parser-2": "^1.2.3",
12423
13591
  unified: "^11.0.5",
12424
13592
  "unist-util-visit": "^5.0.0",
@@ -12502,7 +13670,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
12502
13670
  if (options.file && options.file.length) {
12503
13671
  buckets = buckets.map((bucket) => {
12504
13672
  const paths = bucket.paths.filter(
12505
- (bucketPath) => _optionalChain([options, 'access', _389 => _389.file, 'optionalAccess', _390 => _390.some, 'call', _391 => _391((f) => bucketPath.pathPattern.includes(f))])
13673
+ (bucketPath) => _optionalChain([options, 'access', _416 => _416.file, 'optionalAccess', _417 => _417.some, 'call', _418 => _418((f) => bucketPath.pathPattern.includes(f))])
12506
13674
  );
12507
13675
  return { ...bucket, paths };
12508
13676
  }).filter((bucket) => bucket.paths.length > 0);