@angular/core 17.1.0-next.4 → 17.1.0-next.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.
Files changed (39) hide show
  1. package/esm2022/src/application/application_ref.mjs +4 -8
  2. package/esm2022/src/application/create_application.mjs +2 -2
  3. package/esm2022/src/change_detection/flags.mjs +16 -0
  4. package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +164 -0
  5. package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +13 -0
  6. package/esm2022/src/core.mjs +2 -2
  7. package/esm2022/src/core_private_export.mjs +4 -2
  8. package/esm2022/src/event_emitter.mjs +1 -2
  9. package/esm2022/src/pending_tasks.mjs +57 -0
  10. package/esm2022/src/platform/platform_ref.mjs +2 -2
  11. package/esm2022/src/render3/after_render_hooks.mjs +2 -2
  12. package/esm2022/src/render3/component_ref.mjs +13 -9
  13. package/esm2022/src/render3/instructions/control_flow.mjs +5 -3
  14. package/esm2022/src/render3/instructions/mark_view_dirty.mjs +3 -2
  15. package/esm2022/src/render3/instructions/shared.mjs +3 -2
  16. package/esm2022/src/render3/interfaces/view.mjs +1 -1
  17. package/esm2022/src/render3/util/view_utils.mjs +18 -5
  18. package/esm2022/src/render3/view_ref.mjs +2 -1
  19. package/esm2022/src/version.mjs +6 -5
  20. package/esm2022/src/zone/ng_zone.mjs +1 -61
  21. package/esm2022/testing/src/logger.mjs +3 -3
  22. package/fesm2022/core.mjs +176 -138
  23. package/fesm2022/core.mjs.map +1 -1
  24. package/fesm2022/primitives/signals.mjs +1 -1
  25. package/fesm2022/rxjs-interop.mjs +1 -1
  26. package/fesm2022/testing.mjs +1 -1
  27. package/index.d.ts +41 -23
  28. package/package.json +1 -1
  29. package/primitives/signals/index.d.ts +1 -1
  30. package/rxjs-interop/index.d.ts +1 -1
  31. package/schematics/migrations/block-template-entities/bundle.js +378 -278
  32. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  33. package/schematics/ng-generate/control-flow-migration/bundle.js +543 -344
  34. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  35. package/schematics/ng-generate/standalone-migration/bundle.js +412 -266
  36. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  37. package/testing/index.d.ts +1 -1
  38. package/esm2022/src/change_detection/scheduling.mjs +0 -103
  39. package/esm2022/src/initial_render_pending_tasks.mjs +0 -49
@@ -1874,7 +1874,7 @@ var ConstantPool = class {
1874
1874
  }))));
1875
1875
  }
1876
1876
  }
1877
- getSharedFunctionReference(fn2, prefix) {
1877
+ getSharedFunctionReference(fn2, prefix, useUniqueName = true) {
1878
1878
  var _a2;
1879
1879
  const isArrow = fn2 instanceof ArrowFunctionExpr;
1880
1880
  for (const current of this.statements) {
@@ -1885,7 +1885,7 @@ var ConstantPool = class {
1885
1885
  return variable(current.name);
1886
1886
  }
1887
1887
  }
1888
- const name = this.uniqueName(prefix);
1888
+ const name = useUniqueName ? this.uniqueName(prefix) : prefix;
1889
1889
  this.statements.push(fn2.toDeclStmt(name, StmtModifier.Final));
1890
1890
  return variable(name);
1891
1891
  }
@@ -3512,13 +3512,17 @@ var TagContentType;
3512
3512
  TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
3513
3513
  TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
3514
3514
  })(TagContentType || (TagContentType = {}));
3515
- function splitNsName(elementName) {
3515
+ function splitNsName(elementName, fatal = true) {
3516
3516
  if (elementName[0] != ":") {
3517
3517
  return [null, elementName];
3518
3518
  }
3519
3519
  const colonIndex = elementName.indexOf(":", 1);
3520
3520
  if (colonIndex === -1) {
3521
- throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3521
+ if (fatal) {
3522
+ throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3523
+ } else {
3524
+ return [null, elementName];
3525
+ }
3522
3526
  }
3523
3527
  return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
3524
3528
  }
@@ -4025,28 +4029,6 @@ var BlockPlaceholder = class {
4025
4029
  return visitor.visitBlockPlaceholder(this, context);
4026
4030
  }
4027
4031
  };
4028
- var RecurseVisitor = class {
4029
- visitText(text2, context) {
4030
- }
4031
- visitContainer(container, context) {
4032
- container.children.forEach((child) => child.visit(this));
4033
- }
4034
- visitIcu(icu, context) {
4035
- Object.keys(icu.cases).forEach((k) => {
4036
- icu.cases[k].visit(this);
4037
- });
4038
- }
4039
- visitTagPlaceholder(ph, context) {
4040
- ph.children.forEach((child) => child.visit(this));
4041
- }
4042
- visitPlaceholder(ph, context) {
4043
- }
4044
- visitIcuPlaceholder(ph, context) {
4045
- }
4046
- visitBlockPlaceholder(ph, context) {
4047
- ph.children.forEach((child) => child.visit(this));
4048
- }
4049
- };
4050
4032
  function serializeMessage(messageNodes) {
4051
4033
  const visitor = new LocalizeMessageStringVisitor();
4052
4034
  const str = messageNodes.map((n) => n.visit(visitor)).join("");
@@ -7114,8 +7096,9 @@ var OpKind;
7114
7096
  OpKind2[OpKind2["I18nApply"] = 40] = "I18nApply";
7115
7097
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7116
7098
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7117
- OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7118
- OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7099
+ OpKind2[OpKind2["IcuPlaceholder"] = 43] = "IcuPlaceholder";
7100
+ OpKind2[OpKind2["I18nContext"] = 44] = "I18nContext";
7101
+ OpKind2[OpKind2["I18nAttributes"] = 45] = "I18nAttributes";
7119
7102
  })(OpKind || (OpKind = {}));
7120
7103
  var ExpressionKind;
