@angular/material 17.0.0-next.5 → 17.0.0-next.6

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 (256) hide show
  1. package/_index.scss +3 -4
  2. package/dialog/index.d.ts +22 -14
  3. package/esm2022/autocomplete/autocomplete-origin.mjs +4 -4
  4. package/esm2022/autocomplete/autocomplete-trigger.mjs +16 -6
  5. package/esm2022/autocomplete/autocomplete.mjs +6 -6
  6. package/esm2022/autocomplete/module.mjs +4 -4
  7. package/esm2022/badge/badge-module.mjs +4 -4
  8. package/esm2022/badge/badge.mjs +6 -6
  9. package/esm2022/bottom-sheet/bottom-sheet-container.mjs +5 -5
  10. package/esm2022/bottom-sheet/bottom-sheet-module.mjs +4 -4
  11. package/esm2022/bottom-sheet/bottom-sheet.mjs +5 -5
  12. package/esm2022/button/button-base.mjs +9 -9
  13. package/esm2022/button/button.mjs +10 -10
  14. package/esm2022/button/fab.mjs +21 -21
  15. package/esm2022/button/icon-button.mjs +10 -10
  16. package/esm2022/button/module.mjs +4 -4
  17. package/esm2022/button-toggle/button-toggle-module.mjs +4 -4
  18. package/esm2022/button-toggle/button-toggle.mjs +11 -11
  19. package/esm2022/card/card.mjs +45 -45
  20. package/esm2022/card/module.mjs +4 -4
  21. package/esm2022/checkbox/checkbox-required-validator.mjs +3 -3
  22. package/esm2022/checkbox/checkbox.mjs +6 -6
  23. package/esm2022/checkbox/module.mjs +8 -8
  24. package/esm2022/chips/chip-action.mjs +6 -6
  25. package/esm2022/chips/chip-edit-input.mjs +5 -5
  26. package/esm2022/chips/chip-grid.mjs +6 -6
  27. package/esm2022/chips/chip-icons.mjs +9 -9
  28. package/esm2022/chips/chip-input.mjs +6 -6
  29. package/esm2022/chips/chip-listbox.mjs +3 -3
  30. package/esm2022/chips/chip-option.mjs +3 -3
  31. package/esm2022/chips/chip-row.mjs +6 -6
  32. package/esm2022/chips/chip-set.mjs +6 -6
  33. package/esm2022/chips/chip.mjs +6 -6
  34. package/esm2022/chips/module.mjs +4 -4
  35. package/esm2022/core/common-behaviors/common-module.mjs +6 -6
  36. package/esm2022/core/datetime/index.mjs +8 -8
  37. package/esm2022/core/datetime/native-date-adapter.mjs +5 -5
  38. package/esm2022/core/error/error-options.mjs +6 -6
  39. package/esm2022/core/line/line.mjs +7 -7
  40. package/esm2022/core/option/index.mjs +4 -4
  41. package/esm2022/core/option/optgroup.mjs +6 -6
  42. package/esm2022/core/option/option.mjs +6 -6
  43. package/esm2022/core/private/ripple-loader.mjs +4 -4
  44. package/esm2022/core/ripple/index.mjs +4 -4
  45. package/esm2022/core/ripple/ripple.mjs +6 -6
  46. package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox-module.mjs +4 -4
  47. package/esm2022/core/selection/pseudo-checkbox/pseudo-checkbox.mjs +6 -6
  48. package/esm2022/core/version.mjs +1 -1
  49. package/esm2022/datepicker/calendar-body.mjs +5 -5
  50. package/esm2022/datepicker/calendar.mjs +11 -11
  51. package/esm2022/datepicker/date-range-input-parts.mjs +15 -15
  52. package/esm2022/datepicker/date-range-input.mjs +6 -6
  53. package/esm2022/datepicker/date-range-picker.mjs +3 -3
  54. package/esm2022/datepicker/date-range-selection-strategy.mjs +4 -4
  55. package/esm2022/datepicker/date-selection-model.mjs +12 -12
  56. package/esm2022/datepicker/datepicker-actions.mjs +13 -13
  57. package/esm2022/datepicker/datepicker-base.mjs +11 -11
  58. package/esm2022/datepicker/datepicker-input-base.mjs +6 -6
  59. package/esm2022/datepicker/datepicker-input.mjs +6 -6
  60. package/esm2022/datepicker/datepicker-intl.mjs +3 -3
  61. package/esm2022/datepicker/datepicker-module.mjs +4 -4
  62. package/esm2022/datepicker/datepicker-toggle.mjs +9 -9
  63. package/esm2022/datepicker/datepicker.mjs +3 -3
  64. package/esm2022/datepicker/month-view.mjs +6 -6
  65. package/esm2022/datepicker/multi-year-view.mjs +6 -6
  66. package/esm2022/datepicker/year-view.mjs +6 -6
  67. package/esm2022/dialog/dialog-container.mjs +8 -7
  68. package/esm2022/dialog/dialog-content-directives.mjs +21 -17
  69. package/esm2022/dialog/dialog.mjs +26 -11
  70. package/esm2022/dialog/module.mjs +18 -26
  71. package/esm2022/divider/divider-module.mjs +4 -4
  72. package/esm2022/divider/divider.mjs +3 -3
  73. package/esm2022/expansion/accordion.mjs +3 -3
  74. package/esm2022/expansion/expansion-module.mjs +4 -4
  75. package/esm2022/expansion/expansion-panel-content.mjs +5 -5
  76. package/esm2022/expansion/expansion-panel-header.mjs +12 -12
  77. package/esm2022/expansion/expansion-panel.mjs +9 -9
  78. package/esm2022/form-field/directives/error.mjs +6 -6
  79. package/esm2022/form-field/directives/floating-label.mjs +5 -5
  80. package/esm2022/form-field/directives/hint.mjs +3 -3
  81. package/esm2022/form-field/directives/label.mjs +3 -3
  82. package/esm2022/form-field/directives/line-ripple.mjs +4 -4
  83. package/esm2022/form-field/directives/notched-outline.mjs +5 -5
  84. package/esm2022/form-field/directives/prefix.mjs +3 -3
  85. package/esm2022/form-field/directives/suffix.mjs +3 -3
  86. package/esm2022/form-field/form-field-control.mjs +3 -3
  87. package/esm2022/form-field/form-field.mjs +6 -6
  88. package/esm2022/form-field/module.mjs +4 -4
  89. package/esm2022/grid-list/grid-list-module.mjs +4 -4
  90. package/esm2022/grid-list/grid-list.mjs +6 -6
  91. package/esm2022/grid-list/grid-tile.mjs +19 -19
  92. package/esm2022/icon/icon-module.mjs +4 -4
  93. package/esm2022/icon/icon-registry.mjs +5 -5
  94. package/esm2022/icon/icon.mjs +6 -6
  95. package/esm2022/icon/testing/fake-icon-registry.mjs +7 -7
  96. package/esm2022/input/input.mjs +6 -6
  97. package/esm2022/input/module.mjs +4 -4
  98. package/esm2022/list/action-list.mjs +3 -3
  99. package/esm2022/list/list-base.mjs +9 -9
  100. package/esm2022/list/list-item-sections.mjs +22 -22
  101. package/esm2022/list/list-module.mjs +4 -4
  102. package/esm2022/list/list-option.mjs +6 -6
  103. package/esm2022/list/list.mjs +9 -9
  104. package/esm2022/list/nav-list.mjs +3 -3
  105. package/esm2022/list/selection-list.mjs +5 -5
  106. package/esm2022/list/subheader.mjs +3 -3
  107. package/esm2022/menu/menu-content.mjs +5 -5
  108. package/esm2022/menu/menu-item.mjs +6 -6
  109. package/esm2022/menu/menu-trigger.mjs +6 -6
  110. package/esm2022/menu/menu.mjs +6 -6
  111. package/esm2022/menu/module.mjs +4 -4
  112. package/esm2022/paginator/module.mjs +4 -4
  113. package/esm2022/paginator/paginator-intl.mjs +3 -3
  114. package/esm2022/paginator/paginator.mjs +6 -6
  115. package/esm2022/progress-bar/module.mjs +4 -4
  116. package/esm2022/progress-bar/progress-bar.mjs +6 -6
  117. package/esm2022/progress-spinner/module.mjs +4 -4
  118. package/esm2022/progress-spinner/progress-spinner.mjs +6 -6
  119. package/esm2022/radio/module.mjs +4 -4
  120. package/esm2022/radio/radio.mjs +10 -10
  121. package/esm2022/select/module.mjs +4 -4
  122. package/esm2022/select/select.mjs +9 -9
  123. package/esm2022/sidenav/drawer.mjs +16 -16
  124. package/esm2022/sidenav/sidenav-module.mjs +4 -4
  125. package/esm2022/sidenav/sidenav.mjs +11 -11
  126. package/esm2022/slide-toggle/module.mjs +8 -8
  127. package/esm2022/slide-toggle/slide-toggle-required-validator.mjs +3 -3
  128. package/esm2022/slide-toggle/slide-toggle.mjs +6 -6
  129. package/esm2022/slider/module.mjs +4 -4
  130. package/esm2022/slider/slider-input.mjs +11 -11
  131. package/esm2022/slider/slider-thumb.mjs +6 -6
  132. package/esm2022/slider/slider.mjs +6 -6
  133. package/esm2022/snack-bar/module.mjs +4 -4
  134. package/esm2022/snack-bar/simple-snack-bar.mjs +5 -5
  135. package/esm2022/snack-bar/snack-bar-container.mjs +5 -5
  136. package/esm2022/snack-bar/snack-bar-content.mjs +9 -9
  137. package/esm2022/snack-bar/snack-bar.mjs +5 -5
  138. package/esm2022/sort/sort-header-intl.mjs +3 -3
  139. package/esm2022/sort/sort-header.mjs +6 -6
  140. package/esm2022/sort/sort-module.mjs +4 -4
  141. package/esm2022/sort/sort.mjs +6 -6
  142. package/esm2022/stepper/step-content.mjs +4 -4
  143. package/esm2022/stepper/step-header.mjs +5 -5
  144. package/esm2022/stepper/step-label.mjs +3 -3
  145. package/esm2022/stepper/stepper-button.mjs +6 -6
  146. package/esm2022/stepper/stepper-icon.mjs +5 -5
  147. package/esm2022/stepper/stepper-intl.mjs +3 -3
  148. package/esm2022/stepper/stepper-module.mjs +4 -4
  149. package/esm2022/stepper/stepper.mjs +11 -11
  150. package/esm2022/table/cell.mjs +21 -21
  151. package/esm2022/table/module.mjs +4 -4
  152. package/esm2022/table/row.mjs +21 -21
  153. package/esm2022/table/table.mjs +6 -6
  154. package/esm2022/table/text-column.mjs +3 -3
  155. package/esm2022/tabs/module.mjs +4 -4
  156. package/esm2022/tabs/paginated-tab-header.mjs +6 -6
  157. package/esm2022/tabs/tab-body.mjs +11 -11
  158. package/esm2022/tabs/tab-content.mjs +4 -4
  159. package/esm2022/tabs/tab-group.mjs +6 -6
  160. package/esm2022/tabs/tab-header.mjs +6 -6
  161. package/esm2022/tabs/tab-label-wrapper.mjs +4 -4
  162. package/esm2022/tabs/tab-label.mjs +5 -5
  163. package/esm2022/tabs/tab-nav-bar/tab-nav-bar.mjs +21 -19
  164. package/esm2022/tabs/tab.mjs +6 -6
  165. package/esm2022/toolbar/toolbar-module.mjs +4 -4
  166. package/esm2022/toolbar/toolbar.mjs +9 -9
  167. package/esm2022/tooltip/module.mjs +4 -4
  168. package/esm2022/tooltip/tooltip.mjs +11 -11
  169. package/esm2022/tree/node.mjs +14 -14
  170. package/esm2022/tree/outlet.mjs +5 -5
  171. package/esm2022/tree/padding.mjs +3 -3
  172. package/esm2022/tree/toggle.mjs +3 -3
  173. package/esm2022/tree/tree-module.mjs +4 -4
  174. package/esm2022/tree/tree.mjs +3 -3
  175. package/fesm2022/autocomplete.mjs +29 -19
  176. package/fesm2022/autocomplete.mjs.map +1 -1
  177. package/fesm2022/badge.mjs +9 -9
  178. package/fesm2022/badge.mjs.map +1 -1
  179. package/fesm2022/bottom-sheet.mjs +14 -14
  180. package/fesm2022/button-toggle.mjs +14 -14
  181. package/fesm2022/button-toggle.mjs.map +1 -1
  182. package/fesm2022/button.mjs +52 -52
  183. package/fesm2022/button.mjs.map +1 -1
  184. package/fesm2022/card.mjs +48 -48
  185. package/fesm2022/card.mjs.map +1 -1
  186. package/fesm2022/checkbox.mjs +16 -16
  187. package/fesm2022/checkbox.mjs.map +1 -1
  188. package/fesm2022/chips.mjs +54 -54
  189. package/fesm2022/chips.mjs.map +1 -1
  190. package/fesm2022/core.mjs +69 -69
  191. package/fesm2022/core.mjs.map +1 -1
  192. package/fesm2022/datepicker.mjs +118 -118
  193. package/fesm2022/datepicker.mjs.map +1 -1
  194. package/fesm2022/dialog.mjs +67 -56
  195. package/fesm2022/dialog.mjs.map +1 -1
  196. package/fesm2022/divider.mjs +7 -7
  197. package/fesm2022/expansion.mjs +31 -31
  198. package/fesm2022/expansion.mjs.map +1 -1
  199. package/fesm2022/form-field.mjs +41 -41
  200. package/fesm2022/form-field.mjs.map +1 -1
  201. package/fesm2022/grid-list.mjs +27 -27
  202. package/fesm2022/grid-list.mjs.map +1 -1
  203. package/fesm2022/icon/testing.mjs +7 -7
  204. package/fesm2022/icon.mjs +14 -14
  205. package/fesm2022/icon.mjs.map +1 -1
  206. package/fesm2022/input.mjs +9 -9
  207. package/fesm2022/input.mjs.map +1 -1
  208. package/fesm2022/list.mjs +60 -60
  209. package/fesm2022/list.mjs.map +1 -1
  210. package/fesm2022/menu.mjs +24 -24
  211. package/fesm2022/menu.mjs.map +1 -1
  212. package/fesm2022/paginator.mjs +12 -12
  213. package/fesm2022/paginator.mjs.map +1 -1
  214. package/fesm2022/progress-bar.mjs +9 -9
  215. package/fesm2022/progress-bar.mjs.map +1 -1
  216. package/fesm2022/progress-spinner.mjs +9 -9
  217. package/fesm2022/progress-spinner.mjs.map +1 -1
  218. package/fesm2022/radio.mjs +13 -13
  219. package/fesm2022/radio.mjs.map +1 -1
  220. package/fesm2022/select.mjs +12 -12
  221. package/fesm2022/select.mjs.map +1 -1
  222. package/fesm2022/sidenav.mjs +30 -30
  223. package/fesm2022/sidenav.mjs.map +1 -1
  224. package/fesm2022/slide-toggle.mjs +16 -16
  225. package/fesm2022/slide-toggle.mjs.map +1 -1
  226. package/fesm2022/slider.mjs +24 -24
  227. package/fesm2022/slider.mjs.map +1 -1
  228. package/fesm2022/snack-bar.mjs +27 -27
  229. package/fesm2022/snack-bar.mjs.map +1 -1
  230. package/fesm2022/sort.mjs +17 -17
  231. package/fesm2022/sort.mjs.map +1 -1
  232. package/fesm2022/stepper.mjs +38 -38
  233. package/fesm2022/stepper.mjs.map +1 -1
  234. package/fesm2022/table.mjs +55 -55
  235. package/fesm2022/tabs.mjs +67 -65
  236. package/fesm2022/tabs.mjs.map +1 -1
  237. package/fesm2022/toolbar.mjs +12 -12
  238. package/fesm2022/toolbar.mjs.map +1 -1
  239. package/fesm2022/tooltip.mjs +14 -14
  240. package/fesm2022/tooltip.mjs.map +1 -1
  241. package/fesm2022/tree.mjs +31 -31
  242. package/fesm2022/tree.mjs.map +1 -1
  243. package/list/_list-theme.scss +5 -0
  244. package/package.json +2 -2
  245. package/prebuilt-themes/deeppurple-amber.css +1 -1
  246. package/prebuilt-themes/indigo-pink.css +1 -1
  247. package/prebuilt-themes/pink-bluegrey.css +1 -1
  248. package/prebuilt-themes/purple-green.css +1 -1
  249. package/progress-spinner/_progress-spinner-theme.scss +37 -17
  250. package/radio/_radio-theme.scss +80 -43
  251. package/schematics/ng-add/index.js +1 -1
  252. package/schematics/ng-add/index.mjs +1 -1
  253. package/schematics/ng-add/theming/theming.js +3 -4
  254. package/schematics/ng-add/theming/theming.mjs +3 -4
  255. package/schematics/ng-generate/mdc-migration/index_bundled.js +1508 -547
  256. package/schematics/ng-generate/mdc-migration/index_bundled.js.map +4 -4
@@ -6704,6 +6704,191 @@ var CssSelector = class {
6704
6704
  return res;
6705
6705
  }
6706
6706
  };
6707
+ var SelectorMatcher = class {
6708
+ constructor() {
6709
+ this._elementMap = /* @__PURE__ */ new Map();
6710
+ this._elementPartialMap = /* @__PURE__ */ new Map();
6711
+ this._classMap = /* @__PURE__ */ new Map();
6712
+ this._classPartialMap = /* @__PURE__ */ new Map();
6713
+ this._attrValueMap = /* @__PURE__ */ new Map();
6714
+ this._attrValuePartialMap = /* @__PURE__ */ new Map();
6715
+ this._listContexts = [];
6716
+ }
6717
+ static createNotMatcher(notSelectors) {
6718
+ const notMatcher = new SelectorMatcher();
6719
+ notMatcher.addSelectables(notSelectors, null);
6720
+ return notMatcher;
6721
+ }
6722
+ addSelectables(cssSelectors, callbackCtxt) {
6723
+ let listContext = null;
6724
+ if (cssSelectors.length > 1) {
6725
+ listContext = new SelectorListContext(cssSelectors);
6726
+ this._listContexts.push(listContext);
6727
+ }
6728
+ for (let i = 0; i < cssSelectors.length; i++) {
6729
+ this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
6730
+ }
6731
+ }
6732
+ _addSelectable(cssSelector, callbackCtxt, listContext) {
6733
+ let matcher = this;
6734
+ const element2 = cssSelector.element;
6735
+ const classNames = cssSelector.classNames;
6736
+ const attrs = cssSelector.attrs;
6737
+ const selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
6738
+ if (element2) {
6739
+ const isTerminal = attrs.length === 0 && classNames.length === 0;
6740
+ if (isTerminal) {
6741
+ this._addTerminal(matcher._elementMap, element2, selectable);
6742
+ } else {
6743
+ matcher = this._addPartial(matcher._elementPartialMap, element2);
6744
+ }
6745
+ }
6746
+ if (classNames) {
6747
+ for (let i = 0; i < classNames.length; i++) {
6748
+ const isTerminal = attrs.length === 0 && i === classNames.length - 1;
6749
+ const className = classNames[i];
6750
+ if (isTerminal) {
6751
+ this._addTerminal(matcher._classMap, className, selectable);
6752
+ } else {
6753
+ matcher = this._addPartial(matcher._classPartialMap, className);
6754
+ }
6755
+ }
6756
+ }
6757
+ if (attrs) {
6758
+ for (let i = 0; i < attrs.length; i += 2) {
6759
+ const isTerminal = i === attrs.length - 2;
6760
+ const name = attrs[i];
6761
+ const value = attrs[i + 1];
6762
+ if (isTerminal) {
6763
+ const terminalMap = matcher._attrValueMap;
6764
+ let terminalValuesMap = terminalMap.get(name);
6765
+ if (!terminalValuesMap) {
6766
+ terminalValuesMap = /* @__PURE__ */ new Map();
6767
+ terminalMap.set(name, terminalValuesMap);
6768
+ }
6769
+ this._addTerminal(terminalValuesMap, value, selectable);
6770
+ } else {
6771
+ const partialMap = matcher._attrValuePartialMap;
6772
+ let partialValuesMap = partialMap.get(name);
6773
+ if (!partialValuesMap) {
6774
+ partialValuesMap = /* @__PURE__ */ new Map();
6775
+ partialMap.set(name, partialValuesMap);
6776
+ }
6777
+ matcher = this._addPartial(partialValuesMap, value);
6778
+ }
6779
+ }
6780
+ }
6781
+ }
6782
+ _addTerminal(map, name, selectable) {
6783
+ let terminalList = map.get(name);
6784
+ if (!terminalList) {
6785
+ terminalList = [];
6786
+ map.set(name, terminalList);
6787
+ }
6788
+ terminalList.push(selectable);
6789
+ }
6790
+ _addPartial(map, name) {
6791
+ let matcher = map.get(name);
6792
+ if (!matcher) {
6793
+ matcher = new SelectorMatcher();
6794
+ map.set(name, matcher);
6795
+ }
6796
+ return matcher;
6797
+ }
6798
+ match(cssSelector, matchedCallback) {
6799
+ let result = false;
6800
+ const element2 = cssSelector.element;
6801
+ const classNames = cssSelector.classNames;
6802
+ const attrs = cssSelector.attrs;
6803
+ for (let i = 0; i < this._listContexts.length; i++) {
6804
+ this._listContexts[i].alreadyMatched = false;
6805
+ }
6806
+ result = this._matchTerminal(this._elementMap, element2, cssSelector, matchedCallback) || result;
6807
+ result = this._matchPartial(this._elementPartialMap, element2, cssSelector, matchedCallback) || result;
6808
+ if (classNames) {
6809
+ for (let i = 0; i < classNames.length; i++) {
6810
+ const className = classNames[i];
6811
+ result = this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
6812
+ result = this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) || result;
6813
+ }
6814
+ }
6815
+ if (attrs) {
6816
+ for (let i = 0; i < attrs.length; i += 2) {
6817
+ const name = attrs[i];
6818
+ const value = attrs[i + 1];
6819
+ const terminalValuesMap = this._attrValueMap.get(name);
6820
+ if (value) {
6821
+ result = this._matchTerminal(terminalValuesMap, "", cssSelector, matchedCallback) || result;
6822
+ }
6823
+ result = this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;
6824
+ const partialValuesMap = this._attrValuePartialMap.get(name);
6825
+ if (value) {
6826
+ result = this._matchPartial(partialValuesMap, "", cssSelector, matchedCallback) || result;
6827
+ }
6828
+ result = this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;
6829
+ }
6830
+ }
6831
+ return result;
6832
+ }
6833
+ _matchTerminal(map, name, cssSelector, matchedCallback) {
6834
+ if (!map || typeof name !== "string") {
6835
+ return false;
6836
+ }
6837
+ let selectables = map.get(name) || [];
6838
+ const starSelectables = map.get("*");
6839
+ if (starSelectables) {
6840
+ selectables = selectables.concat(starSelectables);
6841
+ }
6842
+ if (selectables.length === 0) {
6843
+ return false;
6844
+ }
6845
+ let selectable;
6846
+ let result = false;
6847
+ for (let i = 0; i < selectables.length; i++) {
6848
+ selectable = selectables[i];
6849
+ result = selectable.finalize(cssSelector, matchedCallback) || result;
6850
+ }
6851
+ return result;
6852
+ }
6853
+ _matchPartial(map, name, cssSelector, matchedCallback) {
6854
+ if (!map || typeof name !== "string") {
6855
+ return false;
6856
+ }
6857
+ const nestedSelector = map.get(name);
6858
+ if (!nestedSelector) {
6859
+ return false;
6860
+ }
6861
+ return nestedSelector.match(cssSelector, matchedCallback);
6862
+ }
6863
+ };
6864
+ var SelectorListContext = class {
6865
+ constructor(selectors) {
6866
+ this.selectors = selectors;
6867
+ this.alreadyMatched = false;
6868
+ }
6869
+ };
6870
+ var SelectorContext = class {
6871
+ constructor(selector, cbContext, listContext) {
6872
+ this.selector = selector;
6873
+ this.cbContext = cbContext;
6874
+ this.listContext = listContext;
6875
+ this.notSelectors = selector.notSelectors;
6876
+ }
6877
+ finalize(cssSelector, callback) {
6878
+ let result = true;
6879
+ if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) {
6880
+ const notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
6881
+ result = !notMatcher.match(cssSelector, null);
6882
+ }
6883
+ if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) {
6884
+ if (this.listContext) {
6885
+ this.listContext.alreadyMatched = true;
6886
+ }
6887
+ callback(this.selector, this.cbContext);
6888
+ }
6889
+ return result;
6890
+ }
6891
+ };
6707
6892
  var ViewEncapsulation;
