@angular/core 17.0.5 → 17.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/esm2022/primitives/signals/src/signal.mjs +2 -9
  2. package/esm2022/src/application/application_config.mjs +21 -0
  3. package/esm2022/src/application/application_init.mjs +188 -0
  4. package/esm2022/src/application/application_module.mjs +29 -0
  5. package/esm2022/src/application/application_ref.mjs +509 -0
  6. package/esm2022/src/application/application_tokens.mjs +121 -0
  7. package/esm2022/src/application/create_application.mjs +102 -0
  8. package/esm2022/src/change_detection/scheduling.mjs +103 -0
  9. package/esm2022/src/core.mjs +10 -7
  10. package/esm2022/src/core_private_export.mjs +5 -3
  11. package/esm2022/src/core_reactivity_export_internal.mjs +2 -2
  12. package/esm2022/src/core_render3_private_export.mjs +2 -2
  13. package/esm2022/src/error_handler.mjs +15 -1
  14. package/esm2022/src/hydration/annotate.mjs +30 -20
  15. package/esm2022/src/hydration/api.mjs +2 -2
  16. package/esm2022/src/hydration/cleanup.mjs +1 -1
  17. package/esm2022/src/hydration/interfaces.mjs +1 -1
  18. package/esm2022/src/hydration/node_lookup_utils.mjs +23 -2
  19. package/esm2022/src/image_performance_warning.mjs +2 -2
  20. package/esm2022/src/linker/query_list.mjs +8 -6
  21. package/esm2022/src/metadata/do_bootstrap.mjs +1 -1
  22. package/esm2022/src/platform/platform.mjs +135 -0
  23. package/esm2022/src/platform/platform_core_providers.mjs +15 -0
  24. package/esm2022/src/platform/platform_ref.mjs +179 -0
  25. package/esm2022/src/render3/instructions/change_detection.mjs +2 -4
  26. package/esm2022/src/render3/list_reconciliation.mjs +58 -24
  27. package/esm2022/src/render3/node_manipulation.mjs +2 -2
  28. package/esm2022/src/render3/util/change_detection_utils.mjs +3 -1
  29. package/esm2022/src/render3/util/misc_utils.mjs +2 -2
  30. package/esm2022/src/render3/view_manipulation.mjs +13 -5
  31. package/esm2022/src/render3/view_ref.mjs +7 -1
  32. package/esm2022/src/transfer_state.mjs +2 -2
  33. package/esm2022/src/util/performance.mjs +2 -2
  34. package/esm2022/src/version.mjs +1 -1
  35. package/esm2022/src/zone/ng_zone.mjs +10 -1
  36. package/esm2022/testing/src/component_fixture.mjs +20 -36
  37. package/esm2022/testing/src/logger.mjs +3 -3
  38. package/esm2022/testing/src/test_bed.mjs +5 -6
  39. package/fesm2022/core.mjs +1263 -1191
  40. package/fesm2022/core.mjs.map +1 -1
  41. package/fesm2022/primitives/signals.mjs +2 -9
  42. package/fesm2022/primitives/signals.mjs.map +1 -1
  43. package/fesm2022/rxjs-interop.mjs +1 -1
  44. package/fesm2022/testing.mjs +46 -64
  45. package/fesm2022/testing.mjs.map +1 -1
  46. package/index.d.ts +18 -14
  47. package/package.json +1 -1
  48. package/primitives/signals/index.d.ts +1 -1
  49. package/rxjs-interop/index.d.ts +1 -1
  50. package/schematics/migrations/block-template-entities/bundle.js +958 -457
  51. package/schematics/migrations/block-template-entities/bundle.js.map +4 -4
  52. package/schematics/ng-generate/control-flow-migration/bundle.js +1221 -525
  53. package/schematics/ng-generate/control-flow-migration/bundle.js.map +4 -4
  54. package/schematics/ng-generate/standalone-migration/bundle.js +1143 -509
  55. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  56. package/testing/index.d.ts +6 -10
  57. package/esm2022/src/application_config.mjs +0 -21
  58. package/esm2022/src/application_init.mjs +0 -188
  59. package/esm2022/src/application_module.mjs +0 -29
  60. package/esm2022/src/application_ref.mjs +0 -997
  61. package/esm2022/src/application_tokens.mjs +0 -121
  62. package/esm2022/src/platform_core_providers.mjs +0 -15
@@ -3499,6 +3499,39 @@ function getInjectFn(target) {
3499
3499
  }
3500
3500
  }
3501
3501
 
3502
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/ml_parser/tags.mjs
3503
+ var TagContentType;
3504
+ (function(TagContentType2) {
3505
+ TagContentType2[TagContentType2["RAW_TEXT"] = 0] = "RAW_TEXT";
3506
+ TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
3507
+ TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
3508
+ })(TagContentType || (TagContentType = {}));
3509
+ function splitNsName(elementName) {
3510
+ if (elementName[0] != ":") {
3511
+ return [null, elementName];
3512
+ }
3513
+ const colonIndex = elementName.indexOf(":", 1);
3514
+ if (colonIndex === -1) {
3515
+ throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
3516
+ }
3517
+ return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
3518
+ }
3519
+ function isNgContainer(tagName) {
3520
+ return splitNsName(tagName)[1] === "ng-container";
3521
+ }
3522
+ function isNgContent(tagName) {
3523
+ return splitNsName(tagName)[1] === "ng-content";
3524
+ }
3525
+ function isNgTemplate(tagName) {
3526
+ return splitNsName(tagName)[1] === "ng-template";
3527
+ }
3528
+ function getNsPrefix(fullName) {
3529
+ return fullName === null ? null : splitNsName(fullName)[0];
3530
+ }
3531
+ function mergeNsAndName(prefix, localName) {
3532
+ return prefix ? `:${prefix}:${localName}` : localName;
3533
+ }
3534
+
3502
3535
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/render3/r3_ast.mjs
3503
3536
  var Comment = class {
3504
3537
  constructor(value, sourceSpan) {
@@ -4342,6 +4375,23 @@ var DefinitionMap = class {
4342
4375
  return literalMap(this.values);
4343
4376
  }
4344
4377
  };
4378
+ function createCssSelectorFromNode(node) {
4379
+ const elementName = node instanceof Element ? node.name : "ng-template";
4380
+ const attributes = getAttrsForDirectiveMatching(node);
4381
+ const cssSelector = new CssSelector();
4382
+ const elementNameNoNs = splitNsName(elementName)[1];
4383
+ cssSelector.setElement(elementNameNoNs);
4384
+ Object.getOwnPropertyNames(attributes).forEach((name) => {
4385
+ const nameNoNs = splitNsName(name)[1];
4386
+ const value = attributes[name];
4387
+ cssSelector.addAttribute(nameNoNs, value);
4388
+ if (name.toLowerCase() === "class") {
4389
+ const classes = value.trim().split(/\s+/);
4390
+ classes.forEach((className) => cssSelector.addClassName(className));
4391
+ }
4392
+ });
4393
+ return cssSelector;
4394
+ }
4345
4395
  function getAttrsForDirectiveMatching(elOrTpl) {
4346
4396
  const attributesMap = {};
4347
4397
  if (elOrTpl instanceof Template && elOrTpl.tagName !== "ng-template") {
@@ -7059,6 +7109,7 @@ var OpKind;
7059
7109
  OpKind2[OpKind2["IcuStart"] = 41] = "IcuStart";
7060
7110
  OpKind2[OpKind2["IcuEnd"] = 42] = "IcuEnd";
7061
7111
  OpKind2[OpKind2["I18nContext"] = 43] = "I18nContext";
7112
+ OpKind2[OpKind2["I18nAttributes"] = 44] = "I18nAttributes";
7062
7113
  })(OpKind || (OpKind = {}));
7063
7114
  var ExpressionKind;
7064
7115
  (function(ExpressionKind2) {
@@ -7083,10 +7134,11 @@ var ExpressionKind;
7083
7134
  ExpressionKind2[ExpressionKind2["AssignTemporaryExpr"] = 18] = "AssignTemporaryExpr";
7084
7135
  ExpressionKind2[ExpressionKind2["ReadTemporaryExpr"] = 19] = "ReadTemporaryExpr";
7085
7136
  ExpressionKind2[ExpressionKind2["SanitizerExpr"] = 20] = "SanitizerExpr";
7086
- ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 21] = "SlotLiteralExpr";
7087
- ExpressionKind2[ExpressionKind2["ConditionalCase"] = 22] = "ConditionalCase";
7088
- ExpressionKind2[ExpressionKind2["DerivedRepeaterVar"] = 23] = "DerivedRepeaterVar";
7089
- ExpressionKind2[ExpressionKind2["ConstCollected"] = 24] = "ConstCollected";
7137
+ ExpressionKind2[ExpressionKind2["TrustedValueFnExpr"] = 21] = "TrustedValueFnExpr";
7138
+ ExpressionKind2[ExpressionKind2["SlotLiteralExpr"] = 22] = "SlotLiteralExpr";
7139
+ ExpressionKind2[ExpressionKind2["ConditionalCase"] = 23] = "ConditionalCase";
7140
+ ExpressionKind2[ExpressionKind2["DerivedRepeaterVar"] = 24] = "DerivedRepeaterVar";
7141
+ ExpressionKind2[ExpressionKind2["ConstCollected"] = 25] = "ConstCollected";
7090
7142
  })(ExpressionKind || (ExpressionKind = {}));
7091
7143
  var VariableFlags;
7092
7144
  (function(VariableFlags2) {
@@ -7105,15 +7157,6 @@ var CompatibilityMode;
7105
7157
  CompatibilityMode2[CompatibilityMode2["Normal"] = 0] = "Normal";
7106
7158
  CompatibilityMode2[CompatibilityMode2["TemplateDefinitionBuilder"] = 1] = "TemplateDefinitionBuilder";
7107
7159
  })(CompatibilityMode || (CompatibilityMode = {}));
7108
- var SanitizerFn;
7109
- (function(SanitizerFn2) {
7110
- SanitizerFn2[SanitizerFn2["Html"] = 0] = "Html";
7111
- SanitizerFn2[SanitizerFn2["Script"] = 1] = "Script";
7112
- SanitizerFn2[SanitizerFn2["Style"] = 2] = "Style";
7113
- SanitizerFn2[SanitizerFn2["Url"] = 3] = "Url";
7114
- SanitizerFn2[SanitizerFn2["ResourceUrl"] = 4] = "ResourceUrl";
7115
- SanitizerFn2[SanitizerFn2["IframeAttribute"] = 5] = "IframeAttribute";
7116
- })(SanitizerFn || (SanitizerFn = {}));
7117
7160
  var DeferSecondaryKind;
7118
7161
  (function(DeferSecondaryKind2) {
7119
7162
  DeferSecondaryKind2[DeferSecondaryKind2["Loading"] = 0] = "Loading";
@@ -7135,6 +7178,11 @@ var I18nParamResolutionTime;
7135
7178
  I18nParamResolutionTime2[I18nParamResolutionTime2["Creation"] = 0] = "Creation";
7136
7179
  I18nParamResolutionTime2[I18nParamResolutionTime2["Postproccessing"] = 1] = "Postproccessing";
7137
7180
  })(I18nParamResolutionTime || (I18nParamResolutionTime = {}));
7181
+ var I18nExpressionFor;
7182
+ (function(I18nExpressionFor2) {
7183
+ I18nExpressionFor2[I18nExpressionFor2["I18nText"] = 0] = "I18nText";
7184
+ I18nExpressionFor2[I18nExpressionFor2["I18nAttribute"] = 1] = "I18nAttribute";
7185
+ })(I18nExpressionFor || (I18nExpressionFor = {}));
7138
7186
  var I18nParamValueFlags;
