@danielx/civet 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -1271,6 +1271,14 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1271
1271
  }
1272
1272
 
1273
1273
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
1274
+ var range = (start, end) => {
1275
+ let length = end - start;
1276
+ if (length <= 0) return [];
1277
+ let arr = Array(length);
1278
+ for (let i = 0; i < length; ++i)
1279
+ arr[i] = i + start;
1280
+ return arr;
1281
+ };
1274
1282
  function makeRef(base = "ref", id = base) {
1275
1283
  return {
1276
1284
  type: "Ref",
@@ -1281,7 +1289,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1281
1289
  function needsRef(expression, base = "ref") {
1282
1290
  if (expression != null && typeof expression == "object") {
1283
1291
  if (Array.isArray(expression)) {
1284
- let nonempty = ((s) => Array.from({ length: expression.length - s }, (_2, i) => s + i))(0).filter((i) => !isWhitespaceOrEmpty(expression[i]));
1292
+ let nonempty = range(0, expression.length).filter((i) => !isWhitespaceOrEmpty(expression[i]));
1285
1293
  if (nonempty.length === 1) {
1286
1294
  let ref1;
1287
1295
  return (ref1 = needsRef(expression[nonempty[0]], base)) ? ref1 : void 0;
@@ -1320,10 +1328,27 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1320
1328
  let ref = maybeRef(exp, base);
1321
1329
  return ref === exp ? { ref, refAssignmentComma: [] } : { ref, ...makeRefAssignment(ref, exp) };
1322
1330
  }
1331
+ function populateRefs(statements) {
1332
+ let refNodes = gatherRecursive(statements, ($) => $.type === "Ref");
1333
+ if (!refNodes.length)
1334
+ return;
1335
+ let ids = gatherRecursive(statements, ($1) => $1.type === "Identifier"), names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
1336
+ for (let i1 = 0, len3 = refNodes.length; i1 < len3; i1++) {
1337
+ let ref = refNodes[i1];
1338
+ if (ref.type !== "Ref")
1339
+ continue;
1340
+ let { base } = ref;
1341
+ ref.type = "Identifier";
1342
+ let n = 0, name = base;
1343
+ for (; names.has(name); )
1344
+ n++, name = `${base}${n}`;
1345
+ names.add(name), ref.children = ref.names = [name];
1346
+ }
1347
+ }
1323
1348
 
1324
1349
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
1325
1350
  function adjustAtBindings(statements, asThis = !1) {
1326
- for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1351
+ for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
1327
1352
  let binding = ref1[i1], { ref } = binding;
1328
1353
  if (asThis) {
1329
1354
  let atBinding = binding.binding;
@@ -1334,7 +1359,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1334
1359
  }
1335
1360
  }
1336
1361
  function adjustBindingElements(elements) {
1337
- let names = elements.flatMap(($1) => $1.names || []), { length } = elements, blockPrefix, restIndex = -1, restCount = 0;
1362
+ let names = elements.flatMap(($2) => $2.names || []), { length } = elements, blockPrefix, restIndex = -1, restCount = 0;
1338
1363
  for (let i2 = 0, len1 = elements.length; i2 < len1; i2++) {
1339
1364
  let i = i2, { type } = elements[i2];
1340
1365
  type === "BindingRestElement" && (restIndex < 0 && (restIndex = i), restCount++);
@@ -1382,21 +1407,40 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1382
1407
  length
1383
1408
  };
1384
1409
  }
1410
+ function gatherSubbindings(node, subbindings = []) {
1411
+ for (let ref2 = gatherRecursiveAll(node, ($) => $.subbinding != null), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
1412
+ let p = ref2[i3], { subbinding } = p;
1413
+ subbindings.push(", ", subbinding), gatherSubbindings(subbinding, subbindings);
1414
+ }
1415
+ return subbindings;
1416
+ }
1417
+ function simplifyBindingProperties(node) {
1418
+ let results = [];
1419
+ for (let ref3 = gatherRecursiveAll(node, ($3) => $3.type === "BindingProperty"), i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
1420
+ let p = ref3[i4], { name, value } = p;
1421
+ if (value?.type === "NamedBindingPattern" && value.binding === name) {
1422
+ let [ws] = p.children;
1423
+ results.push(p.children = [ws, name, p.delim]);
1424
+ } else
1425
+ results.push(void 0);
1426
+ }
1427
+ return results;
1428
+ }
1385
1429
  function gatherBindingCode(statements, opts) {
1386
1430
  let thisAssignments = [], splices = [];
1387
1431
  function insertRestSplices(s, p, thisAssignments2) {
1388
1432
  let m;
1389
- for (let ref2 = gatherRecursiveAll(
1433
+ for (let ref4 = gatherRecursiveAll(
1390
1434
  s,
1391
1435
  (n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding" || opts?.assignPins && (m = n.type, m === "PinPattern" || m === "PinProperty")
1392
- ), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
1393
- let n = ref2[i3];
1436
+ ), i5 = 0, len4 = ref4.length; i5 < len4; i5++) {
1437
+ let n = ref4[i5];
1394
1438
  if (n.type === "AtBinding") {
1395
1439
  let { ref } = n, { id } = ref;
1396
1440
  thisAssignments2.push([`this.${id} = `, ref]);
1397
1441
  continue;
1398
1442
  }
1399
- if (opts?.assignPins && (n.type === "PinProperty" && (n.children = n.children.flatMap(($2) => $2 === n.name ? [n.name, ": ", n.value] : $2), updateParentPointers(n), n = n.value), n.type === "PinPattern")) {
1443
+ if (opts?.assignPins && (n.type === "PinProperty" && (n.children = n.children.flatMap(($4) => $4 === n.name ? [n.name, ": ", n.value] : $4), updateParentPointers(n), n = n.value), n.type === "PinPattern")) {
1400
1444
  n.ref = makeRef(
1401
1445
  n.expression.type === "Identifier" ? n.expression.name : "pin"
1402
1446
  ), n.children = [n.ref], updateParentPointers(n), thisAssignments2.push({
@@ -1410,8 +1454,8 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1410
1454
  continue;
1411
1455
  }
1412
1456
  if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
1413
- for (let ref3 = n.names, i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
1414
- let id = ref3[i4];
1457
+ for (let ref5 = n.names, i6 = 0, len5 = ref5.length; i6 < len5; i6++) {
1458
+ let id = ref5[i6];
1415
1459
  thisAssignments2.push({
1416
1460
  type: "AssignmentExpression",
1417
1461
  children: [`this.${id} = `, id],
@@ -1427,7 +1471,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1427
1471
  return insertRestSplices(statements, splices, thisAssignments), [splices, thisAssignments];
1428
1472
  }
1429
1473
  function arrayElementHasTrailingComma(elementNode) {
1430
- let ref4, lastChild = (ref4 = elementNode.children)[ref4.length - 1];
1474
+ let ref6, lastChild = (ref6 = elementNode.children)[ref6.length - 1];
1431
1475
  return lastChild && lastChild[lastChild.length - 1]?.token === ",";
1432
1476
  }
1433
1477
  function gatherBindingPatternTypeSuffix(pattern) {
@@ -1437,14 +1481,14 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1437
1481
  switch (pattern.type) {
1438
1482
  case "ArrayBindingPattern": {
1439
1483
  {
1440
- let results = [];
1441
- for (let ref5 = pattern.elements, i5 = 0, len4 = ref5.length; i5 < len4; i5++) {
1442
- let elem = ref5[i5], { typeSuffix } = elem;
1484
+ let results1 = [];
1485
+ for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
1486
+ let elem = ref7[i7], { typeSuffix } = elem;
1443
1487
  typeSuffix ??= elem.binding?.typeSuffix, typeSuffix && count++;
1444
1488
  let typeElement = [typeSuffix?.t, elem.delim];
1445
- typeSuffix?.optional && (typeElement[0] = parenthesizeType(typeElement[0]), typeElement.unshift("undefined |")), elem.type === "BindingRestElement" ? (typeElement[0] ??= "unknown[]", typeElement.unshift(elem.dots)) : typeElement[0] ??= "unknown", results.push(typeElement);
1489
+ typeSuffix?.optional && (typeElement[0] = parenthesizeType(typeElement[0]), typeElement.unshift("undefined |")), elem.type === "BindingRestElement" ? (typeElement[0] ??= "unknown[]", typeElement.unshift(elem.dots)) : typeElement[0] ??= "unknown", results1.push(typeElement);
1446
1490
  }
1447
- let types = results;
1491
+ let types = results1;
1448
1492
  if (count) {
1449
1493
  let t = [": [", types, "]"];
1450
1494
  pattern.typeSuffix = {
@@ -1459,9 +1503,9 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1459
1503
  }
1460
1504
  case "ObjectBindingPattern": {
1461
1505
  {
1462
- let restType, results1 = [];
1463
- for (let ref6 = pattern.properties, i6 = 0, len5 = ref6.length; i6 < len5; i6++) {
1464
- let prop = ref6[i6], { typeSuffix } = prop;
1506
+ let restType, results2 = [];
1507
+ for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
1508
+ let prop = ref8[i8], { typeSuffix } = prop;
1465
1509
  switch (typeSuffix ??= prop.value?.typeSuffix, typeSuffix && count++, typeSuffix ??= {
1466
1510
  type: "TypeSuffix",
1467
1511
  ts: !0,
@@ -1469,12 +1513,12 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1469
1513
  }, prop.type) {
1470
1514
  case "BindingProperty": {
1471
1515
  let ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1472
- results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1516
+ results2.push([...ws, prop.name, typeSuffix, prop.delim]);
1473
1517
  break;
1474
1518
  }
1475
1519
  case "AtBindingProperty": {
1476
1520
  let ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1477
- results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1521
+ results2.push([...ws, prop.ref.id.replace(/^#/, ""), typeSuffix, prop.delim]);
1478
1522
  break;
1479
1523
  }
1480
1524
  case "BindingRestProperty": {
@@ -1483,7 +1527,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
1483
1527
  }
1484
1528
  }
1485
1529
  }
1486
- let types = results1;
1530
+ let types = results2;
1487
1531
  if (count) {
1488
1532
  let t = ["{", types, "}"];
1489
1533
  restType != null && t.push(" & ", parenthesizeType(trimFirstSpace(restType))), pattern.typeSuffix = {
@@ -2828,7 +2872,8 @@ ${js}`
2828
2872
  if (parameters.names = before.flatMap(($7) => $7.names), parameters.parameters.splice(0, 1 / 0), tt && parameters.parameters.push(tt), parameters.parameters.push(...before), rest) {
2829
2873
  let restIdentifier = rest.binding.ref || rest.binding;
2830
2874
  if (parameters.names.push(...rest.names || []), rest.children.pop(), after.length) {
2831
- (rest.binding.type === "ArrayBindingPattern" || rest.binding.type === "ObjectBindingPattern") && parameters.parameters.push({
2875
+ let m4;
2876
+ m4 = rest.binding.type, (m4 === "ArrayBindingPattern" || m4 === "ObjectBindingPattern" || m4 === "NamedBindingPattern") && parameters.parameters.push({
2832
2877
  type: "Error",
2833
2878
  message: "Non-end rest parameter cannot be binding pattern"
2834
2879
  }), after = trimFirstSpace(after);
@@ -2924,14 +2969,14 @@ ${js}`
2924
2969
  let [splices, thisAssignments] = gatherBindingCode(parameters, {
2925
2970
  injectParamProps: isConstructor,
2926
2971
  assignPins: !0
2927
- });
2928
- if (isConstructor) {
2972
+ }), subbindings = gatherSubbindings(parameters.parameters);
2973
+ if (simplifyBindingProperties(parameters.parameters), simplifyBindingProperties(subbindings), isConstructor) {
2929
2974
  let { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
2930
2975
  if (ancestor != null) {
2931
2976
  let fields = new Set(gatherRecursiveWithinFunction(ancestor, ($11) => $11.type === "FieldDefinition").map(($12) => $12.id).filter((a3) => typeof a3 == "object" && a3 != null && "type" in a3 && a3.type === "Identifier").map(($13) => $13.name)), classExpressions = ancestor.body.expressions, index2 = findChildIndex(classExpressions, f);
2932
2977
  assert.notEqual(index2, -1, "Could not find constructor in class");
2933
- let m4;
2934
- for (; m4 = classExpressions[index2 - 1]?.[1], typeof m4 == "object" && m4 != null && "type" in m4 && m4.type === "MethodDefinition" && "name" in m4 && m4.name === "constructor"; )
2978
+ let m5;
2979
+ for (; m5 = classExpressions[index2 - 1]?.[1], typeof m5 == "object" && m5 != null && "type" in m5 && m5.type === "MethodDefinition" && "name" in m5 && m5.name === "constructor"; )
2935
2980
  index2--;
2936
2981
  let fStatement = classExpressions[index2];
2937
2982
  for (let ref18 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
@@ -2957,6 +3002,13 @@ ${js}`
2957
3002
  type: "SemicolonDelimiter",
2958
3003
  children: [";"]
2959
3004
  }, prefix = [];
3005
+ subbindings.length && prefix.push(makeNode({
3006
+ type: "Declaration",
3007
+ children: ["const ", subbindings.slice(1)],
3008
+ names: subbindings.flatMap(($16) => $16.names ?? []),
3009
+ bindings: [],
3010
+ decl: "const"
3011
+ }));
2960
3012
  for (let ref20 = splices, i11 = 0, len10 = ref20.length; i11 < len10; i11++) {
2961
3013
  let binding = ref20[i11];
2962
3014
  assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding"), prefix.push(makeNode({
@@ -2996,7 +3048,7 @@ ${js}`
2996
3048
  if (f.async != null)
2997
3049
  f.async.push("async "), signature.modifier.async = !0;
2998
3050
  else
2999
- for (let ref21 = gatherRecursiveWithinFunction(block, ($16) => $16.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
3051
+ for (let ref21 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
3000
3052
  let a = ref21[i12], i = findChildIndex(a.parent, a);
3001
3053
  a.parent.children.splice(i + 1, 0, {
3002
3054
  type: "Error",
@@ -3007,8 +3059,8 @@ ${js}`
3007
3059
  if (f.generator != null)
3008
3060
  f.generator.push("*"), signature.modifier.generator = !0;
3009
3061
  else
3010
- for (let ref22 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
3011
- let y = ref22[i13], i = y.children.findIndex(($18) => $18.type === "Yield");
3062
+ for (let ref22 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
3063
+ let y = ref22[i13], i = y.children.findIndex(($19) => $19.type === "Yield");
3012
3064
  y.children.splice(i + 1, 0, {
3013
3065
  type: "Error",
3014
3066
  message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
@@ -3017,7 +3069,7 @@ ${js}`
3017
3069
  signature.modifier.async && !signature.modifier.generator && signature.returnType && !isPromiseType(signature.returnType.t) && replaceNode(signature.returnType.t, wrapTypeInPromise(signature.returnType.t));
3018
3070
  }
3019
3071
  function processFunctions(statements, config2) {
3020
- for (let ref23 = gatherRecursiveAll(statements, ($19) => $19.type === "FunctionExpression" || $19.type === "ArrowFunction" || $19.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
3072
+ for (let ref23 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
3021
3073
  let f = ref23[i14];
3022
3074
  (f.type === "FunctionExpression" || f.type === "MethodDefinition") && implicitFunctionBlock(f), processSignature(f), processParams(f), processReturn(f, config2.implicitReturns);
3023
3075
  }
@@ -3064,7 +3116,7 @@ ${js}`
3064
3116
  done || (generator || (statements[statements.length - 1][1] = wrapWithReturn(statements[statements.length - 1][1])), children.splice(i, 1, wrapIIFE(statements, async, generator)), updateParentPointers(exp));
3065
3117
  }
3066
3118
  function processIterationExpressions(statements) {
3067
- for (let ref25 = gatherRecursiveAll(statements, ($20) => $20.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
3119
+ for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
3068
3120
  let s = ref25[i15];
3069
3121
  expressionizeIteration(s);
3070
3122
  }
@@ -3102,12 +3154,12 @@ ${js}`
3102
3154
  let newParameterList = results1, newParameters = {
3103
3155
  ...parameters,
3104
3156
  parameters: newParameterList,
3105
- children: parameters.children.map(($21) => $21 === parameterList ? newParameterList : $21)
3157
+ children: parameters.children.map(($22) => $22 === parameterList ? newParameterList : $22)
3106
3158
  };
3107
3159
  expression = {
3108
3160
  ...expression,
3109
3161
  parameters: newParameters,
3110
- children: expression.children.map(($22) => $22 === parameters ? newParameters : $22)
3162
+ children: expression.children.map(($23) => $23 === parameters ? newParameters : $23)
3111
3163
  };
3112
3164
  }
3113
3165
  return {
@@ -3125,7 +3177,7 @@ ${js}`
3125
3177
  }
3126
3178
  function makeAmpersandFunction(rhs) {
3127
3179
  let { ref, typeSuffix, body } = rhs;
3128
- ref == null && (ref = makeRef("$"), inplacePrepend(ref, body)), startsWithPredicate(body, ($23) => $23.type === "ObjectExpression") && (body = makeLeftHandSideExpression(body));
3180
+ ref == null && (ref = makeRef("$"), inplacePrepend(ref, body)), startsWithPredicate(body, ($24) => $24.type === "ObjectExpression") && (body = makeLeftHandSideExpression(body));
3129
3181
  let parameterList = [
3130
3182
  typeSuffix ? [ref, typeSuffix] : ref
3131
3183
  ], parameters = makeNode({
@@ -3642,14 +3694,12 @@ ${js}`
3642
3694
  break;
3643
3695
  }
3644
3696
  case "ConditionFragment": {
3645
- let { children } = pattern;
3646
- if (children.length) {
3647
- let [first, ...rest] = children, [ws, ...op] = first;
3648
- ws = [" "].concat(ws), first = [ws, ...op], children = [first, ...rest];
3697
+ let { rhs } = pattern;
3698
+ if (rhs.length) {
3699
+ let [first, ...rest] = rhs, [ws, ...op] = first;
3700
+ ws = [" "].concat(ws), first = [ws, ...op], rhs = [first, ...rest];
3649
3701
  }
3650
- conditions.push(
3651
- processBinaryOpExpression([ref, children])
3652
- );
3702
+ conditions.push(processBinaryOpExpression([ref, rhs]));
3653
3703
  break;
3654
3704
  }
3655
3705
  case "RegularExpressionLiteral": {
@@ -3667,6 +3717,10 @@ ${js}`
3667
3717
  ]);
3668
3718
  break;
3669
3719
  }
3720
+ case "NamedBindingPattern": {
3721
+ getPatternConditions(pattern.pattern, ref, conditions);
3722
+ break;
3723
+ }
3670
3724
  case "Literal": {
3671
3725
  conditions.push([
3672
3726
  ref,
@@ -3693,37 +3747,38 @@ ${js}`
3693
3747
  case "Literal":
3694
3748
  case "RegularExpressionLiteral":
3695
3749
  case "PinPattern":
3696
- case "ConditionFragment":
3697
3750
  return;
3751
+ case "ConditionFragment": {
3752
+ if (!pattern.binding)
3753
+ return;
3754
+ break;
3755
+ }
3698
3756
  }
3699
- let [splices, thisAssignments] = gatherBindingCode(pattern), patternBindings2 = nonMatcherBindings(pattern), results = [];
3700
- for (let ref2 = gatherRecursiveAll(patternBindings2, ($7) => $7.subbinding != null), i5 = 0, len4 = ref2.length; i5 < len4; i5++) {
3701
- let p = ref2[i5];
3702
- results.push(prepend(", ", p.subbinding));
3703
- }
3704
- let subbindings = results;
3705
- splices = splices.map((s) => [", ", nonMatcherBindings(s)]), thisAssignments = thisAssignments.map(($8) => ["", $8, ";"]);
3706
- let duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices]);
3707
- return [
3708
- ["", {
3757
+ let [splices, thisAssignments] = gatherBindingCode(pattern), patternBindings2 = nonMatcherBindings(pattern), subbindings = gatherSubbindings(patternBindings2);
3758
+ simplifyBindingProperties(patternBindings2), simplifyBindingProperties(subbindings), splices = splices.flatMap((s) => [", ", nonMatcherBindings(s)]), thisAssignments = thisAssignments.map(($7) => ["", $7, ";"]);
3759
+ let duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices, subbindings]), blockPrefix = [];
3760
+ if (ref || subbindings.length || splices.length) {
3761
+ let children = [decl];
3762
+ ref && children.push(patternBindings2, typeSuffix, " = ", ref), children.push(...subbindings), children.push(...splices), ref || children.splice(1, 1), blockPrefix.push(["", {
3709
3763
  type: "Declaration",
3710
- children: [decl, patternBindings2, typeSuffix, " = ", ref, ...subbindings, ...splices],
3764
+ children,
3765
+ decl,
3711
3766
  names: [],
3712
3767
  bindings: []
3713
3768
  // avoid implicit return of any bindings
3714
- }, ";"],
3715
- ...thisAssignments,
3716
- ...duplicateDeclarations.map(($9) => ["", $9, ";"])
3717
- ];
3769
+ }, ";"]);
3770
+ }
3771
+ if (blockPrefix.push(...thisAssignments), blockPrefix.push(...duplicateDeclarations.map(($8) => ["", $8, ";"])), !!blockPrefix.length)
3772
+ return blockPrefix;
3718
3773
  }
3719
3774
  function elideMatchersFromArrayBindings(elements) {
3720
- let results1 = [];
3721
- for (let i6 = 0, len5 = elements.length; i6 < len5; i6++) {
3722
- let element = elements[i6];
3775
+ let results = [];
3776
+ for (let i5 = 0, len4 = elements.length; i5 < len4; i5++) {
3777
+ let element = elements[i5];
3723
3778
  switch (element.type) {
3724
3779
  case "BindingRestElement":
3725
3780
  case "ElisionElement": {
3726
- results1.push(element);
3781
+ results.push(element);
3727
3782
  break;
3728
3783
  }
3729
3784
  case "BindingElement": {
@@ -3732,12 +3787,12 @@ ${js}`
3732
3787
  case "RegularExpressionLiteral":
3733
3788
  case "StringLiteral":
3734
3789
  case "PinPattern": {
3735
- results1.push(element.delim);
3790
+ results.push(element.delim);
3736
3791
  break;
3737
3792
  }
3738
3793
  default: {
3739
3794
  let binding = nonMatcherBindings(element.binding);
3740
- results1.push(makeNode({
3795
+ results.push(makeNode({
3741
3796
  ...element,
3742
3797
  binding,
3743
3798
  children: element.children.map((c) => c === element.binding ? binding : c)
@@ -3748,26 +3803,20 @@ ${js}`
3748
3803
  }
3749
3804
  }
3750
3805
  }
3751
- return results1;
3806
+ return results;
3752
3807
  }
3753
3808
  function elideMatchersFromPropertyBindings(properties) {
3754
- let results2 = [];
3755
- for (let i7 = 0, len6 = properties.length; i7 < len6; i7++) {
3756
- let p = properties[i7];
3809
+ let results1 = [];
3810
+ for (let i6 = 0, len5 = properties.length; i6 < len5; i6++) {
3811
+ let p = properties[i6];
3757
3812
  switch (p.type) {
3758
3813
  case "BindingProperty":
3759
3814
  case "PinProperty": {
3760
- let { children, name, value, bind } = p, [ws] = children;
3815
+ let { children, name, value } = p, [ws] = children;
3761
3816
  if (name.type === "NumericLiteral" && !value?.name || name.type === "ComputedPropertyName" && value?.subtype === "NumericLiteral")
3762
- if (bind)
3763
- results2.push({
3764
- type: "Error",
3765
- message: `Cannot bind ${name.type}`
3766
- });
3767
- else
3768
- continue;
3769
- else {
3770
- let contents;
3817
+ continue;
3818
+ {
3819
+ let contents, m1;
3771
3820
  switch (value?.type) {
3772
3821
  case "ArrayBindingPattern":
3773
3822
  case "ObjectBindingPattern": {
@@ -3784,33 +3833,36 @@ ${js}`
3784
3833
  contents = p;
3785
3834
  break;
3786
3835
  }
3836
+ case "NamedBindingPattern": {
3837
+ let bindings = nonMatcherBindings(value.pattern);
3838
+ contents = {
3839
+ ...p,
3840
+ subbinding: (m1 = bindings?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern" || m1 === "Identifier" ? [
3841
+ bindings,
3842
+ " = ",
3843
+ name
3844
+ ] : void 0)
3845
+ }, p.name === value.binding && (contents.children = [ws, name, p.delim]);
3846
+ break;
3847
+ }
3787
3848
  default:
3788
3849
  contents = void 0;
3789
3850
  }
3790
- if (bind)
3791
- results2.push({
3792
- ...p,
3793
- children: [ws, name, p.delim],
3794
- subbinding: contents?.value ? [
3795
- contents.value,
3796
- " = ",
3797
- name
3798
- ] : void 0
3799
- });
3800
- else if (contents)
3801
- results2.push(contents);
3851
+ if (contents)
3852
+ results1.push(contents);
3802
3853
  else
3803
3854
  continue;
3804
3855
  }
3805
3856
  break;
3806
3857
  }
3807
3858
  default:
3808
- results2.push(p);
3859
+ results1.push(p);
3809
3860
  }
3810
3861
  }
3811
- return results2;
3862
+ return results1;
3812
3863
  }
3813
3864
  function nonMatcherBindings(pattern) {
3865
+ let m2;
3814
3866
  switch (pattern.type) {
3815
3867
  case "ArrayBindingPattern":
3816
3868
  case "PostRestBindingElements": {
@@ -3818,7 +3870,7 @@ ${js}`
3818
3870
  return makeNode({
3819
3871
  ...pattern,
3820
3872
  elements,
3821
- children: pattern.children.map(($10) => $10 === pattern.elements ? elements : $10)
3873
+ children: pattern.children.map(($9) => $9 === pattern.elements ? elements : $9)
3822
3874
  });
3823
3875
  }
3824
3876
  case "ObjectBindingPattern": {
@@ -3826,9 +3878,18 @@ ${js}`
3826
3878
  return makeNode({
3827
3879
  ...pattern,
3828
3880
  properties,
3829
- children: pattern.children.map(($11) => $11 === pattern.properties ? properties : $11)
3881
+ children: pattern.children.map(($10) => $10 === pattern.properties ? properties : $10)
3882
+ });
3883
+ }
3884
+ case "NamedBindingPattern": {
3885
+ let bindings = nonMatcherBindings(pattern.pattern);
3886
+ return makeNode({
3887
+ ...pattern,
3888
+ subbinding: (m2 = bindings?.type, m2 === "ArrayBindingPattern" || m2 === "ObjectBindingPattern" || m2 === "Identifier" ? [bindings, " = ", pattern.binding] : void 0)
3830
3889
  });
3831
3890
  }
3891
+ case "ConditionFragment":
3892
+ return pattern.binding;
3832
3893
  default:
3833
3894
  return pattern;
3834
3895
  }
@@ -3841,9 +3902,9 @@ ${js}`
3841
3902
  //$.type is "BindingRestProperty"
3842
3903
  $.type === "Identifier" && $.parent?.type === "BindingElement" || $.type === "BindingRestElement"
3843
3904
  ), declarations = [], propsGroupedByName = /* @__PURE__ */ new Map();
3844
- for (let i8 = 0, len7 = props.length; i8 < len7; i8++) {
3845
- let p = props[i8], { name, value } = p, m1;
3846
- if (m1 = value?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern")
3905
+ for (let i7 = 0, len6 = props.length; i7 < len6; i7++) {
3906
+ let p = props[i7], { name, value } = p, m3;
3907
+ if (m3 = value?.type, m3 === "ArrayBindingPattern" || m3 === "ObjectBindingPattern")
3847
3908
  continue;
3848
3909
  let key = value?.name || name?.name || name;
3849
3910
  key?.type === "NumericLiteral" || key?.type === "ComputedPropertyName" || (propsGroupedByName.has(key) ? propsGroupedByName.get(key).push(p) : propsGroupedByName.set(key, [p]));
@@ -3856,8 +3917,8 @@ ${js}`
3856
3917
  pos: 0,
3857
3918
  input: key
3858
3919
  })) {
3859
- for (let i9 = 0, len8 = shared.length; i9 < len8; i9++) {
3860
- let p = shared[i9];
3920
+ for (let i8 = 0, len7 = shared.length; i8 < len7; i8++) {
3921
+ let p = shared[i8];
3861
3922
  aliasBinding(p, makeRef(`_${key}`, key));
3862
3923
  }
3863
3924
  return;
@@ -3938,9 +3999,13 @@ ${js}`
3938
3999
  function processDeclarations(statements) {
3939
4000
  for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "Declaration"), i1 = 0, len1 = ref1.length; i1 < len1; i1++) {
3940
4001
  let declaration = ref1[i1], { bindings } = declaration;
3941
- if (bindings != null)
3942
- for (let i2 = 0, len22 = bindings.length; i2 < len22; i2++) {
3943
- let binding = bindings[i2], { typeSuffix, initializer } = binding;
4002
+ if (bindings != null) {
4003
+ for (let i2 = bindings.length + -1; i2 >= 0; --i2) {
4004
+ let binding = bindings[i2], subbindings = gatherSubbindings(binding);
4005
+ subbindings.length && (simplifyBindingProperties(binding), simplifyBindingProperties(subbindings), spliceChild(declaration, binding, 1, binding, subbindings));
4006
+ }
4007
+ for (let i3 = 0, len22 = bindings.length; i3 < len22; i3++) {
4008
+ let binding = bindings[i3], { typeSuffix, initializer } = binding;
3944
4009
  if (typeSuffix && typeSuffix.optional) {
3945
4010
  if (initializer && !typeSuffix.t) {
3946
4011
  let expression = trimFirstSpace(initializer.expression), m;
@@ -3968,6 +4033,19 @@ ${js}`
3968
4033
  }
3969
4034
  initializer && prependStatementExpressionBlock(initializer, declaration);
3970
4035
  }
4036
+ }
4037
+ }
4038
+ for (let ref2 = gatherRecursiveAll(statements, ($1) => $1.type === "ForStatement"), i4 = 0, len3 = ref2.length; i4 < len3; i4++) {
4039
+ let statement = ref2[i4], { declaration } = statement;
4040
+ if (declaration?.type !== "ForDeclaration")
4041
+ continue;
4042
+ let { binding } = declaration, blockPrefix = getPatternBlockPrefix(
4043
+ binding.pattern,
4044
+ void 0,
4045
+ append(declaration.decl, " "),
4046
+ binding.typeSuffix
4047
+ );
4048
+ simplifyBindingProperties(binding), blockPrefix != null && (statement.block.expressions.unshift(...blockPrefix), braceBlock(statement.block));
3971
4049
  }
3972
4050
  }
3973
4051
  function prependStatementExpressionBlock(initializer, statement) {
@@ -4068,7 +4146,7 @@ ${js}`
4068
4146
  return;
4069
4147
  let { expression } = condition;
4070
4148
  if (expression && typeof expression == "object" && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && Array.isArray(expression.children[0]) && len2(expression.children[0], 1) && expression.children[0][0] === "!" && typeof expression.children[1] == "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
4071
- let { type: type1, children: [[], { type: type2, expression: expression2 }] } = expression, type = [type1, type2];
4149
+ let { children: [[], { expression: expression2 }] } = expression;
4072
4150
  expression = expression2;
4073
4151
  }
4074
4152
  processDeclarationCondition(expression, condition.expression, s);
@@ -4090,8 +4168,8 @@ ${js}`
4090
4168
  ({ children } = condition.expression.children[1]);
4091
4169
  }
4092
4170
  children.unshift("(");
4093
- for (let i3 = 0, len3 = conditions.length; i3 < len3; i3++) {
4094
- let c = conditions[i3];
4171
+ for (let i5 = 0, len4 = conditions.length; i5 < len4; i5++) {
4172
+ let c = conditions[i5];
4095
4173
  children.push(" && ", c);
4096
4174
  }
4097
4175
  children.push(")");
@@ -4109,11 +4187,11 @@ ${js}`
4109
4187
  if (index < 0)
4110
4188
  throw new Error("Couldn't find where in block to put postfix declaration");
4111
4189
  ancestor.expressions.splice(index + 1, 0, ...blockPrefix), updateParentPointers(ancestor), braceBlock(ancestor);
4112
- let ref2;
4190
+ let ref3;
4113
4191
  switch (s.type) {
4114
4192
  case "IfStatement": {
4115
- if (ref2 = s.else?.block) {
4116
- let elseBlock = ref2;
4193
+ if (ref3 = s.else?.block) {
4194
+ let elseBlock = ref3;
4117
4195
  elseBlock.bare && !elseBlock.semicolon && elseBlock.children.push(elseBlock.semicolon = ";"), ancestor.expressions.splice(index + 1 + blockPrefix.length, 0, ["", elseBlock]), s.children = s.children.filter((a1) => a1 !== s.else), s.else = void 0;
4118
4196
  }
4119
4197
  let block = s.then;
@@ -4129,11 +4207,11 @@ ${js}`
4129
4207
  if (s.negated) {
4130
4208
  if (e != null) {
4131
4209
  let block = blockWithPrefix(blockPrefix, e.block);
4132
- e.children = e.children.map(($1) => $1 === e.block ? block : $1), e.block = block, updateParentPointers(e);
4210
+ e.children = e.children.map(($2) => $2 === e.block ? block : $2), e.block = block, updateParentPointers(e);
4133
4211
  }
4134
4212
  } else {
4135
4213
  let block = blockWithPrefix(blockPrefix, s.then);
4136
- s.children = s.children.map(($2) => $2 === s.then ? block : $2), s.then = block, updateParentPointers(s);
4214
+ s.children = s.children.map(($3) => $3 === s.then ? block : $3), s.then = block, updateParentPointers(s);
4137
4215
  }
4138
4216
  break;
4139
4217
  }
@@ -4141,7 +4219,7 @@ ${js}`
4141
4219
  if (!blockPrefix)
4142
4220
  return;
4143
4221
  let { children, block } = s, newBlock = blockWithPrefix(blockPrefix, block);
4144
- s.children = children.map(($3) => $3 === block ? newBlock : $3), updateParentPointers(s);
4222
+ s.children = children.map(($4) => $4 === block ? newBlock : $4), updateParentPointers(s);
4145
4223
  break;
4146
4224
  }
4147
4225
  case "SwitchStatement": {
@@ -4158,7 +4236,7 @@ ${js}`
4158
4236
  return c === s.condition ? newCondition : c;
4159
4237
  }), s.condition = newCondition, updateParentPointers(s), statementDeclaration) {
4160
4238
  let block = makeEmptyBlock();
4161
- replaceBlockExpression(s.parent, s, block), block.expressions.push(["", s]), s.children.splice(s.children.findIndex(($4) => $4.token === "switch"), 0, blockPrefix), s.parent = block;
4239
+ replaceBlockExpression(s.parent, s, block), block.expressions.push(["", s]), s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix), s.parent = block;
4162
4240
  } else {
4163
4241
  let block = blockWithPrefix([["", [{
4164
4242
  type: "Declaration",
@@ -4172,17 +4250,17 @@ ${js}`
4172
4250
  }
4173
4251
  function dynamizeFromClause(from) {
4174
4252
  from = from.slice(1), from = trimFirstSpace(from);
4175
- let ref3;
4176
- if (ref3 = from[from.length - 1]?.assertion) {
4177
- let assert4 = ref3, ref4;
4178
- ref4 = from[from.length - 1], ref4.children = ref4.children.filter((a2) => a2 !== assert4), from.push(", {", assert4.keyword, ":", assert4.object, "}");
4253
+ let ref4;
4254
+ if (ref4 = from[from.length - 1]?.assertion) {
4255
+ let assert2 = ref4, ref5;
4256
+ ref5 = from[from.length - 1], ref5.children = ref5.children.filter((a2) => a2 !== assert2), from.push(", {", assert2.keyword, ":", assert2.object, "}");
4179
4257
  }
4180
4258
  return ["(", ...from, ")"];
4181
4259
  }
4182
4260
  function dynamizeImportDeclaration(decl) {
4183
- let { imports } = decl, { star, binding, specifiers } = imports, justDefault = binding && !specifiers && !star, ref5;
4184
- binding ? specifiers ? ref5 = makeRef() : ref5 = binding : ref5 = convertNamedImportsToObject(imports, !0);
4185
- let pattern = ref5, c = "const", expression = [
4261
+ let { imports } = decl, { star, binding, specifiers } = imports, justDefault = binding && !specifiers && !star, ref6;
4262
+ binding ? specifiers ? ref6 = makeRef() : ref6 = binding : ref6 = convertNamedImportsToObject(imports, !0);
4263
+ let pattern = ref6, c = "const", expression = [
4186
4264
  justDefault ? "(" : void 0,
4187
4265
  { type: "Await", children: ["await"] },
4188
4266
  " ",
@@ -4362,7 +4440,7 @@ ${js}`
4362
4440
  children: args.children.map(
4363
4441
  (arg) => {
4364
4442
  if (typeof arg == "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
4365
- let { type, expression: exp, children } = arg, expression = processUnaryExpression([last], trimFirstSpace(exp));
4443
+ let { expression: exp, children } = arg, expression = processUnaryExpression([last], trimFirstSpace(exp));
4366
4444
  return expression = prepend(getTrimmingSpace(exp), expression), {
4367
4445
  ...arg,
4368
4446
  expression,
@@ -4562,10 +4640,10 @@ ${js}`
4562
4640
  }
4563
4641
 
4564
4642
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
4565
- function processRangeExpression(start, ws1, range, end) {
4566
- ws1 = [ws1, range.children[0]];
4567
- let ws2 = range.children[1], comma = { $loc: range.$loc, token: "," }, ref;
4568
- switch (range.increasing) {
4643
+ function processRangeExpression(start, ws1, range2, end) {
4644
+ ws1 = [ws1, range2.children[0]];
4645
+ let ws2 = range2.children[1], comma = { $loc: range2.$loc, token: "," }, ref;
4646
+ switch (range2.increasing) {
4569
4647
  case !0: {
4570
4648
  ref = ($) => $;
4571
4649
  break;
@@ -4577,14 +4655,14 @@ ${js}`
4577
4655
  default:
4578
4656
  ref = Math.abs;
4579
4657
  }
4580
- let abs = ref, lengthAdjust = 1 - +!range.left.inclusive - +!range.right.inclusive, children;
4658
+ let abs = ref, lengthAdjust = 1 - +!range2.left.inclusive - +!range2.right.inclusive, children;
4581
4659
  if (typeof start == "object" && start != null && "type" in start && start.type === "Literal" && typeof end == "object" && end != null && "type" in end && end.type === "Literal") {
4582
4660
  let startValue = literalValue(start), endValue = literalValue(end);
4583
4661
  if (typeof startValue == "string" && typeof endValue == "string") {
4584
4662
  if (!(startValue.length === 1 && endValue.length === 1))
4585
4663
  throw new Error("String range start and end must be a single character");
4586
4664
  let startCode = startValue.charCodeAt(0), endCode = endValue.charCodeAt(0), step = startCode <= endCode ? 1 : -1, length = abs(endCode - startCode) + lengthAdjust;
4587
- range.left.inclusive || (startCode += step), length <= 26 ? children = [
4665
+ range2.left.inclusive || (startCode += step), length <= 26 ? children = [
4588
4666
  "[",
4589
4667
  Array.from({ length }, (_2, i) => JSON.stringify(String.fromCharCode(startCode + i * step))).join(", "),
4590
4668
  "]"
@@ -4595,25 +4673,25 @@ ${js}`
4595
4673
  ", ",
4596
4674
  length.toString(),
4597
4675
  ")"
4598
- ], range.error != null && children.unshift(range.error);
4676
+ ], range2.error != null && children.unshift(range2.error);
4599
4677
  } else if (typeof startValue == "number" && typeof endValue == "number") {
4600
4678
  let step = startValue <= endValue ? 1 : -1, length = abs(endValue - startValue) + lengthAdjust;
4601
- range.left.inclusive || (startValue += step), length <= 20 && (children = [
4679
+ range2.left.inclusive || (startValue += step), length <= 20 && (children = [
4602
4680
  "[",
4603
4681
  Array.from({ length }, (_2, i) => startValue + i * step).join(", "),
4604
4682
  "]"
4605
- ], range.error != null && children.unshift(range.error));
4683
+ ], range2.error != null && children.unshift(range2.error));
4606
4684
  }
4607
4685
  }
4608
4686
  if (children == null)
4609
- if (range.increasing != null) {
4610
- let sign = range.increasing ? "+" : "-";
4687
+ if (range2.increasing != null) {
4688
+ let sign = range2.increasing ? "+" : "-";
4611
4689
  end = makeLeftHandSideExpression(end), children = [
4612
- getHelperRef(range.increasing ? "range" : "revRange"),
4690
+ getHelperRef(range2.increasing ? "range" : "revRange"),
4613
4691
  "(",
4614
- range.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
4692
+ range2.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
4615
4693
  ",",
4616
- range.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
4694
+ range2.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
4617
4695
  ...ws1,
4618
4696
  ")"
4619
4697
  ];
@@ -4622,11 +4700,11 @@ ${js}`
4622
4700
  "((s, e) => s > e ? ",
4623
4701
  getHelperRef("revRange"),
4624
4702
  "(s, e",
4625
- range.right.inclusive ? " - 1" : void 0,
4703
+ range2.right.inclusive ? " - 1" : void 0,
4626
4704
  ") : ",
4627
4705
  getHelperRef("range"),
4628
4706
  "(s, e",
4629
- range.right.inclusive ? " + 1" : void 0,
4707
+ range2.right.inclusive ? " + 1" : void 0,
4630
4708
  "))",
4631
4709
  "(",
4632
4710
  start,
@@ -4641,14 +4719,14 @@ ${js}`
4641
4719
  children,
4642
4720
  start,
4643
4721
  end,
4644
- error: range.error,
4645
- left: range.left,
4646
- right: range.right,
4647
- increasing: range.increasing
4722
+ error: range2.error,
4723
+ left: range2.left,
4724
+ right: range2.right,
4725
+ increasing: range2.increasing
4648
4726
  };
4649
4727
  }
4650
- function forRange(open, forDeclaration, range, stepExp, close) {
4651
- let { start, end, left, right, increasing } = range, counterRef = makeRef("i"), infinite = typeof end == "object" && end != null && "type" in end && end.type === "Identifier" && "name" in end && end.name === "Infinity", stepRef, asc;
4728
+ function forRange(open, forDeclaration, range2, stepExp, close) {
4729
+ let { start, end, left, right, increasing } = range2, counterRef = makeRef("i"), infinite = typeof end == "object" && end != null && "type" in end && end.type === "Identifier" && "name" in end && end.name === "Infinity", stepRef, asc;
4652
4730
  stepExp ? (stepExp = trimFirstSpace(stepExp), stepRef = maybeRef(stepExp, "step")) : infinite ? stepExp = stepRef = makeNumericLiteral(1) : increasing != null && (increasing ? (stepExp = stepRef = makeNumericLiteral(1), asc = !0) : (stepExp = stepRef = makeNumericLiteral(-1), asc = !1));
4653
4731
  let ref1;
4654
4732
  if (stepExp?.type === "Literal")
@@ -4704,7 +4782,7 @@ ${js}`
4704
4782
  // This declaration doesn't always appear in the output,
4705
4783
  // but it's still helpful for determining the primary loop variable
4706
4784
  declaration: forDeclaration,
4707
- children: [range.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
4785
+ children: [range2.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
4708
4786
  blockPrefix
4709
4787
  };
4710
4788
  }
@@ -4749,6 +4827,7 @@ ${js}`
4749
4827
  return declaration = {
4750
4828
  type: "Declaration",
4751
4829
  children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", trimFirstSpace(expRef2), ".length"],
4830
+ decl: "let",
4752
4831
  names: []
4753
4832
  }, { declaration, eachDeclaration, children: [open, declaration, "; ", [counterRef, " < ", lenRef, "; "], counterRef, increment, close], blockPrefix };
4754
4833
  } else
@@ -4762,7 +4841,7 @@ ${js}`
4762
4841
  message: "'own' is only meaningful in for..in loops"
4763
4842
  });
4764
4843
  let { binding } = declaration, pattern = binding?.pattern;
4765
- if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
4844
+ if (pattern?.type === "NamedBindingPattern" && (pattern = pattern.binding), binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
4766
4845
  let itemRef = makeRef(inOf.token === "in" ? "key" : "item");
4767
4846
  blockPrefix.push(["", {
4768
4847
  type: "Declaration",
@@ -4794,11 +4873,13 @@ ${js}`
4794
4873
  hoistDec = {
4795
4874
  type: "Declaration",
4796
4875
  children: ["let ", counterRef, " = 0"],
4876
+ decl: "let",
4797
4877
  names: []
4798
4878
  }, blockPrefix.push(["", {
4799
4879
  type: "Declaration",
4800
4880
  children: [trimFirstSpace(ws2), decl2, " = ", counterRef, "++"],
4801
- names: decl2.names
4881
+ names: decl2.names,
4882
+ decl: decl2.decl
4802
4883
  }, ";"]);
4803
4884
  break;
4804
4885
  }
@@ -4807,7 +4888,8 @@ ${js}`
4807
4888
  if (expRef2 !== exp && (hoistDec = {
4808
4889
  type: "Declaration",
4809
4890
  children: ["let ", expRef2],
4810
- names: []
4891
+ names: [],
4892
+ decl: "let"
4811
4893
  }, exp = {
4812
4894
  type: "AssignmentExpression",
4813
4895
  children: [" ", expRef2, " =", exp]
@@ -4815,20 +4897,57 @@ ${js}`
4815
4897
  let hasPropRef = getHelperRef("hasProp");
4816
4898
  blockPrefix.push(["", ["if (!", hasPropRef, "(", trimFirstSpace(expRef2), ", ", trimFirstSpace(pattern), ")) continue"], ";"]);
4817
4899
  }
4818
- decl2 && blockPrefix.push(["", {
4819
- type: "Declaration",
4820
- children: [
4821
- trimFirstSpace(ws2),
4822
- decl2,
4823
- " = ",
4824
- trimFirstSpace(expRef2),
4825
- "[",
4826
- trimFirstSpace(pattern),
4827
- "]"
4828
- ],
4829
- decl: decl2,
4830
- names: decl2.names
4831
- }, ";"]);
4900
+ if (decl2) {
4901
+ let trimmedPattern = trimFirstSpace(pattern), expression = makeNode({
4902
+ type: "MemberExpression",
4903
+ children: [
4904
+ trimFirstSpace(expRef2),
4905
+ makeNode({
4906
+ type: "Index",
4907
+ expression: trimmedPattern,
4908
+ children: ["[", trimmedPattern, "]"]
4909
+ })
4910
+ ]
4911
+ });
4912
+ blockPrefix.push([
4913
+ "",
4914
+ (() => {
4915
+ if (decl2.type === "ForDeclaration") {
4916
+ let { binding: binding2, children } = decl2;
4917
+ return binding2.children.push(binding2.initializer = makeNode({
4918
+ type: "Initializer",
4919
+ expression,
4920
+ children: [" = ", expression]
4921
+ })), makeNode({
4922
+ type: "Declaration",
4923
+ children: [
4924
+ trimFirstSpace(ws2),
4925
+ ...children
4926
+ ],
4927
+ bindings: [decl2.binding],
4928
+ decl: decl2.decl,
4929
+ names: decl2.names
4930
+ });
4931
+ } else
4932
+ return makeNode({
4933
+ type: "AssignmentExpression",
4934
+ children: [
4935
+ trimFirstSpace(ws2),
4936
+ decl2,
4937
+ " = ",
4938
+ trimFirstSpace(expRef2),
4939
+ "[",
4940
+ trimFirstSpace(pattern),
4941
+ "]"
4942
+ ],
4943
+ names: decl2.names,
4944
+ lhs: decl2,
4945
+ assigned: decl2
4946
+ });
4947
+ })(),
4948
+ ";"
4949
+ ]);
4950
+ }
4832
4951
  break;
4833
4952
  }
4834
4953
  default:
@@ -5168,7 +5287,7 @@ ${js}`
5168
5287
  }, defaultClause = !1, clauses = cs.map((clause) => {
5169
5288
  let ref1;
5170
5289
  if ((ref1 = clause.binding?.parameter) && typeof ref1 == "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
5171
- let { type, patterns } = ref1;
5290
+ let { patterns } = ref1;
5172
5291
  return {
5173
5292
  type: "PatternClause",
5174
5293
  patterns,
@@ -5648,8 +5767,12 @@ ${js}`
5648
5767
  }
5649
5768
  function processBindingPatternLHS(lhs, tail) {
5650
5769
  adjustAtBindings(lhs, !0);
5651
- let [splices, thisAssignments] = gatherBindingCode(lhs);
5652
- tail.push(...splices.map((s) => [", ", s]), ...thisAssignments.map((a) => [", ", a]));
5770
+ let [splices, thisAssignments] = gatherBindingCode(lhs), subbindings = gatherSubbindings(lhs);
5771
+ simplifyBindingProperties(lhs), simplifyBindingProperties(subbindings), tail.push(
5772
+ ...splices.map((s) => [", ", s]),
5773
+ ...thisAssignments.map((a) => [", ", a]),
5774
+ ...subbindings
5775
+ );
5653
5776
  }
5654
5777
  function processAssignments(statements) {
5655
5778
  for (let ref7 = gatherRecursiveAll(statements, ($4) => $4.type === "AssignmentExpression" || $4.type === "UpdateExpression"), i5 = 0, len3 = ref7.length; i5 < len3; i5++) {
@@ -5751,7 +5874,7 @@ ${js}`
5751
5874
  message: "Slice range cannot be decreasing in assignment"
5752
5875
  });
5753
5876
  break;
5754
- } else m3 = lhs.type, (m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") && (processBindingPatternLHS(lhs, tail), gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare)));
5877
+ } else m3 = lhs.type, (m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") && (processBindingPatternLHS(lhs, tail), gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare)));
5755
5878
  }
5756
5879
  i--;
5757
5880
  }
@@ -5847,7 +5970,7 @@ ${js}`
5847
5970
  for (; suffixIndex >= 0; ) {
5848
5971
  let suffix = unary.suffix[suffixIndex];
5849
5972
  if (typeof suffix == "object" && suffix != null && "token" in suffix && suffix.token === "?") {
5850
- let { token } = suffix, count = 0, m4;
5973
+ let {} = suffix, count = 0, m4;
5851
5974
  for (; m4 = unary.suffix[suffixIndex], typeof m4 == "object" && m4 != null && "token" in m4 && m4.token === "?"; )
5852
5975
  unary.suffix.splice(suffixIndex--, 1), count++;
5853
5976
  let m5;
@@ -5894,7 +6017,7 @@ ${js}`
5894
6017
  children: [prefix, replace, outer]
5895
6018
  })), results2.push(replaceNode(unary, replace, parent));
5896
6019
  } else if (typeof suffix == "object" && suffix != null && "type" in suffix && suffix.type === "NonNullAssertion") {
5897
- let { type } = suffix, m6;
6020
+ let {} = suffix, m6;
5898
6021
  for (; m6 = unary.suffix[suffixIndex], typeof m6 == "object" && m6 != null && "type" in m6 && m6.type === "NonNullAssertion"; )
5899
6022
  unary.suffix.splice(suffixIndex--, 1);
5900
6023
  let m7;
@@ -6160,24 +6283,9 @@ ${js}`
6160
6283
  (classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 == "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) && (classExp.children.unshift(classExp.name, "="), root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]));
6161
6284
  }
6162
6285
  }
6163
- function populateRefs(statements) {
6164
- let refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
6165
- if (refNodes.length) {
6166
- let ids = gatherRecursive(statements, (s) => s.type === "Identifier"), names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
6167
- refNodes.forEach((ref) => {
6168
- let { type, base } = ref;
6169
- if (type !== "Ref") return;
6170
- ref.type = "Identifier";
6171
- let n = 0, name = base;
6172
- for (; names.has(name); )
6173
- n++, name = `${base}${n}`;
6174
- return names.add(name), ref.children = ref.names = [name];
6175
- });
6176
- }
6177
- }
6178
6286
  function processPlaceholders(statements) {
6179
6287
  let placeholderMap = /* @__PURE__ */ new Map(), liftedIfs = /* @__PURE__ */ new Set();
6180
- for (let ref25 = gatherRecursiveAll(statements, ($22) => $22.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
6288
+ for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
6181
6289
  let exp = ref25[i17], ancestor;
6182
6290
  if (exp.subtype === ".") {
6183
6291
  ({ ancestor } = findAncestor(
@@ -6525,6 +6633,7 @@ ${js}`
6525
6633
  NWBindingIdentifier,
6526
6634
  AtIdentifierRef,
6527
6635
  PinPattern,
6636
+ NamedBindingPattern,
6528
6637
  BindingPattern,
6529
6638
  ObjectBindingPattern,
6530
6639
  ObjectBindingPatternContent,
@@ -8370,7 +8479,7 @@ ${js}`
8370
8479
  children: $0,
8371
8480
  expression
8372
8481
  };
8373
- }), LeftHandSideExpression$1 = CallExpression, LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
8482
+ }), LeftHandSideExpression$1 = NamedBindingPattern, LeftHandSideExpression$2 = CallExpression, LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
8374
8483
  function LeftHandSideExpression(ctx, state2) {
8375
8484
  return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
8376
8485
  }
@@ -8827,7 +8936,7 @@ ${js}`
8827
8936
  function FunctionRestParameter(ctx, state2) {
8828
8937
  return (0, import_lib2.$EVENT)(ctx, state2, "FunctionRestParameter", FunctionRestParameter$0);
8829
8938
  }
8830
- var ParameterElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)(_), (0, import_lib2.$C)(NWBindingIdentifier, BindingPattern), (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
8939
+ var ParameterElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, NWBindingIdentifier), (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
8831
8940
  var accessModifier = $2, binding = $4, typeSuffix = $5, initializer = $6, delim = $7;
8832
8941
  return typeSuffix ??= binding.typeSuffix, {
8833
8942
  type: "Parameter",
@@ -8920,7 +9029,22 @@ ${js}`
8920
9029
  function PinPattern(ctx, state2) {
8921
9030
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
8922
9031
  }
8923
- var BindingPattern$0 = ObjectBindingPattern, BindingPattern$1 = ArrayBindingPattern, BindingPattern$2 = PinPattern, BindingPattern$3 = Literal, BindingPattern$4 = RegularExpressionLiteral, BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4];
9032
+ var NamedBindingPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, Caret, (0, import_lib2.$E)(_), BindingPattern), function($skip, $loc, $0, $1, $2, $3, $4) {
9033
+ var binding = $1, ws = $3, pattern = $4;
9034
+ return pattern = prepend(ws, pattern), {
9035
+ type: "NamedBindingPattern",
9036
+ // NOTE: children just has binding, not pattern, for easy destructuring
9037
+ children: [binding],
9038
+ binding,
9039
+ pattern,
9040
+ subbinding: [pattern, " = ", binding],
9041
+ typeSuffix: pattern.typeSuffix
9042
+ };
9043
+ });
9044
+ function NamedBindingPattern(ctx, state2) {
9045
+ return (0, import_lib2.$EVENT)(ctx, state2, "NamedBindingPattern", NamedBindingPattern$0);
9046
+ }
9047
+ var BindingPattern$0 = ObjectBindingPattern, BindingPattern$1 = ArrayBindingPattern, BindingPattern$2 = PinPattern, BindingPattern$3 = Literal, BindingPattern$4 = RegularExpressionLiteral, BindingPattern$5 = NamedBindingPattern, BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4, BindingPattern$5];
8924
9048
  function BindingPattern(ctx, state2) {
8925
9049
  return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingPattern", BindingPattern$$);
8926
9050
  }
@@ -9016,8 +9140,21 @@ ${js}`
9016
9140
  function NestedBindingPropertyList(ctx, state2) {
9017
9141
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingPropertyList", NestedBindingPropertyList$0);
9018
9142
  }
9019
- var BindingProperty$0 = BindingRestProperty, BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PropertyName, (0, import_lib2.$E)(Caret), (0, import_lib2.$E)(_), Colon, (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingIdentifier, BindingPattern), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9143
+ var BindingProperty$0 = BindingRestProperty, BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PropertyName, (0, import_lib2.$E)(Caret), (0, import_lib2.$E)(_), Colon, (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9020
9144
  var ws1 = $1, name = $2, bind = $3, ws2 = $4, colon = $5, ws3 = $6, value = $7, typeSuffix = $8, initializer = $9;
9145
+ if (bind) {
9146
+ let binding = name, pattern = value;
9147
+ value = {
9148
+ type: "NamedBindingPattern",
9149
+ // NOTE: children just has binding, not pattern, for easy destructuring
9150
+ children: [binding],
9151
+ binding,
9152
+ pattern,
9153
+ subbinding: [pattern, " = ", binding],
9154
+ typeSuffix: pattern.typeSuffix,
9155
+ names: value.names
9156
+ };
9157
+ }
9021
9158
  return {
9022
9159
  type: "BindingProperty",
9023
9160
  children: [ws1, name, ws2, colon, ws3, value, initializer],
@@ -9026,8 +9163,7 @@ ${js}`
9026
9163
  value,
9027
9164
  typeSuffix,
9028
9165
  initializer,
9029
- names: value.names,
9030
- bind: !!bind
9166
+ names: value.names
9031
9167
  };
9032
9168
  }), BindingProperty$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), Caret, BindingIdentifier, (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
9033
9169
  var ws = $1, pin = $2, binding = $3, typeSuffix = $4, initializer = $5;
@@ -9070,8 +9206,7 @@ ${js}`
9070
9206
  typeSuffix,
9071
9207
  initializer,
9072
9208
  names: binding.names,
9073
- identifier: binding,
9074
- bind: !!bind
9209
+ identifier: binding
9075
9210
  };
9076
9211
  }), BindingProperty$$ = [BindingProperty$0, BindingProperty$1, BindingProperty$2, BindingProperty$3];
9077
9212
  function BindingProperty(ctx, state2) {
@@ -9117,7 +9252,7 @@ ${js}`
9117
9252
  function NestedBindingElements(ctx, state2) {
9118
9253
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingElements", NestedBindingElements$0);
9119
9254
  }
9120
- var BindingElement$0 = BindingRestElement, BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingIdentifier, BindingPattern), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
9255
+ var BindingElement$0 = BindingRestElement, BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
9121
9256
  var ws = $1, binding = $2, typeSuffix = $3, initializer = $4;
9122
9257
  return {
9123
9258
  type: "BindingElement",
@@ -9137,7 +9272,7 @@ ${js}`
9137
9272
  function BindingElement(ctx, state2) {
9138
9273
  return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingElement", BindingElement$$);
9139
9274
  }
9140
- var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(BindingIdentifier, BindingPattern, EmptyBindingPattern), (0, import_lib2.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
9275
+ var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(BindingPattern, BindingIdentifier, EmptyBindingPattern), (0, import_lib2.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
9141
9276
  var ws = $1, dots = $2, binding = $3, typeSuffix = $4;
9142
9277
  return {
9143
9278
  type: "BindingRestElement",
@@ -9149,7 +9284,7 @@ ${js}`
9149
9284
  names: binding.names,
9150
9285
  rest: !0
9151
9286
  };
9152
- }), BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingIdentifier, BindingPattern), DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
9287
+ }), BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
9153
9288
  var ws = $1, binding = $2, dots = $3;
9154
9289
  return {
9155
9290
  type: "BindingRestElement",
@@ -9933,8 +10068,8 @@ ${js}`
9933
10068
  return (0, import_lib2.$EVENT)(ctx, state2, "RangeEnd", RangeEnd$0);
9934
10069
  }
9935
10070
  var RangeExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, RangeDots, Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
9936
- var start = $1, ws = $2, range = $3, end = $4;
9937
- return processRangeExpression(start, ws, range, end);
10071
+ var start = $1, ws = $2, range2 = $3, end = $4;
10072
+ return processRangeExpression(start, ws, range2, end);
9938
10073
  }), RangeExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, DotDot, (0, import_lib2.$Y)((0, import_lib2.$S)(__, CloseBracket))), function($skip, $loc, $0, $1, $2, $3, $4) {
9939
10074
  var s = $1, ws = $2;
9940
10075
  return {
@@ -11547,10 +11682,10 @@ ${js}`
11547
11682
  };
11548
11683
  }), ForDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertConst, (0, import_lib2.$N)(ActualMemberExpression), ForBinding), function($skip, $loc, $0, $1, $2, $3) {
11549
11684
  var c = $1, binding = $3;
11550
- return {
11685
+ return gatherRecursive(binding, ($) => $.type === "PinPattern").length ? $skip : {
11551
11686
  type: "ForDeclaration",
11552
11687
  children: [c, binding],
11553
- decl: c.token,
11688
+ decl: c.token.trimEnd(),
11554
11689
  binding,
11555
11690
  names: binding.names
11556
11691
  };
@@ -11691,12 +11826,16 @@ ${js}`
11691
11826
  function PatternExpressionList(ctx, state2) {
11692
11827
  return (0, import_lib2.$EVENT)(ctx, state2, "PatternExpressionList", PatternExpressionList$0);
11693
11828
  }
11694
- var PatternExpression$0 = BindingPattern, PatternExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidIndentedApplication, (0, import_lib2.$E)((0, import_lib2.$P)(SingleLineBinaryOpRHS)), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
11695
- var pattern = $2;
11696
- return pattern ? {
11829
+ var PatternExpression$0 = BindingPattern, PatternExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidIndentedApplication, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(Caret))), (0, import_lib2.$P)(SingleLineBinaryOpRHS))), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
11830
+ var body = $2;
11831
+ if (!body) return $skip;
11832
+ let [named, rhs] = body, binding;
11833
+ return named && ([binding] = named), {
11697
11834
  type: "ConditionFragment",
11698
- children: pattern
11699
- } : $skip;
11835
+ children: [binding, rhs],
11836
+ binding,
11837
+ rhs
11838
+ };
11700
11839
  }), PatternExpression$$ = [PatternExpression$0, PatternExpression$1];
11701
11840
  function PatternExpression(ctx, state2) {
11702
11841
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PatternExpression", PatternExpression$$);
@@ -11779,15 +11918,7 @@ ${js}`
11779
11918
  function FinallyClause(ctx, state2) {
11780
11919
  return (0, import_lib2.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
11781
11920
  }
11782
- var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
11783
- var binding = $1, typeSuffix = $2;
11784
- return {
11785
- type: "CatchParameter",
11786
- binding,
11787
- typeSuffix,
11788
- children: $0
11789
- };
11790
- }), CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
11921
+ var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
11791
11922
  var binding = $1, typeSuffix = $2;
11792
11923
  return {
11793
11924
  type: "CatchParameter",
@@ -11795,12 +11926,20 @@ ${js}`
11795
11926
  typeSuffix,
11796
11927
  children: [binding, typeSuffix]
11797
11928
  };
11798
- }), CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
11929
+ }), CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
11799
11930
  return {
11800
11931
  type: "CatchPattern",
11801
11932
  children: $0,
11802
11933
  patterns: $1
11803
11934
  };
11935
+ }), CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
11936
+ var binding = $1, typeSuffix = $2;
11937
+ return {
11938
+ type: "CatchParameter",
11939
+ binding,
11940
+ typeSuffix,
11941
+ children: $0
11942
+ };
11804
11943
  }), CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
11805
11944
  function CatchParameter(ctx, state2) {
11806
11945
  return (0, import_lib2.$EVENT_C)(ctx, state2, "CatchParameter", CatchParameter$$);
@@ -13123,7 +13262,7 @@ ${js}`
13123
13262
  function By(ctx, state2) {
13124
13263
  return (0, import_lib2.$EVENT)(ctx, state2, "By", By$0);
13125
13264
  }
13126
- var Caret$0 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'), function($skip, $loc, $0, $1) {
13265
+ var Caret$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'), (0, import_lib2.$N)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'))), function($skip, $loc, $0, $1, $2) {
13127
13266
  return { $loc, token: $1 };
13128
13267
  });
13129
13268
  function Caret(ctx, state2) {