7121
7104
  (function(ExpressionKind2) {
@@ -7419,15 +7402,15 @@ function createRepeaterOp(repeaterCreate2, targetSlot, collection, sourceSpan) {
7419
7402
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7420
7403
  }
7421
7404
  function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7422
- return __spreadValues(__spreadValues({
7405
+ return __spreadValues(__spreadValues(__spreadValues({
7423
7406
  kind: OpKind.DeferWhen,
7424
7407
  target,
7425
7408
  expr,
7426
7409
  prefetch,
7427
7410
  sourceSpan
7428
- }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7411
+ }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS);
7429
7412
  }
7430
- function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7413
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, icuPlaceholder, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7431
7414
  return __spreadValues(__spreadValues(__spreadValues({
7432
7415
  kind: OpKind.I18nExpression,
7433
7416
  context,
@@ -7435,6 +7418,7 @@ function createI18nExpressionOp(context, target, i18nOwner, handle, expression,
7435
7418
  i18nOwner,
7436
7419
  handle,
7437
7420
  expression,
7421
+ icuPlaceholder,
7438
7422
  i18nPlaceholder,
7439
7423
  resolutionTime,
7440
7424
  usage,
@@ -8167,6 +8151,9 @@ function transformExpressionsInOp(op, transform2, flags) {
8167
8151
  if (op.placeholderConfig !== null) {
8168
8152
  op.placeholderConfig = transformExpressionsInExpression(op.placeholderConfig, transform2, flags);
8169
8153
  }
8154
+ if (op.resolverFn !== null) {
8155
+ op.resolverFn = transformExpressionsInExpression(op.resolverFn, transform2, flags);
8156
+ }
8170
8157
  break;
8171
8158
  case OpKind.I18nMessage:
8172
8159
  for (const [placeholder, expr] of op.params) {
@@ -8203,6 +8190,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8203
8190
  case OpKind.Template:
8204
8191
  case OpKind.Text:
8205
8192
  case OpKind.I18nAttributes:
8193
+ case OpKind.IcuPlaceholder:
8206
8194
  break;
8207
8195
  default:
8208
8196
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8260,6 +8248,14 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8260
8248
  } else if (expr instanceof TaggedTemplateExpr) {
8261
8249
  expr.tag = transformExpressionsInExpression(expr.tag, transform2, flags);
8262
8250
  expr.template.expressions = expr.template.expressions.map((e) => transformExpressionsInExpression(e, transform2, flags));
8251
+ } else if (expr instanceof ArrowFunctionExpr) {
8252
+ if (Array.isArray(expr.body)) {
8253
+ for (let i = 0; i < expr.body.length; i++) {
8254
+ transformExpressionsInStatement(expr.body[i], transform2, flags);
8255
+ }
8256
+ } else {
8257
+ expr.body = transformExpressionsInExpression(expr.body, transform2, flags);
8258
+ }
8263
8259
  } else if (expr instanceof WrappedNodeExpr) {
8264
8260
  } else if (expr instanceof ReadVarExpr || expr instanceof ExternalExpr || expr instanceof LiteralExpr) {
8265
8261
  } else {
@@ -8502,7 +8498,7 @@ var elementContainerOpKinds = /* @__PURE__ */ new Set([
8502
8498
  function isElementOrContainerOp(op) {
8503
8499
  return elementContainerOpKinds.has(op.kind);
8504
8500
  }
8505
- function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan) {
8501
+ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8506
8502
  return __spreadValues(__spreadValues({
8507
8503
  kind: OpKind.ElementStart,
8508
8504
  xref,
@@ -8513,10 +8509,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8513
8509
  nonBindable: false,
8514
8510
  namespace,
8515
8511
  i18nPlaceholder,
8516
- sourceSpan
8512
+ startSourceSpan,
8513
+ wholeSourceSpan
8517
8514
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8518
8515
  }
8519
- function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8516
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8520
8517
  return __spreadValues(__spreadValues({
8521
8518
  kind: OpKind.Template,
8522
8519
  xref,
@@ -8531,11 +8528,12 @@ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace
8531
8528
  nonBindable: false,
8532
8529
  namespace,
8533
8530
  i18nPlaceholder,
8534
- sourceSpan
8531
+ startSourceSpan,
8532
+ wholeSourceSpan
8535
8533
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8536
8534
  }
8537
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8538
- return __spreadProps(__spreadValues(__spreadValues({
8535
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, emptyTag, i18nPlaceholder, emptyI18nPlaceholder, startSourceSpan, wholeSourceSpan) {
8536
+ return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
8539
8537
  kind: OpKind.RepeaterCreate,
8540
8538
  attributes: null,
8541
8539
  xref: primaryView,
@@ -8544,6 +8542,8 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8544
8542
  track,
8545
8543
  trackByFn: null,
8546
8544
  tag,
8545
+ emptyTag,
8546
+ emptyAttributes: null,
8547
8547
  functionNameSuffix: "For",
8548
8548
  namespace: Namespace.HTML,
8549
8549
  nonBindable: false,
@@ -8554,8 +8554,9 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i1
8554
8554
  usesComponentInstance: false,
8555
8555
  i18nPlaceholder,
8556
8556
  emptyI18nPlaceholder,
8557
- sourceSpan
8558
- }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8557
+ startSourceSpan,
8558
+ wholeSourceSpan
8559
+ }, TRAIT_CONSUMES_SLOT), NEW_OP), TRAIT_CONSUMES_VARS), {
8559
8560
  numSlotsUsed: emptyView === null ? 2 : 3
8560
8561
  });
8561
8562
  }
@@ -8578,12 +8579,13 @@ function createEnableBindingsOp(xref) {
8578
8579
  xref
8579
8580
  }, NEW_OP);
8580
8581
  }
8581
- function createTextOp(xref, initialValue, sourceSpan) {
8582
+ function createTextOp(xref, initialValue, icuPlaceholder, sourceSpan) {
8582
8583
  return __spreadValues(__spreadValues({
8583
8584
  kind: OpKind.Text,
8584
8585
  xref,
8585
8586
  handle: new SlotHandle(),
8586
8587
  initialValue,
8588
+ icuPlaceholder,
8587
8589
  sourceSpan
8588
8590
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8589
8591
  }
@@ -8626,7 +8628,7 @@ function createProjectionDefOp(def) {
8626
8628
  def
8627
8629
  }, NEW_OP);
8628
8630
  }
8629
- function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceSpan) {
8631
+ function createProjectionOp(xref, selector, i18nPlaceholder, sourceSpan) {
8630
8632
  return __spreadValues(__spreadValues({
8631
8633
  kind: OpKind.Projection,
8632
8634
  xref,
@@ -8634,7 +8636,7 @@ function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceS
8634
8636
  selector,
8635
8637
  i18nPlaceholder,
8636
8638
  projectionSlotIndex: 0,
8637
- attributes,
8639
+ attributes: null,
8638
8640
  localRefs: [],
8639
8641
  sourceSpan
8640
8642
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
@@ -8700,7 +8702,7 @@ function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlace
8700
8702
  subMessages: []
8701
8703
  }, NEW_OP);
8702
8704
  }
8703
- function createI18nStartOp(xref, message, root) {
8705
+ function createI18nStartOp(xref, message, root, sourceSpan) {
8704
8706
  return __spreadValues(__spreadValues({
8705
8707
  kind: OpKind.I18nStart,
8706
8708
  xref,
@@ -8709,13 +8711,15 @@ function createI18nStartOp(xref, message, root) {
8709
8711
  message,
8710
8712
  messageIndex: null,
8711
8713
  subTemplateIndex: null,
8712
- context: null
8714
+ context: null,
8715
+ sourceSpan
8713
8716
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8714
8717
  }
8715
- function createI18nEndOp(xref) {
8718
+ function createI18nEndOp(xref, sourceSpan) {
8716
8719
  return __spreadValues({
8717
8720
  kind: OpKind.I18nEnd,
8718
- xref
8721
+ xref,
8722
+ sourceSpan
8719
8723
  }, NEW_OP);
8720
8724
  }
8721
8725
  function createIcuStartOp(xref, message, messagePlaceholder, sourceSpan) {
@@ -8734,6 +8738,15 @@ function createIcuEndOp(xref) {
8734
8738
  xref
8735
8739
  }, NEW_OP);
8736
8740
  }
8741
+ function createIcuPlaceholderOp(xref, name, strings) {
8742
+ return __spreadValues({
8743
+ kind: OpKind.IcuPlaceholder,
8744
+ xref,
8745
+ name,
8746
+ strings,
8747
+ expressionPlaceholders: []
8748
+ }, NEW_OP);
8749
+ }
8737
8750
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8738
8751
  if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8739
8752
  throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
@@ -8997,6 +9010,9 @@ function createOpXrefMap(unit) {
8997
9010
  continue;
8998
9011
  }
8999
9012
  map.set(op.xref, op);
9013
+ if (op.kind === OpKind.RepeaterCreate && op.emptyView !== null) {
9014
+ map.set(op.emptyView, op);
9015
+ }
9000
9016
  }
9001
9017
  return map;
9002
9018
  }
@@ -9060,6 +9076,9 @@ function extractAttributes(job) {
9060
9076
  SecurityContext.NONE
9061
9077
  );
9062
9078
  if (job.kind === CompilationJobKind.Host) {
9079
+ if (job.compatibility) {
9080
+ break;
9081
+ }
9063
9082
  unit.create.push(extractedAttributeOp);
9064
9083
  } else {
9065
9084
  OpList.insertBefore(extractedAttributeOp, lookupElement(elements, op.target));
@@ -9081,15 +9100,9 @@ function extractAttributeOp(unit, op, elements) {
9081
9100
  if (op.expression instanceof Interpolation2) {
9082
9101
  return;
9083
9102
  }
9084
- let extractable = op.expression.isConstant();
9103
+ let extractable = op.isTextAttribute || op.expression.isConstant();
9085
9104
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9086
- extractable = isStringLiteral(op.expression);
9087
- if (op.name === "style" || op.name === "class") {
9088
- extractable && (extractable = op.isTextAttribute);
9089
- }
9090
- if (unit.job.kind === CompilationJobKind.Host) {
9091
- extractable && (extractable = op.isTextAttribute);
9092
- }
9105
+ extractable && (extractable = op.isTextAttribute);
9093
9106
  }
9094
9107
  if (extractable) {
9095
9108
  const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
@@ -9324,7 +9337,7 @@ function collectElementConsts(job) {
9324
9337
  for (const unit of job.units) {
9325
9338
  for (const op of unit.create) {
9326
9339
  if (op.kind === OpKind.ExtractedAttribute) {
9327
- const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9340
+ const attributes = allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);
9328
9341
  allElementAttributes.set(op.target, attributes);
9329
9342
  attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9330
9343
  OpList.remove(op);
@@ -9334,14 +9347,19 @@ function collectElementConsts(job) {
9334
9347
  if (job instanceof ComponentCompilationJob) {
9335
9348
  for (const unit of job.units) {
9336
9349
  for (const op of unit.create) {
9337
- if (isElementOrContainerOp(op)) {
9350
+ if (op.kind == OpKind.Projection) {
9338
9351
  const attributes = allElementAttributes.get(op.xref);
9339
9352
  if (attributes !== void 0) {
9340
9353
  const attrArray = serializeAttributes(attributes);
9341
9354
  if (attrArray.entries.length > 0) {
9342
- op.attributes = job.addConst(attrArray);
9355
+ op.attributes = attrArray;
9343
9356
  }
9344
9357
  }
9358
+ } else if (isElementOrContainerOp(op)) {
9359
+ op.attributes = getConstIndex(job, allElementAttributes, op.xref);
9360
+ if (op.kind === OpKind.RepeaterCreate && op.emptyView !== null) {
9361
+ op.emptyAttributes = getConstIndex(job, allElementAttributes, op.emptyView);
9362
+ }
9345
9363
  }
9346
9364
  }
9347
9365
  }
@@ -9357,13 +9375,18 @@ function collectElementConsts(job) {
9357
9375
  }
9358
9376
  }
9359
9377
  }
9378
+ function getConstIndex(job, allElementAttributes, xref) {
9379
+ const attributes = allElementAttributes.get(xref);
9380
+ if (attributes !== void 0) {
9381
+ const attrArray = serializeAttributes(attributes);
9382
+ if (attrArray.entries.length > 0) {
9383
+ return job.addConst(attrArray);
9384
+ }
9385
+ }
9386
+ return null;
9387
+ }
9360
9388
  var FLYWEIGHT_ARRAY = Object.freeze([]);
9361
9389
  var ElementAttributes = class {
9362
- constructor() {
9363
- this.known = /* @__PURE__ */ new Set();
9364
- this.byKind = /* @__PURE__ */ new Map();
9365
- this.projectAs = null;
9366
- }
9367
9390
  get attributes() {
9368
9391
  var _a2;
9369
9392
  return (_a2 = this.byKind.get(BindingKind.Attribute)) != null ? _a2 : FLYWEIGHT_ARRAY;
@@ -9388,12 +9411,28 @@ var ElementAttributes = class {
9388
9411
  var _a2;
9389
9412
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9390
9413
  }
9414
+ constructor(compatibility) {
9415
+ this.compatibility = compatibility;
9416
+ this.known = /* @__PURE__ */ new Map();
9417
+ this.byKind = /* @__PURE__ */ new Map();
9418
+ this.projectAs = null;
9419
+ }
9420
+ isKnown(kind, name, value) {
9421
+ var _a2;
9422
+ const nameToValue = (_a2 = this.known.get(kind)) != null ? _a2 : /* @__PURE__ */ new Set();
9423
+ this.known.set(kind, nameToValue);
9424
+ if (nameToValue.has(name)) {
9425
+ return true;
9426
+ }
9427
+ nameToValue.add(name);
9428
+ return false;
9429
+ }
9391
9430
  add(kind, name, value, trustedValueFn) {
9392
9431
  var _a2;
9393
- if (this.known.has(name)) {
9432
+ const allowDuplicates = this.compatibility === CompatibilityMode.TemplateDefinitionBuilder && (kind === BindingKind.Attribute || kind === BindingKind.ClassName || kind === BindingKind.StyleProperty);
9433
+ if (!allowDuplicates && this.isKnown(kind, name, value)) {
9394
9434
  return;
9395
9435
  }
9396
- this.known.add(name);
9397
9436
  if (name === "ngProjectAs") {
9398
9437
  if (value === null || !(value instanceof LiteralExpr) || value.value == null || typeof ((_a2 = value.value) == null ? void 0 : _a2.toString()) !== "string") {
9399
9438
  throw Error("ngProjectAs must have a string literal value");
@@ -9424,7 +9463,7 @@ var ElementAttributes = class {
9424
9463
  }
9425
9464
  };
9426
9465
  function getAttributeNameLiterals(name) {
9427
- const [attributeNamespace, attributeName] = splitNsName(name);
9466
+ const [attributeNamespace, attributeName] = splitNsName(name, false);
9428
9467
  const nameLiteral = literal(attributeName);
9429
9468
  if (attributeNamespace) {
9430
9469
  return [
@@ -9491,7 +9530,7 @@ function convertI18nBindings(job) {
9491
9530
  if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9492
9531
  throw new Error(`AssertionError: An i18n attribute binding instruction requires the same number of expressions and placeholders, but found ${op.expression.i18nPlaceholders.length} placeholders and ${op.expression.expressions.length} expressions`);
9493
9532
  }
9494
- ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9533
+ ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, null, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9495
9534
  }
9496
9535
  OpList.replaceWithMany(op, ops);
9497
9536
  break;
@@ -9522,7 +9561,11 @@ function createDeferDepsFns(job) {
9522
9561
  if (op.handle.slot === null) {
9523
9562
  throw new Error("AssertionError: slot must be assigned bfore extracting defer deps functions");
9524
9563
  }
9525
- op.resolverFn = job.pool.getSharedFunctionReference(depsFnExpr, `${job.componentName}_Defer_${op.handle.slot}_DepsFn`);
9564
+ op.resolverFn = job.pool.getSharedFunctionReference(
9565
+ depsFnExpr,
9566
+ `${job.componentName}_Defer_${op.handle.slot}_DepsFn`,
9567
+ false
9568
+ );
9526
9569
  }
9527
9570
  }
9528
9571
  }
@@ -9530,62 +9573,99 @@ function createDeferDepsFns(job) {
9530
9573
 
9531
9574
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_i18n_contexts.mjs
9532
9575
  function createI18nContexts(job) {
9533
- const rootContexts = /* @__PURE__ */ new Map();
9534
- let currentI18nOp = null;
9535
- let xref;
9536
- const messageToContext = /* @__PURE__ */ new Map();
9576
+ const attrContextByMessage = /* @__PURE__ */ new Map();
9577
+ for (const unit of job.units) {
9578
+ for (const op of unit.ops()) {
9579
+ switch (op.kind) {
9580
+ case OpKind.Binding:
9581
+ case OpKind.Property:
9582
+ case OpKind.Attribute:
9583
+ case OpKind.ExtractedAttribute:
9584
+ if (op.i18nMessage === null) {
9585
+ continue;
9586
+ }
9587
+ if (!attrContextByMessage.has(op.i18nMessage)) {
9588
+ const i18nContext = createI18nContextOp(I18nContextKind.Attr, job.allocateXrefId(), null, op.i18nMessage, null);
9589
+ unit.create.push(i18nContext);
9590
+ attrContextByMessage.set(op.i18nMessage, i18nContext.xref);
9591
+ }
9592
+ op.i18nContext = attrContextByMessage.get(op.i18nMessage);
9593
+ break;
9594
+ }
9595
+ }
9596
+ }
9597
+ const blockContextByI18nBlock = /* @__PURE__ */ new Map();
9537
9598
  for (const unit of job.units) {
9538
9599
  for (const op of unit.create) {
9539
9600
  switch (op.kind) {
9540
9601
  case OpKind.I18nStart:
9541
- currentI18nOp = op;
9542
9602
  if (op.xref === op.root) {
9543
- xref = job.allocateXrefId();
9544
- unit.create.push(createI18nContextOp(I18nContextKind.RootI18n, xref, op.xref, op.message, null));
9545
- op.context = xref;
9546
- rootContexts.set(op.xref, xref);
9603
+ const contextOp = createI18nContextOp(I18nContextKind.RootI18n, job.allocateXrefId(), op.xref, op.message, null);
9604
+ unit.create.push(contextOp);
9605
+ op.context = contextOp.xref;
9606
+ blockContextByI18nBlock.set(op.xref, contextOp);
9547
9607
  }
9548
9608
  break;
9609
+ }
9610
+ }
9611
+ }
9612
+ for (const unit of job.units) {
9613
+ for (const op of unit.create) {
9614
+ if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9615
+ const rootContext = blockContextByI18nBlock.get(op.root);
9616
+ if (rootContext === void 0) {
9617
+ throw Error("AssertionError: Root i18n block i18n context should have been created.");
9618
+ }
9619
+ op.context = rootContext.xref;
9620
+ blockContextByI18nBlock.set(op.xref, rootContext);
9621
+ }
9622
+ }
9623
+ }
9624
+ let currentI18nOp = null;
9625
+ for (const unit of job.units) {
9626
+ for (const op of unit.create) {
9627
+ switch (op.kind) {
9628
+ case OpKind.I18nStart:
9629
+ currentI18nOp = op;
9630
+ break;
9549
9631
  case OpKind.I18nEnd:
9550
9632
  currentI18nOp = null;
9551
9633
  break;
9552
9634
  case OpKind.IcuStart:
9553
9635
  if (currentI18nOp === null) {
9554
- throw Error("Unexpected ICU outside of an i18n block.");
9636
+ throw Error("AssertionError: Unexpected ICU outside of an i18n block.");
9555
9637
  }
9556
9638
  if (op.message.id !== currentI18nOp.message.id) {
9557
- xref = job.allocateXrefId();
9558
- unit.create.push(createI18nContextOp(I18nContextKind.Icu, xref, currentI18nOp.xref, op.message, null));
9559
- op.context = xref;
9639
+ const contextOp = createI18nContextOp(I18nContextKind.Icu, job.allocateXrefId(), currentI18nOp.xref, op.message, null);
9640
+ unit.create.push(contextOp);
9641
+ op.context = contextOp.xref;
9560
9642
  } else {
9561
9643
  op.context = currentI18nOp.context;
9644
+ blockContextByI18nBlock.get(currentI18nOp.xref).contextKind = I18nContextKind.Icu;
9562
9645
  }
9563
9646
  break;
9564
9647
  }
9565
9648
  }
9566
- for (const op of unit.ops()) {
9567
- switch (op.kind) {
9568
- case OpKind.Binding:
9569
- case OpKind.Property:
9570
- case OpKind.Attribute:
9571
- case OpKind.ExtractedAttribute:
9572
- if (!op.i18nMessage) {
9573
- continue;
9574
- }
9575
- if (!messageToContext.has(op.i18nMessage)) {
9576
- const i18nContext = job.allocateXrefId();
9577
- unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
9578
- messageToContext.set(op.i18nMessage, i18nContext);
9579
- }
9580
- op.i18nContext = messageToContext.get(op.i18nMessage);
9581
- break;
9582
- }
9583
- }
9584
9649
  }
9650
+ }
9651
+
9652
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/deduplicate_text_bindings.mjs
9653
+ function deduplicateTextBindings(job) {
9654
+ const seen = /* @__PURE__ */ new Map();
9585
9655
  for (const unit of job.units) {
9586
- for (const op of unit.create) {
9587
- if (op.kind === OpKind.I18nStart && op.xref !== op.root) {
9588
- op.context = rootContexts.get(op.root);
9656
+ for (const op of unit.update.reversed()) {
9657
+ if (op.kind === OpKind.Binding && op.isTextAttribute) {
9658
+ const seenForElement = seen.get(op.target) || /* @__PURE__ */ new Set();
9659
+ if (seenForElement.has(op.name)) {
9660
+ if (job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
9661
+ if (op.name === "style" || op.name === "class") {
9662
+ OpList.remove(op);
9663
+ }
9664
+ } else {
9665
+ }
9666
+ }
9667
+ seenForElement.add(op.name);
9668
+ seen.set(op.target, seenForElement);
9589
9669
  }
9590
9670
  }
9591
9671
  }
@@ -9875,12 +9955,16 @@ var LIST_START_MARKER = "[";
9875
9955
  var LIST_END_MARKER = "]";
9876
9956
  var LIST_DELIMITER = "|";
9877
9957
  function extractI18nMessages(job) {
9878
- const i18nContexts = /* @__PURE__ */ new Map();
9958
+ const i18nMessagesByContext = /* @__PURE__ */ new Map();
9879
9959
  const i18nBlocks = /* @__PURE__ */ new Map();
9960
+ const i18nContexts = /* @__PURE__ */ new Map();
9880
9961
  for (const unit of job.units) {
9881
9962
  for (const op of unit.create) {
9882
9963
  switch (op.kind) {
9883
9964
  case OpKind.I18nContext:
9965
+ const i18nMessageOp = createI18nMessage(job, op);
9966
+ unit.create.push(i18nMessageOp);
9967
+ i18nMessagesByContext.set(op.xref, i18nMessageOp);
9884
9968
  i18nContexts.set(op.xref, op);
9885
9969
  break;
9886
9970
  case OpKind.I18nStart:
@@ -9889,49 +9973,40 @@ function extractI18nMessages(job) {
9889
9973
  }
9890
9974
  }
9891
9975
  }
9892
- for (const unit of job.units) {
9893
- for (const op of unit.create) {
9894
- if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
9895
- continue;
9896
- }
9897
- const i18nMessageOp = createI18nMessage(job, op);
9898
- unit.create.push(i18nMessageOp);
9899
- }
9900
- }
9901
- const i18nBlockMessages = /* @__PURE__ */ new Map();
9902
- for (const unit of job.units) {
9903
- for (const op of unit.create) {
9904
- if (op.kind === OpKind.I18nStart && op.xref === op.root) {
9905
- if (!op.context) {
9906
- throw Error("I18n start op should have its context set.");
9907
- }
9908
- const i18nMessageOp = createI18nMessage(job, i18nContexts.get(op.context));
9909
- i18nBlockMessages.set(op.xref, i18nMessageOp);
9910
- unit.create.push(i18nMessageOp);
9911
- }
9912
- }
9913
- }
9976
+ let currentIcu = null;
9914
9977
  for (const unit of job.units) {
9915
9978
  for (const op of unit.create) {
9916
9979
  switch (op.kind) {
9917
9980
  case OpKind.IcuStart:
9918
- if (!op.context) {
9919
- throw Error("ICU op should have its context set.");
9981
+ currentIcu = op;
9982
+ OpList.remove(op);
9983
+ const icuContext = i18nContexts.get(op.context);
9984
+ if (icuContext.contextKind !== I18nContextKind.Icu) {
9985
+ continue;
9920
9986
  }
9921
- const i18nContext = i18nContexts.get(op.context);
9922
- if (i18nContext.contextKind === I18nContextKind.Icu) {
9923
- if (i18nContext.i18nBlock === null) {
9924
- throw Error("ICU context should have its i18n block set.");
9925
- }
9926
- const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9927
- unit.create.push(subMessage);
9928
- const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
9929
- const parentMessage = i18nBlockMessages.get(rootI18nId);
9930
- parentMessage == null ? void 0 : parentMessage.subMessages.push(subMessage.xref);
9987
+ const i18nBlock = i18nBlocks.get(icuContext.i18nBlock);
9988
+ if (i18nBlock.context === icuContext.xref) {
9989
+ continue;
9931
9990
  }
9932
- OpList.remove(op);
9991
+ const rootI18nBlock = i18nBlocks.get(i18nBlock.root);
9992
+ const rootMessage = i18nMessagesByContext.get(rootI18nBlock.context);
9993
+ if (rootMessage === void 0) {
9994
+ throw Error("AssertionError: ICU sub-message should belong to a root message.");
9995
+ }
9996
+ const subMessage = i18nMessagesByContext.get(icuContext.xref);
9997
+ subMessage.messagePlaceholder = op.messagePlaceholder;
9998
+ rootMessage.subMessages.push(subMessage.xref);
9933
9999
  break;
9934
10000
  case OpKind.IcuEnd:
10001
+ currentIcu = null;
10002
+ OpList.remove(op);
10003
+ break;
10004
+ case OpKind.IcuPlaceholder:
10005
+ if (currentIcu === null || currentIcu.context == null) {
10006
+ throw Error("AssertionError: Unexpected ICU placeholder outside of i18n context");
10007
+ }
10008
+ const msg = i18nMessagesByContext.get(currentIcu.context);
10009
+ msg.postprocessingParams.set(op.name, literal(formatIcuPlaceholder(op)));
9935
10010
  OpList.remove(op);
9936
10011
  break;
9937
10012
  }
@@ -9941,14 +10016,16 @@ function extractI18nMessages(job) {
9941
10016
  function createI18nMessage(job, context, messagePlaceholder) {
9942
10017
  let formattedParams = formatParams(context.params);
9943
10018
  const formattedPostprocessingParams = formatParams(context.postprocessingParams);
9944
- let needsPostprocessing = formattedPostprocessingParams.size > 0;
9945
- for (const values of context.params.values()) {
9946
- if (values.length > 1) {
9947
- needsPostprocessing = true;
9948
- }
9949
- }
10019
+ let needsPostprocessing = [...context.params.values()].some((v) => v.length > 1);
9950
10020
  return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9951
10021
  }
10022
+ function formatIcuPlaceholder(op) {
10023
+ if (op.strings.length !== op.expressionPlaceholders.length + 1) {
10024
+ throw Error(`AsserionError: Invalid ICU placeholder with ${op.strings.length} strings and ${op.expressionPlaceholders.length} expressions`);
10025
+ }
10026
+ const values = op.expressionPlaceholders.map(formatValue);
10027
+ return op.strings.flatMap((str, i) => [str, values[i] || ""]).join("");
10028
+ }
9952
10029
  function formatParams(params) {
9953
10030
  const formattedParams = /* @__PURE__ */ new Map();
9954
10031
  for (const [placeholder, placeholderValues] of params) {
@@ -10175,7 +10252,7 @@ var CLASS_BANG = "class!";
10175
10252
  var BANG_IMPORTANT = "!important";
10176
10253
  function parseHostStyleProperties(job) {
10177
10254
  for (const op of job.root.update) {
10178
- if (op.kind !== OpKind.Binding) {
10255
+ if (!(op.kind === OpKind.Binding && op.bindingKind === BindingKind.Property)) {
10179
10256
  continue;
10180
10257
  }
10181
10258
  if (op.name.endsWith(BANG_IMPORTANT)) {
@@ -16317,7 +16394,7 @@ function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16317
16394
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16318
16395
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16319
16396
  let transformFn = void 0;
16320
- if (messageOp.needsPostprocessing) {
16397
+ if (messageOp.needsPostprocessing || messageOp.postprocessingParams.size > 0) {
16321
16398
  const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16322
16399
  const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16323
16400
  const extraTransformFnParams = [];
@@ -16336,7 +16413,6 @@ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16336
16413
  } else {
16337
16414
  messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16338
16415
  messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16339
- messageOp.needsPostprocessing = true;
16340
16416
  }
16341
16417
  }
16342
16418
  }
@@ -16370,12 +16446,13 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16370
16446
 
16371
16447
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16372
16448
  function convertI18nText(job) {
16373
- var _a2;
16449
+ var _a2, _b2, _c2;
16374
16450
  for (const unit of job.units) {
16375
16451
  let currentI18n = null;
16376
16452
  let currentIcu = null;
16377
16453
  const textNodeI18nBlocks = /* @__PURE__ */ new Map();
16378
16454
  const textNodeIcus = /* @__PURE__ */ new Map();
16455
+ const icuPlaceholderByText = /* @__PURE__ */ new Map();
16379
16456
  for (const op of unit.create) {
16380
16457
  switch (op.kind) {
16381
16458
  case OpKind.I18nStart:
@@ -16400,7 +16477,13 @@ function convertI18nText(job) {
16400
16477
  if (currentI18n !== null) {
16401
16478
  textNodeI18nBlocks.set(op.xref, currentI18n);
16402
16479
  textNodeIcus.set(op.xref, currentIcu);
16403
- OpList.remove(op);
16480
+ if (op.icuPlaceholder !== null) {
16481
+ const icuPlaceholderOp = createIcuPlaceholderOp(job.allocateXrefId(), op.icuPlaceholder, [op.initialValue]);
16482
+ OpList.replace(op, icuPlaceholderOp);
16483
+ icuPlaceholderByText.set(op.xref, icuPlaceholderOp);
16484
+ } else {
16485
+ OpList.remove(op);
16486
+ }
16404
16487
  }
16405
16488
  break;
16406
16489
  }
@@ -16413,14 +16496,18 @@ function convertI18nText(job) {
16413
16496
  }
16414
16497
  const i18nOp = textNodeI18nBlocks.get(op.target);
16415
16498
  const icuOp = textNodeIcus.get(op.target);
16499
+ const icuPlaceholder = icuPlaceholderByText.get(op.target);
16416
16500
  const contextId = icuOp ? icuOp.context : i18nOp.context;
16417
16501
  const resolutionTime = icuOp ? I18nParamResolutionTime.Postproccessing : I18nParamResolutionTime.Creation;
16418
16502
  const ops = [];
16419
16503
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16420
16504
  const expr = op.interpolation.expressions[i];
16421
- ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, op.interpolation.i18nPlaceholders[i], resolutionTime, I18nExpressionFor.I18nText, "", (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
16505
+ ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.xref, i18nOp.handle, expr, (_a2 = icuPlaceholder == null ? void 0 : icuPlaceholder.xref) != null ? _a2 : null, (_b2 = op.interpolation.i18nPlaceholders[i]) != null ? _b2 : null, resolutionTime, I18nExpressionFor.I18nText, "", (_c2 = expr.sourceSpan) != null ? _c2 : op.sourceSpan));
16422
16506
  }
16423
16507
  OpList.replaceWithMany(op, ops);
16508
+ if (icuPlaceholder !== void 0) {
16509
+ icuPlaceholder.strings = op.interpolation.strings;
16510
+ }
16424
16511
  break;
16425
16512
  }
16426
16513
  }
@@ -16571,7 +16658,7 @@ function addNamesToView(unit, baseName, state, compatibility) {
16571
16658
  op.handlerFnName = sanitizeIdentifier(op.handlerFnName);
16572
16659
  break;
16573
16660
  case OpKind.Variable:
16574
- varNames.set(op.xref, getVariableName(op.variable, state));
16661
+ varNames.set(op.xref, getVariableName(unit, op.variable, state));
16575
16662
  break;
16576
16663
  case OpKind.RepeaterCreate:
16577
16664
  if (!(unit instanceof ViewCompilationUnit)) {
@@ -16622,14 +16709,19 @@ function addNamesToView(unit, baseName, state, compatibility) {
16622
16709
  });
16623
16710
  }
16624
16711
  }
16625
- function getVariableName(variable2, state) {
16712
+ function getVariableName(unit, variable2, state) {
16626
16713
  if (variable2.name === null) {
16627
16714
  switch (variable2.kind) {
16628
16715
  case SemanticVariableKind.Context:
16629
16716
  variable2.name = `ctx_r${state.index++}`;
16630
16717
  break;
16631
16718
  case SemanticVariableKind.Identifier:
16632
- variable2.name = `${variable2.identifier}_r${++state.index}`;
16719
+ if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder) {
16720
+ const compatPrefix = variable2.identifier === "ctx" ? "i" : "";
16721
+ variable2.name = `${variable2.identifier}_${compatPrefix}r${++state.index}`;
16722
+ } else {
16723
+ variable2.name = `${variable2.identifier}_i${state.index++}`;
16724
+ }
16633
16725
  break;
16634
16726
  default:
16635
16727
  variable2.name = `_r${++state.index}`;
@@ -16772,17 +16864,24 @@ var CREATE_ORDERING = [
16772
16864
  { test: (op) => op.kind === OpKind.Listener && !(op.hostListener && op.isAnimationListener) }
16773
16865
  ];
16774
16866
  var UPDATE_ORDERING = [
16775
- { test: kindWithInterpolationTest(OpKind.HostProperty, true) },
16776
- { test: kindWithInterpolationTest(OpKind.HostProperty, false) },
16777
16867
  { test: kindTest(OpKind.StyleMap), transform: keepLast },
16778
16868
  { test: kindTest(OpKind.ClassMap), transform: keepLast },
16779
16869
  { test: kindTest(OpKind.StyleProp) },
16780
16870
  { test: kindTest(OpKind.ClassProp) },
16781
- { test: kindWithInterpolationTest(OpKind.Property, true) },
16782
16871
  { test: kindWithInterpolationTest(OpKind.Attribute, true) },
16872
+ { test: kindWithInterpolationTest(OpKind.Property, true) },
16783
16873
  { test: kindWithInterpolationTest(OpKind.Property, false) },
16784
16874
  { test: kindWithInterpolationTest(OpKind.Attribute, false) }
16785
16875
  ];
16876
+ var UPDATE_HOST_ORDERING = [
16877
+ { test: kindWithInterpolationTest(OpKind.HostProperty, true) },
16878
+ { test: kindWithInterpolationTest(OpKind.HostProperty, false) },
16879
+ { test: kindTest(OpKind.Attribute) },
16880
+ { test: kindTest(OpKind.StyleMap), transform: keepLast },
16881
+ { test: kindTest(OpKind.ClassMap), transform: keepLast },
16882
+ { test: kindTest(OpKind.StyleProp) },
16883
+ { test: kindTest(OpKind.ClassProp) }
16884
+ ];
16786
16885
  var handledOpKinds = /* @__PURE__ */ new Set([
16787
16886
  OpKind.Listener,
16788
16887
  OpKind.StyleMap,
@@ -16796,7 +16895,8 @@ var handledOpKinds = /* @__PURE__ */ new Set([
16796
16895
  function orderOps(job) {
16797
16896
  for (const unit of job.units) {
16798
16897
  orderWithin(unit.create, CREATE_ORDERING);
16799
- orderWithin(unit.update, UPDATE_ORDERING);
16898
+ const ordering = unit.job.kind === CompilationJobKind.Host ? UPDATE_HOST_ORDERING : UPDATE_ORDERING;
16899
+ orderWithin(unit.update, ordering);
16800
16900
  }
16801
16901
  }
16802
16902
  function orderWithin(opList, ordering) {
@@ -16834,9 +16934,21 @@ function keepLast(ops) {
16834
16934
 
16835
16935
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/parse_extracted_styles.mjs
16836
16936
  function parseExtractedStyles(job) {
16937
+ const elements = /* @__PURE__ */ new Map();
16938
+ for (const unit of job.units) {
16939
+ for (const op of unit.create) {
16940
+ if (isElementOrContainerOp(op)) {
16941
+ elements.set(op.xref, op);
16942
+ }
16943
+ }
16944
+ }
16837
16945
  for (const unit of job.units) {
16838
16946
  for (const op of unit.create) {
16839
16947
  if (op.kind === OpKind.ExtractedAttribute && op.bindingKind === BindingKind.Attribute && isStringLiteral(op.expression)) {
16948
+ const target = elements.get(op.target);
16949
+ if (target !== void 0 && target.kind === OpKind.Template && target.templateKind === TemplateKind.Structural) {
16950
+ continue;
16951
+ }
16840
16952
  if (op.name === "style") {
16841
16953
  const parsedStyles = parse(op.expression.value);
16842
16954
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
@@ -16867,13 +16979,6 @@ function removeContentSelectors(job) {
16867
16979
  OpList.remove(op);
16868
16980
  }
16869
16981
  break;
16870
- case OpKind.Projection:
16871
- for (let i = op.attributes.length - 2; i >= 0; i -= 2) {
16872
- if (isSelectAttribute(op.attributes[i])) {
16873
- op.attributes.splice(i, 2);
16874
- }
16875
- }
16876
- break;
16877
16982
  }
16878
16983
  }
16879
16984
  }
@@ -17000,8 +17105,11 @@ function wrapTemplateWithI18n(unit, parentI18n) {
17000
17105
  var _a2;
17001
17106
  if (((_a2 = unit.create.head.next) == null ? void 0 : _a2.kind) !== OpKind.I18nStart) {
17002
17107
  const id = unit.job.allocateXrefId();
17003
- OpList.insertAfter(createI18nStartOp(id, parentI18n.message, parentI18n.root), unit.create.head);
17004
- OpList.insertBefore(createI18nEndOp(id), unit.create.tail);
17108
+ OpList.insertAfter(
17109
+ createI18nStartOp(id, parentI18n.message, parentI18n.root, null),
17110
+ unit.create.head
17111
+ );
17112
+ OpList.insertBefore(createI18nEndOp(id, null), unit.create.tail);
17005
17113
  }
17006
17114
  }
17007
17115
 
@@ -17256,22 +17364,22 @@ function projectionDef(def) {
17256
17364
  }
17257
17365
  function projection(slot, projectionSlotIndex, attributes, sourceSpan) {
17258
17366
  const args = [literal(slot)];
17259
- if (projectionSlotIndex !== 0 || attributes.length > 0) {
17367
+ if (projectionSlotIndex !== 0 || attributes !== null) {
17260
17368
  args.push(literal(projectionSlotIndex));
17261
- if (attributes.length > 0) {
17262
- args.push(literalArr(attributes.map((attr) => literal(attr))));
17369
+ if (attributes !== null) {
17370
+ args.push(attributes);
17263
17371
  }
17264
17372
  }
17265
17373
  return call(Identifiers.projection, args, sourceSpan);
17266
17374
  }
17267
- function i18nStart(slot, constIndex, subTemplateIndex) {
17375
+ function i18nStart(slot, constIndex, subTemplateIndex, sourceSpan) {
17268
17376
  const args = [literal(slot), literal(constIndex)];
17269
17377
  if (subTemplateIndex !== null) {
17270
17378
  args.push(literal(subTemplateIndex));
17271
17379
  }
17272
- return call(Identifiers.i18nStart, args, null);
17380
+ return call(Identifiers.i18nStart, args, sourceSpan);
17273
17381
  }
17274
- function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, sourceSpan) {
17382
+ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByFn, trackByUsesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, emptyTag, emptyConstIndex, sourceSpan) {
17275
17383
  const args = [
17276
17384
  literal(slot),
17277
17385
  variable(viewFnName),
@@ -17285,6 +17393,12 @@ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByF
17285
17393
  args.push(literal(trackByUsesComponentInstance));
17286
17394
  if (emptyViewFnName !== null) {
17287
17395
  args.push(variable(emptyViewFnName), literal(emptyDecls), literal(emptyVars));
17396
+ if (emptyTag !== null || emptyConstIndex !== null) {
17397
+ args.push(literal(emptyTag));
17398
+ }
17399
+ if (emptyConstIndex !== null) {
17400
+ args.push(literal(emptyConstIndex));
17401
+ }
17288
17402
  }
17289
17403
  }
17290
17404
  return call(Identifiers.repeaterCreate, args, sourceSpan);
@@ -17295,15 +17409,15 @@ function repeater(collection, sourceSpan) {
17295
17409
  function deferWhen(prefetch, expr, sourceSpan) {
17296
17410
  return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
17297
17411
  }
17298
- function i18n(slot, constIndex, subTemplateIndex) {
17412
+ function i18n(slot, constIndex, subTemplateIndex, sourceSpan) {
17299
17413
  const args = [literal(slot), literal(constIndex)];
17300
17414
  if (subTemplateIndex) {
17301
17415
  args.push(literal(subTemplateIndex));
17302
17416
  }
17303
- return call(Identifiers.i18n, args, null);
17417
+ return call(Identifiers.i18n, args, sourceSpan);
17304
17418
  }
17305
- function i18nEnd() {
17306
- return call(Identifiers.i18nEnd, [], null);
17419
+ function i18nEnd(endSourceSpan) {
17420
+ return call(Identifiers.i18nEnd, [], endSourceSpan);
17307
17421
  }
17308
17422
  function i18nAttributes(slot, i18nAttributesConfig) {
17309
17423
  const args = [literal(slot), literal(i18nAttributesConfig)];
@@ -17630,31 +17744,31 @@ function reifyCreateOperations(unit, ops) {
17630
17744
  OpList.replace(op, text(op.handle.slot, op.initialValue, op.sourceSpan));
17631
17745
  break;
17632
17746
  case OpKind.ElementStart:
17633
- OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17747
+ OpList.replace(op, elementStart(op.handle.slot, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17634
17748
  break;
17635
17749
  case OpKind.Element:
17636
- OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17750
+ OpList.replace(op, element(op.handle.slot, op.tag, op.attributes, op.localRefs, op.wholeSourceSpan));
17637
17751
  break;
17638
17752
  case OpKind.ElementEnd:
17639
17753
  OpList.replace(op, elementEnd(op.sourceSpan));
17640
17754
  break;
17641
17755
  case OpKind.ContainerStart:
17642
- OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17756
+ OpList.replace(op, elementContainerStart(op.handle.slot, op.attributes, op.localRefs, op.startSourceSpan));
17643
17757
  break;
17644
17758
  case OpKind.Container:
17645
- OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.sourceSpan));
17759
+ OpList.replace(op, elementContainer(op.handle.slot, op.attributes, op.localRefs, op.wholeSourceSpan));
17646
17760
  break;
17647
17761
  case OpKind.ContainerEnd:
17648
17762
  OpList.replace(op, elementContainerEnd());
17649
17763
  break;
17650
17764
  case OpKind.I18nStart:
17651
- OpList.replace(op, i18nStart(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17765
+ OpList.replace(op, i18nStart(op.handle.slot, op.messageIndex, op.subTemplateIndex, op.sourceSpan));
17652
17766
  break;
17653
17767
  case OpKind.I18nEnd:
17654
- OpList.replace(op, i18nEnd());
17768
+ OpList.replace(op, i18nEnd(op.sourceSpan));
17655
17769
  break;
17656
17770
  case OpKind.I18n:
17657
- OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17771
+ OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex, op.sourceSpan));
17658
17772
  break;
17659
17773
  case OpKind.I18nAttributes:
17660
17774
  if (op.i18nAttributesConfig === null) {
@@ -17670,7 +17784,7 @@ function reifyCreateOperations(unit, ops) {
17670
17784
  throw new Error(`AssertionError: local refs array should have been extracted into a constant`);
17671
17785
  }
17672
17786
  const childView = unit.job.views.get(op.xref);
17673
- OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.sourceSpan));
17787
+ OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.startSourceSpan));
17674
17788
  break;
17675
17789
  case OpKind.DisableBindings:
17676
17790
  OpList.replace(op, disableBindings2());
@@ -17685,7 +17799,7 @@ function reifyCreateOperations(unit, ops) {
17685
17799
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17686
17800
  const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17687
17801
  if (eventTargetResolver === void 0) {
17688
- throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17802
+ throw new Error(`Unexpected global target '${op.eventTarget}' defined for '${op.name}' event. Supported list of global targets: window,document,body.`);
17689
17803
  }
17690
17804
  OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17691
17805
  break;
@@ -17772,7 +17886,7 @@ function reifyCreateOperations(unit, ops) {
17772
17886
  emptyDecls = emptyView.decls;
17773
17887
  emptyVars = emptyView.vars;
17774
17888
  }
17775
- OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.sourceSpan));
17889
+ OpList.replace(op, repeaterCreate(op.handle.slot, repeaterView.fnName, op.decls, op.vars, op.tag, op.attributes, op.trackByFn, op.usesComponentInstance, emptyViewFnName, emptyDecls, emptyVars, op.emptyTag, op.emptyAttributes, op.wholeSourceSpan));
17776
17890
  break;
17777
17891
  case OpKind.Statement:
17778
17892
  break;
@@ -18279,6 +18393,7 @@ function resolveI18nExpressionPlaceholders(job) {
18279
18393
  var _a2;
18280
18394
  const subTemplateIndicies = /* @__PURE__ */ new Map();
18281
18395
  const i18nContexts = /* @__PURE__ */ new Map();
18396
+ const icuPlaceholders = /* @__PURE__ */ new Map();
18282
18397
  for (const unit of job.units) {
18283
18398
  for (const op of unit.create) {
18284
18399
  switch (op.kind) {
@@ -18288,6 +18403,9 @@ function resolveI18nExpressionPlaceholders(job) {
18288
18403
  case OpKind.I18nContext:
18289
18404
  i18nContexts.set(op.xref, op);
18290
18405
  break;
18406
+ case OpKind.IcuPlaceholder:
18407
+ icuPlaceholders.set(op.xref, op);
18408
+ break;
18291
18409
  }
18292
18410
  }
18293
18411
  }
@@ -18296,66 +18414,32 @@ function resolveI18nExpressionPlaceholders(job) {
18296
18414
  for (const unit of job.units) {
18297
18415
  for (const op of unit.update) {
18298
18416
  if (op.kind === OpKind.I18nExpression) {
18299
- const i18nContext = i18nContexts.get(op.context);
18300
18417
  const index = expressionIndices.get(referenceIndex(op)) || 0;
18301
18418
  const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
18302
- const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18303
- const values = params.get(op.i18nPlaceholder) || [];
18304
- values.push({
18419
+ const value = {
18305
18420
  value: index,
18306
18421
  subTemplateIndex,
18307
18422
  flags: I18nParamValueFlags.ExpressionIndex
18308
- });
18309
- params.set(op.i18nPlaceholder, values);
18423
+ };
18424
+ updatePlaceholder(op, value, i18nContexts, icuPlaceholders);
18310
18425
  expressionIndices.set(referenceIndex(op), index + 1);
18311
18426
  }
18312
18427
  }
18313
18428
  }
18314
18429
  }
18315
-
18316
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_icu_placeholders.mjs
18317
- function resolveI18nIcuPlaceholders(job) {
18318
- for (const unit of job.units) {
18319
- for (const op of unit.create) {
18320
- if (op.kind === OpKind.I18nContext && op.contextKind === I18nContextKind.Icu) {
18321
- for (const node of op.message.nodes) {
18322
- node.visit(new ResolveIcuPlaceholdersVisitor(op.postprocessingParams));
18323
- }
18324
- }
18325
- }
18326
- }
18327
- }
18328
- var ResolveIcuPlaceholdersVisitor = class extends RecurseVisitor {
18329
- constructor(params) {
18330
- super();
18331
- this.params = params;
18332
- }
18333
- visitContainerPlaceholder(placeholder) {
18334
- var _a2, _b2;
18335
- if (placeholder.startName && placeholder.startSourceSpan && !this.params.has(placeholder.startName)) {
18336
- this.params.set(placeholder.startName, [{
18337
- value: (_a2 = placeholder.startSourceSpan) == null ? void 0 : _a2.toString(),
18338
- subTemplateIndex: null,
18339
- flags: I18nParamValueFlags.None
18340
- }]);
18341
- }
18342
- if (placeholder.closeName && placeholder.endSourceSpan && !this.params.has(placeholder.closeName)) {
18343
- this.params.set(placeholder.closeName, [{
18344
- value: (_b2 = placeholder.endSourceSpan) == null ? void 0 : _b2.toString(),
18345
- subTemplateIndex: null,
18346
- flags: I18nParamValueFlags.None
18347
- }]);
18348
- }
18349
- }
18350
- visitTagPlaceholder(placeholder) {
18351
- super.visitTagPlaceholder(placeholder);
18352
- this.visitContainerPlaceholder(placeholder);
18430
+ function updatePlaceholder(op, value, i18nContexts, icuPlaceholders) {
18431
+ if (op.i18nPlaceholder !== null) {
18432
+ const i18nContext = i18nContexts.get(op.context);
18433
+ const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
18434
+ const values = params.get(op.i18nPlaceholder) || [];
18435
+ values.push(value);
18436
+ params.set(op.i18nPlaceholder, values);
18353
18437
  }
18354
- visitBlockPlaceholder(placeholder) {
18355
- super.visitBlockPlaceholder(placeholder);
18356
- this.visitContainerPlaceholder(placeholder);
18438
+ if (op.icuPlaceholder !== null) {
18439
+ const icuPlaceholderOp = icuPlaceholders.get(op.icuPlaceholder);
18440
+ icuPlaceholderOp == null ? void 0 : icuPlaceholderOp.expressionPlaceholders.push(value);
18357
18441
  }
18358
- };
18442
+ }
18359
18443
 
18360
18444
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_names.mjs
18361
18445
  function resolveNames(job) {
@@ -18661,6 +18745,9 @@ function generateTrackFns(job) {
18661
18745
  }
18662
18746
  let usesComponentContext = false;
18663
18747
  op.track = transformExpressionsInExpression(op.track, (expr) => {
18748
+ if (expr instanceof PipeBindingExpr || expr instanceof PipeBindingVariadicExpr) {
18749
+ throw new Error(`Illegal State: Pipes are not allowed in this context`);
18750
+ }
18664
18751
  if (expr instanceof TrackContextExpr) {
18665
18752
  usesComponentContext = true;
18666
18753
  return variable("this");
@@ -18825,7 +18912,10 @@ function varsUsedByOp(op) {
18825
18912
  return op.interpolation.expressions.length;
18826
18913
  case OpKind.I18nExpression:
18827
18914
  case OpKind.Conditional:
18915
+ case OpKind.DeferWhen:
18828
18916
  return 1;
18917
+ case OpKind.RepeaterCreate:
18918
+ return op.emptyView ? 1 : 0;
18829
18919
  default:
18830
18920
  throw new Error(`Unhandled op: ${OpKind[op.kind]}`);
18831
18921
  }
@@ -19118,12 +19208,12 @@ function wrapI18nIcus(job) {
19118
19208
  case OpKind.IcuStart:
19119
19209
  if (currentI18nOp === null) {
19120
19210
  addedI18nId = job.allocateXrefId();
19121
- OpList.insertBefore(createI18nStartOp(addedI18nId, op.message), op);
19211
+ OpList.insertBefore(createI18nStartOp(addedI18nId, op.message, void 0, null), op);
19122
19212
  }
19123
19213
  break;
19124
19214
  case OpKind.IcuEnd:
19125
19215
  if (addedI18nId !== null) {
19126
- OpList.insertAfter(createI18nEndOp(addedI18nId), op);
19216
+ OpList.insertAfter(createI18nEndOp(addedI18nId, null), op);
19127
19217
  addedI18nId = null;
19128
19218
  }
19129
19219
  break;
@@ -19139,6 +19229,7 @@ var phases = [
19139
19229
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
19140
19230
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
19141
19231
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
19232
+ { kind: CompilationJobKind.Both, fn: deduplicateTextBindings },
19142
19233
  { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19143
19234
  { kind: CompilationJobKind.Both, fn: specializeBindings },
19144
19235
  { kind: CompilationJobKind.Both, fn: extractAttributes },
@@ -19177,7 +19268,6 @@ var phases = [
19177
19268
  { kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
19178
19269
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
19179
19270
  { kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
19180
- { kind: CompilationJobKind.Tmpl, fn: resolveI18nIcuPlaceholders },
19181
19271
  { kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
19182
19272
  { kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
19183
19273
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
@@ -19320,7 +19410,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19320
19410
  bindingKind = BindingKind.Animation;
19321
19411
  }
19322
19412
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19323
- ingestHostProperty(job, property2, bindingKind, false, securityContexts);
19413
+ ingestHostProperty(job, property2, bindingKind, securityContexts);
19324
19414
  }
19325
19415
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
19326
19416
  const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
@@ -19331,7 +19421,7 @@ function ingestHostBinding(input, bindingParser, constantPool) {
19331
19421
  }
19332
19422
  return job;
19333
19423
  }
19334
- function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
19424
+ function ingestHostProperty(job, property2, bindingKind, securityContexts) {
19335
19425
  let expression;
19336
19426
  const ast = property2.expression.ast;
19337
19427
  if (ast instanceof Interpolation) {
@@ -19339,7 +19429,7 @@ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securi
19339
19429
  } else {
19340
19430
  expression = convertAst(ast, job, property2.sourceSpan);
19341
19431
  }
19342
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
19432
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, false, false, null, null, property2.sourceSpan));
19343
19433
  }
19344
19434
  function ingestHostAttribute(job, name, value, securityContexts) {
19345
19435
  const attrBinding = createBindingOp(
@@ -19353,14 +19443,13 @@ function ingestHostAttribute(job, name, value, securityContexts) {
19353
19443
  false,
19354
19444
  null,
19355
19445
  null,
19356
- null
19446
+ value.sourceSpan
19357
19447
  );
19358
19448
  job.root.update.push(attrBinding);
19359
19449
  }
19360
19450
  function ingestHostEvent(job, event) {
19361
19451
  const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
19362
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
19363
- eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
19452
+ const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, makeListenerHandlerOps(job.root, event.handler, event.handlerSpan), phase, target, true, event.sourceSpan);
19364
19453
  job.root.create.push(eventBinding);
19365
19454
  }
19366
19455
  function ingestNodes(unit, template2) {
@@ -19372,9 +19461,9 @@ function ingestNodes(unit, template2) {
19372
19461
  } else if (node instanceof Content) {
19373
19462
  ingestContent(unit, node);
19374
19463
  } else if (node instanceof Text) {
19375
- ingestText(unit, node);
19464
+ ingestText(unit, node, null);
19376
19465
  } else if (node instanceof BoundText) {
19377
- ingestBoundText(unit, node);
19466
+ ingestBoundText(unit, node, null);
19378
19467
  } else if (node instanceof IfBlock) {
19379
19468
  ingestIfBlock(unit, node);
19380
19469
  } else if (node instanceof SwitchBlock) {
@@ -19391,29 +19480,30 @@ function ingestNodes(unit, template2) {
19391
19480
  }
19392
19481
  }
19393
19482
  function ingestElement(unit, element2) {
19394
- var _a2;
19483
+ var _a2, _b2;
19395
19484
  if (element2.i18n !== void 0 && !(element2.i18n instanceof Message || element2.i18n instanceof TagPlaceholder)) {
19396
19485
  throw Error(`Unhandled i18n metadata type for element: ${element2.i18n.constructor.name}`);
19397
19486
  }
19398
19487
  const id = unit.job.allocateXrefId();
19399
19488
  const [namespaceKey, elementName] = splitNsName(element2.name);
19400
- const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
19489
+ const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan, element2.sourceSpan);
19401
19490
  unit.create.push(startOp);
19402
19491
  ingestElementBindings(unit, startOp, element2);
19403
19492
  ingestReferences(startOp, element2);
19404
19493
  let i18nBlockId = null;
19405
19494
  if (element2.i18n instanceof Message) {
19406
19495
  i18nBlockId = unit.job.allocateXrefId();
19407
- unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n));
19496
+ unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n, void 0, element2.startSourceSpan));
19408
19497
  }
19409
19498
  ingestNodes(unit, element2.children);
19410
19499
  const endOp = createElementEndOp(id, (_a2 = element2.endSourceSpan) != null ? _a2 : element2.startSourceSpan);
19411
19500
  unit.create.push(endOp);
19412
19501
  if (i18nBlockId !== null) {
19413
- OpList.insertBefore(createI18nEndOp(i18nBlockId), endOp);
19502
+ OpList.insertBefore(createI18nEndOp(i18nBlockId, (_b2 = element2.endSourceSpan) != null ? _b2 : element2.startSourceSpan), endOp);
19414
19503
  }
19415
19504
  }
19416
19505
  function ingestTemplate(unit, tmpl) {
19506
+ var _a2;
19417
19507
  if (tmpl.i18n !== void 0 && !(tmpl.i18n instanceof Message || tmpl.i18n instanceof TagPlaceholder)) {
19418
19508
  throw Error(`Unhandled i18n metadata type for template: ${tmpl.i18n.constructor.name}`);
19419
19509
  }
@@ -19427,7 +19517,7 @@ function ingestTemplate(unit, tmpl) {
19427
19517
  const namespace = namespaceForKey(namespacePrefix);
19428
19518
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
19429
19519
  const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19430
- const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19520
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan, tmpl.sourceSpan);
19431
19521
  unit.create.push(templateOp);
19432
19522
  ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19433
19523
  ingestReferences(templateOp, tmpl);
@@ -19437,26 +19527,25 @@ function ingestTemplate(unit, tmpl) {
19437
19527
  }
19438
19528
  if (templateKind === TemplateKind.NgTemplate && tmpl.i18n instanceof Message) {
19439
19529
  const id = unit.job.allocateXrefId();
19440
- OpList.insertAfter(createI18nStartOp(id, tmpl.i18n), childView.create.head);
19441
- OpList.insertBefore(createI18nEndOp(id), childView.create.tail);
19530
+ OpList.insertAfter(createI18nStartOp(id, tmpl.i18n, void 0, tmpl.startSourceSpan), childView.create.head);
19531
+ OpList.insertBefore(createI18nEndOp(id, (_a2 = tmpl.endSourceSpan) != null ? _a2 : tmpl.startSourceSpan), childView.create.tail);
19442
19532
  }
19443
19533
  }
19444
19534
  function ingestContent(unit, content) {
19445
19535
  if (content.i18n !== void 0 && !(content.i18n instanceof TagPlaceholder)) {
19446
19536
  throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
19447
19537
  }
19448
- const attrs = content.attributes.flatMap((a) => [a.name, a.value]);
19449
- const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, attrs, content.sourceSpan);
19538
+ const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, content.sourceSpan);
19450
19539
  for (const attr of content.attributes) {
19451
19540
  const securityContext = domSchema.securityContext(content.name, attr.name, true);
19452
19541
  unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19453
19542
  }
19454
19543
  unit.create.push(op);
19455
19544
  }
19456
- function ingestText(unit, text2) {
19457
- unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
19545
+ function ingestText(unit, text2, icuPlaceholder) {
19546
+ unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, icuPlaceholder, text2.sourceSpan));
19458
19547
  }
19459
- function ingestBoundText(unit, text2, i18nPlaceholders) {
19548
+ function ingestBoundText(unit, text2, icuPlaceholder) {
19460
19549
  var _a2;
19461
19550
  let value = text2.value;
19462
19551
  if (value instanceof ASTWithSource) {
@@ -19468,14 +19557,12 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
19468
19557
  if (text2.i18n !== void 0 && !(text2.i18n instanceof Container)) {
19469
19558
  throw Error(`Unhandled i18n metadata type for text interpolation: ${(_a2 = text2.i18n) == null ? void 0 : _a2.constructor.name}`);
19470
19559
  }
19471
- if (i18nPlaceholders === void 0) {
19472
- i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19473
- }
19560
+ const i18nPlaceholders = text2.i18n instanceof Container ? text2.i18n.children.filter((node) => node instanceof Placeholder).map((placeholder) => placeholder.name) : [];
19474
19561
  if (i18nPlaceholders.length > 0 && i18nPlaceholders.length !== value.expressions.length) {
19475
19562
  throw Error(`Unexpected number of i18n placeholders (${value.expressions.length}) for BoundText with ${value.expressions.length} expressions`);
19476
19563
  }
19477
19564
  const textXref = unit.job.allocateXrefId();
19478
- unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
19565
+ unit.create.push(createTextOp(textXref, "", icuPlaceholder, text2.sourceSpan));
19479
19566
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
19480
19567
  unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
19481
19568
  }
@@ -19501,7 +19588,7 @@ function ingestIfBlock(unit, ifBlock) {
19501
19588
  }
19502
19589
  ifCaseI18nMeta = ifCase.i18n;
19503
19590
  }
19504
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19591
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.startSourceSpan, ifCase.sourceSpan);
19505
19592
  unit.create.push(templateOp);
19506
19593
  if (firstXref === null) {
19507
19594
  firstXref = cView.xref;
@@ -19529,7 +19616,7 @@ function ingestSwitchBlock(unit, switchBlock) {
19529
19616
  }
19530
19617
  switchCaseI18nMeta = switchCase.i18n;
19531
19618
  }
19532
- const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19619
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.startSourceSpan, switchCase.sourceSpan);
19533
19620
  unit.create.push(templateOp);
19534
19621
  if (firstXref === null) {
19535
19622
  firstXref = cView.xref;
@@ -19552,7 +19639,7 @@ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19552
19639
  }
19553
19640
  const secondaryView = unit.job.allocateView(unit.xref);
19554
19641
  ingestNodes(secondaryView, children);
19555
- const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19642
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan, sourceSpan);
19556
19643
  unit.create.push(templateOp);
19557
19644
  return templateOp;
19558
19645
  }
@@ -19626,6 +19713,9 @@ function ingestDeferBlock(unit, deferBlock) {
19626
19713
  deferOnOps.push(deferOnOp);
19627
19714
  }
19628
19715
  if (triggers.when !== void 0) {
19716
+ if (triggers.when.value instanceof Interpolation) {
19717
+ throw new Error(`Unexpected interpolation in defer block when trigger`);
19718
+ }
19629
19719
  const deferOnOp = createDeferWhenOp(deferXref, convertAst(triggers.when.value, unit.job, triggers.when.sourceSpan), prefetch, triggers.when.sourceSpan);
19630
19720
  deferWhenOps.push(deferOnOp);
19631
19721
  }
@@ -19645,9 +19735,9 @@ function ingestIcu(unit, icu) {
19645
19735
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19646
19736
  for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19647
19737
  if (text2 instanceof BoundText) {
19648
- ingestBoundText(unit, text2, [placeholder]);
19738
+ ingestBoundText(unit, text2, placeholder);
19649
19739
  } else {
19650
- ingestText(unit, text2);
19740
+ ingestText(unit, text2, placeholder);
19651
19741
  }
19652
19742
  }
19653
19743
  unit.create.push(createIcuEndOp(xref));
@@ -19677,9 +19767,11 @@ function ingestForBlock(unit, forBlock) {
19677
19767
  const track = convertAst(forBlock.trackBy, unit.job, sourceSpan);
19678
19768
  ingestNodes(repeaterView, forBlock.children);
19679
19769
  let emptyView = null;
19770
+ let emptyTagName = null;
19680
19771
  if (forBlock.empty !== null) {
19681
19772
  emptyView = unit.job.allocateView(unit.xref);
19682
19773
  ingestNodes(emptyView, forBlock.empty.children);
19774
+ emptyTagName = ingestControlFlowInsertionPoint(unit, emptyView.xref, forBlock.empty);
19683
19775
  }
19684
19776
  const varNames = {
19685
19777
  $index: forBlock.contextVariables.$index.name,
@@ -19699,7 +19791,7 @@ function ingestForBlock(unit, forBlock) {
19699
19791
  const i18nPlaceholder = forBlock.i18n;
19700
19792
  const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19701
19793
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19702
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19794
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, emptyTagName, i18nPlaceholder, emptyI18nPlaceholder, forBlock.startSourceSpan, forBlock.sourceSpan);
19703
19795
  unit.create.push(repeaterCreate2);
19704
19796
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19705
19797
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19709,7 +19801,10 @@ function convertAst(ast, job, baseSourceSpan) {
19709
19801
  if (ast instanceof ASTWithSource) {
19710
19802
  return convertAst(ast.ast, job, baseSourceSpan);
19711
19803
  } else if (ast instanceof PropertyRead) {
19712
- if (ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver)) {
19804
+ const isThisReceiver = ast.receiver instanceof ThisReceiver;
19805
+ const isImplicitReceiver = ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver);
19806
+ const isSpecialNode = ast.name === "$any" || ast.name === "$event";
19807
+ if (isImplicitReceiver || isThisReceiver && !isSpecialNode) {
19713
19808
  return new LexicalReadExpr(ast.name);
19714
19809
  } else {
19715
19810
  return new ReadPropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, null, convertSourceSpan(ast.span, baseSourceSpan));
@@ -19787,13 +19882,13 @@ function convertAst(ast, job, baseSourceSpan) {
19787
19882
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19788
19883
  }
19789
19884
  }
19790
- function convertAstWithInterpolation(job, value, i18nMeta) {
19885
+ function convertAstWithInterpolation(job, value, i18nMeta, sourceSpan) {
19791
19886
  var _a2, _b2;
19792
19887
  let expression;
19793
19888
  if (value instanceof Interpolation) {
19794
- expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19889
+ expression = new Interpolation2(value.strings, value.expressions.map((e) => convertAst(e, job, sourceSpan != null ? sourceSpan : null)), Object.keys((_b2 = (_a2 = asMessage(i18nMeta)) == null ? void 0 : _a2.placeholders) != null ? _b2 : {}));
19795
19890
  } else if (value instanceof AST) {
19796
- expression = convertAst(value, job, null);
19891
+ expression = convertAst(value, job, sourceSpan != null ? sourceSpan : null);
19797
19892
  } else {
19798
19893
  expression = literal(value);
19799
19894
  }
@@ -22888,7 +22983,12 @@ var TemplateDefinitionBuilder = class {
22888
22983
  });
22889
22984
  const { expression: trackByExpression, usesComponentInstance: trackByUsesComponentInstance } = this.createTrackByFunction(block);
22890
22985
  let emptyData = null;
22986
+ let emptyTagName = null;
22987
+ let emptyAttrsExprs;
22891
22988
  if (block.empty !== null) {
22989
+ const emptyInferred = this.inferProjectionDataFromInsertionPoint(block.empty);
22990
+ emptyTagName = emptyInferred.tagName;
22991
+ emptyAttrsExprs = emptyInferred.attrsExprs;
22892
22992
  emptyData = this.prepareEmbeddedTemplateFn(block.empty.children, "_ForEmpty", void 0, block.empty.i18n);
22893
22993
  this.allocateBindingSlots(null);
22894
22994
  }
@@ -22904,11 +23004,11 @@ var TemplateDefinitionBuilder = class {
22904
23004
  trackByExpression
22905
23005
  ];
22906
23006
  if (emptyData !== null) {
22907
- params.push(literal(trackByUsesComponentInstance), variable(emptyData.name), literal(emptyData.getConstCount()), literal(emptyData.getVarCount()));
23007
+ params.push(literal(trackByUsesComponentInstance), variable(emptyData.name), literal(emptyData.getConstCount()), literal(emptyData.getVarCount()), literal(emptyTagName), this.addAttrsToConsts(emptyAttrsExprs || null));
22908
23008
  } else if (trackByUsesComponentInstance) {
22909
23009
  params.push(literal(trackByUsesComponentInstance));
22910
23010
  }
22911
- return params;
23011
+ return trimTrailingNulls(params);
22912
23012
  });
22913
23013
  const value = block.expression.visit(this._valueConverter);
22914
23014
  this.updateInstructionWithAdvance(blockIndex, block.sourceSpan, Identifiers.repeater, () => [this.convertPropertyBinding(value)]);
@@ -23471,12 +23571,15 @@ var BindingScope = class {
23471
23571
  }
23472
23572
  };
23473
23573
  var TrackByBindingScope = class extends BindingScope {
23474
- constructor(parentScope, globalAliases) {
23574
+ constructor(parentScope, globalOverrides) {
23475
23575
  super(parentScope.bindingLevel + 1, parentScope);
23476
- this.globalAliases = globalAliases;
23576
+ this.globalOverrides = globalOverrides;
23477
23577
  this.componentAccessCount = 0;
23478
23578
  }
23479
23579
  get(name) {
23580
+ if (this.globalOverrides.hasOwnProperty(name)) {
23581
+ return variable(this.globalOverrides[name]);
23582
+ }
23480
23583
  let current = this.parent;
23481
23584
  while (current) {
23482
23585
  if (current.hasLocal(name)) {
@@ -23484,9 +23587,6 @@ var TrackByBindingScope = class extends BindingScope {
23484
23587
  }
23485
23588
  current = current.parent;
23486
23589
  }
23487
- if (this.globalAliases[name]) {
23488
- return variable(this.globalAliases[name]);
23489
- }
23490
23590
  this.componentAccessCount++;
23491
23591
  return variable("this").prop(name);
23492
23592
  }
@@ -25505,7 +25605,7 @@ function publishFacade(global) {
25505
25605
  }
25506
25606
 
25507
25607
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
25508
- var VERSION2 = new Version("17.1.0-next.4");
25608
+ var VERSION2 = new Version("17.1.0-next.5");
25509
25609
 
25510
25610
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
25511
25611
  var _VisitorMode;