7139
7187
  (function(I18nParamValueFlags2) {
7140
7188
  I18nParamValueFlags2[I18nParamValueFlags2["None"] = 0] = "None";
@@ -7170,7 +7218,14 @@ var I18nContextKind;
7170
7218
  (function(I18nContextKind2) {
7171
7219
  I18nContextKind2[I18nContextKind2["RootI18n"] = 0] = "RootI18n";
7172
7220
  I18nContextKind2[I18nContextKind2["Icu"] = 1] = "Icu";
7221
+ I18nContextKind2[I18nContextKind2["Attr"] = 2] = "Attr";
7173
7222
  })(I18nContextKind || (I18nContextKind = {}));
7223
+ var TemplateKind;
7224
+ (function(TemplateKind2) {
7225
+ TemplateKind2[TemplateKind2["NgTemplate"] = 0] = "NgTemplate";
7226
+ TemplateKind2[TemplateKind2["Structural"] = 1] = "Structural";
7227
+ TemplateKind2[TemplateKind2["Block"] = 2] = "Block";
7228
+ })(TemplateKind || (TemplateKind = {}));
7174
7229
 
7175
7230
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/traits.mjs
7176
7231
  var ConsumesSlot = Symbol("ConsumesSlot");
@@ -7227,22 +7282,25 @@ var NEW_OP = {
7227
7282
  };
7228
7283
 
7229
7284
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/ops/update.mjs
7230
- function createInterpolateTextOp(xref, interpolation, i18nPlaceholders, sourceSpan) {
7285
+ function createInterpolateTextOp(xref, interpolation, sourceSpan) {
7231
7286
  return __spreadValues(__spreadValues(__spreadValues({
7232
7287
  kind: OpKind.InterpolateText,
7233
7288
  target: xref,
7234
7289
  interpolation,
7235
- i18nPlaceholders,
7236
7290
  sourceSpan
7237
7291
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7238
7292
  }
7239
7293
  var Interpolation2 = class {
7240
- constructor(strings, expressions) {
7294
+ constructor(strings, expressions, i18nPlaceholders) {
7241
7295
  this.strings = strings;
7242
7296
  this.expressions = expressions;
7297
+ this.i18nPlaceholders = i18nPlaceholders;
7298
+ if (i18nPlaceholders.length !== 0 && i18nPlaceholders.length !== expressions.length) {
7299
+ throw new Error(`Expected ${expressions.length} placeholders to match interpolation expression count, but got ${i18nPlaceholders.length}`);
7300
+ }
7243
7301
  }
7244
7302
  };
7245
- function createBindingOp(target, kind, name, expression, unit, securityContext, isTextAttribute, isTemplate, sourceSpan) {
7303
+ function createBindingOp(target, kind, name, expression, unit, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7246
7304
  return __spreadValues({
7247
7305
  kind: OpKind.Binding,
7248
7306
  bindingKind: kind,
@@ -7252,11 +7310,14 @@ function createBindingOp(target, kind, name, expression, unit, securityContext,
7252
7310
  unit,
7253
7311
  securityContext,
7254
7312
  isTextAttribute,
7255
- isTemplate,
7313
+ isStructuralTemplateAttribute,
7314
+ templateKind,
7315
+ i18nContext: null,
7316
+ i18nMessage,
7256
7317
  sourceSpan
7257
7318
  }, NEW_OP);
7258
7319
  }
7259
- function createPropertyOp(target, name, expression, isAnimationTrigger, securityContext, isTemplate, sourceSpan) {
7320
+ function createPropertyOp(target, name, expression, isAnimationTrigger, securityContext, isStructuralTemplateAttribute, templateKind, i18nContext, i18nMessage, sourceSpan) {
7260
7321
  return __spreadValues(__spreadValues(__spreadValues({
7261
7322
  kind: OpKind.Property,
7262
7323
  target,
@@ -7265,7 +7326,10 @@ function createPropertyOp(target, name, expression, isAnimationTrigger, security
7265
7326
  isAnimationTrigger,
7266
7327
  securityContext,
7267
7328
  sanitizer: null,
7268
- isTemplate,
7329
+ isStructuralTemplateAttribute,
7330
+ templateKind,
7331
+ i18nContext,
7332
+ i18nMessage,
7269
7333
  sourceSpan
7270
7334
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7271
7335
  }
@@ -7304,7 +7368,7 @@ function createClassMapOp(xref, expression, sourceSpan) {
7304
7368
  sourceSpan
7305
7369
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7306
7370
  }
7307
- function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isTemplate, sourceSpan) {
7371
+ function createAttributeOp(target, name, expression, securityContext, isTextAttribute, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
7308
7372
  return __spreadValues(__spreadValues(__spreadValues({
7309
7373
  kind: OpKind.Attribute,
7310
7374
  target,
@@ -7313,7 +7377,10 @@ function createAttributeOp(target, name, expression, securityContext, isTextAttr
7313
7377
  securityContext,
7314
7378
  sanitizer: null,
7315
7379
  isTextAttribute,
7316
- isTemplate,
7380
+ isStructuralTemplateAttribute,
7381
+ templateKind,
7382
+ i18nContext: null,
7383
+ i18nMessage,
7317
7384
  sourceSpan
7318
7385
  }, TRAIT_DEPENDS_ON_SLOT_CONTEXT), TRAIT_CONSUMES_VARS), NEW_OP);
7319
7386
  }
@@ -7354,22 +7421,25 @@ function createDeferWhenOp(target, expr, prefetch, sourceSpan) {
7354
7421
  sourceSpan
7355
7422
  }, NEW_OP), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7356
7423
  }
7357
- function createI18nExpressionOp(context, target, handle, expression, i18nPlaceholder, resolutionTime, sourceSpan) {
7424
+ function createI18nExpressionOp(context, target, i18nOwner, handle, expression, i18nPlaceholder, resolutionTime, usage, name, sourceSpan) {
7358
7425
  return __spreadValues(__spreadValues(__spreadValues({
7359
7426
  kind: OpKind.I18nExpression,
7360
7427
  context,
7361
7428
  target,
7429
+ i18nOwner,
7362
7430
  handle,
7363
7431
  expression,
7364
7432
  i18nPlaceholder,
7365
7433
  resolutionTime,
7434
+ usage,
7435
+ name,
7366
7436
  sourceSpan
7367
7437
  }, NEW_OP), TRAIT_CONSUMES_VARS), TRAIT_DEPENDS_ON_SLOT_CONTEXT);
7368
7438
  }
7369
- function createI18nApplyOp(target, handle, sourceSpan) {
7439
+ function createI18nApplyOp(owner, handle, sourceSpan) {
7370
7440
  return __spreadValues({
7371
7441
  kind: OpKind.I18nApply,
7372
- target,
7442
+ owner,
7373
7443
  handle,
7374
7444
  sourceSpan
7375
7445
  }, NEW_OP);
@@ -7906,26 +7976,6 @@ var ReadTemporaryExpr = class extends ExpressionBase {
7906
7976
  return r;
7907
7977
  }
7908
7978
  };
7909
- var SanitizerExpr = class extends ExpressionBase {
7910
- constructor(fn2) {
7911
- super();
7912
- this.fn = fn2;
7913
- this.kind = ExpressionKind.SanitizerExpr;
7914
- }
7915
- visitExpression(visitor, context) {
7916
- }
7917
- isEquivalent(e) {
7918
- return e instanceof SanitizerExpr && e.fn === this.fn;
7919
- }
7920
- isConstant() {
7921
- return true;
7922
- }
7923
- clone() {
7924
- return new SanitizerExpr(this.fn);
7925
- }
7926
- transformInternalExpressions() {
7927
- }
7928
- };
7929
7979
  var SlotLiteralExpr = class extends ExpressionBase {
7930
7980
  constructor(slot) {
7931
7981
  super();
@@ -8044,7 +8094,6 @@ function transformExpressionsInOp(op, transform2, flags) {
8044
8094
  case OpKind.ClassProp:
8045
8095
  case OpKind.ClassMap:
8046
8096
  case OpKind.Binding:
8047
- case OpKind.HostProperty:
8048
8097
  if (op.expression instanceof Interpolation2) {
8049
8098
  transformExpressionsInInterpolation(op.expression, transform2, flags);
8050
8099
  } else {
@@ -8052,6 +8101,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8052
8101
  }
8053
8102
  break;
8054
8103
  case OpKind.Property:
8104
+ case OpKind.HostProperty:
8055
8105
  case OpKind.Attribute:
8056
8106
  if (op.expression instanceof Interpolation2) {
8057
8107
  transformExpressionsInInterpolation(op.expression, transform2, flags);
@@ -8093,6 +8143,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8093
8143
  break;
8094
8144
  case OpKind.ExtractedAttribute:
8095
8145
  op.expression = op.expression && transformExpressionsInExpression(op.expression, transform2, flags);
8146
+ op.trustedValueFn = op.trustedValueFn && transformExpressionsInExpression(op.trustedValueFn, transform2, flags);
8096
8147
  break;
8097
8148
  case OpKind.RepeaterCreate:
8098
8149
  op.track = transformExpressionsInExpression(op.track, transform2, flags);
@@ -8145,6 +8196,7 @@ function transformExpressionsInOp(op, transform2, flags) {
8145
8196
  case OpKind.ProjectionDef:
8146
8197
  case OpKind.Template:
8147
8198
  case OpKind.Text:
8199
+ case OpKind.I18nAttributes:
8148
8200
  break;
8149
8201
  default:
8150
8202
  throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);
@@ -8156,6 +8208,8 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8156
8208
  } else if (expr instanceof BinaryOperatorExpr) {
8157
8209
  expr.lhs = transformExpressionsInExpression(expr.lhs, transform2, flags);
8158
8210
  expr.rhs = transformExpressionsInExpression(expr.rhs, transform2, flags);
8211
+ } else if (expr instanceof UnaryOperatorExpr) {
8212
+ expr.expr = transformExpressionsInExpression(expr.expr, transform2, flags);
8159
8213
  } else if (expr instanceof ReadPropExpr) {
8160
8214
  expr.receiver = transformExpressionsInExpression(expr.receiver, transform2, flags);
8161
8215
  } else if (expr instanceof ReadKeyExpr) {
@@ -8195,6 +8249,12 @@ function transformExpressionsInExpression(expr, transform2, flags) {
8195
8249
  for (let i = 0; i < expr.expressions.length; i++) {
8196
8250
  expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform2, flags);
8197
8251
  }
8252
+ } else if (expr instanceof NotExpr) {
8253
+ expr.condition = transformExpressionsInExpression(expr.condition, transform2, flags);
8254
+ } else if (expr instanceof TaggedTemplateExpr) {
8255
+ expr.tag = transformExpressionsInExpression(expr.tag, transform2, flags);
8256
+ expr.template.expressions = expr.template.expressions.map((e) => transformExpressionsInExpression(e, transform2, flags));
8257
+ } else if (expr instanceof WrappedNodeExpr) {
8198
8258
  } else if (expr instanceof ReadVarExpr || expr instanceof ExternalExpr || expr instanceof LiteralExpr) {
8199
8259
  } else {
8200
8260
  throw new Error(`Unhandled expression kind: ${expr.constructor.name}`);
@@ -8450,10 +8510,11 @@ function createElementStartOp(tag, xref, namespace, i18nPlaceholder, sourceSpan)
8450
8510
  sourceSpan
8451
8511
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8452
8512
  }
8453
- function createTemplateOp(xref, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8513
+ function createTemplateOp(xref, templateKind, tag, functionNameSuffix, namespace, i18nPlaceholder, sourceSpan) {
8454
8514
  return __spreadValues(__spreadValues({
8455
8515
  kind: OpKind.Template,
8456
8516
  xref,
8517
+ templateKind,
8457
8518
  attributes: null,
8458
8519
  tag,
8459
8520
  handle: new SlotHandle(),
@@ -8467,7 +8528,7 @@ function createTemplateOp(xref, tag, functionNameSuffix, namespace, i18nPlacehol
8467
8528
  sourceSpan
8468
8529
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8469
8530
  }
8470
- function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, sourceSpan) {
8531
+ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, sourceSpan) {
8471
8532
  return __spreadProps(__spreadValues(__spreadValues({
8472
8533
  kind: OpKind.RepeaterCreate,
8473
8534
  attributes: null,
@@ -8485,6 +8546,8 @@ function createRepeaterCreateOp(primaryView, emptyView, tag, track, varNames, so
8485
8546
  vars: null,
8486
8547
  varNames,
8487
8548
  usesComponentInstance: false,
8549
+ i18nPlaceholder,
8550
+ emptyI18nPlaceholder,
8488
8551
  sourceSpan
8489
8552
  }, TRAIT_CONSUMES_SLOT), NEW_OP), {
8490
8553
  numSlotsUsed: emptyView === null ? 2 : 3
@@ -8518,7 +8581,9 @@ function createTextOp(xref, initialValue, sourceSpan) {
8518
8581
  sourceSpan
8519
8582
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
8520
8583
  }
8521
- function createListenerOp(target, targetSlot, name, tag, animationPhase, hostListener, sourceSpan) {
8584
+ function createListenerOp(target, targetSlot, name, tag, handlerOps, animationPhase, eventTarget, hostListener, sourceSpan) {
8585
+ const handlerList = new OpList();
8586
+ handlerList.push(handlerOps);
8522
8587
  return __spreadValues({
8523
8588
  kind: OpKind.Listener,
8524
8589
  target,
@@ -8526,11 +8591,12 @@ function createListenerOp(target, targetSlot, name, tag, animationPhase, hostLis
8526
8591
  tag,
8527
8592
  hostListener,
8528
8593
  name,
8529
- handlerOps: new OpList(),
8594
+ handlerOps: handlerList,
8530
8595
  handlerFnName: null,
8531
8596
  consumesDollarEvent: false,
8532
8597
  isAnimationListener: animationPhase !== null,
8533
8598
  animationPhase,
8599
+ eventTarget,
8534
8600
  sourceSpan
8535
8601
  }, NEW_OP);
8536
8602
  }
@@ -8554,25 +8620,30 @@ function createProjectionDefOp(def) {
8554
8620
  def
8555
8621
  }, NEW_OP);
8556
8622
  }
8557
- function createProjectionOp(xref, selector, sourceSpan) {
8623
+ function createProjectionOp(xref, selector, i18nPlaceholder, attributes, sourceSpan) {
8558
8624
  return __spreadValues(__spreadValues({
8559
8625
  kind: OpKind.Projection,
8560
8626
  xref,
8561
8627
  handle: new SlotHandle(),
8562
8628
  selector,
8629
+ i18nPlaceholder,
8563
8630
  projectionSlotIndex: 0,
8564
- attributes: [],
8631
+ attributes,
8565
8632
  localRefs: [],
8566
8633
  sourceSpan
8567
8634
  }, NEW_OP), TRAIT_CONSUMES_SLOT);
8568
8635
  }
8569
- function createExtractedAttributeOp(target, bindingKind, name, expression) {
8636
+ function createExtractedAttributeOp(target, bindingKind, name, expression, i18nContext, i18nMessage, securityContext) {
8570
8637
  return __spreadValues({
8571
8638
  kind: OpKind.ExtractedAttribute,
8572
8639
  target,
8573
8640
  bindingKind,
8574
8641
  name,
8575
- expression
8642
+ expression,
8643
+ i18nContext,
8644
+ i18nMessage,
8645
+ securityContext,
8646
+ trustedValueFn: null
8576
8647
  }, NEW_OP);
8577
8648
  }
8578
8649
  function createDeferOp(xref, main, mainSlot, metadata, sourceSpan) {
@@ -8609,10 +8680,11 @@ function createDeferOnOp(defer2, trigger, prefetch, sourceSpan) {
8609
8680
  sourceSpan
8610
8681
  }, NEW_OP);
8611
8682
  }
8612
- function createI18nMessageOp(xref, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
8683
+ function createI18nMessageOp(xref, i18nContext, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
8613
8684
  return __spreadValues({
8614
8685
  kind: OpKind.I18nMessage,
8615
8686
  xref,
8687
+ i18nContext,
8616
8688
  i18nBlock,
8617
8689
  message,
8618
8690
  messagePlaceholder,
@@ -8657,6 +8729,9 @@ function createIcuEndOp(xref) {
8657
8729
  }, NEW_OP);
8658
8730
  }
8659
8731
  function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan) {
8732
+ if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {
8733
+ throw new Error("AssertionError: i18nBlock must be provided for non-attribute contexts.");
8734
+ }
8660
8735
  return __spreadValues({
8661
8736
  kind: OpKind.I18nContext,
8662
8737
  contextKind,
@@ -8668,14 +8743,26 @@ function createI18nContextOp(contextKind, xref, i18nBlock, message, sourceSpan)
8668
8743
  postprocessingParams: /* @__PURE__ */ new Map()
8669
8744
  }, NEW_OP);
8670
8745
  }
8746
+ function createI18nAttributesOp(xref, handle, target) {
8747
+ return __spreadValues(__spreadValues({
8748
+ kind: OpKind.I18nAttributes,
8749
+ xref,
8750
+ handle,
8751
+ target,
8752
+ i18nAttributesConfig: null
8753
+ }, NEW_OP), TRAIT_CONSUMES_SLOT);
8754
+ }
8671
8755
 
8672
8756
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/ir/src/ops/host.mjs
8673
- function createHostPropertyOp(name, expression, isAnimationTrigger, sourceSpan) {
8757
+ function createHostPropertyOp(name, expression, isAnimationTrigger, i18nContext, securityContext, sourceSpan) {
8674
8758
  return __spreadValues(__spreadValues({
8675
8759
  kind: OpKind.HostProperty,
8676
8760
  name,
8677
8761
  expression,
8678
8762
  isAnimationTrigger,
8763
+ i18nContext,
8764
+ securityContext,
8765
+ sanitizer: null,
8679
8766
  sourceSpan
8680
8767
  }, TRAIT_CONSUMES_VARS), NEW_OP);
8681
8768
  }
@@ -8821,7 +8908,7 @@ function applyI18nExpressions(job) {
8821
8908
  for (const unit of job.units) {
8822
8909
  for (const op of unit.update) {
8823
8910
  if (op.kind === OpKind.I18nExpression && needsApplication(i18nContexts, op)) {
8824
- OpList.insertAfter(createI18nApplyOp(op.target, op.handle, null), op);
8911
+ OpList.insertAfter(createI18nApplyOp(op.i18nOwner, op.handle, null), op);
8825
8912
  }
8826
8913
  }
8827
8914
  }
@@ -8833,7 +8920,19 @@ function needsApplication(i18nContexts, op) {
8833
8920
  }
8834
8921
  const context = i18nContexts.get(op.context);
8835
8922
  const nextContext2 = i18nContexts.get(op.next.context);
8836
- if (context.i18nBlock !== nextContext2.i18nBlock) {
8923
+ if (context === void 0) {
8924
+ throw new Error("AssertionError: expected an I18nContextOp to exist for the I18nExpressionOp's context");
8925
+ }
8926
+ if (nextContext2 === void 0) {
8927
+ throw new Error("AssertionError: expected an I18nContextOp to exist for the next I18nExpressionOp's context");
8928
+ }
8929
+ if (context.i18nBlock !== null) {
8930
+ if (context.i18nBlock !== nextContext2.i18nBlock) {
8931
+ return true;
8932
+ }
8933
+ return false;
8934
+ }
8935
+ if (op.i18nOwner !== op.next.i18nOwner) {
8837
8936
  return true;
8838
8937
  }
8839
8938
  return false;
@@ -8841,27 +8940,44 @@ function needsApplication(i18nContexts, op) {
8841
8940
 
8842
8941
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/assign_i18n_slot_dependencies.mjs
8843
8942
  function assignI18nSlotDependencies(job) {
8844
- const i18nLastSlotConsumers = /* @__PURE__ */ new Map();
8845
- let lastSlotConsumer = null;
8846
- let currentI18nOp = null;
8847
8943
  for (const unit of job.units) {
8848
- for (const op of unit.create) {
8849
- if (hasConsumesSlotTrait(op)) {
8850
- lastSlotConsumer = op.xref;
8851
- }
8852
- switch (op.kind) {
8853
- case OpKind.I18nStart:
8854
- currentI18nOp = op;
8855
- break;
8856
- case OpKind.I18nEnd:
8857
- i18nLastSlotConsumers.set(currentI18nOp.xref, lastSlotConsumer);
8858
- currentI18nOp = null;
8859
- break;
8944
+ let updateOp = unit.update.head;
8945
+ let i18nExpressionsInProgress = [];
8946
+ let state = null;
8947
+ for (const createOp of unit.create) {
8948
+ if (createOp.kind === OpKind.I18nStart) {
8949
+ state = {
8950
+ blockXref: createOp.xref,
8951
+ lastSlotConsumer: createOp.xref
8952
+ };
8953
+ } else if (createOp.kind === OpKind.I18nEnd) {
8954
+ for (const op of i18nExpressionsInProgress) {
8955
+ op.target = state.lastSlotConsumer;
8956
+ OpList.insertBefore(op, updateOp);
8957
+ }
8958
+ i18nExpressionsInProgress.length = 0;
8959
+ state = null;
8860
8960
  }
8861
- }
8862
- for (const op of unit.update) {
8863
- if (op.kind === OpKind.I18nExpression) {
8864
- op.target = i18nLastSlotConsumers.get(op.target);
8961
+ if (hasConsumesSlotTrait(createOp)) {
8962
+ if (state !== null) {
8963
+ state.lastSlotConsumer = createOp.xref;
8964
+ }
8965
+ while (true) {
8966
+ if (updateOp.next === null) {
8967
+ break;
8968
+ }
8969
+ if (state !== null && updateOp.kind === OpKind.I18nExpression && updateOp.usage === I18nExpressionFor.I18nText && updateOp.i18nOwner === state.blockXref) {
8970
+ const opToRemove = updateOp;
8971
+ updateOp = updateOp.next;
8972
+ OpList.remove(opToRemove);
8973
+ i18nExpressionsInProgress.push(opToRemove);
8974
+ continue;
8975
+ }
8976
+ if (hasDependsOnSlotContextTrait(updateOp) && updateOp.target !== createOp.xref) {
8977
+ break;
8978
+ }
8979
+ updateOp = updateOp.next;
8980
+ }
8865
8981
  }
8866
8982
  }
8867
8983
  }
@@ -8890,18 +9006,53 @@ function extractAttributes(job) {
8890
9006
  break;
8891
9007
  case OpKind.Property:
8892
9008
  if (!op.isAnimationTrigger) {
8893
- OpList.insertBefore(createExtractedAttributeOp(op.target, op.isTemplate ? BindingKind.Template : BindingKind.Property, op.name, null), lookupElement(elements, op.target));
9009
+ let bindingKind;
9010
+ if (op.i18nMessage !== null && op.templateKind === null) {
9011
+ bindingKind = BindingKind.I18n;
9012
+ } else if (op.isStructuralTemplateAttribute) {
9013
+ bindingKind = BindingKind.Template;
9014
+ } else {
9015
+ bindingKind = BindingKind.Property;
9016
+ }
9017
+ OpList.insertBefore(
9018
+ createExtractedAttributeOp(
9019
+ op.target,
9020
+ bindingKind,
9021
+ op.name,
9022
+ null,
9023
+ null,
9024
+ null,
9025
+ op.securityContext
9026
+ ),
9027
+ lookupElement(elements, op.target)
9028
+ );
8894
9029
  }
8895
9030
  break;
8896
9031
  case OpKind.StyleProp:
8897
9032
  case OpKind.ClassProp:
8898
9033
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder && op.expression instanceof EmptyExpr2) {
8899
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.Property, op.name, null), lookupElement(elements, op.target));
9034
+ OpList.insertBefore(createExtractedAttributeOp(
9035
+ op.target,
9036
+ BindingKind.Property,
9037
+ op.name,
9038
+ null,
9039
+ null,
9040
+ null,
9041
+ SecurityContext.STYLE
9042
+ ), lookupElement(elements, op.target));
8900
9043
  }
8901
9044
  break;
8902
9045
  case OpKind.Listener:
8903
9046
  if (!op.isAnimationListener) {
8904
- const extractedAttributeOp = createExtractedAttributeOp(op.target, BindingKind.Property, op.name, null);
9047
+ const extractedAttributeOp = createExtractedAttributeOp(
9048
+ op.target,
9049
+ BindingKind.Property,
9050
+ op.name,
9051
+ null,
9052
+ null,
9053
+ null,
9054
+ SecurityContext.NONE
9055
+ );
8905
9056
  if (job.kind === CompilationJobKind.Host) {
8906
9057
  unit.create.push(extractedAttributeOp);
8907
9058
  } else {
@@ -8935,7 +9086,7 @@ function extractAttributeOp(unit, op, elements) {
8935
9086
  }
8936
9087
  }
8937
9088
  if (extractable) {
8938
- const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isTemplate ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression);
9089
+ const extractedAttributeOp = createExtractedAttributeOp(op.target, op.isStructuralTemplateAttribute ? BindingKind.Template : BindingKind.Attribute, op.name, op.expression, op.i18nContext, op.i18nMessage, op.securityContext);
8939
9090
  if (unit.job.kind === CompilationJobKind.Host) {
8940
9091
  unit.create.push(extractedAttributeOp);
8941
9092
  } else {
@@ -8976,15 +9127,15 @@ function specializeBindings(job) {
8976
9127
  const target = lookupElement2(elements, op.target);
8977
9128
  target.nonBindable = true;
8978
9129
  } else {
8979
- OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isTemplate, op.sourceSpan));
9130
+ OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isStructuralTemplateAttribute, op.templateKind, op.i18nMessage, op.sourceSpan));
8980
9131
  }
8981
9132
  break;
8982
9133
  case BindingKind.Property:
8983
9134
  case BindingKind.Animation:
8984
9135
  if (job.kind === CompilationJobKind.Host) {
8985
- OpList.replace(op, createHostPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.Animation, op.sourceSpan));
9136
+ OpList.replace(op, createHostPropertyOp(op.name, op.expression, op.bindingKind === BindingKind.Animation, op.i18nContext, op.securityContext, op.sourceSpan));
8986
9137
  } else {
8987
- OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.Animation, op.securityContext, op.isTemplate, op.sourceSpan));
9138
+ OpList.replace(op, createPropertyOp(op.target, op.name, op.expression, op.bindingKind === BindingKind.Animation, op.securityContext, op.isStructuralTemplateAttribute, op.templateKind, op.i18nContext, op.i18nMessage, op.sourceSpan));
8988
9139
  }
8989
9140
  break;
8990
9141
  case BindingKind.I18n:
@@ -9111,39 +9262,6 @@ function generateConditionalExpressions(job) {
9111
9262
  }
9112
9263
  }
9113
9264
 
9114
- // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/ml_parser/tags.mjs
9115
- var TagContentType;
9116
- (function(TagContentType2) {
9117
- TagContentType2[TagContentType2["RAW_TEXT"] = 0] = "RAW_TEXT";
9118
- TagContentType2[TagContentType2["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
9119
- TagContentType2[TagContentType2["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
9120
- })(TagContentType || (TagContentType = {}));
9121
- function splitNsName(elementName) {
9122
- if (elementName[0] != ":") {
9123
- return [null, elementName];
9124
- }
9125
- const colonIndex = elementName.indexOf(":", 1);
9126
- if (colonIndex === -1) {
9127
- throw new Error(`Unsupported format "${elementName}" expecting ":namespace:name"`);
9128
- }
9129
- return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
9130
- }
9131
- function isNgContainer(tagName) {
9132
- return splitNsName(tagName)[1] === "ng-container";
9133
- }
9134
- function isNgContent(tagName) {
9135
- return splitNsName(tagName)[1] === "ng-content";
9136
- }
9137
- function isNgTemplate(tagName) {
9138
- return splitNsName(tagName)[1] === "ng-template";
9139
- }
9140
- function getNsPrefix(fullName) {
9141
- return fullName === null ? null : splitNsName(fullName)[0];
9142
- }
9143
- function mergeNsAndName(prefix, localName) {
9144
- return prefix ? `:${prefix}:${localName}` : localName;
9145
- }
9146
-
9147
9265
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/conversion.mjs
9148
9266
  var BINARY_OPERATORS = /* @__PURE__ */ new Map([
9149
9267
  ["&&", BinaryOperator.And],
@@ -9202,7 +9320,7 @@ function collectElementConsts(job) {
9202
9320
  if (op.kind === OpKind.ExtractedAttribute) {
9203
9321
  const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
9204
9322
  allElementAttributes.set(op.target, attributes);
9205
- attributes.add(op.bindingKind, op.name, op.expression);
9323
+ attributes.add(op.bindingKind, op.name, op.expression, op.trustedValueFn);
9206
9324
  OpList.remove(op);
9207
9325
  }
9208
9326
  }
@@ -9264,7 +9382,7 @@ var ElementAttributes = class {
9264
9382
  var _a2;
9265
9383
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
9266
9384
  }
9267
- add(kind, name, value) {
9385
+ add(kind, name, value, trustedValueFn) {
9268
9386
  var _a2;
9269
9387
  if (this.known.has(name)) {
9270
9388
  return;
@@ -9280,9 +9398,16 @@ var ElementAttributes = class {
9280
9398
  array.push(...getAttributeNameLiterals(name));
9281
9399
  if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
9282
9400
  if (value === null) {
9283
- throw Error("Attribute & style element attributes must have a value");
9401
+ throw Error("Attribute, i18n attribute, & style element attributes must have a value");
9402
+ }
9403
+ if (trustedValueFn !== null) {
9404
+ if (!isStringLiteral(value)) {
9405
+ throw Error("AssertionError: extracted attribute value should be string literal");
9406
+ }
9407
+ array.push(taggedTemplate(trustedValueFn, new TemplateLiteral([new TemplateLiteralElement(value.value)], []), void 0, value.sourceSpan));
9408
+ } else {
9409
+ array.push(value);
9284
9410
  }
9285
- array.push(value);
9286
9411
  }
9287
9412
  }
9288
9413
  arrayFor(kind) {
@@ -9328,6 +9453,47 @@ function serializeAttributes({ attributes, bindings, classes, i18n: i18n2, proje
9328
9453
  return literalArr(attrArray);
9329
9454
  }
9330
9455
 
9456
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/convert_i18n_bindings.mjs
9457
+ function convertI18nBindings(job) {
9458
+ const i18nAttributesByElem = /* @__PURE__ */ new Map();
9459
+ for (const unit of job.units) {
9460
+ for (const op of unit.create) {
9461
+ if (op.kind === OpKind.I18nAttributes) {
9462
+ i18nAttributesByElem.set(op.target, op);
9463
+ }
9464
+ }
9465
+ for (const op of unit.update) {
9466
+ switch (op.kind) {
9467
+ case OpKind.Property:
9468
+ case OpKind.Attribute:
9469
+ if (op.i18nContext === null) {
9470
+ continue;
9471
+ }
9472
+ if (!(op.expression instanceof Interpolation2)) {
9473
+ continue;
9474
+ }
9475
+ const i18nAttributesForElem = i18nAttributesByElem.get(op.target);
9476
+ if (i18nAttributesForElem === void 0) {
9477
+ throw new Error("AssertionError: An i18n attribute binding instruction requires the owning element to have an I18nAttributes create instruction");
9478
+ }
9479
+ if (i18nAttributesForElem.target !== op.target) {
9480
+ throw new Error("AssertionError: Expected i18nAttributes target element to match binding target element");
9481
+ }
9482
+ const ops = [];
9483
+ for (let i = 0; i < op.expression.expressions.length; i++) {
9484
+ const expr = op.expression.expressions[i];
9485
+ if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {
9486
+ 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`);
9487
+ }
9488
+ ops.push(createI18nExpressionOp(op.i18nContext, i18nAttributesForElem.target, i18nAttributesForElem.xref, i18nAttributesForElem.handle, expr, op.expression.i18nPlaceholders[i], I18nParamResolutionTime.Creation, I18nExpressionFor.I18nAttribute, op.name, op.sourceSpan));
9489
+ }
9490
+ OpList.replaceWithMany(op, ops);
9491
+ break;
9492
+ }
9493
+ }
9494
+ }
9495
+ }
9496
+
9331
9497
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/create_defer_deps_fns.mjs
9332
9498
  function createDeferDepsFns(job) {
9333
9499
  for (const unit of job.units) {
@@ -9361,6 +9527,7 @@ function createI18nContexts(job) {
9361
9527
  const rootContexts = /* @__PURE__ */ new Map();
9362
9528
  let currentI18nOp = null;
9363
9529
  let xref;
9530
+ const messageToContext = /* @__PURE__ */ new Map();
9364
9531
  for (const unit of job.units) {
9365
9532
  for (const op of unit.create) {
9366
9533
  switch (op.kind) {
@@ -9390,6 +9557,24 @@ function createI18nContexts(job) {
9390
9557
  break;
9391
9558
  }
9392
9559
  }
9560
+ for (const op of unit.ops()) {
9561
+ switch (op.kind) {
9562
+ case OpKind.Binding:
9563
+ case OpKind.Property:
9564
+ case OpKind.Attribute:
9565
+ case OpKind.ExtractedAttribute:
9566
+ if (!op.i18nMessage) {
9567
+ continue;
9568
+ }
9569
+ if (!messageToContext.has(op.i18nMessage)) {
9570
+ const i18nContext = job.allocateXrefId();
9571
+ unit.create.push(createI18nContextOp(I18nContextKind.Attr, i18nContext, null, op.i18nMessage, null));
9572
+ messageToContext.set(op.i18nMessage, i18nContext);
9573
+ }
9574
+ op.i18nContext = messageToContext.get(op.i18nMessage);
9575
+ break;
9576
+ }
9577
+ }
9393
9578
  }
9394
9579
  for (const unit of job.units) {
9395
9580
  for (const op of unit.create) {
@@ -9698,6 +9883,15 @@ function extractI18nMessages(job) {
9698
9883
  }
9699
9884
  }
9700
9885
  }
9886
+ for (const unit of job.units) {
9887
+ for (const op of unit.create) {
9888
+ if (op.kind !== OpKind.I18nContext || op.contextKind !== I18nContextKind.Attr) {
9889
+ continue;
9890
+ }
9891
+ const i18nMessageOp = createI18nMessage(job, op);
9892
+ unit.create.push(i18nMessageOp);
9893
+ }
9894
+ }
9701
9895
  const i18nBlockMessages = /* @__PURE__ */ new Map();
9702
9896
  for (const unit of job.units) {
9703
9897
  for (const op of unit.create) {
@@ -9720,6 +9914,9 @@ function extractI18nMessages(job) {
9720
9914
  }
9721
9915
  const i18nContext = i18nContexts.get(op.context);
9722
9916
  if (i18nContext.contextKind === I18nContextKind.Icu) {
9917
+ if (i18nContext.i18nBlock === null) {
9918
+ throw Error("ICU context should have its i18n block set.");
9919
+ }
9723
9920
  const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
9724
9921
  unit.create.push(subMessage);
9725
9922
  const rootI18nId = i18nBlocks.get(i18nContext.i18nBlock).root;
@@ -9736,69 +9933,54 @@ function extractI18nMessages(job) {
9736
9933
  }
9737
9934
  }
9738
9935
  function createI18nMessage(job, context, messagePlaceholder) {
9739
- let [formattedParams, needsPostprocessing] = formatParams(context.params);
9740
- const [formattedPostprocessingParams] = formatParams(context.postprocessingParams);
9741
- needsPostprocessing || (needsPostprocessing = formattedPostprocessingParams.size > 0);
9742
- return createI18nMessageOp(job.allocateXrefId(), context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9936
+ let formattedParams = formatParams(context.params);
9937
+ const formattedPostprocessingParams = formatParams(context.postprocessingParams);
9938
+ let needsPostprocessing = formattedPostprocessingParams.size > 0;
9939
+ for (const values of context.params.values()) {
9940
+ if (values.length > 1) {
9941
+ needsPostprocessing = true;
9942
+ }
9943
+ }
9944
+ return createI18nMessageOp(job.allocateXrefId(), context.xref, context.i18nBlock, context.message, messagePlaceholder != null ? messagePlaceholder : null, formattedParams, formattedPostprocessingParams, needsPostprocessing);
9743
9945
  }
9744
9946
  function formatParams(params) {
9745
9947
  const formattedParams = /* @__PURE__ */ new Map();
9746
- let needsPostprocessing = false;
9747
9948
  for (const [placeholder, placeholderValues] of params) {
9748
- const [serializedValues, paramNeedsPostprocessing] = formatParamValues(placeholderValues);
9749
- needsPostprocessing || (needsPostprocessing = paramNeedsPostprocessing);
9949
+ const serializedValues = formatParamValues(placeholderValues);
9750
9950
  if (serializedValues !== null) {
9751
9951
  formattedParams.set(placeholder, literal(serializedValues));
9752
9952
  }
9753
9953
  }
9754
- return [formattedParams, needsPostprocessing];
9954
+ return formattedParams;
9755
9955
  }
9756
9956
  function formatParamValues(values) {
9757
9957
  if (values.length === 0) {
9758
- return [null, false];
9958
+ return null;
9759
9959
  }
9760
- collapseElementTemplatePairs(values);
9761
9960
  const serializedValues = values.map((value) => formatValue(value));
9762
- return serializedValues.length === 1 ? [serializedValues[0], false] : [`${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`, true];
9961
+ return serializedValues.length === 1 ? serializedValues[0] : `${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`;
9763
9962
  }
9764
- function collapseElementTemplatePairs(values) {
9765
- var _a2;
9766
- const valueIndiciesBySubTemplateIndex = /* @__PURE__ */ new Map();
9767
- for (let i = 0; i < values.length; i++) {
9768
- const value = values[i];
9769
- if (value.subTemplateIndex !== null && value.flags & (I18nParamValueFlags.ElementTag | I18nParamValueFlags.TemplateTag)) {
9770
- const valueIndicies = (_a2 = valueIndiciesBySubTemplateIndex.get(value.subTemplateIndex)) != null ? _a2 : [];
9771
- valueIndicies.push(i);
9772
- valueIndiciesBySubTemplateIndex.set(value.subTemplateIndex, valueIndicies);
9773
- }
9774
- }
9775
- for (const [subTemplateIndex, valueIndicies] of valueIndiciesBySubTemplateIndex) {
9776
- if (valueIndicies.length > 1) {
9777
- const elementIndex = valueIndicies.find((index) => values[index].flags & I18nParamValueFlags.ElementTag);
9778
- const templateIndex = valueIndicies.find((index) => values[index].flags & I18nParamValueFlags.TemplateTag);
9779
- if (elementIndex !== void 0 && templateIndex !== void 0) {
9780
- const elementValue = values[elementIndex];
9781
- const templateValue = values[templateIndex];
9782
- let compundValue;
9783
- if (elementValue.flags & I18nParamValueFlags.OpenTag && elementValue.flags & I18nParamValueFlags.CloseTag) {
9784
- compundValue = `${formatValue(templateValue)}${formatValue(elementValue)}${formatValue(templateValue)}`;
9785
- } else if (elementValue.flags & I18nParamValueFlags.OpenTag) {
9786
- compundValue = `${formatValue(templateValue)}${formatValue(elementValue)}`;
9787
- } else {
9788
- compundValue = `${formatValue(elementValue)}${formatValue(templateValue)}`;
9789
- }
9790
- values.splice(elementIndex, 1, { value: compundValue, subTemplateIndex, flags: I18nParamValueFlags.None });
9791
- values.splice(templateIndex, 1, null);
9792
- }
9963
+ function formatValue(value) {
9964
+ if (value.flags & I18nParamValueFlags.ElementTag && value.flags & I18nParamValueFlags.TemplateTag) {
9965
+ if (typeof value.value !== "object") {
9966
+ throw Error("AssertionError: Expected i18n param value to have an element and template slot");
9793
9967
  }
9794
- }
9795
- for (let i = values.length - 1; i >= 0; i--) {
9796
- if (values[i] === null) {
9797
- values.splice(i, 1);
9968
+ const elementValue = formatValue(__spreadProps(__spreadValues({}, value), {
9969
+ value: value.value.element,
9970
+ flags: value.flags & ~I18nParamValueFlags.TemplateTag
9971
+ }));
9972
+ const templateValue = formatValue(__spreadProps(__spreadValues({}, value), {
9973
+ value: value.value.template,
9974
+ flags: value.flags & ~I18nParamValueFlags.ElementTag
9975
+ }));
9976
+ if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
9977
+ return `${templateValue}${elementValue}${templateValue}`;
9798
9978
  }
9979
+ return value.flags & I18nParamValueFlags.CloseTag ? `${elementValue}${templateValue}` : `${templateValue}${elementValue}`;
9980
+ }
9981
+ if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
9982
+ return `${formatValue(__spreadProps(__spreadValues({}, value), { flags: value.flags & ~I18nParamValueFlags.CloseTag }))}${formatValue(__spreadProps(__spreadValues({}, value), { flags: value.flags & ~I18nParamValueFlags.OpenTag }))}`;
9799
9983
  }
9800
- }
9801
- function formatValue(value) {
9802
9984
  if (value.flags === I18nParamValueFlags.None) {
9803
9985
  return `${value.value}`;
9804
9986
  }
@@ -9813,9 +9995,6 @@ function formatValue(value) {
9813
9995
  closeMarker = value.flags & I18nParamValueFlags.CloseTag ? TAG_CLOSE_MARKER : "";
9814
9996
  }
9815
9997
  const context = value.subTemplateIndex === null ? "" : `${CONTEXT_MARKER}${value.subTemplateIndex}`;
9816
- if (value.flags & I18nParamValueFlags.OpenTag && value.flags & I18nParamValueFlags.CloseTag) {
9817
- return `${ESCAPE}${tagMarker}${value.value}${context}${ESCAPE}${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;
9818
- }
9819
9998
  return `${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;
9820
9999
  }
9821
10000
 
@@ -9836,7 +10015,7 @@ function generateAdvance(job) {
9836
10015
  if (!hasDependsOnSlotContextTrait(op)) {
9837
10016
  continue;
9838
10017
  } else if (!slotMap.has(op.target)) {
9839
- throw new Error(`AssertionError: reference to unknown slot for var ${op.target}`);
10018
+ throw new Error(`AssertionError: reference to unknown slot for target ${op.target}`);
9840
10019
  }
9841
10020
  const slot = slotMap.get(op.target);
9842
10021
  if (slotContext !== slot) {
@@ -9884,8 +10063,13 @@ function recursivelyProcessView(view, parentScope) {
9884
10063
  for (const op of view.create) {
9885
10064
  switch (op.kind) {
9886
10065
  case OpKind.Template:
10066
+ recursivelyProcessView(view.job.views.get(op.xref), scope);
10067
+ break;
9887
10068
  case OpKind.RepeaterCreate:
9888
10069
  recursivelyProcessView(view.job.views.get(op.xref), scope);
10070
+ if (op.emptyView) {
10071
+ recursivelyProcessView(view.job.views.get(op.emptyView), scope);
10072
+ }
9889
10073
  break;
9890
10074
  case OpKind.Listener:
9891
10075
  op.handlerOps.prepend(generateVariablesInScopeForView(view, scope));
@@ -16019,56 +16203,137 @@ function createEmptyMessagePart(location) {
16019
16203
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.mjs
16020
16204
  var NG_I18N_CLOSURE_MODE = "ngI18nClosureMode";
16021
16205
  var TRANSLATION_VAR_PREFIX2 = "i18n_";
16206
+ var I18N_ICU_MAPPING_PREFIX2 = "I18N_EXP_";
16207
+ var ESCAPE2 = "\uFFFD";
16022
16208
  function collectI18nConsts(job) {
16209
+ var _a2, _b2;
16023
16210
  const fileBasedI18nSuffix = job.relativeContextFilePath.replace(/[^A-Za-z0-9]/g, "_").toUpperCase() + "_";
16024
- const messageConstIndices = /* @__PURE__ */ new Map();
16211
+ const extractedAttributesByI18nContext = /* @__PURE__ */ new Map();
16212
+ const i18nAttributesByElement = /* @__PURE__ */ new Map();
16213
+ const i18nExpressionsByElement = /* @__PURE__ */ new Map();
16025
16214
  const messages = /* @__PURE__ */ new Map();
16215
+ for (const unit of job.units) {
16216
+ for (const op of unit.ops()) {
16217
+ if (op.kind === OpKind.ExtractedAttribute && op.i18nContext !== null) {
16218
+ const attributes = (_a2 = extractedAttributesByI18nContext.get(op.i18nContext)) != null ? _a2 : [];
16219
+ attributes.push(op);
16220
+ extractedAttributesByI18nContext.set(op.i18nContext, attributes);
16221
+ } else if (op.kind === OpKind.I18nAttributes) {
16222
+ i18nAttributesByElement.set(op.target, op);
16223
+ } else if (op.kind === OpKind.I18nExpression && op.usage === I18nExpressionFor.I18nAttribute) {
16224
+ const expressions = (_b2 = i18nExpressionsByElement.get(op.target)) != null ? _b2 : [];
16225
+ expressions.push(op);
16226
+ i18nExpressionsByElement.set(op.target, expressions);
16227
+ } else if (op.kind === OpKind.I18nMessage) {
16228
+ messages.set(op.xref, op);
16229
+ }
16230
+ }
16231
+ }
16232
+ const i18nValuesByContext = /* @__PURE__ */ new Map();
16233
+ const messageConstIndices = /* @__PURE__ */ new Map();
16026
16234
  for (const unit of job.units) {
16027
16235
  for (const op of unit.create) {
16028
16236
  if (op.kind === OpKind.I18nMessage) {
16029
- messages.set(op.xref, op);
16237
+ if (op.messagePlaceholder === null) {
16238
+ const { mainVar, statements } = collectMessage(job, fileBasedI18nSuffix, messages, op);
16239
+ if (op.i18nBlock !== null) {
16240
+ const i18nConst = job.addConst(mainVar, statements);
16241
+ messageConstIndices.set(op.i18nBlock, i18nConst);
16242
+ } else {
16243
+ job.constsInitializers.push(...statements);
16244
+ i18nValuesByContext.set(op.i18nContext, mainVar);
16245
+ const attributesForMessage = extractedAttributesByI18nContext.get(op.i18nContext);
16246
+ if (attributesForMessage !== void 0) {
16247
+ for (const attr of attributesForMessage) {
16248
+ attr.expression = mainVar.clone();
16249
+ }
16250
+ }
16251
+ }
16252
+ }
16030
16253
  OpList.remove(op);
16031
16254
  }
16032
16255
  }
16033
16256
  }
16034
- for (const op of messages.values()) {
16035
- if (op.kind === OpKind.I18nMessage && op.messagePlaceholder === null) {
16036
- const { mainVar, statements } = collectMessage(job, fileBasedI18nSuffix, messages, op);
16037
- messageConstIndices.set(op.i18nBlock, job.addConst(mainVar, statements));
16257
+ for (const unit of job.units) {
16258
+ for (const elem of unit.create) {
16259
+ if (isElementOrContainerOp(elem)) {
16260
+ const i18nAttributes2 = i18nAttributesByElement.get(elem.xref);
16261
+ if (i18nAttributes2 === void 0) {
16262
+ continue;
16263
+ }
16264
+ let i18nExpressions = i18nExpressionsByElement.get(elem.xref);
16265
+ if (i18nExpressions === void 0) {
16266
+ throw new Error("AssertionError: Could not find any i18n expressions associated with an I18nAttributes instruction");
16267
+ }
16268
+ const seenPropertyNames = /* @__PURE__ */ new Set();
16269
+ i18nExpressions = i18nExpressions.filter((i18nExpr) => {
16270
+ const seen = seenPropertyNames.has(i18nExpr.name);
16271
+ seenPropertyNames.add(i18nExpr.name);
16272
+ return !seen;
16273
+ });
16274
+ const i18nAttributeConfig = i18nExpressions.flatMap((i18nExpr) => {
16275
+ const i18nExprValue = i18nValuesByContext.get(i18nExpr.context);
16276
+ if (i18nExprValue === void 0) {
16277
+ throw new Error("AssertionError: Could not find i18n expression's value");
16278
+ }
16279
+ return [literal(i18nExpr.name), i18nExprValue];
16280
+ });
16281
+ i18nAttributes2.i18nAttributesConfig = job.addConst(new LiteralArrayExpr(i18nAttributeConfig));
16282
+ }
16038
16283
  }
16039
16284
  }
16040
16285
  for (const unit of job.units) {
16041
16286
  for (const op of unit.create) {
16042
16287
  if (op.kind === OpKind.I18nStart) {
16043
- op.messageIndex = messageConstIndices.get(op.root);
16288
+ const msgIndex = messageConstIndices.get(op.root);
16289
+ if (msgIndex === void 0) {
16290
+ throw new Error("AssertionError: Could not find corresponding i18n block index for an i18n message op; was an i18n message incorrectly assumed to correspond to an attribute?");
16291
+ }
16292
+ op.messageIndex = msgIndex;
16044
16293
  }
16045
16294
  }
16046
16295
  }
16047
16296
  }
16048
16297
  function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
16298
+ var _a2;
16049
16299
  const statements = [];
16300
+ const subMessagePlaceholders = /* @__PURE__ */ new Map();
16050
16301
  for (const subMessageId of messageOp.subMessages) {
16051
16302
  const subMessage = messages.get(subMessageId);
16052
16303
  const { mainVar: subMessageVar, statements: subMessageStatements } = collectMessage(job, fileBasedI18nSuffix, messages, subMessage);
16053
16304
  statements.push(...subMessageStatements);
16054
- messageOp.params.set(subMessage.messagePlaceholder, subMessageVar);
16305
+ const subMessages = (_a2 = subMessagePlaceholders.get(subMessage.messagePlaceholder)) != null ? _a2 : [];
16306
+ subMessages.push(subMessageVar);
16307
+ subMessagePlaceholders.set(subMessage.messagePlaceholder, subMessages);
16055
16308
  }
16309
+ addSubMessageParams(messageOp, subMessagePlaceholders);
16056
16310
  messageOp.params = new Map([...messageOp.params.entries()].sort());
16057
- assertAllParamsResolved(messageOp);
16058
16311
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX2));
16059
16312
  const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
16060
16313
  let transformFn = void 0;
16061
16314
  if (messageOp.needsPostprocessing) {
16062
- messageOp.postprocessingParams = new Map([...messageOp.postprocessingParams.entries()].sort());
16315
+ const postprocessingParams = Object.fromEntries([...messageOp.postprocessingParams.entries()].sort());
16316
+ const formattedPostprocessingParams = formatI18nPlaceholderNamesInMap(postprocessingParams, false);
16063
16317
  const extraTransformFnParams = [];
16064
16318
  if (messageOp.postprocessingParams.size > 0) {
16065
- extraTransformFnParams.push(literalMap([...messageOp.postprocessingParams].map(([key, value]) => ({ key, value, quoted: true }))));
16319
+ extraTransformFnParams.push(mapLiteral(formattedPostprocessingParams, true));
16066
16320
  }
16067
16321
  transformFn = (expr) => importExpr(Identifiers.i18nPostprocess).callFn([expr, ...extraTransformFnParams]);
16068
16322
  }
16069
16323
  statements.push(...getTranslationDeclStmts(messageOp.message, mainVar, closureVar, messageOp.params, transformFn));
16070
16324
  return { mainVar, statements };
16071
16325
  }
16326
+ function addSubMessageParams(messageOp, subMessagePlaceholders) {
16327
+ for (const [placeholder, subMessages] of subMessagePlaceholders) {
16328
+ if (subMessages.length === 1) {
16329
+ messageOp.params.set(placeholder, subMessages[0]);
16330
+ } else {
16331
+ messageOp.params.set(placeholder, literal(`${ESCAPE2}${I18N_ICU_MAPPING_PREFIX2}${placeholder}${ESCAPE2}`));
16332
+ messageOp.postprocessingParams.set(placeholder, literalArr(subMessages));
16333
+ messageOp.needsPostprocessing = true;
16334
+ }
16335
+ }
16336
+ }
16072
16337
  function getTranslationDeclStmts(message, variable2, closureVar, params, transformFn) {
16073
16338
  const paramsObject = Object.fromEntries(params);
16074
16339
  const statements = [
@@ -16096,23 +16361,9 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
16096
16361
  }
16097
16362
  return variable(name);
16098
16363
  }
16099
- function assertAllParamsResolved(op) {
16100
- for (let placeholder in op.message.placeholders) {
16101
- placeholder = placeholder.trimEnd();
16102
- if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
16103
- throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
16104
- }
16105
- }
16106
- for (let placeholder in op.message.placeholderToMessage) {
16107
- placeholder = placeholder.trimEnd();
16108
- if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
16109
- throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
16110
- }
16111
- }
16112
- }
16113
16364
 
16114
16365
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.mjs
16115
- function extractI18nText(job) {
16366
+ function convertI18nText(job) {
16116
16367
  var _a2;
16117
16368
  for (const unit of job.units) {
16118
16369
  let currentI18n = null;
@@ -16161,7 +16412,7 @@ function extractI18nText(job) {
16161
16412
  const ops = [];
16162
16413
  for (let i = 0; i < op.interpolation.expressions.length; i++) {
16163
16414
  const expr = op.interpolation.expressions[i];
16164
- ops.push(createI18nExpressionOp(contextId, i18nOp.xref, i18nOp.handle, expr, op.i18nPlaceholders[i], resolutionTime, (_a2 = expr.sourceSpan) != null ? _a2 : op.sourceSpan));
16415
+ 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));
16165
16416
  }
16166
16417
  OpList.replaceWithMany(op, ops);
16167
16418
  break;
@@ -16583,13 +16834,13 @@ function parseExtractedStyles(job) {
16583
16834
  if (op.name === "style") {
16584
16835
  const parsedStyles = parse(op.expression.value);
16585
16836
  for (let i = 0; i < parsedStyles.length - 1; i += 2) {
16586
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1])), op);
16837
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.StyleProperty, parsedStyles[i], literal(parsedStyles[i + 1]), null, null, SecurityContext.STYLE), op);
16587
16838
  }
16588
16839
  OpList.remove(op);
16589
16840
  } else if (op.name === "class") {
16590
16841
  const parsedClasses = op.expression.value.trim().split(/\s+/g);
16591
16842
  for (const parsedClass of parsedClasses) {
16592
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null), op);
16843
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.ClassName, parsedClass, null, null, null, SecurityContext.NONE), op);
16593
16844
  }
16594
16845
  OpList.remove(op);
16595
16846
  }
@@ -16602,18 +16853,28 @@ function parseExtractedStyles(job) {
16602
16853
  function removeContentSelectors(job) {
16603
16854
  for (const unit of job.units) {
16604
16855
  const elements = createOpXrefMap(unit);
16605
- for (const op of unit.update) {
16856
+ for (const op of unit.ops()) {
16606
16857
  switch (op.kind) {
16607
16858
  case OpKind.Binding:
16608
16859
  const target = lookupInXrefMap(elements, op.target);
16609
- if (op.name.toLowerCase() === "select" && target.kind === OpKind.Projection) {
16860
+ if (isSelectAttribute(op.name) && target.kind === OpKind.Projection) {
16610
16861
  OpList.remove(op);
16611
16862
  }
16612
16863
  break;
16864
+ case OpKind.Projection:
16865
+ for (let i = op.attributes.length - 2; i >= 0; i -= 2) {
16866
+ if (isSelectAttribute(op.attributes[i])) {
16867
+ op.attributes.splice(i, 2);
16868
+ }
16869
+ }
16870
+ break;
16613
16871
  }
16614
16872
  }
16615
16873
  }
16616
16874
  }
16875
+ function isSelectAttribute(name) {
16876
+ return name.toLowerCase() === "select";
16877
+ }
16617
16878
  function lookupInXrefMap(map, xref) {
16618
16879
  const el = map.get(xref);
16619
16880
  if (el === void 0) {
@@ -16700,22 +16961,35 @@ function propagateI18nBlocksToTemplates(unit, subTemplateIndex) {
16700
16961
  i18nBlock = op;
16701
16962
  break;
16702
16963
  case OpKind.I18nEnd:
16964
+ if (i18nBlock.subTemplateIndex === null) {
16965
+ subTemplateIndex = 0;
16966
+ }
16703
16967
  i18nBlock = null;
16704
16968
  break;
16705
16969
  case OpKind.Template:
16706
- const templateView = unit.job.views.get(op.xref);
16707
- if (op.i18nPlaceholder !== void 0) {
16708
- if (i18nBlock === null) {
16709
- throw Error("Expected template with i18n placeholder to be in an i18n block.");
16710
- }
16711
- subTemplateIndex++;
16712
- wrapTemplateWithI18n(templateView, i18nBlock);
16970
+ subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.xref), i18nBlock, op.i18nPlaceholder, subTemplateIndex);
16971
+ break;
16972
+ case OpKind.RepeaterCreate:
16973
+ const forView = unit.job.views.get(op.xref);
16974
+ subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.xref), i18nBlock, op.i18nPlaceholder, subTemplateIndex);
16975
+ if (op.emptyView !== null) {
16976
+ subTemplateIndex = propagateI18nBlocksForView(unit.job.views.get(op.emptyView), i18nBlock, op.emptyI18nPlaceholder, subTemplateIndex);
16713
16977
  }
16714
- subTemplateIndex = propagateI18nBlocksToTemplates(templateView, subTemplateIndex);
16978
+ break;
16715
16979
  }
16716
16980
  }
16717
16981
  return subTemplateIndex;
16718
16982
  }
16983
+ function propagateI18nBlocksForView(view, i18nBlock, i18nPlaceholder, subTemplateIndex) {
16984
+ if (i18nPlaceholder !== void 0) {
16985
+ if (i18nBlock === null) {
16986
+ throw Error("Expected template with i18n placeholder to be in an i18n block.");
16987
+ }
16988
+ subTemplateIndex++;
16989
+ wrapTemplateWithI18n(view, i18nBlock);
16990
+ }
16991
+ return propagateI18nBlocksToTemplates(view, subTemplateIndex);
16992
+ }
16719
16993
  function wrapTemplateWithI18n(unit, parentI18n) {
16720
16994
  var _a2;
16721
16995
  if (((_a2 = unit.create.head.next) == null ? void 0 : _a2.kind) !== OpKind.I18nStart) {
@@ -16872,17 +17146,13 @@ function disableBindings2() {
16872
17146
  function enableBindings() {
16873
17147
  return call(Identifiers.enableBindings, [], null);
16874
17148
  }
16875
- function listener(name, handlerFn, sourceSpan) {
16876
- return call(Identifiers.listener, [
16877
- literal(name),
16878
- handlerFn
16879
- ], sourceSpan);
16880
- }
16881
- function syntheticHostListener(name, handlerFn, sourceSpan) {
16882
- return call(Identifiers.syntheticHostListener, [
16883
- literal(name),
16884
- handlerFn
16885
- ], sourceSpan);
17149
+ function listener(name, handlerFn, eventTargetResolver, syntheticHost, sourceSpan) {
17150
+ const args = [literal(name), handlerFn];
17151
+ if (eventTargetResolver !== null) {
17152
+ args.push(literal(false));
17153
+ args.push(importExpr(eventTargetResolver));
17154
+ }
17155
+ return call(syntheticHost ? Identifiers.syntheticHostListener : Identifiers.listener, args, sourceSpan);
16886
17156
  }
16887
17157
  function pipe(slot, name) {
16888
17158
  return call(Identifiers.pipe, [
@@ -17029,6 +17299,10 @@ function i18n(slot, constIndex, subTemplateIndex) {
17029
17299
  function i18nEnd() {
17030
17300
  return call(Identifiers.i18nEnd, [], null);
17031
17301
  }
17302
+ function i18nAttributes(slot, i18nAttributesConfig) {
17303
+ const args = [literal(slot), literal(i18nAttributesConfig)];
17304
+ return call(Identifiers.i18nAttributes, args, null);
17305
+ }
17032
17306
  function property(name, expression, sanitizer, sourceSpan) {
17033
17307
  const args = [literal(name), expression];
17034
17308
  if (sanitizer !== null) {
@@ -17137,8 +17411,12 @@ function classMapInterpolate(strings, expressions, sourceSpan) {
17137
17411
  const interpolationArgs = collateInterpolationArgs(strings, expressions);
17138
17412
  return callVariadicInstruction(CLASS_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], sourceSpan);
17139
17413
  }
17140
- function hostProperty(name, expression, sourceSpan) {
17141
- return call(Identifiers.hostProperty, [literal(name), expression], sourceSpan);
17414
+ function hostProperty(name, expression, sanitizer, sourceSpan) {
17415
+ const args = [literal(name), expression];
17416
+ if (sanitizer !== null) {
17417
+ args.push(sanitizer);
17418
+ }
17419
+ return call(Identifiers.hostProperty, args, sourceSpan);
17142
17420
  }
17143
17421
  function syntheticHostProperty(name, expression, sourceSpan) {
17144
17422
  return call(Identifiers.syntheticHostProperty, [literal(name), expression], sourceSpan);
@@ -17326,13 +17604,10 @@ function callVariadicInstruction(config, baseArgs, interpolationArgs, extraArgs,
17326
17604
  }
17327
17605
 
17328
17606
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/reify.mjs
17329
- var sanitizerIdentifierMap = /* @__PURE__ */ new Map([
17330
- [SanitizerFn.Html, Identifiers.sanitizeHtml],
17331
- [SanitizerFn.IframeAttribute, Identifiers.validateIframeAttribute],
17332
- [SanitizerFn.ResourceUrl, Identifiers.sanitizeResourceUrl],
17333
- [SanitizerFn.Script, Identifiers.sanitizeScript],
17334
- [SanitizerFn.Style, Identifiers.sanitizeStyle],
17335
- [SanitizerFn.Url, Identifiers.sanitizeUrl]
17607
+ var GLOBAL_TARGET_RESOLVERS = /* @__PURE__ */ new Map([
17608
+ ["window", Identifiers.resolveWindow],
17609
+ ["document", Identifiers.resolveDocument],
17610
+ ["body", Identifiers.resolveBody]
17336
17611
  ]);
17337
17612
  function reify(job) {
17338
17613
  for (const unit of job.units) {
@@ -17375,6 +17650,12 @@ function reifyCreateOperations(unit, ops) {
17375
17650
  case OpKind.I18n:
17376
17651
  OpList.replace(op, i18n(op.handle.slot, op.messageIndex, op.subTemplateIndex));
17377
17652
  break;
17653
+ case OpKind.I18nAttributes:
17654
+ if (op.i18nAttributesConfig === null) {
17655
+ throw new Error(`AssertionError: i18nAttributesConfig was not set`);
17656
+ }
17657
+ OpList.replace(op, i18nAttributes(op.handle.slot, op.i18nAttributesConfig));
17658
+ break;
17378
17659
  case OpKind.Template:
17379
17660
  if (!(unit instanceof ViewCompilationUnit)) {
17380
17661
  throw new Error(`AssertionError: must be compiling a component`);
@@ -17396,8 +17677,11 @@ function reifyCreateOperations(unit, ops) {
17396
17677
  break;
17397
17678
  case OpKind.Listener:
17398
17679
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
17399
- const reified = op.hostListener && op.isAnimationListener ? syntheticHostListener(op.name, listenerFn, op.sourceSpan) : listener(op.name, listenerFn, op.sourceSpan);
17400
- OpList.replace(op, reified);
17680
+ const eventTargetResolver = op.eventTarget ? GLOBAL_TARGET_RESOLVERS.get(op.eventTarget) : null;
17681
+ if (eventTargetResolver === void 0) {
17682
+ throw new Error(`AssertionError: unknown event target ${op.eventTarget}`);
17683
+ }
17684
+ OpList.replace(op, listener(op.name, listenerFn, eventTargetResolver, op.hostListener && op.isAnimationListener, op.sourceSpan));
17401
17685
  break;
17402
17686
  case OpKind.Variable:
17403
17687
  if (op.variable.name === null) {
@@ -17552,7 +17836,7 @@ function reifyUpdateOperations(_unit, ops) {
17552
17836
  if (op.isAnimationTrigger) {
17553
17837
  OpList.replace(op, syntheticHostProperty(op.name, op.expression, op.sourceSpan));
17554
17838
  } else {
17555
- OpList.replace(op, hostProperty(op.name, op.expression, op.sourceSpan));
17839
+ OpList.replace(op, hostProperty(op.name, op.expression, op.sanitizer, op.sourceSpan));
17556
17840
  }
17557
17841
  }
17558
17842
  break;
@@ -17630,8 +17914,6 @@ function reifyIrExpression(expr) {
17630
17914
  return pipeBind(expr.targetSlot.slot, expr.varOffset, expr.args);
17631
17915
  case ExpressionKind.PipeBindingVariadic:
17632
17916
  return pipeBindV(expr.targetSlot.slot, expr.varOffset, expr.args);
17633
- case ExpressionKind.SanitizerExpr:
17634
- return importExpr(sanitizerIdentifierMap.get(expr.fn));
17635
17917
  case ExpressionKind.SlotLiteralExpr:
17636
17918
  return literal(expr.slot.slot);
17637
17919
  default:
@@ -17691,6 +17973,28 @@ function removeI18nContexts(job) {
17691
17973
  }
17692
17974
  }
17693
17975
 
17976
+ // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/remove_unused_i18n_attrs.mjs
17977
+ function removeUnusedI18nAttributesOps(job) {
17978
+ for (const unit of job.units) {
17979
+ const ownersWithI18nExpressions = /* @__PURE__ */ new Set();
17980
+ for (const op of unit.update) {
17981
+ switch (op.kind) {
17982
+ case OpKind.I18nExpression:
17983
+ ownersWithI18nExpressions.add(op.i18nOwner);
17984
+ }
17985
+ }
17986
+ for (const op of unit.create) {
17987
+ switch (op.kind) {
17988
+ case OpKind.I18nAttributes:
17989
+ if (ownersWithI18nExpressions.has(op.xref)) {
17990
+ continue;
17991
+ }
17992
+ OpList.remove(op);
17993
+ }
17994
+ }
17995
+ }
17996
+ }
17997
+
17694
17998
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/repeater_derived_vars.mjs
17695
17999
  function generateRepeaterDerivedVars(job) {
17696
18000
  const repeaters = /* @__PURE__ */ new Map();
@@ -17803,8 +18107,9 @@ function resolveI18nElementPlaceholders(job) {
17803
18107
  }
17804
18108
  resolvePlaceholdersForView(job, job.root, i18nContexts, elements);
17805
18109
  }
17806
- function resolvePlaceholdersForView(job, unit, i18nContexts, elements) {
18110
+ function resolvePlaceholdersForView(job, unit, i18nContexts, elements, pendingStructuralDirective) {
17807
18111
  let currentOps = null;
18112
+ let pendingStructuralDirectiveCloses = /* @__PURE__ */ new Map();
17808
18113
  for (const op of unit.create) {
17809
18114
  switch (op.kind) {
17810
18115
  case OpKind.I18nStart:
@@ -17821,52 +18126,135 @@ function resolvePlaceholdersForView(job, unit, i18nContexts, elements) {
17821
18126
  if (currentOps === null) {
17822
18127
  throw Error("i18n tag placeholder should only occur inside an i18n block");
17823
18128
  }
17824
- const { startName, closeName } = op.i18nPlaceholder;
17825
- let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.OpenTag;
17826
- if (closeName === "") {
17827
- flags |= I18nParamValueFlags.CloseTag;
18129
+ recordElementStart(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18130
+ if (pendingStructuralDirective && op.i18nPlaceholder.closeName) {
18131
+ pendingStructuralDirectiveCloses.set(op.xref, pendingStructuralDirective);
17828
18132
  }
17829
- addParam(currentOps.i18nContext.params, startName, op.handle.slot, currentOps.i18nBlock.subTemplateIndex, flags);
18133
+ pendingStructuralDirective = void 0;
17830
18134
  }
17831
18135
  break;
17832
18136
  case OpKind.ElementEnd:
17833
18137
  const startOp = elements.get(op.xref);
17834
18138
  if (startOp && startOp.i18nPlaceholder !== void 0) {
17835
18139
  if (currentOps === null) {
17836
- throw Error("i18n tag placeholder should only occur inside an i18n block");
17837
- }
17838
- const { closeName } = startOp.i18nPlaceholder;
17839
- if (closeName !== "") {
17840
- addParam(currentOps.i18nContext.params, closeName, startOp.handle.slot, currentOps.i18nBlock.subTemplateIndex, I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag);
18140
+ throw Error("AssertionError: i18n tag placeholder should only occur inside an i18n block");
17841
18141
  }
18142
+ recordElementClose(startOp, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirectiveCloses.get(op.xref));
18143
+ pendingStructuralDirectiveCloses.delete(op.xref);
17842
18144
  }
17843
18145
  break;
17844
- case OpKind.Template:
18146
+ case OpKind.Projection:
17845
18147
  if (op.i18nPlaceholder !== void 0) {
17846
18148
  if (currentOps === null) {
17847
18149
  throw Error("i18n tag placeholder should only occur inside an i18n block");
17848
18150
  }
17849
- let startFlags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.OpenTag;
17850
- const subTemplateIndex = getSubTemplateIndexForTemplateTag(job, currentOps.i18nBlock, op);
17851
- const { startName, closeName } = op.i18nPlaceholder;
17852
- const isSelfClosing = closeName === "";
17853
- if (isSelfClosing) {
17854
- startFlags |= I18nParamValueFlags.CloseTag;
18151
+ recordElementStart(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18152
+ recordElementClose(op, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18153
+ pendingStructuralDirective = void 0;
18154
+ }
18155
+ break;
18156
+ case OpKind.Template:
18157
+ const view = job.views.get(op.xref);
18158
+ if (op.i18nPlaceholder === void 0) {
18159
+ resolvePlaceholdersForView(job, view, i18nContexts, elements);
18160
+ } else {
18161
+ if (currentOps === null) {
18162
+ throw Error("i18n tag placeholder should only occur inside an i18n block");
17855
18163
  }
17856
- addParam(currentOps.i18nContext.params, startName, op.handle.slot, subTemplateIndex, startFlags);
17857
- resolvePlaceholdersForView(job, job.views.get(op.xref), i18nContexts, elements);
17858
- if (!isSelfClosing) {
17859
- addParam(currentOps.i18nContext.params, closeName, op.handle.slot, subTemplateIndex, I18nParamValueFlags.TemplateTag | I18nParamValueFlags.CloseTag);
18164
+ if (op.templateKind === TemplateKind.Structural) {
18165
+ resolvePlaceholdersForView(job, view, i18nContexts, elements, op);
18166
+ } else {
18167
+ recordTemplateStart(job, view, op.handle.slot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18168
+ resolvePlaceholdersForView(job, view, i18nContexts, elements);
18169
+ recordTemplateClose(job, view, op.handle.slot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18170
+ pendingStructuralDirective = void 0;
17860
18171
  }
18172
+ }
18173
+ break;
18174
+ case OpKind.RepeaterCreate:
18175
+ if (pendingStructuralDirective !== void 0) {
18176
+ throw Error("AssertionError: Unexpected structural directive associated with @for block");
18177
+ }
18178
+ const forSlot = op.handle.slot + 1;
18179
+ const forView = job.views.get(op.xref);
18180
+ if (op.i18nPlaceholder === void 0) {
18181
+ resolvePlaceholdersForView(job, forView, i18nContexts, elements);
17861
18182
  } else {
17862
- resolvePlaceholdersForView(job, job.views.get(op.xref), i18nContexts, elements);
18183
+ if (currentOps === null) {
18184
+ throw Error("i18n tag placeholder should only occur inside an i18n block");
18185
+ }
18186
+ recordTemplateStart(job, forView, forSlot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18187
+ resolvePlaceholdersForView(job, forView, i18nContexts, elements);
18188
+ recordTemplateClose(job, forView, forSlot, op.i18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18189
+ pendingStructuralDirective = void 0;
18190
+ }
18191
+ if (op.emptyView !== null) {
18192
+ const emptySlot = op.handle.slot + 2;
18193
+ const emptyView = job.views.get(op.emptyView);
18194
+ if (op.emptyI18nPlaceholder === void 0) {
18195
+ resolvePlaceholdersForView(job, emptyView, i18nContexts, elements);
18196
+ } else {
18197
+ if (currentOps === null) {
18198
+ throw Error("i18n tag placeholder should only occur inside an i18n block");
18199
+ }
18200
+ recordTemplateStart(job, emptyView, emptySlot, op.emptyI18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18201
+ resolvePlaceholdersForView(job, emptyView, i18nContexts, elements);
18202
+ recordTemplateClose(job, emptyView, emptySlot, op.emptyI18nPlaceholder, currentOps.i18nContext, currentOps.i18nBlock, pendingStructuralDirective);
18203
+ pendingStructuralDirective = void 0;
18204
+ }
17863
18205
  }
17864
18206
  break;
17865
18207
  }
17866
18208
  }
17867
18209
  }
17868
- function getSubTemplateIndexForTemplateTag(job, i18nOp, op) {
17869
- for (const childOp of job.views.get(op.xref).create) {
18210
+ function recordElementStart(op, i18nContext, i18nBlock, structuralDirective) {
18211
+ const { startName, closeName } = op.i18nPlaceholder;
18212
+ let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.OpenTag;
18213
+ let value = op.handle.slot;
18214
+ if (structuralDirective !== void 0) {
18215
+ flags |= I18nParamValueFlags.TemplateTag;
18216
+ value = { element: value, template: structuralDirective.handle.slot };
18217
+ }
18218
+ if (!closeName) {
18219
+ flags |= I18nParamValueFlags.CloseTag;
18220
+ }
18221
+ addParam(i18nContext.params, startName, value, i18nBlock.subTemplateIndex, flags);
18222
+ }
18223
+ function recordElementClose(op, i18nContext, i18nBlock, structuralDirective) {
18224
+ const { closeName } = op.i18nPlaceholder;
18225
+ if (closeName) {
18226
+ let flags = I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag;
18227
+ let value = op.handle.slot;
18228
+ if (structuralDirective !== void 0) {
18229
+ flags |= I18nParamValueFlags.TemplateTag;
18230
+ value = { element: value, template: structuralDirective.handle.slot };
18231
+ }
18232
+ addParam(i18nContext.params, closeName, value, i18nBlock.subTemplateIndex, flags);
18233
+ }
18234
+ }
18235
+ function recordTemplateStart(job, view, slot, i18nPlaceholder, i18nContext, i18nBlock, structuralDirective) {
18236
+ let { startName, closeName } = i18nPlaceholder;
18237
+ let flags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.OpenTag;
18238
+ if (!closeName) {
18239
+ flags |= I18nParamValueFlags.CloseTag;
18240
+ }
18241
+ if (structuralDirective !== void 0) {
18242
+ addParam(i18nContext.params, startName, structuralDirective.handle.slot, i18nBlock.subTemplateIndex, flags);
18243
+ }
18244
+ addParam(i18nContext.params, startName, slot, getSubTemplateIndexForTemplateTag(job, i18nBlock, view), flags);
18245
+ }
18246
+ function recordTemplateClose(job, view, slot, i18nPlaceholder, i18nContext, i18nBlock, structuralDirective) {
18247
+ const { startName, closeName } = i18nPlaceholder;
18248
+ const flags = I18nParamValueFlags.TemplateTag | I18nParamValueFlags.CloseTag;
18249
+ if (closeName) {
18250
+ addParam(i18nContext.params, closeName, slot, getSubTemplateIndexForTemplateTag(job, i18nBlock, view), flags);
18251
+ if (structuralDirective !== void 0) {
18252
+ addParam(i18nContext.params, closeName, structuralDirective.handle.slot, i18nBlock.subTemplateIndex, flags);
18253
+ }
18254
+ }
18255
+ }
18256
+ function getSubTemplateIndexForTemplateTag(job, i18nOp, view) {
18257
+ for (const childOp of view.create) {
17870
18258
  if (childOp.kind === OpKind.I18nStart) {
17871
18259
  return childOp.subTemplateIndex;
17872
18260
  }
@@ -17882,6 +18270,7 @@ function addParam(params, placeholder, value, subTemplateIndex, flags) {
17882
18270
 
17883
18271
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_i18n_expression_placeholders.mjs
17884
18272
  function resolveI18nExpressionPlaceholders(job) {
18273
+ var _a2;
17885
18274
  const subTemplateIndicies = /* @__PURE__ */ new Map();
17886
18275
  const i18nContexts = /* @__PURE__ */ new Map();
17887
18276
  for (const unit of job.units) {
@@ -17897,12 +18286,13 @@ function resolveI18nExpressionPlaceholders(job) {
17897
18286
  }
17898
18287
  }
17899
18288
  const expressionIndices = /* @__PURE__ */ new Map();
18289
+ const referenceIndex = (op) => op.usage === I18nExpressionFor.I18nText ? op.i18nOwner : op.context;
17900
18290
  for (const unit of job.units) {
17901
18291
  for (const op of unit.update) {
17902
18292
  if (op.kind === OpKind.I18nExpression) {
17903
18293
  const i18nContext = i18nContexts.get(op.context);
17904
- const index = expressionIndices.get(op.target) || 0;
17905
- const subTemplateIndex = subTemplateIndicies.get(op.target);
18294
+ const index = expressionIndices.get(referenceIndex(op)) || 0;
18295
+ const subTemplateIndex = (_a2 = subTemplateIndicies.get(op.i18nOwner)) != null ? _a2 : null;
17906
18296
  const params = op.resolutionTime === I18nParamResolutionTime.Creation ? i18nContext.params : i18nContext.postprocessingParams;
17907
18297
  const values = params.get(op.i18nPlaceholder) || [];
17908
18298
  values.push({
@@ -17911,7 +18301,7 @@ function resolveI18nExpressionPlaceholders(job) {
17911
18301
  flags: I18nParamValueFlags.ExpressionIndex
17912
18302
  });
17913
18303
  params.set(op.i18nPlaceholder, values);
17914
- expressionIndices.set(op.target, index + 1);
18304
+ expressionIndices.set(referenceIndex(op), index + 1);
17915
18305
  }
17916
18306
  }
17917
18307
  }
@@ -18026,30 +18416,54 @@ function processLexicalScope2(unit, ops, savedView) {
18026
18416
  }
18027
18417
 
18028
18418
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/resolve_sanitizers.mjs
18029
- var sanitizers = /* @__PURE__ */ new Map([
18030
- [SecurityContext.HTML, SanitizerFn.Html],
18031
- [SecurityContext.SCRIPT, SanitizerFn.Script],
18032
- [SecurityContext.STYLE, SanitizerFn.Style],
18033
- [SecurityContext.URL, SanitizerFn.Url],
18034
- [SecurityContext.RESOURCE_URL, SanitizerFn.ResourceUrl]
18419
+ var sanitizerFns = /* @__PURE__ */ new Map([
18420
+ [SecurityContext.HTML, Identifiers.sanitizeHtml],
18421
+ [SecurityContext.RESOURCE_URL, Identifiers.sanitizeResourceUrl],
18422
+ [SecurityContext.SCRIPT, Identifiers.sanitizeScript],
18423
+ [SecurityContext.STYLE, Identifiers.sanitizeStyle],
18424
+ [SecurityContext.URL, Identifiers.sanitizeUrl]
18425
+ ]);
18426
+ var trustedValueFns = /* @__PURE__ */ new Map([
18427
+ [SecurityContext.HTML, Identifiers.trustConstantHtml],
18428
+ [SecurityContext.RESOURCE_URL, Identifiers.trustConstantResourceUrl]
18035
18429
  ]);
18036
18430
  function resolveSanitizers(job) {
18431
+ var _a2, _b2;
18037
18432
  for (const unit of job.units) {
18038
18433
  const elements = createOpXrefMap(unit);
18039
- let sanitizerFn;
18434
+ if (job.kind !== CompilationJobKind.Host) {
18435
+ for (const op of unit.create) {
18436
+ if (op.kind === OpKind.ExtractedAttribute) {
18437
+ const trustedValueFn = (_a2 = trustedValueFns.get(getOnlySecurityContext(op.securityContext))) != null ? _a2 : null;
18438
+ op.trustedValueFn = trustedValueFn !== null ? importExpr(trustedValueFn) : null;
18439
+ }
18440
+ }
18441
+ }
18040
18442
  for (const op of unit.update) {
18041
18443
  switch (op.kind) {
18042
18444
  case OpKind.Property:
18043
18445
  case OpKind.Attribute:
18044
- sanitizerFn = sanitizers.get(op.securityContext) || null;
18045
- op.sanitizer = sanitizerFn ? new SanitizerExpr(sanitizerFn) : null;
18446
+ case OpKind.HostProperty:
18447
+ let sanitizerFn = null;
18448
+ if (Array.isArray(op.securityContext) && op.securityContext.length === 2 && op.securityContext.indexOf(SecurityContext.URL) > -1 && op.securityContext.indexOf(SecurityContext.RESOURCE_URL) > -1) {
18449
+ sanitizerFn = Identifiers.sanitizeUrlOrResourceUrl;
18450
+ } else {
18451
+ sanitizerFn = (_b2 = sanitizerFns.get(getOnlySecurityContext(op.securityContext))) != null ? _b2 : null;
18452
+ }
18453
+ op.sanitizer = sanitizerFn !== null ? importExpr(sanitizerFn) : null;
18046
18454
  if (op.sanitizer === null) {
18047
- const ownerOp = elements.get(op.target);
18048
- if (ownerOp === void 0 || !isElementOrContainerOp(ownerOp)) {
18049
- throw Error("Property should have an element-like owner");
18455
+ let isIframe = false;
18456
+ if (job.kind === CompilationJobKind.Host || op.kind === OpKind.HostProperty) {
18457
+ isIframe = true;
18458
+ } else {
18459
+ const ownerOp = elements.get(op.target);
18460
+ if (ownerOp === void 0 || !isElementOrContainerOp(ownerOp)) {
18461
+ throw Error("Property should have an element-like owner");
18462
+ }
18463
+ isIframe = isIframeElement(ownerOp);
18050
18464
  }
18051
- if (isIframeElement(ownerOp) && isIframeSecuritySensitiveAttr(op.name)) {
18052
- op.sanitizer = new SanitizerExpr(SanitizerFn.IframeAttribute);
18465
+ if (isIframe && isIframeSecuritySensitiveAttr(op.name)) {
18466
+ op.sanitizer = importExpr(Identifiers.validateIframeAttribute);
18053
18467
  }
18054
18468
  }
18055
18469
  break;
@@ -18061,6 +18475,15 @@ function isIframeElement(op) {
18061
18475
  var _a2;
18062
18476
  return op.kind === OpKind.ElementStart && ((_a2 = op.tag) == null ? void 0 : _a2.toLowerCase()) === "iframe";
18063
18477
  }
18478
+ function getOnlySecurityContext(securityContext) {
18479
+ if (Array.isArray(securityContext)) {
18480
+ if (securityContext.length > 1) {
18481
+ throw Error(`AssertionError: Ambiguous security context`);
18482
+ }
18483
+ return securityContext[0] || SecurityContext.NONE;
18484
+ }
18485
+ return securityContext;
18486
+ }
18064
18487
 
18065
18488
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/phases/save_restore_view.mjs
18066
18489
  function saveAndRestoreView(job) {
@@ -18708,12 +19131,12 @@ var phases = [
18708
19131
  { kind: CompilationJobKind.Tmpl, fn: removeContentSelectors },
18709
19132
  { kind: CompilationJobKind.Host, fn: parseHostStyleProperties },
18710
19133
  { kind: CompilationJobKind.Tmpl, fn: emitNamespaceChanges },
18711
- { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
18712
- { kind: CompilationJobKind.Both, fn: specializeBindings },
18713
19134
  { kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
18714
19135
  { kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
18715
- { kind: CompilationJobKind.Tmpl, fn: createI18nContexts },
19136
+ { kind: CompilationJobKind.Both, fn: specializeStyleBindings },
19137
+ { kind: CompilationJobKind.Both, fn: specializeBindings },
18716
19138
  { kind: CompilationJobKind.Both, fn: extractAttributes },
19139
+ { kind: CompilationJobKind.Tmpl, fn: createI18nContexts },
18717
19140
  { kind: CompilationJobKind.Both, fn: parseExtractedStyles },
18718
19141
  { kind: CompilationJobKind.Tmpl, fn: removeEmptyBindings },
18719
19142
  { kind: CompilationJobKind.Both, fn: collapseSingletonInterpolations },
@@ -18721,14 +19144,17 @@ var phases = [
18721
19144
  { kind: CompilationJobKind.Tmpl, fn: generateConditionalExpressions },
18722
19145
  { kind: CompilationJobKind.Tmpl, fn: createPipes },
18723
19146
  { kind: CompilationJobKind.Tmpl, fn: configureDeferInstructions },
18724
- { kind: CompilationJobKind.Tmpl, fn: extractI18nText },
19147
+ { kind: CompilationJobKind.Tmpl, fn: convertI18nText },
19148
+ { kind: CompilationJobKind.Tmpl, fn: convertI18nBindings },
19149
+ { kind: CompilationJobKind.Tmpl, fn: removeUnusedI18nAttributesOps },
19150
+ { kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
18725
19151
  { kind: CompilationJobKind.Tmpl, fn: applyI18nExpressions },
18726
19152
  { kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
18727
19153
  { kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
18728
19154
  { kind: CompilationJobKind.Tmpl, fn: generateProjectionDefs },
18729
19155
  { kind: CompilationJobKind.Tmpl, fn: generateVariables },
18730
19156
  { kind: CompilationJobKind.Tmpl, fn: saveAndRestoreView },
18731
- { kind: CompilationJobKind.Tmpl, fn: deleteAnyCasts },
19157
+ { kind: CompilationJobKind.Both, fn: deleteAnyCasts },
18732
19158
  { kind: CompilationJobKind.Both, fn: resolveDollarEvent },
18733
19159
  { kind: CompilationJobKind.Tmpl, fn: generateRepeaterDerivedVars },
18734
19160
  { kind: CompilationJobKind.Tmpl, fn: generateTrackVariables },
@@ -18736,7 +19162,7 @@ var phases = [
18736
19162
  { kind: CompilationJobKind.Tmpl, fn: resolveDeferTargetNames },
18737
19163
  { kind: CompilationJobKind.Tmpl, fn: optimizeTrackFns },
18738
19164
  { kind: CompilationJobKind.Both, fn: resolveContexts },
18739
- { kind: CompilationJobKind.Tmpl, fn: resolveSanitizers },
19165
+ { kind: CompilationJobKind.Both, fn: resolveSanitizers },
18740
19166
  { kind: CompilationJobKind.Tmpl, fn: liftLocalRefs },
18741
19167
  { kind: CompilationJobKind.Both, fn: generateNullishCoalesceExpressions },
18742
19168
  { kind: CompilationJobKind.Both, fn: expandSafeReads },
@@ -18751,7 +19177,6 @@ var phases = [
18751
19177
  { kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
18752
19178
  { kind: CompilationJobKind.Tmpl, fn: collectConstExpressions },
18753
19179
  { kind: CompilationJobKind.Both, fn: collectElementConsts },
18754
- { kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
18755
19180
  { kind: CompilationJobKind.Tmpl, fn: removeI18nContexts },
18756
19181
  { kind: CompilationJobKind.Both, fn: countVariables },
18757
19182
  { kind: CompilationJobKind.Tmpl, fn: generateAdvance },
@@ -18869,6 +19294,8 @@ function emitHostBindingFunction(job) {
18869
19294
 
18870
19295
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/template/pipeline/src/ingest.mjs
18871
19296
  var compatibilityMode = CompatibilityMode.TemplateDefinitionBuilder;
19297
+ var domSchema = new DomElementSchemaRegistry();
19298
+ var NG_TEMPLATE_TAG_NAME = "ng-template";
18872
19299
  function ingestComponent(componentName, template2, constantPool, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta) {
18873
19300
  const job = new ComponentCompilationJob(componentName, constantPool, compatibilityMode, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta);
18874
19301
  ingestNodes(job.root, template2);
@@ -18878,50 +19305,55 @@ function ingestHostBinding(input, bindingParser, constantPool) {
18878
19305
  var _a2, _b2, _c2;
18879
19306
  const job = new HostBindingCompilationJob(input.componentName, constantPool, compatibilityMode);
18880
19307
  for (const property2 of (_a2 = input.properties) != null ? _a2 : []) {
18881
- ingestHostProperty(job, property2, false);
19308
+ let bindingKind = BindingKind.Property;
19309
+ if (property2.name.startsWith("attr.")) {
19310
+ property2.name = property2.name.substring("attr.".length);
19311
+ bindingKind = BindingKind.Attribute;
19312
+ }
19313
+ if (property2.isAnimation) {
19314
+ bindingKind = BindingKind.Animation;
19315
+ }
19316
+ const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, property2.name, bindingKind === BindingKind.Attribute).filter((context) => context !== SecurityContext.NONE);
19317
+ ingestHostProperty(job, property2, bindingKind, false, securityContexts);
18882
19318
  }
18883
19319
  for (const [name, expr] of (_b2 = Object.entries(input.attributes)) != null ? _b2 : []) {
18884
- ingestHostAttribute(job, name, expr);
19320
+ const securityContexts = bindingParser.calcPossibleSecurityContexts(input.componentSelector, name, true).filter((context) => context !== SecurityContext.NONE);
19321
+ ingestHostAttribute(job, name, expr, securityContexts);
18885
19322
  }
18886
19323
  for (const event of (_c2 = input.events) != null ? _c2 : []) {
18887
19324
  ingestHostEvent(job, event);
18888
19325
  }
18889
19326
  return job;
18890
19327
  }
18891
- function ingestHostProperty(job, property2, isTextAttribute) {
19328
+ function ingestHostProperty(job, property2, bindingKind, isTextAttribute, securityContexts) {
18892
19329
  let expression;
18893
19330
  const ast = property2.expression.ast;
18894
19331
  if (ast instanceof Interpolation) {
18895
- expression = new Interpolation2(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)));
19332
+ expression = new Interpolation2(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)), []);
18896
19333
  } else {
18897
19334
  expression = convertAst(ast, job, property2.sourceSpan);
18898
19335
  }
18899
- let bindingKind = BindingKind.Property;
18900
- if (property2.name.startsWith("attr.")) {
18901
- property2.name = property2.name.substring("attr.".length);
18902
- bindingKind = BindingKind.Attribute;
18903
- }
18904
- if (property2.isAnimation) {
18905
- bindingKind = BindingKind.Animation;
18906
- }
18907
- job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, SecurityContext.NONE, isTextAttribute, false, property2.sourceSpan));
19336
+ job.root.update.push(createBindingOp(job.root.xref, bindingKind, property2.name, expression, null, securityContexts, isTextAttribute, false, null, null, property2.sourceSpan));
18908
19337
  }
18909
- function ingestHostAttribute(job, name, value) {
19338
+ function ingestHostAttribute(job, name, value, securityContexts) {
18910
19339
  const attrBinding = createBindingOp(
18911
19340
  job.root.xref,
18912
19341
  BindingKind.Attribute,
18913
19342
  name,
18914
19343
  value,
18915
19344
  null,
18916
- SecurityContext.NONE,
19345
+ securityContexts,
18917
19346
  true,
18918
19347
  false,
19348
+ null,
19349
+ null,
18919
19350
  null
18920
19351
  );
18921
19352
  job.root.update.push(attrBinding);
18922
19353
  }
18923
19354
  function ingestHostEvent(job, event) {
18924
- const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, event.targetOrPhase, true, event.sourceSpan);
19355
+ const [phase, target] = event.type === 0 ? [null, event.targetOrPhase] : [event.targetOrPhase, null];
19356
+ const eventBinding = createListenerOp(job.root.xref, new SlotHandle(), event.name, null, [], phase, target, true, event.sourceSpan);
18925
19357
  eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
18926
19358
  job.root.create.push(eventBinding);
18927
19359
  }
@@ -18961,14 +19393,17 @@ function ingestElement(unit, element2) {
18961
19393
  const [namespaceKey, elementName] = splitNsName(element2.name);
18962
19394
  const startOp = createElementStartOp(elementName, id, namespaceForKey(namespaceKey), element2.i18n instanceof TagPlaceholder ? element2.i18n : void 0, element2.startSourceSpan);
18963
19395
  unit.create.push(startOp);
18964
- ingestBindings(unit, startOp, element2);
19396
+ ingestElementBindings(unit, startOp, element2);
18965
19397
  ingestReferences(startOp, element2);
19398
+ let i18nBlockId = null;
19399
+ if (element2.i18n instanceof Message) {
19400
+ i18nBlockId = unit.job.allocateXrefId();
19401
+ unit.create.push(createI18nStartOp(i18nBlockId, element2.i18n));
19402
+ }
18966
19403
  ingestNodes(unit, element2.children);
18967
19404
  const endOp = createElementEndOp(id, (_a2 = element2.endSourceSpan) != null ? _a2 : element2.startSourceSpan);
18968
19405
  unit.create.push(endOp);
18969
- if (element2.i18n instanceof Message) {
18970
- const i18nBlockId = unit.job.allocateXrefId();
18971
- OpList.insertAfter(createI18nStartOp(i18nBlockId, element2.i18n), startOp);
19406
+ if (i18nBlockId !== null) {
18972
19407
  OpList.insertBefore(createI18nEndOp(i18nBlockId), endOp);
18973
19408
  }
18974
19409
  }
@@ -18985,24 +19420,30 @@ function ingestTemplate(unit, tmpl) {
18985
19420
  const i18nPlaceholder = tmpl.i18n instanceof TagPlaceholder ? tmpl.i18n : void 0;
18986
19421
  const namespace = namespaceForKey(namespacePrefix);
18987
19422
  const functionNameSuffix = tagNameWithoutNamespace === null ? "" : prefixWithNamespace(tagNameWithoutNamespace, namespace);
18988
- const tplOp = createTemplateOp(childView.xref, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
18989
- unit.create.push(tplOp);
18990
- ingestBindings(unit, tplOp, tmpl);
18991
- ingestReferences(tplOp, tmpl);
19423
+ const templateKind = isPlainTemplate(tmpl) ? TemplateKind.NgTemplate : TemplateKind.Structural;
19424
+ const templateOp = createTemplateOp(childView.xref, templateKind, tagNameWithoutNamespace, functionNameSuffix, namespace, i18nPlaceholder, tmpl.startSourceSpan);
19425
+ unit.create.push(templateOp);
19426
+ ingestTemplateBindings(unit, templateOp, tmpl, templateKind);
19427
+ ingestReferences(templateOp, tmpl);
18992
19428
  ingestNodes(childView, tmpl.children);
18993
19429
  for (const { name, value } of tmpl.variables) {
18994
19430
  childView.contextVariables.set(name, value !== "" ? value : "$implicit");
18995
19431
  }
18996
- if (isPlainTemplate(tmpl) && tmpl.i18n instanceof Message) {
19432
+ if (templateKind === TemplateKind.NgTemplate && tmpl.i18n instanceof Message) {
18997
19433
  const id = unit.job.allocateXrefId();
18998
19434
  OpList.insertAfter(createI18nStartOp(id, tmpl.i18n), childView.create.head);
18999
19435
  OpList.insertBefore(createI18nEndOp(id), childView.create.tail);
19000
19436
  }
19001
19437
  }
19002
19438
  function ingestContent(unit, content) {
19003
- const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.sourceSpan);
19439
+ if (content.i18n !== void 0 && !(content.i18n instanceof TagPlaceholder)) {
19440
+ throw Error(`Unhandled i18n metadata type for element: ${content.i18n.constructor.name}`);
19441
+ }
19442
+ const attrs = content.attributes.flatMap((a) => [a.name, a.value]);
19443
+ const op = createProjectionOp(unit.job.allocateXrefId(), content.selector, content.i18n, attrs, content.sourceSpan);
19004
19444
  for (const attr of content.attributes) {
19005
- ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, BindingFlags.TextValue);
19445
+ const securityContext = domSchema.securityContext(content.name, attr.name, true);
19446
+ unit.update.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19006
19447
  }
19007
19448
  unit.create.push(op);
19008
19449
  }
@@ -19030,9 +19471,10 @@ function ingestBoundText(unit, text2, i18nPlaceholders) {
19030
19471
  const textXref = unit.job.allocateXrefId();
19031
19472
  unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
19032
19473
  const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
19033
- unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan))), i18nPlaceholders, text2.sourceSpan));
19474
+ unit.update.push(createInterpolateTextOp(textXref, new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan)), i18nPlaceholders), text2.sourceSpan));
19034
19475
  }
19035
19476
  function ingestIfBlock(unit, ifBlock) {
19477
+ var _a2;
19036
19478
  let firstXref = null;
19037
19479
  let firstSlotHandle = null;
19038
19480
  let conditions = [];
@@ -19046,14 +19488,21 @@ function ingestIfBlock(unit, ifBlock) {
19046
19488
  if (ifCase.expressionAlias !== null) {
19047
19489
  cView.contextVariables.set(ifCase.expressionAlias.name, CTX_REF);
19048
19490
  }
19049
- const tmplOp = createTemplateOp(cView.xref, tagName, "Conditional", Namespace.HTML, void 0, ifCase.sourceSpan);
19050
- unit.create.push(tmplOp);
19491
+ let ifCaseI18nMeta = void 0;
19492
+ if (ifCase.i18n !== void 0) {
19493
+ if (!(ifCase.i18n instanceof BlockPlaceholder)) {
19494
+ throw Error(`Unhandled i18n metadata type for if block: ${(_a2 = ifCase.i18n) == null ? void 0 : _a2.constructor.name}`);
19495
+ }
19496
+ ifCaseI18nMeta = ifCase.i18n;
19497
+ }
19498
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, tagName, "Conditional", Namespace.HTML, ifCaseI18nMeta, ifCase.sourceSpan);
19499
+ unit.create.push(templateOp);
19051
19500
  if (firstXref === null) {
19052
19501
  firstXref = cView.xref;
19053
- firstSlotHandle = tmplOp.handle;
19502
+ firstSlotHandle = templateOp.handle;
19054
19503
  }
19055
19504
  const caseExpr = ifCase.expression ? convertAst(ifCase.expression, unit.job, null) : null;
19056
- const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, tmplOp.xref, tmplOp.handle, ifCase.expressionAlias);
19505
+ const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, templateOp.xref, templateOp.handle, ifCase.expressionAlias);
19057
19506
  conditions.push(conditionalCaseExpr);
19058
19507
  ingestNodes(cView, ifCase.children);
19059
19508
  }
@@ -19061,54 +19510,65 @@ function ingestIfBlock(unit, ifBlock) {
19061
19510
  unit.update.push(conditional2);
19062
19511
  }
19063
19512
  function ingestSwitchBlock(unit, switchBlock) {
19513
+ var _a2;
19064
19514
  let firstXref = null;
19065
19515
  let firstSlotHandle = null;
19066
19516
  let conditions = [];
19067
19517
  for (const switchCase of switchBlock.cases) {
19068
19518
  const cView = unit.job.allocateView(unit.xref);
19069
- const tmplOp = createTemplateOp(cView.xref, null, "Case", Namespace.HTML, void 0, switchCase.sourceSpan);
19070
- unit.create.push(tmplOp);
19519
+ let switchCaseI18nMeta = void 0;
19520
+ if (switchCase.i18n !== void 0) {
19521
+ if (!(switchCase.i18n instanceof BlockPlaceholder)) {
19522
+ throw Error(`Unhandled i18n metadata type for switch block: ${(_a2 = switchCase.i18n) == null ? void 0 : _a2.constructor.name}`);
19523
+ }
19524
+ switchCaseI18nMeta = switchCase.i18n;
19525
+ }
19526
+ const templateOp = createTemplateOp(cView.xref, TemplateKind.Block, null, "Case", Namespace.HTML, switchCaseI18nMeta, switchCase.sourceSpan);
19527
+ unit.create.push(templateOp);
19071
19528
  if (firstXref === null) {
19072
19529
  firstXref = cView.xref;
19073
- firstSlotHandle = tmplOp.handle;
19530
+ firstSlotHandle = templateOp.handle;
19074
19531
  }
19075
19532
  const caseExpr = switchCase.expression ? convertAst(switchCase.expression, unit.job, switchBlock.startSourceSpan) : null;
19076
- const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, tmplOp.xref, tmplOp.handle);
19533
+ const conditionalCaseExpr = new ConditionalCaseExpr(caseExpr, templateOp.xref, templateOp.handle);
19077
19534
  conditions.push(conditionalCaseExpr);
19078
19535
  ingestNodes(cView, switchCase.children);
19079
19536
  }
19080
19537
  const conditional2 = createConditionalOp(firstXref, firstSlotHandle, convertAst(switchBlock.expression, unit.job, null), conditions, switchBlock.sourceSpan);
19081
19538
  unit.update.push(conditional2);
19082
19539
  }
19083
- function ingestDeferView(unit, suffix, children, sourceSpan) {
19540
+ function ingestDeferView(unit, suffix, i18nMeta, children, sourceSpan) {
19541
+ if (i18nMeta !== void 0 && !(i18nMeta instanceof BlockPlaceholder)) {
19542
+ throw Error("Unhandled i18n metadata type for defer block");
19543
+ }
19084
19544
  if (children === void 0) {
19085
19545
  return null;
19086
19546
  }
19087
19547
  const secondaryView = unit.job.allocateView(unit.xref);
19088
19548
  ingestNodes(secondaryView, children);
19089
- const templateOp = createTemplateOp(secondaryView.xref, null, `Defer${suffix}`, Namespace.HTML, void 0, sourceSpan);
19549
+ const templateOp = createTemplateOp(secondaryView.xref, TemplateKind.Block, null, `Defer${suffix}`, Namespace.HTML, i18nMeta, sourceSpan);
19090
19550
  unit.create.push(templateOp);
19091
19551
  return templateOp;
19092
19552
  }
19093
19553
  function ingestDeferBlock(unit, deferBlock) {
19094
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
19554
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
19095
19555
  const blockMeta = unit.job.deferBlocksMeta.get(deferBlock);
19096
19556
  if (blockMeta === void 0) {
19097
19557
  throw new Error(`AssertionError: unable to find metadata for deferred block`);
19098
19558
  }
19099
- const main = ingestDeferView(unit, "", deferBlock.children, deferBlock.sourceSpan);
19100
- const loading = ingestDeferView(unit, "Loading", (_a2 = deferBlock.loading) == null ? void 0 : _a2.children, (_b2 = deferBlock.loading) == null ? void 0 : _b2.sourceSpan);
19101
- const placeholder = ingestDeferView(unit, "Placeholder", (_c2 = deferBlock.placeholder) == null ? void 0 : _c2.children, (_d2 = deferBlock.placeholder) == null ? void 0 : _d2.sourceSpan);
19102
- const error2 = ingestDeferView(unit, "Error", (_e2 = deferBlock.error) == null ? void 0 : _e2.children, (_f2 = deferBlock.error) == null ? void 0 : _f2.sourceSpan);
19559
+ const main = ingestDeferView(unit, "", deferBlock.i18n, deferBlock.children, deferBlock.sourceSpan);
19560
+ const loading = ingestDeferView(unit, "Loading", (_a2 = deferBlock.loading) == null ? void 0 : _a2.i18n, (_b2 = deferBlock.loading) == null ? void 0 : _b2.children, (_c2 = deferBlock.loading) == null ? void 0 : _c2.sourceSpan);
19561
+ const placeholder = ingestDeferView(unit, "Placeholder", (_d2 = deferBlock.placeholder) == null ? void 0 : _d2.i18n, (_e2 = deferBlock.placeholder) == null ? void 0 : _e2.children, (_f2 = deferBlock.placeholder) == null ? void 0 : _f2.sourceSpan);
19562
+ const error2 = ingestDeferView(unit, "Error", (_g = deferBlock.error) == null ? void 0 : _g.i18n, (_h = deferBlock.error) == null ? void 0 : _h.children, (_i = deferBlock.error) == null ? void 0 : _i.sourceSpan);
19103
19563
  const deferXref = unit.job.allocateXrefId();
19104
19564
  const deferOp = createDeferOp(deferXref, main.xref, main.handle, blockMeta, deferBlock.sourceSpan);
19105
- deferOp.placeholderView = (_g = placeholder == null ? void 0 : placeholder.xref) != null ? _g : null;
19106
- deferOp.placeholderSlot = (_h = placeholder == null ? void 0 : placeholder.handle) != null ? _h : null;
19107
- deferOp.loadingSlot = (_i = loading == null ? void 0 : loading.handle) != null ? _i : null;
19108
- deferOp.errorSlot = (_j = error2 == null ? void 0 : error2.handle) != null ? _j : null;
19109
- deferOp.placeholderMinimumTime = (_l = (_k = deferBlock.placeholder) == null ? void 0 : _k.minimumTime) != null ? _l : null;
19110
- deferOp.loadingMinimumTime = (_n = (_m = deferBlock.loading) == null ? void 0 : _m.minimumTime) != null ? _n : null;
19111
- deferOp.loadingAfterTime = (_p = (_o = deferBlock.loading) == null ? void 0 : _o.afterTime) != null ? _p : null;
19565
+ deferOp.placeholderView = (_j = placeholder == null ? void 0 : placeholder.xref) != null ? _j : null;
19566
+ deferOp.placeholderSlot = (_k = placeholder == null ? void 0 : placeholder.handle) != null ? _k : null;
19567
+ deferOp.loadingSlot = (_l = loading == null ? void 0 : loading.handle) != null ? _l : null;
19568
+ deferOp.errorSlot = (_m = error2 == null ? void 0 : error2.handle) != null ? _m : null;
19569
+ deferOp.placeholderMinimumTime = (_o = (_n = deferBlock.placeholder) == null ? void 0 : _n.minimumTime) != null ? _o : null;
19570
+ deferOp.loadingMinimumTime = (_q = (_p = deferBlock.loading) == null ? void 0 : _p.minimumTime) != null ? _q : null;
19571
+ deferOp.loadingAfterTime = (_s = (_r = deferBlock.loading) == null ? void 0 : _r.afterTime) != null ? _s : null;
19112
19572
  unit.create.push(deferOp);
19113
19573
  let prefetch = false;
19114
19574
  let deferOnOps = [];
@@ -19172,17 +19632,12 @@ function ingestDeferBlock(unit, deferBlock) {
19172
19632
  unit.update.push(deferWhenOps);
19173
19633
  }
19174
19634
  function ingestIcu(unit, icu) {
19175
- var _a2, _b2;
19635
+ var _a2;
19176
19636
  if (icu.i18n instanceof Message && isSingleI18nIcu(icu.i18n)) {
19177
19637
  const xref = unit.job.allocateXrefId();
19178
19638
  const icuNode = icu.i18n.nodes[0];
19179
19639
  unit.create.push(createIcuStartOp(xref, icu.i18n, icuFromI18nMessage(icu.i18n).name, null));
19180
- const expressionPlaceholder = (_a2 = icuNode.expressionPlaceholder) == null ? void 0 : _a2.trimEnd();
19181
- if (expressionPlaceholder === void 0 || icu.vars[expressionPlaceholder] === void 0) {
19182
- throw Error("ICU should have a text binding");
19183
- }
19184
- ingestBoundText(unit, icu.vars[expressionPlaceholder], [expressionPlaceholder]);
19185
- for (const [placeholder, text2] of Object.entries(icu.placeholders)) {
19640
+ for (const [placeholder, text2] of Object.entries(__spreadValues(__spreadValues({}, icu.vars), icu.placeholders))) {
19186
19641
  if (text2 instanceof BoundText) {
19187
19642
  ingestBoundText(unit, text2, [placeholder]);
19188
19643
  } else {
@@ -19191,11 +19646,11 @@ function ingestIcu(unit, icu) {
19191
19646
  }
19192
19647
  unit.create.push(createIcuEndOp(xref));
19193
19648
  } else {
19194
- throw Error(`Unhandled i18n metadata type for ICU: ${(_b2 = icu.i18n) == null ? void 0 : _b2.constructor.name}`);
19649
+ throw Error(`Unhandled i18n metadata type for ICU: ${(_a2 = icu.i18n) == null ? void 0 : _a2.constructor.name}`);
19195
19650
  }
19196
19651
  }
19197
19652
  function ingestForBlock(unit, forBlock) {
19198
- var _a2;
19653
+ var _a2, _b2, _c2;
19199
19654
  const repeaterView = unit.job.allocateView(unit.xref);
19200
19655
  const createRepeaterAlias = (ident, repeaterVar) => {
19201
19656
  repeaterView.aliases.add({
@@ -19229,8 +19684,16 @@ function ingestForBlock(unit, forBlock) {
19229
19684
  $odd: forBlock.contextVariables.$odd.name,
19230
19685
  $implicit: forBlock.item.name
19231
19686
  };
19687
+ if (forBlock.i18n !== void 0 && !(forBlock.i18n instanceof BlockPlaceholder)) {
19688
+ throw Error("AssertionError: Unhandled i18n metadata type or @for");
19689
+ }
19690
+ if (((_a2 = forBlock.empty) == null ? void 0 : _a2.i18n) !== void 0 && !(forBlock.empty.i18n instanceof BlockPlaceholder)) {
19691
+ throw Error("AssertionError: Unhandled i18n metadata type or @empty");
19692
+ }
19693
+ const i18nPlaceholder = forBlock.i18n;
19694
+ const emptyI18nPlaceholder = (_b2 = forBlock.empty) == null ? void 0 : _b2.i18n;
19232
19695
  const tagName = ingestControlFlowInsertionPoint(unit, repeaterView.xref, forBlock);
19233
- const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_a2 = emptyView == null ? void 0 : emptyView.xref) != null ? _a2 : null, tagName, track, varNames, forBlock.sourceSpan);
19696
+ const repeaterCreate2 = createRepeaterCreateOp(repeaterView.xref, (_c2 = emptyView == null ? void 0 : emptyView.xref) != null ? _c2 : null, tagName, track, varNames, i18nPlaceholder, emptyI18nPlaceholder, forBlock.sourceSpan);
19234
19697
  unit.create.push(repeaterCreate2);
19235
19698
  const expression = convertAst(forBlock.expression, unit.job, convertSourceSpan(forBlock.expression.span, forBlock.sourceSpan));
19236
19699
  const repeater2 = createRepeaterOp(repeaterCreate2.xref, repeaterCreate2.handle, expression, forBlock.sourceSpan);
@@ -19266,6 +19729,15 @@ function convertAst(ast, job, baseSourceSpan) {
19266
19729
  }
19267
19730
  } else if (ast instanceof LiteralPrimitive) {
19268
19731
  return literal(ast.value, void 0, convertSourceSpan(ast.span, baseSourceSpan));
19732
+ } else if (ast instanceof Unary) {
19733
+ switch (ast.operator) {
19734
+ case "+":
19735
+ return new UnaryOperatorExpr(UnaryOperator.Plus, convertAst(ast.expr, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
19736
+ case "-":
19737
+ return new UnaryOperatorExpr(UnaryOperator.Minus, convertAst(ast.expr, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
19738
+ default:
19739
+ throw new Error(`AssertionError: unknown unary operator ${ast.operator}`);
19740
+ }
19269
19741
  } else if (ast instanceof Binary) {
19270
19742
  const operator = BINARY_OPERATORS.get(ast.operation);
19271
19743
  if (operator === void 0) {
@@ -19303,104 +19775,134 @@ function convertAst(ast, job, baseSourceSpan) {
19303
19775
  return new SafeInvokeFunctionExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.args.map((a) => convertAst(a, job, baseSourceSpan)));
19304
19776
  } else if (ast instanceof EmptyExpr) {
19305
19777
  return new EmptyExpr2(convertSourceSpan(ast.span, baseSourceSpan));
19778
+ } else if (ast instanceof PrefixNot) {
19779
+ return not(convertAst(ast.expression, job, baseSourceSpan), convertSourceSpan(ast.span, baseSourceSpan));
19306
19780
  } else {
19307
19781
  throw new Error(`Unhandled expression type "${ast.constructor.name}" in file "${baseSourceSpan == null ? void 0 : baseSourceSpan.start.file.url}"`);
19308
19782
  }
19309
19783
  }
19784
+ function convertAstWithInterpolation(job, value, i18nMeta) {
19785
+ var _a2, _b2;
19786
+ let expression;
19787
+ if (value instanceof Interpolation) {
19788
+ 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 : {}));
19789
+ } else if (value instanceof AST) {
19790
+ expression = convertAst(value, job, null);
19791
+ } else {
19792
+ expression = literal(value);
19793
+ }
19794
+ return expression;
19795
+ }
19796
+ var BINDING_KINDS = /* @__PURE__ */ new Map([
19797
+ [0, BindingKind.Property],
19798
+ [1, BindingKind.Attribute],
19799
+ [2, BindingKind.ClassName],
19800
+ [3, BindingKind.StyleProperty],
19801
+ [4, BindingKind.Animation]
19802
+ ]);
19310
19803
  function isPlainTemplate(tmpl) {
19311
19804
  var _a2;
19312
- return splitNsName((_a2 = tmpl.tagName) != null ? _a2 : "")[1] === "ng-template";
19313
- }
19314
- function ingestBindings(unit, op, element2) {
19315
- let flags = BindingFlags.None;
19316
- if (element2 instanceof Template) {
19317
- flags |= BindingFlags.OnNgTemplateElement;
19318
- if (element2 instanceof Template && isPlainTemplate(element2)) {
19319
- flags |= BindingFlags.BindingTargetsTemplate;
19320
- }
19321
- const templateAttrFlags = flags | BindingFlags.BindingTargetsTemplate | BindingFlags.IsStructuralTemplateAttribute;
19322
- for (const attr of element2.templateAttrs) {
19323
- if (attr instanceof TextAttribute) {
19324
- ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, templateAttrFlags | BindingFlags.TextValue);
19325
- } else {
19326
- ingestBinding(unit, op.xref, attr.name, attr.value, attr.type, attr.unit, attr.securityContext, attr.sourceSpan, templateAttrFlags);
19327
- }
19328
- }
19805
+ return splitNsName((_a2 = tmpl.tagName) != null ? _a2 : "")[1] === NG_TEMPLATE_TAG_NAME;
19806
+ }
19807
+ function asMessage(i18nMeta) {
19808
+ if (i18nMeta == null) {
19809
+ return null;
19329
19810
  }
19811
+ if (!(i18nMeta instanceof Message)) {
19812
+ throw Error(`Expected i18n meta to be a Message, but got: ${i18nMeta.constructor.name}`);
19813
+ }
19814
+ return i18nMeta;
19815
+ }
19816
+ function ingestElementBindings(unit, op, element2) {
19817
+ var _a2;
19818
+ let bindings = new Array();
19330
19819
  for (const attr of element2.attributes) {
19331
- ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, flags | BindingFlags.TextValue);
19820
+ const securityContext = domSchema.securityContext(element2.name, attr.name, true);
19821
+ bindings.push(createBindingOp(op.xref, BindingKind.Attribute, attr.name, convertAstWithInterpolation(unit.job, attr.value, attr.i18n), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19332
19822
  }
19333
19823
  for (const input of element2.inputs) {
19334
- ingestBinding(unit, op.xref, input.name, input.value, input.type, input.unit, input.securityContext, input.sourceSpan, flags);
19824
+ bindings.push(createBindingOp(op.xref, BINDING_KINDS.get(input.type), input.name, convertAstWithInterpolation(unit.job, astOf(input.value), input.i18n), input.unit, input.securityContext, false, false, null, (_a2 = asMessage(input.i18n)) != null ? _a2 : null, input.sourceSpan));
19335
19825
  }
19826
+ unit.create.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.ExtractedAttribute));
19827
+ unit.update.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.Binding));
19336
19828
  for (const output of element2.outputs) {
19337
- let listenerOp;
19338
- if (output.type === 1) {
19339
- if (output.phase === null) {
19340
- throw Error("Animation listener should have a phase");
19341
- }
19342
- }
19343
- if (element2 instanceof Template && !isPlainTemplate(element2)) {
19344
- unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null));
19345
- continue;
19346
- }
19347
- listenerOp = createListenerOp(op.xref, op.handle, output.name, op.tag, output.phase, false, output.sourceSpan);
19348
- let handlerExprs;
19349
- let handler = output.handler;
19350
- if (handler instanceof ASTWithSource) {
19351
- handler = handler.ast;
19829
+ if (output.type === 1 && output.phase === null) {
19830
+ throw Error("Animation listener should have a phase");
19352
19831
  }
19353
- if (handler instanceof Chain) {
19354
- handlerExprs = handler.expressions;
19832
+ unit.create.push(createListenerOp(op.xref, op.handle, output.name, op.tag, makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, output.target, false, output.sourceSpan));
19833
+ }
19834
+ if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
19835
+ unit.create.push(createI18nAttributesOp(unit.job.allocateXrefId(), new SlotHandle(), op.xref));
19836
+ }
19837
+ }
19838
+ function ingestTemplateBindings(unit, op, template2, templateKind) {
19839
+ let bindings = new Array();
19840
+ for (const attr of template2.templateAttrs) {
19841
+ if (attr instanceof TextAttribute) {
19842
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
19843
+ bindings.push(createTemplateBinding(unit, op.xref, 1, attr.name, attr.value, null, securityContext, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
19355
19844
  } else {
19356
- handlerExprs = [handler];
19845
+ bindings.push(createTemplateBinding(unit, op.xref, attr.type, attr.name, astOf(attr.value), attr.unit, attr.securityContext, true, templateKind, asMessage(attr.i18n), attr.sourceSpan));
19846
+ }
19847
+ }
19848
+ for (const attr of template2.attributes) {
19849
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
19850
+ bindings.push(createTemplateBinding(unit, op.xref, 1, attr.name, attr.value, null, securityContext, false, templateKind, asMessage(attr.i18n), attr.sourceSpan));
19851
+ }
19852
+ for (const input of template2.inputs) {
19853
+ bindings.push(createTemplateBinding(unit, op.xref, input.type, input.name, astOf(input.value), input.unit, input.securityContext, false, templateKind, asMessage(input.i18n), input.sourceSpan));
19854
+ }
19855
+ unit.create.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.ExtractedAttribute));
19856
+ unit.update.push(bindings.filter((b) => (b == null ? void 0 : b.kind) === OpKind.Binding));
19857
+ for (const output of template2.outputs) {
19858
+ if (output.type === 1 && output.phase === null) {
19859
+ throw Error("Animation listener should have a phase");
19357
19860
  }
19358
- if (handlerExprs.length === 0) {
19359
- throw new Error("Expected listener to have non-empty expression list.");
19861
+ if (templateKind === TemplateKind.NgTemplate) {
19862
+ unit.create.push(createListenerOp(op.xref, op.handle, output.name, op.tag, makeListenerHandlerOps(unit, output.handler, output.handlerSpan), output.phase, output.target, false, output.sourceSpan));
19360
19863
  }
19361
- const expressions = handlerExprs.map((expr) => convertAst(expr, unit.job, output.handlerSpan));
19362
- const returnExpr = expressions.pop();
19363
- for (const expr of expressions) {
19364
- const stmtOp = createStatementOp(new ExpressionStatement(expr, expr.sourceSpan));
19365
- listenerOp.handlerOps.push(stmtOp);
19864
+ if (templateKind === TemplateKind.Structural && output.type !== 1) {
19865
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, output.name, false);
19866
+ unit.create.push(createExtractedAttributeOp(op.xref, BindingKind.Property, output.name, null, null, null, securityContext));
19366
19867
  }
19367
- listenerOp.handlerOps.push(createStatementOp(new ReturnStatement(returnExpr, returnExpr.sourceSpan)));
19368
- unit.create.push(listenerOp);
19868
+ }
19869
+ if (bindings.some((b) => b == null ? void 0 : b.i18nMessage) !== null) {
19870
+ unit.create.push(createI18nAttributesOp(unit.job.allocateXrefId(), new SlotHandle(), op.xref));
19369
19871
  }
19370
19872
  }
19371
- var BINDING_KINDS = /* @__PURE__ */ new Map([
19372
- [0, BindingKind.Property],
19373
- [1, BindingKind.Attribute],
19374
- [2, BindingKind.ClassName],
19375
- [3, BindingKind.StyleProperty],
19376
- [4, BindingKind.Animation]
19377
- ]);
19378
- var BindingFlags;
19379
- (function(BindingFlags2) {
19380
- BindingFlags2[BindingFlags2["None"] = 0] = "None";
19381
- BindingFlags2[BindingFlags2["TextValue"] = 1] = "TextValue";
19382
- BindingFlags2[BindingFlags2["BindingTargetsTemplate"] = 2] = "BindingTargetsTemplate";
19383
- BindingFlags2[BindingFlags2["IsStructuralTemplateAttribute"] = 4] = "IsStructuralTemplateAttribute";
19384
- BindingFlags2[BindingFlags2["OnNgTemplateElement"] = 8] = "OnNgTemplateElement";
19385
- })(BindingFlags || (BindingFlags = {}));
19386
- function ingestBinding(view, xref, name, value, type, unit, securityContext, sourceSpan, flags) {
19387
- if (value instanceof ASTWithSource) {
19388
- value = value.ast;
19873
+ function createTemplateBinding(view, xref, type, name, value, unit, securityContext, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan) {
19874
+ const isTextBinding = typeof value === "string";
19875
+ if (templateKind === TemplateKind.Structural) {
19876
+ if (!isStructuralTemplateAttribute && (type === 0 || type === 2 || type === 3)) {
19877
+ return createExtractedAttributeOp(xref, BindingKind.Property, name, null, null, i18nMessage, securityContext);
19878
+ }
19879
+ if (!isTextBinding && (type === 1 || type === 4)) {
19880
+ return null;
19881
+ }
19389
19882
  }
19390
- if (flags & BindingFlags.OnNgTemplateElement && !(flags & BindingFlags.BindingTargetsTemplate) && type === 0) {
19391
- view.create.push(createExtractedAttributeOp(xref, BindingKind.Property, name, null));
19392
- return;
19883
+ let bindingType = BINDING_KINDS.get(type);
19884
+ if (templateKind === TemplateKind.NgTemplate) {
19885
+ if (type === 2 || type === 3 || type === 1 && !isTextBinding) {
19886
+ bindingType = BindingKind.Property;
19887
+ }
19393
19888
  }
19394
- let expression;
19395
- if (value instanceof Interpolation) {
19396
- expression = new Interpolation2(value.strings, value.expressions.map((expr) => convertAst(expr, view.job, null)));
19397
- } else if (value instanceof AST) {
19398
- expression = convertAst(value, view.job, null);
19399
- } else {
19400
- expression = value;
19889
+ return createBindingOp(xref, bindingType, name, convertAstWithInterpolation(view.job, value, i18nMessage), unit, securityContext, isTextBinding, isStructuralTemplateAttribute, templateKind, i18nMessage, sourceSpan);
19890
+ }
19891
+ function makeListenerHandlerOps(unit, handler, handlerSpan) {
19892
+ handler = astOf(handler);
19893
+ const handlerOps = new Array();
19894
+ let handlerExprs = handler instanceof Chain ? handler.expressions : [handler];
19895
+ if (handlerExprs.length === 0) {
19896
+ throw new Error("Expected listener to have non-empty expression list.");
19401
19897
  }
19402
- const kind = BINDING_KINDS.get(type);
19403
- view.update.push(createBindingOp(xref, kind, name, expression, unit, securityContext, !!(flags & BindingFlags.TextValue), !!(flags & BindingFlags.IsStructuralTemplateAttribute), sourceSpan));
19898
+ const expressions = handlerExprs.map((expr) => convertAst(expr, unit.job, handlerSpan));
19899
+ const returnExpr = expressions.pop();
19900
+ handlerOps.push(...expressions.map((e) => createStatementOp(new ExpressionStatement(e, e.sourceSpan))));
19901
+ handlerOps.push(createStatementOp(new ReturnStatement(returnExpr, returnExpr.sourceSpan)));
19902
+ return handlerOps;
19903
+ }
19904
+ function astOf(ast) {
19905
+ return ast instanceof ASTWithSource ? ast.ast : ast;
19404
19906
  }
19405
19907
  function ingestReferences(op, element2) {
19406
19908
  assertIsArray(op.localRefs);
@@ -19440,10 +19942,11 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
19440
19942
  }
19441
19943
  if (root !== null) {
19442
19944
  for (const attr of root.attributes) {
19443
- ingestBinding(unit, xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, BindingFlags.TextValue);
19945
+ const securityContext = domSchema.securityContext(NG_TEMPLATE_TAG_NAME, attr.name, true);
19946
+ unit.update.push(createBindingOp(xref, BindingKind.Attribute, attr.name, literal(attr.value), null, securityContext, true, false, null, asMessage(attr.i18n), attr.sourceSpan));
19444
19947
  }
19445
19948
  const tagName = root instanceof Element ? root.name : root.tagName;
19446
- return tagName === "ng-template" ? null : tagName;
19949
+ return tagName === NG_TEMPLATE_TAG_NAME ? null : tagName;
19447
19950
  }
19448
19951
  return null;
19449
19952
  }
@@ -21529,17 +22032,17 @@ function serializePlaceholderValue(value) {
21529
22032
  var NG_CONTENT_SELECT_ATTR2 = "select";
21530
22033
  var NG_PROJECT_AS_ATTR_NAME = "ngProjectAs";
21531
22034
  var EVENT_BINDING_SCOPE_GLOBALS = /* @__PURE__ */ new Set(["$event"]);
21532
- var NG_TEMPLATE_TAG_NAME = "ng-template";
21533
- var GLOBAL_TARGET_RESOLVERS = /* @__PURE__ */ new Map([["window", Identifiers.resolveWindow], ["document", Identifiers.resolveDocument], ["body", Identifiers.resolveBody]]);
22035
+ var NG_TEMPLATE_TAG_NAME2 = "ng-template";
22036
+ var GLOBAL_TARGET_RESOLVERS2 = /* @__PURE__ */ new Map([["window", Identifiers.resolveWindow], ["document", Identifiers.resolveDocument], ["body", Identifiers.resolveBody]]);
21534
22037
  var LEADING_TRIVIA_CHARS = [" ", "\n", "\r", " "];
21535
22038
  function renderFlagCheckIfStmt(flags, statements) {
21536
22039
  return ifStmt(variable(RENDER_FLAGS).bitwiseAnd(literal(flags), null, false), statements);
21537
22040
  }
21538
22041
  function prepareEventListenerParameters(eventAst, handlerName = null, scope = null) {
21539
22042
  const { type, name, target, phase, handler } = eventAst;
21540
- if (target && !GLOBAL_TARGET_RESOLVERS.has(target)) {
22043
+ if (target && !GLOBAL_TARGET_RESOLVERS2.has(target)) {
21541
22044
  throw new Error(`Unexpected global target '${target}' defined for '${name}' event.
21542
- Supported list of global targets: ${Array.from(GLOBAL_TARGET_RESOLVERS.keys())}.`);
22045
+ Supported list of global targets: ${Array.from(GLOBAL_TARGET_RESOLVERS2.keys())}.`);
21543
22046
  }
21544
22047
  const eventArgumentName = "$event";
21545
22048
  const implicitReceiverAccesses = /* @__PURE__ */ new Set();
@@ -21572,7 +22075,7 @@ function prepareEventListenerParameters(eventAst, handlerName = null, scope = nu
21572
22075
  if (target) {
21573
22076
  params.push(
21574
22077
  literal(false),
21575
- importExpr(GLOBAL_TARGET_RESOLVERS.get(target))
22078
+ importExpr(GLOBAL_TARGET_RESOLVERS2.get(target))
21576
22079
  );
21577
22080
  }
21578
22081
  return params;
@@ -22118,10 +22621,10 @@ var TemplateDefinitionBuilder = class {
22118
22621
  var _a2;
22119
22622
  const tagNameWithoutNamespace = template2.tagName ? splitNsName(template2.tagName)[1] : template2.tagName;
22120
22623
  const contextNameSuffix = template2.tagName ? "_" + sanitizeIdentifier(template2.tagName) : "";
22121
- const attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME, template2.attributes, template2.inputs, template2.outputs, void 0, template2.templateAttrs);
22624
+ const attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME2, template2.attributes, template2.inputs, template2.outputs, void 0, template2.templateAttrs);
22122
22625
  const templateIndex = this.createEmbeddedTemplateFn(tagNameWithoutNamespace, template2.children, contextNameSuffix, template2.sourceSpan, template2.variables, attrsExprs, template2.references, template2.i18n);
22123
22626
  this.templatePropertyBindings(templateIndex, template2.templateAttrs);
22124
- if (tagNameWithoutNamespace === NG_TEMPLATE_TAG_NAME) {
22627
+ if (tagNameWithoutNamespace === NG_TEMPLATE_TAG_NAME2) {
22125
22628
  const [i18nInputs, inputs] = partitionArray(template2.inputs, hasI18nMeta);
22126
22629
  if (i18nInputs.length > 0) {
22127
22630
  this.i18nAttributesInstruction(templateIndex, i18nInputs, (_a2 = template2.startSourceSpan) != null ? _a2 : template2.sourceSpan);
@@ -22362,8 +22865,8 @@ var TemplateDefinitionBuilder = class {
22362
22865
  }
22363
22866
  if (root !== null) {
22364
22867
  const name = root instanceof Element ? root.name : root.tagName;
22365
- tagName = name === NG_TEMPLATE_TAG_NAME ? null : name;
22366
- attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME, root.attributes, root.inputs, []);
22868
+ tagName = name === NG_TEMPLATE_TAG_NAME2 ? null : name;
22869
+ attrsExprs = this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME2, root.attributes, root.inputs, []);
22367
22870
  }
22368
22871
  return { tagName, attrsExprs };
22369
22872
  }
@@ -22985,21 +23488,6 @@ var TrackByBindingScope = class extends BindingScope {
22985
23488
  return this.componentAccessCount;
22986
23489
  }
22987
23490
  };
22988
- function createCssSelector(elementName, attributes) {
22989
- const cssSelector = new CssSelector();
22990
- const elementNameNoNs = splitNsName(elementName)[1];
22991
- cssSelector.setElement(elementNameNoNs);
22992
- Object.getOwnPropertyNames(attributes).forEach((name) => {
22993
- const nameNoNs = splitNsName(name)[1];
22994
- const value = attributes[name];
22995
- cssSelector.addAttribute(nameNoNs, value);
22996
- if (name.toLowerCase() === "class") {
22997
- const classes = value.trim().split(/\s+/);
22998
- classes.forEach((className) => cssSelector.addClassName(className));
22999
- }
23000
- });
23001
- return cssSelector;
23002
- }
23003
23491
  function getNgProjectAsLiteral(attribute2) {
23004
23492
  const parsedR3Selector = parseSelectorToR3Selector(attribute2.value)[0];
23005
23493
  return [literal(5), asLiteral(parsedR3Selector)];
@@ -23538,6 +24026,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23538
24026
  }
23539
24027
  const hostJob = ingestHostBinding({
23540
24028
  componentName: name,
24029
+ componentSelector: selector,
23541
24030
  properties: bindings,
23542
24031
  events: eventBindings,
23543
24032
  attributes: hostBindingsMetadata.attributes
@@ -23550,6 +24039,8 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23550
24039
  }
23551
24040
  return emitHostBindingFunction(hostJob);
23552
24041
  }
24042
+ let bindingId = 0;
24043
+ const getNextBindingId = () => `${bindingId++}`;
23553
24044
  const bindingContext = variable(CONTEXT_NAME);
23554
24045
  const styleBuilder = new StylingBuilder(bindingContext);
23555
24046
  const { styleAttr, classAttr } = hostBindingsMetadata.specialAttributes;
@@ -23599,7 +24090,7 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23599
24090
  const syntheticHostBindings = [];
23600
24091
  for (const binding of allOtherBindings) {
23601
24092
  const value = binding.expression.visit(getValueConverter());
23602
- const bindingExpr = bindingFn(bindingContext, value);
24093
+ const bindingExpr = bindingFn(bindingContext, value, getNextBindingId);
23603
24094
  const { bindingName, instruction, isAttribute } = getBindingNameAndInstruction(binding);
23604
24095
  const securityContexts = bindingParser.calcPossibleSecurityContexts(selector, bindingName, isAttribute).filter((context) => context !== SecurityContext.NONE);
23605
24096
  let sanitizerFn = null;
@@ -23644,9 +24135,11 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23644
24135
  styleBuilder.buildUpdateLevelInstructions(getValueConverter()).forEach((instruction) => {
23645
24136
  for (const call2 of instruction.calls) {
23646
24137
  totalHostVarsCount += Math.max(call2.allocateBindingSlots - MIN_STYLING_BINDING_SLOTS_REQUIRED, 0);
24138
+ const { params, stmts } = convertStylingCall(call2, bindingContext, bindingFn, getNextBindingId);
24139
+ updateVariables.push(...stmts);
23647
24140
  updateInstructions.push({
23648
24141
  reference: instruction.reference,
23649
- paramsOrFn: convertStylingCall(call2, bindingContext, bindingFn),
24142
+ paramsOrFn: params,
23650
24143
  span: null
23651
24144
  });
23652
24145
  }
@@ -23668,11 +24161,19 @@ function createHostBindingsFunction(hostBindingsMetadata, typeSourceSpan, bindin
23668
24161
  }
23669
24162
  return null;
23670
24163
  }
23671
- function bindingFn(implicit, value) {
23672
- return convertPropertyBinding(null, implicit, value, "b");
24164
+ function bindingFn(implicit, value, getNextBindingIdFn) {
24165
+ return convertPropertyBinding(null, implicit, value, getNextBindingIdFn());
23673
24166
  }
23674
- function convertStylingCall(call2, bindingContext, bindingFn2) {
23675
- return call2.params((value) => bindingFn2(bindingContext, value).currValExpr);
24167
+ function convertStylingCall(call2, bindingContext, bindingFn2, getNextBindingIdFn) {
24168
+ const stmts = [];
24169
+ const params = call2.params((value) => {
24170
+ const result = bindingFn2(bindingContext, value, getNextBindingIdFn);
24171
+ if (Array.isArray(result.stmts) && result.stmts.length > 0) {
24172
+ stmts.push(...result.stmts);
24173
+ }
24174
+ return result.currValExpr;
24175
+ });
24176
+ return { params, stmts };
23676
24177
  }
23677
24178
  function getBindingNameAndInstruction(binding) {
23678
24179
  let bindingName = binding.name;
@@ -23987,13 +24488,13 @@ var DirectiveBinder = class {
23987
24488
  template2.forEach((node) => node.visit(this));
23988
24489
  }
23989
24490
  visitElement(element2) {
23990
- this.visitElementOrTemplate(element2.name, element2);
24491
+ this.visitElementOrTemplate(element2);
23991
24492
  }
23992
24493
  visitTemplate(template2) {
23993
- this.visitElementOrTemplate("ng-template", template2);
24494
+ this.visitElementOrTemplate(template2);
23994
24495
  }
23995
- visitElementOrTemplate(elementName, node) {
23996
- const cssSelector = createCssSelector(elementName, getAttrsForDirectiveMatching(node));
24496
+ visitElementOrTemplate(node) {
24497
+ const cssSelector = createCssSelectorFromNode(node);
23997
24498
  const directives = [];
23998
24499
  this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
23999
24500
  if (directives.length > 0) {
@@ -24981,7 +25482,7 @@ function publishFacade(global) {
24981
25482
  }
24982
25483
 
24983
25484
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
24984
- var VERSION2 = new Version("17.0.5");
25485
+ var VERSION2 = new Version("17.0.7");
24985
25486
 
24986
25487
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
24987
25488
  var _VisitorMode;