6708
6893
  (function(ViewEncapsulation2) {
6709
6894
  ViewEncapsulation2[ViewEncapsulation2["Emulated"] = 0] = "Emulated";
@@ -9775,6 +9960,10 @@ var IdleDeferredTrigger = class extends DeferredTrigger {
9775
9960
  var ImmediateDeferredTrigger = class extends DeferredTrigger {
9776
9961
  };
9777
9962
  var HoverDeferredTrigger = class extends DeferredTrigger {
9963
+ constructor(reference2, sourceSpan) {
9964
+ super(sourceSpan);
9965
+ this.reference = reference2;
9966
+ }
9778
9967
  };
9779
9968
  var TimerDeferredTrigger = class extends DeferredTrigger {
9780
9969
  constructor(delay, sourceSpan) {
@@ -9885,8 +10074,8 @@ var SwitchBlockCase = class {
9885
10074
  }
9886
10075
  };
9887
10076
  var ForLoopBlock = class {
9888
- constructor(itemName, expression, trackBy, contextVariables, children, empty, sourceSpan, startSourceSpan, endSourceSpan) {
9889
- this.itemName = itemName;
10077
+ constructor(item, expression, trackBy, contextVariables, children, empty, sourceSpan, startSourceSpan, endSourceSpan) {
10078
+ this.item = item;
9890
10079
  this.expression = expression;
9891
10080
  this.trackBy = trackBy;
9892
10081
  this.contextVariables = contextVariables;
@@ -10422,6 +10611,27 @@ var DefinitionMap = class {
10422
10611
  return literalMap(this.values);
10423
10612
  }
10424
10613
  };
10614
+ function getAttrsForDirectiveMatching(elOrTpl) {
10615
+ const attributesMap = {};
10616
+ if (elOrTpl instanceof Template && elOrTpl.tagName !== "ng-template") {
10617
+ elOrTpl.templateAttrs.forEach((a) => attributesMap[a.name] = "");
10618
+ } else {
10619
+ elOrTpl.attributes.forEach((a) => {
10620
+ if (!isI18nAttribute(a.name)) {
10621
+ attributesMap[a.name] = a.value;
10622
+ }
10623
+ });
10624
+ elOrTpl.inputs.forEach((i) => {
10625
+ if (i.type === 0) {
10626
+ attributesMap[i.name] = "";
10627
+ }
10628
+ });
10629
+ elOrTpl.outputs.forEach((o) => {
10630
+ attributesMap[o.name] = "";
10631
+ });
10632
+ }
10633
+ return attributesMap;
10634
+ }
10425
10635
  function getInterpolationArgsLength(interpolation) {
10426
10636
  const { expressions, strings } = interpolation;
10427
10637
  if (expressions.length === 1 && strings.length === 2 && strings[0] === "" && strings[1] === "") {
@@ -10633,6 +10843,7 @@ var $LBRACE = 123;
10633
10843
  var $BAR = 124;
10634
10844
  var $RBRACE = 125;
10635
10845
  var $NBSP = 160;
10846
+ var $AT = 64;
10636
10847
  var $BT = 96;
10637
10848
  function isWhitespace(code) {
10638
10849
  return code >= $TAB && code <= $SPACE || code == $NBSP;
@@ -11060,14 +11271,8 @@ function compileNgModule(meta) {
11060
11271
  const statements = [];
11061
11272
  const definitionMap = new DefinitionMap();
11062
11273
  definitionMap.set("type", meta.type.value);
11063
- if (meta.kind === R3NgModuleMetadataKind.Global) {
11064
- if (meta.bootstrap.length > 0) {
11065
- definitionMap.set("bootstrap", refsToArray(meta.bootstrap, meta.containsForwardDecls));
11066
- }
11067
- } else {
11068
- if (meta.bootstrapExpression) {
11069
- definitionMap.set("bootstrap", meta.bootstrapExpression);
11070
- }
11274
+ if (meta.kind === R3NgModuleMetadataKind.Global && meta.bootstrap.length > 0) {
11275
+ definitionMap.set("bootstrap", refsToArray(meta.bootstrap, meta.containsForwardDecls));
11071
11276
  }
11072
11277
  if (meta.selectorScopeMode === R3SelectorScopeMode.Inline) {
11073
11278
  if (meta.declarations.length > 0) {
@@ -11161,6 +11366,9 @@ function generateSetNgModuleScopeCall(meta) {
11161
11366
  scopeMap.set("exports", meta.exportsExpression);
11162
11367
  }
11163
11368
  }
11369
+ if (meta.kind === R3NgModuleMetadataKind.Local && meta.bootstrapExpression) {
11370
+ scopeMap.set("bootstrap", meta.bootstrapExpression);
11371
+ }
11164
11372
  if (Object.keys(scopeMap.values).length === 0) {
11165
11373
  return null;
11166
11374
  }
@@ -13067,9 +13275,11 @@ var OpKind;
13067
13275
  OpKind2[OpKind2["ExtractedMessage"] = 26] = "ExtractedMessage";
13068
13276
  OpKind2[OpKind2["HostProperty"] = 27] = "HostProperty";
13069
13277
  OpKind2[OpKind2["Namespace"] = 28] = "Namespace";
13070
- OpKind2[OpKind2["I18nStart"] = 29] = "I18nStart";
13071
- OpKind2[OpKind2["I18n"] = 30] = "I18n";
13072
- OpKind2[OpKind2["I18nEnd"] = 31] = "I18nEnd";
13278
+ OpKind2[OpKind2["ProjectionDef"] = 29] = "ProjectionDef";
13279
+ OpKind2[OpKind2["Projection"] = 30] = "Projection";
13280
+ OpKind2[OpKind2["I18nStart"] = 31] = "I18nStart";
13281
+ OpKind2[OpKind2["I18n"] = 32] = "I18n";
13282
+ OpKind2[OpKind2["I18nEnd"] = 33] = "I18nEnd";
13073
13283
  })(OpKind || (OpKind = {}));
13074
13284
  var ExpressionKind;
13075
13285
  (function(ExpressionKind2) {
@@ -13668,8 +13878,8 @@ var SafePropertyReadExpr = class extends ExpressionBase {
13668
13878
  }
13669
13879
  };
13670
13880
  var SafeKeyedReadExpr = class extends ExpressionBase {
13671
- constructor(receiver, index2) {
13672
- super();
13881
+ constructor(receiver, index2, sourceSpan) {
13882
+ super(sourceSpan);
13673
13883
  this.receiver = receiver;
13674
13884
  this.index = index2;
13675
13885
  this.kind = ExpressionKind.SafeKeyedRead;
@@ -13689,7 +13899,7 @@ var SafeKeyedReadExpr = class extends ExpressionBase {
13689
13899
  this.index = transformExpressionsInExpression(this.index, transform2, flags);
13690
13900
  }
13691
13901
  clone() {
13692
- return new SafeKeyedReadExpr(this.receiver.clone(), this.index.clone());
13902
+ return new SafeKeyedReadExpr(this.receiver.clone(), this.index.clone(), this.sourceSpan);
13693
13903
  }
13694
13904
  };
13695
13905
  var SafeInvokeFunctionExpr = class extends ExpressionBase {
@@ -13938,6 +14148,8 @@ function transformExpressionsInOp(op, transform2, flags) {
13938
14148
  op.tagNameParams[placeholder] = transformExpressionsInExpression(op.tagNameParams[placeholder], transform2, flags);
13939
14149
  }
13940
14150
  break;
14151
+ case OpKind.Projection:
14152
+ case OpKind.ProjectionDef:
13941
14153
  case OpKind.Element:
13942
14154
  case OpKind.ElementStart:
13943
14155
  case OpKind.ElementEnd:
@@ -14227,7 +14439,8 @@ var elementContainerOpKinds = /* @__PURE__ */ new Set([
14227
14439
  OpKind.ElementStart,
14228
14440
  OpKind.Container,
14229
14441
  OpKind.ContainerStart,
14230
- OpKind.Template
14442
+ OpKind.Template,
14443
+ OpKind.Projection
14231
14444
  ]);
14232
14445
  function isElementOrContainerOp(op) {
14233
14446
  return elementContainerOpKinds.has(op.kind);
@@ -14245,12 +14458,13 @@ function createElementStartOp(tag, xref, namespace, i18n2, sourceSpan) {
14245
14458
  sourceSpan
14246
14459
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
14247
14460
  }
14248
- function createTemplateOp(xref, tag, namespace, i18n2, sourceSpan) {
14461
+ function createTemplateOp(xref, tag, namespace, controlFlow, i18n2, sourceSpan) {
14249
14462
  return __spreadValues(__spreadValues({
14250
14463
  kind: OpKind.Template,
14251
14464
  xref,
14252
14465
  attributes: null,
14253
14466
  tag,
14467
+ controlFlow,
14254
14468
  decls: null,
14255
14469
  vars: null,
14256
14470
  localRefs: [],
@@ -14287,7 +14501,7 @@ function createTextOp(xref, initialValue, sourceSpan) {
14287
14501
  sourceSpan
14288
14502
  }, TRAIT_CONSUMES_SLOT), NEW_OP);
14289
14503
  }
14290
- function createListenerOp(target, name, tag, animationPhase, hostListener) {
14504
+ function createListenerOp(target, name, tag, animationPhase, hostListener, sourceSpan) {
14291
14505
  return __spreadValues(__spreadValues({
14292
14506
  kind: OpKind.Listener,
14293
14507
  target,
@@ -14298,7 +14512,8 @@ function createListenerOp(target, name, tag, animationPhase, hostListener) {
14298
14512
  handlerFnName: null,
14299
14513
  consumesDollarEvent: false,
14300
14514
  isAnimationListener: animationPhase !== null,
14301
- animationPhase
14515
+ animationPhase,
14516
+ sourceSpan
14302
14517
  }, NEW_OP), TRAIT_USES_SLOT_INDEX);
14303
14518
  }
14304
14519
  function createPipeOp(xref, name) {
@@ -14320,6 +14535,25 @@ function createNamespaceOp(namespace) {
14320
14535
  active: namespace
14321
14536
  }, NEW_OP);
14322
14537
  }
14538
+ function createProjectionDefOp(def) {
14539
+ return __spreadValues({
14540
+ kind: OpKind.ProjectionDef,
14541
+ def
14542
+ }, NEW_OP);
14543
+ }
14544
+ function createProjectionOp(xref, selector) {
14545
+ return __spreadValues(__spreadValues(__spreadValues({
14546
+ kind: OpKind.Projection,
14547
+ xref,
14548
+ selector,
14549
+ projectionSlotIndex: 0,
14550
+ attributes: null,
14551
+ localRefs: [],
14552
+ nonBindable: false,
14553
+ i18n: void 0,
14554
+ sourceSpan: null
14555
+ }, NEW_OP), TRAIT_CONSUMES_SLOT), TRAIT_USES_SLOT_INDEX);
14556
+ }
14323
14557
  function createExtractedAttributeOp(target, bindingKind, name, expression) {
14324
14558
  return __spreadValues({
14325
14559
  kind: OpKind.ExtractedAttribute,
@@ -14387,6 +14621,7 @@ var ComponentCompilationJob = class extends CompilationJob {
14387
14621
  this.kind = CompilationJobKind.Tmpl;
14388
14622
  this.fnSuffix = "Template";
14389
14623
  this.views = /* @__PURE__ */ new Map();
14624
+ this.contentSelectors = null;
14390
14625
  this.consts = [];
14391
14626
  this.constsInitializers = [];
14392
14627
  this.root = new ViewCompilationUnit(this, this.allocateXrefId(), null);
@@ -14590,13 +14825,13 @@ function phaseAttributeExtraction(job) {
14590
14825
  break;
14591
14826
  case OpKind.Property:
14592
14827
  if (!op.isAnimationTrigger) {
14593
- OpList.insertBefore(createExtractedAttributeOp(op.target, op.isTemplate ? BindingKind.Template : BindingKind.Property, op.name, null), lookupElement$2(elements, op.target));
14828
+ OpList.insertBefore(createExtractedAttributeOp(op.target, op.isTemplate ? BindingKind.Template : BindingKind.Property, op.name, null), lookupElement$3(elements, op.target));
14594
14829
  }
14595
14830
  break;
14596
14831
  case OpKind.StyleProp:
14597
14832
  case OpKind.ClassProp:
14598
14833
  if (unit.job.compatibility === CompatibilityMode.TemplateDefinitionBuilder && op.expression instanceof EmptyExpr) {
14599
- OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.Property, op.name, null), lookupElement$2(elements, op.target));
14834
+ OpList.insertBefore(createExtractedAttributeOp(op.target, BindingKind.Property, op.name, null), lookupElement$3(elements, op.target));
14600
14835
  }
14601
14836
  break;
14602
14837
  case OpKind.Listener:
@@ -14605,7 +14840,7 @@ function phaseAttributeExtraction(job) {
14605
14840
  if (job.kind === CompilationJobKind.Host) {
14606
14841
  unit.create.push(extractedAttributeOp);
14607
14842
  } else {
14608
- OpList.insertBefore(extractedAttributeOp, lookupElement$2(elements, op.target));
14843
+ OpList.insertBefore(extractedAttributeOp, lookupElement$3(elements, op.target));
14609
14844
  }
14610
14845
  }
14611
14846
  break;
@@ -14613,7 +14848,7 @@ function phaseAttributeExtraction(job) {
14613
14848
  }
14614
14849
  }
14615
14850
  }
14616
- function lookupElement$2(elements, xref) {
14851
+ function lookupElement$3(elements, xref) {
14617
14852
  const el = elements.get(xref);
14618
14853
  if (el === void 0) {
14619
14854
  throw new Error("All attributes should have an element-like target.");
@@ -14639,13 +14874,13 @@ function extractAttributeOp(unit, op, elements) {
14639
14874
  if (unit.job.kind === CompilationJobKind.Host) {
14640
14875
  unit.create.push(extractedAttributeOp);
14641
14876
  } else {
14642
- const ownerOp = lookupElement$2(elements, op.target);
14877
+ const ownerOp = lookupElement$3(elements, op.target);
14643
14878
  OpList.insertBefore(extractedAttributeOp, ownerOp);
14644
14879
  }
14645
14880
  OpList.remove(op);
14646
14881
  }
14647
14882
  }
14648
- function lookupElement$1(elements, xref) {
14883
+ function lookupElement$2(elements, xref) {
14649
14884
  const el = elements.get(xref);
14650
14885
  if (el === void 0) {
14651
14886
  throw new Error("All attributes should have an element-like target.");
@@ -14671,7 +14906,7 @@ function phaseBindingSpecialization(job) {
14671
14906
  case BindingKind.Attribute:
14672
14907
  if (op.name === "ngNonBindable") {
14673
14908
  OpList.remove(op);
14674
- const target = lookupElement$1(elements, op.target);
14909
+ const target = lookupElement$2(elements, op.target);
14675
14910
  target.nonBindable = true;
14676
14911
  } else {
14677
14912
  OpList.replace(op, createAttributeOp(op.target, op.name, op.expression, op.securityContext, op.isTextAttribute, op.isTemplate, op.sourceSpan));
@@ -14812,31 +15047,60 @@ function getNsPrefix(fullName) {
14812
15047
  function mergeNsAndName(prefix, localName) {
14813
15048
  return prefix ? `:${prefix}:${localName}` : localName;
14814
15049
  }
14815
- function phaseConstCollection(job) {
14816
- if (job instanceof ComponentCompilationJob) {
14817
- const messageConstIndices = {};
14818
- for (const unit of job.units) {
14819
- for (const op of unit.create) {
14820
- if (op.kind === OpKind.ExtractedMessage) {
14821
- messageConstIndices[op.owner] = job.addConst(op.expression, op.statements);
14822
- OpList.remove(op);
14823
- }
14824
- }
14825
- }
14826
- for (const unit of job.units) {
14827
- for (const op of unit.create) {
14828
- if (op.kind === OpKind.I18nStart && messageConstIndices[op.xref] !== void 0) {
14829
- op.messageIndex = messageConstIndices[op.xref];
14830
- }
14831
- }
15050
+ var BINARY_OPERATORS = /* @__PURE__ */ new Map([
15051
+ ["&&", BinaryOperator.And],
15052
+ [">", BinaryOperator.Bigger],
15053
+ [">=", BinaryOperator.BiggerEquals],
15054
+ ["&", BinaryOperator.BitwiseAnd],
15055
+ ["/", BinaryOperator.Divide],
15056
+ ["==", BinaryOperator.Equals],
15057
+ ["===", BinaryOperator.Identical],
15058
+ ["<", BinaryOperator.Lower],
15059
+ ["<=", BinaryOperator.LowerEquals],
15060
+ ["-", BinaryOperator.Minus],
15061
+ ["%", BinaryOperator.Modulo],
15062
+ ["*", BinaryOperator.Multiply],
15063
+ ["!=", BinaryOperator.NotEquals],
15064
+ ["!==", BinaryOperator.NotIdentical],
15065
+ ["??", BinaryOperator.NullishCoalesce],
15066
+ ["||", BinaryOperator.Or],
15067
+ ["+", BinaryOperator.Plus]
15068
+ ]);
15069
+ var NAMESPACES = /* @__PURE__ */ new Map([["svg", Namespace.SVG], ["math", Namespace.Math]]);
15070
+ function namespaceForKey(namespacePrefixKey) {
15071
+ var _a2;
15072
+ if (namespacePrefixKey === null) {
15073
+ return Namespace.HTML;
15074
+ }
15075
+ return (_a2 = NAMESPACES.get(namespacePrefixKey)) != null ? _a2 : Namespace.HTML;
15076
+ }
15077
+ function keyForNamespace(namespace) {
15078
+ for (const [k, n] of NAMESPACES.entries()) {
15079
+ if (n === namespace) {
15080
+ return k;
14832
15081
  }
14833
15082
  }
14834
- const elementAttributes = /* @__PURE__ */ new Map();
15083
+ return null;
15084
+ }
15085
+ function prefixWithNamespace(strippedTag, namespace) {
15086
+ if (namespace === Namespace.HTML) {
15087
+ return strippedTag;
15088
+ }
15089
+ return `:${keyForNamespace(namespace)}:${strippedTag}`;
15090
+ }
15091
+ function literalOrArrayLiteral(value) {
15092
+ if (Array.isArray(value)) {
15093
+ return literalArr(value.map(literalOrArrayLiteral));
15094
+ }
15095
+ return literal(value, INFERRED_TYPE);
15096
+ }
15097
+ function phaseConstCollection(job) {
15098
+ const allElementAttributes = /* @__PURE__ */ new Map();
14835
15099
  for (const unit of job.units) {
14836
15100
  for (const op of unit.create) {
14837
15101
  if (op.kind === OpKind.ExtractedAttribute) {
14838
- const attributes = elementAttributes.get(op.target) || new ElementAttributes();
14839
- elementAttributes.set(op.target, attributes);
15102
+ const attributes = allElementAttributes.get(op.target) || new ElementAttributes();
15103
+ allElementAttributes.set(op.target, attributes);
14840
15104
  attributes.add(op.bindingKind, op.name, op.expression);
14841
15105
  OpList.remove(op);
14842
15106
  }
@@ -14845,8 +15109,8 @@ function phaseConstCollection(job) {
14845
15109
  if (job instanceof ComponentCompilationJob) {
14846
15110
  for (const unit of job.units) {
14847
15111
  for (const op of unit.create) {
14848
- if (op.kind === OpKind.Element || op.kind === OpKind.ElementStart || op.kind === OpKind.Template) {
14849
- const attributes = elementAttributes.get(op.xref);
15112
+ if (isElementOrContainerOp(op)) {
15113
+ const attributes = allElementAttributes.get(op.xref);
14850
15114
  if (attributes !== void 0) {
14851
15115
  const attrArray = serializeAttributes(attributes);
14852
15116
  if (attrArray.entries.length > 0) {
@@ -14857,7 +15121,7 @@ function phaseConstCollection(job) {
14857
15121
  }
14858
15122
  }
14859
15123
  } else if (job instanceof HostBindingCompilationJob) {
14860
- for (const [xref, attributes] of elementAttributes.entries()) {
15124
+ for (const [xref, attributes] of allElementAttributes.entries()) {
14861
15125
  if (xref !== job.root.xref) {
14862
15126
  throw new Error(`An attribute would be const collected into the host binding's template function, but is not associated with the root xref.`);
14863
15127
  }
@@ -14900,10 +15164,17 @@ var ElementAttributes = class {
14900
15164
  return (_a2 = this.byKind.get(BindingKind.I18n)) != null ? _a2 : FLYWEIGHT_ARRAY;
14901
15165
  }
14902
15166
  add(kind, name, value) {
15167
+ var _a2;
14903
15168
  if (this.known.has(name)) {
14904
15169
  return;
14905
15170
  }
14906
15171
  this.known.add(name);
15172
+ if (name === "ngProjectAs") {
15173
+ if (value === null || !(value instanceof LiteralExpr) || value.value == null || typeof ((_a2 = value.value) == null ? void 0 : _a2.toString()) !== "string") {
15174
+ throw Error("ngProjectAs must have a string literal value");
15175
+ }
15176
+ this.projectAs = value.value.toString();
15177
+ }
14907
15178
  const array = this.arrayFor(kind);
14908
15179
  array.push(...getAttributeNameLiterals$1(name));
14909
15180
  if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
@@ -14935,7 +15206,8 @@ function getAttributeNameLiterals$1(name) {
14935
15206
  function serializeAttributes({ attributes, bindings, classes, i18n: i18n2, projectAs, styles, template: template2 }) {
14936
15207
  const attrArray = [...attributes];
14937
15208
  if (projectAs !== null) {
14938
- attrArray.push(literal(5), literal(projectAs));
15209
+ const parsedR3Selector = parseSelectorToR3Selector(projectAs)[0];
15210
+ attrArray.push(literal(5), literalOrArrayLiteral(parsedR3Selector));
14939
15211
  }
14940
15212
  if (classes.length > 0) {
14941
15213
  attrArray.push(literal(1), ...classes);
@@ -16654,17 +16926,6 @@ var Comment = class {
16654
16926
  return visitor.visitComment(this, context);
16655
16927
  }
16656
16928
  };
16657
- var BlockGroup = class {
16658
- constructor(blocks, sourceSpan, startSourceSpan, endSourceSpan = null) {
16659
- this.blocks = blocks;
16660
- this.sourceSpan = sourceSpan;
16661
- this.startSourceSpan = startSourceSpan;
16662
- this.endSourceSpan = endSourceSpan;
16663
- }
16664
- visit(visitor, context) {
16665
- return visitor.visitBlockGroup(this, context);
16666
- }
16667
- };
16668
16929
  var Block = class {
16669
16930
  constructor(name, parameters, children, sourceSpan, startSourceSpan, endSourceSpan = null) {
16670
16931
  this.name = name;
@@ -17344,11 +17605,6 @@ var _I18nVisitor = class {
17344
17605
  visitExpansionCase(_icuCase, _context) {
17345
17606
  throw new Error("Unreachable code");
17346
17607
  }
17347
- visitBlockGroup(group, context) {
17348
- const children = visitAll(this, group.blocks, context);
17349
- const node = new Container(children, group.sourceSpan);
17350
- return context.visitNodeFn(group, node);
17351
- }
17352
17608
  visitBlock(block, context) {
17353
17609
  const children = visitAll(this, block.children, context);
17354
17610
  const node = new Container(children, block.sourceSpan);
@@ -19645,12 +19901,10 @@ var _Tokenizer = class {
19645
19901
  } else {
19646
19902
  this._consumeTagOpen(start);
19647
19903
  }
19648
- } else if (this._tokenizeBlocks && this._attemptStr("{#")) {
19649
- this._consumeBlockGroupOpen(start);
19650
- } else if (this._tokenizeBlocks && this._attemptStr("{/")) {
19651
- this._consumeBlockGroupClose(start);
19652
- } else if (this._tokenizeBlocks && this._attemptStr("{:")) {
19653
- this._consumeBlock(start);
19904
+ } else if (this._tokenizeBlocks && this._attemptCharCode($AT)) {
19905
+ this._consumeBlockStart(start);
19906
+ } else if (this._tokenizeBlocks && !this._inInterpolation && !this._isInExpansionCase() && !this._isInExpansionForm() && this._attemptCharCode($RBRACE)) {
19907
+ this._consumeBlockEnd(start);
19654
19908
  } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
19655
19909
  this._consumeWithInterpolation(5, 8, () => this._isTextEnd(), () => this._isTagStart());
19656
19910
  }
@@ -19658,44 +19912,49 @@ var _Tokenizer = class {
19658
19912
  this.handleError(e);
19659
19913
  }
19660
19914
  }
19661
- this._beginToken(24);
19915
+ this._beginToken(28);
19662
19916
  this._endToken([]);
19663
19917
  }
19664
- _consumeBlockGroupOpen(start) {
19665
- this._beginToken(25, start);
19918
+ _getBlockName() {
19919
+ let spacesInNameAllowed = false;
19666
19920
  const nameCursor = this._cursor.clone();
19667
- this._attemptCharCodeUntilFn((code) => !isBlockNameChar(code));
19668
- this._endToken([this._cursor.getChars(nameCursor)]);
19669
- this._consumeBlockParameters();
19670
- this._beginToken(26);
19671
- this._requireCharCode($RBRACE);
19672
- this._endToken([]);
19921
+ this._attemptCharCodeUntilFn((code) => {
19922
+ if (isWhitespace(code)) {
19923
+ return !spacesInNameAllowed;
19924
+ }
19925
+ if (isBlockNameChar(code)) {
19926
+ spacesInNameAllowed = true;
19927
+ return false;
19928
+ }
19929
+ return true;
19930
+ });
19931
+ return this._cursor.getChars(nameCursor).trim();
19673
19932
  }
19674
- _consumeBlockGroupClose(start) {
19675
- this._beginToken(27, start);
19676
- const nameCursor = this._cursor.clone();
19677
- this._attemptCharCodeUntilFn((code) => !isBlockNameChar(code));
19678
- const name = this._cursor.getChars(nameCursor);
19679
- this._requireCharCode($RBRACE);
19680
- this._endToken([name]);
19933
+ _consumeBlockStart(start) {
19934
+ this._beginToken(24, start);
19935
+ this._endToken([this._getBlockName()]);
19936
+ if (this._cursor.peek() === $LPAREN) {
19937
+ this._cursor.advance();
19938
+ this._consumeBlockParameters();
19939
+ this._attemptCharCodeUntilFn(isNotWhitespace);
19940
+ this._requireCharCode($RPAREN);
19941
+ this._attemptCharCodeUntilFn(isNotWhitespace);
19942
+ }
19943
+ this._beginToken(25);
19944
+ this._requireCharCode($LBRACE);
19945
+ this._endToken([]);
19681
19946
  }
19682
- _consumeBlock(start) {
19683
- this._beginToken(29, start);
19684
- const nameCursor = this._cursor.clone();
19685
- this._attemptCharCodeUntilFn((code) => !isBlockNameChar(code));
19686
- this._endToken([this._cursor.getChars(nameCursor)]);
19687
- this._consumeBlockParameters();
19688
- this._beginToken(30);
19689
- this._requireCharCode($RBRACE);
19947
+ _consumeBlockEnd(start) {
19948
+ this._beginToken(26, start);
19690
19949
  this._endToken([]);
19691
19950
  }
19692
19951
  _consumeBlockParameters() {
19693
19952
  this._attemptCharCodeUntilFn(isBlockParameterChar);
19694
- while (this._cursor.peek() !== $RBRACE && this._cursor.peek() !== $EOF) {
19695
- this._beginToken(28);
19953
+ while (this._cursor.peek() !== $RPAREN && this._cursor.peek() !== $EOF) {
19954
+ this._beginToken(27);
19696
19955
  const start = this._cursor.clone();
19697
19956
  let inQuote = null;
19698
- let openBraces = 0;
19957
+ let openParens = 0;
19699
19958
  while (this._cursor.peek() !== $SEMICOLON && this._cursor.peek() !== $EOF || inQuote !== null) {
19700
19959
  const char = this._cursor.peek();
19701
19960
  if (char === $BACKSLASH) {
@@ -19704,13 +19963,13 @@ var _Tokenizer = class {
19704
19963
  inQuote = null;
19705
19964
  } else if (inQuote === null && isQuote(char)) {
19706
19965
  inQuote = char;
19707
- } else if (char === $LBRACE && inQuote === null) {
19708
- openBraces++;
19709
- } else if (char === $RBRACE && inQuote === null) {
19710
- if (openBraces === 0) {
19966
+ } else if (char === $LPAREN && inQuote === null) {
19967
+ openParens++;
19968
+ } else if (char === $RPAREN && inQuote === null) {
19969
+ if (openParens === 0) {
19711
19970
  break;
19712
- } else if (openBraces > 0) {
19713
- openBraces--;
19971
+ } else if (openParens > 0) {
19972
+ openParens--;
19714
19973
  }
19715
19974
  }
19716
19975
  this._cursor.advance();
@@ -20169,7 +20428,7 @@ var _Tokenizer = class {
20169
20428
  return this._processCarriageReturns(end.getChars(start));
20170
20429
  }
20171
20430
  _isTextEnd() {
20172
- if (this._isTagStart() || this._isBlockStart() || this._cursor.peek() === $EOF) {
20431
+ if (this._isTagStart() || this._cursor.peek() === $EOF) {
20173
20432
  return true;
20174
20433
  }
20175
20434
  if (this._tokenizeIcu && !this._inInterpolation) {
@@ -20180,6 +20439,9 @@ var _Tokenizer = class {
20180
20439
  return true;
20181
20440
  }
20182
20441
  }
20442
+ if (this._tokenizeBlocks && !this._inInterpolation && !this._isInExpansion() && (this._isBlockStart() || this._cursor.peek() === $RBRACE)) {
20443
+ return true;
20444
+ }
20183
20445
  return false;
20184
20446
  }
20185
20447
  _isTagStart() {
@@ -20194,14 +20456,9 @@ var _Tokenizer = class {
20194
20456
  return false;
20195
20457
  }
20196
20458
  _isBlockStart() {
20197
- if (this._tokenizeBlocks && this._cursor.peek() === $LBRACE) {
20459
+ if (this._tokenizeBlocks && this._cursor.peek() === $AT) {
20198
20460
  const tmp = this._cursor.clone();
20199
20461
  tmp.advance();
20200
- const next = tmp.peek();
20201
- if (next !== $BANG && next !== $SLASH && next !== $COLON) {
20202
- return false;
20203
- }
20204
- tmp.advance();
20205
20462
  if (isBlockNameChar(tmp.peek())) {
20206
20463
  return true;
20207
20464
  }
@@ -20213,6 +20470,9 @@ var _Tokenizer = class {
20213
20470
  this._attemptUntilChar(char);
20214
20471
  return this._cursor.getChars(start);
20215
20472
  }
20473
+ _isInExpansion() {
20474
+ return this._isInExpansionCase() || this._isInExpansionForm();
20475
+ }
20216
20476
  _isInExpansionCase() {
20217
20477
  return this._expansionCaseStack.length > 0 && this._expansionCaseStack[this._expansionCaseStack.length - 1] === 21;
20218
20478
  }
@@ -20512,7 +20772,7 @@ var _TreeBuilder = class {
20512
20772
  this._advance();
20513
20773
  }
20514
20774
  build() {
20515
- while (this._peek.type !== 24) {
20775
+ while (this._peek.type !== 28) {
20516
20776
  if (this._peek.type === 0 || this._peek.type === 4) {
20517
20777
  this._consumeStartTag(this._advance());
20518
20778
  } else if (this._peek.type === 3) {
@@ -20528,19 +20788,21 @@ var _TreeBuilder = class {
20528
20788
  this._consumeText(this._advance());
20529
20789
  } else if (this._peek.type === 19) {
20530
20790
  this._consumeExpansion(this._advance());
20531
- } else if (this._peek.type === 25) {
20532
- this._closeVoidElement();
20533
- this._consumeBlockGroupOpen(this._advance());
20534
- } else if (this._peek.type === 29) {
20791
+ } else if (this._peek.type === 24) {
20535
20792
  this._closeVoidElement();
20536
- this._consumeBlock(this._advance(), 30);
20537
- } else if (this._peek.type === 27) {
20793
+ this._consumeBlockOpen(this._advance());
20794
+ } else if (this._peek.type === 26) {
20538
20795
  this._closeVoidElement();
20539
- this._consumeBlockGroupClose(this._advance());
20796
+ this._consumeBlockClose(this._advance());
20540
20797
  } else {
20541
20798
  this._advance();
20542
20799
  }
20543
20800
  }
20801
+ for (const leftoverContainer of this._containerStack) {
20802
+ if (leftoverContainer instanceof Block) {
20803
+ this.errors.push(TreeError.create(leftoverContainer.name, leftoverContainer.sourceSpan, `Unclosed block "${leftoverContainer.name}"`));
20804
+ }
20805
+ }
20544
20806
  }
20545
20807
  _advance() {
20546
20808
  const prev = this._peek;
@@ -20596,7 +20858,7 @@ var _TreeBuilder = class {
20596
20858
  if (!exp)
20597
20859
  return null;
20598
20860
  const end = this._advance();
20599
- exp.push({ type: 24, parts: [], sourceSpan: end.sourceSpan });
20861
+ exp.push({ type: 28, parts: [], sourceSpan: end.sourceSpan });
20600
20862
  const expansionCaseParser = new _TreeBuilder(exp, this.getTagDefinition);
20601
20863
  expansionCaseParser.build();
20602
20864
  if (expansionCaseParser.errors.length > 0) {
@@ -20632,7 +20894,7 @@ var _TreeBuilder = class {
20632
20894
  return null;
20633
20895
  }
20634
20896
  }
20635
- if (this._peek.type === 24) {
20897
+ if (this._peek.type === 28) {
20636
20898
  this.errors.push(TreeError.create(null, start.sourceSpan, `Invalid ICU message. Missing '}'.`));
20637
20899
  return null;
20638
20900
  }
@@ -20645,10 +20907,6 @@ var _TreeBuilder = class {
20645
20907
  let text2 = token.parts[0];
20646
20908
  if (text2.length > 0 && text2[0] === "\n") {
20647
20909
  const parent = this._getContainer();
20648
- if (parent instanceof BlockGroup) {
20649
- this.errors.push(TreeError.create(null, startSpan, "Text cannot be placed directly inside of a block group."));
20650
- return;
20651
- }
20652
20910
  if (parent != null && parent.children.length === 0 && this.getTagDefinition(parent.name).ignoreFirstLf) {
20653
20911
  text2 = text2.substring(1);
20654
20912
  tokens[0] = { type: token.type, sourceSpan: token.sourceSpan, parts: [text2] };
@@ -20724,19 +20982,17 @@ var _TreeBuilder = class {
20724
20982
  this.errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg));
20725
20983
  }
20726
20984
  }
20727
- _popContainer(fullName, expectedType, endSourceSpan) {
20728
- var _a2;
20985
+ _popContainer(expectedName, expectedType, endSourceSpan) {
20729
20986
  let unexpectedCloseTagDetected = false;
20730
20987
  for (let stackIndex = this._containerStack.length - 1; stackIndex >= 0; stackIndex--) {
20731
20988
  const node = this._containerStack[stackIndex];
20732
- const name = node instanceof BlockGroup ? (_a2 = node.blocks[0]) == null ? void 0 : _a2.name : node.name;
20733
- if (name === fullName && node instanceof expectedType) {
20989
+ if ((node.name === expectedName || expectedName === null) && node instanceof expectedType) {
20734
20990
  node.endSourceSpan = endSourceSpan;
20735
20991
  node.sourceSpan.end = endSourceSpan !== null ? endSourceSpan.end : node.sourceSpan.end;
20736
20992
  this._containerStack.splice(stackIndex, this._containerStack.length - stackIndex);
20737
20993
  return !unexpectedCloseTagDetected;
20738
20994
  }
20739
- if (node instanceof BlockGroup || node instanceof Element && !this.getTagDefinition(node.name).closedByParent) {
20995
+ if (node instanceof Block || node instanceof Element && !this.getTagDefinition(node.name).closedByParent) {
20740
20996
  unexpectedCloseTagDetected = true;
20741
20997
  }
20742
20998
  }
@@ -20776,53 +21032,27 @@ var _TreeBuilder = class {
20776
21032
  const valueSpan = valueStartSpan && valueEnd && new ParseSourceSpan(valueStartSpan.start, valueEnd, valueStartSpan.fullStart);
20777
21033
  return new Attribute(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, attrEnd, attrName.sourceSpan.fullStart), attrName.sourceSpan, valueSpan, valueTokens.length > 0 ? valueTokens : void 0, void 0);
20778
21034
  }
20779
- _consumeBlockGroupOpen(token) {
20780
- const end = this._peek.sourceSpan.fullStart;
20781
- const span = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);
20782
- const startSpan = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);
20783
- const blockGroup = new BlockGroup([], span, startSpan, null);
20784
- this._pushContainer(blockGroup, false);
20785
- const implicitBlock = this._consumeBlock(token, 26);
20786
- startSpan.end = implicitBlock.startSourceSpan.end;
20787
- }
20788
- _consumeBlock(token, closeToken) {
20789
- this._conditionallyClosePreviousBlock();
21035
+ _consumeBlockOpen(token) {
20790
21036
  const parameters = [];
20791
- while (this._peek.type === 28) {
21037
+ while (this._peek.type === 27) {
20792
21038
  const paramToken = this._advance();
20793
21039
  parameters.push(new BlockParameter(paramToken.parts[0], paramToken.sourceSpan));
20794
21040
  }
20795
- if (this._peek.type === closeToken) {
21041
+ if (this._peek.type === 25) {
20796
21042
  this._advance();
20797
21043
  }
20798
21044
  const end = this._peek.sourceSpan.fullStart;
20799
21045
  const span = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);
20800
21046
  const startSpan = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);
20801
21047
  const block = new Block(token.parts[0], parameters, [], span, startSpan);
20802
- const parent = this._getContainer();
20803
- if (!(parent instanceof BlockGroup)) {
20804
- this.errors.push(TreeError.create(block.name, block.sourceSpan, "Blocks can only be placed inside of block groups."));
20805
- } else {
20806
- parent.blocks.push(block);
20807
- this._containerStack.push(block);
20808
- }
21048
+ this._pushContainer(block, false);
20809
21049
  return block;
20810
21050
  }
20811
- _consumeBlockGroupClose(token) {
20812
- const name = token.parts[0];
21051
+ _consumeBlockClose(token) {
20813
21052
  const previousContainer = this._getContainer();
20814
- this._conditionallyClosePreviousBlock();
20815
- if (!this._popContainer(name, BlockGroup, token.sourceSpan)) {
20816
- const context = previousContainer instanceof Element ? `There is an unclosed "${previousContainer.name}" HTML tag named that may have to be closed first.` : `The block may have been closed earlier.`;
20817
- this.errors.push(TreeError.create(name, token.sourceSpan, `Unexpected closing block "${name}". ${context}`));
20818
- }
20819
- }
20820
- _conditionallyClosePreviousBlock() {
20821
- const container = this._getContainer();
20822
- if (container instanceof Block) {
20823
- const lastChild = container.children.length ? container.children[container.children.length - 1] : null;
20824
- const endSpan = lastChild === null ? null : new ParseSourceSpan(lastChild.sourceSpan.end, lastChild.sourceSpan.end);
20825
- this._popContainer(container.name, Block, endSpan);
21053
+ if (!this._popContainer(null, Block, token.sourceSpan)) {
21054
+ const context = previousContainer instanceof Element ? `There is an unclosed "${previousContainer.name}" HTML tag that may have to be closed first.` : `The block may have been closed earlier.`;
21055
+ this.errors.push(TreeError.create(null, token.sourceSpan, `Unexpected closing block. ${context}`));
20826
21056
  }
20827
21057
  }
20828
21058
  _getContainer() {
@@ -20840,8 +21070,6 @@ var _TreeBuilder = class {
20840
21070
  const parent = this._getContainer();
20841
21071
  if (parent === null) {
20842
21072
  this.rootNodes.push(node);
20843
- } else if (parent instanceof BlockGroup) {
20844
- this.errors.push(TreeError.create(null, node.sourceSpan, "Block groups can only contain blocks."));
20845
21073
  } else {
20846
21074
  parent.children.push(node);
20847
21075
  }
@@ -20987,10 +21215,6 @@ var I18nMetaVisitor = class {
20987
21215
  visitExpansionCase(expansionCase) {
20988
21216
  return expansionCase;
20989
21217
  }
20990
- visitBlockGroup(group, context) {
20991
- visitAll(this, group.blocks, context);
20992
- return group;
20993
- }
20994
21218
  visitBlock(block, context) {
20995
21219
  visitAll(this, block.children, context);
20996
21220
  return block;
@@ -21180,7 +21404,7 @@ function phaseI18nMessageExtraction(job) {
21180
21404
  for (const unit of job.units) {
21181
21405
  for (const op of unit.create) {
21182
21406
  if (op.kind === OpKind.I18nStart && op.i18n instanceof Message) {
21183
- const params = op.tagNameParams;
21407
+ const params = Object.fromEntries(Object.entries(op.tagNameParams).sort());
21184
21408
  const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX));
21185
21409
  const closureVar = i18nGenerateClosureVar(job.pool, op.i18n.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
21186
21410
  const statements = getTranslationDeclStmts$1(op.i18n, mainVar, closureVar, params, void 0);
@@ -21337,47 +21561,6 @@ function hyphenate(value) {
21337
21561
  return v.charAt(0) + "-" + v.charAt(1);
21338
21562
  }).toLowerCase();
21339
21563
  }
21340
- var BINARY_OPERATORS = /* @__PURE__ */ new Map([
21341
- ["&&", BinaryOperator.And],
21342
- [">", BinaryOperator.Bigger],
21343
- [">=", BinaryOperator.BiggerEquals],
21344
- ["&", BinaryOperator.BitwiseAnd],
21345
- ["/", BinaryOperator.Divide],
21346
- ["==", BinaryOperator.Equals],
21347
- ["===", BinaryOperator.Identical],
21348
- ["<", BinaryOperator.Lower],
21349
- ["<=", BinaryOperator.LowerEquals],
21350
- ["-", BinaryOperator.Minus],
21351
- ["%", BinaryOperator.Modulo],
21352
- ["*", BinaryOperator.Multiply],
21353
- ["!=", BinaryOperator.NotEquals],
21354
- ["!==", BinaryOperator.NotIdentical],
21355
- ["??", BinaryOperator.NullishCoalesce],
21356
- ["||", BinaryOperator.Or],
21357
- ["+", BinaryOperator.Plus]
21358
- ]);
21359
- var NAMESPACES = /* @__PURE__ */ new Map([["svg", Namespace.SVG], ["math", Namespace.Math]]);
21360
- function namespaceForKey(namespacePrefixKey) {
21361
- var _a2;
21362
- if (namespacePrefixKey === null) {
21363
- return Namespace.HTML;
21364
- }
21365
- return (_a2 = NAMESPACES.get(namespacePrefixKey)) != null ? _a2 : Namespace.HTML;
21366
- }
21367
- function keyForNamespace(namespace) {
21368
- for (const [k, n] of NAMESPACES.entries()) {
21369
- if (n === namespace) {
21370
- return k;
21371
- }
21372
- }
21373
- return null;
21374
- }
21375
- function prefixWithNamespace(strippedTag, namespace) {
21376
- if (namespace === Namespace.HTML) {
21377
- return strippedTag;
21378
- }
21379
- return `:${keyForNamespace(namespace)}:${strippedTag}`;
21380
- }
21381
21564
  function phaseNaming(cpl) {
21382
21565
  addNamesToView(cpl.root, cpl.componentName, { index: 0 }, cpl.compatibility === CompatibilityMode.TemplateDefinitionBuilder);
21383
21566
  }
@@ -21559,7 +21742,7 @@ function phaseNoListenersOnTemplates(job) {
21559
21742
  }
21560
21743
  }
21561
21744
  }
21562
- function lookupElement(elements, xref) {
21745
+ function lookupElement$1(elements, xref) {
21563
21746
  const el = elements.get(xref);
21564
21747
  if (el === void 0) {
21565
21748
  throw new Error("All attributes should have an element-like target.");
@@ -21581,7 +21764,7 @@ function phaseNonbindable(job) {
21581
21764
  if ((op.kind === OpKind.ElementStart || op.kind === OpKind.ContainerStart) && op.nonBindable) {
21582
21765
  OpList.insertAfter(createDisableBindingsOp(op.xref), op);
21583
21766
  }
21584
- if ((op.kind === OpKind.ElementEnd || op.kind === OpKind.ContainerEnd) && lookupElement(elements, op.xref).nonBindable) {
21767
+ if ((op.kind === OpKind.ElementEnd || op.kind === OpKind.ContainerEnd) && lookupElement$1(elements, op.xref).nonBindable) {
21585
21768
  OpList.insertBefore(createEnableBindingsOp(op.xref), op);
21586
21769
  }
21587
21770
  }
@@ -21866,8 +22049,11 @@ function elementContainerEnd() {
21866
22049
  }
21867
22050
  function template(slot, templateFnRef, decls, vars, tag, constIndex, sourceSpan) {
21868
22051
  const args = [literal(slot), templateFnRef, literal(decls), literal(vars)];
21869
- if (tag != null && constIndex != null) {
21870
- args.push(literal(tag), literal(constIndex));
22052
+ if (tag !== null) {
22053
+ args.push(literal(tag));
22054
+ if (constIndex !== null) {
22055
+ args.push(literal(constIndex));
22056
+ }
21871
22057
  }
21872
22058
  return call(Identifiers.templateCreate, args, sourceSpan);
21873
22059
  }
@@ -21877,17 +22063,17 @@ function disableBindings() {
21877
22063
  function enableBindings() {
21878
22064
  return call(Identifiers.enableBindings, [], null);
21879
22065
  }
21880
- function listener(name, handlerFn) {
22066
+ function listener(name, handlerFn, sourceSpan) {
21881
22067
  return call(Identifiers.listener, [
21882
22068
  literal(name),
21883
22069
  handlerFn
21884
- ], null);
22070
+ ], sourceSpan);
21885
22071
  }
21886
- function syntheticHostListener(name, handlerFn) {
22072
+ function syntheticHostListener(name, handlerFn, sourceSpan) {
21887
22073
  return call(Identifiers.syntheticHostListener, [
21888
22074
  literal(name),
21889
22075
  handlerFn
21890
- ], null);
22076
+ ], sourceSpan);
21891
22077
  }
21892
22078
  function pipe(slot, name) {
21893
22079
  return call(Identifiers.pipe, [
@@ -21937,6 +22123,19 @@ function text(slot, initialValue, sourceSpan) {
21937
22123
  }
21938
22124
  return call(Identifiers.text, args, sourceSpan);
21939
22125
  }
22126
+ function projectionDef(def) {
22127
+ return call(Identifiers.projectionDef, def ? [def] : [], null);
22128
+ }
22129
+ function projection(slot, projectionSlotIndex, attributes) {
22130
+ const args = [literal(slot)];
22131
+ if (projectionSlotIndex !== 0 || attributes !== null) {
22132
+ args.push(literal(projectionSlotIndex));
22133
+ if (attributes != null) {
22134
+ args.push(literal(attributes));
22135
+ }
22136
+ }
22137
+ return call(Identifiers.projection, args, null);
22138
+ }
21940
22139
  function i18nStart(slot, constIndex) {
21941
22140
  return call(Identifiers.i18nStart, [literal(slot), literal(constIndex)], null);
21942
22141
  }
@@ -21960,21 +22159,21 @@ function attribute(name, expression, sanitizer) {
21960
22159
  }
21961
22160
  return call(Identifiers.attribute, args, null);
21962
22161
  }
21963
- function styleProp(name, expression, unit) {
22162
+ function styleProp(name, expression, unit, sourceSpan) {
21964
22163
  const args = [literal(name), expression];
21965
22164
  if (unit !== null) {
21966
22165
  args.push(literal(unit));
21967
22166
  }
21968
- return call(Identifiers.styleProp, args, null);
22167
+ return call(Identifiers.styleProp, args, sourceSpan);
21969
22168
  }
21970
- function classProp(name, expression) {
21971
- return call(Identifiers.classProp, [literal(name), expression], null);
22169
+ function classProp(name, expression, sourceSpan) {
22170
+ return call(Identifiers.classProp, [literal(name), expression], sourceSpan);
21972
22171
  }
21973
- function styleMap(expression) {
21974
- return call(Identifiers.styleMap, [expression], null);
22172
+ function styleMap(expression, sourceSpan) {
22173
+ return call(Identifiers.styleMap, [expression], sourceSpan);
21975
22174
  }
21976
- function classMap(expression) {
21977
- return call(Identifiers.classMap, [expression], null);
22175
+ function classMap(expression, sourceSpan) {
22176
+ return call(Identifiers.classMap, [expression], sourceSpan);
21978
22177
  }
21979
22178
  var PIPE_BINDINGS = [
21980
22179
  Identifiers.pipeBind1,
@@ -22024,35 +22223,35 @@ function propertyInterpolate(name, strings, expressions, sanitizer, sourceSpan)
22024
22223
  }
22025
22224
  return callVariadicInstruction(PROPERTY_INTERPOLATE_CONFIG, [literal(name)], interpolationArgs, extraArgs, sourceSpan);
22026
22225
  }
22027
- function attributeInterpolate(name, strings, expressions, sanitizer) {
22226
+ function attributeInterpolate(name, strings, expressions, sanitizer, sourceSpan) {
22028
22227
  const interpolationArgs = collateInterpolationArgs(strings, expressions);
22029
22228
  const extraArgs = [];
22030
22229
  if (sanitizer !== null) {
22031
22230
  extraArgs.push(sanitizer);
22032
22231
  }
22033
- return callVariadicInstruction(ATTRIBUTE_INTERPOLATE_CONFIG, [literal(name)], interpolationArgs, extraArgs, null);
22232
+ return callVariadicInstruction(ATTRIBUTE_INTERPOLATE_CONFIG, [literal(name)], interpolationArgs, extraArgs, sourceSpan);
22034
22233
  }
22035
- function stylePropInterpolate(name, strings, expressions, unit) {
22234
+ function stylePropInterpolate(name, strings, expressions, unit, sourceSpan) {
22036
22235
  const interpolationArgs = collateInterpolationArgs(strings, expressions);
22037
22236
  const extraArgs = [];
22038
22237
  if (unit !== null) {
22039
22238
  extraArgs.push(literal(unit));
22040
22239
  }
22041
- return callVariadicInstruction(STYLE_PROP_INTERPOLATE_CONFIG, [literal(name)], interpolationArgs, extraArgs, null);
22240
+ return callVariadicInstruction(STYLE_PROP_INTERPOLATE_CONFIG, [literal(name)], interpolationArgs, extraArgs, sourceSpan);
22042
22241
  }
22043
- function styleMapInterpolate(strings, expressions) {
22242
+ function styleMapInterpolate(strings, expressions, sourceSpan) {
22044
22243
  const interpolationArgs = collateInterpolationArgs(strings, expressions);
22045
- return callVariadicInstruction(STYLE_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], null);
22244
+ return callVariadicInstruction(STYLE_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], sourceSpan);
22046
22245
  }
22047
- function classMapInterpolate(strings, expressions) {
22246
+ function classMapInterpolate(strings, expressions, sourceSpan) {
22048
22247
  const interpolationArgs = collateInterpolationArgs(strings, expressions);
22049
- return callVariadicInstruction(CLASS_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], null);
22248
+ return callVariadicInstruction(CLASS_MAP_INTERPOLATE_CONFIG, [], interpolationArgs, [], sourceSpan);
22050
22249
  }
22051
- function hostProperty(name, expression) {
22052
- return call(Identifiers.hostProperty, [literal(name), expression], null);
22250
+ function hostProperty(name, expression, sourceSpan) {
22251
+ return call(Identifiers.hostProperty, [literal(name), expression], sourceSpan);
22053
22252
  }
22054
- function syntheticHostProperty(name, expression) {
22055
- return call(Identifiers.syntheticHostProperty, [literal(name), expression], null);
22253
+ function syntheticHostProperty(name, expression, sourceSpan) {
22254
+ return call(Identifiers.syntheticHostProperty, [literal(name), expression], sourceSpan);
22056
22255
  }
22057
22256
  function pureFunction(varOffset, fn2, args) {
22058
22257
  return callVariadicInstructionExpr(PURE_FUNCTION_CONFIG, [
@@ -22284,7 +22483,7 @@ function reifyCreateOperations(unit, ops) {
22284
22483
  throw new Error(`AssertionError: must be compiling a component`);
22285
22484
  }
22286
22485
  const childView = unit.job.views.get(op.xref);
22287
- OpList.replace(op, template(op.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.sourceSpan));
22486
+ OpList.replace(op, template(op.slot, variable(childView.fnName), childView.decls, childView.vars, op.controlFlow ? null : op.tag, op.attributes, op.sourceSpan));
22288
22487
  break;
22289
22488
  case OpKind.DisableBindings:
22290
22489
  OpList.replace(op, disableBindings());
@@ -22297,7 +22496,7 @@ function reifyCreateOperations(unit, ops) {
22297
22496
  break;
22298
22497
  case OpKind.Listener:
22299
22498
  const listenerFn = reifyListenerHandler(unit, op.handlerFnName, op.handlerOps, op.consumesDollarEvent);
22300
- const reified = op.hostListener && op.isAnimationListener ? syntheticHostListener(op.name, listenerFn) : listener(op.name, listenerFn);
22499
+ const reified = op.hostListener && op.isAnimationListener ? syntheticHostListener(op.name, listenerFn, op.sourceSpan) : listener(op.name, listenerFn, op.sourceSpan);
22301
22500
  OpList.replace(op, reified);
22302
22501
  break;
22303
22502
  case OpKind.Variable:
@@ -22319,6 +22518,15 @@ function reifyCreateOperations(unit, ops) {
22319
22518
  break;
22320
22519
  }
22321
22520
  break;
22521
+ case OpKind.ProjectionDef:
22522
+ OpList.replace(op, projectionDef(op.def));
22523
+ break;
22524
+ case OpKind.Projection:
22525
+ if (op.slot === null) {
22526
+ throw new Error("No slot was assigned for project instruction");
22527
+ }
22528
+ OpList.replace(op, projection(op.slot, op.projectionSlotIndex, op.attributes));
22529
+ break;
22322
22530
  case OpKind.Statement:
22323
22531
  break;
22324
22532
  default:
@@ -22342,26 +22550,26 @@ function reifyUpdateOperations(_unit, ops) {
22342
22550
  break;
22343
22551
  case OpKind.StyleProp:
22344
22552
  if (op.expression instanceof Interpolation) {
22345
- OpList.replace(op, stylePropInterpolate(op.name, op.expression.strings, op.expression.expressions, op.unit));
22553
+ OpList.replace(op, stylePropInterpolate(op.name, op.expression.strings, op.expression.expressions, op.unit, op.sourceSpan));
22346
22554
  } else {
22347
- OpList.replace(op, styleProp(op.name, op.expression, op.unit));
22555
+ OpList.replace(op, styleProp(op.name, op.expression, op.unit, op.sourceSpan));
22348
22556
  }
22349
22557
  break;
22350
22558
  case OpKind.ClassProp:
22351
- OpList.replace(op, classProp(op.name, op.expression));
22559
+ OpList.replace(op, classProp(op.name, op.expression, op.sourceSpan));
22352
22560
  break;
22353
22561
  case OpKind.StyleMap:
22354
22562
  if (op.expression instanceof Interpolation) {
22355
- OpList.replace(op, styleMapInterpolate(op.expression.strings, op.expression.expressions));
22563
+ OpList.replace(op, styleMapInterpolate(op.expression.strings, op.expression.expressions, op.sourceSpan));
22356
22564
  } else {
22357
- OpList.replace(op, styleMap(op.expression));
22565
+ OpList.replace(op, styleMap(op.expression, op.sourceSpan));
22358
22566
  }
22359
22567
  break;
22360
22568
  case OpKind.ClassMap:
22361
22569
  if (op.expression instanceof Interpolation) {
22362
- OpList.replace(op, classMapInterpolate(op.expression.strings, op.expression.expressions));
22570
+ OpList.replace(op, classMapInterpolate(op.expression.strings, op.expression.expressions, op.sourceSpan));
22363
22571
  } else {
22364
- OpList.replace(op, classMap(op.expression));
22572
+ OpList.replace(op, classMap(op.expression, op.sourceSpan));
22365
22573
  }
22366
22574
  break;
22367
22575
  case OpKind.InterpolateText:
@@ -22369,7 +22577,7 @@ function reifyUpdateOperations(_unit, ops) {
22369
22577
  break;
22370
22578
  case OpKind.Attribute:
22371
22579
  if (op.expression instanceof Interpolation) {
22372
- OpList.replace(op, attributeInterpolate(op.name, op.expression.strings, op.expression.expressions, op.sanitizer));
22580
+ OpList.replace(op, attributeInterpolate(op.name, op.expression.strings, op.expression.expressions, op.sanitizer, op.sourceSpan));
22373
22581
  } else {
22374
22582
  OpList.replace(op, attribute(op.name, op.expression, op.sanitizer));
22375
22583
  }
@@ -22379,9 +22587,9 @@ function reifyUpdateOperations(_unit, ops) {
22379
22587
  throw new Error("not yet handled");
22380
22588
  } else {
22381
22589
  if (op.isAnimationTrigger) {
22382
- OpList.replace(op, syntheticHostProperty(op.name, op.expression));
22590
+ OpList.replace(op, syntheticHostProperty(op.name, op.expression, op.sourceSpan));
22383
22591
  } else {
22384
- OpList.replace(op, hostProperty(op.name, op.expression));
22592
+ OpList.replace(op, hostProperty(op.name, op.expression, op.sourceSpan));
22385
22593
  }
22386
22594
  }
22387
22595
  break;
@@ -23044,12 +23252,75 @@ function allowConservativeInlining(decl2, target) {
23044
23252
  return true;
23045
23253
  }
23046
23254
  }
23047
- var phases = [
23048
- { kind: CompilationJobKind.Tmpl, fn: phaseGenerateI18nBlocks },
23049
- { kind: CompilationJobKind.Tmpl, fn: phaseI18nTextExtraction },
23050
- { kind: CompilationJobKind.Host, fn: phaseHostStylePropertyParsing },
23051
- { kind: CompilationJobKind.Tmpl, fn: phaseNamespace },
23052
- { kind: CompilationJobKind.Both, fn: phaseStyleBindingSpecialization },
23255
+ function phaseGenerateProjectionDef(job) {
23256
+ const share = job.compatibility === CompatibilityMode.TemplateDefinitionBuilder;
23257
+ const selectors = [];
23258
+ let projectionSlotIndex = 0;
23259
+ for (const unit of job.units) {
23260
+ for (const op of unit.create) {
23261
+ if (op.kind === OpKind.Projection) {
23262
+ selectors.push(op.selector);
23263
+ op.projectionSlotIndex = projectionSlotIndex++;
23264
+ }
23265
+ }
23266
+ }
23267
+ if (selectors.length > 0) {
23268
+ let defExpr = null;
23269
+ if (selectors.length > 1 || selectors[0] !== "*") {
23270
+ const def = selectors.map((s) => s === "*" ? s : parseSelectorToR3Selector(s));
23271
+ defExpr = job.pool.getConstLiteral(literalOrArrayLiteral(def), share);
23272
+ }
23273
+ job.contentSelectors = job.pool.getConstLiteral(literalOrArrayLiteral(selectors), share);
23274
+ job.root.create.prepend([createProjectionDefOp(defExpr)]);
23275
+ }
23276
+ }
23277
+ function phaseI18nConstCollection(job) {
23278
+ const messageConstIndices = {};
23279
+ for (const unit of job.units) {
23280
+ for (const op of unit.create) {
23281
+ if (op.kind === OpKind.ExtractedMessage) {
23282
+ messageConstIndices[op.owner] = job.addConst(op.expression, op.statements);
23283
+ OpList.remove(op);
23284
+ }
23285
+ }
23286
+ }
23287
+ for (const unit of job.units) {
23288
+ for (const op of unit.create) {
23289
+ if (op.kind === OpKind.I18nStart && messageConstIndices[op.xref] !== void 0) {
23290
+ op.messageIndex = messageConstIndices[op.xref];
23291
+ }
23292
+ }
23293
+ }
23294
+ }
23295
+ function phaseRemoveContentSelectors(job) {
23296
+ for (const unit of job.units) {
23297
+ const elements = getElementsByXrefId(unit);
23298
+ for (const op of unit.update) {
23299
+ switch (op.kind) {
23300
+ case OpKind.Binding:
23301
+ const target = lookupElement(elements, op.target);
23302
+ if (op.name.toLowerCase() === "select" && target.kind === OpKind.Projection) {
23303
+ OpList.remove(op);
23304
+ }
23305
+ continue;
23306
+ }
23307
+ }
23308
+ }
23309
+ }
23310
+ function lookupElement(elements, xref) {
23311
+ const el = elements.get(xref);
23312
+ if (el === void 0) {
23313
+ throw new Error("All attributes should have an element-like target.");
23314
+ }
23315
+ return el;
23316
+ }
23317
+ var phases = [
23318
+ { kind: CompilationJobKind.Tmpl, fn: phaseRemoveContentSelectors },
23319
+ { kind: CompilationJobKind.Tmpl, fn: phaseGenerateI18nBlocks },
23320
+ { kind: CompilationJobKind.Tmpl, fn: phaseI18nTextExtraction },
23321
+ { kind: CompilationJobKind.Host, fn: phaseHostStylePropertyParsing },
23322
+ { kind: CompilationJobKind.Tmpl, fn: phaseNamespace },
23323
+ { kind: CompilationJobKind.Both, fn: phaseStyleBindingSpecialization },
23053
23324
  { kind: CompilationJobKind.Both, fn: phaseBindingSpecialization },
23054
23325
  { kind: CompilationJobKind.Both, fn: phaseAttributeExtraction },
23055
23326
  { kind: CompilationJobKind.Both, fn: phaseParseExtractedStyles },
@@ -23059,6 +23330,7 @@ var phases = [
23059
23330
  { kind: CompilationJobKind.Tmpl, fn: phasePipeCreation },
23060
23331
  { kind: CompilationJobKind.Tmpl, fn: phasePipeVariadic },
23061
23332
  { kind: CompilationJobKind.Both, fn: phasePureLiteralStructures },
23333
+ { kind: CompilationJobKind.Tmpl, fn: phaseGenerateProjectionDef },
23062
23334
  { kind: CompilationJobKind.Tmpl, fn: phaseGenerateVariables },
23063
23335
  { kind: CompilationJobKind.Tmpl, fn: phaseSaveRestoreView },
23064
23336
  { kind: CompilationJobKind.Tmpl, fn: phaseFindAnyCasts },
@@ -23073,6 +23345,7 @@ var phases = [
23073
23345
  { kind: CompilationJobKind.Tmpl, fn: phaseSlotAllocation },
23074
23346
  { kind: CompilationJobKind.Tmpl, fn: phaseResolveI18nPlaceholders },
23075
23347
  { kind: CompilationJobKind.Tmpl, fn: phaseI18nMessageExtraction },
23348
+ { kind: CompilationJobKind.Tmpl, fn: phaseI18nConstCollection },
23076
23349
  { kind: CompilationJobKind.Both, fn: phaseConstCollection },
23077
23350
  { kind: CompilationJobKind.Both, fn: phaseVarCounting },
23078
23351
  { kind: CompilationJobKind.Tmpl, fn: phaseGenerateAdvance },
@@ -23213,9 +23486,9 @@ function ingestHostProperty(job, property2, isTextAttribute) {
23213
23486
  let expression;
23214
23487
  const ast = property2.expression.ast;
23215
23488
  if (ast instanceof Interpolation$1) {
23216
- expression = new Interpolation(ast.strings, ast.expressions.map((expr) => convertAst(expr, job)));
23489
+ expression = new Interpolation(ast.strings, ast.expressions.map((expr) => convertAst(expr, job, property2.sourceSpan)));
23217
23490
  } else {
23218
- expression = convertAst(ast, job);
23491
+ expression = convertAst(ast, job, property2.sourceSpan);
23219
23492
  }
23220
23493
  let bindingKind = BindingKind.Property;
23221
23494
  if (property2.name.startsWith("attr.")) {
@@ -23242,8 +23515,8 @@ function ingestHostAttribute(job, name, value) {
23242
23515
  job.root.update.push(attrBinding);
23243
23516
  }
23244
23517
  function ingestHostEvent(job, event) {
23245
- const eventBinding = createListenerOp(job.root.xref, event.name, null, event.targetOrPhase, true);
23246
- eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job))));
23518
+ const eventBinding = createListenerOp(job.root.xref, event.name, null, event.targetOrPhase, true, event.sourceSpan);
23519
+ eventBinding.handlerOps.push(createStatementOp(new ReturnStatement(convertAst(event.handler.ast, job, event.sourceSpan), event.handlerSpan)));
23247
23520
  job.root.create.push(eventBinding);
23248
23521
  }
23249
23522
  function ingestNodes(unit, template2) {
@@ -23252,6 +23525,8 @@ function ingestNodes(unit, template2) {
23252
23525
  ingestElement(unit, node);
23253
23526
  } else if (node instanceof Template) {
23254
23527
  ingestTemplate(unit, node);
23528
+ } else if (node instanceof Content) {
23529
+ ingestContent(unit, node);
23255
23530
  } else if (node instanceof Text$3) {
23256
23531
  ingestText(unit, node);
23257
23532
  } else if (node instanceof BoundText) {
@@ -23284,7 +23559,7 @@ function ingestTemplate(unit, tmpl) {
23284
23559
  if (tmpl.tagName) {
23285
23560
  [namespacePrefix, tagNameWithoutNamespace] = splitNsName(tmpl.tagName);
23286
23561
  }
23287
- const tplOp = createTemplateOp(childView.xref, tagNameWithoutNamespace != null ? tagNameWithoutNamespace : "ng-template", namespaceForKey(namespacePrefix), tmpl.i18n, tmpl.startSourceSpan);
23562
+ const tplOp = createTemplateOp(childView.xref, tagNameWithoutNamespace != null ? tagNameWithoutNamespace : "ng-template", namespaceForKey(namespacePrefix), false, tmpl.i18n, tmpl.startSourceSpan);
23288
23563
  unit.create.push(tplOp);
23289
23564
  ingestBindings(unit, tplOp, tmpl);
23290
23565
  ingestReferences(tplOp, tmpl);
@@ -23293,6 +23568,13 @@ function ingestTemplate(unit, tmpl) {
23293
23568
  childView.contextVariables.set(name, value);
23294
23569
  }
23295
23570
  }
23571
+ function ingestContent(unit, content) {
23572
+ const op = createProjectionOp(unit.job.allocateXrefId(), content.selector);
23573
+ for (const attr of content.attributes) {
23574
+ ingestBinding(unit, op.xref, attr.name, literal(attr.value), 1, null, SecurityContext.NONE, attr.sourceSpan, true, false);
23575
+ }
23576
+ unit.create.push(op);
23577
+ }
23296
23578
  function ingestText(unit, text2) {
23297
23579
  unit.create.push(createTextOp(unit.job.allocateXrefId(), text2.value, text2.sourceSpan));
23298
23580
  }
@@ -23306,7 +23588,8 @@ function ingestBoundText(unit, text2) {
23306
23588
  }
23307
23589
  const textXref = unit.job.allocateXrefId();
23308
23590
  unit.create.push(createTextOp(textXref, "", text2.sourceSpan));
23309
- unit.update.push(createInterpolateTextOp(textXref, new Interpolation(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job))), text2.sourceSpan));
23591
+ const baseSourceSpan = unit.job.compatibility ? null : text2.sourceSpan;
23592
+ unit.update.push(createInterpolateTextOp(textXref, new Interpolation(value.strings, value.expressions.map((expr) => convertAst(expr, unit.job, baseSourceSpan))), text2.sourceSpan));
23310
23593
  }
23311
23594
  function ingestSwitchBlock(unit, switchBlock) {
23312
23595
  let firstXref = null;
@@ -23315,73 +23598,73 @@ function ingestSwitchBlock(unit, switchBlock) {
23315
23598
  const cView = unit.job.allocateView(unit.xref);
23316
23599
  if (!firstXref)
23317
23600
  firstXref = cView.xref;
23318
- unit.create.push(createTemplateOp(cView.xref, "Case", Namespace.HTML, void 0, null));
23319
- const caseExpr = switchCase.expression ? convertAst(switchCase.expression, unit.job) : null;
23601
+ unit.create.push(createTemplateOp(cView.xref, "Case", Namespace.HTML, true, void 0, null));
23602
+ const caseExpr = switchCase.expression ? convertAst(switchCase.expression, unit.job, switchBlock.startSourceSpan) : null;
23320
23603
  conditions.push([cView.xref, caseExpr]);
23321
23604
  ingestNodes(cView, switchCase.children);
23322
23605
  }
23323
- const conditional2 = createConditionalOp(firstXref, convertAst(switchBlock.expression, unit.job), null);
23606
+ const conditional2 = createConditionalOp(firstXref, convertAst(switchBlock.expression, unit.job, switchBlock.startSourceSpan), null);
23324
23607
  conditional2.conditions = conditions;
23325
23608
  unit.update.push(conditional2);
23326
23609
  }
23327
- function convertAst(ast, job) {
23610
+ function convertAst(ast, job, baseSourceSpan) {
23328
23611
  if (ast instanceof ASTWithSource) {
23329
- return convertAst(ast.ast, job);
23612
+ return convertAst(ast.ast, job, baseSourceSpan);
23330
23613
  } else if (ast instanceof PropertyRead) {
23331
23614
  if (ast.receiver instanceof ImplicitReceiver && !(ast.receiver instanceof ThisReceiver)) {
23332
23615
  return new LexicalReadExpr(ast.name);
23333
23616
  } else {
23334
- return new ReadPropExpr(convertAst(ast.receiver, job), ast.name);
23617
+ return new ReadPropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, null, convertSourceSpan(ast.span, baseSourceSpan));
23335
23618
  }
23336
23619
  } else if (ast instanceof PropertyWrite) {
23337
- return new WritePropExpr(convertAst(ast.receiver, job), ast.name, convertAst(ast.value, job));
23620
+ return new WritePropExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name, convertAst(ast.value, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
23338
23621
  } else if (ast instanceof KeyedWrite) {
23339
- return new WriteKeyExpr(convertAst(ast.receiver, job), convertAst(ast.key, job), convertAst(ast.value, job));
23622
+ return new WriteKeyExpr(convertAst(ast.receiver, job, baseSourceSpan), convertAst(ast.key, job, baseSourceSpan), convertAst(ast.value, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
23340
23623
  } else if (ast instanceof Call) {
23341
23624
  if (ast.receiver instanceof ImplicitReceiver) {
23342
23625
  throw new Error(`Unexpected ImplicitReceiver`);
23343
23626
  } else {
23344
- return new InvokeFunctionExpr(convertAst(ast.receiver, job), ast.args.map((arg) => convertAst(arg, job)));
23627
+ return new InvokeFunctionExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.args.map((arg) => convertAst(arg, job, baseSourceSpan)), void 0, convertSourceSpan(ast.span, baseSourceSpan));
23345
23628
  }
23346
23629
  } else if (ast instanceof LiteralPrimitive) {
23347
- return literal(ast.value);
23630
+ return literal(ast.value, void 0, convertSourceSpan(ast.span, baseSourceSpan));
23348
23631
  } else if (ast instanceof Binary) {
23349
23632
  const operator = BINARY_OPERATORS.get(ast.operation);
23350
23633
  if (operator === void 0) {
23351
23634
  throw new Error(`AssertionError: unknown binary operator ${ast.operation}`);
23352
23635
  }
23353
- return new BinaryOperatorExpr(operator, convertAst(ast.left, job), convertAst(ast.right, job));
23636
+ return new BinaryOperatorExpr(operator, convertAst(ast.left, job, baseSourceSpan), convertAst(ast.right, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
23354
23637
  } else if (ast instanceof ThisReceiver) {
23355
23638
  return new ContextExpr(job.root.xref);
23356
23639
  } else if (ast instanceof KeyedRead) {
23357
- return new ReadKeyExpr(convertAst(ast.receiver, job), convertAst(ast.key, job));
23640
+ return new ReadKeyExpr(convertAst(ast.receiver, job, baseSourceSpan), convertAst(ast.key, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
23358
23641
  } else if (ast instanceof Chain) {
23359
23642
  throw new Error(`AssertionError: Chain in unknown context`);
23360
23643
  } else if (ast instanceof LiteralMap) {
23361
23644
  const entries = ast.keys.map((key, idx) => {
23362
23645
  const value = ast.values[idx];
23363
- return new LiteralMapEntry(key.key, convertAst(value, job), key.quoted);
23646
+ return new LiteralMapEntry(key.key, convertAst(value, job, baseSourceSpan), key.quoted);
23364
23647
  });
23365
- return new LiteralMapExpr(entries);
23648
+ return new LiteralMapExpr(entries, void 0, convertSourceSpan(ast.span, baseSourceSpan));
23366
23649
  } else if (ast instanceof LiteralArray) {
23367
- return new LiteralArrayExpr(ast.expressions.map((expr) => convertAst(expr, job)));
23650
+ return new LiteralArrayExpr(ast.expressions.map((expr) => convertAst(expr, job, baseSourceSpan)));
23368
23651
  } else if (ast instanceof Conditional) {
23369
- return new ConditionalExpr(convertAst(ast.condition, job), convertAst(ast.trueExp, job), convertAst(ast.falseExp, job));
23652
+ return new ConditionalExpr(convertAst(ast.condition, job, baseSourceSpan), convertAst(ast.trueExp, job, baseSourceSpan), convertAst(ast.falseExp, job, baseSourceSpan), void 0, convertSourceSpan(ast.span, baseSourceSpan));
23370
23653
  } else if (ast instanceof NonNullAssert) {
23371
- return convertAst(ast.expression, job);
23654
+ return convertAst(ast.expression, job, baseSourceSpan);
23372
23655
  } else if (ast instanceof BindingPipe) {
23373
23656
  return new PipeBindingExpr(job.allocateXrefId(), ast.name, [
23374
- convertAst(ast.exp, job),
23375
- ...ast.args.map((arg) => convertAst(arg, job))
23657
+ convertAst(ast.exp, job, baseSourceSpan),
23658
+ ...ast.args.map((arg) => convertAst(arg, job, baseSourceSpan))
23376
23659
  ]);
23377
23660
  } else if (ast instanceof SafeKeyedRead) {
23378
- return new SafeKeyedReadExpr(convertAst(ast.receiver, job), convertAst(ast.key, job));
23661
+ return new SafeKeyedReadExpr(convertAst(ast.receiver, job, baseSourceSpan), convertAst(ast.key, job, baseSourceSpan), convertSourceSpan(ast.span, baseSourceSpan));
23379
23662
  } else if (ast instanceof SafePropertyRead) {
23380
- return new SafePropertyReadExpr(convertAst(ast.receiver, job), ast.name);
23663
+ return new SafePropertyReadExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.name);
23381
23664
  } else if (ast instanceof SafeCall) {
23382
- return new SafeInvokeFunctionExpr(convertAst(ast.receiver, job), ast.args.map((a) => convertAst(a, job)));
23665
+ return new SafeInvokeFunctionExpr(convertAst(ast.receiver, job, baseSourceSpan), ast.args.map((a) => convertAst(a, job, baseSourceSpan)));
23383
23666
  } else if (ast instanceof EmptyExpr$1) {
23384
- return new EmptyExpr();
23667
+ return new EmptyExpr(convertSourceSpan(ast.span, baseSourceSpan));
23385
23668
  } else {
23386
23669
  throw new Error(`Unhandled expression type: ${ast.constructor.name}`);
23387
23670
  }
@@ -23409,27 +23692,27 @@ function ingestBindings(unit, op, element2) {
23409
23692
  throw Error("Animation listener should have a phase");
23410
23693
  }
23411
23694
  }
23412
- listenerOp = createListenerOp(op.xref, output.name, op.tag, output.phase, false);
23413
- let inputExprs;
23695
+ listenerOp = createListenerOp(op.xref, output.name, op.tag, output.phase, false, output.sourceSpan);
23696
+ let handlerExprs;
23414
23697
  let handler = output.handler;
23415
23698
  if (handler instanceof ASTWithSource) {
23416
23699
  handler = handler.ast;
23417
23700
  }
23418
23701
  if (handler instanceof Chain) {
23419
- inputExprs = handler.expressions;
23702
+ handlerExprs = handler.expressions;
23420
23703
  } else {
23421
- inputExprs = [handler];
23704
+ handlerExprs = [handler];
23422
23705
  }
23423
- if (inputExprs.length === 0) {
23706
+ if (handlerExprs.length === 0) {
23424
23707
  throw new Error("Expected listener to have non-empty expression list.");
23425
23708
  }
23426
- const expressions = inputExprs.map((expr) => convertAst(expr, unit.job));
23709
+ const expressions = handlerExprs.map((expr) => convertAst(expr, unit.job, output.handlerSpan));
23427
23710
  const returnExpr = expressions.pop();
23428
23711
  for (const expr of expressions) {
23429
- const stmtOp = createStatementOp(new ExpressionStatement(expr));
23712
+ const stmtOp = createStatementOp(new ExpressionStatement(expr, expr.sourceSpan));
23430
23713
  listenerOp.handlerOps.push(stmtOp);
23431
23714
  }
23432
- listenerOp.handlerOps.push(createStatementOp(new ReturnStatement(returnExpr)));
23715
+ listenerOp.handlerOps.push(createStatementOp(new ReturnStatement(returnExpr, returnExpr.sourceSpan)));
23433
23716
  unit.create.push(listenerOp);
23434
23717
  }
23435
23718
  }
@@ -23446,9 +23729,9 @@ function ingestBinding(view, xref, name, value, type, unit, securityContext, sou
23446
23729
  }
23447
23730
  let expression;
23448
23731
  if (value instanceof Interpolation$1) {
23449
- expression = new Interpolation(value.strings, value.expressions.map((expr) => convertAst(expr, view.job)));
23732
+ expression = new Interpolation(value.strings, value.expressions.map((expr) => convertAst(expr, view.job, null)));
23450
23733
  } else if (value instanceof AST) {
23451
- expression = convertAst(value, view.job);
23734
+ expression = convertAst(value, view.job, null);
23452
23735
  } else {
23453
23736
  expression = value;
23454
23737
  }
@@ -23469,6 +23752,15 @@ function assertIsArray(value) {
23469
23752
  throw new Error(`AssertionError: expected an array`);
23470
23753
  }
23471
23754
  }
23755
+ function convertSourceSpan(span, baseSourceSpan) {
23756
+ if (baseSourceSpan === null) {
23757
+ return null;
23758
+ }
23759
+ const start = baseSourceSpan.start.moveBy(span.start);
23760
+ const end = baseSourceSpan.start.moveBy(span.end);
23761
+ const fullStart = baseSourceSpan.fullStart.moveBy(span.start);
23762
+ return new ParseSourceSpan(start, end, fullStart);
23763
+ }
23472
23764
  var USE_TEMPLATE_PIPELINE = false;
23473
23765
  var IMPORTANT_FLAG = "!important";
23474
23766
  var MIN_STYLING_BINDING_SLOTS_REQUIRED = 2;
@@ -23849,11 +24141,8 @@ var WhitespaceVisitor = class {
23849
24141
  visitExpansionCase(expansionCase, context) {
23850
24142
  return expansionCase;
23851
24143
  }
23852
- visitBlockGroup(group, context) {
23853
- return new BlockGroup(visitAllWithSiblings(this, group.blocks), group.sourceSpan, group.startSourceSpan, group.endSourceSpan);
23854
- }
23855
24144
  visitBlock(block, context) {
23856
- return new Block(block.name, block.parameters, visitAllWithSiblings(this, block.children), block.sourceSpan, block.startSourceSpan);
24145
+ return new Block(block.name, block.parameters, visitAllWithSiblings(this, block.children), block.sourceSpan, block.startSourceSpan, block.endSourceSpan);
23857
24146
  }
23858
24147
  visitBlockParameter(parameter, context) {
23859
24148
  return parameter;
@@ -24272,24 +24561,34 @@ function normalizeNgContentSelect(selectAttr) {
24272
24561
  var FOR_LOOP_EXPRESSION_PATTERN = /^\s*([0-9A-Za-z_$]*)\s+of\s+(.*)/;
24273
24562
  var FOR_LOOP_TRACK_PATTERN = /^track\s+(.*)/;
24274
24563
  var CONDITIONAL_ALIAS_PATTERN = /^as\s+(.*)/;
24275
- var ELSE_IF_PATTERN = /^if\s/;
24564
+ var ELSE_IF_PATTERN = /^else[^\S\r\n]+if/;
24276
24565
  var FOR_LOOP_LET_PATTERN = /^let\s+(.*)/;
24277
24566
  var ALLOWED_FOR_LOOP_LET_VARIABLES = /* @__PURE__ */ new Set(["$index", "$first", "$last", "$even", "$odd", "$count"]);
24278
- function createIfBlock(ast, visitor, bindingParser) {
24279
- const errors = validateIfBlock(ast);
24567
+ function isConnectedForLoopBlock(name) {
24568
+ return name === "empty";
24569
+ }
24570
+ function isConnectedIfLoopBlock(name) {
24571
+ return name === "else" || ELSE_IF_PATTERN.test(name);
24572
+ }
24573
+ function createIfBlock(ast, connectedBlocks, visitor, bindingParser) {
24574
+ const errors = validateIfConnectedBlocks(connectedBlocks);
24280
24575
  const branches = [];
24281
24576
  if (errors.length > 0) {
24282
24577
  return { node: null, errors };
24283
24578
  }
24284
- for (const block of ast.blocks) {
24285
- const children = visitAll(visitor, block.children);
24286
- if (block.name === "else" && block.parameters.length === 0) {
24579
+ const mainBlockParams = parseConditionalBlockParameters(ast, errors, bindingParser);
24580
+ if (mainBlockParams !== null) {
24581
+ branches.push(new IfBlockBranch(mainBlockParams.expression, visitAll(visitor, ast.children, ast.children), mainBlockParams.expressionAlias, ast.sourceSpan, ast.startSourceSpan));
24582
+ }
24583
+ for (const block of connectedBlocks) {
24584
+ const children = visitAll(visitor, block.children, block.children);
24585
+ if (ELSE_IF_PATTERN.test(block.name)) {
24586
+ const params = parseConditionalBlockParameters(block, errors, bindingParser);
24587
+ if (params !== null) {
24588
+ branches.push(new IfBlockBranch(params.expression, children, params.expressionAlias, block.sourceSpan, block.startSourceSpan));
24589
+ }
24590
+ } else if (block.name === "else") {
24287
24591
  branches.push(new IfBlockBranch(null, children, null, block.sourceSpan, block.startSourceSpan));
24288
- continue;
24289
- }
24290
- const params = parseConditionalBlockParameters(block, errors, bindingParser);
24291
- if (params !== null) {
24292
- branches.push(new IfBlockBranch(params.expression, children, params.expressionAlias, block.sourceSpan, block.startSourceSpan));
24293
24592
  }
24294
24593
  }
24295
24594
  return {
@@ -24297,46 +24596,47 @@ function createIfBlock(ast, visitor, bindingParser) {
24297
24596
  errors
24298
24597
  };
24299
24598
  }
24300
- function createForLoop(ast, visitor, bindingParser) {
24301
- const [primaryBlock, ...secondaryBlocks] = ast.blocks;
24599
+ function createForLoop(ast, connectedBlocks, visitor, bindingParser) {
24302
24600
  const errors = [];
24303
- const params = parseForLoopParameters(primaryBlock, errors, bindingParser);
24601
+ const params = parseForLoopParameters(ast, errors, bindingParser);
24304
24602
  let node = null;
24305
24603
  let empty = null;
24306
- for (const block of secondaryBlocks) {
24604
+ for (const block of connectedBlocks) {
24307
24605
  if (block.name === "empty") {
24308
24606
  if (empty !== null) {
24309
- errors.push(new ParseError(block.sourceSpan, 'For loop can only have one "empty" block'));
24607
+ errors.push(new ParseError(block.sourceSpan, "@for loop can only have one @empty block"));
24310
24608
  } else if (block.parameters.length > 0) {
24311
- errors.push(new ParseError(block.sourceSpan, "Empty block cannot have parameters"));
24609
+ errors.push(new ParseError(block.sourceSpan, "@empty block cannot have parameters"));
24312
24610
  } else {
24313
- empty = new ForLoopBlockEmpty(visitAll(visitor, block.children), block.sourceSpan, block.startSourceSpan);
24611
+ empty = new ForLoopBlockEmpty(visitAll(visitor, block.children, block.children), block.sourceSpan, block.startSourceSpan);
24314
24612
  }
24315
24613
  } else {
24316
- errors.push(new ParseError(block.sourceSpan, `Unrecognized loop block "${block.name}"`));
24614
+ errors.push(new ParseError(block.sourceSpan, `Unrecognized @for loop block "${block.name}"`));
24317
24615
  }
24318
24616
  }
24319
24617
  if (params !== null) {
24320
24618
  if (params.trackBy === null) {
24321
- errors.push(new ParseError(ast.sourceSpan, 'For loop must have a "track" expression'));
24619
+ errors.push(new ParseError(ast.sourceSpan, '@for loop must have a "track" expression'));
24322
24620
  } else {
24323
- node = new ForLoopBlock(params.itemName, params.expression, params.trackBy, params.context, visitAll(visitor, primaryBlock.children), empty, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
24621
+ node = new ForLoopBlock(params.itemName, params.expression, params.trackBy, params.context, visitAll(visitor, ast.children, ast.children), empty, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
24324
24622
  }
24325
24623
  }
24326
24624
  return { node, errors };
24327
24625
  }
24328
24626
  function createSwitchBlock(ast, visitor, bindingParser) {
24329
- const [primaryBlock, ...secondaryBlocks] = ast.blocks;
24330
24627
  const errors = validateSwitchBlock(ast);
24331
24628
  if (errors.length > 0) {
24332
24629
  return { node: null, errors };
24333
24630
  }
24334
- const primaryExpression = parseBlockParameterToBinding(primaryBlock.parameters[0], bindingParser);
24631
+ const primaryExpression = parseBlockParameterToBinding(ast.parameters[0], bindingParser);
24335
24632
  const cases = [];
24336
24633
  let defaultCase = null;
24337
- for (const block of secondaryBlocks) {
24338
- const expression = block.name === "case" ? parseBlockParameterToBinding(block.parameters[0], bindingParser) : null;
24339
- const ast2 = new SwitchBlockCase(expression, visitAll(visitor, block.children), block.sourceSpan, block.startSourceSpan);
24634
+ for (const node of ast.children) {
24635
+ if (!(node instanceof Block)) {
24636
+ continue;
24637
+ }
24638
+ const expression = node.name === "case" ? parseBlockParameterToBinding(node.parameters[0], bindingParser) : null;
24639
+ const ast2 = new SwitchBlockCase(expression, visitAll(visitor, node.children, node.children), node.sourceSpan, node.startSourceSpan);
24340
24640
  if (expression === null) {
24341
24641
  defaultCase = ast2;
24342
24642
  } else {
@@ -24354,124 +24654,120 @@ function createSwitchBlock(ast, visitor, bindingParser) {
24354
24654
  function parseForLoopParameters(block, errors, bindingParser) {
24355
24655
  var _a2;
24356
24656
  if (block.parameters.length === 0) {
24357
- errors.push(new ParseError(block.sourceSpan, "For loop does not have an expression"));
24657
+ errors.push(new ParseError(block.sourceSpan, "@for loop does not have an expression"));
24358
24658
  return null;
24359
24659
  }
24360
24660
  const [expressionParam, ...secondaryParams] = block.parameters;
24361
24661
  const match = (_a2 = stripOptionalParentheses(expressionParam, errors)) == null ? void 0 : _a2.match(FOR_LOOP_EXPRESSION_PATTERN);
24362
24662
  if (!match || match[2].trim().length === 0) {
24363
- errors.push(new ParseError(expressionParam.sourceSpan, 'Cannot parse expression. For loop expression must match the pattern "<identifier> of <expression>"'));
24663
+ errors.push(new ParseError(expressionParam.sourceSpan, 'Cannot parse expression. @for loop expression must match the pattern "<identifier> of <expression>"'));
24364
24664
  return null;
24365
24665
  }
24366
24666
  const [, itemName, rawExpression] = match;
24367
24667
  const result = {
24368
- itemName,
24668
+ itemName: new Variable(itemName, "$implicit", expressionParam.sourceSpan, expressionParam.sourceSpan),
24369
24669
  trackBy: null,
24370
24670
  expression: parseBlockParameterToBinding(expressionParam, bindingParser, rawExpression),
24371
- context: null
24671
+ context: {}
24372
24672
  };
24373
24673
  for (const param of secondaryParams) {
24374
24674
  const letMatch = param.expression.match(FOR_LOOP_LET_PATTERN);
24375
24675
  if (letMatch !== null) {
24376
- result.context = result.context || {};
24377
- parseLetParameter(param.sourceSpan, letMatch[1], result.context, errors);
24676
+ parseLetParameter(param.sourceSpan, letMatch[1], param.sourceSpan, result.context, errors);
24378
24677
  continue;
24379
24678
  }
24380
24679
  const trackMatch = param.expression.match(FOR_LOOP_TRACK_PATTERN);
24381
24680
  if (trackMatch !== null) {
24382
24681
  if (result.trackBy !== null) {
24383
- errors.push(new ParseError(param.sourceSpan, 'For loop can only have one "track" expression'));
24682
+ errors.push(new ParseError(param.sourceSpan, '@for loop can only have one "track" expression'));
24384
24683
  } else {
24385
24684
  result.trackBy = parseBlockParameterToBinding(param, bindingParser, trackMatch[1]);
24386
24685
  }
24387
24686
  continue;
24388
24687
  }
24389
- errors.push(new ParseError(param.sourceSpan, `Unrecognized loop paramater "${param.expression}"`));
24688
+ errors.push(new ParseError(param.sourceSpan, `Unrecognized @for loop paramater "${param.expression}"`));
24689
+ }
24690
+ for (const variableName of ALLOWED_FOR_LOOP_LET_VARIABLES) {
24691
+ if (!result.context.hasOwnProperty(variableName)) {
24692
+ result.context[variableName] = new Variable(variableName, variableName, block.startSourceSpan, block.startSourceSpan);
24693
+ }
24390
24694
  }
24391
24695
  return result;
24392
24696
  }
24393
- function parseLetParameter(sourceSpan, expression, context, errors) {
24697
+ function parseLetParameter(sourceSpan, expression, span, context, errors) {
24394
24698
  const parts = expression.split(",");
24395
24699
  for (const part of parts) {
24396
24700
  const expressionParts = part.split("=");
24397
24701
  const name = expressionParts.length === 2 ? expressionParts[0].trim() : "";
24398
24702
  const variableName = expressionParts.length === 2 ? expressionParts[1].trim() : "";
24399
24703
  if (name.length === 0 || variableName.length === 0) {
24400
- errors.push(new ParseError(sourceSpan, `Invalid for loop "let" parameter. Parameter should match the pattern "<name> = <variable name>"`));
24704
+ errors.push(new ParseError(sourceSpan, `Invalid @for loop "let" parameter. Parameter should match the pattern "<name> = <variable name>"`));
24401
24705
  } else if (!ALLOWED_FOR_LOOP_LET_VARIABLES.has(variableName)) {
24402
24706
  errors.push(new ParseError(sourceSpan, `Unknown "let" parameter variable "${variableName}". The allowed variables are: ${Array.from(ALLOWED_FOR_LOOP_LET_VARIABLES).join(", ")}`));
24403
24707
  } else if (context.hasOwnProperty(variableName)) {
24404
24708
  errors.push(new ParseError(sourceSpan, `Duplicate "let" parameter variable "${variableName}"`));
24405
24709
  } else {
24406
- context[variableName] = name;
24710
+ context[variableName] = new Variable(name, variableName, span, span);
24407
24711
  }
24408
24712
  }
24409
24713
  }
24410
- function validateIfBlock(ast) {
24714
+ function validateIfConnectedBlocks(connectedBlocks) {
24411
24715
  const errors = [];
24412
24716
  let hasElse = false;
24413
- for (let i = 0; i < ast.blocks.length; i++) {
24414
- const block = ast.blocks[i];
24415
- if ((block.name !== "if" || i > 0) && block.name !== "else") {
24416
- errors.push(new ParseError(block.sourceSpan, `Unrecognized conditional block "${block.name}"`));
24417
- continue;
24418
- }
24419
- if (block.name === "if") {
24420
- continue;
24421
- }
24422
- if (block.parameters.length === 0) {
24717
+ for (let i = 0; i < connectedBlocks.length; i++) {
24718
+ const block = connectedBlocks[i];
24719
+ if (block.name === "else") {
24423
24720
  if (hasElse) {
24424
- errors.push(new ParseError(block.sourceSpan, 'Conditional can only have one "else" block'));
24425
- } else if (ast.blocks.length > 1 && i < ast.blocks.length - 1) {
24426
- errors.push(new ParseError(block.sourceSpan, "Else block must be last inside the conditional"));
24721
+ errors.push(new ParseError(block.sourceSpan, "Conditional can only have one @else block"));
24722
+ } else if (connectedBlocks.length > 1 && i < connectedBlocks.length - 1) {
24723
+ errors.push(new ParseError(block.sourceSpan, "@else block must be last inside the conditional"));
24724
+ } else if (block.parameters.length > 0) {
24725
+ errors.push(new ParseError(block.sourceSpan, "@else block cannot have parameters"));
24427
24726
  }
24428
24727
  hasElse = true;
24429
- } else if (block.parameters.length > 0 && !ELSE_IF_PATTERN.test(block.parameters[0].expression)) {
24430
- errors.push(new ParseError(block.sourceSpan, "Else block cannot have parameters"));
24728
+ } else if (!ELSE_IF_PATTERN.test(block.name)) {
24729
+ errors.push(new ParseError(block.sourceSpan, `Unrecognized conditional block @${block.name}`));
24431
24730
  }
24432
24731
  }
24433
24732
  return errors;
24434
24733
  }
24435
24734
  function validateSwitchBlock(ast) {
24436
- const [primaryBlock, ...secondaryBlocks] = ast.blocks;
24437
24735
  const errors = [];
24438
24736
  let hasDefault = false;
24439
- const hasPrimary = primaryBlock.children.length > 0 && primaryBlock.children.some((child) => {
24440
- return !(child instanceof Text) || child.value.trim().length > 0;
24441
- });
24442
- if (hasPrimary) {
24443
- errors.push(new ParseError(primaryBlock.sourceSpan, 'Switch block can only contain "case" and "default" blocks'));
24737
+ if (ast.parameters.length !== 1) {
24738
+ errors.push(new ParseError(ast.sourceSpan, "@switch block must have exactly one parameter"));
24739
+ return errors;
24444
24740
  }
24445
- if (primaryBlock.parameters.length !== 1) {
24446
- errors.push(new ParseError(primaryBlock.sourceSpan, "Switch block must have exactly one parameter"));
24447
- }
24448
- for (const block of secondaryBlocks) {
24449
- if (block.name === "case") {
24450
- if (block.parameters.length !== 1) {
24451
- errors.push(new ParseError(block.sourceSpan, "Case block must have exactly one parameter"));
24452
- }
24453
- } else if (block.name === "default") {
24741
+ for (const node of ast.children) {
24742
+ if (node instanceof Text && node.value.trim().length === 0) {
24743
+ continue;
24744
+ }
24745
+ if (!(node instanceof Block) || node.name !== "case" && node.name !== "default") {
24746
+ errors.push(new ParseError(node.sourceSpan, "@switch block can only contain @case and @default blocks"));
24747
+ continue;
24748
+ }
24749
+ if (node.name === "default") {
24454
24750
  if (hasDefault) {
24455
- errors.push(new ParseError(block.sourceSpan, 'Switch block can only have one "default" block'));
24456
- } else if (block.parameters.length > 0) {
24457
- errors.push(new ParseError(block.sourceSpan, "Default block cannot have parameters"));
24751
+ errors.push(new ParseError(node.sourceSpan, "@switch block can only have one @default block"));
24752
+ } else if (node.parameters.length > 0) {
24753
+ errors.push(new ParseError(node.sourceSpan, "@default block cannot have parameters"));
24458
24754
  }
24459
24755
  hasDefault = true;
24460
- } else {
24461
- errors.push(new ParseError(block.sourceSpan, 'Switch block can only contain "case" and "default" blocks'));
24756
+ } else if (node.name === "case" && node.parameters.length !== 1) {
24757
+ errors.push(new ParseError(node.sourceSpan, "@case block must have exactly one parameter"));
24462
24758
  }
24463
24759
  }
24464
24760
  return errors;
24465
24761
  }
24466
- function parseBlockParameterToBinding(ast, bindingParser, part = 0) {
24762
+ function parseBlockParameterToBinding(ast, bindingParser, part) {
24467
24763
  let start;
24468
24764
  let end;
24469
- if (typeof part === "number") {
24470
- start = part;
24471
- end = ast.expression.length;
24472
- } else {
24765
+ if (typeof part === "string") {
24473
24766
  start = Math.max(0, ast.expression.lastIndexOf(part));
24474
24767
  end = start + part.length;
24768
+ } else {
24769
+ start = 0;
24770
+ end = ast.expression.length;
24475
24771
  }
24476
24772
  return bindingParser.parseBinding(ast.expression.slice(start, end), false, ast.sourceSpan, ast.sourceSpan.start.offset + start);
24477
24773
  }
@@ -24480,20 +24776,20 @@ function parseConditionalBlockParameters(block, errors, bindingParser) {
24480
24776
  errors.push(new ParseError(block.sourceSpan, "Conditional block does not have an expression"));
24481
24777
  return null;
24482
24778
  }
24483
- const isPrimaryIfBlock = block.name === "if";
24484
- const expression = parseBlockParameterToBinding(block.parameters[0], bindingParser, isPrimaryIfBlock ? 0 : 2);
24779
+ const expression = parseBlockParameterToBinding(block.parameters[0], bindingParser);
24485
24780
  let expressionAlias = null;
24486
24781
  for (let i = 1; i < block.parameters.length; i++) {
24487
24782
  const param = block.parameters[i];
24488
24783
  const aliasMatch = param.expression.match(CONDITIONAL_ALIAS_PATTERN);
24489
24784
  if (aliasMatch === null) {
24490
24785
  errors.push(new ParseError(param.sourceSpan, `Unrecognized conditional paramater "${param.expression}"`));
24491
- } else if (!isPrimaryIfBlock) {
24492
- errors.push(new ParseError(param.sourceSpan, '"as" expression is only allowed on the primary "if" block'));
24786
+ } else if (block.name !== "if") {
24787
+ errors.push(new ParseError(param.sourceSpan, '"as" expression is only allowed on the primary @if block'));
24493
24788
  } else if (expressionAlias !== null) {
24494
24789
  errors.push(new ParseError(param.sourceSpan, 'Conditional can only have one "as" expression'));
24495
24790
  } else {
24496
- expressionAlias = aliasMatch[1].trim();
24791
+ const name = aliasMatch[1].trim();
24792
+ expressionAlias = new Variable(name, name, param.sourceSpan, param.sourceSpan);
24497
24793
  }
24498
24794
  }
24499
24795
  return { expression, expressionAlias };
@@ -24564,23 +24860,24 @@ function parseWhenTrigger({ expression, sourceSpan }, bindingParser, triggers, e
24564
24860
  trackTrigger("when", triggers, errors, new BoundDeferredTrigger(parsed, sourceSpan));
24565
24861
  }
24566
24862
  }
24567
- function parseOnTrigger({ expression, sourceSpan }, triggers, errors) {
24863
+ function parseOnTrigger({ expression, sourceSpan }, triggers, errors, placeholder) {
24568
24864
  const onIndex = expression.indexOf("on");
24569
24865
  if (onIndex === -1) {
24570
24866
  errors.push(new ParseError(sourceSpan, `Could not find "on" keyword in expression`));
24571
24867
  } else {
24572
24868
  const start = getTriggerParametersStart(expression, onIndex + 1);
24573
- const parser = new OnTriggerParser(expression, start, sourceSpan, triggers, errors);
24869
+ const parser = new OnTriggerParser(expression, start, sourceSpan, triggers, errors, placeholder);
24574
24870
  parser.parse();
24575
24871
  }
24576
24872
  }
24577
24873
  var OnTriggerParser = class {
24578
- constructor(expression, start, span, triggers, errors) {
24874
+ constructor(expression, start, span, triggers, errors, placeholder) {
24579
24875
  this.expression = expression;
24580
24876
  this.start = start;
24581
24877
  this.span = span;
24582
24878
  this.triggers = triggers;
24583
24879
  this.errors = errors;
24880
+ this.placeholder = placeholder;
24584
24881
  this.index = 0;
24585
24882
  this.tokens = new Lexer().tokenize(expression.slice(start));
24586
24883
  }
@@ -24634,16 +24931,16 @@ var OnTriggerParser = class {
24634
24931
  this.trackTrigger("timer", createTimerTrigger(parameters, sourceSpan));
24635
24932
  break;
24636
24933
  case OnTriggerType.INTERACTION:
24637
- this.trackTrigger("interaction", createInteractionTrigger(parameters, sourceSpan));
24934
+ this.trackTrigger("interaction", createInteractionTrigger(parameters, sourceSpan, this.placeholder));
24638
24935
  break;
24639
24936
  case OnTriggerType.IMMEDIATE:
24640
24937
  this.trackTrigger("immediate", createImmediateTrigger(parameters, sourceSpan));
24641
24938
  break;
24642
24939
  case OnTriggerType.HOVER:
24643
- this.trackTrigger("hover", createHoverTrigger(parameters, sourceSpan));
24940
+ this.trackTrigger("hover", createHoverTrigger(parameters, sourceSpan, this.placeholder));
24644
24941
  break;
24645
24942
  case OnTriggerType.VIEWPORT:
24646
- this.trackTrigger("viewport", createViewportTrigger(parameters, sourceSpan));
24943
+ this.trackTrigger("viewport", createViewportTrigger(parameters, sourceSpan, this.placeholder));
24647
24944
  break;
24648
24945
  default:
24649
24946
  throw new Error(`Unrecognized trigger type "${identifier}"`);
@@ -24730,31 +25027,39 @@ function createTimerTrigger(parameters, sourceSpan) {
24730
25027
  }
24731
25028
  return new TimerDeferredTrigger(delay, sourceSpan);
24732
25029
  }
24733
- function createInteractionTrigger(parameters, sourceSpan) {
24734
- var _a2;
24735
- if (parameters.length > 1) {
24736
- throw new Error(`"${OnTriggerType.INTERACTION}" trigger can only have zero or one parameters`);
24737
- }
24738
- return new InteractionDeferredTrigger((_a2 = parameters[0]) != null ? _a2 : null, sourceSpan);
24739
- }
24740
25030
  function createImmediateTrigger(parameters, sourceSpan) {
24741
25031
  if (parameters.length > 0) {
24742
25032
  throw new Error(`"${OnTriggerType.IMMEDIATE}" trigger cannot have parameters`);
24743
25033
  }
24744
25034
  return new ImmediateDeferredTrigger(sourceSpan);
24745
25035
  }
24746
- function createHoverTrigger(parameters, sourceSpan) {
24747
- if (parameters.length > 0) {
24748
- throw new Error(`"${OnTriggerType.HOVER}" trigger cannot have parameters`);
24749
- }
24750
- return new HoverDeferredTrigger(sourceSpan);
25036
+ function createHoverTrigger(parameters, sourceSpan, placeholder) {
25037
+ var _a2;
25038
+ validateReferenceBasedTrigger(OnTriggerType.HOVER, parameters, placeholder);
25039
+ return new HoverDeferredTrigger((_a2 = parameters[0]) != null ? _a2 : null, sourceSpan);
25040
+ }
25041
+ function createInteractionTrigger(parameters, sourceSpan, placeholder) {
25042
+ var _a2;
25043
+ validateReferenceBasedTrigger(OnTriggerType.INTERACTION, parameters, placeholder);
25044
+ return new InteractionDeferredTrigger((_a2 = parameters[0]) != null ? _a2 : null, sourceSpan);
24751
25045
  }
24752
- function createViewportTrigger(parameters, sourceSpan) {
25046
+ function createViewportTrigger(parameters, sourceSpan, placeholder) {
24753
25047
  var _a2;
25048
+ validateReferenceBasedTrigger(OnTriggerType.VIEWPORT, parameters, placeholder);
25049
+ return new ViewportDeferredTrigger((_a2 = parameters[0]) != null ? _a2 : null, sourceSpan);
25050
+ }
25051
+ function validateReferenceBasedTrigger(type, parameters, placeholder) {
24754
25052
  if (parameters.length > 1) {
24755
- throw new Error(`"${OnTriggerType.VIEWPORT}" trigger can only have zero or one parameters`);
25053
+ throw new Error(`"${type}" trigger can only have zero or one parameters`);
25054
+ }
25055
+ if (parameters.length === 0) {
25056
+ if (placeholder === null) {
25057
+ throw new Error(`"${type}" trigger with no parameters can only be placed on an @defer that has a @placeholder block`);
25058
+ }
25059
+ if (placeholder.children.length !== 1 || !(placeholder.children[0] instanceof Element$1)) {
25060
+ throw new Error(`"${type}" trigger with no parameters can only be placed on an @defer that has a @placeholder block with exactly one root element node`);
25061
+ }
24756
25062
  }
24757
- return new ViewportDeferredTrigger((_a2 = parameters[0]) != null ? _a2 : null, sourceSpan);
24758
25063
  }
24759
25064
  function getTriggerParametersStart(value, startPosition = 0) {
24760
25065
  let hasFoundSeparator = false;
@@ -24781,53 +25086,48 @@ var MINIMUM_PARAMETER_PATTERN = /^minimum\s/;
24781
25086
  var AFTER_PARAMETER_PATTERN = /^after\s/;
24782
25087
  var WHEN_PARAMETER_PATTERN = /^when\s/;
24783
25088
  var ON_PARAMETER_PATTERN = /^on\s/;
24784
- var SecondaryDeferredBlockType;
24785
- (function(SecondaryDeferredBlockType2) {
24786
- SecondaryDeferredBlockType2["PLACEHOLDER"] = "placeholder";
24787
- SecondaryDeferredBlockType2["LOADING"] = "loading";
24788
- SecondaryDeferredBlockType2["ERROR"] = "error";
24789
- })(SecondaryDeferredBlockType || (SecondaryDeferredBlockType = {}));
24790
- function createDeferredBlock(ast, visitor, bindingParser) {
25089
+ function isConnectedDeferLoopBlock(name) {
25090
+ return name === "placeholder" || name === "loading" || name === "error";
25091
+ }
25092
+ function createDeferredBlock(ast, connectedBlocks, visitor, bindingParser) {
24791
25093
  const errors = [];
24792
- const [primaryBlock, ...secondaryBlocks] = ast.blocks;
24793
- const { triggers, prefetchTriggers } = parsePrimaryTriggers(primaryBlock.parameters, bindingParser, errors);
24794
- const { placeholder, loading, error: error2 } = parseSecondaryBlocks(secondaryBlocks, errors, visitor);
24795
- return {
24796
- node: new DeferredBlock(visitAll(visitor, primaryBlock.children), triggers, prefetchTriggers, placeholder, loading, error2, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan),
24797
- errors
24798
- };
25094
+ const { placeholder, loading, error: error2 } = parseConnectedBlocks(connectedBlocks, errors, visitor);
25095
+ const { triggers, prefetchTriggers } = parsePrimaryTriggers(ast.parameters, bindingParser, errors, placeholder);
25096
+ const node = new DeferredBlock(visitAll(visitor, ast.children, ast.children), triggers, prefetchTriggers, placeholder, loading, error2, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
25097
+ return { node, errors };
24799
25098
  }
24800
- function parseSecondaryBlocks(blocks, errors, visitor) {
25099
+ function parseConnectedBlocks(connectedBlocks, errors, visitor) {
24801
25100
  let placeholder = null;
24802
25101
  let loading = null;
24803
25102
  let error2 = null;
24804
- for (const block of blocks) {
25103
+ for (const block of connectedBlocks) {
24805
25104
  try {
25105
+ if (!isConnectedDeferLoopBlock(block.name)) {
25106
+ errors.push(new ParseError(block.startSourceSpan, `Unrecognized block "@${block.name}"`));
25107
+ break;
25108
+ }
24806
25109
  switch (block.name) {
24807
- case SecondaryDeferredBlockType.PLACEHOLDER:
25110
+ case "placeholder":
24808
25111
  if (placeholder !== null) {
24809
- errors.push(new ParseError(block.startSourceSpan, `"defer" block can only have one "${SecondaryDeferredBlockType.PLACEHOLDER}" block`));
25112
+ errors.push(new ParseError(block.startSourceSpan, `@defer block can only have one @placeholder block`));
24810
25113
  } else {
24811
25114
  placeholder = parsePlaceholderBlock(block, visitor);
24812
25115
  }
24813
25116
  break;
24814
- case SecondaryDeferredBlockType.LOADING:
25117
+ case "loading":
24815
25118
  if (loading !== null) {
24816
- errors.push(new ParseError(block.startSourceSpan, `"defer" block can only have one "${SecondaryDeferredBlockType.LOADING}" block`));
25119
+ errors.push(new ParseError(block.startSourceSpan, `@defer block can only have one @loading block`));
24817
25120
  } else {
24818
25121
  loading = parseLoadingBlock(block, visitor);
24819
25122
  }
24820
25123
  break;
24821
- case SecondaryDeferredBlockType.ERROR:
25124
+ case "error":
24822
25125
  if (error2 !== null) {
24823
- errors.push(new ParseError(block.startSourceSpan, `"defer" block can only have one "${SecondaryDeferredBlockType.ERROR}" block`));
25126
+ errors.push(new ParseError(block.startSourceSpan, `@defer block can only have one @error block`));
24824
25127
  } else {
24825
25128
  error2 = parseErrorBlock(block, visitor);
24826
25129
  }
24827
25130
  break;
24828
- default:
24829
- errors.push(new ParseError(block.startSourceSpan, `Unrecognized block "${block.name}"`));
24830
- break;
24831
25131
  }
24832
25132
  } catch (e) {
24833
25133
  errors.push(new ParseError(block.startSourceSpan, e.message));
@@ -24840,7 +25140,7 @@ function parsePlaceholderBlock(ast, visitor) {
24840
25140
  for (const param of ast.parameters) {
24841
25141
  if (MINIMUM_PARAMETER_PATTERN.test(param.expression)) {
24842
25142
  if (minimumTime != null) {
24843
- throw new Error(`Placeholder block can only have one "minimum" parameter`);
25143
+ throw new Error(`@placeholder block can only have one "minimum" parameter`);
24844
25144
  }
24845
25145
  const parsedTime = parseDeferredTime(param.expression.slice(getTriggerParametersStart(param.expression)));
24846
25146
  if (parsedTime === null) {
@@ -24848,10 +25148,10 @@ function parsePlaceholderBlock(ast, visitor) {
24848
25148
  }
24849
25149
  minimumTime = parsedTime;
24850
25150
  } else {
24851
- throw new Error(`Unrecognized parameter in "${SecondaryDeferredBlockType.PLACEHOLDER}" block: "${param.expression}"`);
25151
+ throw new Error(`Unrecognized parameter in @placeholder block: "${param.expression}"`);
24852
25152
  }
24853
25153
  }
24854
- return new DeferredBlockPlaceholder(visitAll(visitor, ast.children), minimumTime, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
25154
+ return new DeferredBlockPlaceholder(visitAll(visitor, ast.children, ast.children), minimumTime, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
24855
25155
  }
24856
25156
  function parseLoadingBlock(ast, visitor) {
24857
25157
  let afterTime = null;
@@ -24859,7 +25159,7 @@ function parseLoadingBlock(ast, visitor) {
24859
25159
  for (const param of ast.parameters) {
24860
25160
  if (AFTER_PARAMETER_PATTERN.test(param.expression)) {
24861
25161
  if (afterTime != null) {
24862
- throw new Error(`Loading block can only have one "after" parameter`);
25162
+ throw new Error(`@loading block can only have one "after" parameter`);
24863
25163
  }
24864
25164
  const parsedTime = parseDeferredTime(param.expression.slice(getTriggerParametersStart(param.expression)));
24865
25165
  if (parsedTime === null) {
@@ -24868,7 +25168,7 @@ function parseLoadingBlock(ast, visitor) {
24868
25168
  afterTime = parsedTime;
24869
25169
  } else if (MINIMUM_PARAMETER_PATTERN.test(param.expression)) {
24870
25170
  if (minimumTime != null) {
24871
- throw new Error(`Loading block can only have one "minimum" parameter`);
25171
+ throw new Error(`@loading block can only have one "minimum" parameter`);
24872
25172
  }
24873
25173
  const parsedTime = parseDeferredTime(param.expression.slice(getTriggerParametersStart(param.expression)));
24874
25174
  if (parsedTime === null) {
@@ -24876,29 +25176,29 @@ function parseLoadingBlock(ast, visitor) {
24876
25176
  }
24877
25177
  minimumTime = parsedTime;
24878
25178
  } else {
24879
- throw new Error(`Unrecognized parameter in "${SecondaryDeferredBlockType.LOADING}" block: "${param.expression}"`);
25179
+ throw new Error(`Unrecognized parameter in @loading block: "${param.expression}"`);
24880
25180
  }
24881
25181
  }
24882
- return new DeferredBlockLoading(visitAll(visitor, ast.children), afterTime, minimumTime, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
25182
+ return new DeferredBlockLoading(visitAll(visitor, ast.children, ast.children), afterTime, minimumTime, ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
24883
25183
  }
24884
25184
  function parseErrorBlock(ast, visitor) {
24885
25185
  if (ast.parameters.length > 0) {
24886
- throw new Error(`"${SecondaryDeferredBlockType.ERROR}" block cannot have parameters`);
25186
+ throw new Error(`@error block cannot have parameters`);
24887
25187
  }
24888
- return new DeferredBlockError(visitAll(visitor, ast.children), ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
25188
+ return new DeferredBlockError(visitAll(visitor, ast.children, ast.children), ast.sourceSpan, ast.startSourceSpan, ast.endSourceSpan);
24889
25189
  }
24890
- function parsePrimaryTriggers(params, bindingParser, errors) {
25190
+ function parsePrimaryTriggers(params, bindingParser, errors, placeholder) {
24891
25191
  const triggers = {};
24892
25192
  const prefetchTriggers = {};
24893
25193
  for (const param of params) {
24894
25194
  if (WHEN_PARAMETER_PATTERN.test(param.expression)) {
24895
25195
  parseWhenTrigger(param, bindingParser, triggers, errors);
24896
25196
  } else if (ON_PARAMETER_PATTERN.test(param.expression)) {
24897
- parseOnTrigger(param, triggers, errors);
25197
+ parseOnTrigger(param, triggers, errors, placeholder);
24898
25198
  } else if (PREFETCH_WHEN_PATTERN.test(param.expression)) {
24899
25199
  parseWhenTrigger(param, bindingParser, prefetchTriggers, errors);
24900
25200
  } else if (PREFETCH_ON_PATTERN.test(param.expression)) {
24901
- parseOnTrigger(param, prefetchTriggers, errors);
25201
+ parseOnTrigger(param, prefetchTriggers, errors, placeholder);
24902
25202
  } else {
24903
25203
  errors.push(new ParseError(param.sourceSpan, "Unrecognized trigger"));
24904
25204
  }
@@ -24921,7 +25221,7 @@ var BINDING_DELIMS = {
24921
25221
  var TEMPLATE_ATTR_PREFIX = "*";
24922
25222
  function htmlAstToRender3Ast(htmlNodes, bindingParser, options) {
24923
25223
  const transformer = new HtmlAstToIvyAst(bindingParser, options);
24924
- const ivyNodes = visitAll(transformer, htmlNodes);
25224
+ const ivyNodes = visitAll(transformer, htmlNodes, htmlNodes);
24925
25225
  const allErrors = bindingParser.errors.concat(transformer.errors);
24926
25226
  const result = {
24927
25227
  nodes: ivyNodes,
@@ -24945,6 +25245,7 @@ var HtmlAstToIvyAst = class {
24945
25245
  this.ngContentSelectors = [];
24946
25246
  this.commentNodes = [];
24947
25247
  this.inI18nBlock = false;
25248
+ this.processedNodes = /* @__PURE__ */ new Set();
24948
25249
  }
24949
25250
  visitElement(element2) {
24950
25251
  const isI18nRootElement = isI18nRootNode(element2.i18n);
@@ -25007,7 +25308,7 @@ var HtmlAstToIvyAst = class {
25007
25308
  if (preparsedElement.nonBindable) {
25008
25309
  children = visitAll(NON_BINDABLE_VISITOR, element2.children).flat(Infinity);
25009
25310
  } else {
25010
- children = visitAll(this, element2.children);
25311
+ children = visitAll(this, element2.children, element2.children);
25011
25312
  }
25012
25313
  let parsedElement;
25013
25314
  if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
@@ -25048,7 +25349,7 @@ var HtmlAstToIvyAst = class {
25048
25349
  return new TextAttribute(attribute2.name, attribute2.value, attribute2.sourceSpan, attribute2.keySpan, attribute2.valueSpan, attribute2.i18n);
25049
25350
  }
25050
25351
  visitText(text2) {
25051
- return this._visitTextWithInterpolation(text2.value, text2.sourceSpan, text2.tokens, text2.i18n);
25352
+ return this.processedNodes.has(text2) ? null : this._visitTextWithInterpolation(text2.value, text2.sourceSpan, text2.tokens, text2.i18n);
25052
25353
  }
25053
25354
  visitExpansion(expansion) {
25054
25355
  if (!expansion.i18n) {
@@ -25081,43 +25382,73 @@ var HtmlAstToIvyAst = class {
25081
25382
  }
25082
25383
  return null;
25083
25384
  }
25084
- visitBlockGroup(group, context) {
25085
- const primaryBlock = group.blocks[0];
25086
- if (!primaryBlock) {
25087
- this.reportError("Block group must have at least one block.", group.sourceSpan);
25385
+ visitBlockParameter() {
25386
+ return null;
25387
+ }
25388
+ visitBlock(block, context) {
25389
+ const index2 = Array.isArray(context) ? context.indexOf(block) : -1;
25390
+ if (index2 === -1) {
25391
+ throw new Error("Visitor invoked incorrectly. Expecting visitBlock to be invoked siblings array as its context");
25392
+ }
25393
+ if (this.processedNodes.has(block)) {
25088
25394
  return null;
25089
25395
  }
25090
- if (!this.options.enabledBlockTypes.has(primaryBlock.name)) {
25091
- this.reportError(`Unrecognized block "${primaryBlock.name}".`, primaryBlock.sourceSpan);
25396
+ if (!this.options.enabledBlockTypes.has(block.name)) {
25397
+ let errorMessage;
25398
+ if (isConnectedDeferLoopBlock(block.name)) {
25399
+ errorMessage = `@${block.name} block can only be used after an @defer block.`;
25400
+ this.processedNodes.add(block);
25401
+ } else if (isConnectedForLoopBlock(block.name)) {
25402
+ errorMessage = `@${block.name} block can only be used after an @for block.`;
25403
+ this.processedNodes.add(block);
25404
+ } else if (isConnectedIfLoopBlock(block.name)) {
25405
+ errorMessage = `@${block.name} block can only be used after an @if or @else if block.`;
25406
+ this.processedNodes.add(block);
25407
+ } else {
25408
+ errorMessage = `Unrecognized block @${block.name}.`;
25409
+ }
25410
+ this.reportError(errorMessage, block.sourceSpan);
25092
25411
  return null;
25093
25412
  }
25094
25413
  let result = null;
25095
- switch (primaryBlock.name) {
25414
+ switch (block.name) {
25096
25415
  case "defer":
25097
- result = createDeferredBlock(group, this, this.bindingParser);
25416
+ result = createDeferredBlock(block, this.findConnectedBlocks(index2, context, isConnectedDeferLoopBlock), this, this.bindingParser);
25098
25417
  break;
25099
25418
  case "switch":
25100
- result = createSwitchBlock(group, this, this.bindingParser);
25419
+ result = createSwitchBlock(block, this, this.bindingParser);
25101
25420
  break;
25102
25421
  case "for":
25103
- result = createForLoop(group, this, this.bindingParser);
25422
+ result = createForLoop(block, this.findConnectedBlocks(index2, context, isConnectedForLoopBlock), this, this.bindingParser);
25104
25423
  break;
25105
25424
  case "if":
25106
- result = createIfBlock(group, this, this.bindingParser);
25425
+ result = createIfBlock(block, this.findConnectedBlocks(index2, context, isConnectedIfLoopBlock), this, this.bindingParser);
25107
25426
  break;
25108
25427
  default:
25109
25428
  result = {
25110
25429
  node: null,
25111
- errors: [new ParseError(primaryBlock.sourceSpan, `Unrecognized block "${primaryBlock.name}".`)]
25430
+ errors: [new ParseError(block.sourceSpan, `Unrecognized block @${block.name}.`)]
25112
25431
  };
25113
25432
  break;
25114
25433
  }
25115
25434
  this.errors.push(...result.errors);
25116
25435
  return result.node;
25117
25436
  }
25118
- visitBlock(block, context) {
25119
- }
25120
- visitBlockParameter(parameter, context) {
25437
+ findConnectedBlocks(primaryBlockIndex, siblings, predicate) {
25438
+ const relatedBlocks = [];
25439
+ for (let i = primaryBlockIndex + 1; i < siblings.length; i++) {
25440
+ const node = siblings[i];
25441
+ if (node instanceof Text && node.value.trim().length === 0) {
25442
+ this.processedNodes.add(node);
25443
+ continue;
25444
+ }
25445
+ if (!(node instanceof Block) || !predicate(node.name)) {
25446
+ break;
25447
+ }
25448
+ relatedBlocks.push(node);
25449
+ this.processedNodes.add(node);
25450
+ }
25451
+ return relatedBlocks;
25121
25452
  }
25122
25453
  extractAttributes(elementName, properties, i18nPropsMeta) {
25123
25454
  const bound = [];
@@ -25273,18 +25604,15 @@ var NonBindableVisitor = class {
25273
25604
  visitExpansionCase(expansionCase) {
25274
25605
  return null;
25275
25606
  }
25276
- visitBlockGroup(group, context) {
25277
- const nodes = visitAll(this, group.blocks);
25278
- if (group.endSourceSpan !== null) {
25279
- nodes.push(new Text$3(group.endSourceSpan.toString(), group.endSourceSpan));
25280
- }
25281
- return nodes;
25282
- }
25283
25607
  visitBlock(block, context) {
25284
- return [
25608
+ const nodes = [
25285
25609
  new Text$3(block.startSourceSpan.toString(), block.startSourceSpan),
25286
25610
  ...visitAll(this, block.children)
25287
25611
  ];
25612
+ if (block.endSourceSpan !== null) {
25613
+ nodes.push(new Text$3(block.endSourceSpan.toString(), block.endSourceSpan));
25614
+ }
25615
+ return nodes;
25288
25616
  }
25289
25617
  visitBlockParameter(parameter, context) {
25290
25618
  return null;
@@ -25515,7 +25843,7 @@ var TemplateData = class {
25515
25843
  }
25516
25844
  };
25517
25845
  var TemplateDefinitionBuilder = class {
25518
- constructor(constantPool, parentBindingScope, level = 0, contextName, i18nContext, templateIndex, templateName, _namespace, relativeContextFilePath, i18nUseExternalIds, deferBlocks, _constants = createComponentDefConsts()) {
25846
+ constructor(constantPool, parentBindingScope, level = 0, contextName, i18nContext, templateIndex, templateName, _namespace, relativeContextFilePath, i18nUseExternalIds, deferBlocks, elementLocations, _constants = createComponentDefConsts()) {
25519
25847
  this.constantPool = constantPool;
25520
25848
  this.level = level;
25521
25849
  this.contextName = contextName;
@@ -25525,6 +25853,7 @@ var TemplateDefinitionBuilder = class {
25525
25853
  this._namespace = _namespace;
25526
25854
  this.i18nUseExternalIds = i18nUseExternalIds;
25527
25855
  this.deferBlocks = deferBlocks;
25856
+ this.elementLocations = elementLocations;
25528
25857
  this._constants = _constants;
25529
25858
  this._dataIndex = 0;
25530
25859
  this._bindingContext = 0;
@@ -25816,6 +26145,7 @@ var TemplateDefinitionBuilder = class {
25816
26145
  var _a2, _b2;
25817
26146
  const elementIndex = this.allocateDataSlot();
25818
26147
  const stylingBuilder = new StylingBuilder(null);
26148
+ this.elementLocations.set(element2, { index: elementIndex, level: this.level });
25819
26149
  let isNonBindableMode = false;
25820
26150
  const isI18nRootElement = isI18nRootNode(element2.i18n) && !isSingleI18nIcu(element2.i18n);
25821
26151
  const outputAttrs = [];
@@ -25988,7 +26318,7 @@ var TemplateDefinitionBuilder = class {
25988
26318
  }
25989
26319
  const contextName = `${this.contextName}${contextNameSuffix}_${index2}`;
25990
26320
  const name = `${contextName}_Template`;
25991
- const visitor = new TemplateDefinitionBuilder(this.constantPool, this._bindingScope, this.level + 1, contextName, this.i18n, index2, name, this._namespace, this.fileBasedI18nSuffix, this.i18nUseExternalIds, this.deferBlocks, this._constants);
26321
+ const visitor = new TemplateDefinitionBuilder(this.constantPool, this._bindingScope, this.level + 1, contextName, this.i18n, index2, name, this._namespace, this.fileBasedI18nSuffix, this.i18nUseExternalIds, this.deferBlocks, this.elementLocations, this._constants);
25992
26322
  this._nestedTemplateFns.push(() => {
25993
26323
  const templateFunctionExpr = visitor.buildTemplateFunction(children, variables, this._ngContentReservedSlots.length + this._ngContentSelectorsOffset, i18n2);
25994
26324
  this.constantPool.statements.push(templateFunctionExpr.toDeclStmt(name));
@@ -26090,13 +26420,10 @@ var TemplateDefinitionBuilder = class {
26090
26420
  return null;
26091
26421
  }
26092
26422
  visitIfBlock(block) {
26423
+ this.allocateBindingSlots(null);
26093
26424
  const branchData = block.branches.map(({ expression, expressionAlias, children, sourceSpan }) => {
26094
- let processedExpression = null;
26095
- if (expression !== null) {
26096
- processedExpression = expression.visit(this._valueConverter);
26097
- this.allocateBindingSlots(processedExpression);
26098
- }
26099
- const variables = expressionAlias ? [new Variable(expressionAlias, DIRECT_CONTEXT_REFERENCE, sourceSpan, sourceSpan)] : void 0;
26425
+ const processedExpression = expression === null ? null : expression.visit(this._valueConverter);
26426
+ const variables = expressionAlias !== null ? [new Variable(expressionAlias.name, DIRECT_CONTEXT_REFERENCE, expressionAlias.sourceSpan, expressionAlias.keySpan)] : void 0;
26100
26427
  return {
26101
26428
  index: this.createEmbeddedTemplateFn(null, children, "_Conditional", sourceSpan, variables),
26102
26429
  expression: processedExpression,
@@ -26133,15 +26460,12 @@ var TemplateDefinitionBuilder = class {
26133
26460
  }
26134
26461
  visitSwitchBlock(block) {
26135
26462
  const blockExpression = block.expression.visit(this._valueConverter);
26136
- this.allocateBindingSlots(blockExpression);
26463
+ this.allocateBindingSlots(null);
26137
26464
  const caseData = block.cases.map((currentCase) => {
26138
- const index2 = this.createEmbeddedTemplateFn(null, currentCase.children, "_Case", currentCase.sourceSpan);
26139
- let expression = null;
26140
- if (currentCase.expression !== null) {
26141
- expression = currentCase.expression.visit(this._valueConverter);
26142
- this.allocateBindingSlots(expression);
26143
- }
26144
- return { index: index2, expression };
26465
+ return {
26466
+ index: this.createEmbeddedTemplateFn(null, currentCase.children, "_Case", currentCase.sourceSpan),
26467
+ expression: currentCase.expression === null ? null : currentCase.expression.visit(this._valueConverter)
26468
+ };
26145
26469
  });
26146
26470
  const containerIndex = caseData[0].index;
26147
26471
  this.updateInstructionWithAdvance(containerIndex, block.sourceSpan, Identifiers.conditional, () => {
@@ -26161,6 +26485,10 @@ var TemplateDefinitionBuilder = class {
26161
26485
  }
26162
26486
  visitDeferredBlock(deferred) {
26163
26487
  const { loading, placeholder, error: error2, triggers, prefetchTriggers } = deferred;
26488
+ const metadata = this.deferBlocks.get(deferred);
26489
+ if (!metadata) {
26490
+ throw new Error("Could not resolve `defer` block metadata. Block may need to be analyzed.");
26491
+ }
26164
26492
  const primaryTemplateIndex = this.createEmbeddedTemplateFn(null, deferred.children, "_Defer", deferred.sourceSpan);
26165
26493
  const loadingIndex = loading ? this.createEmbeddedTemplateFn(null, loading.children, "_DeferLoading", loading.sourceSpan) : null;
26166
26494
  const loadingConsts = loading ? trimTrailingNulls([literal(loading.minimumTime), literal(loading.afterTime)]) : null;
@@ -26172,24 +26500,23 @@ var TemplateDefinitionBuilder = class {
26172
26500
  this.creationInstruction(deferred.sourceSpan, Identifiers.defer, trimTrailingNulls([
26173
26501
  literal(deferredIndex),
26174
26502
  literal(primaryTemplateIndex),
26175
- this.createDeferredDepsFunction(depsFnName, deferred),
26503
+ this.createDeferredDepsFunction(depsFnName, metadata),
26176
26504
  literal(loadingIndex),
26177
26505
  literal(placeholderIndex),
26178
26506
  literal(errorIndex),
26179
26507
  (loadingConsts == null ? void 0 : loadingConsts.length) ? this.addToConsts(literalArr(loadingConsts)) : TYPED_NULL_EXPR,
26180
26508
  placeholderConsts ? this.addToConsts(placeholderConsts) : TYPED_NULL_EXPR
26181
26509
  ]));
26182
- this.createDeferTriggerInstructions(deferredIndex, triggers, false);
26183
- this.createDeferTriggerInstructions(deferredIndex, prefetchTriggers, true);
26510
+ this.createDeferTriggerInstructions(deferredIndex, triggers, metadata, false);
26511
+ this.createDeferTriggerInstructions(deferredIndex, prefetchTriggers, metadata, true);
26184
26512
  this.allocateDataSlot();
26185
26513
  }
26186
- createDeferredDepsFunction(name, deferred) {
26187
- const deferredDeps = this.deferBlocks.get(deferred);
26188
- if (!deferredDeps || deferredDeps.length === 0) {
26514
+ createDeferredDepsFunction(name, metadata) {
26515
+ if (metadata.deps.length === 0) {
26189
26516
  return TYPED_NULL_EXPR;
26190
26517
  }
26191
26518
  const dependencyExp = [];
26192
- for (const deferredDep of deferredDeps) {
26519
+ for (const deferredDep of metadata.deps) {
26193
26520
  if (deferredDep.isDeferrable) {
26194
26521
  const innerFn = arrowFn([new FnParam("m", DYNAMIC_TYPE)], variable("m").prop(deferredDep.symbolName));
26195
26522
  const importExpr2 = new DynamicImportExpr(deferredDep.importPath).prop("then").callFn([innerFn]);
@@ -26202,7 +26529,7 @@ var TemplateDefinitionBuilder = class {
26202
26529
  this.constantPool.statements.push(depsFnExpr.toDeclStmt(name, StmtModifier.Final));
26203
26530
  return variable(name);
26204
26531
  }
26205
- createDeferTriggerInstructions(deferredIndex, triggers, prefetch) {
26532
+ createDeferTriggerInstructions(deferredIndex, triggers, metadata, prefetch) {
26206
26533
  const { when, idle, immediate, timer, hover, interaction, viewport } = triggers;
26207
26534
  if (when) {
26208
26535
  const value = when.value.visit(this._valueConverter);
@@ -26219,25 +26546,39 @@ var TemplateDefinitionBuilder = class {
26219
26546
  this.creationInstruction(timer.sourceSpan, prefetch ? Identifiers.deferPrefetchOnTimer : Identifiers.deferOnTimer, [literal(timer.delay)]);
26220
26547
  }
26221
26548
  if (hover) {
26222
- this.creationInstruction(hover.sourceSpan, prefetch ? Identifiers.deferPrefetchOnHover : Identifiers.deferOnHover);
26549
+ this.domNodeBasedTrigger("hover", hover, metadata, prefetch ? Identifiers.deferPrefetchOnHover : Identifiers.deferOnHover);
26223
26550
  }
26224
26551
  if (interaction) {
26225
- this.creationInstruction(interaction.sourceSpan, prefetch ? Identifiers.deferPrefetchOnInteraction : Identifiers.deferOnInteraction, [literal(interaction.reference)]);
26552
+ this.domNodeBasedTrigger("interaction", interaction, metadata, prefetch ? Identifiers.deferPrefetchOnInteraction : Identifiers.deferOnInteraction);
26226
26553
  }
26227
26554
  if (viewport) {
26228
- this.creationInstruction(viewport.sourceSpan, prefetch ? Identifiers.deferPrefetchOnViewport : Identifiers.deferOnViewport, [literal(viewport.reference)]);
26555
+ this.domNodeBasedTrigger("viewport", viewport, metadata, prefetch ? Identifiers.deferPrefetchOnViewport : Identifiers.deferOnViewport);
26229
26556
  }
26230
26557
  }
26558
+ domNodeBasedTrigger(name, trigger, metadata, instructionRef) {
26559
+ const triggerEl = metadata.triggerElements.get(trigger);
26560
+ if (!triggerEl) {
26561
+ return;
26562
+ }
26563
+ this.creationInstruction(trigger.sourceSpan, instructionRef, () => {
26564
+ const location = this.elementLocations.get(triggerEl);
26565
+ if (!location) {
26566
+ throw new Error(`Could not determine location of reference passed into '${name}' trigger. Template may not have been fully analyzed.`);
26567
+ }
26568
+ const depth = Math.max(this.level - location.level, -1);
26569
+ const params = [literal(location.index)];
26570
+ if (depth !== 0) {
26571
+ params.push(literal(depth));
26572
+ }
26573
+ return params;
26574
+ });
26575
+ }
26231
26576
  allocateDataSlot() {
26232
26577
  return this._dataIndex++;
26233
26578
  }
26234
26579
  visitForLoopBlock(block) {
26235
26580
  const blockIndex = this.allocateDataSlot();
26236
- const primaryData = this.prepareEmbeddedTemplateFn(block.children, "_For", [
26237
- new Variable(block.itemName, "$implicit", block.sourceSpan, block.sourceSpan),
26238
- new Variable(getLoopLocalName(block, "$index"), "$index", block.sourceSpan, block.sourceSpan),
26239
- new Variable(getLoopLocalName(block, "$count"), "$count", block.sourceSpan, block.sourceSpan)
26240
- ]);
26581
+ const primaryData = this.prepareEmbeddedTemplateFn(block.children, "_For", [block.item, block.contextVariables.$index, block.contextVariables.$count]);
26241
26582
  const emptyData = block.empty === null ? null : this.prepareEmbeddedTemplateFn(block.empty.children, "_ForEmpty");
26242
26583
  const { expression: trackByExpression, usesComponentInstance: trackByUsesComponentInstance } = this.createTrackByFunction(block);
26243
26584
  const value = block.expression.visit(this._valueConverter);
@@ -26261,25 +26602,27 @@ var TemplateDefinitionBuilder = class {
26261
26602
  this.updateInstruction(block.sourceSpan, Identifiers.repeater, () => [literal(blockIndex), this.convertPropertyBinding(value)]);
26262
26603
  }
26263
26604
  registerComputedLoopVariables(block, bindingScope) {
26264
- const indexLocalName = getLoopLocalName(block, "$index");
26265
- const countLocalName = getLoopLocalName(block, "$count");
26605
+ const indexLocalName = block.contextVariables.$index.name;
26606
+ const countLocalName = block.contextVariables.$count.name;
26266
26607
  const level = bindingScope.bindingLevel;
26267
- bindingScope.set(level, getLoopLocalName(block, "$odd"), (scope) => scope.get(indexLocalName).modulo(literal(2)).notIdentical(literal(0)));
26268
- bindingScope.set(level, getLoopLocalName(block, "$even"), (scope) => scope.get(indexLocalName).modulo(literal(2)).identical(literal(0)));
26269
- bindingScope.set(level, getLoopLocalName(block, "$first"), (scope) => scope.get(indexLocalName).identical(literal(0)));
26270
- bindingScope.set(level, getLoopLocalName(block, "$last"), (scope) => scope.get(indexLocalName).identical(scope.get(countLocalName).minus(literal(1))));
26608
+ bindingScope.set(level, block.contextVariables.$odd.name, (scope) => scope.get(indexLocalName).modulo(literal(2)).notIdentical(literal(0)));
26609
+ bindingScope.set(level, block.contextVariables.$even.name, (scope) => scope.get(indexLocalName).modulo(literal(2)).identical(literal(0)));
26610
+ bindingScope.set(level, block.contextVariables.$first.name, (scope) => scope.get(indexLocalName).identical(literal(0)));
26611
+ bindingScope.set(level, block.contextVariables.$last.name, (scope) => scope.get(indexLocalName).identical(scope.get(countLocalName).minus(literal(1))));
26271
26612
  }
26272
26613
  optimizeTrackByFunction(block) {
26614
+ const indexLocalName = block.contextVariables.$index.name;
26615
+ const itemName = block.item.name;
26273
26616
  const ast = block.trackBy.ast;
26274
- if (ast instanceof PropertyRead && ast.receiver instanceof ImplicitReceiver && ast.name === getLoopLocalName(block, "$index")) {
26617
+ if (ast instanceof PropertyRead && ast.receiver instanceof ImplicitReceiver && ast.name === indexLocalName) {
26275
26618
  return { expression: importExpr(Identifiers.repeaterTrackByIndex), usesComponentInstance: false };
26276
26619
  }
26277
- if (ast instanceof PropertyRead && ast.receiver instanceof ImplicitReceiver && ast.name === block.itemName) {
26620
+ if (ast instanceof PropertyRead && ast.receiver instanceof ImplicitReceiver && ast.name === itemName) {
26278
26621
  return { expression: importExpr(Identifiers.repeaterTrackByIdentity), usesComponentInstance: false };
26279
26622
  }
26280
26623
  if (ast instanceof Call && ast.receiver instanceof PropertyRead && ast.receiver.receiver instanceof ImplicitReceiver && ast.args.length === 2) {
26281
- const firstIsIndex = ast.args[0] instanceof PropertyRead && ast.args[0].receiver instanceof ImplicitReceiver && ast.args[0].name === getLoopLocalName(block, "$index");
26282
- const secondIsItem = ast.args[1] instanceof PropertyRead && ast.args[1].receiver instanceof ImplicitReceiver && ast.args[1].name === block.itemName;
26624
+ const firstIsIndex = ast.args[0] instanceof PropertyRead && ast.args[0].receiver instanceof ImplicitReceiver && ast.args[0].name === indexLocalName;
26625
+ const secondIsItem = ast.args[1] instanceof PropertyRead && ast.args[1].receiver instanceof ImplicitReceiver && ast.args[1].name === itemName;
26283
26626
  if (firstIsIndex && secondIsItem) {
26284
26627
  const receiver = this.level === 0 ? variable(CONTEXT_NAME) : new ExternalExpr(Identifiers.componentInstance).callFn([]);
26285
26628
  return { expression: receiver.prop(ast.receiver.name), usesComponentInstance: false };
@@ -26292,17 +26635,16 @@ var TemplateDefinitionBuilder = class {
26292
26635
  if (optimizedFn !== null) {
26293
26636
  return optimizedFn;
26294
26637
  }
26295
- const bannedGlobals = /* @__PURE__ */ new Set([
26296
- getLoopLocalName(block, "$count"),
26297
- getLoopLocalName(block, "$first"),
26298
- getLoopLocalName(block, "$last"),
26299
- getLoopLocalName(block, "$even"),
26300
- getLoopLocalName(block, "$odd")
26301
- ]);
26638
+ const contextVars = block.contextVariables;
26302
26639
  const scope = new TrackByBindingScope(this._bindingScope, {
26303
- [getLoopLocalName(block, "$index")]: "$index",
26304
- [block.itemName]: "$item"
26305
- }, bannedGlobals);
26640
+ [contextVars.$index.name]: "$index",
26641
+ [block.item.name]: "$item",
26642
+ [contextVars.$count.name]: contextVars.$count.name,
26643
+ [contextVars.$first.name]: contextVars.$first.name,
26644
+ [contextVars.$last.name]: contextVars.$last.name,
26645
+ [contextVars.$even.name]: contextVars.$even.name,
26646
+ [contextVars.$odd.name]: contextVars.$odd.name
26647
+ });
26306
26648
  const params = [new FnParam("$index"), new FnParam("$item")];
26307
26649
  const stmts = convertPureComponentScopeFunction(block.trackBy.ast, scope, variable(CONTEXT_NAME), "track");
26308
26650
  const usesComponentInstance = scope.getComponentAccessCount() > 0;
@@ -26802,23 +27144,19 @@ var BindingScope = class {
26802
27144
  }
26803
27145
  };
26804
27146
  var TrackByBindingScope = class extends BindingScope {
26805
- constructor(parentScope, globalAliases, bannedGlobals) {
27147
+ constructor(parentScope, globalAliases) {
26806
27148
  super(parentScope.bindingLevel + 1, parentScope);
26807
27149
  this.globalAliases = globalAliases;
26808
- this.bannedGlobals = bannedGlobals;
26809
27150
  this.componentAccessCount = 0;
26810
27151
  }
26811
27152
  get(name) {
26812
27153
  let current = this.parent;
26813
27154
  while (current) {
26814
27155
  if (current.hasLocal(name)) {
26815
- this.forbiddenAccessError(name);
27156
+ return null;
26816
27157
  }
26817
27158
  current = current.parent;
26818
27159
  }
26819
- if (this.bannedGlobals.has(name)) {
26820
- this.forbiddenAccessError(name);
26821
- }
26822
27160
  if (this.globalAliases[name]) {
26823
27161
  return variable(this.globalAliases[name]);
26824
27162
  }
@@ -26828,10 +27166,22 @@ var TrackByBindingScope = class extends BindingScope {
26828
27166
  getComponentAccessCount() {
26829
27167
  return this.componentAccessCount;
26830
27168
  }
26831
- forbiddenAccessError(propertyName) {
26832
- throw new Error(`Accessing ${propertyName} inside of a track expression is not allowed. Tracking expressions can only access the item, $index and properties on the containing component.`);
26833
- }
26834
27169
  };
27170
+ function createCssSelector(elementName, attributes) {
27171
+ const cssSelector = new CssSelector();
27172
+ const elementNameNoNs = splitNsName(elementName)[1];
27173
+ cssSelector.setElement(elementNameNoNs);
27174
+ Object.getOwnPropertyNames(attributes).forEach((name) => {
27175
+ const nameNoNs = splitNsName(name)[1];
27176
+ const value = attributes[name];
27177
+ cssSelector.addAttribute(nameNoNs, value);
27178
+ if (name.toLowerCase() === "class") {
27179
+ const classes = value.trim().split(/\s+/);
27180
+ classes.forEach((className) => cssSelector.addClassName(className));
27181
+ }
27182
+ });
27183
+ return cssSelector;
27184
+ }
26835
27185
  function getNgProjectAsLiteral(attribute2) {
26836
27186
  const parsedR3Selector = parseSelectorToR3Selector(attribute2.value)[0];
26837
27187
  return [literal(5), asLiteral(parsedR3Selector)];
@@ -27037,6 +27387,7 @@ function getBindingFunctionParams(deferredParams, name, eagerParams) {
27037
27387
  }
27038
27388
  var NG_I18N_CLOSURE_MODE = "ngI18nClosureMode";
27039
27389
  function getTranslationDeclStmts(message, variable2, closureVar, params = {}, transformFn) {
27390
+ params = Object.fromEntries(Object.entries(params).sort());
27040
27391
  const statements = [
27041
27392
  declareI18nVariable(variable2),
27042
27393
  ifStmt(createClosureModeGuard(), createGoogleGetMsgStatements(variable2, message, closureVar, params), createLocalizeStatements(variable2, message, formatI18nPlaceholderNamesInMap(params, false)))
@@ -27049,10 +27400,6 @@ function getTranslationDeclStmts(message, variable2, closureVar, params = {}, tr
27049
27400
  function createClosureModeGuard() {
27050
27401
  return typeofExpr(variable(NG_I18N_CLOSURE_MODE)).notIdentical(literal("undefined", STRING_TYPE)).and(variable(NG_I18N_CLOSURE_MODE));
27051
27402
  }
27052
- function getLoopLocalName(block, name) {
27053
- var _a2;
27054
- return ((_a2 = block.contextVariables) == null ? void 0 : _a2[name]) || name;
27055
- }
27056
27403
  var ATTR_REGEX = /attr\.([^\]]+)/;
27057
27404
  var COMPONENT_VARIABLE = "%COMP%";
27058
27405
  var HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
@@ -27145,10 +27492,9 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
27145
27492
  }
27146
27493
  const templateTypeName = meta.name;
27147
27494
  const templateName = templateTypeName ? `${templateTypeName}_Template` : null;
27148
- const changeDetection = meta.changeDetection;
27149
27495
  if (!USE_TEMPLATE_PIPELINE) {
27150
27496
  const template2 = meta.template;
27151
- const templateBuilder = new TemplateDefinitionBuilder(constantPool, BindingScope.createRootScope(), 0, templateTypeName, null, null, templateName, Identifiers.namespaceHTML, meta.relativeContextFilePath, meta.i18nUseExternalIds, meta.deferBlocks);
27497
+ const templateBuilder = new TemplateDefinitionBuilder(constantPool, BindingScope.createRootScope(), 0, templateTypeName, null, null, templateName, Identifiers.namespaceHTML, meta.relativeContextFilePath, meta.i18nUseExternalIds, meta.deferBlocks, /* @__PURE__ */ new Map());
27152
27498
  const templateFunctionExpression = templateBuilder.buildTemplateFunction(template2.nodes, []);
27153
27499
  const ngContentSelectors = templateBuilder.getNgContentSelectors();
27154
27500
  if (ngContentSelectors) {
@@ -27169,6 +27515,9 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
27169
27515
  const tpl = ingestComponent(meta.name, meta.template.nodes, constantPool, meta.relativeContextFilePath, meta.i18nUseExternalIds);
27170
27516
  transform(tpl, CompilationJobKind.Tmpl);
27171
27517
  const templateFn = emitTemplateFn(tpl, constantPool);
27518
+ if (tpl.contentSelectors !== null) {
27519
+ definitionMap.set("ngContentSelectors", tpl.contentSelectors);
27520
+ }
27172
27521
  definitionMap.set("decls", literal(tpl.root.decls));
27173
27522
  definitionMap.set("vars", literal(tpl.root.vars));
27174
27523
  if (tpl.consts.length > 0) {
@@ -27212,8 +27561,12 @@ function compileComponentFromMetadata(meta, constantPool, bindingParser) {
27212
27561
  if (meta.animations !== null) {
27213
27562
  definitionMap.set("data", literalMap([{ key: "animation", value: meta.animations, quoted: false }]));
27214
27563
  }
27215
- if (changeDetection != null && changeDetection !== ChangeDetectionStrategy.Default) {
27216
- definitionMap.set("changeDetection", literal(changeDetection));
27564
+ if (meta.changeDetection !== null) {
27565
+ if (typeof meta.changeDetection === "number" && meta.changeDetection !== ChangeDetectionStrategy.Default) {
27566
+ definitionMap.set("changeDetection", literal(meta.changeDetection));
27567
+ } else if (typeof meta.changeDetection === "object") {
27568
+ definitionMap.set("changeDetection", meta.changeDetection);
27569
+ }
27217
27570
  }
27218
27571
  const expression = importExpr(Identifiers.defineComponent).callFn([definitionMap.toLiteralMap()], void 0, true);
27219
27572
  const type = createComponentType(meta);
@@ -27644,6 +27997,590 @@ function createHostDirectivesMappingArray(mapping) {
27644
27997
  }
27645
27998
  return elements.length > 0 ? literalArr(elements) : null;
27646
27999
  }
28000
+ var R3TargetBinder = class {
28001
+ constructor(directiveMatcher) {
28002
+ this.directiveMatcher = directiveMatcher;
28003
+ }
28004
+ bind(target) {
28005
+ if (!target.template) {
28006
+ throw new Error("Binding without a template not yet supported");
28007
+ }
28008
+ const scope = Scope.apply(target.template);
28009
+ const scopedNodeEntities = extractScopedNodeEntities(scope);
28010
+ const { directives, eagerDirectives, bindings, references } = DirectiveBinder.apply(target.template, this.directiveMatcher);
28011
+ const { expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks } = TemplateBinder.applyWithScope(target.template, scope);
28012
+ return new R3BoundTarget(target, directives, eagerDirectives, bindings, references, expressions, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferBlocks);
28013
+ }
28014
+ };
28015
+ var Scope = class {
28016
+ constructor(parentScope, rootNode) {
28017
+ this.parentScope = parentScope;
28018
+ this.rootNode = rootNode;
28019
+ this.namedEntities = /* @__PURE__ */ new Map();
28020
+ this.childScopes = /* @__PURE__ */ new Map();
28021
+ this.isDeferred = parentScope !== null && parentScope.isDeferred ? true : rootNode instanceof DeferredBlock;
28022
+ }
28023
+ static newRootScope() {
28024
+ return new Scope(null, null);
28025
+ }
28026
+ static apply(template2) {
28027
+ const scope = Scope.newRootScope();
28028
+ scope.ingest(template2);
28029
+ return scope;
28030
+ }
28031
+ ingest(nodeOrNodes) {
28032
+ if (nodeOrNodes instanceof Template) {
28033
+ nodeOrNodes.variables.forEach((node) => this.visitVariable(node));
28034
+ nodeOrNodes.children.forEach((node) => node.visit(this));
28035
+ } else if (nodeOrNodes instanceof IfBlockBranch) {
28036
+ if (nodeOrNodes.expressionAlias !== null) {
28037
+ this.visitVariable(nodeOrNodes.expressionAlias);
28038
+ }
28039
+ nodeOrNodes.children.forEach((node) => node.visit(this));
28040
+ } else if (nodeOrNodes instanceof ForLoopBlock) {
28041
+ this.visitVariable(nodeOrNodes.item);
28042
+ Object.values(nodeOrNodes.contextVariables).forEach((v) => this.visitVariable(v));
28043
+ nodeOrNodes.children.forEach((node) => node.visit(this));
28044
+ } else if (nodeOrNodes instanceof SwitchBlockCase || nodeOrNodes instanceof ForLoopBlockEmpty || nodeOrNodes instanceof DeferredBlock || nodeOrNodes instanceof DeferredBlockError || nodeOrNodes instanceof DeferredBlockPlaceholder || nodeOrNodes instanceof DeferredBlockLoading) {
28045
+ nodeOrNodes.children.forEach((node) => node.visit(this));
28046
+ } else {
28047
+ nodeOrNodes.forEach((node) => node.visit(this));
28048
+ }
28049
+ }
28050
+ visitElement(element2) {
28051
+ element2.references.forEach((node) => this.visitReference(node));
28052
+ element2.children.forEach((node) => node.visit(this));
28053
+ }
28054
+ visitTemplate(template2) {
28055
+ template2.references.forEach((node) => this.visitReference(node));
28056
+ this.ingestScopedNode(template2);
28057
+ }
28058
+ visitVariable(variable2) {
28059
+ this.maybeDeclare(variable2);
28060
+ }
28061
+ visitReference(reference2) {
28062
+ this.maybeDeclare(reference2);
28063
+ }
28064
+ visitDeferredBlock(deferred) {
28065
+ var _a2, _b2, _c2;
28066
+ this.ingestScopedNode(deferred);
28067
+ (_a2 = deferred.placeholder) == null ? void 0 : _a2.visit(this);
28068
+ (_b2 = deferred.loading) == null ? void 0 : _b2.visit(this);
28069
+ (_c2 = deferred.error) == null ? void 0 : _c2.visit(this);
28070
+ }
28071
+ visitDeferredBlockPlaceholder(block) {
28072
+ this.ingestScopedNode(block);
28073
+ }
28074
+ visitDeferredBlockError(block) {
28075
+ this.ingestScopedNode(block);
28076
+ }
28077
+ visitDeferredBlockLoading(block) {
28078
+ this.ingestScopedNode(block);
28079
+ }
28080
+ visitSwitchBlock(block) {
28081
+ block.cases.forEach((node) => node.visit(this));
28082
+ }
28083
+ visitSwitchBlockCase(block) {
28084
+ this.ingestScopedNode(block);
28085
+ }
28086
+ visitForLoopBlock(block) {
28087
+ var _a2;
28088
+ this.ingestScopedNode(block);
28089
+ (_a2 = block.empty) == null ? void 0 : _a2.visit(this);
28090
+ }
28091
+ visitForLoopBlockEmpty(block) {
28092
+ this.ingestScopedNode(block);
28093
+ }
28094
+ visitIfBlock(block) {
28095
+ block.branches.forEach((node) => node.visit(this));
28096
+ }
28097
+ visitIfBlockBranch(block) {
28098
+ this.ingestScopedNode(block);
28099
+ }
28100
+ visitContent(content) {
28101
+ }
28102
+ visitBoundAttribute(attr) {
28103
+ }
28104
+ visitBoundEvent(event) {
28105
+ }
28106
+ visitBoundText(text2) {
28107
+ }
28108
+ visitText(text2) {
28109
+ }
28110
+ visitTextAttribute(attr) {
28111
+ }
28112
+ visitIcu(icu) {
28113
+ }
28114
+ visitDeferredTrigger(trigger) {
28115
+ }
28116
+ maybeDeclare(thing) {
28117
+ if (!this.namedEntities.has(thing.name)) {
28118
+ this.namedEntities.set(thing.name, thing);
28119
+ }
28120
+ }
28121
+ lookup(name) {
28122
+ if (this.namedEntities.has(name)) {
28123
+ return this.namedEntities.get(name);
28124
+ } else if (this.parentScope !== null) {
28125
+ return this.parentScope.lookup(name);
28126
+ } else {
28127
+ return null;
28128
+ }
28129
+ }
28130
+ getChildScope(node) {
28131
+ const res = this.childScopes.get(node);
28132
+ if (res === void 0) {
28133
+ throw new Error(`Assertion error: child scope for ${node} not found`);
28134
+ }
28135
+ return res;
28136
+ }
28137
+ ingestScopedNode(node) {
28138
+ const scope = new Scope(this, node);
28139
+ scope.ingest(node);
28140
+ this.childScopes.set(node, scope);
28141
+ }
28142
+ };
28143
+ var DirectiveBinder = class {
28144
+ constructor(matcher, directives, eagerDirectives, bindings, references) {
28145
+ this.matcher = matcher;
28146
+ this.directives = directives;
28147
+ this.eagerDirectives = eagerDirectives;
28148
+ this.bindings = bindings;
28149
+ this.references = references;
28150
+ this.isInDeferBlock = false;
28151
+ }
28152
+ static apply(template2, selectorMatcher) {
28153
+ const directives = /* @__PURE__ */ new Map();
28154
+ const bindings = /* @__PURE__ */ new Map();
28155
+ const references = /* @__PURE__ */ new Map();
28156
+ const eagerDirectives = [];
28157
+ const matcher = new DirectiveBinder(selectorMatcher, directives, eagerDirectives, bindings, references);
28158
+ matcher.ingest(template2);
28159
+ return { directives, eagerDirectives, bindings, references };
28160
+ }
28161
+ ingest(template2) {
28162
+ template2.forEach((node) => node.visit(this));
28163
+ }
28164
+ visitElement(element2) {
28165
+ this.visitElementOrTemplate(element2.name, element2);
28166
+ }
28167
+ visitTemplate(template2) {
28168
+ this.visitElementOrTemplate("ng-template", template2);
28169
+ }
28170
+ visitElementOrTemplate(elementName, node) {
28171
+ const cssSelector = createCssSelector(elementName, getAttrsForDirectiveMatching(node));
28172
+ const directives = [];
28173
+ this.matcher.match(cssSelector, (_selector, results) => directives.push(...results));
28174
+ if (directives.length > 0) {
28175
+ this.directives.set(node, directives);
28176
+ if (!this.isInDeferBlock) {
28177
+ this.eagerDirectives.push(...directives);
28178
+ }
28179
+ }
28180
+ node.references.forEach((ref) => {
28181
+ let dirTarget = null;
28182
+ if (ref.value.trim() === "") {
28183
+ dirTarget = directives.find((dir) => dir.isComponent) || null;
28184
+ } else {
28185
+ dirTarget = directives.find((dir) => dir.exportAs !== null && dir.exportAs.some((value) => value === ref.value)) || null;
28186
+ if (dirTarget === null) {
28187
+ return;
28188
+ }
28189
+ }
28190
+ if (dirTarget !== null) {
28191
+ this.references.set(ref, { directive: dirTarget, node });
28192
+ } else {
28193
+ this.references.set(ref, node);
28194
+ }
28195
+ });
28196
+ const setAttributeBinding = (attribute2, ioType) => {
28197
+ const dir = directives.find((dir2) => dir2[ioType].hasBindingPropertyName(attribute2.name));
28198
+ const binding = dir !== void 0 ? dir : node;
28199
+ this.bindings.set(attribute2, binding);
28200
+ };
28201
+ node.inputs.forEach((input) => setAttributeBinding(input, "inputs"));
28202
+ node.attributes.forEach((attr) => setAttributeBinding(attr, "inputs"));
28203
+ if (node instanceof Template) {
28204
+ node.templateAttrs.forEach((attr) => setAttributeBinding(attr, "inputs"));
28205
+ }
28206
+ node.outputs.forEach((output) => setAttributeBinding(output, "outputs"));
28207
+ node.children.forEach((child) => child.visit(this));
28208
+ }
28209
+ visitDeferredBlock(deferred) {
28210
+ var _a2, _b2, _c2;
28211
+ const wasInDeferBlock = this.isInDeferBlock;
28212
+ this.isInDeferBlock = true;
28213
+ deferred.children.forEach((child) => child.visit(this));
28214
+ this.isInDeferBlock = wasInDeferBlock;
28215
+ (_a2 = deferred.placeholder) == null ? void 0 : _a2.visit(this);
28216
+ (_b2 = deferred.loading) == null ? void 0 : _b2.visit(this);
28217
+ (_c2 = deferred.error) == null ? void 0 : _c2.visit(this);
28218
+ }
28219
+ visitDeferredBlockPlaceholder(block) {
28220
+ block.children.forEach((child) => child.visit(this));
28221
+ }
28222
+ visitDeferredBlockError(block) {
28223
+ block.children.forEach((child) => child.visit(this));
28224
+ }
28225
+ visitDeferredBlockLoading(block) {
28226
+ block.children.forEach((child) => child.visit(this));
28227
+ }
28228
+ visitSwitchBlock(block) {
28229
+ block.cases.forEach((node) => node.visit(this));
28230
+ }
28231
+ visitSwitchBlockCase(block) {
28232
+ block.children.forEach((node) => node.visit(this));
28233
+ }
28234
+ visitForLoopBlock(block) {
28235
+ var _a2;
28236
+ block.item.visit(this);
28237
+ Object.values(block.contextVariables).forEach((v) => v.visit(this));
28238
+ block.children.forEach((node) => node.visit(this));
28239
+ (_a2 = block.empty) == null ? void 0 : _a2.visit(this);
28240
+ }
28241
+ visitForLoopBlockEmpty(block) {
28242
+ block.children.forEach((node) => node.visit(this));
28243
+ }
28244
+ visitIfBlock(block) {
28245
+ block.branches.forEach((node) => node.visit(this));
28246
+ }
28247
+ visitIfBlockBranch(block) {
28248
+ var _a2;
28249
+ (_a2 = block.expressionAlias) == null ? void 0 : _a2.visit(this);
28250
+ block.children.forEach((node) => node.visit(this));
28251
+ }
28252
+ visitContent(content) {
28253
+ }
28254
+ visitVariable(variable2) {
28255
+ }
28256
+ visitReference(reference2) {
28257
+ }
28258
+ visitTextAttribute(attribute2) {
28259
+ }
28260
+ visitBoundAttribute(attribute2) {
28261
+ }
28262
+ visitBoundEvent(attribute2) {
28263
+ }
28264
+ visitBoundAttributeOrEvent(node) {
28265
+ }
28266
+ visitText(text2) {
28267
+ }
28268
+ visitBoundText(text2) {
28269
+ }
28270
+ visitIcu(icu) {
28271
+ }
28272
+ visitDeferredTrigger(trigger) {
28273
+ }
28274
+ };
28275
+ var TemplateBinder = class extends RecursiveAstVisitor {
28276
+ constructor(bindings, symbols, usedPipes, eagerPipes, deferBlocks, nestingLevel, scope, rootNode, level) {
28277
+ super();
28278
+ this.bindings = bindings;
28279
+ this.symbols = symbols;
28280
+ this.usedPipes = usedPipes;
28281
+ this.eagerPipes = eagerPipes;
28282
+ this.deferBlocks = deferBlocks;
28283
+ this.nestingLevel = nestingLevel;
28284
+ this.scope = scope;
28285
+ this.rootNode = rootNode;
28286
+ this.level = level;
28287
+ this.visitNode = (node) => node.visit(this);
28288
+ }
28289
+ visit(node, context) {
28290
+ if (node instanceof AST) {
28291
+ node.visit(this, context);
28292
+ } else {
28293
+ node.visit(this);
28294
+ }
28295
+ }
28296
+ static applyWithScope(nodes, scope) {
28297
+ const expressions = /* @__PURE__ */ new Map();
28298
+ const symbols = /* @__PURE__ */ new Map();
28299
+ const nestingLevel = /* @__PURE__ */ new Map();
28300
+ const usedPipes = /* @__PURE__ */ new Set();
28301
+ const eagerPipes = /* @__PURE__ */ new Set();
28302
+ const template2 = nodes instanceof Template ? nodes : null;
28303
+ const deferBlocks = /* @__PURE__ */ new Set();
28304
+ const binder = new TemplateBinder(expressions, symbols, usedPipes, eagerPipes, deferBlocks, nestingLevel, scope, template2, 0);
28305
+ binder.ingest(nodes);
28306
+ return { expressions, symbols, nestingLevel, usedPipes, eagerPipes, deferBlocks };
28307
+ }
28308
+ ingest(nodeOrNodes) {
28309
+ if (nodeOrNodes instanceof Template) {
28310
+ nodeOrNodes.variables.forEach(this.visitNode);
28311
+ nodeOrNodes.children.forEach(this.visitNode);
28312
+ this.nestingLevel.set(nodeOrNodes, this.level);
28313
+ } else if (nodeOrNodes instanceof IfBlockBranch) {
28314
+ if (nodeOrNodes.expressionAlias !== null) {
28315
+ this.visitNode(nodeOrNodes.expressionAlias);
28316
+ }
28317
+ nodeOrNodes.children.forEach(this.visitNode);
28318
+ this.nestingLevel.set(nodeOrNodes, this.level);
28319
+ } else if (nodeOrNodes instanceof ForLoopBlock) {
28320
+ this.visitNode(nodeOrNodes.item);
28321
+ Object.values(nodeOrNodes.contextVariables).forEach((v) => this.visitNode(v));
28322
+ nodeOrNodes.trackBy.visit(this);
28323
+ nodeOrNodes.children.forEach(this.visitNode);
28324
+ this.nestingLevel.set(nodeOrNodes, this.level);
28325
+ } else if (nodeOrNodes instanceof SwitchBlockCase || nodeOrNodes instanceof ForLoopBlockEmpty || nodeOrNodes instanceof DeferredBlock || nodeOrNodes instanceof DeferredBlockError || nodeOrNodes instanceof DeferredBlockPlaceholder || nodeOrNodes instanceof DeferredBlockLoading) {
28326
+ nodeOrNodes.children.forEach((node) => node.visit(this));
28327
+ this.nestingLevel.set(nodeOrNodes, this.level);
28328
+ } else {
28329
+ nodeOrNodes.forEach(this.visitNode);
28330
+ }
28331
+ }
28332
+ visitElement(element2) {
28333
+ element2.inputs.forEach(this.visitNode);
28334
+ element2.outputs.forEach(this.visitNode);
28335
+ element2.children.forEach(this.visitNode);
28336
+ element2.references.forEach(this.visitNode);
28337
+ }
28338
+ visitTemplate(template2) {
28339
+ template2.inputs.forEach(this.visitNode);
28340
+ template2.outputs.forEach(this.visitNode);
28341
+ template2.templateAttrs.forEach(this.visitNode);
28342
+ template2.references.forEach(this.visitNode);
28343
+ this.ingestScopedNode(template2);
28344
+ }
28345
+ visitVariable(variable2) {
28346
+ if (this.rootNode !== null) {
28347
+ this.symbols.set(variable2, this.rootNode);
28348
+ }
28349
+ }
28350
+ visitReference(reference2) {
28351
+ if (this.rootNode !== null) {
28352
+ this.symbols.set(reference2, this.rootNode);
28353
+ }
28354
+ }
28355
+ visitText(text2) {
28356
+ }
28357
+ visitContent(content) {
28358
+ }
28359
+ visitTextAttribute(attribute2) {
28360
+ }
28361
+ visitIcu(icu) {
28362
+ Object.keys(icu.vars).forEach((key) => icu.vars[key].visit(this));
28363
+ Object.keys(icu.placeholders).forEach((key) => icu.placeholders[key].visit(this));
28364
+ }
28365
+ visitBoundAttribute(attribute2) {
28366
+ attribute2.value.visit(this);
28367
+ }
28368
+ visitBoundEvent(event) {
28369
+ event.handler.visit(this);
28370
+ }
28371
+ visitDeferredBlock(deferred) {
28372
+ this.deferBlocks.add(deferred);
28373
+ this.ingestScopedNode(deferred);
28374
+ deferred.placeholder && this.visitNode(deferred.placeholder);
28375
+ deferred.loading && this.visitNode(deferred.loading);
28376
+ deferred.error && this.visitNode(deferred.error);
28377
+ }
28378
+ visitDeferredTrigger(trigger) {
28379
+ if (trigger instanceof BoundDeferredTrigger) {
28380
+ trigger.value.visit(this);
28381
+ }
28382
+ }
28383
+ visitDeferredBlockPlaceholder(block) {
28384
+ this.ingestScopedNode(block);
28385
+ }
28386
+ visitDeferredBlockError(block) {
28387
+ this.ingestScopedNode(block);
28388
+ }
28389
+ visitDeferredBlockLoading(block) {
28390
+ this.ingestScopedNode(block);
28391
+ }
28392
+ visitSwitchBlock(block) {
28393
+ block.expression.visit(this);
28394
+ block.cases.forEach(this.visitNode);
28395
+ }
28396
+ visitSwitchBlockCase(block) {
28397
+ var _a2;
28398
+ (_a2 = block.expression) == null ? void 0 : _a2.visit(this);
28399
+ this.ingestScopedNode(block);
28400
+ }
28401
+ visitForLoopBlock(block) {
28402
+ var _a2;
28403
+ block.expression.visit(this);
28404
+ this.ingestScopedNode(block);
28405
+ (_a2 = block.empty) == null ? void 0 : _a2.visit(this);
28406
+ }
28407
+ visitForLoopBlockEmpty(block) {
28408
+ this.ingestScopedNode(block);
28409
+ }
28410
+ visitIfBlock(block) {
28411
+ block.branches.forEach((node) => node.visit(this));
28412
+ }
28413
+ visitIfBlockBranch(block) {
28414
+ var _a2;
28415
+ (_a2 = block.expression) == null ? void 0 : _a2.visit(this);
28416
+ this.ingestScopedNode(block);
28417
+ }
28418
+ visitBoundText(text2) {
28419
+ text2.value.visit(this);
28420
+ }
28421
+ visitPipe(ast, context) {
28422
+ this.usedPipes.add(ast.name);
28423
+ if (!this.scope.isDeferred) {
28424
+ this.eagerPipes.add(ast.name);
28425
+ }
28426
+ return super.visitPipe(ast, context);
28427
+ }
28428
+ visitPropertyRead(ast, context) {
28429
+ this.maybeMap(ast, ast.name);
28430
+ return super.visitPropertyRead(ast, context);
28431
+ }
28432
+ visitSafePropertyRead(ast, context) {
28433
+ this.maybeMap(ast, ast.name);
28434
+ return super.visitSafePropertyRead(ast, context);
28435
+ }
28436
+ visitPropertyWrite(ast, context) {
28437
+ this.maybeMap(ast, ast.name);
28438
+ return super.visitPropertyWrite(ast, context);
28439
+ }
28440
+ ingestScopedNode(node) {
28441
+ const childScope = this.scope.getChildScope(node);
28442
+ const binder = new TemplateBinder(this.bindings, this.symbols, this.usedPipes, this.eagerPipes, this.deferBlocks, this.nestingLevel, childScope, node, this.level + 1);
28443
+ binder.ingest(node);
28444
+ }
28445
+ maybeMap(ast, name) {
28446
+ if (!(ast.receiver instanceof ImplicitReceiver)) {
28447
+ return;
28448
+ }
28449
+ let target = this.scope.lookup(name);
28450
+ if (target !== null) {
28451
+ this.bindings.set(ast, target);
28452
+ }
28453
+ }
28454
+ };
28455
+ var R3BoundTarget = class {
28456
+ constructor(target, directives, eagerDirectives, bindings, references, exprTargets, symbols, nestingLevel, scopedNodeEntities, usedPipes, eagerPipes, deferredBlocks) {
28457
+ this.target = target;
28458
+ this.directives = directives;
28459
+ this.eagerDirectives = eagerDirectives;
28460
+ this.bindings = bindings;
28461
+ this.references = references;
28462
+ this.exprTargets = exprTargets;
28463
+ this.symbols = symbols;
28464
+ this.nestingLevel = nestingLevel;
28465
+ this.scopedNodeEntities = scopedNodeEntities;
28466
+ this.usedPipes = usedPipes;
28467
+ this.eagerPipes = eagerPipes;
28468
+ this.deferredBlocks = deferredBlocks;
28469
+ }
28470
+ getEntitiesInScope(node) {
28471
+ var _a2;
28472
+ return (_a2 = this.scopedNodeEntities.get(node)) != null ? _a2 : /* @__PURE__ */ new Set();
28473
+ }
28474
+ getDirectivesOfNode(node) {
28475
+ return this.directives.get(node) || null;
28476
+ }
28477
+ getReferenceTarget(ref) {
28478
+ return this.references.get(ref) || null;
28479
+ }
28480
+ getConsumerOfBinding(binding) {
28481
+ return this.bindings.get(binding) || null;
28482
+ }
28483
+ getExpressionTarget(expr) {
28484
+ return this.exprTargets.get(expr) || null;
28485
+ }
28486
+ getDefinitionNodeOfSymbol(symbol) {
28487
+ return this.symbols.get(symbol) || null;
28488
+ }
28489
+ getNestingLevel(node) {
28490
+ return this.nestingLevel.get(node) || 0;
28491
+ }
28492
+ getUsedDirectives() {
28493
+ const set = /* @__PURE__ */ new Set();
28494
+ this.directives.forEach((dirs) => dirs.forEach((dir) => set.add(dir)));
28495
+ return Array.from(set.values());
28496
+ }
28497
+ getEagerlyUsedDirectives() {
28498
+ const set = new Set(this.eagerDirectives);
28499
+ return Array.from(set.values());
28500
+ }
28501
+ getUsedPipes() {
28502
+ return Array.from(this.usedPipes);
28503
+ }
28504
+ getEagerlyUsedPipes() {
28505
+ return Array.from(this.eagerPipes);
28506
+ }
28507
+ getDeferBlocks() {
28508
+ return Array.from(this.deferredBlocks);
28509
+ }
28510
+ getDeferredTriggerTarget(block, trigger) {
28511
+ if (!(trigger instanceof InteractionDeferredTrigger) && !(trigger instanceof ViewportDeferredTrigger) && !(trigger instanceof HoverDeferredTrigger)) {
28512
+ return null;
28513
+ }
28514
+ const name = trigger.reference;
28515
+ if (name === null) {
28516
+ const children = block.placeholder ? block.placeholder.children : null;
28517
+ return children !== null && children.length === 1 && children[0] instanceof Element$1 ? children[0] : null;
28518
+ }
28519
+ const outsideRef = this.findEntityInScope(block, name);
28520
+ if (outsideRef instanceof Reference && this.getDefinitionNodeOfSymbol(outsideRef) !== block) {
28521
+ const target = this.getReferenceTarget(outsideRef);
28522
+ if (target !== null) {
28523
+ return this.referenceTargetToElement(target);
28524
+ }
28525
+ }
28526
+ if (block.placeholder !== null) {
28527
+ const refInPlaceholder = this.findEntityInScope(block.placeholder, name);
28528
+ const targetInPlaceholder = refInPlaceholder instanceof Reference ? this.getReferenceTarget(refInPlaceholder) : null;
28529
+ if (targetInPlaceholder !== null) {
28530
+ return this.referenceTargetToElement(targetInPlaceholder);
28531
+ }
28532
+ }
28533
+ return null;
28534
+ }
28535
+ findEntityInScope(rootNode, name) {
28536
+ const entities = this.getEntitiesInScope(rootNode);
28537
+ for (const entitity of entities) {
28538
+ if (entitity.name === name) {
28539
+ return entitity;
28540
+ }
28541
+ }
28542
+ return null;
28543
+ }
28544
+ referenceTargetToElement(target) {
28545
+ if (target instanceof Element$1) {
28546
+ return target;
28547
+ }
28548
+ if (target instanceof Template) {
28549
+ return null;
28550
+ }
28551
+ return this.referenceTargetToElement(target.node);
28552
+ }
28553
+ };
28554
+ function extractScopedNodeEntities(rootScope) {
28555
+ const entityMap = /* @__PURE__ */ new Map();
28556
+ function extractScopeEntities(scope) {
28557
+ if (entityMap.has(scope.rootNode)) {
28558
+ return entityMap.get(scope.rootNode);
28559
+ }
28560
+ const currentEntities = scope.namedEntities;
28561
+ let entities;
28562
+ if (scope.parentScope !== null) {
28563
+ entities = new Map([...extractScopeEntities(scope.parentScope), ...currentEntities]);
28564
+ } else {
28565
+ entities = new Map(currentEntities);
28566
+ }
28567
+ entityMap.set(scope.rootNode, entities);
28568
+ return entities;
28569
+ }
28570
+ const scopesToProcess = [rootScope];
28571
+ while (scopesToProcess.length > 0) {
28572
+ const scope = scopesToProcess.pop();
28573
+ for (const childScope of scope.childScopes.values()) {
28574
+ scopesToProcess.push(childScope);
28575
+ }
28576
+ extractScopeEntities(scope);
28577
+ }
28578
+ const templateEntities = /* @__PURE__ */ new Map();
28579
+ for (const [template2, entities] of entityMap) {
28580
+ templateEntities.set(template2, new Set(entities.values()));
28581
+ }
28582
+ return templateEntities;
28583
+ }
27647
28584
  var ResourceLoader = class {
27648
28585
  };
27649
28586
  var enabledBlockTypes;
@@ -27761,18 +28698,19 @@ var CompilerFacadeImpl = class {
27761
28698
  return this.jitExpression(res.expression, angularCoreEnv, sourceMapUrl, constantPool.statements);
27762
28699
  }
27763
28700
  compileComponent(angularCoreEnv, sourceMapUrl, facade) {
27764
- const { template: template2, interpolation } = parseJitTemplate(facade.template, facade.name, sourceMapUrl, facade.preserveWhitespaces, facade.interpolation);
28701
+ var _a2;
28702
+ const { template: template2, interpolation, deferBlocks } = parseJitTemplate(facade.template, facade.name, sourceMapUrl, facade.preserveWhitespaces, facade.interpolation);
27765
28703
  const meta = __spreadProps(__spreadValues(__spreadValues({}, facade), convertDirectiveFacadeToMetadata(facade)), {
27766
28704
  selector: facade.selector || this.elementSchemaRegistry.getDefaultComponentElementName(),
27767
28705
  template: template2,
27768
28706
  declarations: facade.declarations.map(convertDeclarationFacadeToMetadata),
27769
28707
  declarationListEmitMode: 0,
27770
- deferBlocks: /* @__PURE__ */ new Map(),
28708
+ deferBlocks,
27771
28709
  deferrableDeclToImportDecl: /* @__PURE__ */ new Map(),
27772
28710
  styles: [...facade.styles, ...template2.styles],
27773
28711
  encapsulation: facade.encapsulation,
27774
28712
  interpolation,
27775
- changeDetection: facade.changeDetection,
28713
+ changeDetection: (_a2 = facade.changeDetection) != null ? _a2 : null,
27776
28714
  animations: facade.animations != null ? new WrappedNodeExpr(facade.animations) : null,
27777
28715
  viewProviders: facade.viewProviders != null ? new WrappedNodeExpr(facade.viewProviders) : null,
27778
28716
  relativeContextFilePath: "",
@@ -27948,7 +28886,7 @@ function convertOpaqueValuesToExpressions(obj) {
27948
28886
  }
27949
28887
  function convertDeclareComponentFacadeToMetadata(decl2, typeSourceSpan, sourceMapUrl) {
27950
28888
  var _a2, _b2, _c2, _d2;
27951
- const { template: template2, interpolation } = parseJitTemplate(decl2.template, decl2.type.name, sourceMapUrl, (_a2 = decl2.preserveWhitespaces) != null ? _a2 : false, decl2.interpolation);
28889
+ const { template: template2, interpolation, deferBlocks } = parseJitTemplate(decl2.template, decl2.type.name, sourceMapUrl, (_a2 = decl2.preserveWhitespaces) != null ? _a2 : false, decl2.interpolation);
27952
28890
  const declarations = [];
27953
28891
  if (decl2.dependencies) {
27954
28892
  for (const innerDep of decl2.dependencies) {
@@ -27973,7 +28911,7 @@ function convertDeclareComponentFacadeToMetadata(decl2, typeSourceSpan, sourceMa
27973
28911
  declarations,
27974
28912
  viewProviders: decl2.viewProviders !== void 0 ? new WrappedNodeExpr(decl2.viewProviders) : null,
27975
28913
  animations: decl2.animations !== void 0 ? new WrappedNodeExpr(decl2.animations) : null,
27976
- deferBlocks: /* @__PURE__ */ new Map(),
28914
+ deferBlocks,
27977
28915
  deferrableDeclToImportDecl: /* @__PURE__ */ new Map(),
27978
28916
  changeDetection: (_c2 = decl2.changeDetection) != null ? _c2 : ChangeDetectionStrategy.Default,
27979
28917
  encapsulation: (_d2 = decl2.encapsulation) != null ? _d2 : ViewEncapsulation.Emulated,
@@ -28026,7 +28964,13 @@ function parseJitTemplate(template2, typeName, sourceMapUrl, preserveWhitespaces
28026
28964
  const errors = parsed.errors.map((err) => err.toString()).join(", ");
28027
28965
  throw new Error(`Errors during JIT compilation of template for ${typeName}: ${errors}`);
28028
28966
  }
28029
- return { template: parsed, interpolation: interpolationConfig };
28967
+ const binder = new R3TargetBinder(new SelectorMatcher());
28968
+ const boundTarget = binder.bind({ template: parsed.nodes });
28969
+ return {
28970
+ template: parsed,
28971
+ interpolation: interpolationConfig,
28972
+ deferBlocks: createR3DeferredMetadata(boundTarget)
28973
+ };
28030
28974
  }
28031
28975
  function convertToProviderExpression(obj, property2) {
28032
28976
  if (obj.hasOwnProperty(property2)) {
@@ -28065,6 +29009,23 @@ function createR3DependencyMetadata(token, isAttributeDep, host, optional, self,
28065
29009
  const attributeNameType = isAttributeDep ? literal("unknown") : null;
28066
29010
  return { token, attributeNameType, host, optional, self, skipSelf };
28067
29011
  }
29012
+ function createR3DeferredMetadata(boundTarget) {
29013
+ const deferredBlocks = boundTarget.getDeferBlocks();
29014
+ const meta = /* @__PURE__ */ new Map();
29015
+ for (const block of deferredBlocks) {
29016
+ const triggerElements = /* @__PURE__ */ new Map();
29017
+ resolveDeferTriggers(block, block.triggers, boundTarget, triggerElements);
29018
+ resolveDeferTriggers(block, block.prefetchTriggers, boundTarget, triggerElements);
29019
+ meta.set(block, { deps: [], triggerElements });
29020
+ }
29021
+ return meta;
29022
+ }
29023
+ function resolveDeferTriggers(block, triggers, boundTarget, triggerElements) {
29024
+ Object.keys(triggers).forEach((key) => {
29025
+ const trigger = triggers[key];
29026
+ triggerElements.set(trigger, boundTarget.getDeferredTriggerTarget(block, trigger));
29027
+ });
29028
+ }
28068
29029
  function extractHostBindings(propMetadata, sourceSpan, host) {
28069
29030
  const bindings = parseHostBindings(host || {});
28070
29031
  const errors = verifyHostBindings(bindings, sourceSpan);
@@ -28173,7 +29134,7 @@ function publishFacade(global) {
28173
29134
  const ng = global.ng || (global.ng = {});
28174
29135
  ng.\u0275compilerFacade = new CompilerFacadeImpl();
28175
29136
  }
28176
- var VERSION = new Version("17.0.0-next.4");
29137
+ var VERSION = new Version("17.0.0-next.6");
28177
29138
  var _VisitorMode;
28178
29139
  (function(_VisitorMode2) {
28179
29140
  _VisitorMode2[_VisitorMode2["Extract"] = 0] = "Extract";
@@ -30112,7 +31073,7 @@ ${[...componentsToMigrate].join("\n")}`);
30112
31073
  * found in the LICENSE file at https://angular.io/license
30113
31074
  */
30114
31075
  /**
30115
- * @license Angular v17.0.0-next.4
31076
+ * @license Angular v17.0.0-next.6
30116
31077
  * (c) 2010-2022 Google LLC. https://angular.io/
30117
31078
  * License: MIT
30118
31079
  */