{"version":3,"file":"compiler.mjs","sources":["../../../../../../packages/compiler/src/selector.ts","../../../../../../packages/compiler/src/core.ts","../../../../../../packages/compiler/src/i18n/digest.ts","../../../../../../packages/compiler/src/output/output_ast.ts","../../../../../../packages/compiler/src/constant_pool.ts","../../../../../../packages/compiler/src/render3/r3_identifiers.ts","../../../../../../packages/compiler/src/util.ts","../../../../../../packages/compiler/src/output/source_map.ts","../../../../../../packages/compiler/src/output/abstract_emitter.ts","../../../../../../packages/compiler/src/render3/util.ts","../../../../../../packages/compiler/src/render3/r3_factory.ts","../../../../../../packages/compiler/src/expression_parser/ast.ts","../../../../../../packages/compiler/src/ml_parser/tags.ts","../../../../../../packages/compiler/src/render3/r3_ast.ts","../../../../../../packages/compiler/src/i18n/i18n_ast.ts","../../../../../../packages/compiler/src/i18n/serializers/serializer.ts","../../../../../../packages/compiler/src/i18n/serializers/xml_helper.ts","../../../../../../packages/compiler/src/i18n/serializers/xmb.ts","../../../../../../packages/compiler/src/render3/view/i18n/util.ts","../../../../../../packages/compiler/src/render3/view/util.ts","../../../../../../packages/compiler/src/injectable_compiler_2.ts","../../../../../../packages/compiler/src/assertions.ts","../../../../../../packages/compiler/src/ml_parser/defaults.ts","../../../../../../packages/compiler/src/chars.ts","../../../../../../packages/compiler/src/parse_util.ts","../../../../../../packages/compiler/src/output/abstract_js_emitter.ts","../../../../../../packages/compiler/src/output/output_jit_trusted_types.ts","../../../../../../packages/compiler/src/output/output_jit.ts","../../../../../../packages/compiler/src/render3/r3_injector_compiler.ts","../../../../../../packages/compiler/src/render3/r3_jit.ts","../../../../../../packages/compiler/src/render3/r3_module_compiler.ts","../../../../../../packages/compiler/src/render3/r3_pipe_compiler.ts","../../../../../../packages/compiler/src/render3/view/api.ts","../../../../../../packages/compiler/src/shadow_css.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/enums.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/traits.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/ops/shared.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/ops/update.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/expression.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/operations.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/handle.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/ops/create.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/ops/host.ts","../../../../../../packages/compiler/src/template/pipeline/ir/src/variable.ts","../../../../../../packages/compiler/src/template/pipeline/src/compilation.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/any_cast.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/apply_i18n_expressions.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/assign_i18n_slot_dependencies.ts","../../../../../../packages/compiler/src/template/pipeline/src/util/elements.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/attribute_extraction.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/binding_specialization.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/chaining.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/collapse_singleton_interpolations.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/conditionals.ts","../../../../../../packages/compiler/src/template/pipeline/src/conversion.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/const_collection.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/convert_i18n_bindings.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_defer_deps_fns.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/create_i18n_contexts.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/deduplicate_text_bindings.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/defer_configs.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/defer_resolve_targets.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/empty_elements.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/expand_safe_reads.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/extract_i18n_messages.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/generate_advance.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/generate_projection_def.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/generate_variables.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/has_const_expression_collection.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/host_style_property_parsing.ts","../../../../../../packages/compiler/src/output/map_util.ts","../../../../../../packages/compiler/src/render3/view/i18n/icu_serializer.ts","../../../../../../packages/compiler/src/ml_parser/ast.ts","../../../../../../packages/compiler/src/ml_parser/entities.ts","../../../../../../packages/compiler/src/ml_parser/lexer.ts","../../../../../../packages/compiler/src/ml_parser/parser.ts","../../../../../../packages/compiler/src/ml_parser/html_whitespaces.ts","../../../../../../packages/compiler/src/expression_parser/lexer.ts","../../../../../../packages/compiler/src/expression_parser/parser.ts","../../../../../../packages/compiler/src/schema/dom_security_schema.ts","../../../../../../packages/compiler/src/schema/element_schema_registry.ts","../../../../../../packages/compiler/src/schema/dom_element_schema_registry.ts","../../../../../../packages/compiler/src/ml_parser/html_tags.ts","../../../../../../packages/compiler/src/i18n/serializers/placeholder.ts","../../../../../../packages/compiler/src/i18n/i18n_parser.ts","../../../../../../packages/compiler/src/i18n/parse_util.ts","../../../../../../packages/compiler/src/schema/trusted_types_sinks.ts","../../../../../../packages/compiler/src/render3/view/i18n/meta.ts","../../../../../../packages/compiler/src/render3/view/i18n/get_msg_utils.ts","../../../../../../packages/compiler/src/render3/view/i18n/localize_utils.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/i18n_text_extraction.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/local_refs.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/namespace.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/parse_extracted_styles.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/naming.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/next_context_merging.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/ng_container.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/nonbindable.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/nullish_coalescing.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/ordering.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/phase_remove_content_selectors.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/pipe_creation.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/pipe_variadic.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/propagate_i18n_blocks.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/pure_function_extraction.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/pure_literal_structures.ts","../../../../../../packages/compiler/src/template/pipeline/src/instruction.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/reify.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/remove_empty_bindings.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/remove_i18n_contexts.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/remove_unused_i18n_attrs.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_contexts.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_dollar_event.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_i18n_element_placeholders.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_i18n_expression_placeholders.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_names.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/resolve_sanitizers.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/transform_two_way_binding_set.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/save_restore_view.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/slot_allocation.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/style_binding_specialization.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/temporary_variables.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/track_fn_generation.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/track_fn_optimization.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/track_variables.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/var_counting.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/variable_optimization.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/wrap_icus.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/store_let_optimization.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/remove_illegal_let_references.ts","../../../../../../packages/compiler/src/template/pipeline/src/phases/generate_local_let_references.ts","../../../../../../packages/compiler/src/template/pipeline/src/emit.ts","../../../../../../packages/compiler/src/template/pipeline/src/ingest.ts","../../../../../../packages/compiler/src/render3/view/query_generation.ts","../../../../../../packages/compiler/src/ml_parser/html_parser.ts","../../../../../../packages/compiler/src/template_parser/binding_parser.ts","../../../../../../packages/compiler/src/style_url_resolver.ts","../../../../../../packages/compiler/src/template_parser/template_preparser.ts","../../../../../../packages/compiler/src/render3/r3_control_flow.ts","../../../../../../packages/compiler/src/render3/r3_deferred_triggers.ts","../../../../../../packages/compiler/src/render3/r3_deferred_blocks.ts","../../../../../../packages/compiler/src/render3/r3_template_transform.ts","../../../../../../packages/compiler/src/render3/view/template.ts","../../../../../../packages/compiler/src/render3/view/compiler.ts","../../../../../../packages/compiler/src/render3/view/t2_binder.ts","../../../../../../packages/compiler/src/resource_loader.ts","../../../../../../packages/compiler/src/jit_compiler_facade.ts","../../../../../../packages/compiler/src/version.ts","../../../../../../packages/compiler/src/config.ts","../../../../../../packages/compiler/src/i18n/extractor_merger.ts","../../../../../../packages/compiler/src/ml_parser/xml_tags.ts","../../../../../../packages/compiler/src/ml_parser/xml_parser.ts","../../../../../../packages/compiler/src/i18n/serializers/xliff.ts","../../../../../../packages/compiler/src/i18n/serializers/xliff2.ts","../../../../../../packages/compiler/src/i18n/serializers/xtb.ts","../../../../../../packages/compiler/src/i18n/translation_bundle.ts","../../../../../../packages/compiler/src/i18n/i18n_html_parser.ts","../../../../../../packages/compiler/src/i18n/message_bundle.ts","../../../../../../packages/compiler/src/render3/partial/api.ts","../../../../../../packages/compiler/src/render3/r3_class_metadata_compiler.ts","../../../../../../packages/compiler/src/render3/r3_class_debug_info_compiler.ts","../../../../../../packages/compiler/src/render3/partial/class_metadata.ts","../../../../../../packages/compiler/src/render3/partial/util.ts","../../../../../../packages/compiler/src/render3/partial/directive.ts","../../../../../../packages/compiler/src/render3/partial/component.ts","../../../../../../packages/compiler/src/render3/partial/factory.ts","../../../../../../packages/compiler/src/render3/partial/injectable.ts","../../../../../../packages/compiler/src/render3/partial/injector.ts","../../../../../../packages/compiler/src/render3/partial/ng_module.ts","../../../../../../packages/compiler/src/render3/partial/pipe.ts","../../../../../../packages/compiler/src/compiler.ts","../../../../../../packages/compiler/public_api.ts","../../../../../../packages/compiler/compiler.ts","../../../../../../packages/compiler/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nconst _SELECTOR_REGEXP = new RegExp(\n '(\\\\:not\\\\()|' + // 1: \":not(\"\n '(([\\\\.\\\\#]?)[-\\\\w]+)|' + // 2: \"tag\"; 3: \".\"/\"#\";\n // \"-\" should appear first in the regexp below as FF31 parses \"[.-\\w]\" as a range\n // 4: attribute; 5: attribute_string; 6: attribute_value\n '(?:\\\\[([-.\\\\w*\\\\\\\\$]+)(?:=([\"\\']?)([^\\\\]\"\\']*)\\\\5)?\\\\])|' + // \"[name]\", \"[name=value]\",\n // \"[name=\"value\"]\",\n // \"[name='value']\"\n '(\\\\))|' + // 7: \")\"\n '(\\\\s*,\\\\s*)', // 8: \",\"\n 'g',\n);\n\n/**\n * These offsets should match the match-groups in `_SELECTOR_REGEXP` offsets.\n */\nconst enum SelectorRegexp {\n ALL = 0, // The whole match\n NOT = 1,\n TAG = 2,\n PREFIX = 3,\n ATTRIBUTE = 4,\n ATTRIBUTE_STRING = 5,\n ATTRIBUTE_VALUE = 6,\n NOT_END = 7,\n SEPARATOR = 8,\n}\n/**\n * A css selector contains an element name,\n * css classes and attribute/value pairs with the purpose\n * of selecting subsets out of them.\n */\nexport class CssSelector {\n element: string | null = null;\n classNames: string[] = [];\n /**\n * The selectors are encoded in pairs where:\n * - even locations are attribute names\n * - odd locations are attribute values.\n *\n * Example:\n * Selector: `[key1=value1][key2]` would parse to:\n * ```\n * ['key1', 'value1', 'key2', '']\n * ```\n */\n attrs: string[] = [];\n notSelectors: CssSelector[] = [];\n\n static parse(selector: string): CssSelector[] {\n const results: CssSelector[] = [];\n const _addResult = (res: CssSelector[], cssSel: CssSelector) => {\n if (\n cssSel.notSelectors.length > 0 &&\n !cssSel.element &&\n cssSel.classNames.length == 0 &&\n cssSel.attrs.length == 0\n ) {\n cssSel.element = '*';\n }\n res.push(cssSel);\n };\n let cssSelector = new CssSelector();\n let match: string[] | null;\n let current = cssSelector;\n let inNot = false;\n _SELECTOR_REGEXP.lastIndex = 0;\n while ((match = _SELECTOR_REGEXP.exec(selector))) {\n if (match[SelectorRegexp.NOT]) {\n if (inNot) {\n throw new Error('Nesting :not in a selector is not allowed');\n }\n inNot = true;\n current = new CssSelector();\n cssSelector.notSelectors.push(current);\n }\n const tag = match[SelectorRegexp.TAG];\n if (tag) {\n const prefix = match[SelectorRegexp.PREFIX];\n if (prefix === '#') {\n // #hash\n current.addAttribute('id', tag.slice(1));\n } else if (prefix === '.') {\n // Class\n current.addClassName(tag.slice(1));\n } else {\n // Element\n current.setElement(tag);\n }\n }\n const attribute = match[SelectorRegexp.ATTRIBUTE];\n\n if (attribute) {\n current.addAttribute(\n current.unescapeAttribute(attribute),\n match[SelectorRegexp.ATTRIBUTE_VALUE],\n );\n }\n if (match[SelectorRegexp.NOT_END]) {\n inNot = false;\n current = cssSelector;\n }\n if (match[SelectorRegexp.SEPARATOR]) {\n if (inNot) {\n throw new Error('Multiple selectors in :not are not supported');\n }\n _addResult(results, cssSelector);\n cssSelector = current = new CssSelector();\n }\n }\n _addResult(results, cssSelector);\n return results;\n }\n\n /**\n * Unescape `\\$` sequences from the CSS attribute selector.\n *\n * This is needed because `$` can have a special meaning in CSS selectors,\n * but we might want to match an attribute that contains `$`.\n * [MDN web link for more\n * info](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors).\n * @param attr the attribute to unescape.\n * @returns the unescaped string.\n */\n unescapeAttribute(attr: string): string {\n let result = '';\n let escaping = false;\n for (let i = 0; i < attr.length; i++) {\n const char = attr.charAt(i);\n if (char === '\\\\') {\n escaping = true;\n continue;\n }\n if (char === '$' && !escaping) {\n throw new Error(\n `Error in attribute selector \"${attr}\". ` +\n `Unescaped \"$\" is not supported. Please escape with \"\\\\$\".`,\n );\n }\n escaping = false;\n result += char;\n }\n return result;\n }\n\n /**\n * Escape `$` sequences from the CSS attribute selector.\n *\n * This is needed because `$` can have a special meaning in CSS selectors,\n * with this method we are escaping `$` with `\\$'.\n * [MDN web link for more\n * info](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors).\n * @param attr the attribute to escape.\n * @returns the escaped string.\n */\n escapeAttribute(attr: string): string {\n return attr.replace(/\\\\/g, '\\\\\\\\').replace(/\\$/g, '\\\\$');\n }\n\n isElementSelector(): boolean {\n return (\n this.hasElementSelector() &&\n this.classNames.length == 0 &&\n this.attrs.length == 0 &&\n this.notSelectors.length === 0\n );\n }\n\n hasElementSelector(): boolean {\n return !!this.element;\n }\n\n setElement(element: string | null = null) {\n this.element = element;\n }\n\n getAttrs(): string[] {\n const result: string[] = [];\n if (this.classNames.length > 0) {\n result.push('class', this.classNames.join(' '));\n }\n return result.concat(this.attrs);\n }\n\n addAttribute(name: string, value: string = '') {\n this.attrs.push(name, (value && value.toLowerCase()) || '');\n }\n\n addClassName(name: string) {\n this.classNames.push(name.toLowerCase());\n }\n\n toString(): string {\n let res: string = this.element || '';\n if (this.classNames) {\n this.classNames.forEach((klass) => (res += `.${klass}`));\n }\n if (this.attrs) {\n for (let i = 0; i < this.attrs.length; i += 2) {\n const name = this.escapeAttribute(this.attrs[i]);\n const value = this.attrs[i + 1];\n res += `[${name}${value ? '=' + value : ''}]`;\n }\n }\n this.notSelectors.forEach((notSelector) => (res += `:not(${notSelector})`));\n return res;\n }\n}\n\n/**\n * Reads a list of CssSelectors and allows to calculate which ones\n * are contained in a given CssSelector.\n */\nexport class SelectorMatcher {\n static createNotMatcher(notSelectors: CssSelector[]): SelectorMatcher {\n const notMatcher = new SelectorMatcher();\n notMatcher.addSelectables(notSelectors, null);\n return notMatcher;\n }\n\n private _elementMap = new Map[]>();\n private _elementPartialMap = new Map>();\n private _classMap = new Map[]>();\n private _classPartialMap = new Map>();\n private _attrValueMap = new Map[]>>();\n private _attrValuePartialMap = new Map>>();\n private _listContexts: SelectorListContext[] = [];\n\n addSelectables(cssSelectors: CssSelector[], callbackCtxt?: T) {\n let listContext: SelectorListContext = null!;\n if (cssSelectors.length > 1) {\n listContext = new SelectorListContext(cssSelectors);\n this._listContexts.push(listContext);\n }\n for (let i = 0; i < cssSelectors.length; i++) {\n this._addSelectable(cssSelectors[i], callbackCtxt as T, listContext);\n }\n }\n\n /**\n * Add an object that can be found later on by calling `match`.\n * @param cssSelector A css selector\n * @param callbackCtxt An opaque object that will be given to the callback of the `match` function\n */\n private _addSelectable(\n cssSelector: CssSelector,\n callbackCtxt: T,\n listContext: SelectorListContext,\n ) {\n let matcher: SelectorMatcher = this;\n const element = cssSelector.element;\n const classNames = cssSelector.classNames;\n const attrs = cssSelector.attrs;\n const selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);\n\n if (element) {\n const isTerminal = attrs.length === 0 && classNames.length === 0;\n if (isTerminal) {\n this._addTerminal(matcher._elementMap, element, selectable);\n } else {\n matcher = this._addPartial(matcher._elementPartialMap, element);\n }\n }\n\n if (classNames) {\n for (let i = 0; i < classNames.length; i++) {\n const isTerminal = attrs.length === 0 && i === classNames.length - 1;\n const className = classNames[i];\n if (isTerminal) {\n this._addTerminal(matcher._classMap, className, selectable);\n } else {\n matcher = this._addPartial(matcher._classPartialMap, className);\n }\n }\n }\n\n if (attrs) {\n for (let i = 0; i < attrs.length; i += 2) {\n const isTerminal = i === attrs.length - 2;\n const name = attrs[i];\n const value = attrs[i + 1];\n if (isTerminal) {\n const terminalMap = matcher._attrValueMap;\n let terminalValuesMap = terminalMap.get(name);\n if (!terminalValuesMap) {\n terminalValuesMap = new Map[]>();\n terminalMap.set(name, terminalValuesMap);\n }\n this._addTerminal(terminalValuesMap, value, selectable);\n } else {\n const partialMap = matcher._attrValuePartialMap;\n let partialValuesMap = partialMap.get(name);\n if (!partialValuesMap) {\n partialValuesMap = new Map>();\n partialMap.set(name, partialValuesMap);\n }\n matcher = this._addPartial(partialValuesMap, value);\n }\n }\n }\n }\n\n private _addTerminal(\n map: Map[]>,\n name: string,\n selectable: SelectorContext,\n ) {\n let terminalList = map.get(name);\n if (!terminalList) {\n terminalList = [];\n map.set(name, terminalList);\n }\n terminalList.push(selectable);\n }\n\n private _addPartial(map: Map>, name: string): SelectorMatcher {\n let matcher = map.get(name);\n if (!matcher) {\n matcher = new SelectorMatcher();\n map.set(name, matcher);\n }\n return matcher;\n }\n\n /**\n * Find the objects that have been added via `addSelectable`\n * whose css selector is contained in the given css selector.\n * @param cssSelector A css selector\n * @param matchedCallback This callback will be called with the object handed into `addSelectable`\n * @return boolean true if a match was found\n */\n match(\n cssSelector: CssSelector,\n matchedCallback: ((c: CssSelector, a: T) => void) | null,\n ): boolean {\n let result = false;\n const element = cssSelector.element!;\n const classNames = cssSelector.classNames;\n const attrs = cssSelector.attrs;\n\n for (let i = 0; i < this._listContexts.length; i++) {\n this._listContexts[i].alreadyMatched = false;\n }\n\n result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;\n result =\n this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) || result;\n\n if (classNames) {\n for (let i = 0; i < classNames.length; i++) {\n const className = classNames[i];\n result =\n this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;\n result =\n this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||\n result;\n }\n }\n\n if (attrs) {\n for (let i = 0; i < attrs.length; i += 2) {\n const name = attrs[i];\n const value = attrs[i + 1];\n\n const terminalValuesMap = this._attrValueMap.get(name)!;\n if (value) {\n result =\n this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result;\n }\n result =\n this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;\n\n const partialValuesMap = this._attrValuePartialMap.get(name)!;\n if (value) {\n result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result;\n }\n result =\n this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;\n }\n }\n return result;\n }\n\n /** @internal */\n _matchTerminal(\n map: Map[]>,\n name: string,\n cssSelector: CssSelector,\n matchedCallback: ((c: CssSelector, a: any) => void) | null,\n ): boolean {\n if (!map || typeof name !== 'string') {\n return false;\n }\n\n let selectables: SelectorContext[] = map.get(name) || [];\n const starSelectables: SelectorContext[] = map.get('*')!;\n if (starSelectables) {\n selectables = selectables.concat(starSelectables);\n }\n if (selectables.length === 0) {\n return false;\n }\n let selectable: SelectorContext;\n let result = false;\n for (let i = 0; i < selectables.length; i++) {\n selectable = selectables[i];\n result = selectable.finalize(cssSelector, matchedCallback) || result;\n }\n return result;\n }\n\n /** @internal */\n _matchPartial(\n map: Map>,\n name: string,\n cssSelector: CssSelector,\n matchedCallback: ((c: CssSelector, a: any) => void) | null,\n ): boolean {\n if (!map || typeof name !== 'string') {\n return false;\n }\n\n const nestedSelector = map.get(name);\n if (!nestedSelector) {\n return false;\n }\n // TODO(perf): get rid of recursion and measure again\n // TODO(perf): don't pass the whole selector into the recursion,\n // but only the not processed parts\n return nestedSelector.match(cssSelector, matchedCallback);\n }\n}\n\nexport class SelectorListContext {\n alreadyMatched: boolean = false;\n\n constructor(public selectors: CssSelector[]) {}\n}\n\n// Store context to pass back selector and context when a selector is matched\nexport class SelectorContext {\n notSelectors: CssSelector[];\n\n constructor(\n public selector: CssSelector,\n public cbContext: T,\n public listContext: SelectorListContext,\n ) {\n this.notSelectors = selector.notSelectors;\n }\n\n finalize(cssSelector: CssSelector, callback: ((c: CssSelector, a: T) => void) | null): boolean {\n let result = true;\n if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) {\n const notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);\n result = !notMatcher.match(cssSelector, null);\n }\n if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) {\n if (this.listContext) {\n this.listContext.alreadyMatched = true;\n }\n callback(this.selector, this.cbContext);\n }\n return result;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// Attention:\n// This file duplicates types and values from @angular/core\n// so that we are able to make @angular/compiler independent of @angular/core.\n// This is important to prevent a build cycle, as @angular/core needs to\n// be compiled with the compiler.\n\nimport {CssSelector} from './selector';\n\n// Stores the default value of `emitDistinctChangesOnly` when the `emitDistinctChangesOnly` is not\n// explicitly set.\nexport const emitDistinctChangesOnlyDefaultValue = true;\n\nexport enum ViewEncapsulation {\n Emulated = 0,\n // Historically the 1 value was for `Native` encapsulation which has been removed as of v11.\n None = 2,\n ShadowDom = 3,\n}\n\nexport enum ChangeDetectionStrategy {\n OnPush = 0,\n Default = 1,\n}\n\nexport interface Input {\n alias?: string;\n required?: boolean;\n transform?: (value: any) => any;\n // Note: This field is marked as `internal` in `@angular/core`, but in the compiler\n // we rely on it for JIT processing at runtime.\n isSignal: boolean;\n}\n\n/** Flags describing an input for a directive. */\nexport enum InputFlags {\n None = 0,\n SignalBased = 1 << 0,\n HasDecoratorInputTransform = 1 << 1,\n}\n\nexport interface Output {\n alias?: string;\n}\n\nexport interface HostBinding {\n hostPropertyName?: string;\n}\n\nexport interface HostListener {\n eventName?: string;\n args?: string[];\n}\n\nexport interface SchemaMetadata {\n name: string;\n}\n\nexport const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata = {\n name: 'custom-elements',\n};\n\nexport const NO_ERRORS_SCHEMA: SchemaMetadata = {\n name: 'no-errors-schema',\n};\n\nexport interface Type extends Function {\n new (...args: any[]): any;\n}\nexport const Type = Function;\n\nexport enum SecurityContext {\n NONE = 0,\n HTML = 1,\n STYLE = 2,\n SCRIPT = 3,\n URL = 4,\n RESOURCE_URL = 5,\n}\n\n/**\n * Injection flags for DI.\n */\nexport const enum InjectFlags {\n Default = 0,\n\n /**\n * Specifies that an injector should retrieve a dependency from any injector until reaching the\n * host element of the current component. (Only used with Element Injector)\n */\n Host = 1 << 0,\n /** Don't descend into ancestors of the node requesting injection. */\n Self = 1 << 1,\n /** Skip the node that is requesting injection. */\n SkipSelf = 1 << 2,\n /** Inject `defaultValue` instead if token not found. */\n Optional = 1 << 3,\n /**\n * This token is being injected into a pipe.\n * @internal\n */\n ForPipe = 1 << 4,\n}\n\nexport enum MissingTranslationStrategy {\n Error = 0,\n Warning = 1,\n Ignore = 2,\n}\n\n/**\n * Flags used to generate R3-style CSS Selectors. They are pasted from\n * core/src/render3/projection.ts because they cannot be referenced directly.\n */\nexport const enum SelectorFlags {\n /** Indicates this is the beginning of a new negative selector */\n NOT = 0b0001,\n\n /** Mode for matching attributes */\n ATTRIBUTE = 0b0010,\n\n /** Mode for matching tag names */\n ELEMENT = 0b0100,\n\n /** Mode for matching class names */\n CLASS = 0b1000,\n}\n\n// These are a copy the CSS types from core/src/render3/interfaces/projection.ts\n// They are duplicated here as they cannot be directly referenced from core.\nexport type R3CssSelector = (string | SelectorFlags)[];\nexport type R3CssSelectorList = R3CssSelector[];\n\nfunction parserSelectorToSimpleSelector(selector: CssSelector): R3CssSelector {\n const classes =\n selector.classNames && selector.classNames.length\n ? [SelectorFlags.CLASS, ...selector.classNames]\n : [];\n const elementName = selector.element && selector.element !== '*' ? selector.element : '';\n return [elementName, ...selector.attrs, ...classes];\n}\n\nfunction parserSelectorToNegativeSelector(selector: CssSelector): R3CssSelector {\n const classes =\n selector.classNames && selector.classNames.length\n ? [SelectorFlags.CLASS, ...selector.classNames]\n : [];\n\n if (selector.element) {\n return [\n SelectorFlags.NOT | SelectorFlags.ELEMENT,\n selector.element,\n ...selector.attrs,\n ...classes,\n ];\n } else if (selector.attrs.length) {\n return [SelectorFlags.NOT | SelectorFlags.ATTRIBUTE, ...selector.attrs, ...classes];\n } else {\n return selector.classNames && selector.classNames.length\n ? [SelectorFlags.NOT | SelectorFlags.CLASS, ...selector.classNames]\n : [];\n }\n}\n\nfunction parserSelectorToR3Selector(selector: CssSelector): R3CssSelector {\n const positive = parserSelectorToSimpleSelector(selector);\n\n const negative: R3CssSelectorList =\n selector.notSelectors && selector.notSelectors.length\n ? selector.notSelectors.map((notSelector) => parserSelectorToNegativeSelector(notSelector))\n : [];\n\n return positive.concat(...negative);\n}\n\nexport function parseSelectorToR3Selector(selector: string | null): R3CssSelectorList {\n return selector ? CssSelector.parse(selector).map(parserSelectorToR3Selector) : [];\n}\n\n// Pasted from render3/interfaces/definition since it cannot be referenced directly\n/**\n * Flags passed into template functions to determine which blocks (i.e. creation, update)\n * should be executed.\n *\n * Typically, a template runs both the creation block and the update block on initialization and\n * subsequent runs only execute the update block. However, dynamically created views require that\n * the creation block be executed separately from the update block (for backwards compat).\n */\nexport const enum RenderFlags {\n /* Whether to run the creation block (e.g. create elements and directives) */\n Create = 0b01,\n\n /* Whether to run the update block (e.g. refresh bindings) */\n Update = 0b10,\n}\n\n// Pasted from render3/interfaces/node.ts\n/**\n * A set of marker values to be used in the attributes arrays. These markers indicate that some\n * items are not regular attributes and the processing should be adapted accordingly.\n */\nexport const enum AttributeMarker {\n /**\n * Marker indicates that the following 3 values in the attributes array are:\n * namespaceUri, attributeName, attributeValue\n * in that order.\n */\n NamespaceURI = 0,\n\n /**\n * Signals class declaration.\n *\n * Each value following `Classes` designates a class name to include on the element.\n * ## Example:\n *\n * Given:\n * ```\n *
...\n * ```\n *\n * the generated code is:\n * ```\n * var _c1 = [AttributeMarker.Classes, 'foo', 'bar', 'baz'];\n * ```\n */\n Classes = 1,\n\n /**\n * Signals style declaration.\n *\n * Each pair of values following `Styles` designates a style name and value to include on the\n * element.\n * ## Example:\n *\n * Given:\n * ```\n *
...
\n * ```\n *\n * the generated code is:\n * ```\n * var _c1 = [AttributeMarker.Styles, 'width', '100px', 'height'. '200px', 'color', 'red'];\n * ```\n */\n Styles = 2,\n\n /**\n * Signals that the following attribute names were extracted from input or output bindings.\n *\n * For example, given the following HTML:\n *\n * ```\n *
\n * ```\n *\n * the generated code is:\n *\n * ```\n * var _c1 = ['moo', 'car', AttributeMarker.Bindings, 'foo', 'bar'];\n * ```\n */\n Bindings = 3,\n\n /**\n * Signals that the following attribute names were hoisted from an inline-template declaration.\n *\n * For example, given the following HTML:\n *\n * ```\n *
\n * ```\n *\n * the generated code for the `template()` instruction would include:\n *\n * ```\n * ['dirA', '', AttributeMarker.Bindings, 'dirB', AttributeMarker.Template, 'ngFor', 'ngForOf',\n * 'ngForTrackBy', 'let-value']\n * ```\n *\n * while the generated code for the `element()` instruction inside the template function would\n * include:\n *\n * ```\n * ['dirA', '', AttributeMarker.Bindings, 'dirB']\n * ```\n */\n Template = 4,\n\n /**\n * Signals that the following attribute is `ngProjectAs` and its value is a parsed `CssSelector`.\n *\n * For example, given the following HTML:\n *\n * ```\n *

\n * ```\n *\n * the generated code for the `element()` instruction would include:\n *\n * ```\n * ['attr', 'value', AttributeMarker.ProjectAs, ['', 'title', '']]\n * ```\n */\n ProjectAs = 5,\n\n /**\n * Signals that the following attribute will be translated by runtime i18n\n *\n * For example, given the following HTML:\n *\n * ```\n *
\n * ```\n *\n * the generated code is:\n *\n * ```\n * var _c1 = ['moo', 'car', AttributeMarker.I18n, 'foo', 'bar'];\n */\n I18n = 6,\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Byte} from '../util';\n\nimport * as i18n from './i18n_ast';\n\n/**\n * A lazily created TextEncoder instance for converting strings into UTF-8 bytes\n */\nlet textEncoder: TextEncoder | undefined;\n\n/**\n * Return the message id or compute it using the XLIFF1 digest.\n */\nexport function digest(message: i18n.Message): string {\n return message.id || computeDigest(message);\n}\n\n/**\n * Compute the message id using the XLIFF1 digest.\n */\nexport function computeDigest(message: i18n.Message): string {\n return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);\n}\n\n/**\n * Return the message id or compute it using the XLIFF2/XMB/$localize digest.\n */\nexport function decimalDigest(message: i18n.Message, preservePlaceholders: boolean): string {\n return message.id || computeDecimalDigest(message, preservePlaceholders);\n}\n\n/**\n * Compute the message id using the XLIFF2/XMB/$localize digest.\n */\nexport function computeDecimalDigest(message: i18n.Message, preservePlaceholders: boolean): string {\n const visitor = new _SerializerIgnoreExpVisitor(preservePlaceholders);\n const parts = message.nodes.map((a) => a.visit(visitor, null));\n return computeMsgId(parts.join(''), message.meaning);\n}\n\n/**\n * Serialize the i18n ast to something xml-like in order to generate an UID.\n *\n * The visitor is also used in the i18n parser tests\n *\n * @internal\n */\nclass _SerializerVisitor implements i18n.Visitor {\n visitText(text: i18n.Text, context: any): any {\n return text.value;\n }\n\n visitContainer(container: i18n.Container, context: any): any {\n return `[${container.children.map((child) => child.visit(this)).join(', ')}]`;\n }\n\n visitIcu(icu: i18n.Icu, context: any): any {\n const strCases = Object.keys(icu.cases).map(\n (k: string) => `${k} {${icu.cases[k].visit(this)}}`,\n );\n return `{${icu.expression}, ${icu.type}, ${strCases.join(', ')}}`;\n }\n\n visitTagPlaceholder(ph: i18n.TagPlaceholder, context: any): any {\n return ph.isVoid\n ? ``\n : `${ph.children\n .map((child) => child.visit(this))\n .join(', ')}`;\n }\n\n visitPlaceholder(ph: i18n.Placeholder, context: any): any {\n return ph.value ? `${ph.value}` : ``;\n }\n\n visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any {\n return `${ph.value.visit(this)}`;\n }\n\n visitBlockPlaceholder(ph: i18n.BlockPlaceholder, context: any): any {\n return `${ph.children\n .map((child) => child.visit(this))\n .join(', ')}`;\n }\n}\n\nconst serializerVisitor = new _SerializerVisitor();\n\nexport function serializeNodes(nodes: i18n.Node[]): string[] {\n return nodes.map((a) => a.visit(serializerVisitor, null));\n}\n\n/**\n * Serialize the i18n ast to something xml-like in order to generate an UID.\n *\n * Ignore the expressions so that message IDs stays identical if only the expression changes.\n *\n * @internal\n */\nclass _SerializerIgnoreExpVisitor extends _SerializerVisitor {\n constructor(private readonly preservePlaceholders: boolean) {\n super();\n }\n\n override visitPlaceholder(ph: i18n.Placeholder, context: any): string {\n // Do not take the expression into account when `preservePlaceholders` is disabled.\n return this.preservePlaceholders\n ? super.visitPlaceholder(ph, context)\n : ``;\n }\n\n override visitIcu(icu: i18n.Icu): string {\n let strCases = Object.keys(icu.cases).map((k: string) => `${k} {${icu.cases[k].visit(this)}}`);\n // Do not take the expression into account\n return `{${icu.type}, ${strCases.join(', ')}}`;\n }\n}\n\n/**\n * Compute the SHA1 of the given string\n *\n * see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf\n *\n * WARNING: this function has not been designed not tested with security in mind.\n * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.\n */\nexport function sha1(str: string): string {\n textEncoder ??= new TextEncoder();\n const utf8 = [...textEncoder.encode(str)];\n const words32 = bytesToWords32(utf8, Endian.Big);\n const len = utf8.length * 8;\n\n const w = new Uint32Array(80);\n let a = 0x67452301,\n b = 0xefcdab89,\n c = 0x98badcfe,\n d = 0x10325476,\n e = 0xc3d2e1f0;\n\n words32[len >> 5] |= 0x80 << (24 - (len % 32));\n words32[(((len + 64) >> 9) << 4) + 15] = len;\n\n for (let i = 0; i < words32.length; i += 16) {\n const h0 = a,\n h1 = b,\n h2 = c,\n h3 = d,\n h4 = e;\n\n for (let j = 0; j < 80; j++) {\n if (j < 16) {\n w[j] = words32[i + j];\n } else {\n w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);\n }\n\n const fkVal = fk(j, b, c, d);\n const f = fkVal[0];\n const k = fkVal[1];\n const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);\n e = d;\n d = c;\n c = rol32(b, 30);\n b = a;\n a = temp;\n }\n a = add32(a, h0);\n b = add32(b, h1);\n c = add32(c, h2);\n d = add32(d, h3);\n e = add32(e, h4);\n }\n\n // Convert the output parts to a 160-bit hexadecimal string\n return toHexU32(a) + toHexU32(b) + toHexU32(c) + toHexU32(d) + toHexU32(e);\n}\n\n/**\n * Convert and format a number as a string representing a 32-bit unsigned hexadecimal number.\n * @param value The value to format as a string.\n * @returns A hexadecimal string representing the value.\n */\nfunction toHexU32(value: number): string {\n // unsigned right shift of zero ensures an unsigned 32-bit number\n return (value >>> 0).toString(16).padStart(8, '0');\n}\n\nfunction fk(index: number, b: number, c: number, d: number): [number, number] {\n if (index < 20) {\n return [(b & c) | (~b & d), 0x5a827999];\n }\n\n if (index < 40) {\n return [b ^ c ^ d, 0x6ed9eba1];\n }\n\n if (index < 60) {\n return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];\n }\n\n return [b ^ c ^ d, 0xca62c1d6];\n}\n\n/**\n * Compute the fingerprint of the given string\n *\n * The output is 64 bit number encoded as a decimal string\n *\n * based on:\n * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java\n */\nexport function fingerprint(str: string): bigint {\n textEncoder ??= new TextEncoder();\n const utf8 = textEncoder.encode(str);\n const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);\n\n let hi = hash32(view, utf8.length, 0);\n let lo = hash32(view, utf8.length, 102072);\n\n if (hi == 0 && (lo == 0 || lo == 1)) {\n hi = hi ^ 0x130f9bef;\n lo = lo ^ -0x6b5f56d8;\n }\n\n return (BigInt.asUintN(32, BigInt(hi)) << BigInt(32)) | BigInt.asUintN(32, BigInt(lo));\n}\n\nexport function computeMsgId(msg: string, meaning: string = ''): string {\n let msgFingerprint = fingerprint(msg);\n\n if (meaning) {\n // Rotate the 64-bit message fingerprint one bit to the left and then add the meaning\n // fingerprint.\n msgFingerprint =\n BigInt.asUintN(64, msgFingerprint << BigInt(1)) |\n ((msgFingerprint >> BigInt(63)) & BigInt(1));\n msgFingerprint += fingerprint(meaning);\n }\n\n return BigInt.asUintN(63, msgFingerprint).toString();\n}\n\nfunction hash32(view: DataView, length: number, c: number): number {\n let a = 0x9e3779b9,\n b = 0x9e3779b9;\n let index = 0;\n\n const end = length - 12;\n for (; index <= end; index += 12) {\n a += view.getUint32(index, true);\n b += view.getUint32(index + 4, true);\n c += view.getUint32(index + 8, true);\n const res = mix(a, b, c);\n (a = res[0]), (b = res[1]), (c = res[2]);\n }\n\n const remainder = length - index;\n\n // the first byte of c is reserved for the length\n c += length;\n\n if (remainder >= 4) {\n a += view.getUint32(index, true);\n index += 4;\n\n if (remainder >= 8) {\n b += view.getUint32(index, true);\n index += 4;\n\n // Partial 32-bit word for c\n if (remainder >= 9) {\n c += view.getUint8(index++) << 8;\n }\n if (remainder >= 10) {\n c += view.getUint8(index++) << 16;\n }\n if (remainder === 11) {\n c += view.getUint8(index++) << 24;\n }\n } else {\n // Partial 32-bit word for b\n if (remainder >= 5) {\n b += view.getUint8(index++);\n }\n if (remainder >= 6) {\n b += view.getUint8(index++) << 8;\n }\n if (remainder === 7) {\n b += view.getUint8(index++) << 16;\n }\n }\n } else {\n // Partial 32-bit word for a\n if (remainder >= 1) {\n a += view.getUint8(index++);\n }\n if (remainder >= 2) {\n a += view.getUint8(index++) << 8;\n }\n if (remainder === 3) {\n a += view.getUint8(index++) << 16;\n }\n }\n\n return mix(a, b, c)[2];\n}\n\nfunction mix(a: number, b: number, c: number): [number, number, number] {\n a -= b;\n a -= c;\n a ^= c >>> 13;\n b -= c;\n b -= a;\n b ^= a << 8;\n c -= a;\n c -= b;\n c ^= b >>> 13;\n a -= b;\n a -= c;\n a ^= c >>> 12;\n b -= c;\n b -= a;\n b ^= a << 16;\n c -= a;\n c -= b;\n c ^= b >>> 5;\n a -= b;\n a -= c;\n a ^= c >>> 3;\n b -= c;\n b -= a;\n b ^= a << 10;\n c -= a;\n c -= b;\n c ^= b >>> 15;\n return [a, b, c];\n}\n\n// Utils\n\nenum Endian {\n Little,\n Big,\n}\n\nfunction add32(a: number, b: number): number {\n return add32to64(a, b)[1];\n}\n\nfunction add32to64(a: number, b: number): [number, number] {\n const low = (a & 0xffff) + (b & 0xffff);\n const high = (a >>> 16) + (b >>> 16) + (low >>> 16);\n return [high >>> 16, (high << 16) | (low & 0xffff)];\n}\n\n// Rotate a 32b number left `count` position\nfunction rol32(a: number, count: number): number {\n return (a << count) | (a >>> (32 - count));\n}\n\nfunction bytesToWords32(bytes: Byte[], endian: Endian): number[] {\n const size = (bytes.length + 3) >>> 2;\n const words32 = [];\n\n for (let i = 0; i < size; i++) {\n words32[i] = wordAt(bytes, i * 4, endian);\n }\n\n return words32;\n}\n\nfunction byteAt(bytes: Byte[], index: number): Byte {\n return index >= bytes.length ? 0 : bytes[index];\n}\n\nfunction wordAt(bytes: Byte[], index: number, endian: Endian): number {\n let word = 0;\n if (endian === Endian.Big) {\n for (let i = 0; i < 4; i++) {\n word += byteAt(bytes, index + i) << (24 - 8 * i);\n }\n } else {\n for (let i = 0; i < 4; i++) {\n word += byteAt(bytes, index + i) << (8 * i);\n }\n }\n return word;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computeMsgId} from '../i18n/digest';\nimport {Message} from '../i18n/i18n_ast';\nimport {ParseSourceSpan} from '../parse_util';\nimport {I18nMeta} from '../render3/view/i18n/meta';\n\n//// Types\nexport enum TypeModifier {\n None = 0,\n Const = 1 << 0,\n}\n\nexport abstract class Type {\n constructor(public modifiers: TypeModifier = TypeModifier.None) {}\n abstract visitType(visitor: TypeVisitor, context: any): any;\n\n hasModifier(modifier: TypeModifier): boolean {\n return (this.modifiers & modifier) !== 0;\n }\n}\n\nexport enum BuiltinTypeName {\n Dynamic,\n Bool,\n String,\n Int,\n Number,\n Function,\n Inferred,\n None,\n}\n\nexport class BuiltinType extends Type {\n constructor(\n public name: BuiltinTypeName,\n modifiers?: TypeModifier,\n ) {\n super(modifiers);\n }\n override visitType(visitor: TypeVisitor, context: any): any {\n return visitor.visitBuiltinType(this, context);\n }\n}\n\nexport class ExpressionType extends Type {\n constructor(\n public value: Expression,\n modifiers?: TypeModifier,\n public typeParams: Type[] | null = null,\n ) {\n super(modifiers);\n }\n override visitType(visitor: TypeVisitor, context: any): any {\n return visitor.visitExpressionType(this, context);\n }\n}\n\nexport class ArrayType extends Type {\n constructor(\n public of: Type,\n modifiers?: TypeModifier,\n ) {\n super(modifiers);\n }\n override visitType(visitor: TypeVisitor, context: any): any {\n return visitor.visitArrayType(this, context);\n }\n}\n\nexport class MapType extends Type {\n public valueType: Type | null;\n constructor(valueType: Type | null | undefined, modifiers?: TypeModifier) {\n super(modifiers);\n this.valueType = valueType || null;\n }\n override visitType(visitor: TypeVisitor, context: any): any {\n return visitor.visitMapType(this, context);\n }\n}\n\nexport class TransplantedType extends Type {\n constructor(\n readonly type: T,\n modifiers?: TypeModifier,\n ) {\n super(modifiers);\n }\n override visitType(visitor: TypeVisitor, context: any): any {\n return visitor.visitTransplantedType(this, context);\n }\n}\n\nexport const DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic);\nexport const INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);\nexport const BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool);\nexport const INT_TYPE = new BuiltinType(BuiltinTypeName.Int);\nexport const NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number);\nexport const STRING_TYPE = new BuiltinType(BuiltinTypeName.String);\nexport const FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function);\nexport const NONE_TYPE = new BuiltinType(BuiltinTypeName.None);\n\nexport interface TypeVisitor {\n visitBuiltinType(type: BuiltinType, context: any): any;\n visitExpressionType(type: ExpressionType, context: any): any;\n visitArrayType(type: ArrayType, context: any): any;\n visitMapType(type: MapType, context: any): any;\n visitTransplantedType(type: TransplantedType, context: any): any;\n}\n\n///// Expressions\n\nexport enum UnaryOperator {\n Minus,\n Plus,\n}\n\nexport enum BinaryOperator {\n Equals,\n NotEquals,\n Identical,\n NotIdentical,\n Minus,\n Plus,\n Divide,\n Multiply,\n Modulo,\n And,\n Or,\n BitwiseOr,\n BitwiseAnd,\n Lower,\n LowerEquals,\n Bigger,\n BiggerEquals,\n NullishCoalesce,\n}\n\nexport function nullSafeIsEquivalent(\n base: T | null,\n other: T | null,\n) {\n if (base == null || other == null) {\n return base == other;\n }\n return base.isEquivalent(other);\n}\n\nfunction areAllEquivalentPredicate(\n base: T[],\n other: T[],\n equivalentPredicate: (baseElement: T, otherElement: T) => boolean,\n) {\n const len = base.length;\n if (len !== other.length) {\n return false;\n }\n for (let i = 0; i < len; i++) {\n if (!equivalentPredicate(base[i], other[i])) {\n return false;\n }\n }\n return true;\n}\n\nexport function areAllEquivalent(\n base: T[],\n other: T[],\n) {\n return areAllEquivalentPredicate(base, other, (baseElement: T, otherElement: T) =>\n baseElement.isEquivalent(otherElement),\n );\n}\n\nexport abstract class Expression {\n public type: Type | null;\n public sourceSpan: ParseSourceSpan | null;\n\n constructor(type: Type | null | undefined, sourceSpan?: ParseSourceSpan | null) {\n this.type = type || null;\n this.sourceSpan = sourceSpan || null;\n }\n\n abstract visitExpression(visitor: ExpressionVisitor, context: any): any;\n\n /**\n * Calculates whether this expression produces the same value as the given expression.\n * Note: We don't check Types nor ParseSourceSpans nor function arguments.\n */\n abstract isEquivalent(e: Expression): boolean;\n\n /**\n * Return true if the expression is constant.\n */\n abstract isConstant(): boolean;\n\n abstract clone(): Expression;\n\n prop(name: string, sourceSpan?: ParseSourceSpan | null): ReadPropExpr {\n return new ReadPropExpr(this, name, null, sourceSpan);\n }\n\n key(index: Expression, type?: Type | null, sourceSpan?: ParseSourceSpan | null): ReadKeyExpr {\n return new ReadKeyExpr(this, index, type, sourceSpan);\n }\n\n callFn(\n params: Expression[],\n sourceSpan?: ParseSourceSpan | null,\n pure?: boolean,\n ): InvokeFunctionExpr {\n return new InvokeFunctionExpr(this, params, null, sourceSpan, pure);\n }\n\n instantiate(\n params: Expression[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ): InstantiateExpr {\n return new InstantiateExpr(this, params, type, sourceSpan);\n }\n\n conditional(\n trueCase: Expression,\n falseCase: Expression | null = null,\n sourceSpan?: ParseSourceSpan | null,\n ): ConditionalExpr {\n return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan);\n }\n\n equals(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan);\n }\n notEquals(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan);\n }\n identical(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan);\n }\n notIdentical(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan);\n }\n minus(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan);\n }\n plus(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan);\n }\n divide(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan);\n }\n multiply(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan);\n }\n modulo(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);\n }\n and(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);\n }\n bitwiseOr(\n rhs: Expression,\n sourceSpan?: ParseSourceSpan | null,\n parens: boolean = true,\n ): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan, parens);\n }\n bitwiseAnd(\n rhs: Expression,\n sourceSpan?: ParseSourceSpan | null,\n parens: boolean = true,\n ): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan, parens);\n }\n or(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);\n }\n lower(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan);\n }\n lowerEquals(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan);\n }\n bigger(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan);\n }\n biggerEquals(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan);\n }\n isBlank(sourceSpan?: ParseSourceSpan | null): Expression {\n // Note: We use equals by purpose here to compare to null and undefined in JS.\n // We use the typed null to allow strictNullChecks to narrow types.\n return this.equals(TYPED_NULL_EXPR, sourceSpan);\n }\n nullishCoalesce(rhs: Expression, sourceSpan?: ParseSourceSpan | null): BinaryOperatorExpr {\n return new BinaryOperatorExpr(BinaryOperator.NullishCoalesce, this, rhs, null, sourceSpan);\n }\n\n toStmt(): Statement {\n return new ExpressionStatement(this, null);\n }\n}\n\nexport class ReadVarExpr extends Expression {\n constructor(\n public name: string,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof ReadVarExpr && this.name === e.name;\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitReadVarExpr(this, context);\n }\n\n override clone(): ReadVarExpr {\n return new ReadVarExpr(this.name, this.type, this.sourceSpan);\n }\n\n set(value: Expression): WriteVarExpr {\n return new WriteVarExpr(this.name, value, null, this.sourceSpan);\n }\n}\n\nexport class TypeofExpr extends Expression {\n constructor(\n public expr: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any) {\n return visitor.visitTypeofExpr(this, context);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof TypeofExpr && e.expr.isEquivalent(this.expr);\n }\n\n override isConstant(): boolean {\n return this.expr.isConstant();\n }\n\n override clone(): TypeofExpr {\n return new TypeofExpr(this.expr.clone());\n }\n}\n\nexport class WrappedNodeExpr extends Expression {\n constructor(\n public node: T,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof WrappedNodeExpr && this.node === e.node;\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitWrappedNodeExpr(this, context);\n }\n\n override clone(): WrappedNodeExpr {\n return new WrappedNodeExpr(this.node, this.type, this.sourceSpan);\n }\n}\n\nexport class WriteVarExpr extends Expression {\n public value: Expression;\n constructor(\n public name: string,\n value: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type || value.type, sourceSpan);\n this.value = value;\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value);\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitWriteVarExpr(this, context);\n }\n\n override clone(): WriteVarExpr {\n return new WriteVarExpr(this.name, this.value.clone(), this.type, this.sourceSpan);\n }\n\n toDeclStmt(type?: Type | null, modifiers?: StmtModifier): DeclareVarStmt {\n return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);\n }\n\n toConstDecl(): DeclareVarStmt {\n return this.toDeclStmt(INFERRED_TYPE, StmtModifier.Final);\n }\n}\n\nexport class WriteKeyExpr extends Expression {\n public value: Expression;\n constructor(\n public receiver: Expression,\n public index: Expression,\n value: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type || value.type, sourceSpan);\n this.value = value;\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof WriteKeyExpr &&\n this.receiver.isEquivalent(e.receiver) &&\n this.index.isEquivalent(e.index) &&\n this.value.isEquivalent(e.value)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitWriteKeyExpr(this, context);\n }\n\n override clone(): WriteKeyExpr {\n return new WriteKeyExpr(\n this.receiver.clone(),\n this.index.clone(),\n this.value.clone(),\n this.type,\n this.sourceSpan,\n );\n }\n}\n\nexport class WritePropExpr extends Expression {\n public value: Expression;\n constructor(\n public receiver: Expression,\n public name: string,\n value: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type || value.type, sourceSpan);\n this.value = value;\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof WritePropExpr &&\n this.receiver.isEquivalent(e.receiver) &&\n this.name === e.name &&\n this.value.isEquivalent(e.value)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitWritePropExpr(this, context);\n }\n\n override clone(): WritePropExpr {\n return new WritePropExpr(\n this.receiver.clone(),\n this.name,\n this.value.clone(),\n this.type,\n this.sourceSpan,\n );\n }\n}\n\nexport class InvokeFunctionExpr extends Expression {\n constructor(\n public fn: Expression,\n public args: Expression[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n public pure = false,\n ) {\n super(type, sourceSpan);\n }\n\n // An alias for fn, which allows other logic to handle calls and property reads together.\n get receiver(): Expression {\n return this.fn;\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof InvokeFunctionExpr &&\n this.fn.isEquivalent(e.fn) &&\n areAllEquivalent(this.args, e.args) &&\n this.pure === e.pure\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitInvokeFunctionExpr(this, context);\n }\n\n override clone(): InvokeFunctionExpr {\n return new InvokeFunctionExpr(\n this.fn.clone(),\n this.args.map((arg) => arg.clone()),\n this.type,\n this.sourceSpan,\n this.pure,\n );\n }\n}\n\nexport class TaggedTemplateExpr extends Expression {\n constructor(\n public tag: Expression,\n public template: TemplateLiteral,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof TaggedTemplateExpr &&\n this.tag.isEquivalent(e.tag) &&\n areAllEquivalentPredicate(\n this.template.elements,\n e.template.elements,\n (a, b) => a.text === b.text,\n ) &&\n areAllEquivalent(this.template.expressions, e.template.expressions)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitTaggedTemplateExpr(this, context);\n }\n\n override clone(): TaggedTemplateExpr {\n return new TaggedTemplateExpr(\n this.tag.clone(),\n this.template.clone(),\n this.type,\n this.sourceSpan,\n );\n }\n}\n\nexport class InstantiateExpr extends Expression {\n constructor(\n public classExpr: Expression,\n public args: Expression[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof InstantiateExpr &&\n this.classExpr.isEquivalent(e.classExpr) &&\n areAllEquivalent(this.args, e.args)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitInstantiateExpr(this, context);\n }\n\n override clone(): InstantiateExpr {\n return new InstantiateExpr(\n this.classExpr.clone(),\n this.args.map((arg) => arg.clone()),\n this.type,\n this.sourceSpan,\n );\n }\n}\n\nexport class LiteralExpr extends Expression {\n constructor(\n public value: number | string | boolean | null | undefined,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof LiteralExpr && this.value === e.value;\n }\n\n override isConstant() {\n return true;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitLiteralExpr(this, context);\n }\n\n override clone(): LiteralExpr {\n return new LiteralExpr(this.value, this.type, this.sourceSpan);\n }\n}\n\nexport class TemplateLiteral {\n constructor(\n public elements: TemplateLiteralElement[],\n public expressions: Expression[],\n ) {}\n\n clone(): TemplateLiteral {\n return new TemplateLiteral(\n this.elements.map((el) => el.clone()),\n this.expressions.map((expr) => expr.clone()),\n );\n }\n}\nexport class TemplateLiteralElement {\n rawText: string;\n constructor(\n public text: string,\n public sourceSpan?: ParseSourceSpan,\n rawText?: string,\n ) {\n // If `rawText` is not provided, try to extract the raw string from its\n // associated `sourceSpan`. If that is also not available, \"fake\" the raw\n // string instead by escaping the following control sequences:\n // - \"\\\" would otherwise indicate that the next character is a control character.\n // - \"`\" and \"${\" are template string control sequences that would otherwise prematurely\n // indicate the end of the template literal element.\n this.rawText =\n rawText ?? sourceSpan?.toString() ?? escapeForTemplateLiteral(escapeSlashes(text));\n }\n\n clone(): TemplateLiteralElement {\n return new TemplateLiteralElement(this.text, this.sourceSpan, this.rawText);\n }\n}\n\nexport class LiteralPiece {\n constructor(\n public text: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n}\nexport class PlaceholderPiece {\n /**\n * Create a new instance of a `PlaceholderPiece`.\n *\n * @param text the name of this placeholder (e.g. `PH_1`).\n * @param sourceSpan the location of this placeholder in its localized message the source code.\n * @param associatedMessage reference to another message that this placeholder is associated with.\n * The `associatedMessage` is mainly used to provide a relationship to an ICU message that has\n * been extracted out from the message containing the placeholder.\n */\n constructor(\n public text: string,\n public sourceSpan: ParseSourceSpan,\n public associatedMessage?: Message,\n ) {}\n}\n\nexport type MessagePiece = LiteralPiece | PlaceholderPiece;\n\nconst MEANING_SEPARATOR = '|';\nconst ID_SEPARATOR = '@@';\nconst LEGACY_ID_INDICATOR = '␟';\n\nexport class LocalizedString extends Expression {\n constructor(\n readonly metaBlock: I18nMeta,\n readonly messageParts: LiteralPiece[],\n readonly placeHolderNames: PlaceholderPiece[],\n readonly expressions: Expression[],\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(STRING_TYPE, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n // return e instanceof LocalizedString && this.message === e.message;\n return false;\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitLocalizedString(this, context);\n }\n\n override clone(): LocalizedString {\n return new LocalizedString(\n this.metaBlock,\n this.messageParts,\n this.placeHolderNames,\n this.expressions.map((expr) => expr.clone()),\n this.sourceSpan,\n );\n }\n\n /**\n * Serialize the given `meta` and `messagePart` into \"cooked\" and \"raw\" strings that can be used\n * in a `$localize` tagged string. The format of the metadata is the same as that parsed by\n * `parseI18nMeta()`.\n *\n * @param meta The metadata to serialize\n * @param messagePart The first part of the tagged string\n */\n serializeI18nHead(): CookedRawString {\n let metaBlock = this.metaBlock.description || '';\n if (this.metaBlock.meaning) {\n metaBlock = `${this.metaBlock.meaning}${MEANING_SEPARATOR}${metaBlock}`;\n }\n if (this.metaBlock.customId) {\n metaBlock = `${metaBlock}${ID_SEPARATOR}${this.metaBlock.customId}`;\n }\n if (this.metaBlock.legacyIds) {\n this.metaBlock.legacyIds.forEach((legacyId) => {\n metaBlock = `${metaBlock}${LEGACY_ID_INDICATOR}${legacyId}`;\n });\n }\n return createCookedRawString(\n metaBlock,\n this.messageParts[0].text,\n this.getMessagePartSourceSpan(0),\n );\n }\n\n getMessagePartSourceSpan(i: number): ParseSourceSpan | null {\n return this.messageParts[i]?.sourceSpan ?? this.sourceSpan;\n }\n\n getPlaceholderSourceSpan(i: number): ParseSourceSpan {\n return (\n this.placeHolderNames[i]?.sourceSpan ?? this.expressions[i]?.sourceSpan ?? this.sourceSpan\n );\n }\n\n /**\n * Serialize the given `placeholderName` and `messagePart` into \"cooked\" and \"raw\" strings that\n * can be used in a `$localize` tagged string.\n *\n * The format is `:[@@]:`.\n *\n * The `associated-id` is the message id of the (usually an ICU) message to which this placeholder\n * refers.\n *\n * @param partIndex The index of the message part to serialize.\n */\n serializeI18nTemplatePart(partIndex: number): CookedRawString {\n const placeholder = this.placeHolderNames[partIndex - 1];\n const messagePart = this.messageParts[partIndex];\n let metaBlock = placeholder.text;\n if (placeholder.associatedMessage?.legacyIds.length === 0) {\n metaBlock += `${ID_SEPARATOR}${computeMsgId(\n placeholder.associatedMessage.messageString,\n placeholder.associatedMessage.meaning,\n )}`;\n }\n return createCookedRawString(\n metaBlock,\n messagePart.text,\n this.getMessagePartSourceSpan(partIndex),\n );\n }\n}\n\n/**\n * A structure to hold the cooked and raw strings of a template literal element, along with its\n * source-span range.\n */\nexport interface CookedRawString {\n cooked: string;\n raw: string;\n range: ParseSourceSpan | null;\n}\n\nconst escapeSlashes = (str: string): string => str.replace(/\\\\/g, '\\\\\\\\');\nconst escapeStartingColon = (str: string): string => str.replace(/^:/, '\\\\:');\nconst escapeColons = (str: string): string => str.replace(/:/g, '\\\\:');\nconst escapeForTemplateLiteral = (str: string): string =>\n str.replace(/`/g, '\\\\`').replace(/\\${/g, '$\\\\{');\n\n/**\n * Creates a `{cooked, raw}` object from the `metaBlock` and `messagePart`.\n *\n * The `raw` text must have various character sequences escaped:\n * * \"\\\" would otherwise indicate that the next character is a control character.\n * * \"`\" and \"${\" are template string control sequences that would otherwise prematurely indicate\n * the end of a message part.\n * * \":\" inside a metablock would prematurely indicate the end of the metablock.\n * * \":\" at the start of a messagePart with no metablock would erroneously indicate the start of a\n * metablock.\n *\n * @param metaBlock Any metadata that should be prepended to the string\n * @param messagePart The message part of the string\n */\nfunction createCookedRawString(\n metaBlock: string,\n messagePart: string,\n range: ParseSourceSpan | null,\n): CookedRawString {\n if (metaBlock === '') {\n return {\n cooked: messagePart,\n raw: escapeForTemplateLiteral(escapeStartingColon(escapeSlashes(messagePart))),\n range,\n };\n } else {\n return {\n cooked: `:${metaBlock}:${messagePart}`,\n raw: escapeForTemplateLiteral(\n `:${escapeColons(escapeSlashes(metaBlock))}:${escapeSlashes(messagePart)}`,\n ),\n range,\n };\n }\n}\n\nexport class ExternalExpr extends Expression {\n constructor(\n public value: ExternalReference,\n type?: Type | null,\n public typeParams: Type[] | null = null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof ExternalExpr &&\n this.value.name === e.value.name &&\n this.value.moduleName === e.value.moduleName &&\n this.value.runtime === e.value.runtime\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitExternalExpr(this, context);\n }\n\n override clone(): ExternalExpr {\n return new ExternalExpr(this.value, this.type, this.typeParams, this.sourceSpan);\n }\n}\n\nexport class ExternalReference {\n constructor(\n public moduleName: string | null,\n public name: string | null,\n public runtime?: any | null,\n ) {}\n // Note: no isEquivalent method here as we use this as an interface too.\n}\n\nexport class ConditionalExpr extends Expression {\n public trueCase: Expression;\n\n constructor(\n public condition: Expression,\n trueCase: Expression,\n public falseCase: Expression | null = null,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type || trueCase.type, sourceSpan);\n this.trueCase = trueCase;\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof ConditionalExpr &&\n this.condition.isEquivalent(e.condition) &&\n this.trueCase.isEquivalent(e.trueCase) &&\n nullSafeIsEquivalent(this.falseCase, e.falseCase)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitConditionalExpr(this, context);\n }\n\n override clone(): ConditionalExpr {\n return new ConditionalExpr(\n this.condition.clone(),\n this.trueCase.clone(),\n this.falseCase?.clone(),\n this.type,\n this.sourceSpan,\n );\n }\n}\n\nexport class DynamicImportExpr extends Expression {\n constructor(\n public url: string,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(null, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof DynamicImportExpr && this.url === e.url;\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitDynamicImportExpr(this, context);\n }\n\n override clone(): DynamicImportExpr {\n return new DynamicImportExpr(this.url, this.sourceSpan);\n }\n}\n\nexport class NotExpr extends Expression {\n constructor(\n public condition: Expression,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(BOOL_TYPE, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof NotExpr && this.condition.isEquivalent(e.condition);\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitNotExpr(this, context);\n }\n\n override clone(): NotExpr {\n return new NotExpr(this.condition.clone(), this.sourceSpan);\n }\n}\n\nexport class FnParam {\n constructor(\n public name: string,\n public type: Type | null = null,\n ) {}\n\n isEquivalent(param: FnParam): boolean {\n return this.name === param.name;\n }\n\n clone(): FnParam {\n return new FnParam(this.name, this.type);\n }\n}\n\nexport class FunctionExpr extends Expression {\n constructor(\n public params: FnParam[],\n public statements: Statement[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n public name?: string | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression | Statement): boolean {\n return (\n (e instanceof FunctionExpr || e instanceof DeclareFunctionStmt) &&\n areAllEquivalent(this.params, e.params) &&\n areAllEquivalent(this.statements, e.statements)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitFunctionExpr(this, context);\n }\n\n toDeclStmt(name: string, modifiers?: StmtModifier): DeclareFunctionStmt {\n return new DeclareFunctionStmt(\n name,\n this.params,\n this.statements,\n this.type,\n modifiers,\n this.sourceSpan,\n );\n }\n\n override clone(): FunctionExpr {\n // TODO: Should we deep clone statements?\n return new FunctionExpr(\n this.params.map((p) => p.clone()),\n this.statements,\n this.type,\n this.sourceSpan,\n this.name,\n );\n }\n}\n\nexport class ArrowFunctionExpr extends Expression {\n // Note that `body: Expression` represents `() => expr` whereas\n // `body: Statement[]` represents `() => { expr }`.\n\n constructor(\n public params: FnParam[],\n public body: Expression | Statement[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n if (!(e instanceof ArrowFunctionExpr) || !areAllEquivalent(this.params, e.params)) {\n return false;\n }\n\n if (this.body instanceof Expression && e.body instanceof Expression) {\n return this.body.isEquivalent(e.body);\n }\n\n if (Array.isArray(this.body) && Array.isArray(e.body)) {\n return areAllEquivalent(this.body, e.body);\n }\n\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any) {\n return visitor.visitArrowFunctionExpr(this, context);\n }\n\n override clone(): Expression {\n // TODO: Should we deep clone statements?\n return new ArrowFunctionExpr(\n this.params.map((p) => p.clone()),\n Array.isArray(this.body) ? this.body : this.body.clone(),\n this.type,\n this.sourceSpan,\n );\n }\n\n toDeclStmt(name: string, modifiers?: StmtModifier): DeclareVarStmt {\n return new DeclareVarStmt(name, this, INFERRED_TYPE, modifiers, this.sourceSpan);\n }\n}\n\nexport class UnaryOperatorExpr extends Expression {\n constructor(\n public operator: UnaryOperator,\n public expr: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n public parens: boolean = true,\n ) {\n super(type || NUMBER_TYPE, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof UnaryOperatorExpr &&\n this.operator === e.operator &&\n this.expr.isEquivalent(e.expr)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitUnaryOperatorExpr(this, context);\n }\n\n override clone(): UnaryOperatorExpr {\n return new UnaryOperatorExpr(\n this.operator,\n this.expr.clone(),\n this.type,\n this.sourceSpan,\n this.parens,\n );\n }\n}\n\nexport class BinaryOperatorExpr extends Expression {\n public lhs: Expression;\n constructor(\n public operator: BinaryOperator,\n lhs: Expression,\n public rhs: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n public parens: boolean = true,\n ) {\n super(type || lhs.type, sourceSpan);\n this.lhs = lhs;\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof BinaryOperatorExpr &&\n this.operator === e.operator &&\n this.lhs.isEquivalent(e.lhs) &&\n this.rhs.isEquivalent(e.rhs)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitBinaryOperatorExpr(this, context);\n }\n\n override clone(): BinaryOperatorExpr {\n return new BinaryOperatorExpr(\n this.operator,\n this.lhs.clone(),\n this.rhs.clone(),\n this.type,\n this.sourceSpan,\n this.parens,\n );\n }\n}\n\nexport class ReadPropExpr extends Expression {\n constructor(\n public receiver: Expression,\n public name: string,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n // An alias for name, which allows other logic to handle property reads and keyed reads together.\n get index() {\n return this.name;\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitReadPropExpr(this, context);\n }\n\n set(value: Expression): WritePropExpr {\n return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);\n }\n\n override clone(): ReadPropExpr {\n return new ReadPropExpr(this.receiver.clone(), this.name, this.type, this.sourceSpan);\n }\n}\n\nexport class ReadKeyExpr extends Expression {\n constructor(\n public receiver: Expression,\n public index: Expression,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return (\n e instanceof ReadKeyExpr &&\n this.receiver.isEquivalent(e.receiver) &&\n this.index.isEquivalent(e.index)\n );\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitReadKeyExpr(this, context);\n }\n\n set(value: Expression): WriteKeyExpr {\n return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);\n }\n\n override clone(): ReadKeyExpr {\n return new ReadKeyExpr(this.receiver.clone(), this.index.clone(), this.type, this.sourceSpan);\n }\n}\n\nexport class LiteralArrayExpr extends Expression {\n public entries: Expression[];\n constructor(entries: Expression[], type?: Type | null, sourceSpan?: ParseSourceSpan | null) {\n super(type, sourceSpan);\n this.entries = entries;\n }\n\n override isConstant() {\n return this.entries.every((e) => e.isConstant());\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries);\n }\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitLiteralArrayExpr(this, context);\n }\n\n override clone(): LiteralArrayExpr {\n return new LiteralArrayExpr(\n this.entries.map((e) => e.clone()),\n this.type,\n this.sourceSpan,\n );\n }\n}\n\nexport class LiteralMapEntry {\n constructor(\n public key: string,\n public value: Expression,\n public quoted: boolean,\n ) {}\n isEquivalent(e: LiteralMapEntry): boolean {\n return this.key === e.key && this.value.isEquivalent(e.value);\n }\n\n clone(): LiteralMapEntry {\n return new LiteralMapEntry(this.key, this.value.clone(), this.quoted);\n }\n}\n\nexport class LiteralMapExpr extends Expression {\n public valueType: Type | null = null;\n constructor(\n public entries: LiteralMapEntry[],\n type?: MapType | null,\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(type, sourceSpan);\n if (type) {\n this.valueType = type.valueType;\n }\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries);\n }\n\n override isConstant() {\n return this.entries.every((e) => e.value.isConstant());\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitLiteralMapExpr(this, context);\n }\n\n override clone(): LiteralMapExpr {\n const entriesClone = this.entries.map((entry) => entry.clone());\n return new LiteralMapExpr(entriesClone, this.type as MapType | null, this.sourceSpan);\n }\n}\n\nexport class CommaExpr extends Expression {\n constructor(\n public parts: Expression[],\n sourceSpan?: ParseSourceSpan | null,\n ) {\n super(parts[parts.length - 1].type, sourceSpan);\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts);\n }\n\n override isConstant() {\n return false;\n }\n\n override visitExpression(visitor: ExpressionVisitor, context: any): any {\n return visitor.visitCommaExpr(this, context);\n }\n\n override clone(): CommaExpr {\n return new CommaExpr(this.parts.map((p) => p.clone()));\n }\n}\n\nexport interface ExpressionVisitor {\n visitReadVarExpr(ast: ReadVarExpr, context: any): any;\n visitWriteVarExpr(expr: WriteVarExpr, context: any): any;\n visitWriteKeyExpr(expr: WriteKeyExpr, context: any): any;\n visitWritePropExpr(expr: WritePropExpr, context: any): any;\n visitInvokeFunctionExpr(ast: InvokeFunctionExpr, context: any): any;\n visitTaggedTemplateExpr(ast: TaggedTemplateExpr, context: any): any;\n visitInstantiateExpr(ast: InstantiateExpr, context: any): any;\n visitLiteralExpr(ast: LiteralExpr, context: any): any;\n visitLocalizedString(ast: LocalizedString, context: any): any;\n visitExternalExpr(ast: ExternalExpr, context: any): any;\n visitConditionalExpr(ast: ConditionalExpr, context: any): any;\n visitDynamicImportExpr(ast: DynamicImportExpr, context: any): any;\n visitNotExpr(ast: NotExpr, context: any): any;\n visitFunctionExpr(ast: FunctionExpr, context: any): any;\n visitUnaryOperatorExpr(ast: UnaryOperatorExpr, context: any): any;\n visitBinaryOperatorExpr(ast: BinaryOperatorExpr, context: any): any;\n visitReadPropExpr(ast: ReadPropExpr, context: any): any;\n visitReadKeyExpr(ast: ReadKeyExpr, context: any): any;\n visitLiteralArrayExpr(ast: LiteralArrayExpr, context: any): any;\n visitLiteralMapExpr(ast: LiteralMapExpr, context: any): any;\n visitCommaExpr(ast: CommaExpr, context: any): any;\n visitWrappedNodeExpr(ast: WrappedNodeExpr, context: any): any;\n visitTypeofExpr(ast: TypeofExpr, context: any): any;\n visitArrowFunctionExpr(ast: ArrowFunctionExpr, context: any): any;\n}\n\nexport const NULL_EXPR = new LiteralExpr(null, null, null);\nexport const TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);\n\n//// Statements\nexport enum StmtModifier {\n None = 0,\n Final = 1 << 0,\n Private = 1 << 1,\n Exported = 1 << 2,\n Static = 1 << 3,\n}\n\nexport class LeadingComment {\n constructor(\n public text: string,\n public multiline: boolean,\n public trailingNewline: boolean,\n ) {}\n toString() {\n return this.multiline ? ` ${this.text} ` : this.text;\n }\n}\nexport class JSDocComment extends LeadingComment {\n constructor(public tags: JSDocTag[]) {\n super('', /* multiline */ true, /* trailingNewline */ true);\n }\n override toString(): string {\n return serializeTags(this.tags);\n }\n}\n\nexport abstract class Statement {\n constructor(\n public modifiers: StmtModifier = StmtModifier.None,\n public sourceSpan: ParseSourceSpan | null = null,\n public leadingComments?: LeadingComment[],\n ) {}\n /**\n * Calculates whether this statement produces the same value as the given statement.\n * Note: We don't check Types nor ParseSourceSpans nor function arguments.\n */\n abstract isEquivalent(stmt: Statement): boolean;\n\n abstract visitStatement(visitor: StatementVisitor, context: any): any;\n\n hasModifier(modifier: StmtModifier): boolean {\n return (this.modifiers & modifier) !== 0;\n }\n\n addLeadingComment(leadingComment: LeadingComment): void {\n this.leadingComments = this.leadingComments ?? [];\n this.leadingComments.push(leadingComment);\n }\n}\n\nexport class DeclareVarStmt extends Statement {\n public type: Type | null;\n constructor(\n public name: string,\n public value?: Expression,\n type?: Type | null,\n modifiers?: StmtModifier,\n sourceSpan?: ParseSourceSpan | null,\n leadingComments?: LeadingComment[],\n ) {\n super(modifiers, sourceSpan, leadingComments);\n this.type = type || (value && value.type) || null;\n }\n override isEquivalent(stmt: Statement): boolean {\n return (\n stmt instanceof DeclareVarStmt &&\n this.name === stmt.name &&\n (this.value ? !!stmt.value && this.value.isEquivalent(stmt.value) : !stmt.value)\n );\n }\n override visitStatement(visitor: StatementVisitor, context: any): any {\n return visitor.visitDeclareVarStmt(this, context);\n }\n}\n\nexport class DeclareFunctionStmt extends Statement {\n public type: Type | null;\n constructor(\n public name: string,\n public params: FnParam[],\n public statements: Statement[],\n type?: Type | null,\n modifiers?: StmtModifier,\n sourceSpan?: ParseSourceSpan | null,\n leadingComments?: LeadingComment[],\n ) {\n super(modifiers, sourceSpan, leadingComments);\n this.type = type || null;\n }\n override isEquivalent(stmt: Statement): boolean {\n return (\n stmt instanceof DeclareFunctionStmt &&\n areAllEquivalent(this.params, stmt.params) &&\n areAllEquivalent(this.statements, stmt.statements)\n );\n }\n override visitStatement(visitor: StatementVisitor, context: any): any {\n return visitor.visitDeclareFunctionStmt(this, context);\n }\n}\n\nexport class ExpressionStatement extends Statement {\n constructor(\n public expr: Expression,\n sourceSpan?: ParseSourceSpan | null,\n leadingComments?: LeadingComment[],\n ) {\n super(StmtModifier.None, sourceSpan, leadingComments);\n }\n override isEquivalent(stmt: Statement): boolean {\n return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr);\n }\n override visitStatement(visitor: StatementVisitor, context: any): any {\n return visitor.visitExpressionStmt(this, context);\n }\n}\n\nexport class ReturnStatement extends Statement {\n constructor(\n public value: Expression,\n sourceSpan: ParseSourceSpan | null = null,\n leadingComments?: LeadingComment[],\n ) {\n super(StmtModifier.None, sourceSpan, leadingComments);\n }\n override isEquivalent(stmt: Statement): boolean {\n return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value);\n }\n override visitStatement(visitor: StatementVisitor, context: any): any {\n return visitor.visitReturnStmt(this, context);\n }\n}\n\nexport class IfStmt extends Statement {\n constructor(\n public condition: Expression,\n public trueCase: Statement[],\n public falseCase: Statement[] = [],\n sourceSpan?: ParseSourceSpan | null,\n leadingComments?: LeadingComment[],\n ) {\n super(StmtModifier.None, sourceSpan, leadingComments);\n }\n override isEquivalent(stmt: Statement): boolean {\n return (\n stmt instanceof IfStmt &&\n this.condition.isEquivalent(stmt.condition) &&\n areAllEquivalent(this.trueCase, stmt.trueCase) &&\n areAllEquivalent(this.falseCase, stmt.falseCase)\n );\n }\n override visitStatement(visitor: StatementVisitor, context: any): any {\n return visitor.visitIfStmt(this, context);\n }\n}\n\nexport interface StatementVisitor {\n visitDeclareVarStmt(stmt: DeclareVarStmt, context: any): any;\n visitDeclareFunctionStmt(stmt: DeclareFunctionStmt, context: any): any;\n visitExpressionStmt(stmt: ExpressionStatement, context: any): any;\n visitReturnStmt(stmt: ReturnStatement, context: any): any;\n visitIfStmt(stmt: IfStmt, context: any): any;\n}\n\nexport class RecursiveAstVisitor implements StatementVisitor, ExpressionVisitor {\n visitType(ast: Type, context: any): any {\n return ast;\n }\n visitExpression(ast: Expression, context: any): any {\n if (ast.type) {\n ast.type.visitType(this, context);\n }\n return ast;\n }\n visitBuiltinType(type: BuiltinType, context: any): any {\n return this.visitType(type, context);\n }\n visitExpressionType(type: ExpressionType, context: any): any {\n type.value.visitExpression(this, context);\n if (type.typeParams !== null) {\n type.typeParams.forEach((param) => this.visitType(param, context));\n }\n return this.visitType(type, context);\n }\n visitArrayType(type: ArrayType, context: any): any {\n return this.visitType(type, context);\n }\n visitMapType(type: MapType, context: any): any {\n return this.visitType(type, context);\n }\n visitTransplantedType(type: TransplantedType, context: any): any {\n return type;\n }\n visitWrappedNodeExpr(ast: WrappedNodeExpr, context: any): any {\n return ast;\n }\n visitTypeofExpr(ast: TypeofExpr, context: any): any {\n return this.visitExpression(ast, context);\n }\n visitReadVarExpr(ast: ReadVarExpr, context: any): any {\n return this.visitExpression(ast, context);\n }\n visitWriteVarExpr(ast: WriteVarExpr, context: any): any {\n ast.value.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitWriteKeyExpr(ast: WriteKeyExpr, context: any): any {\n ast.receiver.visitExpression(this, context);\n ast.index.visitExpression(this, context);\n ast.value.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitWritePropExpr(ast: WritePropExpr, context: any): any {\n ast.receiver.visitExpression(this, context);\n ast.value.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitDynamicImportExpr(ast: DynamicImportExpr, context: any) {\n return this.visitExpression(ast, context);\n }\n visitInvokeFunctionExpr(ast: InvokeFunctionExpr, context: any): any {\n ast.fn.visitExpression(this, context);\n this.visitAllExpressions(ast.args, context);\n return this.visitExpression(ast, context);\n }\n visitTaggedTemplateExpr(ast: TaggedTemplateExpr, context: any): any {\n ast.tag.visitExpression(this, context);\n this.visitAllExpressions(ast.template.expressions, context);\n return this.visitExpression(ast, context);\n }\n visitInstantiateExpr(ast: InstantiateExpr, context: any): any {\n ast.classExpr.visitExpression(this, context);\n this.visitAllExpressions(ast.args, context);\n return this.visitExpression(ast, context);\n }\n visitLiteralExpr(ast: LiteralExpr, context: any): any {\n return this.visitExpression(ast, context);\n }\n visitLocalizedString(ast: LocalizedString, context: any): any {\n return this.visitExpression(ast, context);\n }\n visitExternalExpr(ast: ExternalExpr, context: any): any {\n if (ast.typeParams) {\n ast.typeParams.forEach((type) => type.visitType(this, context));\n }\n return this.visitExpression(ast, context);\n }\n visitConditionalExpr(ast: ConditionalExpr, context: any): any {\n ast.condition.visitExpression(this, context);\n ast.trueCase.visitExpression(this, context);\n ast.falseCase!.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitNotExpr(ast: NotExpr, context: any): any {\n ast.condition.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitFunctionExpr(ast: FunctionExpr, context: any): any {\n this.visitAllStatements(ast.statements, context);\n return this.visitExpression(ast, context);\n }\n visitArrowFunctionExpr(ast: ArrowFunctionExpr, context: any): any {\n if (Array.isArray(ast.body)) {\n this.visitAllStatements(ast.body, context);\n } else {\n this.visitExpression(ast.body, context);\n }\n\n return this.visitExpression(ast, context);\n }\n visitUnaryOperatorExpr(ast: UnaryOperatorExpr, context: any): any {\n ast.expr.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitBinaryOperatorExpr(ast: BinaryOperatorExpr, context: any): any {\n ast.lhs.visitExpression(this, context);\n ast.rhs.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitReadPropExpr(ast: ReadPropExpr, context: any): any {\n ast.receiver.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitReadKeyExpr(ast: ReadKeyExpr, context: any): any {\n ast.receiver.visitExpression(this, context);\n ast.index.visitExpression(this, context);\n return this.visitExpression(ast, context);\n }\n visitLiteralArrayExpr(ast: LiteralArrayExpr, context: any): any {\n this.visitAllExpressions(ast.entries, context);\n return this.visitExpression(ast, context);\n }\n visitLiteralMapExpr(ast: LiteralMapExpr, context: any): any {\n ast.entries.forEach((entry) => entry.value.visitExpression(this, context));\n return this.visitExpression(ast, context);\n }\n visitCommaExpr(ast: CommaExpr, context: any): any {\n this.visitAllExpressions(ast.parts, context);\n return this.visitExpression(ast, context);\n }\n visitAllExpressions(exprs: Expression[], context: any): void {\n exprs.forEach((expr) => expr.visitExpression(this, context));\n }\n\n visitDeclareVarStmt(stmt: DeclareVarStmt, context: any): any {\n if (stmt.value) {\n stmt.value.visitExpression(this, context);\n }\n if (stmt.type) {\n stmt.type.visitType(this, context);\n }\n return stmt;\n }\n visitDeclareFunctionStmt(stmt: DeclareFunctionStmt, context: any): any {\n this.visitAllStatements(stmt.statements, context);\n if (stmt.type) {\n stmt.type.visitType(this, context);\n }\n return stmt;\n }\n visitExpressionStmt(stmt: ExpressionStatement, context: any): any {\n stmt.expr.visitExpression(this, context);\n return stmt;\n }\n visitReturnStmt(stmt: ReturnStatement, context: any): any {\n stmt.value.visitExpression(this, context);\n return stmt;\n }\n visitIfStmt(stmt: IfStmt, context: any): any {\n stmt.condition.visitExpression(this, context);\n this.visitAllStatements(stmt.trueCase, context);\n this.visitAllStatements(stmt.falseCase, context);\n return stmt;\n }\n visitAllStatements(stmts: Statement[], context: any): void {\n stmts.forEach((stmt) => stmt.visitStatement(this, context));\n }\n}\n\nexport function leadingComment(\n text: string,\n multiline: boolean = false,\n trailingNewline: boolean = true,\n): LeadingComment {\n return new LeadingComment(text, multiline, trailingNewline);\n}\n\nexport function jsDocComment(tags: JSDocTag[] = []): JSDocComment {\n return new JSDocComment(tags);\n}\n\nexport function variable(\n name: string,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n): ReadVarExpr {\n return new ReadVarExpr(name, type, sourceSpan);\n}\n\nexport function importExpr(\n id: ExternalReference,\n typeParams: Type[] | null = null,\n sourceSpan?: ParseSourceSpan | null,\n): ExternalExpr {\n return new ExternalExpr(id, null, typeParams, sourceSpan);\n}\n\nexport function importType(\n id: ExternalReference,\n typeParams?: Type[] | null,\n typeModifiers?: TypeModifier,\n): ExpressionType | null {\n return id != null ? expressionType(importExpr(id, typeParams, null), typeModifiers) : null;\n}\n\nexport function expressionType(\n expr: Expression,\n typeModifiers?: TypeModifier,\n typeParams?: Type[] | null,\n): ExpressionType {\n return new ExpressionType(expr, typeModifiers, typeParams);\n}\n\nexport function transplantedType(type: T, typeModifiers?: TypeModifier): TransplantedType {\n return new TransplantedType(type, typeModifiers);\n}\n\nexport function typeofExpr(expr: Expression) {\n return new TypeofExpr(expr);\n}\n\nexport function literalArr(\n values: Expression[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n): LiteralArrayExpr {\n return new LiteralArrayExpr(values, type, sourceSpan);\n}\n\nexport function literalMap(\n values: {key: string; quoted: boolean; value: Expression}[],\n type: MapType | null = null,\n): LiteralMapExpr {\n return new LiteralMapExpr(\n values.map((e) => new LiteralMapEntry(e.key, e.value, e.quoted)),\n type,\n null,\n );\n}\n\nexport function unary(\n operator: UnaryOperator,\n expr: Expression,\n type?: Type,\n sourceSpan?: ParseSourceSpan | null,\n): UnaryOperatorExpr {\n return new UnaryOperatorExpr(operator, expr, type, sourceSpan);\n}\n\nexport function not(expr: Expression, sourceSpan?: ParseSourceSpan | null): NotExpr {\n return new NotExpr(expr, sourceSpan);\n}\n\nexport function fn(\n params: FnParam[],\n body: Statement[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n name?: string | null,\n): FunctionExpr {\n return new FunctionExpr(params, body, type, sourceSpan, name);\n}\n\nexport function arrowFn(\n params: FnParam[],\n body: Expression | Statement[],\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n) {\n return new ArrowFunctionExpr(params, body, type, sourceSpan);\n}\n\nexport function ifStmt(\n condition: Expression,\n thenClause: Statement[],\n elseClause?: Statement[],\n sourceSpan?: ParseSourceSpan,\n leadingComments?: LeadingComment[],\n) {\n return new IfStmt(condition, thenClause, elseClause, sourceSpan, leadingComments);\n}\n\nexport function taggedTemplate(\n tag: Expression,\n template: TemplateLiteral,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n): TaggedTemplateExpr {\n return new TaggedTemplateExpr(tag, template, type, sourceSpan);\n}\n\nexport function literal(\n value: any,\n type?: Type | null,\n sourceSpan?: ParseSourceSpan | null,\n): LiteralExpr {\n return new LiteralExpr(value, type, sourceSpan);\n}\n\nexport function localizedString(\n metaBlock: I18nMeta,\n messageParts: LiteralPiece[],\n placeholderNames: PlaceholderPiece[],\n expressions: Expression[],\n sourceSpan?: ParseSourceSpan | null,\n): LocalizedString {\n return new LocalizedString(metaBlock, messageParts, placeholderNames, expressions, sourceSpan);\n}\n\nexport function isNull(exp: Expression): boolean {\n return exp instanceof LiteralExpr && exp.value === null;\n}\n\n// The list of JSDoc tags that we currently support. Extend it if needed.\nexport const enum JSDocTagName {\n Desc = 'desc',\n Id = 'id',\n Meaning = 'meaning',\n Suppress = 'suppress',\n}\n\n/*\n * TypeScript has an API for JSDoc already, but it's not exposed.\n * https://github.com/Microsoft/TypeScript/issues/7393\n * For now we create types that are similar to theirs so that migrating\n * to their API will be easier. See e.g. `ts.JSDocTag` and `ts.JSDocComment`.\n */\nexport type JSDocTag =\n | {\n // `tagName` is e.g. \"param\" in an `@param` declaration\n tagName: JSDocTagName | string;\n // Any remaining text on the tag, e.g. the description\n text?: string;\n }\n | {\n // no `tagName` for plain text documentation that occurs before any `@param` lines\n tagName?: undefined;\n text: string;\n };\n\n/*\n * Serializes a `Tag` into a string.\n * Returns a string like \" @foo {bar} baz\" (note the leading whitespace before `@foo`).\n */\nfunction tagToString(tag: JSDocTag): string {\n let out = '';\n if (tag.tagName) {\n out += ` @${tag.tagName}`;\n }\n if (tag.text) {\n if (tag.text.match(/\\/\\*|\\*\\//)) {\n throw new Error('JSDoc text cannot contain \"/*\" and \"*/\"');\n }\n out += ' ' + tag.text.replace(/@/g, '\\\\@');\n }\n return out;\n}\n\nfunction serializeTags(tags: JSDocTag[]): string {\n if (tags.length === 0) return '';\n\n if (tags.length === 1 && tags[0].tagName && !tags[0].text) {\n // The JSDOC comment is a single simple tag: e.g `/** @tagname */`.\n return `*${tagToString(tags[0])} `;\n }\n\n let out = '*\\n';\n for (const tag of tags) {\n out += ' *';\n // If the tagToString is multi-line, insert \" * \" prefixes on lines.\n out += tagToString(tag).replace(/\\n/g, '\\n * ');\n out += '\\n';\n }\n out += ' ';\n return out;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from './output/output_ast';\n\nconst CONSTANT_PREFIX = '_c';\n\n/**\n * `ConstantPool` tries to reuse literal factories when two or more literals are identical.\n * We determine whether literals are identical by creating a key out of their AST using the\n * `KeyVisitor`. This constant is used to replace dynamic expressions which can't be safely\n * converted into a key. E.g. given an expression `{foo: bar()}`, since we don't know what\n * the result of `bar` will be, we create a key that looks like `{foo: }`. Note\n * that we use a variable, rather than something like `null` in order to avoid collisions.\n */\nconst UNKNOWN_VALUE_KEY = o.variable('');\n\n/**\n * Context to use when producing a key.\n *\n * This ensures we see the constant not the reference variable when producing\n * a key.\n */\nconst KEY_CONTEXT = {};\n\n/**\n * Generally all primitive values are excluded from the `ConstantPool`, but there is an exclusion\n * for strings that reach a certain length threshold. This constant defines the length threshold for\n * strings.\n */\nconst POOL_INCLUSION_LENGTH_THRESHOLD_FOR_STRINGS = 50;\n\n/**\n * A node that is a place-holder that allows the node to be replaced when the actual\n * node is known.\n *\n * This allows the constant pool to change an expression from a direct reference to\n * a constant to a shared constant. It returns a fix-up node that is later allowed to\n * change the referenced expression.\n */\nclass FixupExpression extends o.Expression {\n private original: o.Expression;\n\n shared = false;\n\n constructor(public resolved: o.Expression) {\n super(resolved.type);\n this.original = resolved;\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n if (context === KEY_CONTEXT) {\n // When producing a key we want to traverse the constant not the\n // variable used to refer to it.\n return this.original.visitExpression(visitor, context);\n } else {\n return this.resolved.visitExpression(visitor, context);\n }\n }\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof FixupExpression && this.resolved.isEquivalent(e.resolved);\n }\n\n override isConstant() {\n return true;\n }\n\n override clone(): FixupExpression {\n throw new Error(`Not supported.`);\n }\n\n fixup(expression: o.Expression) {\n this.resolved = expression;\n this.shared = true;\n }\n}\n\n/**\n * A constant pool allows a code emitter to share constant in an output context.\n *\n * The constant pool also supports sharing access to ivy definitions references.\n */\nexport class ConstantPool {\n statements: o.Statement[] = [];\n private literals = new Map();\n private literalFactories = new Map();\n private sharedConstants = new Map();\n\n /**\n * Constant pool also tracks claimed names from {@link uniqueName}.\n * This is useful to avoid collisions if variables are intended to be\n * named a certain way- but may conflict. We wouldn't want to always suffix\n * them with unique numbers.\n */\n private _claimedNames = new Map();\n\n private nextNameIndex = 0;\n\n constructor(private readonly isClosureCompilerEnabled: boolean = false) {}\n\n getConstLiteral(literal: o.Expression, forceShared?: boolean): o.Expression {\n if (\n (literal instanceof o.LiteralExpr && !isLongStringLiteral(literal)) ||\n literal instanceof FixupExpression\n ) {\n // Do no put simple literals into the constant pool or try to produce a constant for a\n // reference to a constant.\n return literal;\n }\n const key = GenericKeyFn.INSTANCE.keyOf(literal);\n let fixup = this.literals.get(key);\n let newValue = false;\n if (!fixup) {\n fixup = new FixupExpression(literal);\n this.literals.set(key, fixup);\n newValue = true;\n }\n\n if ((!newValue && !fixup.shared) || (newValue && forceShared)) {\n // Replace the expression with a variable\n const name = this.freshName();\n let definition: o.WriteVarExpr;\n let usage: o.Expression;\n if (this.isClosureCompilerEnabled && isLongStringLiteral(literal)) {\n // For string literals, Closure will **always** inline the string at\n // **all** usages, duplicating it each time. For large strings, this\n // unnecessarily bloats bundle size. To work around this restriction, we\n // wrap the string in a function, and call that function for each usage.\n // This tricks Closure into using inline logic for functions instead of\n // string literals. Function calls are only inlined if the body is small\n // enough to be worth it. By doing this, very large strings will be\n // shared across multiple usages, rather than duplicating the string at\n // each usage site.\n //\n // const myStr = function() { return \"very very very long string\"; };\n // const usage1 = myStr();\n // const usage2 = myStr();\n definition = o.variable(name).set(\n new o.FunctionExpr(\n [], // Params.\n [\n // Statements.\n new o.ReturnStatement(literal),\n ],\n ),\n );\n usage = o.variable(name).callFn([]);\n } else {\n // Just declare and use the variable directly, without a function call\n // indirection. This saves a few bytes and avoids an unnecessary call.\n definition = o.variable(name).set(literal);\n usage = o.variable(name);\n }\n\n this.statements.push(definition.toDeclStmt(o.INFERRED_TYPE, o.StmtModifier.Final));\n fixup.fixup(usage);\n }\n\n return fixup;\n }\n\n getSharedConstant(def: SharedConstantDefinition, expr: o.Expression): o.Expression {\n const key = def.keyOf(expr);\n if (!this.sharedConstants.has(key)) {\n const id = this.freshName();\n this.sharedConstants.set(key, o.variable(id));\n this.statements.push(def.toSharedConstantDeclaration(id, expr));\n }\n return this.sharedConstants.get(key)!;\n }\n\n getLiteralFactory(literal: o.LiteralArrayExpr | o.LiteralMapExpr): {\n literalFactory: o.Expression;\n literalFactoryArguments: o.Expression[];\n } {\n // Create a pure function that builds an array of a mix of constant and variable expressions\n if (literal instanceof o.LiteralArrayExpr) {\n const argumentsForKey = literal.entries.map((e) => (e.isConstant() ? e : UNKNOWN_VALUE_KEY));\n const key = GenericKeyFn.INSTANCE.keyOf(o.literalArr(argumentsForKey));\n return this._getLiteralFactory(key, literal.entries, (entries) => o.literalArr(entries));\n } else {\n const expressionForKey = o.literalMap(\n literal.entries.map((e) => ({\n key: e.key,\n value: e.value.isConstant() ? e.value : UNKNOWN_VALUE_KEY,\n quoted: e.quoted,\n })),\n );\n const key = GenericKeyFn.INSTANCE.keyOf(expressionForKey);\n return this._getLiteralFactory(\n key,\n literal.entries.map((e) => e.value),\n (entries) =>\n o.literalMap(\n entries.map((value, index) => ({\n key: literal.entries[index].key,\n value,\n quoted: literal.entries[index].quoted,\n })),\n ),\n );\n }\n }\n\n // TODO: useUniqueName(false) is necessary for naming compatibility with\n // TemplateDefinitionBuilder, but should be removed once Template Pipeline is the default.\n getSharedFunctionReference(\n fn: o.Expression,\n prefix: string,\n useUniqueName: boolean = true,\n ): o.Expression {\n const isArrow = fn instanceof o.ArrowFunctionExpr;\n\n for (const current of this.statements) {\n // Arrow functions are saved as variables so we check if the\n // value of the variable is the same as the arrow function.\n if (isArrow && current instanceof o.DeclareVarStmt && current.value?.isEquivalent(fn)) {\n return o.variable(current.name);\n }\n\n // Function declarations are saved as function statements\n // so we compare them directly to the passed-in function.\n if (\n !isArrow &&\n current instanceof o.DeclareFunctionStmt &&\n fn instanceof o.FunctionExpr &&\n fn.isEquivalent(current)\n ) {\n return o.variable(current.name);\n }\n }\n\n // Otherwise declare the function.\n const name = useUniqueName ? this.uniqueName(prefix) : prefix;\n this.statements.push(\n fn instanceof o.FunctionExpr\n ? fn.toDeclStmt(name, o.StmtModifier.Final)\n : new o.DeclareVarStmt(name, fn, o.INFERRED_TYPE, o.StmtModifier.Final, fn.sourceSpan),\n );\n return o.variable(name);\n }\n\n private _getLiteralFactory(\n key: string,\n values: o.Expression[],\n resultMap: (parameters: o.Expression[]) => o.Expression,\n ): {literalFactory: o.Expression; literalFactoryArguments: o.Expression[]} {\n let literalFactory = this.literalFactories.get(key);\n const literalFactoryArguments = values.filter((e) => !e.isConstant());\n if (!literalFactory) {\n const resultExpressions = values.map((e, index) =>\n e.isConstant() ? this.getConstLiteral(e, true) : o.variable(`a${index}`),\n );\n const parameters = resultExpressions\n .filter(isVariable)\n .map((e) => new o.FnParam(e.name!, o.DYNAMIC_TYPE));\n const pureFunctionDeclaration = o.arrowFn(\n parameters,\n resultMap(resultExpressions),\n o.INFERRED_TYPE,\n );\n const name = this.freshName();\n this.statements.push(\n o\n .variable(name)\n .set(pureFunctionDeclaration)\n .toDeclStmt(o.INFERRED_TYPE, o.StmtModifier.Final),\n );\n literalFactory = o.variable(name);\n this.literalFactories.set(key, literalFactory);\n }\n return {literalFactory, literalFactoryArguments};\n }\n\n /**\n * Produce a unique name in the context of this pool.\n *\n * The name might be unique among different prefixes if any of the prefixes end in\n * a digit so the prefix should be a constant string (not based on user input) and\n * must not end in a digit.\n */\n uniqueName(name: string, alwaysIncludeSuffix = true): string {\n const count = this._claimedNames.get(name) ?? 0;\n const result = count === 0 && !alwaysIncludeSuffix ? `${name}` : `${name}${count}`;\n\n this._claimedNames.set(name, count + 1);\n return result;\n }\n\n private freshName(): string {\n return this.uniqueName(CONSTANT_PREFIX);\n }\n}\n\nexport interface ExpressionKeyFn {\n keyOf(expr: o.Expression): string;\n}\n\nexport interface SharedConstantDefinition extends ExpressionKeyFn {\n toSharedConstantDeclaration(declName: string, keyExpr: o.Expression): o.Statement;\n}\n\nexport class GenericKeyFn implements ExpressionKeyFn {\n static readonly INSTANCE = new GenericKeyFn();\n\n keyOf(expr: o.Expression): string {\n if (expr instanceof o.LiteralExpr && typeof expr.value === 'string') {\n return `\"${expr.value}\"`;\n } else if (expr instanceof o.LiteralExpr) {\n return String(expr.value);\n } else if (expr instanceof o.LiteralArrayExpr) {\n const entries: string[] = [];\n for (const entry of expr.entries) {\n entries.push(this.keyOf(entry));\n }\n return `[${entries.join(',')}]`;\n } else if (expr instanceof o.LiteralMapExpr) {\n const entries: string[] = [];\n for (const entry of expr.entries) {\n let key = entry.key;\n if (entry.quoted) {\n key = `\"${key}\"`;\n }\n entries.push(key + ':' + this.keyOf(entry.value));\n }\n return `{${entries.join(',')}}`;\n } else if (expr instanceof o.ExternalExpr) {\n return `import(\"${expr.value.moduleName}\", ${expr.value.name})`;\n } else if (expr instanceof o.ReadVarExpr) {\n return `read(${expr.name})`;\n } else if (expr instanceof o.TypeofExpr) {\n return `typeof(${this.keyOf(expr.expr)})`;\n } else {\n throw new Error(\n `${this.constructor.name} does not handle expressions of type ${expr.constructor.name}`,\n );\n }\n }\n}\n\nfunction isVariable(e: o.Expression): e is o.ReadVarExpr {\n return e instanceof o.ReadVarExpr;\n}\n\nfunction isLongStringLiteral(expr: o.Expression): boolean {\n return (\n expr instanceof o.LiteralExpr &&\n typeof expr.value === 'string' &&\n expr.value.length >= POOL_INCLUSION_LENGTH_THRESHOLD_FOR_STRINGS\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../output/output_ast';\n\nconst CORE = '@angular/core';\n\nexport class Identifiers {\n /* Methods */\n static NEW_METHOD = 'factory';\n static TRANSFORM_METHOD = 'transform';\n static PATCH_DEPS = 'patchedDeps';\n\n static core: o.ExternalReference = {name: null, moduleName: CORE};\n\n /* Instructions */\n static namespaceHTML: o.ExternalReference = {name: 'ɵɵnamespaceHTML', moduleName: CORE};\n\n static namespaceMathML: o.ExternalReference = {name: 'ɵɵnamespaceMathML', moduleName: CORE};\n\n static namespaceSVG: o.ExternalReference = {name: 'ɵɵnamespaceSVG', moduleName: CORE};\n\n static element: o.ExternalReference = {name: 'ɵɵelement', moduleName: CORE};\n\n static elementStart: o.ExternalReference = {name: 'ɵɵelementStart', moduleName: CORE};\n\n static elementEnd: o.ExternalReference = {name: 'ɵɵelementEnd', moduleName: CORE};\n\n static advance: o.ExternalReference = {name: 'ɵɵadvance', moduleName: CORE};\n\n static syntheticHostProperty: o.ExternalReference = {\n name: 'ɵɵsyntheticHostProperty',\n moduleName: CORE,\n };\n\n static syntheticHostListener: o.ExternalReference = {\n name: 'ɵɵsyntheticHostListener',\n moduleName: CORE,\n };\n\n static attribute: o.ExternalReference = {name: 'ɵɵattribute', moduleName: CORE};\n\n static attributeInterpolate1: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate1',\n moduleName: CORE,\n };\n static attributeInterpolate2: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate2',\n moduleName: CORE,\n };\n static attributeInterpolate3: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate3',\n moduleName: CORE,\n };\n static attributeInterpolate4: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate4',\n moduleName: CORE,\n };\n static attributeInterpolate5: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate5',\n moduleName: CORE,\n };\n static attributeInterpolate6: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate6',\n moduleName: CORE,\n };\n static attributeInterpolate7: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate7',\n moduleName: CORE,\n };\n static attributeInterpolate8: o.ExternalReference = {\n name: 'ɵɵattributeInterpolate8',\n moduleName: CORE,\n };\n static attributeInterpolateV: o.ExternalReference = {\n name: 'ɵɵattributeInterpolateV',\n moduleName: CORE,\n };\n\n static classProp: o.ExternalReference = {name: 'ɵɵclassProp', moduleName: CORE};\n\n static elementContainerStart: o.ExternalReference = {\n name: 'ɵɵelementContainerStart',\n moduleName: CORE,\n };\n\n static elementContainerEnd: o.ExternalReference = {\n name: 'ɵɵelementContainerEnd',\n moduleName: CORE,\n };\n\n static elementContainer: o.ExternalReference = {name: 'ɵɵelementContainer', moduleName: CORE};\n\n static styleMap: o.ExternalReference = {name: 'ɵɵstyleMap', moduleName: CORE};\n\n static styleMapInterpolate1: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate1',\n moduleName: CORE,\n };\n static styleMapInterpolate2: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate2',\n moduleName: CORE,\n };\n static styleMapInterpolate3: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate3',\n moduleName: CORE,\n };\n static styleMapInterpolate4: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate4',\n moduleName: CORE,\n };\n static styleMapInterpolate5: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate5',\n moduleName: CORE,\n };\n static styleMapInterpolate6: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate6',\n moduleName: CORE,\n };\n static styleMapInterpolate7: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate7',\n moduleName: CORE,\n };\n static styleMapInterpolate8: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolate8',\n moduleName: CORE,\n };\n static styleMapInterpolateV: o.ExternalReference = {\n name: 'ɵɵstyleMapInterpolateV',\n moduleName: CORE,\n };\n\n static classMap: o.ExternalReference = {name: 'ɵɵclassMap', moduleName: CORE};\n\n static classMapInterpolate1: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate1',\n moduleName: CORE,\n };\n static classMapInterpolate2: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate2',\n moduleName: CORE,\n };\n static classMapInterpolate3: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate3',\n moduleName: CORE,\n };\n static classMapInterpolate4: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate4',\n moduleName: CORE,\n };\n static classMapInterpolate5: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate5',\n moduleName: CORE,\n };\n static classMapInterpolate6: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate6',\n moduleName: CORE,\n };\n static classMapInterpolate7: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate7',\n moduleName: CORE,\n };\n static classMapInterpolate8: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolate8',\n moduleName: CORE,\n };\n static classMapInterpolateV: o.ExternalReference = {\n name: 'ɵɵclassMapInterpolateV',\n moduleName: CORE,\n };\n\n static styleProp: o.ExternalReference = {name: 'ɵɵstyleProp', moduleName: CORE};\n\n static stylePropInterpolate1: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate1',\n moduleName: CORE,\n };\n static stylePropInterpolate2: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate2',\n moduleName: CORE,\n };\n static stylePropInterpolate3: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate3',\n moduleName: CORE,\n };\n static stylePropInterpolate4: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate4',\n moduleName: CORE,\n };\n static stylePropInterpolate5: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate5',\n moduleName: CORE,\n };\n static stylePropInterpolate6: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate6',\n moduleName: CORE,\n };\n static stylePropInterpolate7: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate7',\n moduleName: CORE,\n };\n static stylePropInterpolate8: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolate8',\n moduleName: CORE,\n };\n static stylePropInterpolateV: o.ExternalReference = {\n name: 'ɵɵstylePropInterpolateV',\n moduleName: CORE,\n };\n\n static nextContext: o.ExternalReference = {name: 'ɵɵnextContext', moduleName: CORE};\n\n static resetView: o.ExternalReference = {name: 'ɵɵresetView', moduleName: CORE};\n\n static templateCreate: o.ExternalReference = {name: 'ɵɵtemplate', moduleName: CORE};\n\n static defer: o.ExternalReference = {name: 'ɵɵdefer', moduleName: CORE};\n static deferWhen: o.ExternalReference = {name: 'ɵɵdeferWhen', moduleName: CORE};\n static deferOnIdle: o.ExternalReference = {name: 'ɵɵdeferOnIdle', moduleName: CORE};\n static deferOnImmediate: o.ExternalReference = {name: 'ɵɵdeferOnImmediate', moduleName: CORE};\n static deferOnTimer: o.ExternalReference = {name: 'ɵɵdeferOnTimer', moduleName: CORE};\n static deferOnHover: o.ExternalReference = {name: 'ɵɵdeferOnHover', moduleName: CORE};\n static deferOnInteraction: o.ExternalReference = {name: 'ɵɵdeferOnInteraction', moduleName: CORE};\n static deferOnViewport: o.ExternalReference = {name: 'ɵɵdeferOnViewport', moduleName: CORE};\n static deferPrefetchWhen: o.ExternalReference = {name: 'ɵɵdeferPrefetchWhen', moduleName: CORE};\n static deferPrefetchOnIdle: o.ExternalReference = {\n name: 'ɵɵdeferPrefetchOnIdle',\n moduleName: CORE,\n };\n static deferPrefetchOnImmediate: o.ExternalReference = {\n name: 'ɵɵdeferPrefetchOnImmediate',\n moduleName: CORE,\n };\n static deferPrefetchOnTimer: o.ExternalReference = {\n name: 'ɵɵdeferPrefetchOnTimer',\n moduleName: CORE,\n };\n static deferPrefetchOnHover: o.ExternalReference = {\n name: 'ɵɵdeferPrefetchOnHover',\n moduleName: CORE,\n };\n static deferPrefetchOnInteraction: o.ExternalReference = {\n name: 'ɵɵdeferPrefetchOnInteraction',\n moduleName: CORE,\n };\n static deferPrefetchOnViewport: o.ExternalReference = {\n name: 'ɵɵdeferPrefetchOnViewport',\n moduleName: CORE,\n };\n static deferEnableTimerScheduling: o.ExternalReference = {\n name: 'ɵɵdeferEnableTimerScheduling',\n moduleName: CORE,\n };\n\n static conditional: o.ExternalReference = {name: 'ɵɵconditional', moduleName: CORE};\n static repeater: o.ExternalReference = {name: 'ɵɵrepeater', moduleName: CORE};\n static repeaterCreate: o.ExternalReference = {name: 'ɵɵrepeaterCreate', moduleName: CORE};\n static repeaterTrackByIndex: o.ExternalReference = {\n name: 'ɵɵrepeaterTrackByIndex',\n moduleName: CORE,\n };\n static repeaterTrackByIdentity: o.ExternalReference = {\n name: 'ɵɵrepeaterTrackByIdentity',\n moduleName: CORE,\n };\n static componentInstance: o.ExternalReference = {name: 'ɵɵcomponentInstance', moduleName: CORE};\n\n static text: o.ExternalReference = {name: 'ɵɵtext', moduleName: CORE};\n\n static enableBindings: o.ExternalReference = {name: 'ɵɵenableBindings', moduleName: CORE};\n\n static disableBindings: o.ExternalReference = {name: 'ɵɵdisableBindings', moduleName: CORE};\n\n static getCurrentView: o.ExternalReference = {name: 'ɵɵgetCurrentView', moduleName: CORE};\n\n static textInterpolate: o.ExternalReference = {name: 'ɵɵtextInterpolate', moduleName: CORE};\n static textInterpolate1: o.ExternalReference = {name: 'ɵɵtextInterpolate1', moduleName: CORE};\n static textInterpolate2: o.ExternalReference = {name: 'ɵɵtextInterpolate2', moduleName: CORE};\n static textInterpolate3: o.ExternalReference = {name: 'ɵɵtextInterpolate3', moduleName: CORE};\n static textInterpolate4: o.ExternalReference = {name: 'ɵɵtextInterpolate4', moduleName: CORE};\n static textInterpolate5: o.ExternalReference = {name: 'ɵɵtextInterpolate5', moduleName: CORE};\n static textInterpolate6: o.ExternalReference = {name: 'ɵɵtextInterpolate6', moduleName: CORE};\n static textInterpolate7: o.ExternalReference = {name: 'ɵɵtextInterpolate7', moduleName: CORE};\n static textInterpolate8: o.ExternalReference = {name: 'ɵɵtextInterpolate8', moduleName: CORE};\n static textInterpolateV: o.ExternalReference = {name: 'ɵɵtextInterpolateV', moduleName: CORE};\n\n static restoreView: o.ExternalReference = {name: 'ɵɵrestoreView', moduleName: CORE};\n\n static pureFunction0: o.ExternalReference = {name: 'ɵɵpureFunction0', moduleName: CORE};\n static pureFunction1: o.ExternalReference = {name: 'ɵɵpureFunction1', moduleName: CORE};\n static pureFunction2: o.ExternalReference = {name: 'ɵɵpureFunction2', moduleName: CORE};\n static pureFunction3: o.ExternalReference = {name: 'ɵɵpureFunction3', moduleName: CORE};\n static pureFunction4: o.ExternalReference = {name: 'ɵɵpureFunction4', moduleName: CORE};\n static pureFunction5: o.ExternalReference = {name: 'ɵɵpureFunction5', moduleName: CORE};\n static pureFunction6: o.ExternalReference = {name: 'ɵɵpureFunction6', moduleName: CORE};\n static pureFunction7: o.ExternalReference = {name: 'ɵɵpureFunction7', moduleName: CORE};\n static pureFunction8: o.ExternalReference = {name: 'ɵɵpureFunction8', moduleName: CORE};\n static pureFunctionV: o.ExternalReference = {name: 'ɵɵpureFunctionV', moduleName: CORE};\n\n static pipeBind1: o.ExternalReference = {name: 'ɵɵpipeBind1', moduleName: CORE};\n static pipeBind2: o.ExternalReference = {name: 'ɵɵpipeBind2', moduleName: CORE};\n static pipeBind3: o.ExternalReference = {name: 'ɵɵpipeBind3', moduleName: CORE};\n static pipeBind4: o.ExternalReference = {name: 'ɵɵpipeBind4', moduleName: CORE};\n static pipeBindV: o.ExternalReference = {name: 'ɵɵpipeBindV', moduleName: CORE};\n\n static hostProperty: o.ExternalReference = {name: 'ɵɵhostProperty', moduleName: CORE};\n\n static property: o.ExternalReference = {name: 'ɵɵproperty', moduleName: CORE};\n\n static propertyInterpolate: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate',\n moduleName: CORE,\n };\n static propertyInterpolate1: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate1',\n moduleName: CORE,\n };\n static propertyInterpolate2: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate2',\n moduleName: CORE,\n };\n static propertyInterpolate3: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate3',\n moduleName: CORE,\n };\n static propertyInterpolate4: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate4',\n moduleName: CORE,\n };\n static propertyInterpolate5: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate5',\n moduleName: CORE,\n };\n static propertyInterpolate6: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate6',\n moduleName: CORE,\n };\n static propertyInterpolate7: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate7',\n moduleName: CORE,\n };\n static propertyInterpolate8: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolate8',\n moduleName: CORE,\n };\n static propertyInterpolateV: o.ExternalReference = {\n name: 'ɵɵpropertyInterpolateV',\n moduleName: CORE,\n };\n\n static i18n: o.ExternalReference = {name: 'ɵɵi18n', moduleName: CORE};\n static i18nAttributes: o.ExternalReference = {name: 'ɵɵi18nAttributes', moduleName: CORE};\n static i18nExp: o.ExternalReference = {name: 'ɵɵi18nExp', moduleName: CORE};\n static i18nStart: o.ExternalReference = {name: 'ɵɵi18nStart', moduleName: CORE};\n static i18nEnd: o.ExternalReference = {name: 'ɵɵi18nEnd', moduleName: CORE};\n static i18nApply: o.ExternalReference = {name: 'ɵɵi18nApply', moduleName: CORE};\n static i18nPostprocess: o.ExternalReference = {name: 'ɵɵi18nPostprocess', moduleName: CORE};\n\n static pipe: o.ExternalReference = {name: 'ɵɵpipe', moduleName: CORE};\n\n static projection: o.ExternalReference = {name: 'ɵɵprojection', moduleName: CORE};\n static projectionDef: o.ExternalReference = {name: 'ɵɵprojectionDef', moduleName: CORE};\n\n static reference: o.ExternalReference = {name: 'ɵɵreference', moduleName: CORE};\n\n static inject: o.ExternalReference = {name: 'ɵɵinject', moduleName: CORE};\n\n static injectAttribute: o.ExternalReference = {name: 'ɵɵinjectAttribute', moduleName: CORE};\n\n static directiveInject: o.ExternalReference = {name: 'ɵɵdirectiveInject', moduleName: CORE};\n static invalidFactory: o.ExternalReference = {name: 'ɵɵinvalidFactory', moduleName: CORE};\n static invalidFactoryDep: o.ExternalReference = {name: 'ɵɵinvalidFactoryDep', moduleName: CORE};\n\n static templateRefExtractor: o.ExternalReference = {\n name: 'ɵɵtemplateRefExtractor',\n moduleName: CORE,\n };\n\n static forwardRef: o.ExternalReference = {name: 'forwardRef', moduleName: CORE};\n static resolveForwardRef: o.ExternalReference = {name: 'resolveForwardRef', moduleName: CORE};\n\n static ɵɵdefineInjectable: o.ExternalReference = {name: 'ɵɵdefineInjectable', moduleName: CORE};\n static declareInjectable: o.ExternalReference = {name: 'ɵɵngDeclareInjectable', moduleName: CORE};\n static InjectableDeclaration: o.ExternalReference = {\n name: 'ɵɵInjectableDeclaration',\n moduleName: CORE,\n };\n\n static resolveWindow: o.ExternalReference = {name: 'ɵɵresolveWindow', moduleName: CORE};\n static resolveDocument: o.ExternalReference = {name: 'ɵɵresolveDocument', moduleName: CORE};\n static resolveBody: o.ExternalReference = {name: 'ɵɵresolveBody', moduleName: CORE};\n\n static getComponentDepsFactory: o.ExternalReference = {\n name: 'ɵɵgetComponentDepsFactory',\n moduleName: CORE,\n };\n\n static defineComponent: o.ExternalReference = {name: 'ɵɵdefineComponent', moduleName: CORE};\n static declareComponent: o.ExternalReference = {name: 'ɵɵngDeclareComponent', moduleName: CORE};\n\n static setComponentScope: o.ExternalReference = {name: 'ɵɵsetComponentScope', moduleName: CORE};\n\n static ChangeDetectionStrategy: o.ExternalReference = {\n name: 'ChangeDetectionStrategy',\n moduleName: CORE,\n };\n static ViewEncapsulation: o.ExternalReference = {\n name: 'ViewEncapsulation',\n moduleName: CORE,\n };\n\n static ComponentDeclaration: o.ExternalReference = {\n name: 'ɵɵComponentDeclaration',\n moduleName: CORE,\n };\n\n static FactoryDeclaration: o.ExternalReference = {\n name: 'ɵɵFactoryDeclaration',\n moduleName: CORE,\n };\n static declareFactory: o.ExternalReference = {name: 'ɵɵngDeclareFactory', moduleName: CORE};\n static FactoryTarget: o.ExternalReference = {name: 'ɵɵFactoryTarget', moduleName: CORE};\n\n static defineDirective: o.ExternalReference = {name: 'ɵɵdefineDirective', moduleName: CORE};\n static declareDirective: o.ExternalReference = {name: 'ɵɵngDeclareDirective', moduleName: CORE};\n\n static DirectiveDeclaration: o.ExternalReference = {\n name: 'ɵɵDirectiveDeclaration',\n moduleName: CORE,\n };\n\n static InjectorDef: o.ExternalReference = {name: 'ɵɵInjectorDef', moduleName: CORE};\n static InjectorDeclaration: o.ExternalReference = {\n name: 'ɵɵInjectorDeclaration',\n moduleName: CORE,\n };\n\n static defineInjector: o.ExternalReference = {name: 'ɵɵdefineInjector', moduleName: CORE};\n static declareInjector: o.ExternalReference = {name: 'ɵɵngDeclareInjector', moduleName: CORE};\n\n static NgModuleDeclaration: o.ExternalReference = {\n name: 'ɵɵNgModuleDeclaration',\n moduleName: CORE,\n };\n\n static ModuleWithProviders: o.ExternalReference = {\n name: 'ModuleWithProviders',\n moduleName: CORE,\n };\n\n static defineNgModule: o.ExternalReference = {name: 'ɵɵdefineNgModule', moduleName: CORE};\n static declareNgModule: o.ExternalReference = {name: 'ɵɵngDeclareNgModule', moduleName: CORE};\n static setNgModuleScope: o.ExternalReference = {name: 'ɵɵsetNgModuleScope', moduleName: CORE};\n static registerNgModuleType: o.ExternalReference = {\n name: 'ɵɵregisterNgModuleType',\n moduleName: CORE,\n };\n\n static PipeDeclaration: o.ExternalReference = {name: 'ɵɵPipeDeclaration', moduleName: CORE};\n\n static definePipe: o.ExternalReference = {name: 'ɵɵdefinePipe', moduleName: CORE};\n static declarePipe: o.ExternalReference = {name: 'ɵɵngDeclarePipe', moduleName: CORE};\n\n static declareClassMetadata: o.ExternalReference = {\n name: 'ɵɵngDeclareClassMetadata',\n moduleName: CORE,\n };\n static declareClassMetadataAsync: o.ExternalReference = {\n name: 'ɵɵngDeclareClassMetadataAsync',\n moduleName: CORE,\n };\n static setClassMetadata: o.ExternalReference = {name: 'ɵsetClassMetadata', moduleName: CORE};\n static setClassMetadataAsync: o.ExternalReference = {\n name: 'ɵsetClassMetadataAsync',\n moduleName: CORE,\n };\n static setClassDebugInfo: o.ExternalReference = {name: 'ɵsetClassDebugInfo', moduleName: CORE};\n static queryRefresh: o.ExternalReference = {name: 'ɵɵqueryRefresh', moduleName: CORE};\n static viewQuery: o.ExternalReference = {name: 'ɵɵviewQuery', moduleName: CORE};\n static loadQuery: o.ExternalReference = {name: 'ɵɵloadQuery', moduleName: CORE};\n static contentQuery: o.ExternalReference = {name: 'ɵɵcontentQuery', moduleName: CORE};\n\n // Signal queries\n static viewQuerySignal: o.ExternalReference = {name: 'ɵɵviewQuerySignal', moduleName: CORE};\n static contentQuerySignal: o.ExternalReference = {name: 'ɵɵcontentQuerySignal', moduleName: CORE};\n static queryAdvance: o.ExternalReference = {name: 'ɵɵqueryAdvance', moduleName: CORE};\n\n // Two-way bindings\n static twoWayProperty: o.ExternalReference = {name: 'ɵɵtwoWayProperty', moduleName: CORE};\n static twoWayBindingSet: o.ExternalReference = {name: 'ɵɵtwoWayBindingSet', moduleName: CORE};\n static twoWayListener: o.ExternalReference = {name: 'ɵɵtwoWayListener', moduleName: CORE};\n\n static declareLet: o.ExternalReference = {name: 'ɵɵdeclareLet', moduleName: CORE};\n static storeLet: o.ExternalReference = {name: 'ɵɵstoreLet', moduleName: CORE};\n static readContextLet: o.ExternalReference = {name: 'ɵɵreadContextLet', moduleName: CORE};\n\n static NgOnChangesFeature: o.ExternalReference = {name: 'ɵɵNgOnChangesFeature', moduleName: CORE};\n\n static InheritDefinitionFeature: o.ExternalReference = {\n name: 'ɵɵInheritDefinitionFeature',\n moduleName: CORE,\n };\n\n static CopyDefinitionFeature: o.ExternalReference = {\n name: 'ɵɵCopyDefinitionFeature',\n moduleName: CORE,\n };\n\n static StandaloneFeature: o.ExternalReference = {name: 'ɵɵStandaloneFeature', moduleName: CORE};\n\n static ProvidersFeature: o.ExternalReference = {name: 'ɵɵProvidersFeature', moduleName: CORE};\n\n static HostDirectivesFeature: o.ExternalReference = {\n name: 'ɵɵHostDirectivesFeature',\n moduleName: CORE,\n };\n\n static InputTransformsFeatureFeature: o.ExternalReference = {\n name: 'ɵɵInputTransformsFeature',\n moduleName: CORE,\n };\n\n static listener: o.ExternalReference = {name: 'ɵɵlistener', moduleName: CORE};\n\n static getInheritedFactory: o.ExternalReference = {\n name: 'ɵɵgetInheritedFactory',\n moduleName: CORE,\n };\n\n // sanitization-related functions\n static sanitizeHtml: o.ExternalReference = {name: 'ɵɵsanitizeHtml', moduleName: CORE};\n static sanitizeStyle: o.ExternalReference = {name: 'ɵɵsanitizeStyle', moduleName: CORE};\n static sanitizeResourceUrl: o.ExternalReference = {\n name: 'ɵɵsanitizeResourceUrl',\n moduleName: CORE,\n };\n static sanitizeScript: o.ExternalReference = {name: 'ɵɵsanitizeScript', moduleName: CORE};\n static sanitizeUrl: o.ExternalReference = {name: 'ɵɵsanitizeUrl', moduleName: CORE};\n static sanitizeUrlOrResourceUrl: o.ExternalReference = {\n name: 'ɵɵsanitizeUrlOrResourceUrl',\n moduleName: CORE,\n };\n static trustConstantHtml: o.ExternalReference = {name: 'ɵɵtrustConstantHtml', moduleName: CORE};\n static trustConstantResourceUrl: o.ExternalReference = {\n name: 'ɵɵtrustConstantResourceUrl',\n moduleName: CORE,\n };\n static validateIframeAttribute: o.ExternalReference = {\n name: 'ɵɵvalidateIframeAttribute',\n moduleName: CORE,\n };\n\n // type-checking\n static InputSignalBrandWriteType = {name: 'ɵINPUT_SIGNAL_BRAND_WRITE_TYPE', moduleName: CORE};\n static UnwrapDirectiveSignalInputs = {name: 'ɵUnwrapDirectiveSignalInputs', moduleName: CORE};\n static unwrapWritableSignal = {name: 'ɵunwrapWritableSignal', moduleName: CORE};\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nconst DASH_CASE_REGEXP = /-+([a-z0-9])/g;\n\nexport function dashCaseToCamelCase(input: string): string {\n return input.replace(DASH_CASE_REGEXP, (...m: any[]) => m[1].toUpperCase());\n}\n\nexport function splitAtColon(input: string, defaultValues: string[]): string[] {\n return _splitAt(input, ':', defaultValues);\n}\n\nexport function splitAtPeriod(input: string, defaultValues: string[]): string[] {\n return _splitAt(input, '.', defaultValues);\n}\n\nfunction _splitAt(input: string, character: string, defaultValues: string[]): string[] {\n const characterIndex = input.indexOf(character);\n if (characterIndex == -1) return defaultValues;\n return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];\n}\n\nexport function noUndefined(val: T | undefined): T {\n return val === undefined ? null! : val;\n}\n\nexport function error(msg: string): never {\n throw new Error(`Internal Error: ${msg}`);\n}\n\n// Escape characters that have a special meaning in Regular Expressions\nexport function escapeRegExp(s: string): string {\n return s.replace(/([.*+?^=!:${}()|[\\]\\/\\\\])/g, '\\\\$1');\n}\n\nexport type Byte = number;\n\nexport function utf8Encode(str: string): Byte[] {\n let encoded: Byte[] = [];\n for (let index = 0; index < str.length; index++) {\n let codePoint = str.charCodeAt(index);\n\n // decode surrogate\n // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > index + 1) {\n const low = str.charCodeAt(index + 1);\n if (low >= 0xdc00 && low <= 0xdfff) {\n index++;\n codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;\n }\n }\n\n if (codePoint <= 0x7f) {\n encoded.push(codePoint);\n } else if (codePoint <= 0x7ff) {\n encoded.push(((codePoint >> 6) & 0x1f) | 0xc0, (codePoint & 0x3f) | 0x80);\n } else if (codePoint <= 0xffff) {\n encoded.push(\n (codePoint >> 12) | 0xe0,\n ((codePoint >> 6) & 0x3f) | 0x80,\n (codePoint & 0x3f) | 0x80,\n );\n } else if (codePoint <= 0x1fffff) {\n encoded.push(\n ((codePoint >> 18) & 0x07) | 0xf0,\n ((codePoint >> 12) & 0x3f) | 0x80,\n ((codePoint >> 6) & 0x3f) | 0x80,\n (codePoint & 0x3f) | 0x80,\n );\n }\n }\n\n return encoded;\n}\n\nexport function stringify(token: any): string {\n if (typeof token === 'string') {\n return token;\n }\n\n if (Array.isArray(token)) {\n return '[' + token.map(stringify).join(', ') + ']';\n }\n\n if (token == null) {\n return '' + token;\n }\n\n if (token.overriddenName) {\n return `${token.overriddenName}`;\n }\n\n if (token.name) {\n return `${token.name}`;\n }\n\n if (!token.toString) {\n return 'object';\n }\n\n // WARNING: do not try to `JSON.stringify(token)` here\n // see https://github.com/angular/angular/issues/23440\n const res = token.toString();\n\n if (res == null) {\n return '' + res;\n }\n\n const newLineIndex = res.indexOf('\\n');\n return newLineIndex === -1 ? res : res.substring(0, newLineIndex);\n}\n\nexport class Version {\n public readonly major: string;\n public readonly minor: string;\n public readonly patch: string;\n\n constructor(public full: string) {\n const splits = full.split('.');\n this.major = splits[0];\n this.minor = splits[1];\n this.patch = splits.slice(2).join('.');\n }\n}\n\nexport interface Console {\n log(message: string): void;\n warn(message: string): void;\n}\n\nconst _global: {[name: string]: any} = globalThis;\nexport {_global as global};\n\nexport function newArray(size: number): T[];\nexport function newArray(size: number, value: T): T[];\nexport function newArray(size: number, value?: T): T[] {\n const list: T[] = [];\n for (let i = 0; i < size; i++) {\n list.push(value!);\n }\n return list;\n}\n\n/**\n * Partitions a given array into 2 arrays, based on a boolean value returned by the condition\n * function.\n *\n * @param arr Input array that should be partitioned\n * @param conditionFn Condition function that is called for each item in a given array and returns a\n * boolean value.\n */\nexport function partitionArray(\n arr: (T | F)[],\n conditionFn: (value: T | F) => boolean,\n): [T[], F[]] {\n const truthy: T[] = [];\n const falsy: F[] = [];\n for (const item of arr) {\n (conditionFn(item) ? truthy : falsy).push(item as any);\n }\n return [truthy, falsy];\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {utf8Encode} from '../util';\n\n// https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit\nconst VERSION = 3;\n\nconst JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,';\n\ntype Segment = {\n col0: number;\n sourceUrl?: string;\n sourceLine0?: number;\n sourceCol0?: number;\n};\n\nexport type SourceMap = {\n version: number;\n file?: string;\n sourceRoot: string;\n sources: string[];\n sourcesContent: (string | null)[];\n mappings: string;\n};\n\nexport class SourceMapGenerator {\n private sourcesContent: Map = new Map();\n private lines: Segment[][] = [];\n private lastCol0: number = 0;\n private hasMappings = false;\n\n constructor(private file: string | null = null) {}\n\n // The content is `null` when the content is expected to be loaded using the URL\n addSource(url: string, content: string | null = null): this {\n if (!this.sourcesContent.has(url)) {\n this.sourcesContent.set(url, content);\n }\n return this;\n }\n\n addLine(): this {\n this.lines.push([]);\n this.lastCol0 = 0;\n return this;\n }\n\n addMapping(col0: number, sourceUrl?: string, sourceLine0?: number, sourceCol0?: number): this {\n if (!this.currentLine) {\n throw new Error(`A line must be added before mappings can be added`);\n }\n if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) {\n throw new Error(`Unknown source file \"${sourceUrl}\"`);\n }\n if (col0 == null) {\n throw new Error(`The column in the generated code must be provided`);\n }\n if (col0 < this.lastCol0) {\n throw new Error(`Mapping should be added in output order`);\n }\n if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) {\n throw new Error(`The source location must be provided when a source url is provided`);\n }\n\n this.hasMappings = true;\n this.lastCol0 = col0;\n this.currentLine.push({col0, sourceUrl, sourceLine0, sourceCol0});\n return this;\n }\n\n /**\n * @internal strip this from published d.ts files due to\n * https://github.com/microsoft/TypeScript/issues/36216\n */\n private get currentLine(): Segment[] | null {\n return this.lines.slice(-1)[0];\n }\n\n toJSON(): SourceMap | null {\n if (!this.hasMappings) {\n return null;\n }\n\n const sourcesIndex = new Map();\n const sources: string[] = [];\n const sourcesContent: (string | null)[] = [];\n\n Array.from(this.sourcesContent.keys()).forEach((url: string, i: number) => {\n sourcesIndex.set(url, i);\n sources.push(url);\n sourcesContent.push(this.sourcesContent.get(url) || null);\n });\n\n let mappings: string = '';\n let lastCol0: number = 0;\n let lastSourceIndex: number = 0;\n let lastSourceLine0: number = 0;\n let lastSourceCol0: number = 0;\n\n this.lines.forEach((segments) => {\n lastCol0 = 0;\n\n mappings += segments\n .map((segment) => {\n // zero-based starting column of the line in the generated code\n let segAsStr = toBase64VLQ(segment.col0 - lastCol0);\n lastCol0 = segment.col0;\n\n if (segment.sourceUrl != null) {\n // zero-based index into the “sources” list\n segAsStr += toBase64VLQ(sourcesIndex.get(segment.sourceUrl)! - lastSourceIndex);\n lastSourceIndex = sourcesIndex.get(segment.sourceUrl)!;\n // the zero-based starting line in the original source\n segAsStr += toBase64VLQ(segment.sourceLine0! - lastSourceLine0);\n lastSourceLine0 = segment.sourceLine0!;\n // the zero-based starting column in the original source\n segAsStr += toBase64VLQ(segment.sourceCol0! - lastSourceCol0);\n lastSourceCol0 = segment.sourceCol0!;\n }\n\n return segAsStr;\n })\n .join(',');\n mappings += ';';\n });\n\n mappings = mappings.slice(0, -1);\n\n return {\n 'file': this.file || '',\n 'version': VERSION,\n 'sourceRoot': '',\n 'sources': sources,\n 'sourcesContent': sourcesContent,\n 'mappings': mappings,\n };\n }\n\n toJsComment(): string {\n return this.hasMappings\n ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0))\n : '';\n }\n}\n\nexport function toBase64String(value: string): string {\n let b64 = '';\n const encoded = utf8Encode(value);\n for (let i = 0; i < encoded.length; ) {\n const i1 = encoded[i++];\n const i2 = i < encoded.length ? encoded[i++] : null;\n const i3 = i < encoded.length ? encoded[i++] : null;\n b64 += toBase64Digit(i1 >> 2);\n b64 += toBase64Digit(((i1 & 3) << 4) | (i2 === null ? 0 : i2 >> 4));\n b64 += i2 === null ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 === null ? 0 : i3 >> 6));\n b64 += i2 === null || i3 === null ? '=' : toBase64Digit(i3 & 63);\n }\n\n return b64;\n}\n\nfunction toBase64VLQ(value: number): string {\n value = value < 0 ? (-value << 1) + 1 : value << 1;\n\n let out = '';\n do {\n let digit = value & 31;\n value = value >> 5;\n if (value > 0) {\n digit = digit | 32;\n }\n out += toBase64Digit(digit);\n } while (value > 0);\n\n return out;\n}\n\nconst B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\nfunction toBase64Digit(value: number): string {\n if (value < 0 || value >= 64) {\n throw new Error(`Can only encode value in the range [0, 63]`);\n }\n\n return B64_DIGITS[value];\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ParseSourceSpan} from '../parse_util';\n\nimport * as o from './output_ast';\nimport {SourceMapGenerator} from './source_map';\n\nconst _SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\\\|\\n|\\r|\\$/g;\nconst _LEGAL_IDENTIFIER_RE = /^[$A-Z_][0-9A-Z_$]*$/i;\nconst _INDENT_WITH = ' ';\n\nclass _EmittedLine {\n partsLength = 0;\n parts: string[] = [];\n srcSpans: (ParseSourceSpan | null)[] = [];\n constructor(public indent: number) {}\n}\n\nexport class EmitterVisitorContext {\n static createRoot(): EmitterVisitorContext {\n return new EmitterVisitorContext(0);\n }\n\n private _lines: _EmittedLine[];\n\n constructor(private _indent: number) {\n this._lines = [new _EmittedLine(_indent)];\n }\n\n /**\n * @internal strip this from published d.ts files due to\n * https://github.com/microsoft/TypeScript/issues/36216\n */\n private get _currentLine(): _EmittedLine {\n return this._lines[this._lines.length - 1];\n }\n\n println(from?: {sourceSpan: ParseSourceSpan | null} | null, lastPart: string = ''): void {\n this.print(from || null, lastPart, true);\n }\n\n lineIsEmpty(): boolean {\n return this._currentLine.parts.length === 0;\n }\n\n lineLength(): number {\n return this._currentLine.indent * _INDENT_WITH.length + this._currentLine.partsLength;\n }\n\n print(from: {sourceSpan: ParseSourceSpan | null} | null, part: string, newLine: boolean = false) {\n if (part.length > 0) {\n this._currentLine.parts.push(part);\n this._currentLine.partsLength += part.length;\n this._currentLine.srcSpans.push((from && from.sourceSpan) || null);\n }\n if (newLine) {\n this._lines.push(new _EmittedLine(this._indent));\n }\n }\n\n removeEmptyLastLine() {\n if (this.lineIsEmpty()) {\n this._lines.pop();\n }\n }\n\n incIndent() {\n this._indent++;\n if (this.lineIsEmpty()) {\n this._currentLine.indent = this._indent;\n }\n }\n\n decIndent() {\n this._indent--;\n if (this.lineIsEmpty()) {\n this._currentLine.indent = this._indent;\n }\n }\n\n toSource(): string {\n return this.sourceLines\n .map((l) => (l.parts.length > 0 ? _createIndent(l.indent) + l.parts.join('') : ''))\n .join('\\n');\n }\n\n toSourceMapGenerator(genFilePath: string, startsAtLine: number = 0): SourceMapGenerator {\n const map = new SourceMapGenerator(genFilePath);\n\n let firstOffsetMapped = false;\n const mapFirstOffsetIfNeeded = () => {\n if (!firstOffsetMapped) {\n // Add a single space so that tools won't try to load the file from disk.\n // Note: We are using virtual urls like `ng:///`, so we have to\n // provide a content here.\n map.addSource(genFilePath, ' ').addMapping(0, genFilePath, 0, 0);\n firstOffsetMapped = true;\n }\n };\n\n for (let i = 0; i < startsAtLine; i++) {\n map.addLine();\n mapFirstOffsetIfNeeded();\n }\n\n this.sourceLines.forEach((line, lineIdx) => {\n map.addLine();\n\n const spans = line.srcSpans;\n const parts = line.parts;\n let col0 = line.indent * _INDENT_WITH.length;\n let spanIdx = 0;\n // skip leading parts without source spans\n while (spanIdx < spans.length && !spans[spanIdx]) {\n col0 += parts[spanIdx].length;\n spanIdx++;\n }\n if (spanIdx < spans.length && lineIdx === 0 && col0 === 0) {\n firstOffsetMapped = true;\n } else {\n mapFirstOffsetIfNeeded();\n }\n\n while (spanIdx < spans.length) {\n const span = spans[spanIdx]!;\n const source = span.start.file;\n const sourceLine = span.start.line;\n const sourceCol = span.start.col;\n map\n .addSource(source.url, source.content)\n .addMapping(col0, source.url, sourceLine, sourceCol);\n\n col0 += parts[spanIdx].length;\n spanIdx++;\n\n // assign parts without span or the same span to the previous segment\n while (spanIdx < spans.length && (span === spans[spanIdx] || !spans[spanIdx])) {\n col0 += parts[spanIdx].length;\n spanIdx++;\n }\n }\n });\n\n return map;\n }\n\n spanOf(line: number, column: number): ParseSourceSpan | null {\n const emittedLine = this._lines[line];\n if (emittedLine) {\n let columnsLeft = column - _createIndent(emittedLine.indent).length;\n for (let partIndex = 0; partIndex < emittedLine.parts.length; partIndex++) {\n const part = emittedLine.parts[partIndex];\n if (part.length > columnsLeft) {\n return emittedLine.srcSpans[partIndex];\n }\n columnsLeft -= part.length;\n }\n }\n return null;\n }\n\n /**\n * @internal strip this from published d.ts files due to\n * https://github.com/microsoft/TypeScript/issues/36216\n */\n private get sourceLines(): _EmittedLine[] {\n if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) {\n return this._lines.slice(0, -1);\n }\n return this._lines;\n }\n}\n\nexport abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.ExpressionVisitor {\n constructor(private _escapeDollarInStrings: boolean) {}\n\n protected printLeadingComments(stmt: o.Statement, ctx: EmitterVisitorContext): void {\n if (stmt.leadingComments === undefined) {\n return;\n }\n for (const comment of stmt.leadingComments) {\n if (comment instanceof o.JSDocComment) {\n ctx.print(stmt, `/*${comment.toString()}*/`, comment.trailingNewline);\n } else {\n if (comment.multiline) {\n ctx.print(stmt, `/* ${comment.text} */`, comment.trailingNewline);\n } else {\n comment.text.split('\\n').forEach((line) => {\n ctx.println(stmt, `// ${line}`);\n });\n }\n }\n }\n }\n\n visitExpressionStmt(stmt: o.ExpressionStatement, ctx: EmitterVisitorContext): any {\n this.printLeadingComments(stmt, ctx);\n stmt.expr.visitExpression(this, ctx);\n ctx.println(stmt, ';');\n return null;\n }\n\n visitReturnStmt(stmt: o.ReturnStatement, ctx: EmitterVisitorContext): any {\n this.printLeadingComments(stmt, ctx);\n ctx.print(stmt, `return `);\n stmt.value.visitExpression(this, ctx);\n ctx.println(stmt, ';');\n return null;\n }\n\n visitIfStmt(stmt: o.IfStmt, ctx: EmitterVisitorContext): any {\n this.printLeadingComments(stmt, ctx);\n ctx.print(stmt, `if (`);\n stmt.condition.visitExpression(this, ctx);\n ctx.print(stmt, `) {`);\n const hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0;\n if (stmt.trueCase.length <= 1 && !hasElseCase) {\n ctx.print(stmt, ` `);\n this.visitAllStatements(stmt.trueCase, ctx);\n ctx.removeEmptyLastLine();\n ctx.print(stmt, ` `);\n } else {\n ctx.println();\n ctx.incIndent();\n this.visitAllStatements(stmt.trueCase, ctx);\n ctx.decIndent();\n if (hasElseCase) {\n ctx.println(stmt, `} else {`);\n ctx.incIndent();\n this.visitAllStatements(stmt.falseCase, ctx);\n ctx.decIndent();\n }\n }\n ctx.println(stmt, `}`);\n return null;\n }\n\n abstract visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any;\n\n visitWriteVarExpr(expr: o.WriteVarExpr, ctx: EmitterVisitorContext): any {\n const lineWasEmpty = ctx.lineIsEmpty();\n if (!lineWasEmpty) {\n ctx.print(expr, '(');\n }\n ctx.print(expr, `${expr.name} = `);\n expr.value.visitExpression(this, ctx);\n if (!lineWasEmpty) {\n ctx.print(expr, ')');\n }\n return null;\n }\n visitWriteKeyExpr(expr: o.WriteKeyExpr, ctx: EmitterVisitorContext): any {\n const lineWasEmpty = ctx.lineIsEmpty();\n if (!lineWasEmpty) {\n ctx.print(expr, '(');\n }\n expr.receiver.visitExpression(this, ctx);\n ctx.print(expr, `[`);\n expr.index.visitExpression(this, ctx);\n ctx.print(expr, `] = `);\n expr.value.visitExpression(this, ctx);\n if (!lineWasEmpty) {\n ctx.print(expr, ')');\n }\n return null;\n }\n visitWritePropExpr(expr: o.WritePropExpr, ctx: EmitterVisitorContext): any {\n const lineWasEmpty = ctx.lineIsEmpty();\n if (!lineWasEmpty) {\n ctx.print(expr, '(');\n }\n expr.receiver.visitExpression(this, ctx);\n ctx.print(expr, `.${expr.name} = `);\n expr.value.visitExpression(this, ctx);\n if (!lineWasEmpty) {\n ctx.print(expr, ')');\n }\n return null;\n }\n\n visitInvokeFunctionExpr(expr: o.InvokeFunctionExpr, ctx: EmitterVisitorContext): any {\n const shouldParenthesize = expr.fn instanceof o.ArrowFunctionExpr;\n\n if (shouldParenthesize) {\n ctx.print(expr.fn, '(');\n }\n expr.fn.visitExpression(this, ctx);\n if (shouldParenthesize) {\n ctx.print(expr.fn, ')');\n }\n ctx.print(expr, `(`);\n this.visitAllExpressions(expr.args, ctx, ',');\n ctx.print(expr, `)`);\n return null;\n }\n visitTaggedTemplateExpr(expr: o.TaggedTemplateExpr, ctx: EmitterVisitorContext): any {\n expr.tag.visitExpression(this, ctx);\n ctx.print(expr, '`' + expr.template.elements[0].rawText);\n for (let i = 1; i < expr.template.elements.length; i++) {\n ctx.print(expr, '${');\n expr.template.expressions[i - 1].visitExpression(this, ctx);\n ctx.print(expr, `}${expr.template.elements[i].rawText}`);\n }\n ctx.print(expr, '`');\n return null;\n }\n visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any {\n throw new Error('Abstract emitter cannot visit WrappedNodeExpr.');\n }\n visitTypeofExpr(expr: o.TypeofExpr, ctx: EmitterVisitorContext): any {\n ctx.print(expr, 'typeof ');\n expr.expr.visitExpression(this, ctx);\n }\n visitReadVarExpr(ast: o.ReadVarExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, ast.name);\n return null;\n }\n visitInstantiateExpr(ast: o.InstantiateExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, `new `);\n ast.classExpr.visitExpression(this, ctx);\n ctx.print(ast, `(`);\n this.visitAllExpressions(ast.args, ctx, ',');\n ctx.print(ast, `)`);\n return null;\n }\n\n visitLiteralExpr(ast: o.LiteralExpr, ctx: EmitterVisitorContext): any {\n const value = ast.value;\n if (typeof value === 'string') {\n ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings));\n } else {\n ctx.print(ast, `${value}`);\n }\n return null;\n }\n\n visitLocalizedString(ast: o.LocalizedString, ctx: EmitterVisitorContext): any {\n const head = ast.serializeI18nHead();\n ctx.print(ast, '$localize `' + head.raw);\n for (let i = 1; i < ast.messageParts.length; i++) {\n ctx.print(ast, '${');\n ast.expressions[i - 1].visitExpression(this, ctx);\n ctx.print(ast, `}${ast.serializeI18nTemplatePart(i).raw}`);\n }\n ctx.print(ast, '`');\n return null;\n }\n\n abstract visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any;\n\n visitConditionalExpr(ast: o.ConditionalExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, `(`);\n ast.condition.visitExpression(this, ctx);\n ctx.print(ast, '? ');\n ast.trueCase.visitExpression(this, ctx);\n ctx.print(ast, ': ');\n ast.falseCase!.visitExpression(this, ctx);\n ctx.print(ast, `)`);\n return null;\n }\n\n visitDynamicImportExpr(ast: o.DynamicImportExpr, ctx: EmitterVisitorContext) {\n ctx.print(ast, `import(${ast.url})`);\n }\n\n visitNotExpr(ast: o.NotExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, '!');\n ast.condition.visitExpression(this, ctx);\n return null;\n }\n abstract visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any;\n abstract visitArrowFunctionExpr(ast: o.ArrowFunctionExpr, context: any): any;\n abstract visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, context: any): any;\n\n visitUnaryOperatorExpr(ast: o.UnaryOperatorExpr, ctx: EmitterVisitorContext): any {\n let opStr: string;\n switch (ast.operator) {\n case o.UnaryOperator.Plus:\n opStr = '+';\n break;\n case o.UnaryOperator.Minus:\n opStr = '-';\n break;\n default:\n throw new Error(`Unknown operator ${ast.operator}`);\n }\n if (ast.parens) ctx.print(ast, `(`);\n ctx.print(ast, opStr);\n ast.expr.visitExpression(this, ctx);\n if (ast.parens) ctx.print(ast, `)`);\n return null;\n }\n\n visitBinaryOperatorExpr(ast: o.BinaryOperatorExpr, ctx: EmitterVisitorContext): any {\n let opStr: string;\n switch (ast.operator) {\n case o.BinaryOperator.Equals:\n opStr = '==';\n break;\n case o.BinaryOperator.Identical:\n opStr = '===';\n break;\n case o.BinaryOperator.NotEquals:\n opStr = '!=';\n break;\n case o.BinaryOperator.NotIdentical:\n opStr = '!==';\n break;\n case o.BinaryOperator.And:\n opStr = '&&';\n break;\n case o.BinaryOperator.BitwiseOr:\n opStr = '|';\n break;\n case o.BinaryOperator.BitwiseAnd:\n opStr = '&';\n break;\n case o.BinaryOperator.Or:\n opStr = '||';\n break;\n case o.BinaryOperator.Plus:\n opStr = '+';\n break;\n case o.BinaryOperator.Minus:\n opStr = '-';\n break;\n case o.BinaryOperator.Divide:\n opStr = '/';\n break;\n case o.BinaryOperator.Multiply:\n opStr = '*';\n break;\n case o.BinaryOperator.Modulo:\n opStr = '%';\n break;\n case o.BinaryOperator.Lower:\n opStr = '<';\n break;\n case o.BinaryOperator.LowerEquals:\n opStr = '<=';\n break;\n case o.BinaryOperator.Bigger:\n opStr = '>';\n break;\n case o.BinaryOperator.BiggerEquals:\n opStr = '>=';\n break;\n case o.BinaryOperator.NullishCoalesce:\n opStr = '??';\n break;\n default:\n throw new Error(`Unknown operator ${ast.operator}`);\n }\n if (ast.parens) ctx.print(ast, `(`);\n ast.lhs.visitExpression(this, ctx);\n ctx.print(ast, ` ${opStr} `);\n ast.rhs.visitExpression(this, ctx);\n if (ast.parens) ctx.print(ast, `)`);\n return null;\n }\n\n visitReadPropExpr(ast: o.ReadPropExpr, ctx: EmitterVisitorContext): any {\n ast.receiver.visitExpression(this, ctx);\n ctx.print(ast, `.`);\n ctx.print(ast, ast.name);\n return null;\n }\n visitReadKeyExpr(ast: o.ReadKeyExpr, ctx: EmitterVisitorContext): any {\n ast.receiver.visitExpression(this, ctx);\n ctx.print(ast, `[`);\n ast.index.visitExpression(this, ctx);\n ctx.print(ast, `]`);\n return null;\n }\n visitLiteralArrayExpr(ast: o.LiteralArrayExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, `[`);\n this.visitAllExpressions(ast.entries, ctx, ',');\n ctx.print(ast, `]`);\n return null;\n }\n visitLiteralMapExpr(ast: o.LiteralMapExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, `{`);\n this.visitAllObjects(\n (entry) => {\n ctx.print(\n ast,\n `${escapeIdentifier(entry.key, this._escapeDollarInStrings, entry.quoted)}:`,\n );\n entry.value.visitExpression(this, ctx);\n },\n ast.entries,\n ctx,\n ',',\n );\n ctx.print(ast, `}`);\n return null;\n }\n visitCommaExpr(ast: o.CommaExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, '(');\n this.visitAllExpressions(ast.parts, ctx, ',');\n ctx.print(ast, ')');\n return null;\n }\n visitAllExpressions(\n expressions: o.Expression[],\n ctx: EmitterVisitorContext,\n separator: string,\n ): void {\n this.visitAllObjects((expr) => expr.visitExpression(this, ctx), expressions, ctx, separator);\n }\n\n visitAllObjects(\n handler: (t: T) => void,\n expressions: T[],\n ctx: EmitterVisitorContext,\n separator: string,\n ): void {\n let incrementedIndent = false;\n for (let i = 0; i < expressions.length; i++) {\n if (i > 0) {\n if (ctx.lineLength() > 80) {\n ctx.print(null, separator, true);\n if (!incrementedIndent) {\n // continuation are marked with double indent.\n ctx.incIndent();\n ctx.incIndent();\n incrementedIndent = true;\n }\n } else {\n ctx.print(null, separator, false);\n }\n }\n handler(expressions[i]);\n }\n if (incrementedIndent) {\n // continuation are marked with double indent.\n ctx.decIndent();\n ctx.decIndent();\n }\n }\n\n visitAllStatements(statements: o.Statement[], ctx: EmitterVisitorContext): void {\n statements.forEach((stmt) => stmt.visitStatement(this, ctx));\n }\n}\n\nexport function escapeIdentifier(\n input: string,\n escapeDollar: boolean,\n alwaysQuote: boolean = true,\n): any {\n if (input == null) {\n return null;\n }\n const body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, (...match: string[]) => {\n if (match[0] == '$') {\n return escapeDollar ? '\\\\$' : '$';\n } else if (match[0] == '\\n') {\n return '\\\\n';\n } else if (match[0] == '\\r') {\n return '\\\\r';\n } else {\n return `\\\\${match[0]}`;\n }\n });\n const requiresQuotes = alwaysQuote || !_LEGAL_IDENTIFIER_RE.test(body);\n return requiresQuotes ? `'${body}'` : body;\n}\n\nfunction _createIndent(count: number): string {\n let res = '';\n for (let i = 0; i < count; i++) {\n res += _INDENT_WITH;\n }\n return res;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {escapeIdentifier} from '../output/abstract_emitter';\nimport * as o from '../output/output_ast';\n\nimport {Identifiers} from './r3_identifiers';\n\nexport function typeWithParameters(type: o.Expression, numParams: number): o.ExpressionType {\n if (numParams === 0) {\n return o.expressionType(type);\n }\n const params: o.Type[] = [];\n for (let i = 0; i < numParams; i++) {\n params.push(o.DYNAMIC_TYPE);\n }\n return o.expressionType(type, undefined, params);\n}\n\nexport interface R3Reference {\n value: o.Expression;\n type: o.Expression;\n}\n\n/**\n * Result of compilation of a render3 code unit, e.g. component, directive, pipe, etc.\n */\nexport interface R3CompiledExpression {\n expression: o.Expression;\n type: o.Type;\n statements: o.Statement[];\n}\n\nconst ANIMATE_SYMBOL_PREFIX = '@';\nexport function prepareSyntheticPropertyName(name: string) {\n return `${ANIMATE_SYMBOL_PREFIX}${name}`;\n}\n\nexport function prepareSyntheticListenerName(name: string, phase: string) {\n return `${ANIMATE_SYMBOL_PREFIX}${name}.${phase}`;\n}\n\nexport function getSafePropertyAccessString(accessor: string, name: string): string {\n const escapedName = escapeIdentifier(name, false, false);\n return escapedName !== name ? `${accessor}[${escapedName}]` : `${accessor}.${name}`;\n}\n\nexport function prepareSyntheticListenerFunctionName(name: string, phase: string) {\n return `animation_${name}_${phase}`;\n}\n\nexport function jitOnlyGuardedExpression(expr: o.Expression): o.Expression {\n return guardedExpression('ngJitMode', expr);\n}\n\nexport function devOnlyGuardedExpression(expr: o.Expression): o.Expression {\n return guardedExpression('ngDevMode', expr);\n}\n\nexport function guardedExpression(guard: string, expr: o.Expression): o.Expression {\n const guardExpr = new o.ExternalExpr({name: guard, moduleName: null});\n const guardNotDefined = new o.BinaryOperatorExpr(\n o.BinaryOperator.Identical,\n new o.TypeofExpr(guardExpr),\n o.literal('undefined'),\n );\n const guardUndefinedOrTrue = new o.BinaryOperatorExpr(\n o.BinaryOperator.Or,\n guardNotDefined,\n guardExpr,\n /* type */ undefined,\n /* sourceSpan */ undefined,\n true,\n );\n return new o.BinaryOperatorExpr(o.BinaryOperator.And, guardUndefinedOrTrue, expr);\n}\n\nexport function wrapReference(value: any): R3Reference {\n const wrapped = new o.WrappedNodeExpr(value);\n return {value: wrapped, type: wrapped};\n}\n\nexport function refsToArray(refs: R3Reference[], shouldForwardDeclare: boolean): o.Expression {\n const values = o.literalArr(refs.map((ref) => ref.value));\n return shouldForwardDeclare ? o.arrowFn([], values) : values;\n}\n\n/**\n * Describes an expression that may have been wrapped in a `forwardRef()` guard.\n *\n * This is used when describing expressions that can refer to types that may eagerly reference types\n * that have not yet been defined.\n */\nexport interface MaybeForwardRefExpression {\n /**\n * The unwrapped expression.\n */\n expression: T;\n /**\n * Specified whether the `expression` contains a reference to something that has not yet been\n * defined, and whether the expression is still wrapped in a `forwardRef()` call.\n *\n * If this value is `ForwardRefHandling.None` then the `expression` is safe to use as-is.\n *\n * Otherwise the `expression` was wrapped in a call to `forwardRef()` and must not be eagerly\n * evaluated. Instead it must be wrapped in a function closure that will be evaluated lazily to\n * allow the definition of the expression to be evaluated first.\n *\n * In full AOT compilation it can be safe to unwrap the `forwardRef()` call up front if the\n * expression will actually be evaluated lazily inside a function call after the value of\n * `expression` has been defined.\n *\n * But in other cases, such as partial AOT compilation or JIT compilation the expression will be\n * evaluated eagerly in top level code so will need to continue to be wrapped in a `forwardRef()`\n * call.\n *\n */\n forwardRef: ForwardRefHandling;\n}\n\nexport function createMayBeForwardRefExpression(\n expression: T,\n forwardRef: ForwardRefHandling,\n): MaybeForwardRefExpression {\n return {expression, forwardRef};\n}\n\n/**\n * Convert a `MaybeForwardRefExpression` to an `Expression`, possibly wrapping its expression in a\n * `forwardRef()` call.\n *\n * If `MaybeForwardRefExpression.forwardRef` is `ForwardRefHandling.Unwrapped` then the expression\n * was originally wrapped in a `forwardRef()` call to prevent the value from being eagerly evaluated\n * in the code.\n *\n * See `packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts` and\n * `packages/compiler/src/jit_compiler_facade.ts` for more information.\n */\nexport function convertFromMaybeForwardRefExpression({\n expression,\n forwardRef,\n}: MaybeForwardRefExpression): o.Expression {\n switch (forwardRef) {\n case ForwardRefHandling.None:\n case ForwardRefHandling.Wrapped:\n return expression;\n case ForwardRefHandling.Unwrapped:\n return generateForwardRef(expression);\n }\n}\n\n/**\n * Generate an expression that has the given `expr` wrapped in the following form:\n *\n * ```\n * forwardRef(() => expr)\n * ```\n */\nexport function generateForwardRef(expr: o.Expression): o.Expression {\n return o.importExpr(Identifiers.forwardRef).callFn([o.arrowFn([], expr)]);\n}\n\n/**\n * Specifies how a forward ref has been handled in a MaybeForwardRefExpression\n */\nexport const enum ForwardRefHandling {\n /** The expression was not wrapped in a `forwardRef()` call in the first place. */\n None,\n /** The expression is still wrapped in a `forwardRef()` call. */\n Wrapped,\n /** The expression was wrapped in a `forwardRef()` call but has since been unwrapped. */\n Unwrapped,\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {InjectFlags} from '../core';\nimport * as o from '../output/output_ast';\nimport {Identifiers as R3} from '../render3/r3_identifiers';\n\nimport {R3CompiledExpression, R3Reference, typeWithParameters} from './util';\n\n/**\n * Metadata required by the factory generator to generate a `factory` function for a type.\n */\nexport interface R3ConstructorFactoryMetadata {\n /**\n * String name of the type being generated (used to name the factory function).\n */\n name: string;\n\n /**\n * An expression representing the interface type being constructed.\n */\n type: R3Reference;\n\n /** Number of arguments for the `type`. */\n typeArgumentCount: number;\n\n /**\n * Regardless of whether `fnOrClass` is a constructor function or a user-defined factory, it\n * may have 0 or more parameters, which will be injected according to the `R3DependencyMetadata`\n * for those parameters. If this is `null`, then the type's constructor is nonexistent and will\n * be inherited from `fnOrClass` which is interpreted as the current type. If this is `'invalid'`,\n * then one or more of the parameters wasn't resolvable and any attempt to use these deps will\n * result in a runtime error.\n */\n deps: R3DependencyMetadata[] | 'invalid' | null;\n\n /**\n * Type of the target being created by the factory.\n */\n target: FactoryTarget;\n}\n\nexport enum R3FactoryDelegateType {\n Class = 0,\n Function = 1,\n}\n\nexport interface R3DelegatedFnOrClassMetadata extends R3ConstructorFactoryMetadata {\n delegate: o.Expression;\n delegateType: R3FactoryDelegateType;\n delegateDeps: R3DependencyMetadata[];\n}\n\nexport interface R3ExpressionFactoryMetadata extends R3ConstructorFactoryMetadata {\n expression: o.Expression;\n}\n\nexport type R3FactoryMetadata =\n | R3ConstructorFactoryMetadata\n | R3DelegatedFnOrClassMetadata\n | R3ExpressionFactoryMetadata;\n\nexport enum FactoryTarget {\n Directive = 0,\n Component = 1,\n Injectable = 2,\n Pipe = 3,\n NgModule = 4,\n}\n\nexport interface R3DependencyMetadata {\n /**\n * An expression representing the token or value to be injected.\n * Or `null` if the dependency could not be resolved - making it invalid.\n */\n token: o.Expression | null;\n\n /**\n * If an @Attribute decorator is present, this is the literal type of the attribute name, or\n * the unknown type if no literal type is available (e.g. the attribute name is an expression).\n * Otherwise it is null;\n */\n attributeNameType: o.Expression | null;\n\n /**\n * Whether the dependency has an @Host qualifier.\n */\n host: boolean;\n\n /**\n * Whether the dependency has an @Optional qualifier.\n */\n optional: boolean;\n\n /**\n * Whether the dependency has an @Self qualifier.\n */\n self: boolean;\n\n /**\n * Whether the dependency has an @SkipSelf qualifier.\n */\n skipSelf: boolean;\n}\n\n/**\n * Construct a factory function expression for the given `R3FactoryMetadata`.\n */\nexport function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpression {\n const t = o.variable('__ngFactoryType__');\n let baseFactoryVar: o.ReadVarExpr | null = null;\n\n // The type to instantiate via constructor invocation. If there is no delegated factory, meaning\n // this type is always created by constructor invocation, then this is the type-to-create\n // parameter provided by the user (t) if specified, or the current type if not. If there is a\n // delegated factory (which is used to create the current type) then this is only the type-to-\n // create parameter (t).\n const typeForCtor = !isDelegatedFactoryMetadata(meta)\n ? new o.BinaryOperatorExpr(o.BinaryOperator.Or, t, meta.type.value)\n : t;\n\n let ctorExpr: o.Expression | null = null;\n if (meta.deps !== null) {\n // There is a constructor (either explicitly or implicitly defined).\n if (meta.deps !== 'invalid') {\n ctorExpr = new o.InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.target));\n }\n } else {\n // There is no constructor, use the base class' factory to construct typeForCtor.\n baseFactoryVar = o.variable(`ɵ${meta.name}_BaseFactory`);\n ctorExpr = baseFactoryVar.callFn([typeForCtor]);\n }\n\n const body: o.Statement[] = [];\n let retExpr: o.Expression | null = null;\n\n function makeConditionalFactory(nonCtorExpr: o.Expression): o.ReadVarExpr {\n const r = o.variable('__ngConditionalFactory__');\n body.push(r.set(o.NULL_EXPR).toDeclStmt());\n const ctorStmt =\n ctorExpr !== null\n ? r.set(ctorExpr).toStmt()\n : o.importExpr(R3.invalidFactory).callFn([]).toStmt();\n body.push(o.ifStmt(t, [ctorStmt], [r.set(nonCtorExpr).toStmt()]));\n return r;\n }\n\n if (isDelegatedFactoryMetadata(meta)) {\n // This type is created with a delegated factory. If a type parameter is not specified, call\n // the factory instead.\n const delegateArgs = injectDependencies(meta.delegateDeps, meta.target);\n // Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.\n const factoryExpr = new (\n meta.delegateType === R3FactoryDelegateType.Class ? o.InstantiateExpr : o.InvokeFunctionExpr\n )(meta.delegate, delegateArgs);\n retExpr = makeConditionalFactory(factoryExpr);\n } else if (isExpressionFactoryMetadata(meta)) {\n // TODO(alxhub): decide whether to lower the value here or in the caller\n retExpr = makeConditionalFactory(meta.expression);\n } else {\n retExpr = ctorExpr;\n }\n\n if (retExpr === null) {\n // The expression cannot be formed so render an `ɵɵinvalidFactory()` call.\n body.push(o.importExpr(R3.invalidFactory).callFn([]).toStmt());\n } else if (baseFactoryVar !== null) {\n // This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.\n const getInheritedFactoryCall = o.importExpr(R3.getInheritedFactory).callFn([meta.type.value]);\n // Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`\n const baseFactory = new o.BinaryOperatorExpr(\n o.BinaryOperator.Or,\n baseFactoryVar,\n baseFactoryVar.set(getInheritedFactoryCall),\n );\n body.push(new o.ReturnStatement(baseFactory.callFn([typeForCtor])));\n } else {\n // This is straightforward factory, just return it.\n body.push(new o.ReturnStatement(retExpr));\n }\n\n let factoryFn: o.Expression = o.fn(\n [new o.FnParam(t.name, o.DYNAMIC_TYPE)],\n body,\n o.INFERRED_TYPE,\n undefined,\n `${meta.name}_Factory`,\n );\n\n if (baseFactoryVar !== null) {\n // There is a base factory variable so wrap its declaration along with the factory function into\n // an IIFE.\n factoryFn = o\n .arrowFn([], [new o.DeclareVarStmt(baseFactoryVar.name!), new o.ReturnStatement(factoryFn)])\n .callFn([], /* sourceSpan */ undefined, /* pure */ true);\n }\n\n return {\n expression: factoryFn,\n statements: [],\n type: createFactoryType(meta),\n };\n}\n\nexport function createFactoryType(meta: R3FactoryMetadata) {\n const ctorDepsType =\n meta.deps !== null && meta.deps !== 'invalid' ? createCtorDepsType(meta.deps) : o.NONE_TYPE;\n return o.expressionType(\n o.importExpr(R3.FactoryDeclaration, [\n typeWithParameters(meta.type.type, meta.typeArgumentCount),\n ctorDepsType,\n ]),\n );\n}\n\nfunction injectDependencies(deps: R3DependencyMetadata[], target: FactoryTarget): o.Expression[] {\n return deps.map((dep, index) => compileInjectDependency(dep, target, index));\n}\n\nfunction compileInjectDependency(\n dep: R3DependencyMetadata,\n target: FactoryTarget,\n index: number,\n): o.Expression {\n // Interpret the dependency according to its resolved type.\n if (dep.token === null) {\n return o.importExpr(R3.invalidFactoryDep).callFn([o.literal(index)]);\n } else if (dep.attributeNameType === null) {\n // Build up the injection flags according to the metadata.\n const flags =\n InjectFlags.Default |\n (dep.self ? InjectFlags.Self : 0) |\n (dep.skipSelf ? InjectFlags.SkipSelf : 0) |\n (dep.host ? InjectFlags.Host : 0) |\n (dep.optional ? InjectFlags.Optional : 0) |\n (target === FactoryTarget.Pipe ? InjectFlags.ForPipe : 0);\n\n // If this dependency is optional or otherwise has non-default flags, then additional\n // parameters describing how to inject the dependency must be passed to the inject function\n // that's being used.\n let flagsParam: o.LiteralExpr | null =\n flags !== InjectFlags.Default || dep.optional ? o.literal(flags) : null;\n\n // Build up the arguments to the injectFn call.\n const injectArgs = [dep.token];\n if (flagsParam) {\n injectArgs.push(flagsParam);\n }\n const injectFn = getInjectFn(target);\n return o.importExpr(injectFn).callFn(injectArgs);\n } else {\n // The `dep.attributeTypeName` value is defined, which indicates that this is an `@Attribute()`\n // type dependency. For the generated JS we still want to use the `dep.token` value in case the\n // name given for the attribute is not a string literal. For example given `@Attribute(foo())`,\n // we want to generate `ɵɵinjectAttribute(foo())`.\n //\n // The `dep.attributeTypeName` is only actually used (in `createCtorDepType()`) to generate\n // typings.\n return o.importExpr(R3.injectAttribute).callFn([dep.token]);\n }\n}\n\nfunction createCtorDepsType(deps: R3DependencyMetadata[]): o.Type {\n let hasTypes = false;\n const attributeTypes = deps.map((dep) => {\n const type = createCtorDepType(dep);\n if (type !== null) {\n hasTypes = true;\n return type;\n } else {\n return o.literal(null);\n }\n });\n\n if (hasTypes) {\n return o.expressionType(o.literalArr(attributeTypes));\n } else {\n return o.NONE_TYPE;\n }\n}\n\nfunction createCtorDepType(dep: R3DependencyMetadata): o.LiteralMapExpr | null {\n const entries: {key: string; quoted: boolean; value: o.Expression}[] = [];\n\n if (dep.attributeNameType !== null) {\n entries.push({key: 'attribute', value: dep.attributeNameType, quoted: false});\n }\n if (dep.optional) {\n entries.push({key: 'optional', value: o.literal(true), quoted: false});\n }\n if (dep.host) {\n entries.push({key: 'host', value: o.literal(true), quoted: false});\n }\n if (dep.self) {\n entries.push({key: 'self', value: o.literal(true), quoted: false});\n }\n if (dep.skipSelf) {\n entries.push({key: 'skipSelf', value: o.literal(true), quoted: false});\n }\n\n return entries.length > 0 ? o.literalMap(entries) : null;\n}\n\nexport function isDelegatedFactoryMetadata(\n meta: R3FactoryMetadata,\n): meta is R3DelegatedFnOrClassMetadata {\n return (meta as any).delegateType !== undefined;\n}\n\nexport function isExpressionFactoryMetadata(\n meta: R3FactoryMetadata,\n): meta is R3ExpressionFactoryMetadata {\n return (meta as any).expression !== undefined;\n}\n\nfunction getInjectFn(target: FactoryTarget): o.ExternalReference {\n switch (target) {\n case FactoryTarget.Component:\n case FactoryTarget.Directive:\n case FactoryTarget.Pipe:\n return R3.directiveInject;\n case FactoryTarget.NgModule:\n case FactoryTarget.Injectable:\n default:\n return R3.inject;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '../core';\nimport {ParseSourceSpan} from '../parse_util';\n\nexport class ParserError {\n public message: string;\n constructor(\n message: string,\n public input: string,\n public errLocation: string,\n public ctxLocation?: any,\n ) {\n this.message = `Parser Error: ${message} ${errLocation} [${input}] in ${ctxLocation}`;\n }\n}\n\nexport class ParseSpan {\n constructor(\n public start: number,\n public end: number,\n ) {}\n toAbsolute(absoluteOffset: number): AbsoluteSourceSpan {\n return new AbsoluteSourceSpan(absoluteOffset + this.start, absoluteOffset + this.end);\n }\n}\n\nexport abstract class AST {\n constructor(\n public span: ParseSpan,\n /**\n * Absolute location of the expression AST in a source code file.\n */\n public sourceSpan: AbsoluteSourceSpan,\n ) {}\n\n abstract visit(visitor: AstVisitor, context?: any): any;\n\n toString(): string {\n return 'AST';\n }\n}\n\nexport abstract class ASTWithName extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public nameSpan: AbsoluteSourceSpan,\n ) {\n super(span, sourceSpan);\n }\n}\n\nexport class EmptyExpr extends AST {\n override visit(visitor: AstVisitor, context: any = null) {\n // do nothing\n }\n}\n\nexport class ImplicitReceiver extends AST {\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitImplicitReceiver(this, context);\n }\n}\n\n/**\n * Receiver when something is accessed through `this` (e.g. `this.foo`). Note that this class\n * inherits from `ImplicitReceiver`, because accessing something through `this` is treated the\n * same as accessing it implicitly inside of an Angular template (e.g. `[attr.title]=\"this.title\"`\n * is the same as `[attr.title]=\"title\"`.). Inheriting allows for the `this` accesses to be treated\n * the same as implicit ones, except for a couple of exceptions like `$event` and `$any`.\n * TODO: we should find a way for this class not to extend from `ImplicitReceiver` in the future.\n */\nexport class ThisReceiver extends ImplicitReceiver {\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitThisReceiver?.(this, context);\n }\n}\n\n/**\n * Multiple expressions separated by a semicolon.\n */\nexport class Chain extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public expressions: any[],\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitChain(this, context);\n }\n}\n\nexport class Conditional extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public condition: AST,\n public trueExp: AST,\n public falseExp: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitConditional(this, context);\n }\n}\n\nexport class PropertyRead extends ASTWithName {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n nameSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public name: string,\n ) {\n super(span, sourceSpan, nameSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitPropertyRead(this, context);\n }\n}\n\nexport class PropertyWrite extends ASTWithName {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n nameSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public name: string,\n public value: AST,\n ) {\n super(span, sourceSpan, nameSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitPropertyWrite(this, context);\n }\n}\n\nexport class SafePropertyRead extends ASTWithName {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n nameSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public name: string,\n ) {\n super(span, sourceSpan, nameSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitSafePropertyRead(this, context);\n }\n}\n\nexport class KeyedRead extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public key: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitKeyedRead(this, context);\n }\n}\n\nexport class SafeKeyedRead extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public key: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitSafeKeyedRead(this, context);\n }\n}\n\nexport class KeyedWrite extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public key: AST,\n public value: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitKeyedWrite(this, context);\n }\n}\n\nexport class BindingPipe extends ASTWithName {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public exp: AST,\n public name: string,\n public args: any[],\n nameSpan: AbsoluteSourceSpan,\n ) {\n super(span, sourceSpan, nameSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitPipe(this, context);\n }\n}\n\nexport class LiteralPrimitive extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public value: any,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitLiteralPrimitive(this, context);\n }\n}\n\nexport class LiteralArray extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public expressions: any[],\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitLiteralArray(this, context);\n }\n}\n\nexport type LiteralMapKey = {\n key: string;\n quoted: boolean;\n isShorthandInitialized?: boolean;\n};\n\nexport class LiteralMap extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public keys: LiteralMapKey[],\n public values: any[],\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitLiteralMap(this, context);\n }\n}\n\nexport class Interpolation extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public strings: string[],\n public expressions: AST[],\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitInterpolation(this, context);\n }\n}\n\nexport class Binary extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public operation: string,\n public left: AST,\n public right: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitBinary(this, context);\n }\n}\n\n/**\n * For backwards compatibility reasons, `Unary` inherits from `Binary` and mimics the binary AST\n * node that was originally used. This inheritance relation can be deleted in some future major,\n * after consumers have been given a chance to fully support Unary.\n */\nexport class Unary extends Binary {\n // Redeclare the properties that are inherited from `Binary` as `never`, as consumers should not\n // depend on these fields when operating on `Unary`.\n override left: never = null as never;\n override right: never = null as never;\n override operation: never = null as never;\n\n /**\n * Creates a unary minus expression \"-x\", represented as `Binary` using \"0 - x\".\n */\n static createMinus(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, expr: AST): Unary {\n return new Unary(\n span,\n sourceSpan,\n '-',\n expr,\n '-',\n new LiteralPrimitive(span, sourceSpan, 0),\n expr,\n );\n }\n\n /**\n * Creates a unary plus expression \"+x\", represented as `Binary` using \"x - 0\".\n */\n static createPlus(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, expr: AST): Unary {\n return new Unary(\n span,\n sourceSpan,\n '+',\n expr,\n '-',\n expr,\n new LiteralPrimitive(span, sourceSpan, 0),\n );\n }\n\n /**\n * During the deprecation period this constructor is private, to avoid consumers from creating\n * a `Unary` with the fallback properties for `Binary`.\n */\n private constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public operator: string,\n public expr: AST,\n binaryOp: string,\n binaryLeft: AST,\n binaryRight: AST,\n ) {\n super(span, sourceSpan, binaryOp, binaryLeft, binaryRight);\n }\n\n override visit(visitor: AstVisitor, context: any = null): any {\n if (visitor.visitUnary !== undefined) {\n return visitor.visitUnary(this, context);\n }\n return visitor.visitBinary(this, context);\n }\n}\n\nexport class PrefixNot extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public expression: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitPrefixNot(this, context);\n }\n}\n\nexport class NonNullAssert extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public expression: AST,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitNonNullAssert(this, context);\n }\n}\n\nexport class Call extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public args: AST[],\n public argumentSpan: AbsoluteSourceSpan,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitCall(this, context);\n }\n}\n\nexport class SafeCall extends AST {\n constructor(\n span: ParseSpan,\n sourceSpan: AbsoluteSourceSpan,\n public receiver: AST,\n public args: AST[],\n public argumentSpan: AbsoluteSourceSpan,\n ) {\n super(span, sourceSpan);\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n return visitor.visitSafeCall(this, context);\n }\n}\n\n/**\n * Records the absolute position of a text span in a source file, where `start` and `end` are the\n * starting and ending byte offsets, respectively, of the text span in a source file.\n */\nexport class AbsoluteSourceSpan {\n constructor(\n public readonly start: number,\n public readonly end: number,\n ) {}\n}\n\nexport class ASTWithSource extends AST {\n constructor(\n public ast: T,\n public source: string | null,\n public location: string,\n absoluteOffset: number,\n public errors: ParserError[],\n ) {\n super(\n new ParseSpan(0, source === null ? 0 : source.length),\n new AbsoluteSourceSpan(\n absoluteOffset,\n source === null ? absoluteOffset : absoluteOffset + source.length,\n ),\n );\n }\n override visit(visitor: AstVisitor, context: any = null): any {\n if (visitor.visitASTWithSource) {\n return visitor.visitASTWithSource(this, context);\n }\n return this.ast.visit(visitor, context);\n }\n override toString(): string {\n return `${this.source} in ${this.location}`;\n }\n}\n\n/**\n * TemplateBinding refers to a particular key-value pair in a microsyntax\n * expression. A few examples are:\n *\n * |---------------------|--------------|---------|--------------|\n * | expression | key | value | binding type |\n * |---------------------|--------------|---------|--------------|\n * | 1. let item | item | null | variable |\n * | 2. of items | ngForOf | items | expression |\n * | 3. let x = y | x | y | variable |\n * | 4. index as i | i | index | variable |\n * | 5. trackBy: func | ngForTrackBy | func | expression |\n * | 6. *ngIf=\"cond\" | ngIf | cond | expression |\n * |---------------------|--------------|---------|--------------|\n *\n * (6) is a notable exception because it is a binding from the template key in\n * the LHS of a HTML attribute to the expression in the RHS. All other bindings\n * in the example above are derived solely from the RHS.\n */\nexport type TemplateBinding = VariableBinding | ExpressionBinding;\n\nexport class VariableBinding {\n /**\n * @param sourceSpan entire span of the binding.\n * @param key name of the LHS along with its span.\n * @param value optional value for the RHS along with its span.\n */\n constructor(\n public readonly sourceSpan: AbsoluteSourceSpan,\n public readonly key: TemplateBindingIdentifier,\n public readonly value: TemplateBindingIdentifier | null,\n ) {}\n}\n\nexport class ExpressionBinding {\n /**\n * @param sourceSpan entire span of the binding.\n * @param key binding name, like ngForOf, ngForTrackBy, ngIf, along with its\n * span. Note that the length of the span may not be the same as\n * `key.source.length`. For example,\n * 1. key.source = ngFor, key.span is for \"ngFor\"\n * 2. key.source = ngForOf, key.span is for \"of\"\n * 3. key.source = ngForTrackBy, key.span is for \"trackBy\"\n * @param value optional expression for the RHS.\n */\n constructor(\n public readonly sourceSpan: AbsoluteSourceSpan,\n public readonly key: TemplateBindingIdentifier,\n public readonly value: ASTWithSource | null,\n ) {}\n}\n\nexport interface TemplateBindingIdentifier {\n source: string;\n span: AbsoluteSourceSpan;\n}\n\nexport interface AstVisitor {\n /**\n * The `visitUnary` method is declared as optional for backwards compatibility. In an upcoming\n * major release, this method will be made required.\n */\n visitUnary?(ast: Unary, context: any): any;\n visitBinary(ast: Binary, context: any): any;\n visitChain(ast: Chain, context: any): any;\n visitConditional(ast: Conditional, context: any): any;\n /**\n * The `visitThisReceiver` method is declared as optional for backwards compatibility.\n * In an upcoming major release, this method will be made required.\n */\n visitThisReceiver?(ast: ThisReceiver, context: any): any;\n visitImplicitReceiver(ast: ImplicitReceiver, context: any): any;\n visitInterpolation(ast: Interpolation, context: any): any;\n visitKeyedRead(ast: KeyedRead, context: any): any;\n visitKeyedWrite(ast: KeyedWrite, context: any): any;\n visitLiteralArray(ast: LiteralArray, context: any): any;\n visitLiteralMap(ast: LiteralMap, context: any): any;\n visitLiteralPrimitive(ast: LiteralPrimitive, context: any): any;\n visitPipe(ast: BindingPipe, context: any): any;\n visitPrefixNot(ast: PrefixNot, context: any): any;\n visitNonNullAssert(ast: NonNullAssert, context: any): any;\n visitPropertyRead(ast: PropertyRead, context: any): any;\n visitPropertyWrite(ast: PropertyWrite, context: any): any;\n visitSafePropertyRead(ast: SafePropertyRead, context: any): any;\n visitSafeKeyedRead(ast: SafeKeyedRead, context: any): any;\n visitCall(ast: Call, context: any): any;\n visitSafeCall(ast: SafeCall, context: any): any;\n visitASTWithSource?(ast: ASTWithSource, context: any): any;\n /**\n * This function is optionally defined to allow classes that implement this\n * interface to selectively decide if the specified `ast` should be visited.\n * @param ast node to visit\n * @param context context that gets passed to the node and all its children\n */\n visit?(ast: AST, context?: any): any;\n}\n\nexport class RecursiveAstVisitor implements AstVisitor {\n visit(ast: AST, context?: any): any {\n // The default implementation just visits every node.\n // Classes that extend RecursiveAstVisitor should override this function\n // to selectively visit the specified node.\n ast.visit(this, context);\n }\n visitUnary(ast: Unary, context: any): any {\n this.visit(ast.expr, context);\n }\n visitBinary(ast: Binary, context: any): any {\n this.visit(ast.left, context);\n this.visit(ast.right, context);\n }\n visitChain(ast: Chain, context: any): any {\n this.visitAll(ast.expressions, context);\n }\n visitConditional(ast: Conditional, context: any): any {\n this.visit(ast.condition, context);\n this.visit(ast.trueExp, context);\n this.visit(ast.falseExp, context);\n }\n visitPipe(ast: BindingPipe, context: any): any {\n this.visit(ast.exp, context);\n this.visitAll(ast.args, context);\n }\n visitImplicitReceiver(ast: ThisReceiver, context: any): any {}\n visitThisReceiver(ast: ThisReceiver, context: any): any {}\n visitInterpolation(ast: Interpolation, context: any): any {\n this.visitAll(ast.expressions, context);\n }\n visitKeyedRead(ast: KeyedRead, context: any): any {\n this.visit(ast.receiver, context);\n this.visit(ast.key, context);\n }\n visitKeyedWrite(ast: KeyedWrite, context: any): any {\n this.visit(ast.receiver, context);\n this.visit(ast.key, context);\n this.visit(ast.value, context);\n }\n visitLiteralArray(ast: LiteralArray, context: any): any {\n this.visitAll(ast.expressions, context);\n }\n visitLiteralMap(ast: LiteralMap, context: any): any {\n this.visitAll(ast.values, context);\n }\n visitLiteralPrimitive(ast: LiteralPrimitive, context: any): any {}\n visitPrefixNot(ast: PrefixNot, context: any): any {\n this.visit(ast.expression, context);\n }\n visitNonNullAssert(ast: NonNullAssert, context: any): any {\n this.visit(ast.expression, context);\n }\n visitPropertyRead(ast: PropertyRead, context: any): any {\n this.visit(ast.receiver, context);\n }\n visitPropertyWrite(ast: PropertyWrite, context: any): any {\n this.visit(ast.receiver, context);\n this.visit(ast.value, context);\n }\n visitSafePropertyRead(ast: SafePropertyRead, context: any): any {\n this.visit(ast.receiver, context);\n }\n visitSafeKeyedRead(ast: SafeKeyedRead, context: any): any {\n this.visit(ast.receiver, context);\n this.visit(ast.key, context);\n }\n visitCall(ast: Call, context: any): any {\n this.visit(ast.receiver, context);\n this.visitAll(ast.args, context);\n }\n visitSafeCall(ast: SafeCall, context: any): any {\n this.visit(ast.receiver, context);\n this.visitAll(ast.args, context);\n }\n // This is not part of the AstVisitor interface, just a helper method\n visitAll(asts: AST[], context: any): any {\n for (const ast of asts) {\n this.visit(ast, context);\n }\n }\n}\n\nexport class AstTransformer implements AstVisitor {\n visitImplicitReceiver(ast: ImplicitReceiver, context: any): AST {\n return ast;\n }\n\n visitThisReceiver(ast: ThisReceiver, context: any): AST {\n return ast;\n }\n\n visitInterpolation(ast: Interpolation, context: any): AST {\n return new Interpolation(ast.span, ast.sourceSpan, ast.strings, this.visitAll(ast.expressions));\n }\n\n visitLiteralPrimitive(ast: LiteralPrimitive, context: any): AST {\n return new LiteralPrimitive(ast.span, ast.sourceSpan, ast.value);\n }\n\n visitPropertyRead(ast: PropertyRead, context: any): AST {\n return new PropertyRead(\n ast.span,\n ast.sourceSpan,\n ast.nameSpan,\n ast.receiver.visit(this),\n ast.name,\n );\n }\n\n visitPropertyWrite(ast: PropertyWrite, context: any): AST {\n return new PropertyWrite(\n ast.span,\n ast.sourceSpan,\n ast.nameSpan,\n ast.receiver.visit(this),\n ast.name,\n ast.value.visit(this),\n );\n }\n\n visitSafePropertyRead(ast: SafePropertyRead, context: any): AST {\n return new SafePropertyRead(\n ast.span,\n ast.sourceSpan,\n ast.nameSpan,\n ast.receiver.visit(this),\n ast.name,\n );\n }\n\n visitLiteralArray(ast: LiteralArray, context: any): AST {\n return new LiteralArray(ast.span, ast.sourceSpan, this.visitAll(ast.expressions));\n }\n\n visitLiteralMap(ast: LiteralMap, context: any): AST {\n return new LiteralMap(ast.span, ast.sourceSpan, ast.keys, this.visitAll(ast.values));\n }\n\n visitUnary(ast: Unary, context: any): AST {\n switch (ast.operator) {\n case '+':\n return Unary.createPlus(ast.span, ast.sourceSpan, ast.expr.visit(this));\n case '-':\n return Unary.createMinus(ast.span, ast.sourceSpan, ast.expr.visit(this));\n default:\n throw new Error(`Unknown unary operator ${ast.operator}`);\n }\n }\n\n visitBinary(ast: Binary, context: any): AST {\n return new Binary(\n ast.span,\n ast.sourceSpan,\n ast.operation,\n ast.left.visit(this),\n ast.right.visit(this),\n );\n }\n\n visitPrefixNot(ast: PrefixNot, context: any): AST {\n return new PrefixNot(ast.span, ast.sourceSpan, ast.expression.visit(this));\n }\n\n visitNonNullAssert(ast: NonNullAssert, context: any): AST {\n return new NonNullAssert(ast.span, ast.sourceSpan, ast.expression.visit(this));\n }\n\n visitConditional(ast: Conditional, context: any): AST {\n return new Conditional(\n ast.span,\n ast.sourceSpan,\n ast.condition.visit(this),\n ast.trueExp.visit(this),\n ast.falseExp.visit(this),\n );\n }\n\n visitPipe(ast: BindingPipe, context: any): AST {\n return new BindingPipe(\n ast.span,\n ast.sourceSpan,\n ast.exp.visit(this),\n ast.name,\n this.visitAll(ast.args),\n ast.nameSpan,\n );\n }\n\n visitKeyedRead(ast: KeyedRead, context: any): AST {\n return new KeyedRead(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.key.visit(this));\n }\n\n visitKeyedWrite(ast: KeyedWrite, context: any): AST {\n return new KeyedWrite(\n ast.span,\n ast.sourceSpan,\n ast.receiver.visit(this),\n ast.key.visit(this),\n ast.value.visit(this),\n );\n }\n\n visitCall(ast: Call, context: any): AST {\n return new Call(\n ast.span,\n ast.sourceSpan,\n ast.receiver.visit(this),\n this.visitAll(ast.args),\n ast.argumentSpan,\n );\n }\n\n visitSafeCall(ast: SafeCall, context: any): AST {\n return new SafeCall(\n ast.span,\n ast.sourceSpan,\n ast.receiver.visit(this),\n this.visitAll(ast.args),\n ast.argumentSpan,\n );\n }\n\n visitAll(asts: any[]): any[] {\n const res = [];\n for (let i = 0; i < asts.length; ++i) {\n res[i] = asts[i].visit(this);\n }\n return res;\n }\n\n visitChain(ast: Chain, context: any): AST {\n return new Chain(ast.span, ast.sourceSpan, this.visitAll(ast.expressions));\n }\n\n visitSafeKeyedRead(ast: SafeKeyedRead, context: any): AST {\n return new SafeKeyedRead(\n ast.span,\n ast.sourceSpan,\n ast.receiver.visit(this),\n ast.key.visit(this),\n );\n }\n}\n\n// A transformer that only creates new nodes if the transformer makes a change or\n// a change is made a child node.\nexport class AstMemoryEfficientTransformer implements AstVisitor {\n visitImplicitReceiver(ast: ImplicitReceiver, context: any): AST {\n return ast;\n }\n\n visitThisReceiver(ast: ThisReceiver, context: any): AST {\n return ast;\n }\n\n visitInterpolation(ast: Interpolation, context: any): Interpolation {\n const expressions = this.visitAll(ast.expressions);\n if (expressions !== ast.expressions)\n return new Interpolation(ast.span, ast.sourceSpan, ast.strings, expressions);\n return ast;\n }\n\n visitLiteralPrimitive(ast: LiteralPrimitive, context: any): AST {\n return ast;\n }\n\n visitPropertyRead(ast: PropertyRead, context: any): AST {\n const receiver = ast.receiver.visit(this);\n if (receiver !== ast.receiver) {\n return new PropertyRead(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name);\n }\n return ast;\n }\n\n visitPropertyWrite(ast: PropertyWrite, context: any): AST {\n const receiver = ast.receiver.visit(this);\n const value = ast.value.visit(this);\n if (receiver !== ast.receiver || value !== ast.value) {\n return new PropertyWrite(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name, value);\n }\n return ast;\n }\n\n visitSafePropertyRead(ast: SafePropertyRead, context: any): AST {\n const receiver = ast.receiver.visit(this);\n if (receiver !== ast.receiver) {\n return new SafePropertyRead(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name);\n }\n return ast;\n }\n\n visitLiteralArray(ast: LiteralArray, context: any): AST {\n const expressions = this.visitAll(ast.expressions);\n if (expressions !== ast.expressions) {\n return new LiteralArray(ast.span, ast.sourceSpan, expressions);\n }\n return ast;\n }\n\n visitLiteralMap(ast: LiteralMap, context: any): AST {\n const values = this.visitAll(ast.values);\n if (values !== ast.values) {\n return new LiteralMap(ast.span, ast.sourceSpan, ast.keys, values);\n }\n return ast;\n }\n\n visitUnary(ast: Unary, context: any): AST {\n const expr = ast.expr.visit(this);\n if (expr !== ast.expr) {\n switch (ast.operator) {\n case '+':\n return Unary.createPlus(ast.span, ast.sourceSpan, expr);\n case '-':\n return Unary.createMinus(ast.span, ast.sourceSpan, expr);\n default:\n throw new Error(`Unknown unary operator ${ast.operator}`);\n }\n }\n return ast;\n }\n\n visitBinary(ast: Binary, context: any): AST {\n const left = ast.left.visit(this);\n const right = ast.right.visit(this);\n if (left !== ast.left || right !== ast.right) {\n return new Binary(ast.span, ast.sourceSpan, ast.operation, left, right);\n }\n return ast;\n }\n\n visitPrefixNot(ast: PrefixNot, context: any): AST {\n const expression = ast.expression.visit(this);\n if (expression !== ast.expression) {\n return new PrefixNot(ast.span, ast.sourceSpan, expression);\n }\n return ast;\n }\n\n visitNonNullAssert(ast: NonNullAssert, context: any): AST {\n const expression = ast.expression.visit(this);\n if (expression !== ast.expression) {\n return new NonNullAssert(ast.span, ast.sourceSpan, expression);\n }\n return ast;\n }\n\n visitConditional(ast: Conditional, context: any): AST {\n const condition = ast.condition.visit(this);\n const trueExp = ast.trueExp.visit(this);\n const falseExp = ast.falseExp.visit(this);\n if (condition !== ast.condition || trueExp !== ast.trueExp || falseExp !== ast.falseExp) {\n return new Conditional(ast.span, ast.sourceSpan, condition, trueExp, falseExp);\n }\n return ast;\n }\n\n visitPipe(ast: BindingPipe, context: any): AST {\n const exp = ast.exp.visit(this);\n const args = this.visitAll(ast.args);\n if (exp !== ast.exp || args !== ast.args) {\n return new BindingPipe(ast.span, ast.sourceSpan, exp, ast.name, args, ast.nameSpan);\n }\n return ast;\n }\n\n visitKeyedRead(ast: KeyedRead, context: any): AST {\n const obj = ast.receiver.visit(this);\n const key = ast.key.visit(this);\n if (obj !== ast.receiver || key !== ast.key) {\n return new KeyedRead(ast.span, ast.sourceSpan, obj, key);\n }\n return ast;\n }\n\n visitKeyedWrite(ast: KeyedWrite, context: any): AST {\n const obj = ast.receiver.visit(this);\n const key = ast.key.visit(this);\n const value = ast.value.visit(this);\n if (obj !== ast.receiver || key !== ast.key || value !== ast.value) {\n return new KeyedWrite(ast.span, ast.sourceSpan, obj, key, value);\n }\n return ast;\n }\n\n visitAll(asts: any[]): any[] {\n const res = [];\n let modified = false;\n for (let i = 0; i < asts.length; ++i) {\n const original = asts[i];\n const value = original.visit(this);\n res[i] = value;\n modified = modified || value !== original;\n }\n return modified ? res : asts;\n }\n\n visitChain(ast: Chain, context: any): AST {\n const expressions = this.visitAll(ast.expressions);\n if (expressions !== ast.expressions) {\n return new Chain(ast.span, ast.sourceSpan, expressions);\n }\n return ast;\n }\n\n visitCall(ast: Call, context: any): AST {\n const receiver = ast.receiver.visit(this);\n const args = this.visitAll(ast.args);\n if (receiver !== ast.receiver || args !== ast.args) {\n return new Call(ast.span, ast.sourceSpan, receiver, args, ast.argumentSpan);\n }\n return ast;\n }\n\n visitSafeCall(ast: SafeCall, context: any): AST {\n const receiver = ast.receiver.visit(this);\n const args = this.visitAll(ast.args);\n if (receiver !== ast.receiver || args !== ast.args) {\n return new SafeCall(ast.span, ast.sourceSpan, receiver, args, ast.argumentSpan);\n }\n return ast;\n }\n\n visitSafeKeyedRead(ast: SafeKeyedRead, context: any): AST {\n const obj = ast.receiver.visit(this);\n const key = ast.key.visit(this);\n if (obj !== ast.receiver || key !== ast.key) {\n return new SafeKeyedRead(ast.span, ast.sourceSpan, obj, key);\n }\n return ast;\n }\n}\n\n// Bindings\n\nexport class ParsedProperty {\n public readonly isLiteral: boolean;\n public readonly isAnimation: boolean;\n\n constructor(\n public name: string,\n public expression: ASTWithSource,\n public type: ParsedPropertyType,\n public sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan,\n public valueSpan: ParseSourceSpan | undefined,\n ) {\n this.isLiteral = this.type === ParsedPropertyType.LITERAL_ATTR;\n this.isAnimation = this.type === ParsedPropertyType.ANIMATION;\n }\n}\n\nexport enum ParsedPropertyType {\n DEFAULT,\n LITERAL_ATTR,\n ANIMATION,\n TWO_WAY,\n}\n\nexport enum ParsedEventType {\n // DOM or Directive event\n Regular,\n // Animation specific event\n Animation,\n // Event side of a two-way binding (e.g. `[(property)]=\"expression\"`).\n TwoWay,\n}\n\nexport class ParsedEvent {\n // Regular events have a target\n // Animation events have a phase\n constructor(\n name: string,\n targetOrPhase: string,\n type: ParsedEventType.TwoWay,\n handler: ASTWithSource,\n sourceSpan: ParseSourceSpan,\n handlerSpan: ParseSourceSpan,\n keySpan: ParseSourceSpan,\n );\n\n constructor(\n name: string,\n targetOrPhase: string,\n type: ParsedEventType,\n handler: ASTWithSource,\n sourceSpan: ParseSourceSpan,\n handlerSpan: ParseSourceSpan,\n keySpan: ParseSourceSpan,\n );\n\n constructor(\n public name: string,\n public targetOrPhase: string,\n public type: ParsedEventType,\n public handler: ASTWithSource,\n public sourceSpan: ParseSourceSpan,\n public handlerSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan,\n ) {}\n}\n\n/**\n * ParsedVariable represents a variable declaration in a microsyntax expression.\n */\nexport class ParsedVariable {\n constructor(\n public readonly name: string,\n public readonly value: string,\n public readonly sourceSpan: ParseSourceSpan,\n public readonly keySpan: ParseSourceSpan,\n public readonly valueSpan?: ParseSourceSpan,\n ) {}\n}\n\nexport enum BindingType {\n // A regular binding to a property (e.g. `[property]=\"expression\"`).\n Property,\n // A binding to an element attribute (e.g. `[attr.name]=\"expression\"`).\n Attribute,\n // A binding to a CSS class (e.g. `[class.name]=\"condition\"`).\n Class,\n // A binding to a style rule (e.g. `[style.rule]=\"expression\"`).\n Style,\n // A binding to an animation reference (e.g. `[animate.key]=\"expression\"`).\n Animation,\n // Property side of a two-way binding (e.g. `[(property)]=\"expression\"`).\n TwoWay,\n}\n\nexport class BoundElementProperty {\n constructor(\n public name: string,\n public type: BindingType,\n public securityContext: SecurityContext,\n public value: ASTWithSource,\n public unit: string | null,\n public sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan | undefined,\n public valueSpan: ParseSourceSpan | undefined,\n ) {}\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nexport enum TagContentType {\n RAW_TEXT,\n ESCAPABLE_RAW_TEXT,\n PARSABLE_DATA,\n}\n\nexport interface TagDefinition {\n closedByParent: boolean;\n implicitNamespacePrefix: string | null;\n isVoid: boolean;\n ignoreFirstLf: boolean;\n canSelfClose: boolean;\n preventNamespaceInheritance: boolean;\n\n isClosedByChild(name: string): boolean;\n getContentType(prefix?: string): TagContentType;\n}\n\nexport function splitNsName(elementName: string, fatal: boolean = true): [string | null, string] {\n if (elementName[0] != ':') {\n return [null, elementName];\n }\n\n const colonIndex = elementName.indexOf(':', 1);\n\n if (colonIndex === -1) {\n if (fatal) {\n throw new Error(`Unsupported format \"${elementName}\" expecting \":namespace:name\"`);\n } else {\n return [null, elementName];\n }\n }\n\n return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];\n}\n\n// `` tags work the same regardless the namespace\nexport function isNgContainer(tagName: string): boolean {\n return splitNsName(tagName)[1] === 'ng-container';\n}\n\n// `` tags work the same regardless the namespace\nexport function isNgContent(tagName: string): boolean {\n return splitNsName(tagName)[1] === 'ng-content';\n}\n\n// `` tags work the same regardless the namespace\nexport function isNgTemplate(tagName: string): boolean {\n return splitNsName(tagName)[1] === 'ng-template';\n}\n\nexport function getNsPrefix(fullName: string): string;\nexport function getNsPrefix(fullName: null): null;\nexport function getNsPrefix(fullName: string | null): string | null {\n return fullName === null ? null : splitNsName(fullName)[0];\n}\n\nexport function mergeNsAndName(prefix: string, localName: string): string {\n return prefix ? `:${prefix}:${localName}` : localName;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '../core';\nimport {\n AST,\n ASTWithSource,\n BindingType,\n BoundElementProperty,\n ParsedEvent,\n ParsedEventType,\n} from '../expression_parser/ast';\nimport {I18nMeta} from '../i18n/i18n_ast';\nimport {ParseSourceSpan} from '../parse_util';\n\nexport interface Node {\n sourceSpan: ParseSourceSpan;\n visit(visitor: Visitor): Result;\n}\n\n/**\n * This is an R3 `Node`-like wrapper for a raw `html.Comment` node. We do not currently\n * require the implementation of a visitor for Comments as they are only collected at\n * the top-level of the R3 AST, and only if `Render3ParseOptions['collectCommentNodes']`\n * is true.\n */\nexport class Comment implements Node {\n constructor(\n public value: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n visit(_visitor: Visitor): Result {\n throw new Error('visit() not implemented for Comment');\n }\n}\n\nexport class Text implements Node {\n constructor(\n public value: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitText(this);\n }\n}\n\nexport class BoundText implements Node {\n constructor(\n public value: AST,\n public sourceSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitBoundText(this);\n }\n}\n\n/**\n * Represents a text attribute in the template.\n *\n * `valueSpan` may not be present in cases where there is no value `
`.\n * `keySpan` may also not be present for synthetic attributes from ICU expansions.\n */\nexport class TextAttribute implements Node {\n constructor(\n public name: string,\n public value: string,\n public sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan | undefined,\n public valueSpan?: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitTextAttribute(this);\n }\n}\n\nexport class BoundAttribute implements Node {\n constructor(\n public name: string,\n public type: BindingType,\n public securityContext: SecurityContext,\n public value: AST,\n public unit: string | null,\n public sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan,\n public valueSpan: ParseSourceSpan | undefined,\n public i18n: I18nMeta | undefined,\n ) {}\n\n static fromBoundElementProperty(prop: BoundElementProperty, i18n?: I18nMeta): BoundAttribute {\n if (prop.keySpan === undefined) {\n throw new Error(\n `Unexpected state: keySpan must be defined for bound attributes but was not for ${prop.name}: ${prop.sourceSpan}`,\n );\n }\n return new BoundAttribute(\n prop.name,\n prop.type,\n prop.securityContext,\n prop.value,\n prop.unit,\n prop.sourceSpan,\n prop.keySpan,\n prop.valueSpan,\n i18n,\n );\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitBoundAttribute(this);\n }\n}\n\nexport class BoundEvent implements Node {\n constructor(\n public name: string,\n public type: ParsedEventType,\n public handler: AST,\n public target: string | null,\n public phase: string | null,\n public sourceSpan: ParseSourceSpan,\n public handlerSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan,\n ) {}\n\n static fromParsedEvent(event: ParsedEvent) {\n const target: string | null =\n event.type === ParsedEventType.Regular ? event.targetOrPhase : null;\n const phase: string | null =\n event.type === ParsedEventType.Animation ? event.targetOrPhase : null;\n if (event.keySpan === undefined) {\n throw new Error(\n `Unexpected state: keySpan must be defined for bound event but was not for ${event.name}: ${event.sourceSpan}`,\n );\n }\n return new BoundEvent(\n event.name,\n event.type,\n event.handler,\n target,\n phase,\n event.sourceSpan,\n event.handlerSpan,\n event.keySpan,\n );\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitBoundEvent(this);\n }\n}\n\nexport class Element implements Node {\n constructor(\n public name: string,\n public attributes: TextAttribute[],\n public inputs: BoundAttribute[],\n public outputs: BoundEvent[],\n public children: Node[],\n public references: Reference[],\n public sourceSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan,\n public endSourceSpan: ParseSourceSpan | null,\n public i18n?: I18nMeta,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitElement(this);\n }\n}\n\nexport abstract class DeferredTrigger implements Node {\n constructor(\n public nameSpan: ParseSourceSpan | null,\n public sourceSpan: ParseSourceSpan,\n public prefetchSpan: ParseSourceSpan | null,\n public whenOrOnSourceSpan: ParseSourceSpan | null,\n ) {}\n\n visit(visitor: Visitor): Result {\n return visitor.visitDeferredTrigger(this);\n }\n}\n\nexport class BoundDeferredTrigger extends DeferredTrigger {\n constructor(\n public value: AST,\n sourceSpan: ParseSourceSpan,\n prefetchSpan: ParseSourceSpan | null,\n whenSourceSpan: ParseSourceSpan,\n ) {\n // BoundDeferredTrigger is for 'when' triggers. These aren't really \"triggers\" and don't have a\n // nameSpan. Trigger names are the built in event triggers like hover, interaction, etc.\n super(/** nameSpan */ null, sourceSpan, prefetchSpan, whenSourceSpan);\n }\n}\n\nexport class IdleDeferredTrigger extends DeferredTrigger {}\n\nexport class ImmediateDeferredTrigger extends DeferredTrigger {}\n\nexport class HoverDeferredTrigger extends DeferredTrigger {\n constructor(\n public reference: string | null,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n prefetchSpan: ParseSourceSpan | null,\n onSourceSpan: ParseSourceSpan | null,\n ) {\n super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);\n }\n}\n\nexport class TimerDeferredTrigger extends DeferredTrigger {\n constructor(\n public delay: number,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n prefetchSpan: ParseSourceSpan | null,\n onSourceSpan: ParseSourceSpan | null,\n ) {\n super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);\n }\n}\n\nexport class InteractionDeferredTrigger extends DeferredTrigger {\n constructor(\n public reference: string | null,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n prefetchSpan: ParseSourceSpan | null,\n onSourceSpan: ParseSourceSpan | null,\n ) {\n super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);\n }\n}\n\nexport class ViewportDeferredTrigger extends DeferredTrigger {\n constructor(\n public reference: string | null,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n prefetchSpan: ParseSourceSpan | null,\n onSourceSpan: ParseSourceSpan | null,\n ) {\n super(nameSpan, sourceSpan, prefetchSpan, onSourceSpan);\n }\n}\n\nexport class BlockNode {\n constructor(\n public nameSpan: ParseSourceSpan,\n public sourceSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan,\n public endSourceSpan: ParseSourceSpan | null,\n ) {}\n}\n\nexport class DeferredBlockPlaceholder extends BlockNode implements Node {\n constructor(\n public children: Node[],\n public minimumTime: number | null,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitDeferredBlockPlaceholder(this);\n }\n}\n\nexport class DeferredBlockLoading extends BlockNode implements Node {\n constructor(\n public children: Node[],\n public afterTime: number | null,\n public minimumTime: number | null,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitDeferredBlockLoading(this);\n }\n}\n\nexport class DeferredBlockError extends BlockNode implements Node {\n constructor(\n public children: Node[],\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitDeferredBlockError(this);\n }\n}\n\nexport interface DeferredBlockTriggers {\n when?: BoundDeferredTrigger;\n idle?: IdleDeferredTrigger;\n immediate?: ImmediateDeferredTrigger;\n hover?: HoverDeferredTrigger;\n timer?: TimerDeferredTrigger;\n interaction?: InteractionDeferredTrigger;\n viewport?: ViewportDeferredTrigger;\n}\n\nexport class DeferredBlock extends BlockNode implements Node {\n readonly triggers: Readonly;\n readonly prefetchTriggers: Readonly;\n private readonly definedTriggers: (keyof DeferredBlockTriggers)[];\n private readonly definedPrefetchTriggers: (keyof DeferredBlockTriggers)[];\n\n constructor(\n public children: Node[],\n triggers: DeferredBlockTriggers,\n prefetchTriggers: DeferredBlockTriggers,\n public placeholder: DeferredBlockPlaceholder | null,\n public loading: DeferredBlockLoading | null,\n public error: DeferredBlockError | null,\n nameSpan: ParseSourceSpan,\n sourceSpan: ParseSourceSpan,\n public mainBlockSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n this.triggers = triggers;\n this.prefetchTriggers = prefetchTriggers;\n // We cache the keys since we know that they won't change and we\n // don't want to enumarate them every time we're traversing the AST.\n this.definedTriggers = Object.keys(triggers) as (keyof DeferredBlockTriggers)[];\n this.definedPrefetchTriggers = Object.keys(prefetchTriggers) as (keyof DeferredBlockTriggers)[];\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitDeferredBlock(this);\n }\n\n visitAll(visitor: Visitor): void {\n this.visitTriggers(this.definedTriggers, this.triggers, visitor);\n this.visitTriggers(this.definedPrefetchTriggers, this.prefetchTriggers, visitor);\n visitAll(visitor, this.children);\n const remainingBlocks = [this.placeholder, this.loading, this.error].filter(\n (x) => x !== null,\n ) as Array;\n visitAll(visitor, remainingBlocks);\n }\n\n private visitTriggers(\n keys: (keyof DeferredBlockTriggers)[],\n triggers: DeferredBlockTriggers,\n visitor: Visitor,\n ) {\n visitAll(\n visitor,\n keys.map((k) => triggers[k]!),\n );\n }\n}\n\nexport class SwitchBlock extends BlockNode implements Node {\n constructor(\n public expression: AST,\n public cases: SwitchBlockCase[],\n /**\n * These blocks are only captured to allow for autocompletion in the language service. They\n * aren't meant to be processed in any other way.\n */\n public unknownBlocks: UnknownBlock[],\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n nameSpan: ParseSourceSpan,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitSwitchBlock(this);\n }\n}\n\nexport class SwitchBlockCase extends BlockNode implements Node {\n constructor(\n public expression: AST | null,\n public children: Node[],\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n nameSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitSwitchBlockCase(this);\n }\n}\n\nexport class ForLoopBlock extends BlockNode implements Node {\n constructor(\n public item: Variable,\n public expression: ASTWithSource,\n public trackBy: ASTWithSource,\n public trackKeywordSpan: ParseSourceSpan,\n public contextVariables: Variable[],\n public children: Node[],\n public empty: ForLoopBlockEmpty | null,\n sourceSpan: ParseSourceSpan,\n public mainBlockSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n nameSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitForLoopBlock(this);\n }\n}\n\nexport class ForLoopBlockEmpty extends BlockNode implements Node {\n constructor(\n public children: Node[],\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n nameSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitForLoopBlockEmpty(this);\n }\n}\n\nexport class IfBlock extends BlockNode implements Node {\n constructor(\n public branches: IfBlockBranch[],\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n nameSpan: ParseSourceSpan,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitIfBlock(this);\n }\n}\n\nexport class IfBlockBranch extends BlockNode implements Node {\n constructor(\n public expression: AST | null,\n public children: Node[],\n public expressionAlias: Variable | null,\n sourceSpan: ParseSourceSpan,\n startSourceSpan: ParseSourceSpan,\n endSourceSpan: ParseSourceSpan | null,\n nameSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {\n super(nameSpan, sourceSpan, startSourceSpan, endSourceSpan);\n }\n\n visit(visitor: Visitor): Result {\n return visitor.visitIfBlockBranch(this);\n }\n}\n\nexport class UnknownBlock implements Node {\n constructor(\n public name: string,\n public sourceSpan: ParseSourceSpan,\n public nameSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor): Result {\n return visitor.visitUnknownBlock(this);\n }\n}\n\nexport class LetDeclaration implements Node {\n constructor(\n public name: string,\n public value: AST,\n public sourceSpan: ParseSourceSpan,\n public nameSpan: ParseSourceSpan,\n public valueSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor): Result {\n return visitor.visitLetDeclaration(this);\n }\n}\n\nexport class Template implements Node {\n constructor(\n // tagName is the name of the container element, if applicable.\n // `null` is a special case for when there is a structural directive on an `ng-template` so\n // the renderer can differentiate between the synthetic template and the one written in the\n // file.\n public tagName: string | null,\n public attributes: TextAttribute[],\n public inputs: BoundAttribute[],\n public outputs: BoundEvent[],\n public templateAttrs: (BoundAttribute | TextAttribute)[],\n public children: Node[],\n public references: Reference[],\n public variables: Variable[],\n public sourceSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan,\n public endSourceSpan: ParseSourceSpan | null,\n public i18n?: I18nMeta,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitTemplate(this);\n }\n}\n\nexport class Content implements Node {\n readonly name = 'ng-content';\n\n constructor(\n public selector: string,\n public attributes: TextAttribute[],\n public children: Node[],\n public sourceSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitContent(this);\n }\n}\n\nexport class Variable implements Node {\n constructor(\n public name: string,\n public value: string,\n public sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan,\n public valueSpan?: ParseSourceSpan,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitVariable(this);\n }\n}\n\nexport class Reference implements Node {\n constructor(\n public name: string,\n public value: string,\n public sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan,\n public valueSpan?: ParseSourceSpan,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitReference(this);\n }\n}\n\nexport class Icu implements Node {\n constructor(\n public vars: {[name: string]: BoundText},\n public placeholders: {[name: string]: Text | BoundText},\n public sourceSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {}\n visit(visitor: Visitor): Result {\n return visitor.visitIcu(this);\n }\n}\n\nexport interface Visitor {\n // Returning a truthy value from `visit()` will prevent `visitAll()` from the call to the typed\n // method and result returned will become the result included in `visitAll()`s result array.\n visit?(node: Node): Result;\n\n visitElement(element: Element): Result;\n visitTemplate(template: Template): Result;\n visitContent(content: Content): Result;\n visitVariable(variable: Variable): Result;\n visitReference(reference: Reference): Result;\n visitTextAttribute(attribute: TextAttribute): Result;\n visitBoundAttribute(attribute: BoundAttribute): Result;\n visitBoundEvent(attribute: BoundEvent): Result;\n visitText(text: Text): Result;\n visitBoundText(text: BoundText): Result;\n visitIcu(icu: Icu): Result;\n visitDeferredBlock(deferred: DeferredBlock): Result;\n visitDeferredBlockPlaceholder(block: DeferredBlockPlaceholder): Result;\n visitDeferredBlockError(block: DeferredBlockError): Result;\n visitDeferredBlockLoading(block: DeferredBlockLoading): Result;\n visitDeferredTrigger(trigger: DeferredTrigger): Result;\n visitSwitchBlock(block: SwitchBlock): Result;\n visitSwitchBlockCase(block: SwitchBlockCase): Result;\n visitForLoopBlock(block: ForLoopBlock): Result;\n visitForLoopBlockEmpty(block: ForLoopBlockEmpty): Result;\n visitIfBlock(block: IfBlock): Result;\n visitIfBlockBranch(block: IfBlockBranch): Result;\n visitUnknownBlock(block: UnknownBlock): Result;\n visitLetDeclaration(decl: LetDeclaration): Result;\n}\n\nexport class RecursiveVisitor implements Visitor {\n visitElement(element: Element): void {\n visitAll(this, element.attributes);\n visitAll(this, element.inputs);\n visitAll(this, element.outputs);\n visitAll(this, element.children);\n visitAll(this, element.references);\n }\n visitTemplate(template: Template): void {\n visitAll(this, template.attributes);\n visitAll(this, template.inputs);\n visitAll(this, template.outputs);\n visitAll(this, template.children);\n visitAll(this, template.references);\n visitAll(this, template.variables);\n }\n visitDeferredBlock(deferred: DeferredBlock): void {\n deferred.visitAll(this);\n }\n visitDeferredBlockPlaceholder(block: DeferredBlockPlaceholder): void {\n visitAll(this, block.children);\n }\n visitDeferredBlockError(block: DeferredBlockError): void {\n visitAll(this, block.children);\n }\n visitDeferredBlockLoading(block: DeferredBlockLoading): void {\n visitAll(this, block.children);\n }\n visitSwitchBlock(block: SwitchBlock): void {\n visitAll(this, block.cases);\n }\n visitSwitchBlockCase(block: SwitchBlockCase): void {\n visitAll(this, block.children);\n }\n visitForLoopBlock(block: ForLoopBlock): void {\n const blockItems = [block.item, ...block.contextVariables, ...block.children];\n block.empty && blockItems.push(block.empty);\n visitAll(this, blockItems);\n }\n visitForLoopBlockEmpty(block: ForLoopBlockEmpty): void {\n visitAll(this, block.children);\n }\n visitIfBlock(block: IfBlock): void {\n visitAll(this, block.branches);\n }\n visitIfBlockBranch(block: IfBlockBranch): void {\n const blockItems = block.children;\n block.expressionAlias && blockItems.push(block.expressionAlias);\n visitAll(this, blockItems);\n }\n visitContent(content: Content): void {\n visitAll(this, content.children);\n }\n visitVariable(variable: Variable): void {}\n visitReference(reference: Reference): void {}\n visitTextAttribute(attribute: TextAttribute): void {}\n visitBoundAttribute(attribute: BoundAttribute): void {}\n visitBoundEvent(attribute: BoundEvent): void {}\n visitText(text: Text): void {}\n visitBoundText(text: BoundText): void {}\n visitIcu(icu: Icu): void {}\n visitDeferredTrigger(trigger: DeferredTrigger): void {}\n visitUnknownBlock(block: UnknownBlock): void {}\n visitLetDeclaration(decl: LetDeclaration): void {}\n}\n\nexport function visitAll(visitor: Visitor, nodes: Node[]): Result[] {\n const result: Result[] = [];\n if (visitor.visit) {\n for (const node of nodes) {\n visitor.visit(node) || node.visit(visitor);\n }\n } else {\n for (const node of nodes) {\n const newNode = node.visit(visitor);\n if (newNode) {\n result.push(newNode);\n }\n }\n }\n return result;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ParseSourceSpan} from '../parse_util';\n\n/**\n * Describes the text contents of a placeholder as it appears in an ICU expression, including its\n * source span information.\n */\nexport interface MessagePlaceholder {\n /** The text contents of the placeholder */\n text: string;\n\n /** The source span of the placeholder */\n sourceSpan: ParseSourceSpan;\n}\n\nexport class Message {\n sources: MessageSpan[];\n id: string;\n /** The ids to use if there are no custom id and if `i18nLegacyMessageIdFormat` is not empty */\n legacyIds: string[] = [];\n\n messageString: string;\n\n /**\n * @param nodes message AST\n * @param placeholders maps placeholder names to static content and their source spans\n * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages)\n * @param meaning\n * @param description\n * @param customId\n */\n constructor(\n public nodes: Node[],\n public placeholders: {[phName: string]: MessagePlaceholder},\n public placeholderToMessage: {[phName: string]: Message},\n public meaning: string,\n public description: string,\n public customId: string,\n ) {\n this.id = this.customId;\n this.messageString = serializeMessage(this.nodes);\n\n if (nodes.length) {\n this.sources = [\n {\n filePath: nodes[0].sourceSpan.start.file.url,\n startLine: nodes[0].sourceSpan.start.line + 1,\n startCol: nodes[0].sourceSpan.start.col + 1,\n endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1,\n endCol: nodes[0].sourceSpan.start.col + 1,\n },\n ];\n } else {\n this.sources = [];\n }\n }\n}\n\n// line and columns indexes are 1 based\nexport interface MessageSpan {\n filePath: string;\n startLine: number;\n startCol: number;\n endLine: number;\n endCol: number;\n}\n\nexport interface Node {\n sourceSpan: ParseSourceSpan;\n visit(visitor: Visitor, context?: any): any;\n}\n\nexport class Text implements Node {\n constructor(\n public value: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitText(this, context);\n }\n}\n\n// TODO(vicb): do we really need this node (vs an array) ?\nexport class Container implements Node {\n constructor(\n public children: Node[],\n public sourceSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitContainer(this, context);\n }\n}\n\nexport class Icu implements Node {\n constructor(\n public expression: string,\n public type: string,\n public cases: {[k: string]: Node},\n public sourceSpan: ParseSourceSpan,\n public expressionPlaceholder?: string,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitIcu(this, context);\n }\n}\n\nexport class TagPlaceholder implements Node {\n constructor(\n public tag: string,\n public attrs: {[k: string]: string},\n public startName: string,\n public closeName: string,\n public children: Node[],\n public isVoid: boolean,\n // TODO sourceSpan should cover all (we need a startSourceSpan and endSourceSpan)\n public sourceSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan | null,\n public endSourceSpan: ParseSourceSpan | null,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitTagPlaceholder(this, context);\n }\n}\n\nexport class Placeholder implements Node {\n constructor(\n public value: string,\n public name: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitPlaceholder(this, context);\n }\n}\n\nexport class IcuPlaceholder implements Node {\n /** Used to capture a message computed from a previous processing pass (see `setI18nRefs()`). */\n previousMessage?: Message;\n constructor(\n public value: Icu,\n public name: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitIcuPlaceholder(this, context);\n }\n}\n\nexport class BlockPlaceholder implements Node {\n constructor(\n public name: string,\n public parameters: string[],\n public startName: string,\n public closeName: string,\n public children: Node[],\n public sourceSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan | null,\n public endSourceSpan: ParseSourceSpan | null,\n ) {}\n\n visit(visitor: Visitor, context?: any): any {\n return visitor.visitBlockPlaceholder(this, context);\n }\n}\n\n/**\n * Each HTML node that is affect by an i18n tag will also have an `i18n` property that is of type\n * `I18nMeta`.\n * This information is either a `Message`, which indicates it is the root of an i18n message, or a\n * `Node`, which indicates is it part of a containing `Message`.\n */\nexport type I18nMeta = Message | Node;\n\nexport interface Visitor {\n visitText(text: Text, context?: any): any;\n visitContainer(container: Container, context?: any): any;\n visitIcu(icu: Icu, context?: any): any;\n visitTagPlaceholder(ph: TagPlaceholder, context?: any): any;\n visitPlaceholder(ph: Placeholder, context?: any): any;\n visitIcuPlaceholder(ph: IcuPlaceholder, context?: any): any;\n visitBlockPlaceholder(ph: BlockPlaceholder, context?: any): any;\n}\n\n// Clone the AST\nexport class CloneVisitor implements Visitor {\n visitText(text: Text, context?: any): Text {\n return new Text(text.value, text.sourceSpan);\n }\n\n visitContainer(container: Container, context?: any): Container {\n const children = container.children.map((n) => n.visit(this, context));\n return new Container(children, container.sourceSpan);\n }\n\n visitIcu(icu: Icu, context?: any): Icu {\n const cases: {[k: string]: Node} = {};\n Object.keys(icu.cases).forEach((key) => (cases[key] = icu.cases[key].visit(this, context)));\n const msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan, icu.expressionPlaceholder);\n return msg;\n }\n\n visitTagPlaceholder(ph: TagPlaceholder, context?: any): TagPlaceholder {\n const children = ph.children.map((n) => n.visit(this, context));\n return new TagPlaceholder(\n ph.tag,\n ph.attrs,\n ph.startName,\n ph.closeName,\n children,\n ph.isVoid,\n ph.sourceSpan,\n ph.startSourceSpan,\n ph.endSourceSpan,\n );\n }\n\n visitPlaceholder(ph: Placeholder, context?: any): Placeholder {\n return new Placeholder(ph.value, ph.name, ph.sourceSpan);\n }\n\n visitIcuPlaceholder(ph: IcuPlaceholder, context?: any): IcuPlaceholder {\n return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan);\n }\n\n visitBlockPlaceholder(ph: BlockPlaceholder, context?: any): BlockPlaceholder {\n const children = ph.children.map((n) => n.visit(this, context));\n return new BlockPlaceholder(\n ph.name,\n ph.parameters,\n ph.startName,\n ph.closeName,\n children,\n ph.sourceSpan,\n ph.startSourceSpan,\n ph.endSourceSpan,\n );\n }\n}\n\n// Visit all the nodes recursively\nexport class RecurseVisitor implements Visitor {\n visitText(text: Text, context?: any): any {}\n\n visitContainer(container: Container, context?: any): any {\n container.children.forEach((child) => child.visit(this));\n }\n\n visitIcu(icu: Icu, context?: any): any {\n Object.keys(icu.cases).forEach((k) => {\n icu.cases[k].visit(this);\n });\n }\n\n visitTagPlaceholder(ph: TagPlaceholder, context?: any): any {\n ph.children.forEach((child) => child.visit(this));\n }\n\n visitPlaceholder(ph: Placeholder, context?: any): any {}\n\n visitIcuPlaceholder(ph: IcuPlaceholder, context?: any): any {}\n\n visitBlockPlaceholder(ph: BlockPlaceholder, context?: any): any {\n ph.children.forEach((child) => child.visit(this));\n }\n}\n\n/**\n * Serialize the message to the Localize backtick string format that would appear in compiled code.\n */\nfunction serializeMessage(messageNodes: Node[]): string {\n const visitor = new LocalizeMessageStringVisitor();\n const str = messageNodes.map((n) => n.visit(visitor)).join('');\n return str;\n}\n\nclass LocalizeMessageStringVisitor implements Visitor {\n visitText(text: Text): any {\n return text.value;\n }\n\n visitContainer(container: Container): any {\n return container.children.map((child) => child.visit(this)).join('');\n }\n\n visitIcu(icu: Icu): any {\n const strCases = Object.keys(icu.cases).map(\n (k: string) => `${k} {${icu.cases[k].visit(this)}}`,\n );\n return `{${icu.expressionPlaceholder}, ${icu.type}, ${strCases.join(' ')}}`;\n }\n\n visitTagPlaceholder(ph: TagPlaceholder): any {\n const children = ph.children.map((child) => child.visit(this)).join('');\n return `{$${ph.startName}}${children}{$${ph.closeName}}`;\n }\n\n visitPlaceholder(ph: Placeholder): any {\n return `{$${ph.name}}`;\n }\n\n visitIcuPlaceholder(ph: IcuPlaceholder): any {\n return `{$${ph.name}}`;\n }\n\n visitBlockPlaceholder(ph: BlockPlaceholder): any {\n const children = ph.children.map((child) => child.visit(this)).join('');\n return `{$${ph.startName}}${children}{$${ph.closeName}}`;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as i18n from '../i18n_ast';\n\nexport abstract class Serializer {\n // - The `placeholders` and `placeholderToMessage` properties are irrelevant in the input messages\n // - The `id` contains the message id that the serializer is expected to use\n // - Placeholder names are already map to public names using the provided mapper\n abstract write(messages: i18n.Message[], locale: string | null): string;\n\n abstract load(\n content: string,\n url: string,\n ): {locale: string | null; i18nNodesByMsgId: {[msgId: string]: i18n.Node[]}};\n\n abstract digest(message: i18n.Message): string;\n\n // Creates a name mapper, see `PlaceholderMapper`\n // Returning `null` means that no name mapping is used.\n createNameMapper(message: i18n.Message): PlaceholderMapper | null {\n return null;\n }\n}\n\n/**\n * A `PlaceholderMapper` converts placeholder names from internal to serialized representation and\n * back.\n *\n * It should be used for serialization format that put constraints on the placeholder names.\n */\nexport interface PlaceholderMapper {\n toPublicName(internalName: string): string | null;\n\n toInternalName(publicName: string): string | null;\n}\n\n/**\n * A simple mapper that take a function to transform an internal name to a public name\n */\nexport class SimplePlaceholderMapper extends i18n.RecurseVisitor implements PlaceholderMapper {\n private internalToPublic: {[k: string]: string} = {};\n private publicToNextId: {[k: string]: number} = {};\n private publicToInternal: {[k: string]: string} = {};\n\n // create a mapping from the message\n constructor(\n message: i18n.Message,\n private mapName: (name: string) => string,\n ) {\n super();\n message.nodes.forEach((node) => node.visit(this));\n }\n\n toPublicName(internalName: string): string | null {\n return this.internalToPublic.hasOwnProperty(internalName)\n ? this.internalToPublic[internalName]\n : null;\n }\n\n toInternalName(publicName: string): string | null {\n return this.publicToInternal.hasOwnProperty(publicName)\n ? this.publicToInternal[publicName]\n : null;\n }\n\n override visitText(text: i18n.Text, context?: any): any {\n return null;\n }\n\n override visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): any {\n this.visitPlaceholderName(ph.startName);\n super.visitTagPlaceholder(ph, context);\n this.visitPlaceholderName(ph.closeName);\n }\n\n override visitPlaceholder(ph: i18n.Placeholder, context?: any): any {\n this.visitPlaceholderName(ph.name);\n }\n\n override visitBlockPlaceholder(ph: i18n.BlockPlaceholder, context?: any): any {\n this.visitPlaceholderName(ph.startName);\n super.visitBlockPlaceholder(ph, context);\n this.visitPlaceholderName(ph.closeName);\n }\n\n override visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any {\n this.visitPlaceholderName(ph.name);\n }\n\n // XMB placeholders could only contains A-Z, 0-9 and _\n private visitPlaceholderName(internalName: string): void {\n if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) {\n return;\n }\n\n let publicName = this.mapName(internalName);\n\n if (this.publicToInternal.hasOwnProperty(publicName)) {\n // Create a new XMB when it has already been used\n const nextId = this.publicToNextId[publicName];\n this.publicToNextId[publicName] = nextId + 1;\n publicName = `${publicName}_${nextId}`;\n } else {\n this.publicToNextId[publicName] = 1;\n }\n\n this.internalToPublic[internalName] = publicName;\n this.publicToInternal[publicName] = internalName;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nexport interface IVisitor {\n visitTag(tag: Tag): any;\n visitText(text: Text): any;\n visitDeclaration(decl: Declaration): any;\n visitDoctype(doctype: Doctype): any;\n}\n\nclass _Visitor implements IVisitor {\n visitTag(tag: Tag): string {\n const strAttrs = this._serializeAttributes(tag.attrs);\n\n if (tag.children.length == 0) {\n return `<${tag.name}${strAttrs}/>`;\n }\n\n const strChildren = tag.children.map((node) => node.visit(this));\n return `<${tag.name}${strAttrs}>${strChildren.join('')}`;\n }\n\n visitText(text: Text): string {\n return text.value;\n }\n\n visitDeclaration(decl: Declaration): string {\n return ``;\n }\n\n private _serializeAttributes(attrs: {[k: string]: string}) {\n const strAttrs = Object.keys(attrs)\n .map((name: string) => `${name}=\"${attrs[name]}\"`)\n .join(' ');\n return strAttrs.length > 0 ? ' ' + strAttrs : '';\n }\n\n visitDoctype(doctype: Doctype): any {\n return ``;\n }\n}\n\nconst _visitor = new _Visitor();\n\nexport function serialize(nodes: Node[]): string {\n return nodes.map((node: Node): string => node.visit(_visitor)).join('');\n}\n\nexport interface Node {\n visit(visitor: IVisitor): any;\n}\n\nexport class Declaration implements Node {\n public attrs: {[k: string]: string} = {};\n\n constructor(unescapedAttrs: {[k: string]: string}) {\n Object.keys(unescapedAttrs).forEach((k: string) => {\n this.attrs[k] = escapeXml(unescapedAttrs[k]);\n });\n }\n\n visit(visitor: IVisitor): any {\n return visitor.visitDeclaration(this);\n }\n}\n\nexport class Doctype implements Node {\n constructor(\n public rootTag: string,\n public dtd: string,\n ) {}\n\n visit(visitor: IVisitor): any {\n return visitor.visitDoctype(this);\n }\n}\n\nexport class Tag implements Node {\n public attrs: {[k: string]: string} = {};\n\n constructor(\n public name: string,\n unescapedAttrs: {[k: string]: string} = {},\n public children: Node[] = [],\n ) {\n Object.keys(unescapedAttrs).forEach((k: string) => {\n this.attrs[k] = escapeXml(unescapedAttrs[k]);\n });\n }\n\n visit(visitor: IVisitor): any {\n return visitor.visitTag(this);\n }\n}\n\nexport class Text implements Node {\n value: string;\n constructor(unescapedValue: string) {\n this.value = escapeXml(unescapedValue);\n }\n\n visit(visitor: IVisitor): any {\n return visitor.visitText(this);\n }\n}\n\nexport class CR extends Text {\n constructor(ws: number = 0) {\n super(`\\n${new Array(ws + 1).join(' ')}`);\n }\n}\n\nconst _ESCAPED_CHARS: [RegExp, string][] = [\n [/&/g, '&'],\n [/\"/g, '"'],\n [/'/g, '''],\n [//g, '>'],\n];\n\n// Escape `_ESCAPED_CHARS` characters in the given text with encoded entities\nexport function escapeXml(text: string): string {\n return _ESCAPED_CHARS.reduce(\n (text: string, entry: [RegExp, string]) => text.replace(entry[0], entry[1]),\n text,\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {decimalDigest} from '../digest';\nimport * as i18n from '../i18n_ast';\n\nimport {PlaceholderMapper, Serializer, SimplePlaceholderMapper} from './serializer';\nimport * as xml from './xml_helper';\n\n/**\n * Defines the `handler` value on the serialized XMB, indicating that Angular\n * generated the bundle. This is useful for analytics in Translation Console.\n *\n * NOTE: Keep in sync with\n * packages/localize/tools/src/extract/translation_files/xmb_translation_serializer.ts.\n */\nconst _XMB_HANDLER = 'angular';\n\nconst _MESSAGES_TAG = 'messagebundle';\nconst _MESSAGE_TAG = 'msg';\nconst _PLACEHOLDER_TAG = 'ph';\nconst _EXAMPLE_TAG = 'ex';\nconst _SOURCE_TAG = 'source';\n\nconst _DOCTYPE = `\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`;\n\nexport class Xmb extends Serializer {\n constructor(private readonly preservePlaceholders: boolean = true) {\n super();\n }\n\n override write(messages: i18n.Message[], locale: string | null): string {\n const exampleVisitor = new ExampleVisitor();\n const visitor = new _Visitor();\n const rootNode = new xml.Tag(_MESSAGES_TAG);\n rootNode.attrs['handler'] = _XMB_HANDLER;\n\n messages.forEach((message) => {\n const attrs: {[k: string]: string} = {id: message.id};\n\n if (message.description) {\n attrs['desc'] = message.description;\n }\n\n if (message.meaning) {\n attrs['meaning'] = message.meaning;\n }\n\n let sourceTags: xml.Tag[] = [];\n message.sources.forEach((source: i18n.MessageSpan) => {\n sourceTags.push(\n new xml.Tag(_SOURCE_TAG, {}, [\n new xml.Text(\n `${source.filePath}:${source.startLine}${\n source.endLine !== source.startLine ? ',' + source.endLine : ''\n }`,\n ),\n ]),\n );\n });\n\n rootNode.children.push(\n new xml.CR(2),\n new xml.Tag(_MESSAGE_TAG, attrs, [...sourceTags, ...visitor.serialize(message.nodes)]),\n );\n });\n\n rootNode.children.push(new xml.CR());\n\n return xml.serialize([\n new xml.Declaration({version: '1.0', encoding: 'UTF-8'}),\n new xml.CR(),\n new xml.Doctype(_MESSAGES_TAG, _DOCTYPE),\n new xml.CR(),\n exampleVisitor.addDefaultExamples(rootNode),\n new xml.CR(),\n ]);\n }\n\n override load(\n content: string,\n url: string,\n ): {locale: string; i18nNodesByMsgId: {[msgId: string]: i18n.Node[]}} {\n throw new Error('Unsupported');\n }\n\n override digest(message: i18n.Message): string {\n return digest(message, this.preservePlaceholders);\n }\n\n override createNameMapper(message: i18n.Message): PlaceholderMapper {\n return new SimplePlaceholderMapper(message, toPublicName);\n }\n}\n\nclass _Visitor implements i18n.Visitor {\n visitText(text: i18n.Text, context?: any): xml.Node[] {\n return [new xml.Text(text.value)];\n }\n\n visitContainer(container: i18n.Container, context: any): xml.Node[] {\n const nodes: xml.Node[] = [];\n container.children.forEach((node: i18n.Node) => nodes.push(...node.visit(this)));\n return nodes;\n }\n\n visitIcu(icu: i18n.Icu, context?: any): xml.Node[] {\n const nodes = [new xml.Text(`{${icu.expressionPlaceholder}, ${icu.type}, `)];\n\n Object.keys(icu.cases).forEach((c: string) => {\n nodes.push(new xml.Text(`${c} {`), ...icu.cases[c].visit(this), new xml.Text(`} `));\n });\n\n nodes.push(new xml.Text(`}`));\n\n return nodes;\n }\n\n visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): xml.Node[] {\n const startTagAsText = new xml.Text(`<${ph.tag}>`);\n const startEx = new xml.Tag(_EXAMPLE_TAG, {}, [startTagAsText]);\n // TC requires PH to have a non empty EX, and uses the text node to show the \"original\" value.\n const startTagPh = new xml.Tag(_PLACEHOLDER_TAG, {name: ph.startName}, [\n startEx,\n startTagAsText,\n ]);\n if (ph.isVoid) {\n // void tags have no children nor closing tags\n return [startTagPh];\n }\n\n const closeTagAsText = new xml.Text(``);\n const closeEx = new xml.Tag(_EXAMPLE_TAG, {}, [closeTagAsText]);\n // TC requires PH to have a non empty EX, and uses the text node to show the \"original\" value.\n const closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, {name: ph.closeName}, [\n closeEx,\n closeTagAsText,\n ]);\n\n return [startTagPh, ...this.serialize(ph.children), closeTagPh];\n }\n\n visitPlaceholder(ph: i18n.Placeholder, context?: any): xml.Node[] {\n const interpolationAsText = new xml.Text(`{{${ph.value}}}`);\n // Example tag needs to be not-empty for TC.\n const exTag = new xml.Tag(_EXAMPLE_TAG, {}, [interpolationAsText]);\n return [\n // TC requires PH to have a non empty EX, and uses the text node to show the \"original\" value.\n new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name}, [exTag, interpolationAsText]),\n ];\n }\n\n visitBlockPlaceholder(ph: i18n.BlockPlaceholder, context?: any): xml.Node[] {\n const startAsText = new xml.Text(`@${ph.name}`);\n const startEx = new xml.Tag(_EXAMPLE_TAG, {}, [startAsText]);\n // TC requires PH to have a non empty EX, and uses the text node to show the \"original\" value.\n const startTagPh = new xml.Tag(_PLACEHOLDER_TAG, {name: ph.startName}, [startEx, startAsText]);\n\n const closeAsText = new xml.Text(`}`);\n const closeEx = new xml.Tag(_EXAMPLE_TAG, {}, [closeAsText]);\n // TC requires PH to have a non empty EX, and uses the text node to show the \"original\" value.\n const closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, {name: ph.closeName}, [closeEx, closeAsText]);\n\n return [startTagPh, ...this.serialize(ph.children), closeTagPh];\n }\n\n visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): xml.Node[] {\n const icuExpression = ph.value.expression;\n const icuType = ph.value.type;\n const icuCases = Object.keys(ph.value.cases)\n .map((value: string) => value + ' {...}')\n .join(' ');\n const icuAsText = new xml.Text(`{${icuExpression}, ${icuType}, ${icuCases}}`);\n const exTag = new xml.Tag(_EXAMPLE_TAG, {}, [icuAsText]);\n return [\n // TC requires PH to have a non empty EX, and uses the text node to show the \"original\" value.\n new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name}, [exTag, icuAsText]),\n ];\n }\n\n serialize(nodes: i18n.Node[]): xml.Node[] {\n return [].concat(...nodes.map((node) => node.visit(this)));\n }\n}\n\nexport function digest(message: i18n.Message, preservePlaceholders: boolean): string {\n return decimalDigest(message, preservePlaceholders);\n}\n\n// TC requires at least one non-empty example on placeholders\nclass ExampleVisitor implements xml.IVisitor {\n addDefaultExamples(node: xml.Node): xml.Node {\n node.visit(this);\n return node;\n }\n\n visitTag(tag: xml.Tag): void {\n if (tag.name === _PLACEHOLDER_TAG) {\n if (!tag.children || tag.children.length == 0) {\n const exText = new xml.Text(tag.attrs['name'] || '...');\n tag.children = [new xml.Tag(_EXAMPLE_TAG, {}, [exText])];\n }\n } else if (tag.children) {\n tag.children.forEach((node) => node.visit(this));\n }\n }\n\n visitText(text: xml.Text): void {}\n visitDeclaration(decl: xml.Declaration): void {}\n visitDoctype(doctype: xml.Doctype): void {}\n}\n\n// XMB/XTB placeholders can only contain A-Z, 0-9 and _\nexport function toPublicName(internalName: string): string {\n return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport * as i18n from '../../../i18n/i18n_ast';\nimport {toPublicName} from '../../../i18n/serializers/xmb';\nimport * as html from '../../../ml_parser/ast';\nimport * as o from '../../../output/output_ast';\n\n/** Name of the i18n attributes **/\nexport const I18N_ATTR = 'i18n';\nexport const I18N_ATTR_PREFIX = 'i18n-';\n\n/** Prefix of var expressions used in ICUs */\nexport const I18N_ICU_VAR_PREFIX = 'VAR_';\n\nexport function isI18nAttribute(name: string): boolean {\n return name === I18N_ATTR || name.startsWith(I18N_ATTR_PREFIX);\n}\n\nexport function hasI18nAttrs(element: html.Element): boolean {\n return element.attrs.some((attr: html.Attribute) => isI18nAttribute(attr.name));\n}\n\nexport function icuFromI18nMessage(message: i18n.Message) {\n return message.nodes[0] as i18n.IcuPlaceholder;\n}\n\nexport function placeholdersToParams(placeholders: Map): {\n [name: string]: o.LiteralExpr;\n} {\n const params: {[name: string]: o.LiteralExpr} = {};\n placeholders.forEach((values: string[], key: string) => {\n params[key] = o.literal(values.length > 1 ? `[${values.join('|')}]` : values[0]);\n });\n return params;\n}\n\n/**\n * Format the placeholder names in a map of placeholders to expressions.\n *\n * The placeholder names are converted from \"internal\" format (e.g. `START_TAG_DIV_1`) to \"external\"\n * format (e.g. `startTagDiv_1`).\n *\n * @param params A map of placeholder names to expressions.\n * @param useCamelCase whether to camelCase the placeholder name when formatting.\n * @returns A new map of formatted placeholder names to expressions.\n */\nexport function formatI18nPlaceholderNamesInMap(\n params: {[name: string]: o.Expression} = {},\n useCamelCase: boolean,\n) {\n const _params: {[key: string]: o.Expression} = {};\n if (params && Object.keys(params).length) {\n Object.keys(params).forEach(\n (key) => (_params[formatI18nPlaceholderName(key, useCamelCase)] = params[key]),\n );\n }\n return _params;\n}\n\n/**\n * Converts internal placeholder names to public-facing format\n * (for example to use in goog.getMsg call).\n * Example: `START_TAG_DIV_1` is converted to `startTagDiv_1`.\n *\n * @param name The placeholder name that should be formatted\n * @returns Formatted placeholder name\n */\nexport function formatI18nPlaceholderName(name: string, useCamelCase: boolean = true): string {\n const publicName = toPublicName(name);\n if (!useCamelCase) {\n return publicName;\n }\n const chunks = publicName.split('_');\n if (chunks.length === 1) {\n // if no \"_\" found - just lowercase the value\n return name.toLowerCase();\n }\n let postfix;\n // eject last element if it's a number\n if (/^\\d+$/.test(chunks[chunks.length - 1])) {\n postfix = chunks.pop();\n }\n let raw = chunks.shift()!.toLowerCase();\n if (chunks.length) {\n raw += chunks.map((c) => c.charAt(0).toUpperCase() + c.slice(1).toLowerCase()).join('');\n }\n return postfix ? `${raw}_${postfix}` : raw;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {InputFlags} from '../../core';\nimport {BindingType} from '../../expression_parser/ast';\nimport {splitNsName} from '../../ml_parser/tags';\nimport * as o from '../../output/output_ast';\nimport {CssSelector} from '../../selector';\nimport * as t from '../r3_ast';\n\nimport {isI18nAttribute} from './i18n/util';\n\n/**\n * Checks whether an object key contains potentially unsafe chars, thus the key should be wrapped in\n * quotes. Note: we do not wrap all keys into quotes, as it may have impact on minification and may\n * not work in some cases when object keys are mangled by a minifier.\n *\n * TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with\n * inputs that contain potentially unsafe chars.\n */\nexport const UNSAFE_OBJECT_KEY_NAME_REGEXP = /[-.]/;\n\n/** Name of the temporary to use during data binding */\nexport const TEMPORARY_NAME = '_t';\n\n/** Name of the context parameter passed into a template function */\nexport const CONTEXT_NAME = 'ctx';\n\n/** Name of the RenderFlag passed into a template function */\nexport const RENDER_FLAGS = 'rf';\n\n/**\n * Creates an allocator for a temporary variable.\n *\n * A variable declaration is added to the statements the first time the allocator is invoked.\n */\nexport function temporaryAllocator(\n pushStatement: (st: o.Statement) => void,\n name: string,\n): () => o.ReadVarExpr {\n let temp: o.ReadVarExpr | null = null;\n return () => {\n if (!temp) {\n pushStatement(new o.DeclareVarStmt(TEMPORARY_NAME, undefined, o.DYNAMIC_TYPE));\n temp = o.variable(name);\n }\n return temp;\n };\n}\n\nexport function invalid(this: t.Visitor, arg: o.Expression | o.Statement | t.Node): never {\n throw new Error(\n `Invalid state: Visitor ${this.constructor.name} doesn't handle ${arg.constructor.name}`,\n );\n}\n\nexport function asLiteral(value: any): o.Expression {\n if (Array.isArray(value)) {\n return o.literalArr(value.map(asLiteral));\n }\n return o.literal(value, o.INFERRED_TYPE);\n}\n\n/**\n * Serializes inputs and outputs for `defineDirective` and `defineComponent`.\n *\n * This will attempt to generate optimized data structures to minimize memory or\n * file size of fully compiled applications.\n */\nexport function conditionallyCreateDirectiveBindingLiteral(\n map: Record<\n string,\n | string\n | {\n classPropertyName: string;\n bindingPropertyName: string;\n transformFunction: o.Expression | null;\n isSignal: boolean;\n }\n >,\n forInputs?: boolean,\n): o.Expression | null {\n const keys = Object.getOwnPropertyNames(map);\n\n if (keys.length === 0) {\n return null;\n }\n\n return o.literalMap(\n keys.map((key) => {\n const value = map[key];\n let declaredName: string;\n let publicName: string;\n let minifiedName: string;\n let expressionValue: o.Expression;\n\n if (typeof value === 'string') {\n // canonical syntax: `dirProp: publicProp`\n declaredName = key;\n minifiedName = key;\n publicName = value;\n expressionValue = asLiteral(publicName);\n } else {\n minifiedName = key;\n declaredName = value.classPropertyName;\n publicName = value.bindingPropertyName;\n\n const differentDeclaringName = publicName !== declaredName;\n const hasDecoratorInputTransform = value.transformFunction !== null;\n let flags = InputFlags.None;\n\n // Build up input flags\n if (value.isSignal) {\n flags |= InputFlags.SignalBased;\n }\n if (hasDecoratorInputTransform) {\n flags |= InputFlags.HasDecoratorInputTransform;\n }\n\n // Inputs, compared to outputs, will track their declared name (for `ngOnChanges`), support\n // decorator input transform functions, or store flag information if there is any.\n if (\n forInputs &&\n (differentDeclaringName || hasDecoratorInputTransform || flags !== InputFlags.None)\n ) {\n const result = [o.literal(flags), asLiteral(publicName)];\n\n if (differentDeclaringName || hasDecoratorInputTransform) {\n result.push(asLiteral(declaredName));\n\n if (hasDecoratorInputTransform) {\n result.push(value.transformFunction!);\n }\n }\n\n expressionValue = o.literalArr(result);\n } else {\n expressionValue = asLiteral(publicName);\n }\n }\n\n return {\n key: minifiedName,\n // put quotes around keys that contain potentially unsafe characters\n quoted: UNSAFE_OBJECT_KEY_NAME_REGEXP.test(minifiedName),\n value: expressionValue,\n };\n }),\n );\n}\n\n/**\n * A representation for an object literal used during codegen of definition objects. The generic\n * type `T` allows to reference a documented type of the generated structure, such that the\n * property names that are set can be resolved to their documented declaration.\n */\nexport class DefinitionMap {\n values: {key: string; quoted: boolean; value: o.Expression}[] = [];\n\n set(key: keyof T, value: o.Expression | null): void {\n if (value) {\n const existing = this.values.find((value) => value.key === key);\n\n if (existing) {\n existing.value = value;\n } else {\n this.values.push({key: key as string, value, quoted: false});\n }\n }\n }\n\n toLiteralMap(): o.LiteralMapExpr {\n return o.literalMap(this.values);\n }\n}\n\n/**\n * Creates a `CssSelector` from an AST node.\n */\nexport function createCssSelectorFromNode(node: t.Element | t.Template): CssSelector {\n const elementName = node instanceof t.Element ? node.name : 'ng-template';\n const attributes = getAttrsForDirectiveMatching(node);\n const cssSelector = new CssSelector();\n const elementNameNoNs = splitNsName(elementName)[1];\n\n cssSelector.setElement(elementNameNoNs);\n\n Object.getOwnPropertyNames(attributes).forEach((name) => {\n const nameNoNs = splitNsName(name)[1];\n const value = attributes[name];\n\n cssSelector.addAttribute(nameNoNs, value);\n if (name.toLowerCase() === 'class') {\n const classes = value.trim().split(/\\s+/);\n classes.forEach((className) => cssSelector.addClassName(className));\n }\n });\n\n return cssSelector;\n}\n\n/**\n * Extract a map of properties to values for a given element or template node, which can be used\n * by the directive matching machinery.\n *\n * @param elOrTpl the element or template in question\n * @return an object set up for directive matching. For attributes on the element/template, this\n * object maps a property name to its (static) value. For any bindings, this map simply maps the\n * property name to an empty string.\n */\nfunction getAttrsForDirectiveMatching(elOrTpl: t.Element | t.Template): {[name: string]: string} {\n const attributesMap: {[name: string]: string} = {};\n\n if (elOrTpl instanceof t.Template && elOrTpl.tagName !== 'ng-template') {\n elOrTpl.templateAttrs.forEach((a) => (attributesMap[a.name] = ''));\n } else {\n elOrTpl.attributes.forEach((a) => {\n if (!isI18nAttribute(a.name)) {\n attributesMap[a.name] = a.value;\n }\n });\n\n elOrTpl.inputs.forEach((i) => {\n if (i.type === BindingType.Property || i.type === BindingType.TwoWay) {\n attributesMap[i.name] = '';\n }\n });\n elOrTpl.outputs.forEach((o) => {\n attributesMap[o.name] = '';\n });\n }\n\n return attributesMap;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from './output/output_ast';\nimport {\n compileFactoryFunction,\n FactoryTarget,\n R3DependencyMetadata,\n R3FactoryDelegateType,\n R3FactoryMetadata,\n} from './render3/r3_factory';\nimport {Identifiers} from './render3/r3_identifiers';\nimport {\n convertFromMaybeForwardRefExpression,\n MaybeForwardRefExpression,\n R3CompiledExpression,\n R3Reference,\n typeWithParameters,\n} from './render3/util';\nimport {DefinitionMap} from './render3/view/util';\n\nexport interface R3InjectableMetadata {\n name: string;\n type: R3Reference;\n typeArgumentCount: number;\n providedIn: MaybeForwardRefExpression;\n useClass?: MaybeForwardRefExpression;\n useFactory?: o.Expression;\n useExisting?: MaybeForwardRefExpression;\n useValue?: MaybeForwardRefExpression;\n deps?: R3DependencyMetadata[];\n}\n\nexport function compileInjectable(\n meta: R3InjectableMetadata,\n resolveForwardRefs: boolean,\n): R3CompiledExpression {\n let result: {expression: o.Expression; statements: o.Statement[]} | null = null;\n\n const factoryMeta: R3FactoryMetadata = {\n name: meta.name,\n type: meta.type,\n typeArgumentCount: meta.typeArgumentCount,\n deps: [],\n target: FactoryTarget.Injectable,\n };\n\n if (meta.useClass !== undefined) {\n // meta.useClass has two modes of operation. Either deps are specified, in which case `new` is\n // used to instantiate the class with dependencies injected, or deps are not specified and\n // the factory of the class is used to instantiate it.\n //\n // A special case exists for useClass: Type where Type is the injectable type itself and no\n // deps are specified, in which case 'useClass' is effectively ignored.\n\n const useClassOnSelf = meta.useClass.expression.isEquivalent(meta.type.value);\n let deps: R3DependencyMetadata[] | undefined = undefined;\n if (meta.deps !== undefined) {\n deps = meta.deps;\n }\n\n if (deps !== undefined) {\n // factory: () => new meta.useClass(...deps)\n result = compileFactoryFunction({\n ...factoryMeta,\n delegate: meta.useClass.expression,\n delegateDeps: deps,\n delegateType: R3FactoryDelegateType.Class,\n });\n } else if (useClassOnSelf) {\n result = compileFactoryFunction(factoryMeta);\n } else {\n result = {\n statements: [],\n expression: delegateToFactory(\n meta.type.value as o.WrappedNodeExpr,\n meta.useClass.expression as o.WrappedNodeExpr,\n resolveForwardRefs,\n ),\n };\n }\n } else if (meta.useFactory !== undefined) {\n if (meta.deps !== undefined) {\n result = compileFactoryFunction({\n ...factoryMeta,\n delegate: meta.useFactory,\n delegateDeps: meta.deps || [],\n delegateType: R3FactoryDelegateType.Function,\n });\n } else {\n result = {statements: [], expression: o.arrowFn([], meta.useFactory.callFn([]))};\n }\n } else if (meta.useValue !== undefined) {\n // Note: it's safe to use `meta.useValue` instead of the `USE_VALUE in meta` check used for\n // client code because meta.useValue is an Expression which will be defined even if the actual\n // value is undefined.\n result = compileFactoryFunction({\n ...factoryMeta,\n expression: meta.useValue.expression,\n });\n } else if (meta.useExisting !== undefined) {\n // useExisting is an `inject` call on the existing token.\n result = compileFactoryFunction({\n ...factoryMeta,\n expression: o.importExpr(Identifiers.inject).callFn([meta.useExisting.expression]),\n });\n } else {\n result = {\n statements: [],\n expression: delegateToFactory(\n meta.type.value as o.WrappedNodeExpr,\n meta.type.value as o.WrappedNodeExpr,\n resolveForwardRefs,\n ),\n };\n }\n\n const token = meta.type.value;\n\n const injectableProps = new DefinitionMap<{\n token: o.Expression;\n factory: o.Expression;\n providedIn: o.Expression;\n }>();\n injectableProps.set('token', token);\n injectableProps.set('factory', result.expression);\n\n // Only generate providedIn property if it has a non-null value\n if ((meta.providedIn.expression as o.LiteralExpr).value !== null) {\n injectableProps.set('providedIn', convertFromMaybeForwardRefExpression(meta.providedIn));\n }\n\n const expression = o\n .importExpr(Identifiers.ɵɵdefineInjectable)\n .callFn([injectableProps.toLiteralMap()], undefined, true);\n return {\n expression,\n type: createInjectableType(meta),\n statements: result.statements,\n };\n}\n\nexport function createInjectableType(meta: R3InjectableMetadata) {\n return new o.ExpressionType(\n o.importExpr(Identifiers.InjectableDeclaration, [\n typeWithParameters(meta.type.type, meta.typeArgumentCount),\n ]),\n );\n}\n\nfunction delegateToFactory(\n type: o.WrappedNodeExpr,\n useType: o.WrappedNodeExpr,\n unwrapForwardRefs: boolean,\n): o.Expression {\n if (type.node === useType.node) {\n // The types are the same, so we can simply delegate directly to the type's factory.\n // ```\n // factory: type.ɵfac\n // ```\n return useType.prop('ɵfac');\n }\n\n if (!unwrapForwardRefs) {\n // The type is not wrapped in a `forwardRef()`, so we create a simple factory function that\n // accepts a sub-type as an argument.\n // ```\n // factory: function(t) { return useType.ɵfac(t); }\n // ```\n return createFactoryFunction(useType);\n }\n\n // The useType is actually wrapped in a `forwardRef()` so we need to resolve that before\n // calling its factory.\n // ```\n // factory: function(t) { return core.resolveForwardRef(type).ɵfac(t); }\n // ```\n const unwrappedType = o.importExpr(Identifiers.resolveForwardRef).callFn([useType]);\n return createFactoryFunction(unwrappedType);\n}\n\nfunction createFactoryFunction(type: o.Expression): o.ArrowFunctionExpr {\n const t = new o.FnParam('__ngFactoryType__', o.DYNAMIC_TYPE);\n return o.arrowFn([t], type.prop('ɵfac').callFn([o.variable(t.name)]));\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nconst UNUSABLE_INTERPOLATION_REGEXPS = [\n /@/, // control flow reserved symbol\n /^\\s*$/, // empty\n /[<>]/, // html tag\n /^[{}]$/, // i18n expansion\n /&(#|[a-z])/i, // character reference,\n /^\\/\\//, // comment\n];\n\nexport function assertInterpolationSymbols(identifier: string, value: any): void {\n if (value != null && !(Array.isArray(value) && value.length == 2)) {\n throw new Error(`Expected '${identifier}' to be an array, [start, end].`);\n } else if (value != null) {\n const start = value[0] as string;\n const end = value[1] as string;\n // Check for unusable interpolation symbols\n UNUSABLE_INTERPOLATION_REGEXPS.forEach((regexp) => {\n if (regexp.test(start) || regexp.test(end)) {\n throw new Error(`['${start}', '${end}'] contains unusable interpolation symbol.`);\n }\n });\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {assertInterpolationSymbols} from '../assertions';\n\nexport class InterpolationConfig {\n static fromArray(markers: [string, string] | null): InterpolationConfig {\n if (!markers) {\n return DEFAULT_INTERPOLATION_CONFIG;\n }\n\n assertInterpolationSymbols('interpolation', markers);\n return new InterpolationConfig(markers[0], markers[1]);\n }\n\n constructor(\n public start: string,\n public end: string,\n ) {}\n}\n\nexport const DEFAULT_INTERPOLATION_CONFIG: InterpolationConfig = new InterpolationConfig(\n '{{',\n '}}',\n);\n\nexport const DEFAULT_CONTAINER_BLOCKS = new Set(['switch']);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nexport const $EOF = 0;\nexport const $BSPACE = 8;\nexport const $TAB = 9;\nexport const $LF = 10;\nexport const $VTAB = 11;\nexport const $FF = 12;\nexport const $CR = 13;\nexport const $SPACE = 32;\nexport const $BANG = 33;\nexport const $DQ = 34;\nexport const $HASH = 35;\nexport const $$ = 36;\nexport const $PERCENT = 37;\nexport const $AMPERSAND = 38;\nexport const $SQ = 39;\nexport const $LPAREN = 40;\nexport const $RPAREN = 41;\nexport const $STAR = 42;\nexport const $PLUS = 43;\nexport const $COMMA = 44;\nexport const $MINUS = 45;\nexport const $PERIOD = 46;\nexport const $SLASH = 47;\nexport const $COLON = 58;\nexport const $SEMICOLON = 59;\nexport const $LT = 60;\nexport const $EQ = 61;\nexport const $GT = 62;\nexport const $QUESTION = 63;\n\nexport const $0 = 48;\nexport const $7 = 55;\nexport const $9 = 57;\n\nexport const $A = 65;\nexport const $E = 69;\nexport const $F = 70;\nexport const $X = 88;\nexport const $Z = 90;\n\nexport const $LBRACKET = 91;\nexport const $BACKSLASH = 92;\nexport const $RBRACKET = 93;\nexport const $CARET = 94;\nexport const $_ = 95;\n\nexport const $a = 97;\nexport const $b = 98;\nexport const $e = 101;\nexport const $f = 102;\nexport const $n = 110;\nexport const $r = 114;\nexport const $t = 116;\nexport const $u = 117;\nexport const $v = 118;\nexport const $x = 120;\nexport const $z = 122;\n\nexport const $LBRACE = 123;\nexport const $BAR = 124;\nexport const $RBRACE = 125;\nexport const $NBSP = 160;\n\nexport const $PIPE = 124;\nexport const $TILDA = 126;\nexport const $AT = 64;\n\nexport const $BT = 96;\n\nexport function isWhitespace(code: number): boolean {\n return (code >= $TAB && code <= $SPACE) || code == $NBSP;\n}\n\nexport function isDigit(code: number): boolean {\n return $0 <= code && code <= $9;\n}\n\nexport function isAsciiLetter(code: number): boolean {\n return (code >= $a && code <= $z) || (code >= $A && code <= $Z);\n}\n\nexport function isAsciiHexDigit(code: number): boolean {\n return (code >= $a && code <= $f) || (code >= $A && code <= $F) || isDigit(code);\n}\n\nexport function isNewLine(code: number): boolean {\n return code === $LF || code === $CR;\n}\n\nexport function isOctalDigit(code: number): boolean {\n return $0 <= code && code <= $7;\n}\n\nexport function isQuote(code: number): boolean {\n return code === $SQ || code === $DQ || code === $BT;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport * as chars from './chars';\nimport {stringify} from './util';\n\nexport class ParseLocation {\n constructor(\n public file: ParseSourceFile,\n public offset: number,\n public line: number,\n public col: number,\n ) {}\n\n toString(): string {\n return this.offset != null ? `${this.file.url}@${this.line}:${this.col}` : this.file.url;\n }\n\n moveBy(delta: number): ParseLocation {\n const source = this.file.content;\n const len = source.length;\n let offset = this.offset;\n let line = this.line;\n let col = this.col;\n while (offset > 0 && delta < 0) {\n offset--;\n delta++;\n const ch = source.charCodeAt(offset);\n if (ch == chars.$LF) {\n line--;\n const priorLine = source\n .substring(0, offset - 1)\n .lastIndexOf(String.fromCharCode(chars.$LF));\n col = priorLine > 0 ? offset - priorLine : offset;\n } else {\n col--;\n }\n }\n while (offset < len && delta > 0) {\n const ch = source.charCodeAt(offset);\n offset++;\n delta--;\n if (ch == chars.$LF) {\n line++;\n col = 0;\n } else {\n col++;\n }\n }\n return new ParseLocation(this.file, offset, line, col);\n }\n\n // Return the source around the location\n // Up to `maxChars` or `maxLines` on each side of the location\n getContext(maxChars: number, maxLines: number): {before: string; after: string} | null {\n const content = this.file.content;\n let startOffset = this.offset;\n\n if (startOffset != null) {\n if (startOffset > content.length - 1) {\n startOffset = content.length - 1;\n }\n let endOffset = startOffset;\n let ctxChars = 0;\n let ctxLines = 0;\n\n while (ctxChars < maxChars && startOffset > 0) {\n startOffset--;\n ctxChars++;\n if (content[startOffset] == '\\n') {\n if (++ctxLines == maxLines) {\n break;\n }\n }\n }\n\n ctxChars = 0;\n ctxLines = 0;\n while (ctxChars < maxChars && endOffset < content.length - 1) {\n endOffset++;\n ctxChars++;\n if (content[endOffset] == '\\n') {\n if (++ctxLines == maxLines) {\n break;\n }\n }\n }\n\n return {\n before: content.substring(startOffset, this.offset),\n after: content.substring(this.offset, endOffset + 1),\n };\n }\n\n return null;\n }\n}\n\nexport class ParseSourceFile {\n constructor(\n public content: string,\n public url: string,\n ) {}\n}\n\nexport class ParseSourceSpan {\n /**\n * Create an object that holds information about spans of tokens/nodes captured during\n * lexing/parsing of text.\n *\n * @param start\n * The location of the start of the span (having skipped leading trivia).\n * Skipping leading trivia makes source-spans more \"user friendly\", since things like HTML\n * elements will appear to begin at the start of the opening tag, rather than at the start of any\n * leading trivia, which could include newlines.\n *\n * @param end\n * The location of the end of the span.\n *\n * @param fullStart\n * The start of the token without skipping the leading trivia.\n * This is used by tooling that splits tokens further, such as extracting Angular interpolations\n * from text tokens. Such tooling creates new source-spans relative to the original token's\n * source-span. If leading trivia characters have been skipped then the new source-spans may be\n * incorrectly offset.\n *\n * @param details\n * Additional information (such as identifier names) that should be associated with the span.\n */\n constructor(\n public start: ParseLocation,\n public end: ParseLocation,\n public fullStart: ParseLocation = start,\n public details: string | null = null,\n ) {}\n\n toString(): string {\n return this.start.file.content.substring(this.start.offset, this.end.offset);\n }\n}\n\nexport enum ParseErrorLevel {\n WARNING,\n ERROR,\n}\n\nexport class ParseError {\n constructor(\n public span: ParseSourceSpan,\n public msg: string,\n public level: ParseErrorLevel = ParseErrorLevel.ERROR,\n ) {}\n\n contextualMessage(): string {\n const ctx = this.span.start.getContext(100, 3);\n return ctx\n ? `${this.msg} (\"${ctx.before}[${ParseErrorLevel[this.level]} ->]${ctx.after}\")`\n : this.msg;\n }\n\n toString(): string {\n const details = this.span.details ? `, ${this.span.details}` : '';\n return `${this.contextualMessage()}: ${this.span.start}${details}`;\n }\n}\n\n/**\n * Generates Source Span object for a given R3 Type for JIT mode.\n *\n * @param kind Component or Directive.\n * @param typeName name of the Component or Directive.\n * @param sourceUrl reference to Component or Directive source.\n * @returns instance of ParseSourceSpan that represent a given Component or Directive.\n */\nexport function r3JitTypeSourceSpan(\n kind: string,\n typeName: string,\n sourceUrl: string,\n): ParseSourceSpan {\n const sourceFileName = `in ${kind} ${typeName} in ${sourceUrl}`;\n const sourceFile = new ParseSourceFile('', sourceFileName);\n return new ParseSourceSpan(\n new ParseLocation(sourceFile, -1, -1, -1),\n new ParseLocation(sourceFile, -1, -1, -1),\n );\n}\n\nlet _anonymousTypeIndex = 0;\n\nexport function identifierName(\n compileIdentifier: CompileIdentifierMetadata | null | undefined,\n): string | null {\n if (!compileIdentifier || !compileIdentifier.reference) {\n return null;\n }\n const ref = compileIdentifier.reference;\n if (ref['__anonymousType']) {\n return ref['__anonymousType'];\n }\n if (ref['__forward_ref__']) {\n // We do not want to try to stringify a `forwardRef()` function because that would cause the\n // inner function to be evaluated too early, defeating the whole point of the `forwardRef`.\n return '__forward_ref__';\n }\n let identifier = stringify(ref);\n if (identifier.indexOf('(') >= 0) {\n // case: anonymous functions!\n identifier = `anonymous_${_anonymousTypeIndex++}`;\n ref['__anonymousType'] = identifier;\n } else {\n identifier = sanitizeIdentifier(identifier);\n }\n return identifier;\n}\n\nexport interface CompileIdentifierMetadata {\n reference: any;\n}\n\nexport function sanitizeIdentifier(name: string): string {\n return name.replace(/\\W/g, '_');\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractEmitterVisitor, EmitterVisitorContext, escapeIdentifier} from './abstract_emitter';\nimport * as o from './output_ast';\n\n/**\n * In TypeScript, tagged template functions expect a \"template object\", which is an array of\n * \"cooked\" strings plus a `raw` property that contains an array of \"raw\" strings. This is\n * typically constructed with a function called `__makeTemplateObject(cooked, raw)`, but it may not\n * be available in all environments.\n *\n * This is a JavaScript polyfill that uses __makeTemplateObject when it's available, but otherwise\n * creates an inline helper with the same functionality.\n *\n * In the inline function, if `Object.defineProperty` is available we use that to attach the `raw`\n * array.\n */\nconst makeTemplateObjectPolyfill =\n '(this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,\"raw\",{value:t}):e.raw=t,e})';\n\nexport abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {\n constructor() {\n super(false);\n }\n\n override visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any {\n throw new Error('Cannot emit a WrappedNodeExpr in Javascript.');\n }\n\n override visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any {\n ctx.print(stmt, `var ${stmt.name}`);\n if (stmt.value) {\n ctx.print(stmt, ' = ');\n stmt.value.visitExpression(this, ctx);\n }\n ctx.println(stmt, `;`);\n return null;\n }\n override visitTaggedTemplateExpr(ast: o.TaggedTemplateExpr, ctx: EmitterVisitorContext): any {\n // The following convoluted piece of code is effectively the downlevelled equivalent of\n // ```\n // tag`...`\n // ```\n // which is effectively like:\n // ```\n // tag(__makeTemplateObject(cooked, raw), expression1, expression2, ...);\n // ```\n const elements = ast.template.elements;\n ast.tag.visitExpression(this, ctx);\n ctx.print(ast, `(${makeTemplateObjectPolyfill}(`);\n ctx.print(ast, `[${elements.map((part) => escapeIdentifier(part.text, false)).join(', ')}], `);\n ctx.print(\n ast,\n `[${elements.map((part) => escapeIdentifier(part.rawText, false)).join(', ')}])`,\n );\n ast.template.expressions.forEach((expression) => {\n ctx.print(ast, ', ');\n expression.visitExpression(this, ctx);\n });\n ctx.print(ast, ')');\n return null;\n }\n override visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, `function${ast.name ? ' ' + ast.name : ''}(`);\n this._visitParams(ast.params, ctx);\n ctx.println(ast, `) {`);\n ctx.incIndent();\n this.visitAllStatements(ast.statements, ctx);\n ctx.decIndent();\n ctx.print(ast, `}`);\n return null;\n }\n override visitArrowFunctionExpr(ast: o.ArrowFunctionExpr, ctx: EmitterVisitorContext): any {\n ctx.print(ast, '(');\n this._visitParams(ast.params, ctx);\n ctx.print(ast, ') =>');\n\n if (Array.isArray(ast.body)) {\n ctx.println(ast, `{`);\n ctx.incIndent();\n this.visitAllStatements(ast.body, ctx);\n ctx.decIndent();\n ctx.print(ast, `}`);\n } else {\n const isObjectLiteral = ast.body instanceof o.LiteralMapExpr;\n\n if (isObjectLiteral) {\n ctx.print(ast, '(');\n }\n\n ast.body.visitExpression(this, ctx);\n\n if (isObjectLiteral) {\n ctx.print(ast, ')');\n }\n }\n\n return null;\n }\n override visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any {\n ctx.print(stmt, `function ${stmt.name}(`);\n this._visitParams(stmt.params, ctx);\n ctx.println(stmt, `) {`);\n ctx.incIndent();\n this.visitAllStatements(stmt.statements, ctx);\n ctx.decIndent();\n ctx.println(stmt, `}`);\n return null;\n }\n override visitLocalizedString(ast: o.LocalizedString, ctx: EmitterVisitorContext): any {\n // The following convoluted piece of code is effectively the downlevelled equivalent of\n // ```\n // $localize `...`\n // ```\n // which is effectively like:\n // ```\n // $localize(__makeTemplateObject(cooked, raw), expression1, expression2, ...);\n // ```\n ctx.print(ast, `$localize(${makeTemplateObjectPolyfill}(`);\n const parts = [ast.serializeI18nHead()];\n for (let i = 1; i < ast.messageParts.length; i++) {\n parts.push(ast.serializeI18nTemplatePart(i));\n }\n ctx.print(ast, `[${parts.map((part) => escapeIdentifier(part.cooked, false)).join(', ')}], `);\n ctx.print(ast, `[${parts.map((part) => escapeIdentifier(part.raw, false)).join(', ')}])`);\n ast.expressions.forEach((expression) => {\n ctx.print(ast, ', ');\n expression.visitExpression(this, ctx);\n });\n ctx.print(ast, ')');\n return null;\n }\n\n private _visitParams(params: o.FnParam[], ctx: EmitterVisitorContext): void {\n this.visitAllObjects((param) => ctx.print(null, param.name), params, ctx, ',');\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * @fileoverview\n * A module to facilitate use of a Trusted Types policy within the JIT\n * compiler. It lazily constructs the Trusted Types policy, providing helper\n * utilities for promoting strings to Trusted Types. When Trusted Types are not\n * available, strings are used as a fallback.\n * @security All use of this module is security-sensitive and should go through\n * security review.\n */\n\nimport {global} from '../util';\n\n/**\n * While Angular only uses Trusted Types internally for the time being,\n * references to Trusted Types could leak into our core.d.ts, which would force\n * anyone compiling against @angular/core to provide the @types/trusted-types\n * package in their compilation unit.\n *\n * Until https://github.com/microsoft/TypeScript/issues/30024 is resolved, we\n * will keep Angular's public API surface free of references to Trusted Types.\n * For internal and semi-private APIs that need to reference Trusted Types, the\n * minimal type definitions for the Trusted Types API provided by this module\n * should be used instead. They are marked as \"declare\" to prevent them from\n * being renamed by compiler optimization.\n *\n * Adapted from\n * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/trusted-types/index.d.ts\n * but restricted to the API surface used within Angular.\n */\n\nexport declare interface TrustedScript {\n __brand__: 'TrustedScript';\n}\n\nexport declare interface TrustedTypePolicyFactory {\n createPolicy(\n policyName: string,\n policyOptions: {\n createScript?: (input: string) => string;\n },\n ): TrustedTypePolicy;\n}\n\nexport declare interface TrustedTypePolicy {\n createScript(input: string): TrustedScript;\n}\n\n/**\n * The Trusted Types policy, or null if Trusted Types are not\n * enabled/supported, or undefined if the policy has not been created yet.\n */\nlet policy: TrustedTypePolicy | null | undefined;\n\n/**\n * Returns the Trusted Types policy, or null if Trusted Types are not\n * enabled/supported. The first call to this function will create the policy.\n */\nfunction getPolicy(): TrustedTypePolicy | null {\n if (policy === undefined) {\n const trustedTypes = global['trustedTypes'] as TrustedTypePolicyFactory | undefined;\n policy = null;\n\n if (trustedTypes) {\n try {\n policy = trustedTypes.createPolicy('angular#unsafe-jit', {\n createScript: (s: string) => s,\n });\n } catch {\n // trustedTypes.createPolicy throws if called with a name that is\n // already registered, even in report-only mode. Until the API changes,\n // catch the error not to break the applications functionally. In such\n // cases, the code will fall back to using strings.\n }\n }\n }\n return policy;\n}\n\n/**\n * Unsafely promote a string to a TrustedScript, falling back to strings when\n * Trusted Types are not available.\n * @security In particular, it must be assured that the provided string will\n * never cause an XSS vulnerability if used in a context that will be\n * interpreted and executed as a script by a browser, e.g. when calling eval.\n */\nfunction trustedScriptFromString(script: string): TrustedScript | string {\n return getPolicy()?.createScript(script) || script;\n}\n\n/**\n * Unsafely call the Function constructor with the given string arguments.\n * @security This is a security-sensitive function; any use of this function\n * must go through security review. In particular, it must be assured that it\n * is only called from the JIT compiler, as use in other code can lead to XSS\n * vulnerabilities.\n */\nexport function newTrustedFunctionForJIT(...args: string[]): Function {\n if (!global['trustedTypes']) {\n // In environments that don't support Trusted Types, fall back to the most\n // straightforward implementation:\n return new Function(...args);\n }\n\n // Chrome currently does not support passing TrustedScript to the Function\n // constructor. The following implements the workaround proposed on the page\n // below, where the Chromium bug is also referenced:\n // https://github.com/w3c/webappsec-trusted-types/wiki/Trusted-Types-for-function-constructor\n const fnArgs = args.slice(0, -1).join(',');\n const fnBody = args[args.length - 1];\n const body = `(function anonymous(${fnArgs}\n) { ${fnBody}\n})`;\n\n // Using eval directly confuses the compiler and prevents this module from\n // being stripped out of JS binaries even if not used. The global['eval']\n // indirection fixes that.\n const fn = global['eval'](trustedScriptFromString(body) as string) as Function;\n if (fn.bind === undefined) {\n // Workaround for a browser bug that only exists in Chrome 83, where passing\n // a TrustedScript to eval just returns the TrustedScript back without\n // evaluating it. In that case, fall back to the most straightforward\n // implementation:\n return new Function(...args);\n }\n\n // To completely mimic the behavior of calling \"new Function\", two more\n // things need to happen:\n // 1. Stringifying the resulting function should return its source code\n fn.toString = () => body;\n // 2. When calling the resulting function, `this` should refer to `global`\n return fn.bind(global);\n\n // When Trusted Types support in Function constructors is widely available,\n // the implementation of this function can be simplified to:\n // return new Function(...args.map(a => trustedScriptFromString(a)));\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {identifierName} from '../parse_util';\n\nimport {EmitterVisitorContext} from './abstract_emitter';\nimport {AbstractJsEmitterVisitor} from './abstract_js_emitter';\nimport * as o from './output_ast';\nimport {newTrustedFunctionForJIT} from './output_jit_trusted_types';\n\nexport interface ExternalReferenceResolver {\n resolveExternalReference(ref: o.ExternalReference): unknown;\n}\n\n/**\n * A helper class to manage the evaluation of JIT generated code.\n */\nexport class JitEvaluator {\n /**\n *\n * @param sourceUrl The URL of the generated code.\n * @param statements An array of Angular statement AST nodes to be evaluated.\n * @param refResolver Resolves `o.ExternalReference`s into values.\n * @param createSourceMaps If true then create a source-map for the generated code and include it\n * inline as a source-map comment.\n * @returns A map of all the variables in the generated code.\n */\n evaluateStatements(\n sourceUrl: string,\n statements: o.Statement[],\n refResolver: ExternalReferenceResolver,\n createSourceMaps: boolean,\n ): {[key: string]: any} {\n const converter = new JitEmitterVisitor(refResolver);\n const ctx = EmitterVisitorContext.createRoot();\n // Ensure generated code is in strict mode\n if (statements.length > 0 && !isUseStrictStatement(statements[0])) {\n statements = [o.literal('use strict').toStmt(), ...statements];\n }\n converter.visitAllStatements(statements, ctx);\n converter.createReturnStmt(ctx);\n return this.evaluateCode(sourceUrl, ctx, converter.getArgs(), createSourceMaps);\n }\n\n /**\n * Evaluate a piece of JIT generated code.\n * @param sourceUrl The URL of this generated code.\n * @param ctx A context object that contains an AST of the code to be evaluated.\n * @param vars A map containing the names and values of variables that the evaluated code might\n * reference.\n * @param createSourceMap If true then create a source-map for the generated code and include it\n * inline as a source-map comment.\n * @returns The result of evaluating the code.\n */\n evaluateCode(\n sourceUrl: string,\n ctx: EmitterVisitorContext,\n vars: {[key: string]: any},\n createSourceMap: boolean,\n ): any {\n let fnBody = `\"use strict\";${ctx.toSource()}\\n//# sourceURL=${sourceUrl}`;\n const fnArgNames: string[] = [];\n const fnArgValues: any[] = [];\n for (const argName in vars) {\n fnArgValues.push(vars[argName]);\n fnArgNames.push(argName);\n }\n if (createSourceMap) {\n // using `new Function(...)` generates a header, 1 line of no arguments, 2 lines otherwise\n // E.g. ```\n // function anonymous(a,b,c\n // /**/) { ... }```\n // We don't want to hard code this fact, so we auto detect it via an empty function first.\n const emptyFn = newTrustedFunctionForJIT(...fnArgNames.concat('return null;')).toString();\n const headerLines = emptyFn.slice(0, emptyFn.indexOf('return null;')).split('\\n').length - 1;\n fnBody += `\\n${ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment()}`;\n }\n const fn = newTrustedFunctionForJIT(...fnArgNames.concat(fnBody));\n return this.executeFunction(fn, fnArgValues);\n }\n\n /**\n * Execute a JIT generated function by calling it.\n *\n * This method can be overridden in tests to capture the functions that are generated\n * by this `JitEvaluator` class.\n *\n * @param fn A function to execute.\n * @param args The arguments to pass to the function being executed.\n * @returns The return value of the executed function.\n */\n executeFunction(fn: Function, args: any[]) {\n return fn(...args);\n }\n}\n\n/**\n * An Angular AST visitor that converts AST nodes into executable JavaScript code.\n */\nexport class JitEmitterVisitor extends AbstractJsEmitterVisitor {\n private _evalArgNames: string[] = [];\n private _evalArgValues: any[] = [];\n private _evalExportedVars: string[] = [];\n\n constructor(private refResolver: ExternalReferenceResolver) {\n super();\n }\n\n createReturnStmt(ctx: EmitterVisitorContext) {\n const stmt = new o.ReturnStatement(\n new o.LiteralMapExpr(\n this._evalExportedVars.map(\n (resultVar) => new o.LiteralMapEntry(resultVar, o.variable(resultVar), false),\n ),\n ),\n );\n stmt.visitStatement(this, ctx);\n }\n\n getArgs(): {[key: string]: any} {\n const result: {[key: string]: any} = {};\n for (let i = 0; i < this._evalArgNames.length; i++) {\n result[this._evalArgNames[i]] = this._evalArgValues[i];\n }\n return result;\n }\n\n override visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any {\n this._emitReferenceToExternal(ast, this.refResolver.resolveExternalReference(ast.value), ctx);\n return null;\n }\n\n override visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any {\n this._emitReferenceToExternal(ast, ast.node, ctx);\n return null;\n }\n\n override visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any {\n if (stmt.hasModifier(o.StmtModifier.Exported)) {\n this._evalExportedVars.push(stmt.name);\n }\n return super.visitDeclareVarStmt(stmt, ctx);\n }\n\n override visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any {\n if (stmt.hasModifier(o.StmtModifier.Exported)) {\n this._evalExportedVars.push(stmt.name);\n }\n return super.visitDeclareFunctionStmt(stmt, ctx);\n }\n\n private _emitReferenceToExternal(\n ast: o.Expression,\n value: any,\n ctx: EmitterVisitorContext,\n ): void {\n let id = this._evalArgValues.indexOf(value);\n if (id === -1) {\n id = this._evalArgValues.length;\n this._evalArgValues.push(value);\n const name = identifierName({reference: value}) || 'val';\n this._evalArgNames.push(`jit_${name}_${id}`);\n }\n ctx.print(ast, this._evalArgNames[id]);\n }\n}\n\nfunction isUseStrictStatement(statement: o.Statement): boolean {\n return statement.isEquivalent(o.literal('use strict').toStmt());\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../output/output_ast';\n\nimport {Identifiers as R3} from './r3_identifiers';\nimport {R3CompiledExpression, R3Reference} from './util';\nimport {DefinitionMap} from './view/util';\n\nexport interface R3InjectorMetadata {\n name: string;\n type: R3Reference;\n providers: o.Expression | null;\n imports: o.Expression[];\n}\n\nexport function compileInjector(meta: R3InjectorMetadata): R3CompiledExpression {\n const definitionMap = new DefinitionMap<{providers: o.Expression; imports: o.Expression}>();\n\n if (meta.providers !== null) {\n definitionMap.set('providers', meta.providers);\n }\n\n if (meta.imports.length > 0) {\n definitionMap.set('imports', o.literalArr(meta.imports));\n }\n\n const expression = o\n .importExpr(R3.defineInjector)\n .callFn([definitionMap.toLiteralMap()], undefined, true);\n const type = createInjectorType(meta);\n return {expression, type, statements: []};\n}\n\nexport function createInjectorType(meta: R3InjectorMetadata): o.Type {\n return new o.ExpressionType(\n o.importExpr(R3.InjectorDeclaration, [new o.ExpressionType(meta.type.type)]),\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../output/output_ast';\nimport {ExternalReferenceResolver} from '../output/output_jit';\n\n/**\n * Implementation of `CompileReflector` which resolves references to @angular/core\n * symbols at runtime, according to a consumer-provided mapping.\n *\n * Only supports `resolveExternalReference`, all other methods throw.\n */\nexport class R3JitReflector implements ExternalReferenceResolver {\n constructor(private context: {[key: string]: unknown}) {}\n\n resolveExternalReference(ref: o.ExternalReference): unknown {\n // This reflector only handles @angular/core imports.\n if (ref.moduleName !== '@angular/core') {\n throw new Error(\n `Cannot resolve external reference to ${ref.moduleName}, only references to @angular/core are supported.`,\n );\n }\n if (!this.context.hasOwnProperty(ref.name!)) {\n throw new Error(`No value provided for @angular/core symbol '${ref.name!}'.`);\n }\n return this.context[ref.name!];\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {R3DeclareNgModuleFacade} from '../compiler_facade_interface';\nimport * as o from '../output/output_ast';\n\nimport {Identifiers as R3} from './r3_identifiers';\nimport {jitOnlyGuardedExpression, R3CompiledExpression, R3Reference, refsToArray} from './util';\nimport {DefinitionMap} from './view/util';\n\n/**\n * How the selector scope of an NgModule (its declarations, imports, and exports) should be emitted\n * as a part of the NgModule definition.\n */\nexport enum R3SelectorScopeMode {\n /**\n * Emit the declarations inline into the module definition.\n *\n * This option is useful in certain contexts where it's known that JIT support is required. The\n * tradeoff here is that this emit style prevents directives and pipes from being tree-shaken if\n * they are unused, but the NgModule is used.\n */\n Inline,\n\n /**\n * Emit the declarations using a side effectful function call, `ɵɵsetNgModuleScope`, that is\n * guarded with the `ngJitMode` flag.\n *\n * This form of emit supports JIT and can be optimized away if the `ngJitMode` flag is set to\n * false, which allows unused directives and pipes to be tree-shaken.\n */\n SideEffect,\n\n /**\n * Don't generate selector scopes at all.\n *\n * This is useful for contexts where JIT support is known to be unnecessary.\n */\n Omit,\n}\n\n/**\n * The type of the NgModule meta data.\n * - Global: Used for full and partial compilation modes which mainly includes R3References.\n * - Local: Used for the local compilation mode which mainly includes the raw expressions as appears\n * in the NgModule decorator.\n */\nexport enum R3NgModuleMetadataKind {\n Global,\n Local,\n}\n\ninterface R3NgModuleMetadataCommon {\n kind: R3NgModuleMetadataKind;\n\n /**\n * An expression representing the module type being compiled.\n */\n type: R3Reference;\n\n /**\n * How to emit the selector scope values (declarations, imports, exports).\n */\n selectorScopeMode: R3SelectorScopeMode;\n\n /**\n * The set of schemas that declare elements to be allowed in the NgModule.\n */\n schemas: R3Reference[] | null;\n\n /** Unique ID or expression representing the unique ID of an NgModule. */\n id: o.Expression | null;\n}\n\n/**\n * Metadata required by the module compiler in full/partial mode to generate a module def (`ɵmod`)\n * for a type.\n */\nexport interface R3NgModuleMetadataGlobal extends R3NgModuleMetadataCommon {\n kind: R3NgModuleMetadataKind.Global;\n\n /**\n * An array of expressions representing the bootstrap components specified by the module.\n */\n bootstrap: R3Reference[];\n\n /**\n * An array of expressions representing the directives and pipes declared by the module.\n */\n declarations: R3Reference[];\n\n /**\n * Those declarations which should be visible to downstream consumers. If not specified, all\n * declarations are made visible to downstream consumers.\n */\n publicDeclarationTypes: o.Expression[] | null;\n\n /**\n * An array of expressions representing the imports of the module.\n */\n imports: R3Reference[];\n\n /**\n * Whether or not to include `imports` in generated type declarations.\n */\n includeImportTypes: boolean;\n\n /**\n * An array of expressions representing the exports of the module.\n */\n exports: R3Reference[];\n\n /**\n * Whether to generate closure wrappers for bootstrap, declarations, imports, and exports.\n */\n containsForwardDecls: boolean;\n}\n\n/**\n * Metadata required by the module compiler in local mode to generate a module def (`ɵmod`) for a\n * type.\n */\nexport interface R3NgModuleMetadataLocal extends R3NgModuleMetadataCommon {\n kind: R3NgModuleMetadataKind.Local;\n\n /**\n * The output expression representing the bootstrap components specified by the module.\n */\n bootstrapExpression: o.Expression | null;\n\n /**\n * The output expression representing the declarations of the module.\n */\n declarationsExpression: o.Expression | null;\n\n /**\n * The output expression representing the imports of the module.\n */\n importsExpression: o.Expression | null;\n\n /**\n * The output expression representing the exports of the module.\n */\n exportsExpression: o.Expression | null;\n\n /**\n * Local compilation mode always requires scope to be handled using side effect function calls.\n */\n selectorScopeMode: R3SelectorScopeMode.SideEffect;\n}\n\n/**\n * Metadata required by the module compiler to generate a module def (`ɵmod`) for a type.\n */\nexport type R3NgModuleMetadata = R3NgModuleMetadataGlobal | R3NgModuleMetadataLocal;\n\n/**\n * The shape of the object literal that is passed to the `ɵɵdefineNgModule()` call.\n */\ninterface R3NgModuleDefMap {\n /**\n * An expression representing the module type being compiled.\n */\n type: o.Expression;\n /**\n * An expression evaluating to an array of expressions representing the bootstrap components\n * specified by the module.\n */\n bootstrap?: o.Expression;\n /**\n * An expression evaluating to an array of expressions representing the directives and pipes\n * declared by the module.\n */\n declarations?: o.Expression;\n /**\n * An expression evaluating to an array of expressions representing the imports of the module.\n */\n imports?: o.Expression;\n /**\n * An expression evaluating to an array of expressions representing the exports of the module.\n */\n exports?: o.Expression;\n /**\n * A literal array expression containing the schemas that declare elements to be allowed in the\n * NgModule.\n */\n schemas?: o.LiteralArrayExpr;\n /**\n * An expression evaluating to the unique ID of an NgModule.\n * */\n id?: o.Expression;\n}\n\n/**\n * Construct an `R3NgModuleDef` for the given `R3NgModuleMetadata`.\n */\nexport function compileNgModule(meta: R3NgModuleMetadata): R3CompiledExpression {\n const statements: o.Statement[] = [];\n const definitionMap = new DefinitionMap();\n definitionMap.set('type', meta.type.value);\n\n // Assign bootstrap definition. In local compilation mode (i.e., for\n // `R3NgModuleMetadataKind.LOCAL`) we assign the bootstrap field using the runtime\n // `ɵɵsetNgModuleScope`.\n if (meta.kind === R3NgModuleMetadataKind.Global && meta.bootstrap.length > 0) {\n definitionMap.set('bootstrap', refsToArray(meta.bootstrap, meta.containsForwardDecls));\n }\n\n if (meta.selectorScopeMode === R3SelectorScopeMode.Inline) {\n // If requested to emit scope information inline, pass the `declarations`, `imports` and\n // `exports` to the `ɵɵdefineNgModule()` call directly.\n\n if (meta.declarations.length > 0) {\n definitionMap.set('declarations', refsToArray(meta.declarations, meta.containsForwardDecls));\n }\n\n if (meta.imports.length > 0) {\n definitionMap.set('imports', refsToArray(meta.imports, meta.containsForwardDecls));\n }\n\n if (meta.exports.length > 0) {\n definitionMap.set('exports', refsToArray(meta.exports, meta.containsForwardDecls));\n }\n } else if (meta.selectorScopeMode === R3SelectorScopeMode.SideEffect) {\n // In this mode, scope information is not passed into `ɵɵdefineNgModule` as it\n // would prevent tree-shaking of the declarations, imports and exports references. Instead, it's\n // patched onto the NgModule definition with a `ɵɵsetNgModuleScope` call that's guarded by the\n // `ngJitMode` flag.\n const setNgModuleScopeCall = generateSetNgModuleScopeCall(meta);\n if (setNgModuleScopeCall !== null) {\n statements.push(setNgModuleScopeCall);\n }\n } else {\n // Selector scope emit was not requested, so skip it.\n }\n\n if (meta.schemas !== null && meta.schemas.length > 0) {\n definitionMap.set('schemas', o.literalArr(meta.schemas.map((ref) => ref.value)));\n }\n\n if (meta.id !== null) {\n definitionMap.set('id', meta.id);\n\n // Generate a side-effectful call to register this NgModule by its id, as per the semantics of\n // NgModule ids.\n statements.push(\n o.importExpr(R3.registerNgModuleType).callFn([meta.type.value, meta.id]).toStmt(),\n );\n }\n\n const expression = o\n .importExpr(R3.defineNgModule)\n .callFn([definitionMap.toLiteralMap()], undefined, true);\n const type = createNgModuleType(meta);\n\n return {expression, type, statements};\n}\n\n/**\n * This function is used in JIT mode to generate the call to `ɵɵdefineNgModule()` from a call to\n * `ɵɵngDeclareNgModule()`.\n */\nexport function compileNgModuleDeclarationExpression(meta: R3DeclareNgModuleFacade): o.Expression {\n const definitionMap = new DefinitionMap();\n definitionMap.set('type', new o.WrappedNodeExpr(meta.type));\n if (meta.bootstrap !== undefined) {\n definitionMap.set('bootstrap', new o.WrappedNodeExpr(meta.bootstrap));\n }\n if (meta.declarations !== undefined) {\n definitionMap.set('declarations', new o.WrappedNodeExpr(meta.declarations));\n }\n if (meta.imports !== undefined) {\n definitionMap.set('imports', new o.WrappedNodeExpr(meta.imports));\n }\n if (meta.exports !== undefined) {\n definitionMap.set('exports', new o.WrappedNodeExpr(meta.exports));\n }\n if (meta.schemas !== undefined) {\n definitionMap.set('schemas', new o.WrappedNodeExpr(meta.schemas));\n }\n if (meta.id !== undefined) {\n definitionMap.set('id', new o.WrappedNodeExpr(meta.id));\n }\n return o.importExpr(R3.defineNgModule).callFn([definitionMap.toLiteralMap()]);\n}\n\nexport function createNgModuleType(meta: R3NgModuleMetadata): o.ExpressionType {\n if (meta.kind === R3NgModuleMetadataKind.Local) {\n return new o.ExpressionType(meta.type.value);\n }\n\n const {\n type: moduleType,\n declarations,\n exports,\n imports,\n includeImportTypes,\n publicDeclarationTypes,\n } = meta;\n\n return new o.ExpressionType(\n o.importExpr(R3.NgModuleDeclaration, [\n new o.ExpressionType(moduleType.type),\n publicDeclarationTypes === null\n ? tupleTypeOf(declarations)\n : tupleOfTypes(publicDeclarationTypes),\n includeImportTypes ? tupleTypeOf(imports) : o.NONE_TYPE,\n tupleTypeOf(exports),\n ]),\n );\n}\n\n/**\n * Generates a function call to `ɵɵsetNgModuleScope` with all necessary information so that the\n * transitive module scope can be computed during runtime in JIT mode. This call is marked pure\n * such that the references to declarations, imports and exports may be elided causing these\n * symbols to become tree-shakeable.\n */\nfunction generateSetNgModuleScopeCall(meta: R3NgModuleMetadata): o.Statement | null {\n const scopeMap = new DefinitionMap<{\n declarations: o.Expression;\n imports: o.Expression;\n exports: o.Expression;\n bootstrap: o.Expression;\n }>();\n\n if (meta.kind === R3NgModuleMetadataKind.Global) {\n if (meta.declarations.length > 0) {\n scopeMap.set('declarations', refsToArray(meta.declarations, meta.containsForwardDecls));\n }\n } else {\n if (meta.declarationsExpression) {\n scopeMap.set('declarations', meta.declarationsExpression);\n }\n }\n\n if (meta.kind === R3NgModuleMetadataKind.Global) {\n if (meta.imports.length > 0) {\n scopeMap.set('imports', refsToArray(meta.imports, meta.containsForwardDecls));\n }\n } else {\n if (meta.importsExpression) {\n scopeMap.set('imports', meta.importsExpression);\n }\n }\n\n if (meta.kind === R3NgModuleMetadataKind.Global) {\n if (meta.exports.length > 0) {\n scopeMap.set('exports', refsToArray(meta.exports, meta.containsForwardDecls));\n }\n } else {\n if (meta.exportsExpression) {\n scopeMap.set('exports', meta.exportsExpression);\n }\n }\n\n if (meta.kind === R3NgModuleMetadataKind.Local && meta.bootstrapExpression) {\n scopeMap.set('bootstrap', meta.bootstrapExpression);\n }\n\n if (Object.keys(scopeMap.values).length === 0) {\n return null;\n }\n\n // setNgModuleScope(...)\n const fnCall = new o.InvokeFunctionExpr(\n /* fn */ o.importExpr(R3.setNgModuleScope),\n /* args */ [meta.type.value, scopeMap.toLiteralMap()],\n );\n\n // (ngJitMode guard) && setNgModuleScope(...)\n const guardedCall = jitOnlyGuardedExpression(fnCall);\n\n // function() { (ngJitMode guard) && setNgModuleScope(...); }\n const iife = new o.FunctionExpr(/* params */ [], /* statements */ [guardedCall.toStmt()]);\n\n // (function() { (ngJitMode guard) && setNgModuleScope(...); })()\n const iifeCall = new o.InvokeFunctionExpr(/* fn */ iife, /* args */ []);\n\n return iifeCall.toStmt();\n}\n\nfunction tupleTypeOf(exp: R3Reference[]): o.Type {\n const types = exp.map((ref) => o.typeofExpr(ref.type));\n return exp.length > 0 ? o.expressionType(o.literalArr(types)) : o.NONE_TYPE;\n}\n\nfunction tupleOfTypes(types: o.Expression[]): o.Type {\n const typeofTypes = types.map((type) => o.typeofExpr(type));\n return types.length > 0 ? o.expressionType(o.literalArr(typeofTypes)) : o.NONE_TYPE;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport * as o from '../output/output_ast';\n\nimport {R3DependencyMetadata} from './r3_factory';\nimport {Identifiers as R3} from './r3_identifiers';\nimport {R3CompiledExpression, R3Reference, typeWithParameters} from './util';\n\nexport interface R3PipeMetadata {\n /**\n * Name of the pipe type.\n */\n name: string;\n\n /**\n * An expression representing a reference to the pipe itself.\n */\n type: R3Reference;\n\n /**\n * Number of generic type parameters of the type itself.\n */\n typeArgumentCount: number;\n\n /**\n * Name of the pipe.\n */\n pipeName: string;\n\n /**\n * Dependencies of the pipe's constructor.\n */\n deps: R3DependencyMetadata[] | null;\n\n /**\n * Whether the pipe is marked as pure.\n */\n pure: boolean;\n\n /**\n * Whether the pipe is standalone.\n */\n isStandalone: boolean;\n}\n\nexport function compilePipeFromMetadata(metadata: R3PipeMetadata): R3CompiledExpression {\n const definitionMapValues: {key: string; quoted: boolean; value: o.Expression}[] = [];\n\n // e.g. `name: 'myPipe'`\n definitionMapValues.push({key: 'name', value: o.literal(metadata.pipeName), quoted: false});\n\n // e.g. `type: MyPipe`\n definitionMapValues.push({key: 'type', value: metadata.type.value, quoted: false});\n\n // e.g. `pure: true`\n definitionMapValues.push({key: 'pure', value: o.literal(metadata.pure), quoted: false});\n\n if (metadata.isStandalone) {\n definitionMapValues.push({key: 'standalone', value: o.literal(true), quoted: false});\n }\n\n const expression = o\n .importExpr(R3.definePipe)\n .callFn([o.literalMap(definitionMapValues)], undefined, true);\n const type = createPipeType(metadata);\n\n return {expression, type, statements: []};\n}\n\nexport function createPipeType(metadata: R3PipeMetadata): o.Type {\n return new o.ExpressionType(\n o.importExpr(R3.PipeDeclaration, [\n typeWithParameters(metadata.type.type, metadata.typeArgumentCount),\n new o.ExpressionType(new o.LiteralExpr(metadata.pipeName)),\n new o.ExpressionType(new o.LiteralExpr(metadata.isStandalone)),\n ]),\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ChangeDetectionStrategy, ViewEncapsulation} from '../../core';\nimport {InterpolationConfig} from '../../ml_parser/defaults';\nimport * as o from '../../output/output_ast';\nimport {ParseSourceSpan} from '../../parse_util';\nimport * as t from '../r3_ast';\nimport {R3DependencyMetadata} from '../r3_factory';\nimport {MaybeForwardRefExpression, R3Reference} from '../util';\n\n/**\n * Information needed to compile a directive for the render3 runtime.\n */\nexport interface R3DirectiveMetadata {\n /**\n * Name of the directive type.\n */\n name: string;\n\n /**\n * An expression representing a reference to the directive itself.\n */\n type: R3Reference;\n\n /**\n * Number of generic type parameters of the type itself.\n */\n typeArgumentCount: number;\n\n /**\n * A source span for the directive type.\n */\n typeSourceSpan: ParseSourceSpan;\n\n /**\n * Dependencies of the directive's constructor.\n */\n deps: R3DependencyMetadata[] | 'invalid' | null;\n\n /**\n * Unparsed selector of the directive, or `null` if there was no selector.\n */\n selector: string | null;\n\n /**\n * Information about the content queries made by the directive.\n */\n queries: R3QueryMetadata[];\n\n /**\n * Information about the view queries made by the directive.\n */\n viewQueries: R3QueryMetadata[];\n\n /**\n * Mappings indicating how the directive interacts with its host element (host bindings,\n * listeners, etc).\n */\n host: R3HostMetadata;\n\n /**\n * Information about usage of specific lifecycle events which require special treatment in the\n * code generator.\n */\n lifecycle: {\n /**\n * Whether the directive uses NgOnChanges.\n */\n usesOnChanges: boolean;\n };\n\n /**\n * A mapping of inputs from class property names to binding property names, or to a tuple of\n * binding property name and class property name if the names are different.\n */\n inputs: {[field: string]: R3InputMetadata};\n\n /**\n * A mapping of outputs from class property names to binding property names, or to a tuple of\n * binding property name and class property name if the names are different.\n */\n outputs: {[field: string]: string};\n\n /**\n * Whether or not the component or directive inherits from another class\n */\n usesInheritance: boolean;\n\n /**\n * Whether or not the component or directive inherits its entire decorator from its base class.\n */\n fullInheritance: boolean;\n\n /**\n * Reference name under which to export the directive's type in a template,\n * if any.\n */\n exportAs: string[] | null;\n\n /**\n * The list of providers defined in the directive.\n */\n providers: o.Expression | null;\n\n /**\n * Whether or not the component or directive is standalone.\n */\n isStandalone: boolean;\n\n /**\n * Whether or not the component or directive is signal-based.\n */\n isSignal: boolean;\n\n /**\n * Additional directives applied to the directive host.\n */\n hostDirectives: R3HostDirectiveMetadata[] | null;\n}\n\n/**\n * Defines how dynamic imports for deferred dependencies should be emitted in the\n * generated output:\n * - either in a function on per-component basis (in case of local compilation)\n * - or in a function on per-block basis (in full compilation mode)\n */\nexport const enum DeferBlockDepsEmitMode {\n /**\n * Dynamic imports are grouped on per-block basis.\n *\n * This is used in full compilation mode, when compiler has more information\n * about particular dependencies that belong to this block.\n */\n PerBlock,\n\n /**\n * Dynamic imports are grouped on per-component basis.\n *\n * In local compilation, compiler doesn't have enough information to determine\n * which deferred dependencies belong to which block. In this case we group all\n * dynamic imports into a single file on per-component basis.\n */\n PerComponent,\n}\n\n/**\n * Specifies how a list of declaration type references should be emitted into the generated code.\n */\nexport const enum DeclarationListEmitMode {\n /**\n * The list of declarations is emitted into the generated code as is.\n *\n * ```\n * directives: [MyDir],\n * ```\n */\n Direct,\n\n /**\n * The list of declarations is emitted into the generated code wrapped inside a closure, which\n * is needed when at least one declaration is a forward reference.\n *\n * ```\n * directives: function () { return [MyDir, ForwardDir]; },\n * ```\n */\n Closure,\n\n /**\n * Similar to `Closure`, with the addition that the list of declarations can contain individual\n * items that are themselves forward references. This is relevant for JIT compilations, as\n * unwrapping the forwardRef cannot be done statically so must be deferred. This mode emits\n * the declaration list using a mapping transform through `resolveForwardRef` to ensure that\n * any forward references within the list are resolved when the outer closure is invoked.\n *\n * Consider the case where the runtime has captured two declarations in two distinct values:\n * ```\n * const dirA = MyDir;\n * const dirB = forwardRef(function() { return ForwardRef; });\n * ```\n *\n * This mode would emit the declarations captured in `dirA` and `dirB` as follows:\n * ```\n * directives: function () { return [dirA, dirB].map(ng.resolveForwardRef); },\n * ```\n */\n ClosureResolved,\n\n RuntimeResolved,\n}\n\n/**\n * Information needed to compile a component for the render3 runtime.\n */\nexport interface R3ComponentMetadata\n extends R3DirectiveMetadata {\n /**\n * Information about the component's template.\n */\n template: {\n /**\n * Parsed nodes of the template.\n */\n nodes: t.Node[];\n\n /**\n * Any ng-content selectors extracted from the template. Contains `*` when an ng-content\n * element without selector is present.\n */\n ngContentSelectors: string[];\n\n /**\n * Whether the template preserves whitespaces from the user's code.\n */\n preserveWhitespaces?: boolean;\n };\n\n declarations: DeclarationT[];\n\n /** Metadata related to the deferred blocks in the component's template. */\n defer: R3ComponentDeferMetadata;\n\n /**\n * Specifies how the 'directives' and/or `pipes` array, if generated, need to be emitted.\n */\n declarationListEmitMode: DeclarationListEmitMode;\n\n /**\n * A collection of styling data that will be applied and scoped to the component.\n */\n styles: string[];\n\n /**\n * An encapsulation policy for the component's styling.\n * Possible values:\n * - `ViewEncapsulation.Emulated`: Apply modified component styles in order to emulate\n * a native Shadow DOM CSS encapsulation behavior.\n * - `ViewEncapsulation.None`: Apply component styles globally without any sort of encapsulation.\n * - `ViewEncapsulation.ShadowDom`: Use the browser's native Shadow DOM API to encapsulate styles.\n */\n encapsulation: ViewEncapsulation;\n\n /**\n * A collection of animation triggers that will be used in the component template.\n */\n animations: o.Expression | null;\n\n /**\n * The list of view providers defined in the component.\n */\n viewProviders: o.Expression | null;\n\n /**\n * Path to the .ts file in which this template's generated code will be included, relative to\n * the compilation root. This will be used to generate identifiers that need to be globally\n * unique in certain contexts (such as g3).\n */\n relativeContextFilePath: string;\n\n /**\n * Whether translation variable name should contain external message id\n * (used by Closure Compiler's output of `goog.getMsg` for transition period).\n */\n i18nUseExternalIds: boolean;\n\n /**\n * Overrides the default interpolation start and end delimiters ({{ and }}).\n */\n interpolation: InterpolationConfig;\n\n /**\n * Strategy used for detecting changes in the component.\n *\n * In global compilation mode the value is ChangeDetectionStrategy if available as it is\n * statically resolved during analysis phase. Whereas in local compilation mode the value is the\n * expression as appears in the decorator.\n */\n changeDetection: ChangeDetectionStrategy | o.Expression | null;\n\n /**\n * The imports expression as appears on the component decorate for standalone component. This\n * field is currently needed only for local compilation, and so in other compilation modes it may\n * not be set. If component has empty array imports then this field is not set.\n */\n rawImports?: o.Expression;\n}\n\n/**\n * Information about the deferred blocks in a component's template.\n */\nexport type R3ComponentDeferMetadata =\n | {\n mode: DeferBlockDepsEmitMode.PerBlock;\n blocks: Map;\n }\n | {\n mode: DeferBlockDepsEmitMode.PerComponent;\n dependenciesFn: o.Expression | null;\n };\n\n/**\n * Metadata for an individual input on a directive.\n */\nexport interface R3InputMetadata {\n classPropertyName: string;\n bindingPropertyName: string;\n required: boolean;\n isSignal: boolean;\n /**\n * Transform function for the input.\n *\n * Null if there is no transform, or if this is a signal input.\n * Signal inputs capture their transform as part of the `InputSignal`.\n */\n transformFunction: o.Expression | null;\n}\n\nexport enum R3TemplateDependencyKind {\n Directive = 0,\n Pipe = 1,\n NgModule = 2,\n}\n\n/**\n * A dependency that's used within a component template.\n */\nexport interface R3TemplateDependency {\n kind: R3TemplateDependencyKind;\n\n /**\n * The type of the dependency as an expression.\n */\n type: o.Expression;\n}\n\n/**\n * A dependency that's used within a component template\n */\nexport type R3TemplateDependencyMetadata =\n | R3DirectiveDependencyMetadata\n | R3PipeDependencyMetadata\n | R3NgModuleDependencyMetadata;\n\n/**\n * Information about a directive that is used in a component template. Only the stable, public\n * facing information of the directive is stored here.\n */\nexport interface R3DirectiveDependencyMetadata extends R3TemplateDependency {\n kind: R3TemplateDependencyKind.Directive;\n\n /**\n * The selector of the directive.\n */\n selector: string;\n\n /**\n * The binding property names of the inputs of the directive.\n */\n inputs: string[];\n\n /**\n * The binding property names of the outputs of the directive.\n */\n outputs: string[];\n\n /**\n * Name under which the directive is exported, if any (exportAs in Angular). Null otherwise.\n */\n exportAs: string[] | null;\n\n /**\n * If true then this directive is actually a component; otherwise it is not.\n */\n isComponent: boolean;\n}\n\nexport interface R3PipeDependencyMetadata extends R3TemplateDependency {\n kind: R3TemplateDependencyKind.Pipe;\n\n name: string;\n}\n\nexport interface R3NgModuleDependencyMetadata extends R3TemplateDependency {\n kind: R3TemplateDependencyKind.NgModule;\n}\n\n/**\n * Information needed to compile a query (view or content).\n */\nexport interface R3QueryMetadata {\n /**\n * Name of the property on the class to update with query results.\n */\n propertyName: string;\n\n /**\n * Whether to read only the first matching result, or an array of results.\n */\n first: boolean;\n\n /**\n * Either an expression representing a type or `InjectionToken` for the query\n * predicate, or a set of string selectors.\n *\n * Note: At compile time we split selectors as an optimization that avoids this\n * extra work at runtime creation phase.\n *\n * Notably, if the selector is not statically analyzable due to an expression,\n * the selectors may need to be split up at runtime.\n */\n predicate: MaybeForwardRefExpression | string[];\n\n /**\n * Whether to include only direct children or all descendants.\n */\n descendants: boolean;\n\n /**\n * If the `QueryList` should fire change event only if actual change to query was computed (vs old\n * behavior where the change was fired whenever the query was recomputed, even if the recomputed\n * query resulted in the same list.)\n */\n emitDistinctChangesOnly: boolean;\n\n /**\n * An expression representing a type to read from each matched node, or null if the default value\n * for a given node is to be returned.\n */\n read: o.Expression | null;\n\n /**\n * Whether or not this query should collect only static results.\n *\n * If static is true, the query's results will be set on the component after nodes are created,\n * but before change detection runs. This means that any results that relied upon change detection\n * to run (e.g. results inside *ngIf or *ngFor views) will not be collected. Query results are\n * available in the ngOnInit hook.\n *\n * If static is false, the query's results will be set on the component after change detection\n * runs. This means that the query results can contain nodes inside *ngIf or *ngFor views, but\n * the results will not be available in the ngOnInit hook (only in the ngAfterContentInit for\n * content hooks and ngAfterViewInit for view hooks).\n *\n * Note: For signal-based queries, this option does not have any effect.\n */\n static: boolean;\n\n /** Whether the query is signal-based. */\n isSignal: boolean;\n}\n\n/**\n * Mappings indicating how the class interacts with its\n * host element (host bindings, listeners, etc).\n */\nexport interface R3HostMetadata {\n /**\n * A mapping of attribute binding keys to `o.Expression`s.\n */\n attributes: {[key: string]: o.Expression};\n\n /**\n * A mapping of event binding keys to unparsed expressions.\n */\n listeners: {[key: string]: string};\n\n /**\n * A mapping of property binding keys to unparsed expressions.\n */\n properties: {[key: string]: string};\n\n specialAttributes: {styleAttr?: string; classAttr?: string};\n}\n\n/**\n * Information needed to compile a host directive for the render3 runtime.\n */\nexport interface R3HostDirectiveMetadata {\n /** An expression representing the host directive class itself. */\n directive: R3Reference;\n\n /** Whether the expression referring to the host directive is a forward reference. */\n isForwardReference: boolean;\n\n /** Inputs from the host directive that will be exposed on the host. */\n inputs: {[publicName: string]: string} | null;\n\n /** Outputs from the host directive that will be exposed on the host. */\n outputs: {[publicName: string]: string} | null;\n}\n\n/**\n * Information needed to compile the defer block resolver function.\n */\nexport type R3DeferResolverFunctionMetadata =\n | {\n mode: DeferBlockDepsEmitMode.PerBlock;\n dependencies: R3DeferPerBlockDependency[];\n }\n | {\n mode: DeferBlockDepsEmitMode.PerComponent;\n dependencies: R3DeferPerComponentDependency[];\n };\n\n/**\n * Information about a single dependency of a defer block in `PerBlock` mode.\n */\nexport interface R3DeferPerBlockDependency {\n /**\n * Reference to a dependency.\n */\n typeReference: o.Expression;\n\n /**\n * Dependency class name.\n */\n symbolName: string;\n\n /**\n * Whether this dependency can be defer-loaded.\n */\n isDeferrable: boolean;\n\n /**\n * Import path where this dependency is located.\n */\n importPath: string | null;\n\n /**\n * Whether the symbol is the default export.\n */\n isDefaultImport: boolean;\n}\n\n/**\n * Information about a single dependency of a defer block in `PerComponent` mode.\n */\nexport interface R3DeferPerComponentDependency {\n /**\n * Dependency class name.\n */\n symbolName: string;\n\n /**\n * Import path where this dependency is located.\n */\n importPath: string;\n\n /**\n * Whether the symbol is the default export.\n */\n isDefaultImport: boolean;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * The following set contains all keywords that can be used in the animation css shorthand\n * property and is used during the scoping of keyframes to make sure such keywords\n * are not modified.\n */\nconst animationKeywords = new Set([\n // global values\n 'inherit',\n 'initial',\n 'revert',\n 'unset',\n // animation-direction\n 'alternate',\n 'alternate-reverse',\n 'normal',\n 'reverse',\n // animation-fill-mode\n 'backwards',\n 'both',\n 'forwards',\n 'none',\n // animation-play-state\n 'paused',\n 'running',\n // animation-timing-function\n 'ease',\n 'ease-in',\n 'ease-in-out',\n 'ease-out',\n 'linear',\n 'step-start',\n 'step-end',\n // `steps()` function\n 'end',\n 'jump-both',\n 'jump-end',\n 'jump-none',\n 'jump-start',\n 'start',\n]);\n\n/**\n * The following array contains all of the CSS at-rule identifiers which are scoped.\n */\nconst scopedAtRuleIdentifiers = [\n '@media',\n '@supports',\n '@document',\n '@layer',\n '@container',\n '@scope',\n '@starting-style',\n];\n\n/**\n * The following class has its origin from a port of shadowCSS from webcomponents.js to TypeScript.\n * It has since diverge in many ways to tailor Angular's needs.\n *\n * Source:\n * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js\n *\n * The original file level comment is reproduced below\n */\n\n/*\n This is a limited shim for ShadowDOM css styling.\n https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles\n\n The intention here is to support only the styling features which can be\n relatively simply implemented. The goal is to allow users to avoid the\n most obvious pitfalls and do so without compromising performance significantly.\n For ShadowDOM styling that's not covered here, a set of best practices\n can be provided that should allow users to accomplish more complex styling.\n\n The following is a list of specific ShadowDOM styling features and a brief\n discussion of the approach used to shim.\n\n Shimmed features:\n\n * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host\n element using the :host rule. To shim this feature, the :host styles are\n reformatted and prefixed with a given scope name and promoted to a\n document level stylesheet.\n For example, given a scope name of .foo, a rule like this:\n\n :host {\n background: red;\n }\n }\n\n becomes:\n\n .foo {\n background: red;\n }\n\n * encapsulation: Styles defined within ShadowDOM, apply only to\n dom inside the ShadowDOM.\n The selectors are scoped by adding an attribute selector suffix to each\n simple selector that contains the host element tag name. Each element\n in the element's ShadowDOM template is also given the scope attribute.\n Thus, these rules match only elements that have the scope attribute.\n For example, given a scope name of x-foo, a rule like this:\n\n div {\n font-weight: bold;\n }\n\n becomes:\n\n div[x-foo] {\n font-weight: bold;\n }\n\n Note that elements that are dynamically added to a scope must have the scope\n selector added to them manually.\n\n * upper/lower bound encapsulation: Styles which are defined outside a\n shadowRoot should not cross the ShadowDOM boundary and should not apply\n inside a shadowRoot.\n\n This styling behavior is not emulated. Some possible ways to do this that\n were rejected due to complexity and/or performance concerns include: (1) reset\n every possible property for every possible selector for a given scope name;\n (2) re-implement css in javascript.\n\n As an alternative, users should make sure to use selectors\n specific to the scope in which they are working.\n\n * ::distributed: This behavior is not emulated. It's often not necessary\n to style the contents of a specific insertion point and instead, descendants\n of the host element can be styled selectively. Users can also create an\n extra node around an insertion point and style that node's contents\n via descendent selectors. For example, with a shadowRoot like this:\n\n \n \n\n could become:\n\n \n
\n \n
\n\n Note the use of @polyfill in the comment above a ShadowDOM specific style\n declaration. This is a directive to the styling shim to use the selector\n in comments in lieu of the next selector when running under polyfill.\n*/\nexport class ShadowCss {\n /*\n * Shim some cssText with the given selector. Returns cssText that can be included in the document\n *\n * The selector is the attribute added to all elements inside the host,\n * The hostSelector is the attribute added to the host itself.\n */\n shimCssText(cssText: string, selector: string, hostSelector: string = ''): string {\n // **NOTE**: Do not strip comments as this will cause component sourcemaps to break\n // due to shift in lines.\n\n // Collect comments and replace them with a placeholder, this is done to avoid complicating\n // the rule parsing RegExp and keep it safer.\n const comments: string[] = [];\n cssText = cssText.replace(_commentRe, (m) => {\n if (m.match(_commentWithHashRe)) {\n comments.push(m);\n } else {\n // Replace non hash comments with empty lines.\n // This is done so that we do not leak any sensitive data in comments.\n const newLinesMatches = m.match(_newLinesRe);\n comments.push((newLinesMatches?.join('') ?? '') + '\\n');\n }\n\n return COMMENT_PLACEHOLDER;\n });\n\n cssText = this._insertDirectives(cssText);\n const scopedCssText = this._scopeCssText(cssText, selector, hostSelector);\n // Add back comments at the original position.\n let commentIdx = 0;\n return scopedCssText.replace(_commentWithHashPlaceHolderRe, () => comments[commentIdx++]);\n }\n\n private _insertDirectives(cssText: string): string {\n cssText = this._insertPolyfillDirectivesInCssText(cssText);\n return this._insertPolyfillRulesInCssText(cssText);\n }\n\n /**\n * Process styles to add scope to keyframes.\n *\n * Modify both the names of the keyframes defined in the component styles and also the css\n * animation rules using them.\n *\n * Animation rules using keyframes defined elsewhere are not modified to allow for globally\n * defined keyframes.\n *\n * For example, we convert this css:\n *\n * ```\n * .box {\n * animation: box-animation 1s forwards;\n * }\n *\n * @keyframes box-animation {\n * to {\n * background-color: green;\n * }\n * }\n * ```\n *\n * to this:\n *\n * ```\n * .box {\n * animation: scopeName_box-animation 1s forwards;\n * }\n *\n * @keyframes scopeName_box-animation {\n * to {\n * background-color: green;\n * }\n * }\n * ```\n *\n * @param cssText the component's css text that needs to be scoped.\n * @param scopeSelector the component's scope selector.\n *\n * @returns the scoped css text.\n */\n private _scopeKeyframesRelatedCss(cssText: string, scopeSelector: string): string {\n const unscopedKeyframesSet = new Set();\n const scopedKeyframesCssText = processRules(cssText, (rule) =>\n this._scopeLocalKeyframeDeclarations(rule, scopeSelector, unscopedKeyframesSet),\n );\n return processRules(scopedKeyframesCssText, (rule) =>\n this._scopeAnimationRule(rule, scopeSelector, unscopedKeyframesSet),\n );\n }\n\n /**\n * Scopes local keyframes names, returning the updated css rule and it also\n * adds the original keyframe name to a provided set to collect all keyframes names\n * so that it can later be used to scope the animation rules.\n *\n * For example, it takes a rule such as:\n *\n * ```\n * @keyframes box-animation {\n * to {\n * background-color: green;\n * }\n * }\n * ```\n *\n * and returns:\n *\n * ```\n * @keyframes scopeName_box-animation {\n * to {\n * background-color: green;\n * }\n * }\n * ```\n * and as a side effect it adds \"box-animation\" to the `unscopedKeyframesSet` set\n *\n * @param cssRule the css rule to process.\n * @param scopeSelector the component's scope selector.\n * @param unscopedKeyframesSet the set of unscoped keyframes names (which can be\n * modified as a side effect)\n *\n * @returns the css rule modified with the scoped keyframes name.\n */\n private _scopeLocalKeyframeDeclarations(\n rule: CssRule,\n scopeSelector: string,\n unscopedKeyframesSet: Set,\n ): CssRule {\n return {\n ...rule,\n selector: rule.selector.replace(\n /(^@(?:-webkit-)?keyframes(?:\\s+))(['\"]?)(.+)\\2(\\s*)$/,\n (_, start, quote, keyframeName, endSpaces) => {\n unscopedKeyframesSet.add(unescapeQuotes(keyframeName, quote));\n return `${start}${quote}${scopeSelector}_${keyframeName}${quote}${endSpaces}`;\n },\n ),\n };\n }\n\n /**\n * Function used to scope a keyframes name (obtained from an animation declaration)\n * using an existing set of unscopedKeyframes names to discern if the scoping needs to be\n * performed (keyframes names of keyframes not defined in the component's css need not to be\n * scoped).\n *\n * @param keyframe the keyframes name to check.\n * @param scopeSelector the component's scope selector.\n * @param unscopedKeyframesSet the set of unscoped keyframes names.\n *\n * @returns the scoped name of the keyframe, or the original name is the name need not to be\n * scoped.\n */\n private _scopeAnimationKeyframe(\n keyframe: string,\n scopeSelector: string,\n unscopedKeyframesSet: ReadonlySet,\n ): string {\n return keyframe.replace(/^(\\s*)(['\"]?)(.+?)\\2(\\s*)$/, (_, spaces1, quote, name, spaces2) => {\n name = `${unscopedKeyframesSet.has(unescapeQuotes(name, quote)) ? scopeSelector + '_' : ''}${name}`;\n return `${spaces1}${quote}${name}${quote}${spaces2}`;\n });\n }\n\n /**\n * Regular expression used to extrapolate the possible keyframes from an\n * animation declaration (with possibly multiple animation definitions)\n *\n * The regular expression can be divided in three parts\n * - (^|\\s+|,)\n * captures how many (if any) leading whitespaces are present or a comma\n * - (?:(?:(['\"])((?:\\\\\\\\|\\\\\\2|(?!\\2).)+)\\2)|(-?[A-Za-z][\\w\\-]*))\n * captures two different possible keyframes, ones which are quoted or ones which are valid css\n * idents (custom properties excluded)\n * - (?=[,\\s;]|$)\n * simply matches the end of the possible keyframe, valid endings are: a comma, a space, a\n * semicolon or the end of the string\n */\n private _animationDeclarationKeyframesRe =\n /(^|\\s+|,)(?:(?:(['\"])((?:\\\\\\\\|\\\\\\2|(?!\\2).)+)\\2)|(-?[A-Za-z][\\w\\-]*))(?=[,\\s]|$)/g;\n\n /**\n * Scope an animation rule so that the keyframes mentioned in such rule\n * are scoped if defined in the component's css and left untouched otherwise.\n *\n * It can scope values of both the 'animation' and 'animation-name' properties.\n *\n * @param rule css rule to scope.\n * @param scopeSelector the component's scope selector.\n * @param unscopedKeyframesSet the set of unscoped keyframes names.\n *\n * @returns the updated css rule.\n **/\n private _scopeAnimationRule(\n rule: CssRule,\n scopeSelector: string,\n unscopedKeyframesSet: ReadonlySet,\n ): CssRule {\n let content = rule.content.replace(\n /((?:^|\\s+|;)(?:-webkit-)?animation\\s*:\\s*),*([^;]+)/g,\n (_, start, animationDeclarations) =>\n start +\n animationDeclarations.replace(\n this._animationDeclarationKeyframesRe,\n (\n original: string,\n leadingSpaces: string,\n quote = '',\n quotedName: string,\n nonQuotedName: string,\n ) => {\n if (quotedName) {\n return `${leadingSpaces}${this._scopeAnimationKeyframe(\n `${quote}${quotedName}${quote}`,\n scopeSelector,\n unscopedKeyframesSet,\n )}`;\n } else {\n return animationKeywords.has(nonQuotedName)\n ? original\n : `${leadingSpaces}${this._scopeAnimationKeyframe(\n nonQuotedName,\n scopeSelector,\n unscopedKeyframesSet,\n )}`;\n }\n },\n ),\n );\n content = content.replace(\n /((?:^|\\s+|;)(?:-webkit-)?animation-name(?:\\s*):(?:\\s*))([^;]+)/g,\n (_match, start, commaSeparatedKeyframes) =>\n `${start}${commaSeparatedKeyframes\n .split(',')\n .map((keyframe: string) =>\n this._scopeAnimationKeyframe(keyframe, scopeSelector, unscopedKeyframesSet),\n )\n .join(',')}`,\n );\n return {...rule, content};\n }\n\n /*\n * Process styles to convert native ShadowDOM rules that will trip\n * up the css parser; we rely on decorating the stylesheet with inert rules.\n *\n * For example, we convert this rule:\n *\n * polyfill-next-selector { content: ':host menu-item'; }\n * ::content menu-item {\n *\n * to this:\n *\n * scopeName menu-item {\n *\n **/\n private _insertPolyfillDirectivesInCssText(cssText: string): string {\n return cssText.replace(_cssContentNextSelectorRe, function (...m: string[]) {\n return m[2] + '{';\n });\n }\n\n /*\n * Process styles to add rules which will only apply under the polyfill\n *\n * For example, we convert this rule:\n *\n * polyfill-rule {\n * content: ':host menu-item';\n * ...\n * }\n *\n * to this:\n *\n * scopeName menu-item {...}\n *\n **/\n private _insertPolyfillRulesInCssText(cssText: string): string {\n return cssText.replace(_cssContentRuleRe, (...m: string[]) => {\n const rule = m[0].replace(m[1], '').replace(m[2], '');\n return m[4] + rule;\n });\n }\n\n /* Ensure styles are scoped. Pseudo-scoping takes a rule like:\n *\n * .foo {... }\n *\n * and converts this to\n *\n * scopeName .foo { ... }\n */\n private _scopeCssText(cssText: string, scopeSelector: string, hostSelector: string): string {\n const unscopedRules = this._extractUnscopedRulesFromCssText(cssText);\n // replace :host and :host-context -shadowcsshost and -shadowcsshost respectively\n cssText = this._insertPolyfillHostInCssText(cssText);\n cssText = this._convertColonHost(cssText);\n cssText = this._convertColonHostContext(cssText);\n cssText = this._convertShadowDOMSelectors(cssText);\n if (scopeSelector) {\n cssText = this._scopeKeyframesRelatedCss(cssText, scopeSelector);\n cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector);\n }\n cssText = cssText + '\\n' + unscopedRules;\n return cssText.trim();\n }\n\n /*\n * Process styles to add rules which will only apply under the polyfill\n * and do not process via CSSOM. (CSSOM is destructive to rules on rare\n * occasions, e.g. -webkit-calc on Safari.)\n * For example, we convert this rule:\n *\n * @polyfill-unscoped-rule {\n * content: 'menu-item';\n * ... }\n *\n * to this:\n *\n * menu-item {...}\n *\n **/\n private _extractUnscopedRulesFromCssText(cssText: string): string {\n let r = '';\n let m: RegExpExecArray | null;\n _cssContentUnscopedRuleRe.lastIndex = 0;\n while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) {\n const rule = m[0].replace(m[2], '').replace(m[1], m[4]);\n r += rule + '\\n\\n';\n }\n return r;\n }\n\n /*\n * convert a rule like :host(.foo) > .bar { }\n *\n * to\n *\n * .foo > .bar\n */\n private _convertColonHost(cssText: string): string {\n return cssText.replace(_cssColonHostRe, (_, hostSelectors: string, otherSelectors: string) => {\n if (hostSelectors) {\n const convertedSelectors: string[] = [];\n const hostSelectorArray = hostSelectors.split(',').map((p) => p.trim());\n for (const hostSelector of hostSelectorArray) {\n if (!hostSelector) break;\n const convertedSelector =\n _polyfillHostNoCombinator + hostSelector.replace(_polyfillHost, '') + otherSelectors;\n convertedSelectors.push(convertedSelector);\n }\n return convertedSelectors.join(',');\n } else {\n return _polyfillHostNoCombinator + otherSelectors;\n }\n });\n }\n\n /*\n * convert a rule like :host-context(.foo) > .bar { }\n *\n * to\n *\n * .foo > .bar, .foo > .bar { }\n *\n * and\n *\n * :host-context(.foo:host) .bar { ... }\n *\n * to\n *\n * .foo .bar { ... }\n */\n private _convertColonHostContext(cssText: string): string {\n return cssText.replace(_cssColonHostContextReGlobal, (selectorText) => {\n // We have captured a selector that contains a `:host-context` rule.\n\n // For backward compatibility `:host-context` may contain a comma separated list of selectors.\n // Each context selector group will contain a list of host-context selectors that must match\n // an ancestor of the host.\n // (Normally `contextSelectorGroups` will only contain a single array of context selectors.)\n const contextSelectorGroups: string[][] = [[]];\n\n // There may be more than `:host-context` in this selector so `selectorText` could look like:\n // `:host-context(.one):host-context(.two)`.\n // Execute `_cssColonHostContextRe` over and over until we have extracted all the\n // `:host-context` selectors from this selector.\n let match: RegExpExecArray | null;\n while ((match = _cssColonHostContextRe.exec(selectorText))) {\n // `match` = [':host-context()', , ]\n\n // The `` could actually be a comma separated list: `:host-context(.one, .two)`.\n const newContextSelectors = (match[1] ?? '')\n .trim()\n .split(',')\n .map((m) => m.trim())\n .filter((m) => m !== '');\n\n // We must duplicate the current selector group for each of these new selectors.\n // For example if the current groups are:\n // ```\n // [\n // ['a', 'b', 'c'],\n // ['x', 'y', 'z'],\n // ]\n // ```\n // And we have a new set of comma separated selectors: `:host-context(m,n)` then the new\n // groups are:\n // ```\n // [\n // ['a', 'b', 'c', 'm'],\n // ['x', 'y', 'z', 'm'],\n // ['a', 'b', 'c', 'n'],\n // ['x', 'y', 'z', 'n'],\n // ]\n // ```\n const contextSelectorGroupsLength = contextSelectorGroups.length;\n repeatGroups(contextSelectorGroups, newContextSelectors.length);\n for (let i = 0; i < newContextSelectors.length; i++) {\n for (let j = 0; j < contextSelectorGroupsLength; j++) {\n contextSelectorGroups[j + i * contextSelectorGroupsLength].push(newContextSelectors[i]);\n }\n }\n\n // Update the `selectorText` and see repeat to see if there are more `:host-context`s.\n selectorText = match[2];\n }\n\n // The context selectors now must be combined with each other to capture all the possible\n // selectors that `:host-context` can match. See `combineHostContextSelectors()` for more\n // info about how this is done.\n return contextSelectorGroups\n .map((contextSelectors) => combineHostContextSelectors(contextSelectors, selectorText))\n .join(', ');\n });\n }\n\n /*\n * Convert combinators like ::shadow and pseudo-elements like ::content\n * by replacing with space.\n */\n private _convertShadowDOMSelectors(cssText: string): string {\n return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, ' '), cssText);\n }\n\n // change a selector like 'div' to 'name div'\n private _scopeSelectors(cssText: string, scopeSelector: string, hostSelector: string): string {\n return processRules(cssText, (rule: CssRule) => {\n let selector = rule.selector;\n let content = rule.content;\n if (rule.selector[0] !== '@') {\n selector = this._scopeSelector(rule.selector, scopeSelector, hostSelector);\n } else if (scopedAtRuleIdentifiers.some((atRule) => rule.selector.startsWith(atRule))) {\n content = this._scopeSelectors(rule.content, scopeSelector, hostSelector);\n } else if (rule.selector.startsWith('@font-face') || rule.selector.startsWith('@page')) {\n content = this._stripScopingSelectors(rule.content);\n }\n return new CssRule(selector, content);\n });\n }\n\n /**\n * Handle a css text that is within a rule that should not contain scope selectors by simply\n * removing them! An example of such a rule is `@font-face`.\n *\n * `@font-face` rules cannot contain nested selectors. Nor can they be nested under a selector.\n * Normally this would be a syntax error by the author of the styles. But in some rare cases, such\n * as importing styles from a library, and applying `:host ::ng-deep` to the imported styles, we\n * can end up with broken css if the imported styles happen to contain @font-face rules.\n *\n * For example:\n *\n * ```\n * :host ::ng-deep {\n * import 'some/lib/containing/font-face';\n * }\n *\n * Similar logic applies to `@page` rules which can contain a particular set of properties,\n * as well as some specific at-rules. Since they can't be encapsulated, we have to strip\n * any scoping selectors from them. For more information: https://www.w3.org/TR/css-page-3\n * ```\n */\n private _stripScopingSelectors(cssText: string): string {\n return processRules(cssText, (rule) => {\n const selector = rule.selector\n .replace(_shadowDeepSelectors, ' ')\n .replace(_polyfillHostNoCombinatorRe, ' ');\n return new CssRule(selector, rule.content);\n });\n }\n\n private _scopeSelector(selector: string, scopeSelector: string, hostSelector: string): string {\n return selector\n .split(/ ?, ?/)\n .map((part) => part.split(_shadowDeepSelectors))\n .map((deepParts) => {\n const [shallowPart, ...otherParts] = deepParts;\n const applyScope = (shallowPart: string) => {\n if (this._selectorNeedsScoping(shallowPart, scopeSelector)) {\n return this._applySelectorScope(shallowPart, scopeSelector, hostSelector);\n } else {\n return shallowPart;\n }\n };\n return [applyScope(shallowPart), ...otherParts].join(' ');\n })\n .join(', ');\n }\n\n private _selectorNeedsScoping(selector: string, scopeSelector: string): boolean {\n const re = this._makeScopeMatcher(scopeSelector);\n return !re.test(selector);\n }\n\n private _makeScopeMatcher(scopeSelector: string): RegExp {\n const lre = /\\[/g;\n const rre = /\\]/g;\n scopeSelector = scopeSelector.replace(lre, '\\\\[').replace(rre, '\\\\]');\n return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');\n }\n\n // scope via name and [is=name]\n private _applySimpleSelectorScope(\n selector: string,\n scopeSelector: string,\n hostSelector: string,\n ): string {\n // In Android browser, the lastIndex is not reset when the regex is used in String.replace()\n _polyfillHostRe.lastIndex = 0;\n if (_polyfillHostRe.test(selector)) {\n const replaceBy = `[${hostSelector}]`;\n return selector\n .replace(_polyfillHostNoCombinatorRe, (hnc, selector) => {\n return selector.replace(\n /([^:]*)(:*)(.*)/,\n (_: string, before: string, colon: string, after: string) => {\n return before + replaceBy + colon + after;\n },\n );\n })\n .replace(_polyfillHostRe, replaceBy + ' ');\n }\n\n return scopeSelector + ' ' + selector;\n }\n\n // return a selector with [name] suffix on each simple selector\n // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name] /** @internal */\n private _applySelectorScope(\n selector: string,\n scopeSelector: string,\n hostSelector: string,\n ): string {\n const isRe = /\\[is=([^\\]]*)\\]/g;\n scopeSelector = scopeSelector.replace(isRe, (_: string, ...parts: string[]) => parts[0]);\n\n const attrName = '[' + scopeSelector + ']';\n\n const _scopeSelectorPart = (p: string) => {\n let scopedP = p.trim();\n\n if (!scopedP) {\n return p;\n }\n\n if (p.includes(_polyfillHostNoCombinator)) {\n scopedP = this._applySimpleSelectorScope(p, scopeSelector, hostSelector);\n } else {\n // remove :host since it should be unnecessary\n const t = p.replace(_polyfillHostRe, '');\n if (t.length > 0) {\n const matches = t.match(/([^:]*)(:*)(.*)/);\n if (matches) {\n scopedP = matches[1] + attrName + matches[2] + matches[3];\n }\n }\n }\n\n return scopedP;\n };\n\n const safeContent = new SafeSelector(selector);\n selector = safeContent.content();\n\n let scopedSelector = '';\n let startIndex = 0;\n let res: RegExpExecArray | null;\n const sep = /( |>|\\+|~(?!=))\\s*/g;\n\n // If a selector appears before :host it should not be shimmed as it\n // matches on ancestor elements and not on elements in the host's shadow\n // `:host-context(div)` is transformed to\n // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator`\n // the `div` is not part of the component in the 2nd selectors and should not be scoped.\n // Historically `component-tag:host` was matching the component so we also want to preserve\n // this behavior to avoid breaking legacy apps (it should not match).\n // The behavior should be:\n // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)\n // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a\n // `:host-context(tag)`)\n const hasHost = selector.includes(_polyfillHostNoCombinator);\n // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present\n let shouldScope = !hasHost;\n\n while ((res = sep.exec(selector)) !== null) {\n const separator = res[1];\n // Do not trim the selector, as otherwise this will break sourcemaps\n // when they are defined on multiple lines\n // Example:\n // div,\n // p { color: red}\n const part = selector.slice(startIndex, res.index);\n\n // A space following an escaped hex value and followed by another hex character\n // (ie: \".\\fc ber\" for \".über\") is not a separator between 2 selectors\n // also keep in mind that backslashes are replaced by a placeholder by SafeSelector\n // These escaped selectors happen for example when esbuild runs with optimization.minify.\n if (part.match(/__esc-ph-(\\d+)__/) && selector[res.index + 1]?.match(/[a-fA-F\\d]/)) {\n continue;\n }\n\n shouldScope = shouldScope || part.includes(_polyfillHostNoCombinator);\n const scopedPart = shouldScope ? _scopeSelectorPart(part) : part;\n scopedSelector += `${scopedPart} ${separator} `;\n startIndex = sep.lastIndex;\n }\n\n const part = selector.substring(startIndex);\n shouldScope = shouldScope || part.includes(_polyfillHostNoCombinator);\n scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;\n\n // replace the placeholders with their original values\n return safeContent.restore(scopedSelector);\n }\n\n private _insertPolyfillHostInCssText(selector: string): string {\n return selector\n .replace(_colonHostContextRe, _polyfillHostContext)\n .replace(_colonHostRe, _polyfillHost);\n }\n}\n\nclass SafeSelector {\n private placeholders: string[] = [];\n private index = 0;\n private _content: string;\n\n constructor(selector: string) {\n // Replaces attribute selectors with placeholders.\n // The WS in [attr=\"va lue\"] would otherwise be interpreted as a selector separator.\n selector = this._escapeRegexMatches(selector, /(\\[[^\\]]*\\])/g);\n\n // CSS allows for certain special characters to be used in selectors if they're escaped.\n // E.g. `.foo:blue` won't match a class called `foo:blue`, because the colon denotes a\n // pseudo-class, but writing `.foo\\:blue` will match, because the colon was escaped.\n // Replace all escape sequences (`\\` followed by a character) with a placeholder so\n // that our handling of pseudo-selectors doesn't mess with them.\n // Escaped characters have a specific placeholder so they can be detected separately.\n selector = selector.replace(/(\\\\.)/g, (_, keep) => {\n const replaceBy = `__esc-ph-${this.index}__`;\n this.placeholders.push(keep);\n this.index++;\n return replaceBy;\n });\n\n // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.\n // WS and \"+\" would otherwise be interpreted as selector separators.\n this._content = selector.replace(/(:nth-[-\\w]+)(\\([^)]+\\))/g, (_, pseudo, exp) => {\n const replaceBy = `__ph-${this.index}__`;\n this.placeholders.push(exp);\n this.index++;\n return pseudo + replaceBy;\n });\n }\n\n restore(content: string): string {\n return content.replace(/__(?:ph|esc-ph)-(\\d+)__/g, (_ph, index) => this.placeholders[+index]);\n }\n\n content(): string {\n return this._content;\n }\n\n /**\n * Replaces all of the substrings that match a regex within a\n * special string (e.g. `__ph-0__`, `__ph-1__`, etc).\n */\n private _escapeRegexMatches(content: string, pattern: RegExp): string {\n return content.replace(pattern, (_, keep) => {\n const replaceBy = `__ph-${this.index}__`;\n this.placeholders.push(keep);\n this.index++;\n return replaceBy;\n });\n }\n}\n\nconst _cssContentNextSelectorRe =\n /polyfill-next-selector[^}]*content:[\\s]*?(['\"])(.*?)\\1[;\\s]*}([^{]*?){/gim;\nconst _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\\s]*(['\"])(.*?)\\3)[;\\s]*[^}]*}/gim;\nconst _cssContentUnscopedRuleRe =\n /(polyfill-unscoped-rule)[^}]*(content:[\\s]*(['\"])(.*?)\\3)[;\\s]*[^}]*}/gim;\nconst _polyfillHost = '-shadowcsshost';\n// note: :host-context pre-processed to -shadowcsshostcontext.\nconst _polyfillHostContext = '-shadowcsscontext';\nconst _parenSuffix = '(?:\\\\((' + '(?:\\\\([^)(]*\\\\)|[^)(]*)+?' + ')\\\\))?([^,{]*)';\nconst _cssColonHostRe = new RegExp(_polyfillHost + _parenSuffix, 'gim');\nconst _cssColonHostContextReGlobal = new RegExp(_polyfillHostContext + _parenSuffix, 'gim');\nconst _cssColonHostContextRe = new RegExp(_polyfillHostContext + _parenSuffix, 'im');\nconst _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';\nconst _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\\s]*)/;\nconst _shadowDOMSelectorsRe = [\n /::shadow/g,\n /::content/g,\n // Deprecated selectors\n /\\/shadow-deep\\//g,\n /\\/shadow\\//g,\n];\n\n// The deep combinator is deprecated in the CSS spec\n// Support for `>>>`, `deep`, `::ng-deep` is then also deprecated and will be removed in the future.\n// see https://github.com/angular/angular/pull/17677\nconst _shadowDeepSelectors = /(?:>>>)|(?:\\/deep\\/)|(?:::ng-deep)/g;\nconst _selectorReSuffix = '([>\\\\s~+[.,{:][\\\\s\\\\S]*)?$';\nconst _polyfillHostRe = /-shadowcsshost/gim;\nconst _colonHostRe = /:host/gim;\nconst _colonHostContextRe = /:host-context/gim;\n\nconst _newLinesRe = /\\r?\\n/g;\nconst _commentRe = /\\/\\*[\\s\\S]*?\\*\\//g;\nconst _commentWithHashRe = /\\/\\*\\s*#\\s*source(Mapping)?URL=/g;\nconst COMMENT_PLACEHOLDER = '%COMMENT%';\nconst _commentWithHashPlaceHolderRe = new RegExp(COMMENT_PLACEHOLDER, 'g');\n\nconst BLOCK_PLACEHOLDER = '%BLOCK%';\nconst _ruleRe = new RegExp(\n `(\\\\s*(?:${COMMENT_PLACEHOLDER}\\\\s*)*)([^;\\\\{\\\\}]+?)(\\\\s*)((?:{%BLOCK%}?\\\\s*;?)|(?:\\\\s*;))`,\n 'g',\n);\nconst CONTENT_PAIRS = new Map([['{', '}']]);\n\nconst COMMA_IN_PLACEHOLDER = '%COMMA_IN_PLACEHOLDER%';\nconst SEMI_IN_PLACEHOLDER = '%SEMI_IN_PLACEHOLDER%';\nconst COLON_IN_PLACEHOLDER = '%COLON_IN_PLACEHOLDER%';\n\nconst _cssCommaInPlaceholderReGlobal = new RegExp(COMMA_IN_PLACEHOLDER, 'g');\nconst _cssSemiInPlaceholderReGlobal = new RegExp(SEMI_IN_PLACEHOLDER, 'g');\nconst _cssColonInPlaceholderReGlobal = new RegExp(COLON_IN_PLACEHOLDER, 'g');\n\nexport class CssRule {\n constructor(\n public selector: string,\n public content: string,\n ) {}\n}\n\nexport function processRules(input: string, ruleCallback: (rule: CssRule) => CssRule): string {\n const escaped = escapeInStrings(input);\n const inputWithEscapedBlocks = escapeBlocks(escaped, CONTENT_PAIRS, BLOCK_PLACEHOLDER);\n let nextBlockIndex = 0;\n const escapedResult = inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m: string[]) => {\n const selector = m[2];\n let content = '';\n let suffix = m[4];\n let contentPrefix = '';\n if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) {\n content = inputWithEscapedBlocks.blocks[nextBlockIndex++];\n suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);\n contentPrefix = '{';\n }\n const rule = ruleCallback(new CssRule(selector, content));\n return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;\n });\n return unescapeInStrings(escapedResult);\n}\n\nclass StringWithEscapedBlocks {\n constructor(\n public escapedString: string,\n public blocks: string[],\n ) {}\n}\n\nfunction escapeBlocks(\n input: string,\n charPairs: Map,\n placeholder: string,\n): StringWithEscapedBlocks {\n const resultParts: string[] = [];\n const escapedBlocks: string[] = [];\n let openCharCount = 0;\n let nonBlockStartIndex = 0;\n let blockStartIndex = -1;\n let openChar: string | undefined;\n let closeChar: string | undefined;\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n if (char === '\\\\') {\n i++;\n } else if (char === closeChar) {\n openCharCount--;\n if (openCharCount === 0) {\n escapedBlocks.push(input.substring(blockStartIndex, i));\n resultParts.push(placeholder);\n nonBlockStartIndex = i;\n blockStartIndex = -1;\n openChar = closeChar = undefined;\n }\n } else if (char === openChar) {\n openCharCount++;\n } else if (openCharCount === 0 && charPairs.has(char)) {\n openChar = char;\n closeChar = charPairs.get(char);\n openCharCount = 1;\n blockStartIndex = i + 1;\n resultParts.push(input.substring(nonBlockStartIndex, blockStartIndex));\n }\n }\n\n if (blockStartIndex !== -1) {\n escapedBlocks.push(input.substring(blockStartIndex));\n resultParts.push(placeholder);\n } else {\n resultParts.push(input.substring(nonBlockStartIndex));\n }\n\n return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);\n}\n\n/**\n * Object containing as keys characters that should be substituted by placeholders\n * when found in strings during the css text parsing, and as values the respective\n * placeholders\n */\nconst ESCAPE_IN_STRING_MAP: {[key: string]: string} = {\n ';': SEMI_IN_PLACEHOLDER,\n ',': COMMA_IN_PLACEHOLDER,\n ':': COLON_IN_PLACEHOLDER,\n};\n\n/**\n * Parse the provided css text and inside strings (meaning, inside pairs of unescaped single or\n * double quotes) replace specific characters with their respective placeholders as indicated\n * by the `ESCAPE_IN_STRING_MAP` map.\n *\n * For example convert the text\n * `animation: \"my-anim:at\\\"ion\" 1s;`\n * to\n * `animation: \"my-anim%COLON_IN_PLACEHOLDER%at\\\"ion\" 1s;`\n *\n * This is necessary in order to remove the meaning of some characters when found inside strings\n * (for example `;` indicates the end of a css declaration, `,` the sequence of values and `:` the\n * division between property and value during a declaration, none of these meanings apply when such\n * characters are within strings and so in order to prevent parsing issues they need to be replaced\n * with placeholder text for the duration of the css manipulation process).\n *\n * @param input the original css text.\n *\n * @returns the css text with specific characters in strings replaced by placeholders.\n **/\nfunction escapeInStrings(input: string): string {\n let result = input;\n let currentQuoteChar: string | null = null;\n for (let i = 0; i < result.length; i++) {\n const char = result[i];\n if (char === '\\\\') {\n i++;\n } else {\n if (currentQuoteChar !== null) {\n // index i is inside a quoted sub-string\n if (char === currentQuoteChar) {\n currentQuoteChar = null;\n } else {\n const placeholder: string | undefined = ESCAPE_IN_STRING_MAP[char];\n if (placeholder) {\n result = `${result.substr(0, i)}${placeholder}${result.substr(i + 1)}`;\n i += placeholder.length - 1;\n }\n }\n } else if (char === \"'\" || char === '\"') {\n currentQuoteChar = char;\n }\n }\n }\n return result;\n}\n\n/**\n * Replace in a string all occurrences of keys in the `ESCAPE_IN_STRING_MAP` map with their\n * original representation, this is simply used to revert the changes applied by the\n * escapeInStrings function.\n *\n * For example it reverts the text:\n * `animation: \"my-anim%COLON_IN_PLACEHOLDER%at\\\"ion\" 1s;`\n * to it's original form of:\n * `animation: \"my-anim:at\\\"ion\" 1s;`\n *\n * Note: For the sake of simplicity this function does not check that the placeholders are\n * actually inside strings as it would anyway be extremely unlikely to find them outside of strings.\n *\n * @param input the css text containing the placeholders.\n *\n * @returns the css text without the placeholders.\n */\nfunction unescapeInStrings(input: string): string {\n let result = input.replace(_cssCommaInPlaceholderReGlobal, ',');\n result = result.replace(_cssSemiInPlaceholderReGlobal, ';');\n result = result.replace(_cssColonInPlaceholderReGlobal, ':');\n return result;\n}\n\n/**\n * Unescape all quotes present in a string, but only if the string was actually already\n * quoted.\n *\n * This generates a \"canonical\" representation of strings which can be used to match strings\n * which would otherwise only differ because of differently escaped quotes.\n *\n * For example it converts the string (assumed to be quoted):\n * `this \\\\\"is\\\\\" a \\\\'\\\\\\\\'test`\n * to:\n * `this \"is\" a '\\\\\\\\'test`\n * (note that the latter backslashes are not removed as they are not actually escaping the single\n * quote)\n *\n *\n * @param input the string possibly containing escaped quotes.\n * @param isQuoted boolean indicating whether the string was quoted inside a bigger string (if not\n * then it means that it doesn't represent an inner string and thus no unescaping is required)\n *\n * @returns the string in the \"canonical\" representation without escaped quotes.\n */\nfunction unescapeQuotes(str: string, isQuoted: boolean): string {\n return !isQuoted ? str : str.replace(/((?:^|[^\\\\])(?:\\\\\\\\)*)\\\\(?=['\"])/g, '$1');\n}\n\n/**\n * Combine the `contextSelectors` with the `hostMarker` and the `otherSelectors`\n * to create a selector that matches the same as `:host-context()`.\n *\n * Given a single context selector `A` we need to output selectors that match on the host and as an\n * ancestor of the host:\n *\n * ```\n * A , A {}\n * ```\n *\n * When there is more than one context selector we also have to create combinations of those\n * selectors with each other. For example if there are `A` and `B` selectors the output is:\n *\n * ```\n * AB, AB , A B,\n * B A, A B , B A {}\n * ```\n *\n * And so on...\n *\n * @param contextSelectors an array of context selectors that will be combined.\n * @param otherSelectors the rest of the selectors that are not context selectors.\n */\nfunction combineHostContextSelectors(contextSelectors: string[], otherSelectors: string): string {\n const hostMarker = _polyfillHostNoCombinator;\n _polyfillHostRe.lastIndex = 0; // reset the regex to ensure we get an accurate test\n const otherSelectorsHasHost = _polyfillHostRe.test(otherSelectors);\n\n // If there are no context selectors then just output a host marker\n if (contextSelectors.length === 0) {\n return hostMarker + otherSelectors;\n }\n\n const combined: string[] = [contextSelectors.pop() || ''];\n while (contextSelectors.length > 0) {\n const length = combined.length;\n const contextSelector = contextSelectors.pop();\n for (let i = 0; i < length; i++) {\n const previousSelectors = combined[i];\n // Add the new selector as a descendant of the previous selectors\n combined[length * 2 + i] = previousSelectors + ' ' + contextSelector;\n // Add the new selector as an ancestor of the previous selectors\n combined[length + i] = contextSelector + ' ' + previousSelectors;\n // Add the new selector to act on the same element as the previous selectors\n combined[i] = contextSelector + previousSelectors;\n }\n }\n // Finally connect the selector to the `hostMarker`s: either acting directly on the host\n // (A) or as an ancestor (A ).\n return combined\n .map((s) =>\n otherSelectorsHasHost\n ? `${s}${otherSelectors}`\n : `${s}${hostMarker}${otherSelectors}, ${s} ${hostMarker}${otherSelectors}`,\n )\n .join(',');\n}\n\n/**\n * Mutate the given `groups` array so that there are `multiples` clones of the original array\n * stored.\n *\n * For example `repeatGroups([a, b], 3)` will result in `[a, b, a, b, a, b]` - but importantly the\n * newly added groups will be clones of the original.\n *\n * @param groups An array of groups of strings that will be repeated. This array is mutated\n * in-place.\n * @param multiples The number of times the current groups should appear.\n */\nexport function repeatGroups(groups: string[][], multiples: number): void {\n const length = groups.length;\n for (let i = 1; i < multiples; i++) {\n for (let j = 0; j < length; j++) {\n groups[j + i * length] = groups[j].slice(0);\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * Distinguishes different kinds of IR operations.\n *\n * Includes both creation and update operations.\n */\nexport enum OpKind {\n /**\n * A special operation type which is used to represent the beginning and end nodes of a linked\n * list of operations.\n */\n ListEnd,\n\n /**\n * An operation which wraps an output AST statement.\n */\n Statement,\n\n /**\n * An operation which declares and initializes a `SemanticVariable`.\n */\n Variable,\n\n /**\n * An operation to begin rendering of an element.\n */\n ElementStart,\n\n /**\n * An operation to render an element with no children.\n */\n Element,\n\n /**\n * An operation which declares an embedded view.\n */\n Template,\n\n /**\n * An operation to end rendering of an element previously started with `ElementStart`.\n */\n ElementEnd,\n\n /**\n * An operation to begin an `ng-container`.\n */\n ContainerStart,\n\n /**\n * An operation for an `ng-container` with no children.\n */\n Container,\n\n /**\n * An operation to end an `ng-container`.\n */\n ContainerEnd,\n\n /**\n * An operation disable binding for subsequent elements, which are descendants of a non-bindable\n * node.\n */\n DisableBindings,\n\n /**\n * An op to conditionally render a template.\n */\n Conditional,\n\n /**\n * An operation to re-enable binding, after it was previously disabled.\n */\n EnableBindings,\n\n /**\n * An operation to render a text node.\n */\n Text,\n\n /**\n * An operation declaring an event listener for an element.\n */\n Listener,\n\n /**\n * An operation to interpolate text into a text node.\n */\n InterpolateText,\n\n /**\n * An intermediate binding op, that has not yet been processed into an individual property,\n * attribute, style, etc.\n */\n Binding,\n\n /**\n * An operation to bind an expression to a property of an element.\n */\n Property,\n\n /**\n * An operation to bind an expression to a style property of an element.\n */\n StyleProp,\n\n /**\n * An operation to bind an expression to a class property of an element.\n */\n ClassProp,\n\n /**\n * An operation to bind an expression to the styles of an element.\n */\n StyleMap,\n\n /**\n * An operation to bind an expression to the classes of an element.\n */\n ClassMap,\n\n /**\n * An operation to advance the runtime's implicit slot context during the update phase of a view.\n */\n Advance,\n\n /**\n * An operation to instantiate a pipe.\n */\n Pipe,\n\n /**\n * An operation to associate an attribute with an element.\n */\n Attribute,\n\n /**\n * An attribute that has been extracted for inclusion in the consts array.\n */\n ExtractedAttribute,\n\n /**\n * An operation that configures a `@defer` block.\n */\n Defer,\n\n /**\n * An operation that controls when a `@defer` loads.\n */\n DeferOn,\n\n /**\n * An operation that controls when a `@defer` loads, using a custom expression as the condition.\n */\n DeferWhen,\n\n /**\n * An i18n message that has been extracted for inclusion in the consts array.\n */\n I18nMessage,\n\n /**\n * A host binding property.\n */\n HostProperty,\n\n /**\n * A namespace change, which causes the subsequent elements to be processed as either HTML or SVG.\n */\n Namespace,\n\n /**\n * Configure a content projeciton definition for the view.\n */\n ProjectionDef,\n\n /**\n * Create a content projection slot.\n */\n Projection,\n\n /**\n * Create a repeater creation instruction op.\n */\n RepeaterCreate,\n\n /**\n * An update up for a repeater.\n */\n Repeater,\n\n /**\n * An operation to bind an expression to the property side of a two-way binding.\n */\n TwoWayProperty,\n\n /**\n * An operation declaring the event side of a two-way binding.\n */\n TwoWayListener,\n\n /**\n * A creation-time operation that initializes the slot for a `@let` declaration.\n */\n DeclareLet,\n\n /**\n * An update-time operation that stores the current value of a `@let` declaration.\n */\n StoreLet,\n\n /**\n * The start of an i18n block.\n */\n I18nStart,\n\n /**\n * A self-closing i18n on a single element.\n */\n I18n,\n\n /**\n * The end of an i18n block.\n */\n I18nEnd,\n\n /**\n * An expression in an i18n message.\n */\n I18nExpression,\n\n /**\n * An instruction that applies a set of i18n expressions.\n */\n I18nApply,\n\n /**\n * An instruction to create an ICU expression.\n */\n IcuStart,\n\n /**\n * An instruction to update an ICU expression.\n */\n IcuEnd,\n\n /**\n * An instruction representing a placeholder in an ICU expression.\n */\n IcuPlaceholder,\n\n /**\n * An i18n context containing information needed to generate an i18n message.\n */\n I18nContext,\n\n /**\n * A creation op that corresponds to i18n attributes on an element.\n */\n I18nAttributes,\n}\n\n/**\n * Distinguishes different kinds of IR expressions.\n */\nexport enum ExpressionKind {\n /**\n * Read of a variable in a lexical scope.\n */\n LexicalRead,\n\n /**\n * A reference to the current view context.\n */\n Context,\n\n /**\n * A reference to the view context, for use inside a track function.\n */\n TrackContext,\n\n /**\n * Read of a variable declared in a `VariableOp`.\n */\n ReadVariable,\n\n /**\n * Runtime operation to navigate to the next view context in the view hierarchy.\n */\n NextContext,\n\n /**\n * Runtime operation to retrieve the value of a local reference.\n */\n Reference,\n\n /**\n * A call storing the value of a `@let` declaration.\n */\n StoreLet,\n\n /**\n * A reference to a `@let` declaration read from the context view.\n */\n ContextLetReference,\n\n /**\n * Runtime operation to snapshot the current view context.\n */\n GetCurrentView,\n\n /**\n * Runtime operation to restore a snapshotted view.\n */\n RestoreView,\n\n /**\n * Runtime operation to reset the current view context after `RestoreView`.\n */\n ResetView,\n\n /**\n * Defines and calls a function with change-detected arguments.\n */\n PureFunctionExpr,\n\n /**\n * Indicates a positional parameter to a pure function definition.\n */\n PureFunctionParameterExpr,\n\n /**\n * Binding to a pipe transformation.\n */\n PipeBinding,\n\n /**\n * Binding to a pipe transformation with a variable number of arguments.\n */\n PipeBindingVariadic,\n\n /*\n * A safe property read requiring expansion into a null check.\n */\n SafePropertyRead,\n\n /**\n * A safe keyed read requiring expansion into a null check.\n */\n SafeKeyedRead,\n\n /**\n * A safe function call requiring expansion into a null check.\n */\n SafeInvokeFunction,\n\n /**\n * An intermediate expression that will be expanded from a safe read into an explicit ternary.\n */\n SafeTernaryExpr,\n\n /**\n * An empty expression that will be stipped before generating the final output.\n */\n EmptyExpr,\n\n /*\n * An assignment to a temporary variable.\n */\n AssignTemporaryExpr,\n\n /**\n * A reference to a temporary variable.\n */\n ReadTemporaryExpr,\n\n /**\n * An expression that will cause a literal slot index to be emitted.\n */\n SlotLiteralExpr,\n\n /**\n * A test expression for a conditional op.\n */\n ConditionalCase,\n\n /**\n * An expression that will be automatically extracted to the component const array.\n */\n ConstCollected,\n\n /**\n * Operation that sets the value of a two-way binding.\n */\n TwoWayBindingSet,\n}\n\nexport enum VariableFlags {\n None = 0b0000,\n\n /**\n * Always inline this variable, regardless of the number of times it's used.\n * An `AlwaysInline` variable may not depend on context, because doing so may cause side effects\n * that are illegal when multi-inlined. (The optimizer will enforce this constraint.)\n */\n AlwaysInline = 0b0001,\n}\n/**\n * Distinguishes between different kinds of `SemanticVariable`s.\n */\nexport enum SemanticVariableKind {\n /**\n * Represents the context of a particular view.\n */\n Context,\n\n /**\n * Represents an identifier declared in the lexical scope of a view.\n */\n Identifier,\n\n /**\n * Represents a saved state that can be used to restore a view in a listener handler function.\n */\n SavedView,\n\n /**\n * An alias generated by a special embedded view type (e.g. a `@for` block).\n */\n Alias,\n}\n\n/**\n * Whether to compile in compatibilty mode. In compatibility mode, the template pipeline will\n * attempt to match the output of `TemplateDefinitionBuilder` as exactly as possible, at the cost\n * of producing quirky or larger code in some cases.\n */\nexport enum CompatibilityMode {\n Normal,\n TemplateDefinitionBuilder,\n}\n\n/**\n * Enumeration of the types of attributes which can be applied to an element.\n */\nexport enum BindingKind {\n /**\n * Static attributes.\n */\n Attribute,\n\n /**\n * Class bindings.\n */\n ClassName,\n\n /**\n * Style bindings.\n */\n StyleProperty,\n\n /**\n * Dynamic property bindings.\n */\n Property,\n\n /**\n * Property or attribute bindings on a template.\n */\n Template,\n\n /**\n * Internationalized attributes.\n */\n I18n,\n\n /**\n * Animation property bindings.\n */\n Animation,\n\n /**\n * Property side of a two-way binding.\n */\n TwoWayProperty,\n}\n\n/**\n * Enumeration of possible times i18n params can be resolved.\n */\nexport enum I18nParamResolutionTime {\n /**\n * Param is resolved at message creation time. Most params should be resolved at message creation\n * time. However, ICU params need to be handled in post-processing.\n */\n Creation,\n\n /**\n * Param is resolved during post-processing. This should be used for params whose value comes from\n * an ICU.\n */\n Postproccessing,\n}\n\n/**\n * The contexts in which an i18n expression can be used.\n */\nexport enum I18nExpressionFor {\n /**\n * This expression is used as a value (i.e. inside an i18n block).\n */\n I18nText,\n\n /**\n * This expression is used in a binding.\n */\n I18nAttribute,\n}\n\n/**\n * Flags that describe what an i18n param value. These determine how the value is serialized into\n * the final map.\n */\nexport enum I18nParamValueFlags {\n None = 0b0000,\n\n /**\n * This value represents an element tag.\n */\n ElementTag = 0b1,\n\n /**\n * This value represents a template tag.\n */\n TemplateTag = 0b10,\n\n /**\n * This value represents the opening of a tag.\n */\n OpenTag = 0b0100,\n\n /**\n * This value represents the closing of a tag.\n */\n CloseTag = 0b1000,\n\n /**\n * This value represents an i18n expression index.\n */\n ExpressionIndex = 0b10000,\n}\n\n/**\n * Whether the active namespace is HTML, MathML, or SVG mode.\n */\nexport enum Namespace {\n HTML,\n SVG,\n Math,\n}\n\n/**\n * The type of a `@defer` trigger, for use in the ir.\n */\nexport enum DeferTriggerKind {\n Idle,\n Immediate,\n Timer,\n Hover,\n Interaction,\n Viewport,\n}\n\n/**\n * Kinds of i18n contexts. They can be created because of root i18n blocks, or ICUs.\n */\nexport enum I18nContextKind {\n RootI18n,\n Icu,\n Attr,\n}\n\nexport enum TemplateKind {\n NgTemplate,\n Structural,\n Block,\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport type {ParseSourceSpan} from '../../../../parse_util';\nimport type {Expression} from './expression';\nimport * as o from '../../../../output/output_ast';\nimport type {Op, XrefId} from './operations';\nimport {SlotHandle} from './handle';\n\n/**\n * Marker symbol for `ConsumesSlotOpTrait`.\n */\nexport const ConsumesSlot = Symbol('ConsumesSlot');\n\n/**\n * Marker symbol for `DependsOnSlotContextOpTrait`.\n */\nexport const DependsOnSlotContext = Symbol('DependsOnSlotContext');\n\n/**\n * Marker symbol for `ConsumesVars` trait.\n */\nexport const ConsumesVarsTrait = Symbol('ConsumesVars');\n\n/**\n * Marker symbol for `UsesVarOffset` trait.\n */\nexport const UsesVarOffset = Symbol('UsesVarOffset');\n\n/**\n * Marks an operation as requiring allocation of one or more data slots for storage.\n */\nexport interface ConsumesSlotOpTrait {\n readonly [ConsumesSlot]: true;\n\n /**\n * Assigned data slot (the starting index, if more than one slot is needed) for this operation, or\n * `null` if slots have not yet been assigned.\n */\n handle: SlotHandle;\n\n /**\n * The number of slots which will be used by this operation. By default 1, but can be increased if\n * necessary.\n */\n numSlotsUsed: number;\n\n /**\n * `XrefId` of this operation (e.g. the element stored in the assigned slot). This `XrefId` is\n * used to link this `ConsumesSlotOpTrait` operation with `DependsOnSlotContextTrait` or\n * `UsesSlotIndexExprTrait` implementors and ensure that the assigned slot is propagated through\n * the IR to all consumers.\n */\n xref: XrefId;\n}\n\n/**\n * Marks an operation as depending on the runtime's implicit slot context being set to a particular\n * slot.\n *\n * The runtime has an implicit slot context which is adjusted using the `advance()` instruction\n * during the execution of template update functions. This trait marks an operation as requiring\n * this implicit context to be `advance()`'d to point at a particular slot prior to execution.\n */\nexport interface DependsOnSlotContextOpTrait {\n readonly [DependsOnSlotContext]: true;\n\n /**\n * `XrefId` of the `ConsumesSlotOpTrait` which the implicit slot context must reference before\n * this operation can be executed.\n */\n target: XrefId;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Marker trait indicating that an operation or expression consumes variable storage space.\n */\nexport interface ConsumesVarsTrait {\n [ConsumesVarsTrait]: true;\n}\n\n/**\n * Marker trait indicating that an expression requires knowledge of the number of variable storage\n * slots used prior to it.\n */\nexport interface UsesVarOffsetTrait {\n [UsesVarOffset]: true;\n\n varOffset: number | null;\n}\n\n/**\n * Default values for most `ConsumesSlotOpTrait` fields (used with the spread operator to initialize\n * implementors of the trait).\n */\nexport const TRAIT_CONSUMES_SLOT: Omit = {\n [ConsumesSlot]: true,\n numSlotsUsed: 1,\n} as const;\n\n/**\n * Default values for most `DependsOnSlotContextOpTrait` fields (used with the spread operator to\n * initialize implementors of the trait).\n */\nexport const TRAIT_DEPENDS_ON_SLOT_CONTEXT: Omit<\n DependsOnSlotContextOpTrait,\n 'target' | 'sourceSpan'\n> = {\n [DependsOnSlotContext]: true,\n} as const;\n\n/**\n * Default values for `UsesVars` fields (used with the spread operator to initialize\n * implementors of the trait).\n */\nexport const TRAIT_CONSUMES_VARS: ConsumesVarsTrait = {\n [ConsumesVarsTrait]: true,\n} as const;\n\n/**\n * Test whether an operation implements `ConsumesSlotOpTrait`.\n */\nexport function hasConsumesSlotTrait>(\n op: OpT,\n): op is OpT & ConsumesSlotOpTrait {\n return (op as Partial)[ConsumesSlot] === true;\n}\n\n/**\n * Test whether an operation implements `DependsOnSlotContextOpTrait`.\n */\nexport function hasDependsOnSlotContextTrait(\n expr: ExprT,\n): expr is ExprT & DependsOnSlotContextOpTrait;\nexport function hasDependsOnSlotContextTrait>(\n op: OpT,\n): op is OpT & DependsOnSlotContextOpTrait;\nexport function hasDependsOnSlotContextTrait(value: any): boolean {\n return (value as Partial)[DependsOnSlotContext] === true;\n}\n\n/**\n * Test whether an operation implements `ConsumesVarsTrait`.\n */\nexport function hasConsumesVarsTrait(\n expr: ExprT,\n): expr is ExprT & ConsumesVarsTrait;\nexport function hasConsumesVarsTrait>(op: OpT): op is OpT & ConsumesVarsTrait;\nexport function hasConsumesVarsTrait(value: any): boolean {\n return (value as Partial)[ConsumesVarsTrait] === true;\n}\n\n/**\n * Test whether an expression implements `UsesVarOffsetTrait`.\n */\nexport function hasUsesVarOffsetTrait(\n expr: ExprT,\n): expr is ExprT & UsesVarOffsetTrait {\n return (expr as Partial)[UsesVarOffset] === true;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../../output/output_ast';\nimport {OpKind, VariableFlags} from '../enums';\nimport {Op, XrefId} from '../operations';\nimport {SemanticVariable} from '../variable';\n\n/**\n * A special `Op` which is used internally in the `OpList` linked list to represent the head and\n * tail nodes of the list.\n *\n * `ListEndOp` is created internally in the `OpList` and should not be instantiated directly.\n */\nexport interface ListEndOp> extends Op {\n kind: OpKind.ListEnd;\n}\n\n/**\n * An `Op` which directly wraps an output `Statement`.\n *\n * Often `StatementOp`s are the final result of IR processing.\n */\nexport interface StatementOp> extends Op {\n kind: OpKind.Statement;\n\n /**\n * The output statement.\n */\n statement: o.Statement;\n}\n\n/**\n * Create a `StatementOp`.\n */\nexport function createStatementOp>(statement: o.Statement): StatementOp {\n return {\n kind: OpKind.Statement,\n statement,\n ...NEW_OP,\n };\n}\n\n/**\n * Operation which declares and initializes a `SemanticVariable`, that is valid either in create or\n * update IR.\n */\nexport interface VariableOp> extends Op {\n kind: OpKind.Variable;\n\n /**\n * `XrefId` which identifies this specific variable, and is used to reference this variable from\n * other parts of the IR.\n */\n xref: XrefId;\n\n /**\n * The `SemanticVariable` which describes the meaning behind this variable.\n */\n variable: SemanticVariable;\n\n /**\n * Expression representing the value of the variable.\n */\n initializer: o.Expression;\n\n flags: VariableFlags;\n}\n\n/**\n * Create a `VariableOp`.\n */\nexport function createVariableOp>(\n xref: XrefId,\n variable: SemanticVariable,\n initializer: o.Expression,\n flags: VariableFlags,\n): VariableOp {\n return {\n kind: OpKind.Variable,\n xref,\n variable,\n initializer,\n flags,\n ...NEW_OP,\n };\n}\n\n/**\n * Static structure shared by all operations.\n *\n * Used as a convenience via the spread operator (`...NEW_OP`) when creating new operations, and\n * ensures the fields are always in the same order.\n */\nexport const NEW_OP: Pick, 'debugListId' | 'prev' | 'next'> = {\n debugListId: null,\n prev: null,\n next: null,\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '../../../../../core';\nimport * as i18n from '../../../../../i18n/i18n_ast';\nimport * as o from '../../../../../output/output_ast';\nimport {ParseSourceSpan} from '../../../../../parse_util';\nimport {\n BindingKind,\n I18nExpressionFor,\n I18nParamResolutionTime,\n OpKind,\n TemplateKind,\n} from '../enums';\nimport type {ConditionalCaseExpr} from '../expression';\nimport {SlotHandle} from '../handle';\nimport {Op, XrefId} from '../operations';\nimport {\n ConsumesVarsTrait,\n DependsOnSlotContextOpTrait,\n TRAIT_CONSUMES_VARS,\n TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n} from '../traits';\nimport type {HostPropertyOp} from './host';\nimport {ListEndOp, NEW_OP, StatementOp, VariableOp} from './shared';\n\n/**\n * An operation usable on the update side of the IR.\n */\nexport type UpdateOp =\n | ListEndOp\n | StatementOp\n | PropertyOp\n | TwoWayPropertyOp\n | AttributeOp\n | StylePropOp\n | ClassPropOp\n | StyleMapOp\n | ClassMapOp\n | InterpolateTextOp\n | AdvanceOp\n | VariableOp\n | BindingOp\n | HostPropertyOp\n | ConditionalOp\n | I18nExpressionOp\n | I18nApplyOp\n | RepeaterOp\n | DeferWhenOp\n | StoreLetOp;\n\n/**\n * A logical operation to perform string interpolation on a text node.\n *\n * Interpolation inputs are stored as static `string`s and dynamic `o.Expression`s, in separate\n * arrays. Thus, the interpolation `A{{b}}C{{d}}E` is stored as 3 static strings `['A', 'C', 'E']`\n * and 2 dynamic expressions `[b, d]`.\n */\nexport interface InterpolateTextOp extends Op, ConsumesVarsTrait {\n kind: OpKind.InterpolateText;\n\n /**\n * Reference to the text node to which the interpolation is bound.\n */\n target: XrefId;\n\n /**\n * The interpolated value.\n */\n interpolation: Interpolation;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create an `InterpolationTextOp`.\n */\nexport function createInterpolateTextOp(\n xref: XrefId,\n interpolation: Interpolation,\n sourceSpan: ParseSourceSpan,\n): InterpolateTextOp {\n return {\n kind: OpKind.InterpolateText,\n target: xref,\n interpolation,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\nexport class Interpolation {\n constructor(\n readonly strings: string[],\n readonly expressions: o.Expression[],\n readonly i18nPlaceholders: string[],\n ) {\n if (i18nPlaceholders.length !== 0 && i18nPlaceholders.length !== expressions.length) {\n throw new Error(\n `Expected ${expressions.length} placeholders to match interpolation expression count, but got ${i18nPlaceholders.length}`,\n );\n }\n }\n}\n\n/**\n * An intermediate binding op, that has not yet been processed into an individual property,\n * attribute, style, etc.\n */\nexport interface BindingOp extends Op {\n kind: OpKind.Binding;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * The kind of binding represented by this op.\n */\n bindingKind: BindingKind;\n\n /**\n * The name of this binding.\n */\n name: string;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression | Interpolation;\n\n /**\n * The unit of the bound value.\n */\n unit: string | null;\n\n /**\n * The security context of the binding.\n */\n securityContext: SecurityContext | SecurityContext[];\n\n /**\n * Whether the binding is a TextAttribute (e.g. `some-attr=\"some-value\"`).\n *\n * This needs to be tracked for compatibility with `TemplateDefinitionBuilder` which treats\n * `style` and `class` TextAttributes differently from `[attr.style]` and `[attr.class]`.\n */\n isTextAttribute: boolean;\n\n isStructuralTemplateAttribute: boolean;\n\n /**\n * Whether this binding is on a structural template.\n */\n templateKind: TemplateKind | null;\n\n i18nContext: XrefId | null;\n i18nMessage: i18n.Message | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `BindingOp`, not yet transformed into a particular type of binding.\n */\nexport function createBindingOp(\n target: XrefId,\n kind: BindingKind,\n name: string,\n expression: o.Expression | Interpolation,\n unit: string | null,\n securityContext: SecurityContext | SecurityContext[],\n isTextAttribute: boolean,\n isStructuralTemplateAttribute: boolean,\n templateKind: TemplateKind | null,\n i18nMessage: i18n.Message | null,\n sourceSpan: ParseSourceSpan,\n): BindingOp {\n return {\n kind: OpKind.Binding,\n bindingKind: kind,\n target,\n name,\n expression,\n unit,\n securityContext,\n isTextAttribute,\n isStructuralTemplateAttribute,\n templateKind,\n i18nContext: null,\n i18nMessage,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing binding to a property in the update IR.\n */\nexport interface PropertyOp extends Op, ConsumesVarsTrait, DependsOnSlotContextOpTrait {\n kind: OpKind.Property;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * Name of the bound property.\n */\n name: string;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression | Interpolation;\n\n /**\n * Whether this property is an animation trigger.\n */\n isAnimationTrigger: boolean;\n\n /**\n * The security context of the binding.\n */\n securityContext: SecurityContext | SecurityContext[];\n\n /**\n * The sanitizer for this property.\n */\n sanitizer: o.Expression | null;\n\n isStructuralTemplateAttribute: boolean;\n\n /**\n * The kind of template targeted by the binding, or null if this binding does not target a\n * template.\n */\n templateKind: TemplateKind | null;\n\n i18nContext: XrefId | null;\n i18nMessage: i18n.Message | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `PropertyOp`.\n */\nexport function createPropertyOp(\n target: XrefId,\n name: string,\n expression: o.Expression | Interpolation,\n isAnimationTrigger: boolean,\n securityContext: SecurityContext | SecurityContext[],\n isStructuralTemplateAttribute: boolean,\n templateKind: TemplateKind | null,\n i18nContext: XrefId | null,\n i18nMessage: i18n.Message | null,\n sourceSpan: ParseSourceSpan,\n): PropertyOp {\n return {\n kind: OpKind.Property,\n target,\n name,\n expression,\n isAnimationTrigger,\n securityContext,\n sanitizer: null,\n isStructuralTemplateAttribute,\n templateKind,\n i18nContext,\n i18nMessage,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing the property binding side of a two-way binding in the update IR.\n */\nexport interface TwoWayPropertyOp\n extends Op,\n ConsumesVarsTrait,\n DependsOnSlotContextOpTrait {\n kind: OpKind.TwoWayProperty;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * Name of the property.\n */\n name: string;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression;\n\n /**\n * The security context of the binding.\n */\n securityContext: SecurityContext | SecurityContext[];\n\n /**\n * The sanitizer for this property.\n */\n sanitizer: o.Expression | null;\n\n isStructuralTemplateAttribute: boolean;\n\n /**\n * The kind of template targeted by the binding, or null if this binding does not target a\n * template.\n */\n templateKind: TemplateKind | null;\n\n i18nContext: XrefId | null;\n i18nMessage: i18n.Message | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `TwoWayPropertyOp`.\n */\nexport function createTwoWayPropertyOp(\n target: XrefId,\n name: string,\n expression: o.Expression,\n securityContext: SecurityContext | SecurityContext[],\n isStructuralTemplateAttribute: boolean,\n templateKind: TemplateKind | null,\n i18nContext: XrefId | null,\n i18nMessage: i18n.Message | null,\n sourceSpan: ParseSourceSpan,\n): TwoWayPropertyOp {\n return {\n kind: OpKind.TwoWayProperty,\n target,\n name,\n expression,\n securityContext,\n sanitizer: null,\n isStructuralTemplateAttribute,\n templateKind,\n i18nContext,\n i18nMessage,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing binding to a style property in the update IR.\n */\nexport interface StylePropOp extends Op, ConsumesVarsTrait, DependsOnSlotContextOpTrait {\n kind: OpKind.StyleProp;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * Name of the bound property.\n */\n name: string;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression | Interpolation;\n\n /**\n * The unit of the bound value.\n */\n unit: string | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/** Create a `StylePropOp`. */\nexport function createStylePropOp(\n xref: XrefId,\n name: string,\n expression: o.Expression | Interpolation,\n unit: string | null,\n sourceSpan: ParseSourceSpan,\n): StylePropOp {\n return {\n kind: OpKind.StyleProp,\n target: xref,\n name,\n expression,\n unit,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing binding to a class property in the update IR.\n */\nexport interface ClassPropOp extends Op, ConsumesVarsTrait, DependsOnSlotContextOpTrait {\n kind: OpKind.ClassProp;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * Name of the bound property.\n */\n name: string;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `ClassPropOp`.\n */\nexport function createClassPropOp(\n xref: XrefId,\n name: string,\n expression: o.Expression,\n sourceSpan: ParseSourceSpan,\n): ClassPropOp {\n return {\n kind: OpKind.ClassProp,\n target: xref,\n name,\n expression,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing binding to a style map in the update IR.\n */\nexport interface StyleMapOp extends Op, ConsumesVarsTrait, DependsOnSlotContextOpTrait {\n kind: OpKind.StyleMap;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression | Interpolation;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/** Create a `StyleMapOp`. */\nexport function createStyleMapOp(\n xref: XrefId,\n expression: o.Expression | Interpolation,\n sourceSpan: ParseSourceSpan,\n): StyleMapOp {\n return {\n kind: OpKind.StyleMap,\n target: xref,\n expression,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing binding to a style map in the update IR.\n */\nexport interface ClassMapOp extends Op, ConsumesVarsTrait, DependsOnSlotContextOpTrait {\n kind: OpKind.ClassMap;\n\n /**\n * Reference to the element on which the property is bound.\n */\n target: XrefId;\n\n /**\n * Expression which is bound to the property.\n */\n expression: o.Expression | Interpolation;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `ClassMapOp`.\n */\nexport function createClassMapOp(\n xref: XrefId,\n expression: o.Expression | Interpolation,\n sourceSpan: ParseSourceSpan,\n): ClassMapOp {\n return {\n kind: OpKind.ClassMap,\n target: xref,\n expression,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * A logical operation representing setting an attribute on an element in the update IR.\n */\nexport interface AttributeOp extends Op {\n kind: OpKind.Attribute;\n\n /**\n * The `XrefId` of the template-like element the attribute will belong to.\n */\n target: XrefId;\n\n /**\n * The namespace of the attribute (or null if none).\n */\n namespace: string | null;\n\n /**\n * The name of the attribute.\n */\n name: string;\n\n /**\n * The value of the attribute.\n */\n expression: o.Expression | Interpolation;\n\n /**\n * The security context of the binding.\n */\n securityContext: SecurityContext | SecurityContext[];\n\n /**\n * The sanitizer for this attribute.\n */\n sanitizer: o.Expression | null;\n\n /**\n * Whether the binding is a TextAttribute (e.g. `some-attr=\"some-value\"`).\n *\n * This needs to be tracked for compatibility with `TemplateDefinitionBuilder` which treats\n * `style` and `class` TextAttributes differently from `[attr.style]` and `[attr.class]`.\n */\n isTextAttribute: boolean;\n\n isStructuralTemplateAttribute: boolean;\n\n /**\n * The kind of template targeted by the binding, or null if this binding does not target a\n * template.\n */\n templateKind: TemplateKind | null;\n\n /**\n * The i18n context, if this is an i18n attribute.\n */\n i18nContext: XrefId | null;\n\n i18nMessage: i18n.Message | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create an `AttributeOp`.\n */\nexport function createAttributeOp(\n target: XrefId,\n namespace: string | null,\n name: string,\n expression: o.Expression | Interpolation,\n securityContext: SecurityContext | SecurityContext[],\n isTextAttribute: boolean,\n isStructuralTemplateAttribute: boolean,\n templateKind: TemplateKind | null,\n i18nMessage: i18n.Message | null,\n sourceSpan: ParseSourceSpan,\n): AttributeOp {\n return {\n kind: OpKind.Attribute,\n target,\n namespace,\n name,\n expression,\n securityContext,\n sanitizer: null,\n isTextAttribute,\n isStructuralTemplateAttribute,\n templateKind,\n i18nContext: null,\n i18nMessage,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation to advance the runtime's internal slot pointer in the update IR.\n */\nexport interface AdvanceOp extends Op {\n kind: OpKind.Advance;\n\n /**\n * Delta by which to advance the pointer.\n */\n delta: number;\n\n // Source span of the binding that caused the advance\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create an `AdvanceOp`.\n */\nexport function createAdvanceOp(delta: number, sourceSpan: ParseSourceSpan): AdvanceOp {\n return {\n kind: OpKind.Advance,\n delta,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation representing a conditional expression in the update IR.\n */\nexport interface ConditionalOp\n extends Op,\n DependsOnSlotContextOpTrait,\n ConsumesVarsTrait {\n kind: OpKind.Conditional;\n\n /**\n * The insertion point, which is the first template in the creation block belonging to this\n * condition.\n */\n target: XrefId;\n\n /**\n * The main test expression (for a switch), or `null` (for an if, which has no test\n * expression).\n */\n test: o.Expression | null;\n\n /**\n * Each possible embedded view that could be displayed has a condition (or is default). This\n * structure maps each view xref to its corresponding condition.\n */\n conditions: Array;\n\n /**\n * After processing, this will be a single collapsed Joost-expression that evaluates the\n * conditions, and yields the slot number of the template which should be displayed.\n */\n processed: o.Expression | null;\n\n /**\n * Control flow conditionals can accept a context value (this is a result of specifying an\n * alias). This expression will be passed to the conditional instruction's context parameter.\n */\n contextValue: o.Expression | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a conditional op, which will display an embedded view according to a condtion.\n */\nexport function createConditionalOp(\n target: XrefId,\n test: o.Expression | null,\n conditions: Array,\n sourceSpan: ParseSourceSpan,\n): ConditionalOp {\n return {\n kind: OpKind.Conditional,\n target,\n test,\n conditions,\n processed: null,\n sourceSpan,\n contextValue: null,\n ...NEW_OP,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n };\n}\n\nexport interface RepeaterOp extends Op, DependsOnSlotContextOpTrait {\n kind: OpKind.Repeater;\n\n /**\n * The RepeaterCreate op associated with this repeater.\n */\n target: XrefId;\n\n targetSlot: SlotHandle;\n\n /**\n * The collection provided to the for loop as its expression.\n */\n collection: o.Expression;\n\n sourceSpan: ParseSourceSpan;\n}\n\nexport function createRepeaterOp(\n repeaterCreate: XrefId,\n targetSlot: SlotHandle,\n collection: o.Expression,\n sourceSpan: ParseSourceSpan,\n): RepeaterOp {\n return {\n kind: OpKind.Repeater,\n target: repeaterCreate,\n targetSlot,\n collection,\n sourceSpan,\n ...NEW_OP,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n };\n}\n\nexport interface DeferWhenOp extends Op, DependsOnSlotContextOpTrait, ConsumesVarsTrait {\n kind: OpKind.DeferWhen;\n\n /**\n * The `defer` create op associated with this when condition.\n */\n target: XrefId;\n\n /**\n * A user-provided expression that triggers the defer op.\n */\n expr: o.Expression;\n\n /**\n * Whether to emit the prefetch version of the instruction.\n */\n prefetch: boolean;\n\n sourceSpan: ParseSourceSpan;\n}\n\nexport function createDeferWhenOp(\n target: XrefId,\n expr: o.Expression,\n prefetch: boolean,\n sourceSpan: ParseSourceSpan,\n): DeferWhenOp {\n return {\n kind: OpKind.DeferWhen,\n target,\n expr,\n prefetch,\n sourceSpan,\n ...NEW_OP,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n };\n}\n\n/**\n * An op that represents an expression in an i18n message.\n *\n * TODO: This can represent expressions used in both i18n attributes and normal i18n content. We\n * may want to split these into two different op types, deriving from the same base class.\n */\nexport interface I18nExpressionOp\n extends Op,\n ConsumesVarsTrait,\n DependsOnSlotContextOpTrait {\n kind: OpKind.I18nExpression;\n\n /**\n * The i18n context that this expression belongs to.\n */\n context: XrefId;\n\n /**\n * The Xref of the op that we need to `advance` to.\n *\n * In an i18n block, this is initially the i18n start op, but will eventually correspond to\n * the final slot consumer in the owning i18n block.\n * TODO: We should make text i18nExpressions target the i18nEnd instruction, instead the last\n * slot consumer in the i18n block. This makes them resilient to that last consumer being\n * deleted. (Or new slot consumers being added!)\n *\n * In an i18n attribute, this is the xref of the corresponding elementStart/element.\n */\n target: XrefId;\n\n /**\n * In an i18n block, this should be the i18n start op.\n *\n * In an i18n attribute, this will be the xref of the attribute configuration instruction.\n */\n i18nOwner: XrefId;\n\n /**\n * A handle for the slot that this expression modifies.\n * - In an i18n block, this is the handle of the block.\n * - In an i18n attribute, this is the handle of the corresponding i18nAttributes instruction.\n */\n handle: SlotHandle;\n\n /**\n * The expression value.\n */\n expression: o.Expression;\n\n icuPlaceholder: XrefId | null;\n\n /**\n * The i18n placeholder associated with this expression. This can be null if the expression is\n * part of an ICU placeholder. In this case it gets combined with the string literal value and\n * other expressions in the ICU placeholder and assigned to the translated message under the ICU\n * placeholder name.\n */\n i18nPlaceholder: string | null;\n\n /**\n * The time that this expression is resolved.\n */\n resolutionTime: I18nParamResolutionTime;\n\n /**\n * Whether this i18n expression applies to a template or to a binding.\n */\n usage: I18nExpressionFor;\n\n /**\n * If this is an I18nExpressionContext.Binding, this expression is associated with a named\n * attribute. That name is stored here.\n */\n name: string;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create an i18n expression op.\n */\nexport function createI18nExpressionOp(\n context: XrefId,\n target: XrefId,\n i18nOwner: XrefId,\n handle: SlotHandle,\n expression: o.Expression,\n icuPlaceholder: XrefId | null,\n i18nPlaceholder: string | null,\n resolutionTime: I18nParamResolutionTime,\n usage: I18nExpressionFor,\n name: string,\n sourceSpan: ParseSourceSpan,\n): I18nExpressionOp {\n return {\n kind: OpKind.I18nExpression,\n context,\n target,\n i18nOwner,\n handle,\n expression,\n icuPlaceholder,\n i18nPlaceholder,\n resolutionTime,\n usage,\n name,\n sourceSpan,\n ...NEW_OP,\n ...TRAIT_CONSUMES_VARS,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n };\n}\n\n/**\n * An op that represents applying a set of i18n expressions.\n */\nexport interface I18nApplyOp extends Op {\n kind: OpKind.I18nApply;\n\n /**\n * In an i18n block, this should be the i18n start op.\n *\n * In an i18n attribute, this will be the xref of the attribute configuration instruction.\n */\n owner: XrefId;\n\n /**\n * A handle for the slot that i18n apply instruction should apply to. In an i18n block, this\n * is the slot of the i18n block this expression belongs to. In an i18n attribute, this is the\n * slot of the corresponding i18nAttributes instruction.\n */\n handle: SlotHandle;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Creates an op to apply i18n expression ops.\n */\nexport function createI18nApplyOp(\n owner: XrefId,\n handle: SlotHandle,\n sourceSpan: ParseSourceSpan,\n): I18nApplyOp {\n return {\n kind: OpKind.I18nApply,\n owner,\n handle,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * Op to store the current value of a `@let` declaration.\n */\nexport interface StoreLetOp extends Op, ConsumesVarsTrait {\n kind: OpKind.StoreLet;\n sourceSpan: ParseSourceSpan;\n\n /** Name that the user set when declaring the `@let`. */\n declaredName: string;\n\n /** XrefId of the slot in which the call may write its value. */\n target: XrefId;\n\n /** Value of the `@let` declaration. */\n value: o.Expression;\n}\n\n/**\n * Creates a `StoreLetOp`.\n */\nexport function createStoreLetOp(\n target: XrefId,\n declaredName: string,\n value: o.Expression,\n sourceSpan: ParseSourceSpan,\n): StoreLetOp {\n return {\n kind: OpKind.StoreLet,\n target,\n declaredName,\n value,\n sourceSpan,\n ...TRAIT_DEPENDS_ON_SLOT_CONTEXT,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport type {ParseSourceSpan} from '../../../../parse_util';\n\nimport * as t from '../../../../render3/r3_ast';\nimport {ExpressionKind, OpKind} from './enums';\nimport {SlotHandle} from './handle';\nimport type {XrefId} from './operations';\nimport type {CreateOp} from './ops/create';\nimport {Interpolation, type UpdateOp} from './ops/update';\nimport {\n ConsumesVarsTrait,\n DependsOnSlotContext,\n DependsOnSlotContextOpTrait,\n UsesVarOffset,\n UsesVarOffsetTrait,\n} from './traits';\n\n/**\n * An `o.Expression` subtype representing a logical expression in the intermediate representation.\n */\nexport type Expression =\n | LexicalReadExpr\n | ReferenceExpr\n | ContextExpr\n | NextContextExpr\n | GetCurrentViewExpr\n | RestoreViewExpr\n | ResetViewExpr\n | ReadVariableExpr\n | PureFunctionExpr\n | PureFunctionParameterExpr\n | PipeBindingExpr\n | PipeBindingVariadicExpr\n | SafePropertyReadExpr\n | SafeKeyedReadExpr\n | SafeInvokeFunctionExpr\n | EmptyExpr\n | AssignTemporaryExpr\n | ReadTemporaryExpr\n | SlotLiteralExpr\n | ConditionalCaseExpr\n | ConstCollectedExpr\n | TwoWayBindingSetExpr\n | ContextLetReferenceExpr\n | StoreLetExpr;\n\n/**\n * Transformer type which converts expressions into general `o.Expression`s (which may be an\n * identity transformation).\n */\nexport type ExpressionTransform = (expr: o.Expression, flags: VisitorContextFlag) => o.Expression;\n\n/**\n * Check whether a given `o.Expression` is a logical IR expression type.\n */\nexport function isIrExpression(expr: o.Expression): expr is Expression {\n return expr instanceof ExpressionBase;\n}\n\n/**\n * Base type used for all logical IR expressions.\n */\nexport abstract class ExpressionBase extends o.Expression {\n abstract readonly kind: ExpressionKind;\n\n constructor(sourceSpan: ParseSourceSpan | null = null) {\n super(null, sourceSpan);\n }\n\n /**\n * Run the transformer against any nested expressions which may be present in this IR expression\n * subtype.\n */\n abstract transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void;\n}\n\n/**\n * Logical expression representing a lexical read of a variable name.\n */\nexport class LexicalReadExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.LexicalRead;\n\n constructor(readonly name: string) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): void {}\n\n override isEquivalent(other: LexicalReadExpr): boolean {\n // We assume that the lexical reads are in the same context, which must be true for parent\n // expressions to be equivalent.\n // TODO: is this generally safe?\n return this.name === other.name;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): LexicalReadExpr {\n return new LexicalReadExpr(this.name);\n }\n}\n\n/**\n * Runtime operation to retrieve the value of a local reference.\n */\nexport class ReferenceExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.Reference;\n\n constructor(\n readonly target: XrefId,\n readonly targetSlot: SlotHandle,\n readonly offset: number,\n ) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof ReferenceExpr && e.target === this.target;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): ReferenceExpr {\n return new ReferenceExpr(this.target, this.targetSlot, this.offset);\n }\n}\n\nexport class StoreLetExpr\n extends ExpressionBase\n implements ConsumesVarsTrait, DependsOnSlotContextOpTrait\n{\n override readonly kind = ExpressionKind.StoreLet;\n readonly [ConsumesVarsTrait] = true;\n readonly [DependsOnSlotContext] = true;\n\n constructor(\n readonly target: XrefId,\n public value: o.Expression,\n override sourceSpan: ParseSourceSpan,\n ) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return (\n e instanceof StoreLetExpr && e.target === this.target && e.value.isEquivalent(this.value)\n );\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.value = transformExpressionsInExpression(this.value, transform, flags);\n }\n\n override clone(): StoreLetExpr {\n return new StoreLetExpr(this.target, this.value, this.sourceSpan);\n }\n}\n\nexport class ContextLetReferenceExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.ContextLetReference;\n\n constructor(\n readonly target: XrefId,\n readonly targetSlot: SlotHandle,\n ) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof ContextLetReferenceExpr && e.target === this.target;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): ContextLetReferenceExpr {\n return new ContextLetReferenceExpr(this.target, this.targetSlot);\n }\n}\n\n/**\n * A reference to the current view context (usually the `ctx` variable in a template function).\n */\nexport class ContextExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.Context;\n\n constructor(readonly view: XrefId) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof ContextExpr && e.view === this.view;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): ContextExpr {\n return new ContextExpr(this.view);\n }\n}\n\n/**\n * A reference to the current view context inside a track function.\n */\nexport class TrackContextExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.TrackContext;\n\n constructor(readonly view: XrefId) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof TrackContextExpr && e.view === this.view;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): TrackContextExpr {\n return new TrackContextExpr(this.view);\n }\n}\n\n/**\n * Runtime operation to navigate to the next view context in the view hierarchy.\n */\nexport class NextContextExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.NextContext;\n\n steps = 1;\n\n constructor() {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof NextContextExpr && e.steps === this.steps;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): NextContextExpr {\n const expr = new NextContextExpr();\n expr.steps = this.steps;\n return expr;\n }\n}\n\n/**\n * Runtime operation to snapshot the current view context.\n *\n * The result of this operation can be stored in a variable and later used with the `RestoreView`\n * operation.\n */\nexport class GetCurrentViewExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.GetCurrentView;\n\n constructor() {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof GetCurrentViewExpr;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): GetCurrentViewExpr {\n return new GetCurrentViewExpr();\n }\n}\n\n/**\n * Runtime operation to restore a snapshotted view.\n */\nexport class RestoreViewExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.RestoreView;\n\n constructor(public view: XrefId | o.Expression) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): void {\n if (typeof this.view !== 'number') {\n this.view.visitExpression(visitor, context);\n }\n }\n\n override isEquivalent(e: o.Expression): boolean {\n if (!(e instanceof RestoreViewExpr) || typeof e.view !== typeof this.view) {\n return false;\n }\n\n if (typeof this.view === 'number') {\n return this.view === e.view;\n } else {\n return this.view.isEquivalent(e.view as o.Expression);\n }\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n if (typeof this.view !== 'number') {\n this.view = transformExpressionsInExpression(this.view, transform, flags);\n }\n }\n\n override clone(): RestoreViewExpr {\n return new RestoreViewExpr(this.view instanceof o.Expression ? this.view.clone() : this.view);\n }\n}\n\n/**\n * Runtime operation to reset the current view context after `RestoreView`.\n */\nexport class ResetViewExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.ResetView;\n\n constructor(public expr: o.Expression) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n this.expr.visitExpression(visitor, context);\n }\n\n override isEquivalent(e: o.Expression): boolean {\n return e instanceof ResetViewExpr && this.expr.isEquivalent(e.expr);\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.expr = transformExpressionsInExpression(this.expr, transform, flags);\n }\n\n override clone(): ResetViewExpr {\n return new ResetViewExpr(this.expr.clone());\n }\n}\n\nexport class TwoWayBindingSetExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.TwoWayBindingSet;\n\n constructor(\n public target: o.Expression,\n public value: o.Expression,\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): void {\n this.target.visitExpression(visitor, context);\n this.value.visitExpression(visitor, context);\n }\n\n override isEquivalent(other: TwoWayBindingSetExpr): boolean {\n return this.target.isEquivalent(other.target) && this.value.isEquivalent(other.value);\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(transform: ExpressionTransform, flags: VisitorContextFlag) {\n this.target = transformExpressionsInExpression(this.target, transform, flags);\n this.value = transformExpressionsInExpression(this.value, transform, flags);\n }\n\n override clone(): TwoWayBindingSetExpr {\n return new TwoWayBindingSetExpr(this.target, this.value);\n }\n}\n\n/**\n * Read of a variable declared as an `ir.VariableOp` and referenced through its `ir.XrefId`.\n */\nexport class ReadVariableExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.ReadVariable;\n name: string | null = null;\n constructor(readonly xref: XrefId) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(other: o.Expression): boolean {\n return other instanceof ReadVariableExpr && other.xref === this.xref;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): ReadVariableExpr {\n const expr = new ReadVariableExpr(this.xref);\n expr.name = this.name;\n return expr;\n }\n}\n\nexport class PureFunctionExpr\n extends ExpressionBase\n implements ConsumesVarsTrait, UsesVarOffsetTrait\n{\n override readonly kind = ExpressionKind.PureFunctionExpr;\n readonly [ConsumesVarsTrait] = true;\n readonly [UsesVarOffset] = true;\n\n varOffset: number | null = null;\n\n /**\n * The expression which should be memoized as a pure computation.\n *\n * This expression contains internal `PureFunctionParameterExpr`s, which are placeholders for the\n * positional argument expressions in `args.\n */\n body: o.Expression | null;\n\n /**\n * Positional arguments to the pure function which will memoize the `body` expression, which act\n * as memoization keys.\n */\n args: o.Expression[];\n\n /**\n * Once extracted to the `ConstantPool`, a reference to the function which defines the computation\n * of `body`.\n */\n fn: o.Expression | null = null;\n\n constructor(expression: o.Expression | null, args: o.Expression[]) {\n super();\n this.body = expression;\n this.args = args;\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any) {\n this.body?.visitExpression(visitor, context);\n for (const arg of this.args) {\n arg.visitExpression(visitor, context);\n }\n }\n\n override isEquivalent(other: o.Expression): boolean {\n if (!(other instanceof PureFunctionExpr) || other.args.length !== this.args.length) {\n return false;\n }\n\n return (\n other.body !== null &&\n this.body !== null &&\n other.body.isEquivalent(this.body) &&\n other.args.every((arg, idx) => arg.isEquivalent(this.args[idx]))\n );\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n if (this.body !== null) {\n // TODO: figure out if this is the right flag to pass here.\n this.body = transformExpressionsInExpression(\n this.body,\n transform,\n flags | VisitorContextFlag.InChildOperation,\n );\n } else if (this.fn !== null) {\n this.fn = transformExpressionsInExpression(this.fn, transform, flags);\n }\n\n for (let i = 0; i < this.args.length; i++) {\n this.args[i] = transformExpressionsInExpression(this.args[i], transform, flags);\n }\n }\n\n override clone(): PureFunctionExpr {\n const expr = new PureFunctionExpr(\n this.body?.clone() ?? null,\n this.args.map((arg) => arg.clone()),\n );\n expr.fn = this.fn?.clone() ?? null;\n expr.varOffset = this.varOffset;\n return expr;\n }\n}\n\nexport class PureFunctionParameterExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.PureFunctionParameterExpr;\n\n constructor(public index: number) {\n super();\n }\n\n override visitExpression(): void {}\n\n override isEquivalent(other: o.Expression): boolean {\n return other instanceof PureFunctionParameterExpr && other.index === this.index;\n }\n\n override isConstant(): boolean {\n return true;\n }\n\n override transformInternalExpressions(): void {}\n\n override clone(): PureFunctionParameterExpr {\n return new PureFunctionParameterExpr(this.index);\n }\n}\n\nexport class PipeBindingExpr\n extends ExpressionBase\n implements ConsumesVarsTrait, UsesVarOffsetTrait\n{\n override readonly kind = ExpressionKind.PipeBinding;\n readonly [ConsumesVarsTrait] = true;\n readonly [UsesVarOffset] = true;\n\n varOffset: number | null = null;\n\n constructor(\n readonly target: XrefId,\n readonly targetSlot: SlotHandle,\n readonly name: string,\n readonly args: o.Expression[],\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): void {\n for (const arg of this.args) {\n arg.visitExpression(visitor, context);\n }\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n for (let idx = 0; idx < this.args.length; idx++) {\n this.args[idx] = transformExpressionsInExpression(this.args[idx], transform, flags);\n }\n }\n\n override clone() {\n const r = new PipeBindingExpr(\n this.target,\n this.targetSlot,\n this.name,\n this.args.map((a) => a.clone()),\n );\n r.varOffset = this.varOffset;\n return r;\n }\n}\n\nexport class PipeBindingVariadicExpr\n extends ExpressionBase\n implements ConsumesVarsTrait, UsesVarOffsetTrait\n{\n override readonly kind = ExpressionKind.PipeBindingVariadic;\n readonly [ConsumesVarsTrait] = true;\n readonly [UsesVarOffset] = true;\n\n varOffset: number | null = null;\n\n constructor(\n readonly target: XrefId,\n readonly targetSlot: SlotHandle,\n readonly name: string,\n public args: o.Expression,\n public numArgs: number,\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): void {\n this.args.visitExpression(visitor, context);\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.args = transformExpressionsInExpression(this.args, transform, flags);\n }\n\n override clone(): PipeBindingVariadicExpr {\n const r = new PipeBindingVariadicExpr(\n this.target,\n this.targetSlot,\n this.name,\n this.args.clone(),\n this.numArgs,\n );\n r.varOffset = this.varOffset;\n return r;\n }\n}\n\nexport class SafePropertyReadExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.SafePropertyRead;\n\n constructor(\n public receiver: o.Expression,\n public name: string,\n ) {\n super();\n }\n\n // An alias for name, which allows other logic to handle property reads and keyed reads together.\n get index() {\n return this.name;\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n this.receiver.visitExpression(visitor, context);\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.receiver = transformExpressionsInExpression(this.receiver, transform, flags);\n }\n\n override clone(): SafePropertyReadExpr {\n return new SafePropertyReadExpr(this.receiver.clone(), this.name);\n }\n}\n\nexport class SafeKeyedReadExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.SafeKeyedRead;\n\n constructor(\n public receiver: o.Expression,\n public index: o.Expression,\n sourceSpan: ParseSourceSpan | null,\n ) {\n super(sourceSpan);\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n this.receiver.visitExpression(visitor, context);\n this.index.visitExpression(visitor, context);\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.receiver = transformExpressionsInExpression(this.receiver, transform, flags);\n this.index = transformExpressionsInExpression(this.index, transform, flags);\n }\n\n override clone(): SafeKeyedReadExpr {\n return new SafeKeyedReadExpr(this.receiver.clone(), this.index.clone(), this.sourceSpan);\n }\n}\n\nexport class SafeInvokeFunctionExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.SafeInvokeFunction;\n\n constructor(\n public receiver: o.Expression,\n public args: o.Expression[],\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n this.receiver.visitExpression(visitor, context);\n for (const a of this.args) {\n a.visitExpression(visitor, context);\n }\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.receiver = transformExpressionsInExpression(this.receiver, transform, flags);\n for (let i = 0; i < this.args.length; i++) {\n this.args[i] = transformExpressionsInExpression(this.args[i], transform, flags);\n }\n }\n\n override clone(): SafeInvokeFunctionExpr {\n return new SafeInvokeFunctionExpr(\n this.receiver.clone(),\n this.args.map((a) => a.clone()),\n );\n }\n}\n\nexport class SafeTernaryExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.SafeTernaryExpr;\n\n constructor(\n public guard: o.Expression,\n public expr: o.Expression,\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n this.guard.visitExpression(visitor, context);\n this.expr.visitExpression(visitor, context);\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.guard = transformExpressionsInExpression(this.guard, transform, flags);\n this.expr = transformExpressionsInExpression(this.expr, transform, flags);\n }\n\n override clone(): SafeTernaryExpr {\n return new SafeTernaryExpr(this.guard.clone(), this.expr.clone());\n }\n}\n\nexport class EmptyExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.EmptyExpr;\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {}\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof EmptyExpr;\n }\n\n override isConstant() {\n return true;\n }\n\n override clone(): EmptyExpr {\n return new EmptyExpr();\n }\n\n override transformInternalExpressions(): void {}\n}\n\nexport class AssignTemporaryExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.AssignTemporaryExpr;\n\n public name: string | null = null;\n\n constructor(\n public expr: o.Expression,\n public xref: XrefId,\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n this.expr.visitExpression(visitor, context);\n }\n\n override isEquivalent(): boolean {\n return false;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.expr = transformExpressionsInExpression(this.expr, transform, flags);\n }\n\n override clone(): AssignTemporaryExpr {\n const a = new AssignTemporaryExpr(this.expr.clone(), this.xref);\n a.name = this.name;\n return a;\n }\n}\n\nexport class ReadTemporaryExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.ReadTemporaryExpr;\n\n public name: string | null = null;\n\n constructor(public xref: XrefId) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {}\n\n override isEquivalent(): boolean {\n return this.xref === this.xref;\n }\n\n override isConstant(): boolean {\n return false;\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {}\n\n override clone(): ReadTemporaryExpr {\n const r = new ReadTemporaryExpr(this.xref);\n r.name = this.name;\n return r;\n }\n}\n\nexport class SlotLiteralExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.SlotLiteralExpr;\n\n constructor(readonly slot: SlotHandle) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {}\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof SlotLiteralExpr && e.slot === this.slot;\n }\n\n override isConstant() {\n return true;\n }\n\n override clone(): SlotLiteralExpr {\n return new SlotLiteralExpr(this.slot);\n }\n\n override transformInternalExpressions(): void {}\n}\n\nexport class ConditionalCaseExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.ConditionalCase;\n\n /**\n * Create an expression for one branch of a conditional.\n * @param expr The expression to be tested for this case. Might be null, as in an `else` case.\n * @param target The Xref of the view to be displayed if this condition is true.\n */\n constructor(\n public expr: o.Expression | null,\n readonly target: XrefId,\n readonly targetSlot: SlotHandle,\n readonly alias: t.Variable | null = null,\n ) {\n super();\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any): any {\n if (this.expr !== null) {\n this.expr.visitExpression(visitor, context);\n }\n }\n\n override isEquivalent(e: Expression): boolean {\n return e instanceof ConditionalCaseExpr && e.expr === this.expr;\n }\n\n override isConstant() {\n return true;\n }\n\n override clone(): ConditionalCaseExpr {\n return new ConditionalCaseExpr(this.expr, this.target, this.targetSlot);\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n if (this.expr !== null) {\n this.expr = transformExpressionsInExpression(this.expr, transform, flags);\n }\n }\n}\n\nexport class ConstCollectedExpr extends ExpressionBase {\n override readonly kind = ExpressionKind.ConstCollected;\n\n constructor(public expr: o.Expression) {\n super();\n }\n\n override transformInternalExpressions(\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n ): void {\n this.expr = transform(this.expr, flags);\n }\n\n override visitExpression(visitor: o.ExpressionVisitor, context: any) {\n this.expr.visitExpression(visitor, context);\n }\n\n override isEquivalent(e: o.Expression): boolean {\n if (!(e instanceof ConstCollectedExpr)) {\n return false;\n }\n return this.expr.isEquivalent(e.expr);\n }\n\n override isConstant(): boolean {\n return this.expr.isConstant();\n }\n\n override clone(): ConstCollectedExpr {\n return new ConstCollectedExpr(this.expr);\n }\n}\n\n/**\n * Visits all `Expression`s in the AST of `op` with the `visitor` function.\n */\nexport function visitExpressionsInOp(\n op: CreateOp | UpdateOp,\n visitor: (expr: o.Expression, flags: VisitorContextFlag) => void,\n): void {\n transformExpressionsInOp(\n op,\n (expr, flags) => {\n visitor(expr, flags);\n return expr;\n },\n VisitorContextFlag.None,\n );\n}\n\nexport enum VisitorContextFlag {\n None = 0b0000,\n InChildOperation = 0b0001,\n}\n\nfunction transformExpressionsInInterpolation(\n interpolation: Interpolation,\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n) {\n for (let i = 0; i < interpolation.expressions.length; i++) {\n interpolation.expressions[i] = transformExpressionsInExpression(\n interpolation.expressions[i],\n transform,\n flags,\n );\n }\n}\n\n/**\n * Transform all `Expression`s in the AST of `op` with the `transform` function.\n *\n * All such operations will be replaced with the result of applying `transform`, which may be an\n * identity transformation.\n */\nexport function transformExpressionsInOp(\n op: CreateOp | UpdateOp,\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n): void {\n switch (op.kind) {\n case OpKind.StyleProp:\n case OpKind.StyleMap:\n case OpKind.ClassProp:\n case OpKind.ClassMap:\n case OpKind.Binding:\n if (op.expression instanceof Interpolation) {\n transformExpressionsInInterpolation(op.expression, transform, flags);\n } else {\n op.expression = transformExpressionsInExpression(op.expression, transform, flags);\n }\n break;\n case OpKind.Property:\n case OpKind.HostProperty:\n case OpKind.Attribute:\n if (op.expression instanceof Interpolation) {\n transformExpressionsInInterpolation(op.expression, transform, flags);\n } else {\n op.expression = transformExpressionsInExpression(op.expression, transform, flags);\n }\n op.sanitizer =\n op.sanitizer && transformExpressionsInExpression(op.sanitizer, transform, flags);\n break;\n case OpKind.TwoWayProperty:\n op.expression = transformExpressionsInExpression(op.expression, transform, flags);\n op.sanitizer =\n op.sanitizer && transformExpressionsInExpression(op.sanitizer, transform, flags);\n break;\n case OpKind.I18nExpression:\n op.expression = transformExpressionsInExpression(op.expression, transform, flags);\n break;\n case OpKind.InterpolateText:\n transformExpressionsInInterpolation(op.interpolation, transform, flags);\n break;\n case OpKind.Statement:\n transformExpressionsInStatement(op.statement, transform, flags);\n break;\n case OpKind.Variable:\n op.initializer = transformExpressionsInExpression(op.initializer, transform, flags);\n break;\n case OpKind.Conditional:\n for (const condition of op.conditions) {\n if (condition.expr === null) {\n // This is a default case.\n continue;\n }\n condition.expr = transformExpressionsInExpression(condition.expr, transform, flags);\n }\n if (op.processed !== null) {\n op.processed = transformExpressionsInExpression(op.processed, transform, flags);\n }\n if (op.contextValue !== null) {\n op.contextValue = transformExpressionsInExpression(op.contextValue, transform, flags);\n }\n break;\n case OpKind.Listener:\n case OpKind.TwoWayListener:\n for (const innerOp of op.handlerOps) {\n transformExpressionsInOp(innerOp, transform, flags | VisitorContextFlag.InChildOperation);\n }\n break;\n case OpKind.ExtractedAttribute:\n op.expression =\n op.expression && transformExpressionsInExpression(op.expression, transform, flags);\n op.trustedValueFn =\n op.trustedValueFn && transformExpressionsInExpression(op.trustedValueFn, transform, flags);\n break;\n case OpKind.RepeaterCreate:\n op.track = transformExpressionsInExpression(op.track, transform, flags);\n if (op.trackByFn !== null) {\n op.trackByFn = transformExpressionsInExpression(op.trackByFn, transform, flags);\n }\n break;\n case OpKind.Repeater:\n op.collection = transformExpressionsInExpression(op.collection, transform, flags);\n break;\n case OpKind.Defer:\n if (op.loadingConfig !== null) {\n op.loadingConfig = transformExpressionsInExpression(op.loadingConfig, transform, flags);\n }\n if (op.placeholderConfig !== null) {\n op.placeholderConfig = transformExpressionsInExpression(\n op.placeholderConfig,\n transform,\n flags,\n );\n }\n if (op.resolverFn !== null) {\n op.resolverFn = transformExpressionsInExpression(op.resolverFn, transform, flags);\n }\n break;\n case OpKind.I18nMessage:\n for (const [placeholder, expr] of op.params) {\n op.params.set(placeholder, transformExpressionsInExpression(expr, transform, flags));\n }\n for (const [placeholder, expr] of op.postprocessingParams) {\n op.postprocessingParams.set(\n placeholder,\n transformExpressionsInExpression(expr, transform, flags),\n );\n }\n break;\n case OpKind.DeferWhen:\n op.expr = transformExpressionsInExpression(op.expr, transform, flags);\n break;\n case OpKind.StoreLet:\n op.value = transformExpressionsInExpression(op.value, transform, flags);\n break;\n case OpKind.Advance:\n case OpKind.Container:\n case OpKind.ContainerEnd:\n case OpKind.ContainerStart:\n case OpKind.DeferOn:\n case OpKind.DisableBindings:\n case OpKind.Element:\n case OpKind.ElementEnd:\n case OpKind.ElementStart:\n case OpKind.EnableBindings:\n case OpKind.I18n:\n case OpKind.I18nApply:\n case OpKind.I18nContext:\n case OpKind.I18nEnd:\n case OpKind.I18nStart:\n case OpKind.IcuEnd:\n case OpKind.IcuStart:\n case OpKind.Namespace:\n case OpKind.Pipe:\n case OpKind.Projection:\n case OpKind.ProjectionDef:\n case OpKind.Template:\n case OpKind.Text:\n case OpKind.I18nAttributes:\n case OpKind.IcuPlaceholder:\n case OpKind.DeclareLet:\n // These operations contain no expressions.\n break;\n default:\n throw new Error(`AssertionError: transformExpressionsInOp doesn't handle ${OpKind[op.kind]}`);\n }\n}\n\n/**\n * Transform all `Expression`s in the AST of `expr` with the `transform` function.\n *\n * All such operations will be replaced with the result of applying `transform`, which may be an\n * identity transformation.\n */\nexport function transformExpressionsInExpression(\n expr: o.Expression,\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n): o.Expression {\n if (expr instanceof ExpressionBase) {\n expr.transformInternalExpressions(transform, flags);\n } else if (expr instanceof o.BinaryOperatorExpr) {\n expr.lhs = transformExpressionsInExpression(expr.lhs, transform, flags);\n expr.rhs = transformExpressionsInExpression(expr.rhs, transform, flags);\n } else if (expr instanceof o.UnaryOperatorExpr) {\n expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);\n } else if (expr instanceof o.ReadPropExpr) {\n expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);\n } else if (expr instanceof o.ReadKeyExpr) {\n expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);\n expr.index = transformExpressionsInExpression(expr.index, transform, flags);\n } else if (expr instanceof o.WritePropExpr) {\n expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);\n expr.value = transformExpressionsInExpression(expr.value, transform, flags);\n } else if (expr instanceof o.WriteKeyExpr) {\n expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);\n expr.index = transformExpressionsInExpression(expr.index, transform, flags);\n expr.value = transformExpressionsInExpression(expr.value, transform, flags);\n } else if (expr instanceof o.InvokeFunctionExpr) {\n expr.fn = transformExpressionsInExpression(expr.fn, transform, flags);\n for (let i = 0; i < expr.args.length; i++) {\n expr.args[i] = transformExpressionsInExpression(expr.args[i], transform, flags);\n }\n } else if (expr instanceof o.LiteralArrayExpr) {\n for (let i = 0; i < expr.entries.length; i++) {\n expr.entries[i] = transformExpressionsInExpression(expr.entries[i], transform, flags);\n }\n } else if (expr instanceof o.LiteralMapExpr) {\n for (let i = 0; i < expr.entries.length; i++) {\n expr.entries[i].value = transformExpressionsInExpression(\n expr.entries[i].value,\n transform,\n flags,\n );\n }\n } else if (expr instanceof o.ConditionalExpr) {\n expr.condition = transformExpressionsInExpression(expr.condition, transform, flags);\n expr.trueCase = transformExpressionsInExpression(expr.trueCase, transform, flags);\n if (expr.falseCase !== null) {\n expr.falseCase = transformExpressionsInExpression(expr.falseCase, transform, flags);\n }\n } else if (expr instanceof o.TypeofExpr) {\n expr.expr = transformExpressionsInExpression(expr.expr, transform, flags);\n } else if (expr instanceof o.WriteVarExpr) {\n expr.value = transformExpressionsInExpression(expr.value, transform, flags);\n } else if (expr instanceof o.LocalizedString) {\n for (let i = 0; i < expr.expressions.length; i++) {\n expr.expressions[i] = transformExpressionsInExpression(expr.expressions[i], transform, flags);\n }\n } else if (expr instanceof o.NotExpr) {\n expr.condition = transformExpressionsInExpression(expr.condition, transform, flags);\n } else if (expr instanceof o.TaggedTemplateExpr) {\n expr.tag = transformExpressionsInExpression(expr.tag, transform, flags);\n expr.template.expressions = expr.template.expressions.map((e) =>\n transformExpressionsInExpression(e, transform, flags),\n );\n } else if (expr instanceof o.ArrowFunctionExpr) {\n if (Array.isArray(expr.body)) {\n for (let i = 0; i < expr.body.length; i++) {\n transformExpressionsInStatement(expr.body[i], transform, flags);\n }\n } else {\n expr.body = transformExpressionsInExpression(expr.body, transform, flags);\n }\n } else if (expr instanceof o.WrappedNodeExpr) {\n // TODO: Do we need to transform any TS nodes nested inside of this expression?\n } else if (\n expr instanceof o.ReadVarExpr ||\n expr instanceof o.ExternalExpr ||\n expr instanceof o.LiteralExpr\n ) {\n // No action for these types.\n } else {\n throw new Error(`Unhandled expression kind: ${expr.constructor.name}`);\n }\n return transform(expr, flags);\n}\n\n/**\n * Transform all `Expression`s in the AST of `stmt` with the `transform` function.\n *\n * All such operations will be replaced with the result of applying `transform`, which may be an\n * identity transformation.\n */\nexport function transformExpressionsInStatement(\n stmt: o.Statement,\n transform: ExpressionTransform,\n flags: VisitorContextFlag,\n): void {\n if (stmt instanceof o.ExpressionStatement) {\n stmt.expr = transformExpressionsInExpression(stmt.expr, transform, flags);\n } else if (stmt instanceof o.ReturnStatement) {\n stmt.value = transformExpressionsInExpression(stmt.value, transform, flags);\n } else if (stmt instanceof o.DeclareVarStmt) {\n if (stmt.value !== undefined) {\n stmt.value = transformExpressionsInExpression(stmt.value, transform, flags);\n }\n } else if (stmt instanceof o.IfStmt) {\n stmt.condition = transformExpressionsInExpression(stmt.condition, transform, flags);\n for (const caseStatement of stmt.trueCase) {\n transformExpressionsInStatement(caseStatement, transform, flags);\n }\n for (const caseStatement of stmt.falseCase) {\n transformExpressionsInStatement(caseStatement, transform, flags);\n }\n } else {\n throw new Error(`Unhandled statement kind: ${stmt.constructor.name}`);\n }\n}\n\n/**\n * Checks whether the given expression is a string literal.\n */\nexport function isStringLiteral(expr: o.Expression): expr is o.LiteralExpr & {value: string} {\n return expr instanceof o.LiteralExpr && typeof expr.value === 'string';\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {OpKind} from './enums';\n\n/**\n * Branded type for a cross-reference ID. During ingest, `XrefId`s are generated to link together\n * different IR operations which need to reference each other.\n */\nexport type XrefId = number & {__brand: 'XrefId'};\n\n/**\n * Base interface for semantic operations being performed within a template.\n *\n * @param OpT a specific narrower type of `Op` (for example, creation operations) which this\n * specific subtype of `Op` can be linked with in a linked list.\n */\nexport interface Op> {\n /**\n * All operations have a distinct kind.\n */\n kind: OpKind;\n\n /**\n * The previous operation in the linked list, if any.\n *\n * This is `null` for operation nodes not currently in a list, or for the special head/tail nodes.\n */\n prev: OpT | null;\n\n /**\n * The next operation in the linked list, if any.\n *\n * This is `null` for operation nodes not currently in a list, or for the special head/tail nodes.\n */\n next: OpT | null;\n\n /**\n * Debug id of the list to which this node currently belongs, or `null` if this node is not part\n * of a list.\n */\n debugListId: number | null;\n}\n\n/**\n * A linked list of `Op` nodes of a given subtype.\n *\n * @param OpT specific subtype of `Op` nodes which this list contains.\n */\nexport class OpList> {\n static nextListId = 0;\n\n /**\n * Debug ID of this `OpList` instance.\n */\n readonly debugListId = OpList.nextListId++;\n\n // OpList uses static head/tail nodes of a special `ListEnd` type.\n // This avoids the need for special casing of the first and last list\n // elements in all list operations.\n readonly head: OpT = {\n kind: OpKind.ListEnd,\n next: null,\n prev: null,\n debugListId: this.debugListId,\n } as OpT;\n\n readonly tail = {\n kind: OpKind.ListEnd,\n next: null,\n prev: null,\n debugListId: this.debugListId,\n } as OpT;\n\n constructor() {\n // Link `head` and `tail` together at the start (list is empty).\n this.head.next = this.tail;\n this.tail.prev = this.head;\n }\n\n /**\n * Push a new operation to the tail of the list.\n */\n push(op: OpT | Array): void {\n if (Array.isArray(op)) {\n for (const o of op) {\n this.push(o);\n }\n return;\n }\n\n OpList.assertIsNotEnd(op);\n OpList.assertIsUnowned(op);\n\n op.debugListId = this.debugListId;\n\n // The old \"previous\" node (which might be the head, if the list is empty).\n const oldLast = this.tail.prev!;\n\n // Insert `op` following the old last node.\n op.prev = oldLast;\n oldLast.next = op;\n\n // Connect `op` with the list tail.\n op.next = this.tail;\n this.tail.prev = op;\n }\n\n /**\n * Prepend one or more nodes to the start of the list.\n */\n prepend(ops: OpT[]): void {\n if (ops.length === 0) {\n return;\n }\n\n for (const op of ops) {\n OpList.assertIsNotEnd(op);\n OpList.assertIsUnowned(op);\n\n op.debugListId = this.debugListId;\n }\n\n const first = this.head.next!;\n\n let prev = this.head;\n for (const op of ops) {\n prev.next = op;\n op.prev = prev;\n\n prev = op;\n }\n\n prev.next = first;\n first.prev = prev;\n }\n\n /**\n * `OpList` is iterable via the iteration protocol.\n *\n * It's safe to mutate the part of the list that has already been returned by the iterator, up to\n * and including the last operation returned. Mutations beyond that point _may_ be safe, but may\n * also corrupt the iteration position and should be avoided.\n */\n *[Symbol.iterator](): Generator {\n let current = this.head.next!;\n while (current !== this.tail) {\n // Guards against corruption of the iterator state by mutations to the tail of the list during\n // iteration.\n OpList.assertIsOwned(current, this.debugListId);\n\n const next = current.next!;\n yield current;\n current = next;\n }\n }\n\n *reversed(): Generator {\n let current = this.tail.prev!;\n while (current !== this.head) {\n OpList.assertIsOwned(current, this.debugListId);\n\n const prev = current.prev!;\n yield current;\n current = prev;\n }\n }\n\n /**\n * Replace `oldOp` with `newOp` in the list.\n */\n static replace>(oldOp: OpT, newOp: OpT): void {\n OpList.assertIsNotEnd(oldOp);\n OpList.assertIsNotEnd(newOp);\n\n OpList.assertIsOwned(oldOp);\n OpList.assertIsUnowned(newOp);\n\n newOp.debugListId = oldOp.debugListId;\n if (oldOp.prev !== null) {\n oldOp.prev.next = newOp;\n newOp.prev = oldOp.prev;\n }\n if (oldOp.next !== null) {\n oldOp.next.prev = newOp;\n newOp.next = oldOp.next;\n }\n oldOp.debugListId = null;\n oldOp.prev = null;\n oldOp.next = null;\n }\n\n /**\n * Replace `oldOp` with some number of new operations in the list (which may include `oldOp`).\n */\n static replaceWithMany>(oldOp: OpT, newOps: OpT[]): void {\n if (newOps.length === 0) {\n // Replacing with an empty list -> pure removal.\n OpList.remove(oldOp);\n return;\n }\n\n OpList.assertIsNotEnd(oldOp);\n OpList.assertIsOwned(oldOp);\n\n const listId = oldOp.debugListId;\n oldOp.debugListId = null;\n\n for (const newOp of newOps) {\n OpList.assertIsNotEnd(newOp);\n\n // `newOp` might be `oldOp`, but at this point it's been marked as unowned.\n OpList.assertIsUnowned(newOp);\n }\n\n // It should be safe to reuse `oldOp` in the `newOps` list - maybe you want to sandwich an\n // operation between two new ops.\n const {prev: oldPrev, next: oldNext} = oldOp;\n oldOp.prev = null;\n oldOp.next = null;\n\n let prev: OpT = oldPrev!;\n for (const newOp of newOps) {\n this.assertIsUnowned(newOp);\n newOp.debugListId = listId;\n\n prev!.next = newOp;\n newOp.prev = prev;\n\n // This _should_ be the case, but set it just in case.\n newOp.next = null;\n\n prev = newOp;\n }\n // At the end of iteration, `prev` holds the last node in the list.\n const first = newOps[0]!;\n const last = prev!;\n\n // Replace `oldOp` with the chain `first` -> `last`.\n if (oldPrev !== null) {\n oldPrev.next = first;\n first.prev = oldPrev;\n }\n\n if (oldNext !== null) {\n oldNext.prev = last;\n last.next = oldNext;\n }\n }\n\n /**\n * Remove the given node from the list which contains it.\n */\n static remove>(op: OpT): void {\n OpList.assertIsNotEnd(op);\n OpList.assertIsOwned(op);\n\n op.prev!.next = op.next;\n op.next!.prev = op.prev;\n\n // Break any link between the node and this list to safeguard against its usage in future\n // operations.\n op.debugListId = null;\n op.prev = null;\n op.next = null;\n }\n\n /**\n * Insert `op` before `target`.\n */\n static insertBefore>(op: OpT | OpT[], target: OpT): void {\n if (Array.isArray(op)) {\n for (const o of op) {\n this.insertBefore(o, target);\n }\n return;\n }\n\n OpList.assertIsOwned(target);\n if (target.prev === null) {\n throw new Error(`AssertionError: illegal operation on list start`);\n }\n\n OpList.assertIsNotEnd(op);\n\n OpList.assertIsUnowned(op);\n\n op.debugListId = target.debugListId;\n\n // Just in case.\n op.prev = null;\n\n target.prev!.next = op;\n op.prev = target.prev;\n\n op.next = target;\n target.prev = op;\n }\n\n /**\n * Insert `op` after `target`.\n */\n static insertAfter>(op: OpT, target: OpT): void {\n OpList.assertIsOwned(target);\n if (target.next === null) {\n throw new Error(`AssertionError: illegal operation on list end`);\n }\n\n OpList.assertIsNotEnd(op);\n\n OpList.assertIsUnowned(op);\n\n op.debugListId = target.debugListId;\n\n target.next.prev = op;\n op.next = target.next;\n\n op.prev = target;\n target.next = op;\n }\n\n /**\n * Asserts that `op` does not currently belong to a list.\n */\n static assertIsUnowned>(op: OpT): void {\n if (op.debugListId !== null) {\n throw new Error(`AssertionError: illegal operation on owned node: ${OpKind[op.kind]}`);\n }\n }\n\n /**\n * Asserts that `op` currently belongs to a list. If `byList` is passed, `op` is asserted to\n * specifically belong to that list.\n */\n static assertIsOwned>(op: OpT, byList?: number): void {\n if (op.debugListId === null) {\n throw new Error(`AssertionError: illegal operation on unowned node: ${OpKind[op.kind]}`);\n } else if (byList !== undefined && op.debugListId !== byList) {\n throw new Error(\n `AssertionError: node belongs to the wrong list (expected ${byList}, actual ${op.debugListId})`,\n );\n }\n }\n\n /**\n * Asserts that `op` is not a special `ListEnd` node.\n */\n static assertIsNotEnd>(op: OpT): void {\n if (op.kind === OpKind.ListEnd) {\n throw new Error(`AssertionError: illegal operation on list head or tail`);\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nexport class SlotHandle {\n slot: number | null = null;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '../../../../../core';\nimport * as i18n from '../../../../../i18n/i18n_ast';\nimport * as o from '../../../../../output/output_ast';\nimport {ParseSourceSpan} from '../../../../../parse_util';\nimport {\n BindingKind,\n DeferTriggerKind,\n I18nContextKind,\n I18nParamValueFlags,\n Namespace,\n OpKind,\n TemplateKind,\n} from '../enums';\nimport {SlotHandle} from '../handle';\nimport {Op, OpList, XrefId} from '../operations';\nimport {\n ConsumesSlotOpTrait,\n ConsumesVarsTrait,\n TRAIT_CONSUMES_SLOT,\n TRAIT_CONSUMES_VARS,\n} from '../traits';\n\nimport {ListEndOp, NEW_OP, StatementOp, VariableOp} from './shared';\n\nimport type {UpdateOp} from './update';\n\n/**\n * An operation usable on the creation side of the IR.\n */\nexport type CreateOp =\n | ListEndOp\n | StatementOp\n | ElementOp\n | ElementStartOp\n | ElementEndOp\n | ContainerOp\n | ContainerStartOp\n | ContainerEndOp\n | TemplateOp\n | EnableBindingsOp\n | DisableBindingsOp\n | TextOp\n | ListenerOp\n | TwoWayListenerOp\n | PipeOp\n | VariableOp\n | NamespaceOp\n | ProjectionDefOp\n | ProjectionOp\n | ExtractedAttributeOp\n | DeferOp\n | DeferOnOp\n | RepeaterCreateOp\n | I18nMessageOp\n | I18nOp\n | I18nStartOp\n | I18nEndOp\n | IcuStartOp\n | IcuEndOp\n | IcuPlaceholderOp\n | I18nContextOp\n | I18nAttributesOp\n | DeclareLetOp;\n\n/**\n * An operation representing the creation of an element or container.\n */\nexport type ElementOrContainerOps =\n | ElementOp\n | ElementStartOp\n | ContainerOp\n | ContainerStartOp\n | TemplateOp\n | RepeaterCreateOp;\n\n/**\n * The set of OpKinds that represent the creation of an element or container\n */\nconst elementContainerOpKinds = new Set([\n OpKind.Element,\n OpKind.ElementStart,\n OpKind.Container,\n OpKind.ContainerStart,\n OpKind.Template,\n OpKind.RepeaterCreate,\n]);\n\n/**\n * Checks whether the given operation represents the creation of an element or container.\n */\nexport function isElementOrContainerOp(op: CreateOp): op is ElementOrContainerOps {\n return elementContainerOpKinds.has(op.kind);\n}\n\n/**\n * Representation of a local reference on an element.\n */\nexport interface LocalRef {\n /**\n * User-defined name of the local ref variable.\n */\n name: string;\n\n /**\n * Target of the local reference variable (often `''`).\n */\n target: string;\n}\n\n/**\n * Base interface for `Element`, `ElementStart`, and `Template` operations, containing common fields\n * used to represent their element-like nature.\n */\nexport interface ElementOrContainerOpBase extends Op, ConsumesSlotOpTrait {\n kind: ElementOrContainerOps['kind'];\n\n /**\n * `XrefId` allocated for this element.\n *\n * This ID is used to reference this element from other IR structures.\n */\n xref: XrefId;\n\n /**\n * Attributes of various kinds on this element. Represented as a `ConstIndex` pointer into the\n * shared `consts` array of the component compilation.\n */\n attributes: ConstIndex | null;\n\n /**\n * Local references to this element.\n *\n * Before local ref processing, this is an array of `LocalRef` declarations.\n *\n * After processing, it's a `ConstIndex` pointer into the shared `consts` array of the component\n * compilation.\n */\n localRefs: LocalRef[] | ConstIndex | null;\n\n /**\n * Whether this container is marked `ngNonBindable`, which disabled Angular binding for itself and\n * all descendants.\n */\n nonBindable: boolean;\n\n /**\n * The span of the element's start tag.\n */\n startSourceSpan: ParseSourceSpan;\n\n /**\n * The whole source span of the element, including children.\n */\n wholeSourceSpan: ParseSourceSpan;\n}\n\nexport interface ElementOpBase extends ElementOrContainerOpBase {\n kind: OpKind.Element | OpKind.ElementStart | OpKind.Template | OpKind.RepeaterCreate;\n\n /**\n * The HTML tag name for this element.\n */\n tag: string | null;\n\n /**\n * The namespace of this element, which controls the preceding namespace instruction.\n */\n namespace: Namespace;\n}\n\n/**\n * Logical operation representing the start of an element in the creation IR.\n */\nexport interface ElementStartOp extends ElementOpBase {\n kind: OpKind.ElementStart;\n\n /**\n * The i18n placeholder data associated with this element.\n */\n i18nPlaceholder?: i18n.TagPlaceholder;\n}\n\n/**\n * Create an `ElementStartOp`.\n */\nexport function createElementStartOp(\n tag: string,\n xref: XrefId,\n namespace: Namespace,\n i18nPlaceholder: i18n.TagPlaceholder | undefined,\n startSourceSpan: ParseSourceSpan,\n wholeSourceSpan: ParseSourceSpan,\n): ElementStartOp {\n return {\n kind: OpKind.ElementStart,\n xref,\n tag,\n handle: new SlotHandle(),\n attributes: null,\n localRefs: [],\n nonBindable: false,\n namespace,\n i18nPlaceholder,\n startSourceSpan,\n wholeSourceSpan,\n ...TRAIT_CONSUMES_SLOT,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation representing an element with no children in the creation IR.\n */\nexport interface ElementOp extends ElementOpBase {\n kind: OpKind.Element;\n\n /**\n * The i18n placeholder data associated with this element.\n */\n i18nPlaceholder?: i18n.TagPlaceholder;\n}\n\n/**\n * Logical operation representing an embedded view declaration in the creation IR.\n */\nexport interface TemplateOp extends ElementOpBase {\n kind: OpKind.Template;\n\n templateKind: TemplateKind;\n\n /**\n * The number of declaration slots used by this template, or `null` if slots have not yet been\n * assigned.\n */\n decls: number | null;\n\n /**\n * The number of binding variable slots used by this template, or `null` if binding variables have\n * not yet been counted.\n */\n vars: number | null;\n\n /**\n * Suffix to add to the name of the generated template function.\n */\n functionNameSuffix: string;\n\n /**\n * The i18n placeholder data associated with this template.\n */\n i18nPlaceholder?: i18n.TagPlaceholder | i18n.BlockPlaceholder;\n}\n\n/**\n * Create a `TemplateOp`.\n */\nexport function createTemplateOp(\n xref: XrefId,\n templateKind: TemplateKind,\n tag: string | null,\n functionNameSuffix: string,\n namespace: Namespace,\n i18nPlaceholder: i18n.TagPlaceholder | i18n.BlockPlaceholder | undefined,\n startSourceSpan: ParseSourceSpan,\n wholeSourceSpan: ParseSourceSpan,\n): TemplateOp {\n return {\n kind: OpKind.Template,\n xref,\n templateKind,\n attributes: null,\n tag,\n handle: new SlotHandle(),\n functionNameSuffix,\n decls: null,\n vars: null,\n localRefs: [],\n nonBindable: false,\n namespace,\n i18nPlaceholder,\n startSourceSpan,\n wholeSourceSpan,\n ...TRAIT_CONSUMES_SLOT,\n ...NEW_OP,\n };\n}\n\n/**\n * An op that creates a repeater (e.g. a for loop).\n */\nexport interface RepeaterCreateOp extends ElementOpBase, ConsumesVarsTrait {\n kind: OpKind.RepeaterCreate;\n\n /**\n * The number of declaration slots used by this repeater's template, or `null` if slots have not\n * yet been assigned.\n */\n decls: number | null;\n\n /**\n * The number of binding variable slots used by this repeater's, or `null` if binding variables\n * have not yet been counted.\n */\n vars: number | null;\n\n /**\n * The Xref of the empty view function. (For the primary view function, use the `xref` property).\n */\n emptyView: XrefId | null;\n\n /**\n * The track expression to use while iterating.\n */\n track: o.Expression;\n\n /**\n * `null` initially, then an `o.Expression`. Might be a track expression, or might be a reference\n * into the constant pool.\n */\n trackByFn: o.Expression | null;\n\n /**\n * Context variables avaialable in this block.\n */\n varNames: RepeaterVarNames;\n\n /**\n * Whether the repeater track function relies on the component instance.\n */\n usesComponentInstance: boolean;\n\n /**\n * Suffix to add to the name of the generated template function.\n */\n functionNameSuffix: string;\n\n /**\n * Tag name for the empty block.\n */\n emptyTag: string | null;\n\n /**\n * Attributes of various kinds on the empty block. Represented as a `ConstIndex` pointer into the\n * shared `consts` array of the component compilation.\n */\n emptyAttributes: ConstIndex | null;\n\n /**\n * The i18n placeholder for the repeated item template.\n */\n i18nPlaceholder: i18n.BlockPlaceholder | undefined;\n\n /**\n * The i18n placeholder for the empty template.\n */\n emptyI18nPlaceholder: i18n.BlockPlaceholder | undefined;\n}\n\n// TODO: add source spans?\nexport interface RepeaterVarNames {\n $index: Set;\n $implicit: string;\n}\n\nexport function createRepeaterCreateOp(\n primaryView: XrefId,\n emptyView: XrefId | null,\n tag: string | null,\n track: o.Expression,\n varNames: RepeaterVarNames,\n emptyTag: string | null,\n i18nPlaceholder: i18n.BlockPlaceholder | undefined,\n emptyI18nPlaceholder: i18n.BlockPlaceholder | undefined,\n startSourceSpan: ParseSourceSpan,\n wholeSourceSpan: ParseSourceSpan,\n): RepeaterCreateOp {\n return {\n kind: OpKind.RepeaterCreate,\n attributes: null,\n xref: primaryView,\n handle: new SlotHandle(),\n emptyView,\n track,\n trackByFn: null,\n tag,\n emptyTag,\n emptyAttributes: null,\n functionNameSuffix: 'For',\n namespace: Namespace.HTML,\n nonBindable: false,\n localRefs: [],\n decls: null,\n vars: null,\n varNames,\n usesComponentInstance: false,\n i18nPlaceholder,\n emptyI18nPlaceholder,\n startSourceSpan,\n wholeSourceSpan,\n ...TRAIT_CONSUMES_SLOT,\n ...NEW_OP,\n ...TRAIT_CONSUMES_VARS,\n numSlotsUsed: emptyView === null ? 2 : 3,\n };\n}\n\n/**\n * Logical operation representing the end of an element structure in the creation IR.\n *\n * Pairs with an `ElementStart` operation.\n */\nexport interface ElementEndOp extends Op {\n kind: OpKind.ElementEnd;\n\n /**\n * The `XrefId` of the element declared via `ElementStart`.\n */\n xref: XrefId;\n\n sourceSpan: ParseSourceSpan | null;\n}\n\n/**\n * Create an `ElementEndOp`.\n */\nexport function createElementEndOp(xref: XrefId, sourceSpan: ParseSourceSpan | null): ElementEndOp {\n return {\n kind: OpKind.ElementEnd,\n xref,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation representing the start of a container in the creation IR.\n */\nexport interface ContainerStartOp extends ElementOrContainerOpBase {\n kind: OpKind.ContainerStart;\n}\n\n/**\n * Logical operation representing an empty container in the creation IR.\n */\nexport interface ContainerOp extends ElementOrContainerOpBase {\n kind: OpKind.Container;\n}\n\n/**\n * Logical operation representing the end of a container structure in the creation IR.\n *\n * Pairs with an `ContainerStart` operation.\n */\nexport interface ContainerEndOp extends Op {\n kind: OpKind.ContainerEnd;\n\n /**\n * The `XrefId` of the element declared via `ContainerStart`.\n */\n xref: XrefId;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Logical operation causing binding to be disabled in descendents of a non-bindable container.\n */\nexport interface DisableBindingsOp extends Op {\n kind: OpKind.DisableBindings;\n\n /**\n * `XrefId` of the element that was marked non-bindable.\n */\n xref: XrefId;\n}\n\nexport function createDisableBindingsOp(xref: XrefId): DisableBindingsOp {\n return {\n kind: OpKind.DisableBindings,\n xref,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation causing binding to be re-enabled after visiting descendants of a\n * non-bindable container.\n */\nexport interface EnableBindingsOp extends Op {\n kind: OpKind.EnableBindings;\n\n /**\n * `XrefId` of the element that was marked non-bindable.\n */\n xref: XrefId;\n}\n\nexport function createEnableBindingsOp(xref: XrefId): EnableBindingsOp {\n return {\n kind: OpKind.EnableBindings,\n xref,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation representing a text node in the creation IR.\n */\nexport interface TextOp extends Op, ConsumesSlotOpTrait {\n kind: OpKind.Text;\n\n /**\n * `XrefId` used to reference this text node in other IR structures.\n */\n xref: XrefId;\n\n /**\n * The static initial value of the text node.\n */\n initialValue: string;\n\n /**\n * The placeholder for this text in its parent ICU. If this text is not part of an ICU, the\n * placeholder is null.\n */\n icuPlaceholder: string | null;\n\n sourceSpan: ParseSourceSpan | null;\n}\n\n/**\n * Create a `TextOp`.\n */\nexport function createTextOp(\n xref: XrefId,\n initialValue: string,\n icuPlaceholder: string | null,\n sourceSpan: ParseSourceSpan | null,\n): TextOp {\n return {\n kind: OpKind.Text,\n xref,\n handle: new SlotHandle(),\n initialValue,\n icuPlaceholder,\n sourceSpan,\n ...TRAIT_CONSUMES_SLOT,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation representing an event listener on an element in the creation IR.\n */\nexport interface ListenerOp extends Op {\n kind: OpKind.Listener;\n\n target: XrefId;\n targetSlot: SlotHandle;\n\n /**\n * Whether this listener is from a host binding.\n */\n hostListener: boolean;\n\n /**\n * Name of the event which is being listened to.\n */\n name: string;\n\n /**\n * Tag name of the element on which this listener is placed. Might be null, if this listener\n * belongs to a host binding.\n */\n tag: string | null;\n\n /**\n * A list of `UpdateOp`s representing the body of the event listener.\n */\n handlerOps: OpList;\n\n /**\n * Name of the function\n */\n handlerFnName: string | null;\n\n /**\n * Whether this listener is known to consume `$event` in its body.\n */\n consumesDollarEvent: boolean;\n\n /**\n * Whether the listener is listening for an animation event.\n */\n isAnimationListener: boolean;\n\n /**\n * The animation phase of the listener.\n */\n animationPhase: string | null;\n\n /**\n * Some event listeners can have a target, e.g. in `document:dragover`.\n */\n eventTarget: string | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `ListenerOp`. Host bindings reuse all the listener logic.\n */\nexport function createListenerOp(\n target: XrefId,\n targetSlot: SlotHandle,\n name: string,\n tag: string | null,\n handlerOps: Array,\n animationPhase: string | null,\n eventTarget: string | null,\n hostListener: boolean,\n sourceSpan: ParseSourceSpan,\n): ListenerOp {\n const handlerList = new OpList();\n handlerList.push(handlerOps);\n return {\n kind: OpKind.Listener,\n target,\n targetSlot,\n tag,\n hostListener,\n name,\n handlerOps: handlerList,\n handlerFnName: null,\n consumesDollarEvent: false,\n isAnimationListener: animationPhase !== null,\n animationPhase,\n eventTarget,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * Logical operation representing the event side of a two-way binding on an element\n * in the creation IR.\n */\nexport interface TwoWayListenerOp extends Op {\n kind: OpKind.TwoWayListener;\n\n target: XrefId;\n targetSlot: SlotHandle;\n\n /**\n * Name of the event which is being listened to.\n */\n name: string;\n\n /**\n * Tag name of the element on which this listener is placed.\n */\n tag: string | null;\n\n /**\n * A list of `UpdateOp`s representing the body of the event listener.\n */\n handlerOps: OpList;\n\n /**\n * Name of the function\n */\n handlerFnName: string | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Create a `TwoWayListenerOp`.\n */\nexport function createTwoWayListenerOp(\n target: XrefId,\n targetSlot: SlotHandle,\n name: string,\n tag: string | null,\n handlerOps: Array,\n sourceSpan: ParseSourceSpan,\n): TwoWayListenerOp {\n const handlerList = new OpList();\n handlerList.push(handlerOps);\n return {\n kind: OpKind.TwoWayListener,\n target,\n targetSlot,\n tag,\n name,\n handlerOps: handlerList,\n handlerFnName: null,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\nexport interface PipeOp extends Op, ConsumesSlotOpTrait {\n kind: OpKind.Pipe;\n xref: XrefId;\n name: string;\n}\n\nexport function createPipeOp(xref: XrefId, slot: SlotHandle, name: string): PipeOp {\n return {\n kind: OpKind.Pipe,\n xref,\n handle: slot,\n name,\n ...NEW_OP,\n ...TRAIT_CONSUMES_SLOT,\n };\n}\n\n/**\n * An op corresponding to a namespace instruction, for switching between HTML, SVG, and MathML.\n */\nexport interface NamespaceOp extends Op {\n kind: OpKind.Namespace;\n active: Namespace;\n}\n\nexport function createNamespaceOp(namespace: Namespace): NamespaceOp {\n return {\n kind: OpKind.Namespace,\n active: namespace,\n ...NEW_OP,\n };\n}\n\n/**\n * An op that creates a content projection slot.\n */\nexport interface ProjectionDefOp extends Op {\n kind: OpKind.ProjectionDef;\n\n // The parsed selector information for this projection def.\n def: o.Expression | null;\n}\n\nexport function createProjectionDefOp(def: o.Expression | null): ProjectionDefOp {\n return {\n kind: OpKind.ProjectionDef,\n def,\n ...NEW_OP,\n };\n}\n\n/**\n * An op that creates a content projection slot.\n */\nexport interface ProjectionOp extends Op, ConsumesSlotOpTrait {\n kind: OpKind.Projection;\n\n xref: XrefId;\n\n projectionSlotIndex: number;\n\n attributes: null | o.LiteralArrayExpr;\n\n localRefs: string[];\n\n selector: string;\n\n i18nPlaceholder?: i18n.TagPlaceholder;\n\n sourceSpan: ParseSourceSpan;\n\n fallbackView: XrefId | null;\n}\n\nexport function createProjectionOp(\n xref: XrefId,\n selector: string,\n i18nPlaceholder: i18n.TagPlaceholder | undefined,\n fallbackView: XrefId | null,\n sourceSpan: ParseSourceSpan,\n): ProjectionOp {\n return {\n kind: OpKind.Projection,\n xref,\n handle: new SlotHandle(),\n selector,\n i18nPlaceholder,\n fallbackView,\n projectionSlotIndex: 0,\n attributes: null,\n localRefs: [],\n sourceSpan,\n ...NEW_OP,\n ...TRAIT_CONSUMES_SLOT,\n numSlotsUsed: fallbackView === null ? 1 : 2,\n };\n}\n\n/**\n * Represents an attribute that has been extracted for inclusion in the consts array.\n */\nexport interface ExtractedAttributeOp extends Op {\n kind: OpKind.ExtractedAttribute;\n\n /**\n * The `XrefId` of the template-like element the extracted attribute will belong to.\n */\n target: XrefId;\n\n /**\n * The kind of binding represented by this extracted attribute.\n */\n bindingKind: BindingKind;\n\n /**\n * The namespace of the attribute (or null if none).\n */\n namespace: string | null;\n\n /**\n * The name of the extracted attribute.\n */\n name: string;\n\n /**\n * The value expression of the extracted attribute.\n */\n expression: o.Expression | null;\n\n /**\n * If this attribute has a corresponding i18n attribute (e.g. `i18n-foo=\"m:d\"`), then this is the\n * i18n context for it.\n */\n i18nContext: XrefId | null;\n\n /**\n * The security context of the binding.\n */\n securityContext: SecurityContext | SecurityContext[];\n\n /**\n * The trusted value function for this property.\n */\n trustedValueFn: o.Expression | null;\n\n i18nMessage: i18n.Message | null;\n}\n\n/**\n * Create an `ExtractedAttributeOp`.\n */\nexport function createExtractedAttributeOp(\n target: XrefId,\n bindingKind: BindingKind,\n namespace: string | null,\n name: string,\n expression: o.Expression | null,\n i18nContext: XrefId | null,\n i18nMessage: i18n.Message | null,\n securityContext: SecurityContext | SecurityContext[],\n): ExtractedAttributeOp {\n return {\n kind: OpKind.ExtractedAttribute,\n target,\n bindingKind,\n namespace,\n name,\n expression,\n i18nContext,\n i18nMessage,\n securityContext,\n trustedValueFn: null,\n ...NEW_OP,\n };\n}\n\nexport interface DeferOp extends Op, ConsumesSlotOpTrait {\n kind: OpKind.Defer;\n\n /**\n * The xref of this defer op.\n */\n xref: XrefId;\n\n /**\n * The xref of the main view.\n */\n mainView: XrefId;\n\n mainSlot: SlotHandle;\n\n /**\n * Secondary loading block associated with this defer op.\n */\n loadingView: XrefId | null;\n\n loadingSlot: SlotHandle | null;\n\n /**\n * Secondary placeholder block associated with this defer op.\n */\n placeholderView: XrefId | null;\n\n placeholderSlot: SlotHandle | null;\n\n /**\n * Secondary error block associated with this defer op.\n */\n errorView: XrefId | null;\n\n errorSlot: SlotHandle | null;\n\n placeholderMinimumTime: number | null;\n loadingMinimumTime: number | null;\n loadingAfterTime: number | null;\n\n placeholderConfig: o.Expression | null;\n loadingConfig: o.Expression | null;\n\n /**\n * Depending on the compilation mode, there can be either one dependency resolution function\n * per deferred block or one for the entire template. This field contains the function that\n * belongs specifically to the current deferred block.\n */\n ownResolverFn: o.Expression | null;\n\n /**\n * After processing, the resolver function for the defer deps will be extracted to the constant\n * pool, and a reference to that function will be populated here.\n */\n resolverFn: o.Expression | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\nexport function createDeferOp(\n xref: XrefId,\n main: XrefId,\n mainSlot: SlotHandle,\n ownResolverFn: o.Expression | null,\n resolverFn: o.Expression | null,\n sourceSpan: ParseSourceSpan,\n): DeferOp {\n return {\n kind: OpKind.Defer,\n xref,\n handle: new SlotHandle(),\n mainView: main,\n mainSlot,\n loadingView: null,\n loadingSlot: null,\n loadingConfig: null,\n loadingMinimumTime: null,\n loadingAfterTime: null,\n placeholderView: null,\n placeholderSlot: null,\n placeholderConfig: null,\n placeholderMinimumTime: null,\n errorView: null,\n errorSlot: null,\n ownResolverFn,\n resolverFn,\n sourceSpan,\n ...NEW_OP,\n ...TRAIT_CONSUMES_SLOT,\n numSlotsUsed: 2,\n };\n}\ninterface DeferTriggerBase {\n kind: DeferTriggerKind;\n}\n\ninterface DeferTriggerWithTargetBase extends DeferTriggerBase {\n targetName: string | null;\n\n /**\n * The Xref of the targeted name. May be in a different view.\n */\n targetXref: XrefId | null;\n\n /**\n * The slot index of the named reference, inside the view provided below. This slot may not be\n * inside the current view, and is handled specially as a result.\n */\n targetSlot: SlotHandle | null;\n\n targetView: XrefId | null;\n\n /**\n * Number of steps to walk up or down the view tree to find the target localRef.\n */\n targetSlotViewSteps: number | null;\n}\n\ninterface DeferIdleTrigger extends DeferTriggerBase {\n kind: DeferTriggerKind.Idle;\n}\n\ninterface DeferImmediateTrigger extends DeferTriggerBase {\n kind: DeferTriggerKind.Immediate;\n}\n\ninterface DeferHoverTrigger extends DeferTriggerWithTargetBase {\n kind: DeferTriggerKind.Hover;\n}\n\ninterface DeferTimerTrigger extends DeferTriggerBase {\n kind: DeferTriggerKind.Timer;\n\n delay: number;\n}\n\ninterface DeferInteractionTrigger extends DeferTriggerWithTargetBase {\n kind: DeferTriggerKind.Interaction;\n}\n\ninterface DeferViewportTrigger extends DeferTriggerWithTargetBase {\n kind: DeferTriggerKind.Viewport;\n}\n\n/**\n * The union type of all defer trigger interfaces.\n */\nexport type DeferTrigger =\n | DeferIdleTrigger\n | DeferImmediateTrigger\n | DeferTimerTrigger\n | DeferHoverTrigger\n | DeferInteractionTrigger\n | DeferViewportTrigger;\n\nexport interface DeferOnOp extends Op {\n kind: OpKind.DeferOn;\n\n defer: XrefId;\n\n /**\n * The trigger for this defer op (e.g. idle, hover, etc).\n */\n trigger: DeferTrigger;\n\n /**\n * Whether to emit the prefetch version of the instruction.\n */\n prefetch: boolean;\n\n sourceSpan: ParseSourceSpan;\n}\n\nexport function createDeferOnOp(\n defer: XrefId,\n trigger: DeferTrigger,\n prefetch: boolean,\n sourceSpan: ParseSourceSpan,\n): DeferOnOp {\n return {\n kind: OpKind.DeferOn,\n defer,\n trigger,\n prefetch,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * Op that reserves a slot during creation time for a `@let` declaration.\n */\nexport interface DeclareLetOp extends Op, ConsumesSlotOpTrait {\n kind: OpKind.DeclareLet;\n xref: XrefId;\n sourceSpan: ParseSourceSpan;\n declaredName: string;\n}\n\n/**\n * Creates a `DeclareLetOp`.\n */\nexport function createDeclareLetOp(\n xref: XrefId,\n declaredName: string,\n sourceSpan: ParseSourceSpan,\n): DeclareLetOp {\n return {\n kind: OpKind.DeclareLet,\n xref,\n declaredName,\n sourceSpan,\n handle: new SlotHandle(),\n ...TRAIT_CONSUMES_SLOT,\n ...NEW_OP,\n };\n}\n\n/**\n * Represents a single value in an i18n param map. Each placeholder in the map may have multiple of\n * these values associated with it.\n */\nexport interface I18nParamValue {\n /**\n * The value. This can be either a slot number, special string, or compound-value consisting of an\n * element slot number and template slot number.\n */\n value: string | number | {element: number; template: number};\n\n /**\n * The sub-template index associated with the value.\n */\n subTemplateIndex: number | null;\n\n /**\n * Flags associated with the value.\n */\n flags: I18nParamValueFlags;\n}\n\n/**\n * Represents an i18n message that has been extracted for inclusion in the consts array.\n */\nexport interface I18nMessageOp extends Op {\n kind: OpKind.I18nMessage;\n\n /**\n * An id used to reference this message.\n */\n xref: XrefId;\n\n /**\n * The context from which this message was extracted\n * TODO: remove this, and add another property here instead to match ExtractedAttributes\n */\n i18nContext: XrefId;\n\n /**\n * A reference to the i18n op this message was extracted from.\n *\n * This might be null, which means this message is not associated with a block. This probably\n * means it is an i18n attribute's message.\n */\n i18nBlock: XrefId | null;\n\n /**\n * The i18n message represented by this op.\n */\n message: i18n.Message;\n\n /**\n * The placeholder used for this message when it is referenced in another message.\n * For a top-level message that isn't referenced from another message, this will be null.\n */\n messagePlaceholder: string | null;\n\n /**\n * Whether this message needs post-processing.\n */\n needsPostprocessing: boolean;\n\n /**\n * The param map, with placeholders represented as an `Expression`.\n */\n params: Map;\n\n /**\n * The post-processing param map, with placeholders represented as an `Expression`.\n */\n postprocessingParams: Map;\n\n /**\n * A list of sub-messages that are referenced by this message.\n */\n subMessages: XrefId[];\n}\n\n/**\n * Create an `ExtractedMessageOp`.\n */\nexport function createI18nMessageOp(\n xref: XrefId,\n i18nContext: XrefId,\n i18nBlock: XrefId | null,\n message: i18n.Message,\n messagePlaceholder: string | null,\n params: Map,\n postprocessingParams: Map,\n needsPostprocessing: boolean,\n): I18nMessageOp {\n return {\n kind: OpKind.I18nMessage,\n xref,\n i18nContext,\n i18nBlock,\n message,\n messagePlaceholder,\n params,\n postprocessingParams,\n needsPostprocessing,\n subMessages: [],\n ...NEW_OP,\n };\n}\n\nexport interface I18nOpBase extends Op, ConsumesSlotOpTrait {\n kind: OpKind.I18nStart | OpKind.I18n;\n\n /**\n * `XrefId` allocated for this i18n block.\n */\n xref: XrefId;\n\n /**\n * A reference to the root i18n block that this one belongs to. For a root i18n block, this is\n * the same as xref.\n */\n root: XrefId;\n\n /**\n * The i18n metadata associated with this op.\n */\n message: i18n.Message;\n\n /**\n * The index in the consts array where the message i18n message is stored.\n */\n messageIndex: ConstIndex | null;\n\n /**\n * The index of this sub-block in the i18n message. For a root i18n block, this is null.\n */\n subTemplateIndex: number | null;\n\n /**\n * The i18n context generated from this block. Initially null, until the context is created.\n */\n context: XrefId | null;\n\n sourceSpan: ParseSourceSpan | null;\n}\n\n/**\n * Represents an empty i18n block.\n */\nexport interface I18nOp extends I18nOpBase {\n kind: OpKind.I18n;\n}\n\n/**\n * Represents the start of an i18n block.\n */\nexport interface I18nStartOp extends I18nOpBase {\n kind: OpKind.I18nStart;\n}\n\n/**\n * Create an `I18nStartOp`.\n */\nexport function createI18nStartOp(\n xref: XrefId,\n message: i18n.Message,\n root: XrefId | undefined,\n sourceSpan: ParseSourceSpan | null,\n): I18nStartOp {\n return {\n kind: OpKind.I18nStart,\n xref,\n handle: new SlotHandle(),\n root: root ?? xref,\n message,\n messageIndex: null,\n subTemplateIndex: null,\n context: null,\n sourceSpan,\n ...NEW_OP,\n ...TRAIT_CONSUMES_SLOT,\n };\n}\n\n/**\n * Represents the end of an i18n block.\n */\nexport interface I18nEndOp extends Op {\n kind: OpKind.I18nEnd;\n\n /**\n * The `XrefId` of the `I18nStartOp` that created this block.\n */\n xref: XrefId;\n\n sourceSpan: ParseSourceSpan | null;\n}\n\n/**\n * Create an `I18nEndOp`.\n */\nexport function createI18nEndOp(xref: XrefId, sourceSpan: ParseSourceSpan | null): I18nEndOp {\n return {\n kind: OpKind.I18nEnd,\n xref,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * An op that represents the start of an ICU expression.\n */\nexport interface IcuStartOp extends Op {\n kind: OpKind.IcuStart;\n\n /**\n * The ID of the ICU.\n */\n xref: XrefId;\n\n /**\n * The i18n message for this ICU.\n */\n message: i18n.Message;\n\n /**\n * Placeholder used to reference this ICU in other i18n messages.\n */\n messagePlaceholder: string;\n\n /**\n * A reference to the i18n context for this op. Initially null, until the context is created.\n */\n context: XrefId | null;\n\n sourceSpan: ParseSourceSpan;\n}\n\n/**\n * Creates an ICU start op.\n */\nexport function createIcuStartOp(\n xref: XrefId,\n message: i18n.Message,\n messagePlaceholder: string,\n sourceSpan: ParseSourceSpan,\n): IcuStartOp {\n return {\n kind: OpKind.IcuStart,\n xref,\n message,\n messagePlaceholder,\n context: null,\n sourceSpan,\n ...NEW_OP,\n };\n}\n\n/**\n * An op that represents the end of an ICU expression.\n */\nexport interface IcuEndOp extends Op {\n kind: OpKind.IcuEnd;\n\n /**\n * The ID of the corresponding IcuStartOp.\n */\n xref: XrefId;\n}\n\n/**\n * Creates an ICU end op.\n */\nexport function createIcuEndOp(xref: XrefId): IcuEndOp {\n return {\n kind: OpKind.IcuEnd,\n xref,\n ...NEW_OP,\n };\n}\n\n/**\n * An op that represents a placeholder in an ICU expression.\n */\nexport interface IcuPlaceholderOp extends Op {\n kind: OpKind.IcuPlaceholder;\n\n /**\n * The ID of the ICU placeholder.\n */\n xref: XrefId;\n\n /**\n * The name of the placeholder in the ICU expression.\n */\n name: string;\n\n /**\n * The static strings to be combined with dynamic expression values to form the text. This works\n * like interpolation, but the strings are combined at compile time, using special placeholders\n * for the dynamic expressions, and put into the translated message.\n */\n strings: string[];\n\n /**\n * Placeholder values for the i18n expressions to be combined with the static strings to form the\n * full placeholder value.\n */\n expressionPlaceholders: I18nParamValue[];\n}\n\n/**\n * Creates an ICU placeholder op.\n */\nexport function createIcuPlaceholderOp(\n xref: XrefId,\n name: string,\n strings: string[],\n): IcuPlaceholderOp {\n return {\n kind: OpKind.IcuPlaceholder,\n xref,\n name,\n strings,\n expressionPlaceholders: [],\n ...NEW_OP,\n };\n}\n\n/**\n * An i18n context that is used to generate a translated i18n message. A separate context is created\n * for three different scenarios:\n *\n * 1. For each top-level i18n block.\n * 2. For each ICU referenced as a sub-message. ICUs that are referenced as a sub-message will be\n * used to generate a separate i18n message, but will not be extracted directly into the consts\n * array. Instead they will be pulled in as part of the initialization statements for the message\n * that references them.\n * 3. For each i18n attribute.\n *\n * Child i18n blocks, resulting from the use of an ng-template inside of a parent i18n block, do not\n * generate a separate context. Instead their content is included in the translated message for\n * their root block.\n */\nexport interface I18nContextOp extends Op {\n kind: OpKind.I18nContext;\n\n contextKind: I18nContextKind;\n\n /**\n * The id of this context.\n */\n xref: XrefId;\n\n /**\n * A reference to the I18nStartOp or I18nOp this context belongs to.\n *\n * It is possible for multiple contexts to belong to the same block, since both the block and any\n * ICUs inside the block will each get their own context.\n *\n * This might be `null`, in which case the context is not associated with an i18n block. This\n * probably means that it belongs to an i18n attribute.\n */\n i18nBlock: XrefId | null;\n\n /**\n * The i18n message associated with this context.\n */\n message: i18n.Message;\n\n /**\n * The param map for this context.\n */\n params: Map;\n\n /**\n * The post-processing param map for this context.\n */\n postprocessingParams: Map;\n\n sourceSpan: ParseSourceSpan;\n}\n\nexport function createI18nContextOp(\n contextKind: I18nContextKind,\n xref: XrefId,\n i18nBlock: XrefId | null,\n message: i18n.Message,\n sourceSpan: ParseSourceSpan,\n): I18nContextOp {\n if (i18nBlock === null && contextKind !== I18nContextKind.Attr) {\n throw new Error('AssertionError: i18nBlock must be provided for non-attribute contexts.');\n }\n\n return {\n kind: OpKind.I18nContext,\n contextKind,\n xref,\n i18nBlock,\n message,\n sourceSpan,\n params: new Map(),\n postprocessingParams: new Map(),\n ...NEW_OP,\n };\n}\n\nexport interface I18nAttributesOp extends Op, ConsumesSlotOpTrait {\n kind: OpKind.I18nAttributes;\n\n /**\n * The element targeted by these attributes.\n */\n target: XrefId;\n\n /**\n * I18nAttributes instructions correspond to a const array with configuration information.\n */\n i18nAttributesConfig: ConstIndex | null;\n}\n\nexport function createI18nAttributesOp(\n xref: XrefId,\n handle: SlotHandle,\n target: XrefId,\n): I18nAttributesOp {\n return {\n kind: OpKind.I18nAttributes,\n xref,\n handle,\n target,\n i18nAttributesConfig: null,\n ...NEW_OP,\n ...TRAIT_CONSUMES_SLOT,\n };\n}\n\n/**\n * An index into the `consts` array which is shared across the compilation of all views in a\n * component.\n */\nexport type ConstIndex = number & {__brand: 'ConstIndex'};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../../../src/output/output_ast';\nimport {ParseSourceSpan} from '../../../../../../src/parse_util';\nimport {SecurityContext} from '../../../../../core';\nimport {OpKind} from '../enums';\nimport {Op, XrefId} from '../operations';\nimport {ConsumesVarsTrait, TRAIT_CONSUMES_VARS} from '../traits';\n\nimport {NEW_OP} from './shared';\n\nimport type {Interpolation, UpdateOp} from './update';\n\n/**\n * Logical operation representing a host binding to a property.\n */\nexport interface HostPropertyOp extends Op, ConsumesVarsTrait {\n kind: OpKind.HostProperty;\n name: string;\n expression: o.Expression | Interpolation;\n isAnimationTrigger: boolean;\n\n i18nContext: XrefId | null;\n\n securityContext: SecurityContext | SecurityContext[];\n\n sanitizer: o.Expression | null;\n\n sourceSpan: ParseSourceSpan | null;\n}\n\nexport function createHostPropertyOp(\n name: string,\n expression: o.Expression | Interpolation,\n isAnimationTrigger: boolean,\n i18nContext: XrefId | null,\n securityContext: SecurityContext | SecurityContext[],\n sourceSpan: ParseSourceSpan | null,\n): HostPropertyOp {\n return {\n kind: OpKind.HostProperty,\n name,\n expression,\n isAnimationTrigger,\n i18nContext,\n securityContext,\n sanitizer: null,\n sourceSpan,\n ...TRAIT_CONSUMES_VARS,\n ...NEW_OP,\n };\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport type {SemanticVariableKind} from './enums';\nimport type {XrefId} from './operations';\n\n/**\n * Union type for the different kinds of variables.\n */\nexport type SemanticVariable =\n | ContextVariable\n | IdentifierVariable\n | SavedViewVariable\n | AliasVariable;\n\nexport interface SemanticVariableBase {\n kind: SemanticVariableKind;\n\n /**\n * Name assigned to this variable in generated code, or `null` if not yet assigned.\n */\n name: string | null;\n}\n\n/**\n * When referenced in the template's context parameters, this indicates a reference to the entire\n * context object, rather than a specific parameter.\n */\nexport const CTX_REF = 'CTX_REF_MARKER';\n\n/**\n * A variable that represents the context of a particular view.\n */\nexport interface ContextVariable extends SemanticVariableBase {\n kind: SemanticVariableKind.Context;\n\n /**\n * `XrefId` of the view that this variable represents.\n */\n view: XrefId;\n}\n\n/**\n * A variable that represents a specific identifier within a template.\n */\nexport interface IdentifierVariable extends SemanticVariableBase {\n kind: SemanticVariableKind.Identifier;\n\n /**\n * The identifier whose value in the template is tracked in this variable.\n */\n identifier: string;\n\n /**\n * Whether the variable was declared locally within the same view or somewhere else.\n */\n local: boolean;\n}\n\n/**\n * A variable that represents a saved view context.\n */\nexport interface SavedViewVariable extends SemanticVariableBase {\n kind: SemanticVariableKind.SavedView;\n\n /**\n * The view context saved in this variable.\n */\n view: XrefId;\n}\n\n/**\n * A variable that will be inlined at every location it is used. An alias is also allowed to depend\n * on the value of a semantic variable.\n */\nexport interface AliasVariable extends SemanticVariableBase {\n kind: SemanticVariableKind.Alias;\n identifier: string;\n expression: o.Expression;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ConstantPool} from '../../../constant_pool';\nimport * as o from '../../../output/output_ast';\nimport {R3ComponentDeferMetadata} from '../../../render3/view/api';\nimport * as ir from '../ir';\n\nexport enum CompilationJobKind {\n Tmpl,\n Host,\n Both, // A special value used to indicate that some logic applies to both compilation types\n}\n\n/**\n * An entire ongoing compilation, which will result in one or more template functions when complete.\n * Contains one or more corresponding compilation units.\n */\nexport abstract class CompilationJob {\n constructor(\n readonly componentName: string,\n readonly pool: ConstantPool,\n readonly compatibility: ir.CompatibilityMode,\n ) {}\n\n kind: CompilationJobKind = CompilationJobKind.Both;\n\n /**\n * A compilation job will contain one or more compilation units.\n */\n abstract get units(): Iterable;\n\n /**\n * The root compilation unit, such as the component's template, or the host binding's compilation\n * unit.\n */\n abstract root: CompilationUnit;\n\n /**\n * A unique string used to identify this kind of job, and generate the template function (as a\n * suffix of the name).\n */\n abstract fnSuffix: string;\n\n /**\n * Generate a new unique `ir.XrefId` in this job.\n */\n allocateXrefId(): ir.XrefId {\n return this.nextXrefId++ as ir.XrefId;\n }\n\n /**\n * Tracks the next `ir.XrefId` which can be assigned as template structures are ingested.\n */\n private nextXrefId: ir.XrefId = 0 as ir.XrefId;\n}\n\n/**\n * Compilation-in-progress of a whole component's template, including the main template and any\n * embedded views or host bindings.\n */\nexport class ComponentCompilationJob extends CompilationJob {\n constructor(\n componentName: string,\n pool: ConstantPool,\n compatibility: ir.CompatibilityMode,\n readonly relativeContextFilePath: string,\n readonly i18nUseExternalIds: boolean,\n readonly deferMeta: R3ComponentDeferMetadata,\n readonly allDeferrableDepsFn: o.ReadVarExpr | null,\n ) {\n super(componentName, pool, compatibility);\n this.root = new ViewCompilationUnit(this, this.allocateXrefId(), null);\n this.views.set(this.root.xref, this.root);\n }\n\n override kind = CompilationJobKind.Tmpl;\n\n override readonly fnSuffix: string = 'Template';\n\n /**\n * The root view, representing the component's template.\n */\n override readonly root: ViewCompilationUnit;\n\n readonly views = new Map();\n\n /**\n * Causes ngContentSelectors to be emitted, for content projection slots in the view. Possibly a\n * reference into the constant pool.\n */\n public contentSelectors: o.Expression | null = null;\n\n /**\n * Add a `ViewCompilation` for a new embedded view to this compilation.\n */\n allocateView(parent: ir.XrefId): ViewCompilationUnit {\n const view = new ViewCompilationUnit(this, this.allocateXrefId(), parent);\n this.views.set(view.xref, view);\n return view;\n }\n\n override get units(): Iterable {\n return this.views.values();\n }\n\n /**\n * Add a constant `o.Expression` to the compilation and return its index in the `consts` array.\n */\n addConst(newConst: o.Expression, initializers?: o.Statement[]): ir.ConstIndex {\n for (let idx = 0; idx < this.consts.length; idx++) {\n if (this.consts[idx].isEquivalent(newConst)) {\n return idx as ir.ConstIndex;\n }\n }\n const idx = this.consts.length;\n this.consts.push(newConst);\n if (initializers) {\n this.constsInitializers.push(...initializers);\n }\n return idx as ir.ConstIndex;\n }\n\n /**\n * Constant expressions used by operations within this component's compilation.\n *\n * This will eventually become the `consts` array in the component definition.\n */\n readonly consts: o.Expression[] = [];\n\n /**\n * Initialization statements needed to set up the consts.\n */\n readonly constsInitializers: o.Statement[] = [];\n}\n\n/**\n * A compilation unit is compiled into a template function. Some example units are views and host\n * bindings.\n */\nexport abstract class CompilationUnit {\n constructor(readonly xref: ir.XrefId) {}\n\n /**\n * List of creation operations for this view.\n *\n * Creation operations may internally contain other operations, including update operations.\n */\n readonly create = new ir.OpList();\n\n /**\n * List of update operations for this view.\n */\n readonly update = new ir.OpList();\n\n /**\n * The enclosing job, which might contain several individual compilation units.\n */\n abstract readonly job: CompilationJob;\n\n /**\n * Name of the function which will be generated for this unit.\n *\n * May be `null` if not yet determined.\n */\n fnName: string | null = null;\n\n /**\n * Number of variable slots used within this view, or `null` if variables have not yet been\n * counted.\n */\n vars: number | null = null;\n\n /**\n * Iterate over all `ir.Op`s within this view.\n *\n * Some operations may have child operations, which this iterator will visit.\n */\n *ops(): Generator {\n for (const op of this.create) {\n yield op;\n if (op.kind === ir.OpKind.Listener || op.kind === ir.OpKind.TwoWayListener) {\n for (const listenerOp of op.handlerOps) {\n yield listenerOp;\n }\n }\n }\n for (const op of this.update) {\n yield op;\n }\n }\n}\n\n/**\n * Compilation-in-progress of an individual view within a template.\n */\nexport class ViewCompilationUnit extends CompilationUnit {\n constructor(\n readonly job: ComponentCompilationJob,\n xref: ir.XrefId,\n readonly parent: ir.XrefId | null,\n ) {\n super(xref);\n }\n\n /**\n * Map of declared variables available within this view to the property on the context object\n * which they alias.\n */\n readonly contextVariables = new Map();\n\n /**\n * Set of aliases available within this view. An alias is a variable whose provided expression is\n * inlined at every location it is used. It may also depend on context variables, by name.\n */\n readonly aliases = new Set();\n\n /**\n * Number of declaration slots used within this view, or `null` if slots have not yet been\n * allocated.\n */\n decls: number | null = null;\n}\n\n/**\n * Compilation-in-progress of a host binding, which contains a single unit for that host binding.\n */\nexport class HostBindingCompilationJob extends CompilationJob {\n constructor(componentName: string, pool: ConstantPool, compatibility: ir.CompatibilityMode) {\n super(componentName, pool, compatibility);\n this.root = new HostBindingCompilationUnit(this);\n }\n\n override kind = CompilationJobKind.Host;\n\n override readonly fnSuffix: string = 'HostBindings';\n\n override readonly root: HostBindingCompilationUnit;\n\n override get units(): Iterable {\n return [this.root];\n }\n}\n\nexport class HostBindingCompilationUnit extends CompilationUnit {\n constructor(readonly job: HostBindingCompilationJob) {\n super(0 as ir.XrefId);\n }\n\n /**\n * Much like an element can have attributes, so can a host binding function.\n */\n attributes: o.LiteralArrayExpr | null = null;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\n/**\n * Find any function calls to `$any`, excluding `this.$any`, and delete them, since they have no\n * runtime effects.\n */\nexport function deleteAnyCasts(job: CompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.ops()) {\n ir.transformExpressionsInOp(op, removeAnys, ir.VisitorContextFlag.None);\n }\n }\n}\n\nfunction removeAnys(e: o.Expression): o.Expression {\n if (\n e instanceof o.InvokeFunctionExpr &&\n e.fn instanceof ir.LexicalReadExpr &&\n e.fn.name === '$any'\n ) {\n if (e.args.length !== 1) {\n throw new Error('The $any builtin function expects exactly one argument.');\n }\n return e.args[0];\n }\n return e;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\n/**\n * Adds apply operations after i18n expressions.\n */\nexport function applyI18nExpressions(job: CompilationJob): void {\n const i18nContexts = new Map();\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind === ir.OpKind.I18nContext) {\n i18nContexts.set(op.xref, op);\n }\n }\n }\n\n for (const unit of job.units) {\n for (const op of unit.update) {\n // Only add apply after expressions that are not followed by more expressions.\n if (op.kind === ir.OpKind.I18nExpression && needsApplication(i18nContexts, op)) {\n // TODO: what should be the source span for the apply op?\n ir.OpList.insertAfter(\n ir.createI18nApplyOp(op.i18nOwner, op.handle, null!),\n op,\n );\n }\n }\n }\n}\n\n/**\n * Checks whether the given expression op needs to be followed with an apply op.\n */\nfunction needsApplication(i18nContexts: Map, op: ir.I18nExpressionOp) {\n // If the next op is not another expression, we need to apply.\n if (op.next?.kind !== ir.OpKind.I18nExpression) {\n return true;\n }\n\n const context = i18nContexts.get(op.context);\n const nextContext = i18nContexts.get(op.next.context);\n\n if (context === undefined) {\n throw new Error(\n \"AssertionError: expected an I18nContextOp to exist for the I18nExpressionOp's context\",\n );\n }\n\n if (nextContext === undefined) {\n throw new Error(\n \"AssertionError: expected an I18nContextOp to exist for the next I18nExpressionOp's context\",\n );\n }\n\n // If the next op is an expression targeting a different i18n block (or different element, in the\n // case of i18n attributes), we need to apply.\n\n // First, handle the case of i18n blocks.\n if (context.i18nBlock !== null) {\n // This is a block context. Compare the blocks.\n if (context.i18nBlock !== nextContext.i18nBlock) {\n return true;\n }\n return false;\n }\n\n // Second, handle the case of i18n attributes.\n if (op.i18nOwner !== op.next.i18nOwner) {\n return true;\n }\n return false;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\ninterface BlockState {\n blockXref: ir.XrefId;\n lastSlotConsumer: ir.XrefId;\n}\n\n/**\n * Updates i18n expression ops to target the last slot in their owning i18n block, and moves them\n * after the last update instruction that depends on that slot.\n */\nexport function assignI18nSlotDependencies(job: CompilationJob) {\n for (const unit of job.units) {\n // The first update op.\n let updateOp = unit.update.head;\n\n // I18n expressions currently being moved during the iteration.\n let i18nExpressionsInProgress: ir.I18nExpressionOp[] = [];\n\n // Non-null while we are iterating through an i18nStart/i18nEnd pair\n let state: BlockState | null = null;\n\n for (const createOp of unit.create) {\n if (createOp.kind === ir.OpKind.I18nStart) {\n state = {\n blockXref: createOp.xref,\n lastSlotConsumer: createOp.xref,\n };\n } else if (createOp.kind === ir.OpKind.I18nEnd) {\n for (const op of i18nExpressionsInProgress) {\n op.target = state!.lastSlotConsumer;\n ir.OpList.insertBefore(op as ir.UpdateOp, updateOp!);\n }\n i18nExpressionsInProgress.length = 0;\n state = null;\n }\n\n if (ir.hasConsumesSlotTrait(createOp)) {\n if (state !== null) {\n state.lastSlotConsumer = createOp.xref;\n }\n\n while (true) {\n if (updateOp.next === null) {\n break;\n }\n\n if (\n state !== null &&\n updateOp.kind === ir.OpKind.I18nExpression &&\n updateOp.usage === ir.I18nExpressionFor.I18nText &&\n updateOp.i18nOwner === state.blockXref\n ) {\n const opToRemove = updateOp;\n updateOp = updateOp.next!;\n ir.OpList.remove(opToRemove);\n i18nExpressionsInProgress.push(opToRemove);\n continue;\n }\n\n if (ir.hasDependsOnSlotContextTrait(updateOp) && updateOp.target !== createOp.xref) {\n break;\n }\n\n updateOp = updateOp.next!;\n }\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport type {CompilationUnit} from '../compilation';\n\n/**\n * Gets a map of all elements in the given view by their xref id.\n */\nexport function createOpXrefMap(\n unit: CompilationUnit,\n): Map {\n const map = new Map();\n for (const op of unit.create) {\n if (!ir.hasConsumesSlotTrait(op)) {\n continue;\n }\n map.set(op.xref, op);\n\n // TODO(dylhunn): `@for` loops with `@empty` blocks need to be special-cased here,\n // because the slot consumer trait currently only supports one slot per consumer and we\n // need two. This should be revisited when making the refactors mentioned in:\n // https://github.com/angular/angular/pull/53620#discussion_r1430918822\n if (op.kind === ir.OpKind.RepeaterCreate && op.emptyView !== null) {\n map.set(op.emptyView, op);\n }\n }\n return map;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '../../../../core';\nimport * as ir from '../../ir';\nimport {CompilationJobKind, type CompilationJob, type CompilationUnit} from '../compilation';\nimport {createOpXrefMap} from '../util/elements';\n\n/**\n * Find all extractable attribute and binding ops, and create ExtractedAttributeOps for them.\n * In cases where no instruction needs to be generated for the attribute or binding, it is removed.\n */\nexport function extractAttributes(job: CompilationJob): void {\n for (const unit of job.units) {\n const elements = createOpXrefMap(unit);\n for (const op of unit.ops()) {\n switch (op.kind) {\n case ir.OpKind.Attribute:\n extractAttributeOp(unit, op, elements);\n break;\n case ir.OpKind.Property:\n if (!op.isAnimationTrigger) {\n let bindingKind: ir.BindingKind;\n if (op.i18nMessage !== null && op.templateKind === null) {\n // If the binding has an i18n context, it is an i18n attribute, and should have that\n // kind in the consts array.\n bindingKind = ir.BindingKind.I18n;\n } else if (op.isStructuralTemplateAttribute) {\n bindingKind = ir.BindingKind.Template;\n } else {\n bindingKind = ir.BindingKind.Property;\n }\n\n ir.OpList.insertBefore(\n // Deliberately null i18nMessage value\n ir.createExtractedAttributeOp(\n op.target,\n bindingKind,\n null,\n op.name,\n /* expression */ null,\n /* i18nContext */ null,\n /* i18nMessage */ null,\n op.securityContext,\n ),\n lookupElement(elements, op.target),\n );\n }\n break;\n case ir.OpKind.TwoWayProperty:\n ir.OpList.insertBefore(\n ir.createExtractedAttributeOp(\n op.target,\n ir.BindingKind.TwoWayProperty,\n null,\n op.name,\n /* expression */ null,\n /* i18nContext */ null,\n /* i18nMessage */ null,\n op.securityContext,\n ),\n lookupElement(elements, op.target),\n );\n break;\n case ir.OpKind.StyleProp:\n case ir.OpKind.ClassProp:\n // TODO: Can style or class bindings be i18n attributes?\n\n // The old compiler treated empty style bindings as regular bindings for the purpose of\n // directive matching. That behavior is incorrect, but we emulate it in compatibility\n // mode.\n if (\n unit.job.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder &&\n op.expression instanceof ir.EmptyExpr\n ) {\n ir.OpList.insertBefore(\n ir.createExtractedAttributeOp(\n op.target,\n ir.BindingKind.Property,\n null,\n op.name,\n /* expression */ null,\n /* i18nContext */ null,\n /* i18nMessage */ null,\n SecurityContext.STYLE,\n ),\n lookupElement(elements, op.target),\n );\n }\n break;\n case ir.OpKind.Listener:\n if (!op.isAnimationListener) {\n const extractedAttributeOp = ir.createExtractedAttributeOp(\n op.target,\n ir.BindingKind.Property,\n null,\n op.name,\n /* expression */ null,\n /* i18nContext */ null,\n /* i18nMessage */ null,\n SecurityContext.NONE,\n );\n if (job.kind === CompilationJobKind.Host) {\n if (job.compatibility) {\n // TemplateDefinitionBuilder does not extract listener bindings to the const array\n // (which is honestly pretty inconsistent).\n break;\n }\n // This attribute will apply to the enclosing host binding compilation unit, so order\n // doesn't matter.\n unit.create.push(extractedAttributeOp);\n } else {\n ir.OpList.insertBefore(\n extractedAttributeOp,\n lookupElement(elements, op.target),\n );\n }\n }\n break;\n case ir.OpKind.TwoWayListener:\n // Two-way listeners aren't supported in host bindings.\n if (job.kind !== CompilationJobKind.Host) {\n const extractedAttributeOp = ir.createExtractedAttributeOp(\n op.target,\n ir.BindingKind.Property,\n null,\n op.name,\n /* expression */ null,\n /* i18nContext */ null,\n /* i18nMessage */ null,\n SecurityContext.NONE,\n );\n ir.OpList.insertBefore(\n extractedAttributeOp,\n lookupElement(elements, op.target),\n );\n }\n break;\n }\n }\n }\n}\n\n/**\n * Looks up an element in the given map by xref ID.\n */\nfunction lookupElement(\n elements: Map,\n xref: ir.XrefId,\n): ir.ConsumesSlotOpTrait & ir.CreateOp {\n const el = elements.get(xref);\n if (el === undefined) {\n throw new Error('All attributes should have an element-like target.');\n }\n return el;\n}\n\n/**\n * Extracts an attribute binding.\n */\nfunction extractAttributeOp(\n unit: CompilationUnit,\n op: ir.AttributeOp,\n elements: Map,\n) {\n if (op.expression instanceof ir.Interpolation) {\n return;\n }\n\n let extractable = op.isTextAttribute || op.expression.isConstant();\n if (unit.job.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder) {\n // TemplateDefinitionBuilder only extracts text attributes. It does not extract attriibute\n // bindings, even if they are constants.\n extractable &&= op.isTextAttribute;\n }\n\n if (extractable) {\n const extractedAttributeOp = ir.createExtractedAttributeOp(\n op.target,\n op.isStructuralTemplateAttribute ? ir.BindingKind.Template : ir.BindingKind.Attribute,\n op.namespace,\n op.name,\n op.expression,\n op.i18nContext,\n op.i18nMessage,\n op.securityContext,\n );\n if (unit.job.kind === CompilationJobKind.Host) {\n // This attribute will apply to the enclosing host binding compilation unit, so order doesn't\n // matter.\n unit.create.push(extractedAttributeOp);\n } else {\n const ownerOp = lookupElement(elements, op.target);\n ir.OpList.insertBefore(extractedAttributeOp, ownerOp);\n }\n ir.OpList.remove(op);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {splitNsName} from '../../../../ml_parser/tags';\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport {CompilationJob, CompilationJobKind} from '../compilation';\n\n/**\n * Looks up an element in the given map by xref ID.\n */\nfunction lookupElement(\n elements: Map,\n xref: ir.XrefId,\n): ir.ElementOrContainerOps {\n const el = elements.get(xref);\n if (el === undefined) {\n throw new Error('All attributes should have an element-like target.');\n }\n return el;\n}\n\nexport function specializeBindings(job: CompilationJob): void {\n const elements = new Map();\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (!ir.isElementOrContainerOp(op)) {\n continue;\n }\n elements.set(op.xref, op);\n }\n }\n\n for (const unit of job.units) {\n for (const op of unit.ops()) {\n if (op.kind !== ir.OpKind.Binding) {\n continue;\n }\n switch (op.bindingKind) {\n case ir.BindingKind.Attribute:\n if (op.name === 'ngNonBindable') {\n ir.OpList.remove(op);\n const target = lookupElement(elements, op.target);\n target.nonBindable = true;\n } else {\n const [namespace, name] = splitNsName(op.name);\n ir.OpList.replace(\n op,\n ir.createAttributeOp(\n op.target,\n namespace,\n name,\n op.expression,\n op.securityContext,\n op.isTextAttribute,\n op.isStructuralTemplateAttribute,\n op.templateKind,\n op.i18nMessage,\n op.sourceSpan,\n ),\n );\n }\n break;\n case ir.BindingKind.Property:\n case ir.BindingKind.Animation:\n if (job.kind === CompilationJobKind.Host) {\n ir.OpList.replace(\n op,\n ir.createHostPropertyOp(\n op.name,\n op.expression,\n op.bindingKind === ir.BindingKind.Animation,\n op.i18nContext,\n op.securityContext,\n op.sourceSpan,\n ),\n );\n } else {\n ir.OpList.replace(\n op,\n ir.createPropertyOp(\n op.target,\n op.name,\n op.expression,\n op.bindingKind === ir.BindingKind.Animation,\n op.securityContext,\n op.isStructuralTemplateAttribute,\n op.templateKind,\n op.i18nContext,\n op.i18nMessage,\n op.sourceSpan,\n ),\n );\n }\n\n break;\n case ir.BindingKind.TwoWayProperty:\n if (!(op.expression instanceof o.Expression)) {\n // We shouldn't be able to hit this code path since interpolations in two-way bindings\n // result in a parser error. We assert here so that downstream we can assume that\n // the value is always an expression.\n throw new Error(\n `Expected value of two-way property binding \"${op.name}\" to be an expression`,\n );\n }\n\n ir.OpList.replace(\n op,\n ir.createTwoWayPropertyOp(\n op.target,\n op.name,\n op.expression,\n op.securityContext,\n op.isStructuralTemplateAttribute,\n op.templateKind,\n op.i18nContext,\n op.i18nMessage,\n op.sourceSpan,\n ),\n );\n break;\n case ir.BindingKind.I18n:\n case ir.BindingKind.ClassName:\n case ir.BindingKind.StyleProperty:\n throw new Error(`Unhandled binding of kind ${ir.BindingKind[op.bindingKind]}`);\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport {Identifiers as R3} from '../../../../render3/r3_identifiers';\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\nconst CHAINABLE = new Set([\n R3.attribute,\n R3.classProp,\n R3.element,\n R3.elementContainer,\n R3.elementContainerEnd,\n R3.elementContainerStart,\n R3.elementEnd,\n R3.elementStart,\n R3.hostProperty,\n R3.i18nExp,\n R3.listener,\n R3.listener,\n R3.property,\n R3.styleProp,\n R3.stylePropInterpolate1,\n R3.stylePropInterpolate2,\n R3.stylePropInterpolate3,\n R3.stylePropInterpolate4,\n R3.stylePropInterpolate5,\n R3.stylePropInterpolate6,\n R3.stylePropInterpolate7,\n R3.stylePropInterpolate8,\n R3.stylePropInterpolateV,\n R3.syntheticHostListener,\n R3.syntheticHostProperty,\n R3.templateCreate,\n R3.twoWayProperty,\n R3.twoWayListener,\n R3.declareLet,\n]);\n\n/**\n * Chaining results in repeated call expressions, causing a deep AST of receiver expressions. To prevent running out of\n * stack depth the maximum number of chained instructions is limited to this threshold, which has been selected\n * arbitrarily.\n */\nconst MAX_CHAIN_LENGTH = 256;\n\n/**\n * Post-process a reified view compilation and convert sequential calls to chainable instructions\n * into chain calls.\n *\n * For example, two `elementStart` operations in sequence:\n *\n * ```typescript\n * elementStart(0, 'div');\n * elementStart(1, 'span');\n * ```\n *\n * Can be called as a chain instead:\n *\n * ```typescript\n * elementStart(0, 'div')(1, 'span');\n * ```\n */\nexport function chain(job: CompilationJob): void {\n for (const unit of job.units) {\n chainOperationsInList(unit.create);\n chainOperationsInList(unit.update);\n }\n}\n\nfunction chainOperationsInList(opList: ir.OpList): void {\n let chain: Chain | null = null;\n for (const op of opList) {\n if (op.kind !== ir.OpKind.Statement || !(op.statement instanceof o.ExpressionStatement)) {\n // This type of statement isn't chainable.\n chain = null;\n continue;\n }\n if (\n !(op.statement.expr instanceof o.InvokeFunctionExpr) ||\n !(op.statement.expr.fn instanceof o.ExternalExpr)\n ) {\n // This is a statement, but not an instruction-type call, so not chainable.\n chain = null;\n continue;\n }\n\n const instruction = op.statement.expr.fn.value;\n if (!CHAINABLE.has(instruction)) {\n // This instruction isn't chainable.\n chain = null;\n continue;\n }\n\n // This instruction can be chained. It can either be added on to the previous chain (if\n // compatible) or it can be the start of a new chain.\n if (chain !== null && chain.instruction === instruction && chain.length < MAX_CHAIN_LENGTH) {\n // This instruction can be added onto the previous chain.\n const expression = chain.expression.callFn(\n op.statement.expr.args,\n op.statement.expr.sourceSpan,\n op.statement.expr.pure,\n );\n chain.expression = expression;\n chain.op.statement = expression.toStmt();\n chain.length++;\n ir.OpList.remove(op as ir.Op);\n } else {\n // Leave this instruction alone for now, but consider it the start of a new chain.\n chain = {\n op,\n instruction,\n expression: op.statement.expr,\n length: 1,\n };\n }\n }\n}\n\n/**\n * Structure representing an in-progress chain.\n */\ninterface Chain {\n /**\n * The statement which holds the entire chain.\n */\n op: ir.StatementOp;\n\n /**\n * The expression representing the whole current chained call.\n *\n * This should be the same as `op.statement.expression`, but is extracted here for convenience\n * since the `op` type doesn't capture the fact that `op.statement` is an `o.ExpressionStatement`.\n */\n expression: o.Expression;\n\n /**\n * The instruction that is being chained.\n */\n instruction: o.ExternalReference;\n\n /**\n * The number of instructions that have been collected into this chain.\n */\n length: number;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\n/**\n * Attribute interpolations of the form `[attr.foo]=\"{{foo}}\"\"` should be \"collapsed\" into a plain\n * attribute instruction, instead of an `attributeInterpolate` instruction.\n *\n * (We cannot do this for singleton property interpolations, because `propertyInterpolate`\n * stringifies its expression.)\n *\n * The reification step is also capable of performing this transformation, but doing it early in the\n * pipeline allows other phases to accurately know what instruction will be emitted.\n */\nexport function collapseSingletonInterpolations(job: CompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.update) {\n const eligibleOpKind = op.kind === ir.OpKind.Attribute;\n if (\n eligibleOpKind &&\n op.expression instanceof ir.Interpolation &&\n op.expression.strings.length === 2 &&\n op.expression.strings.every((s: string) => s === '')\n ) {\n op.expression = op.expression.expressions[0];\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport {ComponentCompilationJob} from '../compilation';\n\n/**\n * Collapse the various conditions of conditional ops (if, switch) into a single test expression.\n */\nexport function generateConditionalExpressions(job: ComponentCompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.ops()) {\n if (op.kind !== ir.OpKind.Conditional) {\n continue;\n }\n\n let test: o.Expression;\n\n // Any case with a `null` condition is `default`. If one exists, default to it instead.\n const defaultCase = op.conditions.findIndex((cond) => cond.expr === null);\n if (defaultCase >= 0) {\n const slot = op.conditions.splice(defaultCase, 1)[0].targetSlot;\n test = new ir.SlotLiteralExpr(slot);\n } else {\n // By default, a switch evaluates to `-1`, causing no template to be displayed.\n test = o.literal(-1);\n }\n\n // Switch expressions assign their main test to a temporary, to avoid re-executing it.\n let tmp = op.test == null ? null : new ir.AssignTemporaryExpr(op.test, job.allocateXrefId());\n\n // For each remaining condition, test whether the temporary satifies the check. (If no temp is\n // present, just check each expression directly.)\n for (let i = op.conditions.length - 1; i >= 0; i--) {\n let conditionalCase = op.conditions[i];\n if (conditionalCase.expr === null) {\n continue;\n }\n if (tmp !== null) {\n const useTmp = i === 0 ? tmp : new ir.ReadTemporaryExpr(tmp.xref);\n conditionalCase.expr = new o.BinaryOperatorExpr(\n o.BinaryOperator.Identical,\n useTmp,\n conditionalCase.expr,\n );\n } else if (conditionalCase.alias !== null) {\n const caseExpressionTemporaryXref = job.allocateXrefId();\n conditionalCase.expr = new ir.AssignTemporaryExpr(\n conditionalCase.expr,\n caseExpressionTemporaryXref,\n );\n op.contextValue = new ir.ReadTemporaryExpr(caseExpressionTemporaryXref);\n }\n test = new o.ConditionalExpr(\n conditionalCase.expr,\n new ir.SlotLiteralExpr(conditionalCase.targetSlot),\n test,\n );\n }\n\n // Save the resulting aggregate Joost-expression.\n op.processed = test;\n\n // Clear the original conditions array, since we no longer need it, and don't want it to\n // affect subsequent phases (e.g. pipe creation).\n op.conditions = [];\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../output/output_ast';\nimport * as ir from '../ir';\n\nexport const BINARY_OPERATORS = new Map([\n ['&&', o.BinaryOperator.And],\n ['>', o.BinaryOperator.Bigger],\n ['>=', o.BinaryOperator.BiggerEquals],\n ['|', o.BinaryOperator.BitwiseOr],\n ['&', o.BinaryOperator.BitwiseAnd],\n ['/', o.BinaryOperator.Divide],\n ['==', o.BinaryOperator.Equals],\n ['===', o.BinaryOperator.Identical],\n ['<', o.BinaryOperator.Lower],\n ['<=', o.BinaryOperator.LowerEquals],\n ['-', o.BinaryOperator.Minus],\n ['%', o.BinaryOperator.Modulo],\n ['*', o.BinaryOperator.Multiply],\n ['!=', o.BinaryOperator.NotEquals],\n ['!==', o.BinaryOperator.NotIdentical],\n ['??', o.BinaryOperator.NullishCoalesce],\n ['||', o.BinaryOperator.Or],\n ['+', o.BinaryOperator.Plus],\n]);\n\nexport function namespaceForKey(namespacePrefixKey: string | null): ir.Namespace {\n const NAMESPACES = new Map([\n ['svg', ir.Namespace.SVG],\n ['math', ir.Namespace.Math],\n ]);\n if (namespacePrefixKey === null) {\n return ir.Namespace.HTML;\n }\n return NAMESPACES.get(namespacePrefixKey) ?? ir.Namespace.HTML;\n}\n\nexport function keyForNamespace(namespace: ir.Namespace): string | null {\n const NAMESPACES = new Map([\n ['svg', ir.Namespace.SVG],\n ['math', ir.Namespace.Math],\n ]);\n for (const [k, n] of NAMESPACES.entries()) {\n if (n === namespace) {\n return k;\n }\n }\n return null; // No namespace prefix for HTML\n}\n\nexport function prefixWithNamespace(strippedTag: string, namespace: ir.Namespace): string {\n if (namespace === ir.Namespace.HTML) {\n return strippedTag;\n }\n return `:${keyForNamespace(namespace)}:${strippedTag}`;\n}\n\nexport type LiteralType = string | number | boolean | null | Array;\n\nexport function literalOrArrayLiteral(value: LiteralType): o.Expression {\n if (Array.isArray(value)) {\n return o.literalArr(value.map(literalOrArrayLiteral));\n }\n return o.literal(value);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as core from '../../../../core';\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\n\nimport {\n ComponentCompilationJob,\n HostBindingCompilationJob,\n type CompilationJob,\n} from '../compilation';\nimport {literalOrArrayLiteral} from '../conversion';\n\n/**\n * Converts the semantic attributes of element-like operations (elements, templates) into constant\n * array expressions, and lifts them into the overall component `consts`.\n */\nexport function collectElementConsts(job: CompilationJob): void {\n // Collect all extracted attributes.\n const allElementAttributes = new Map();\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind === ir.OpKind.ExtractedAttribute) {\n const attributes =\n allElementAttributes.get(op.target) || new ElementAttributes(job.compatibility);\n allElementAttributes.set(op.target, attributes);\n attributes.add(op.bindingKind, op.name, op.expression, op.namespace, op.trustedValueFn);\n ir.OpList.remove(op);\n }\n }\n }\n\n // Serialize the extracted attributes into the const array.\n if (job instanceof ComponentCompilationJob) {\n for (const unit of job.units) {\n for (const op of unit.create) {\n // TODO: Simplify and combine these cases.\n if (op.kind == ir.OpKind.Projection) {\n const attributes = allElementAttributes.get(op.xref);\n if (attributes !== undefined) {\n const attrArray = serializeAttributes(attributes);\n if (attrArray.entries.length > 0) {\n op.attributes = attrArray;\n }\n }\n } else if (ir.isElementOrContainerOp(op)) {\n op.attributes = getConstIndex(job, allElementAttributes, op.xref);\n\n // TODO(dylhunn): `@for` loops with `@empty` blocks need to be special-cased here,\n // because the slot consumer trait currently only supports one slot per consumer and we\n // need two. This should be revisited when making the refactors mentioned in:\n // https://github.com/angular/angular/pull/53620#discussion_r1430918822\n if (op.kind === ir.OpKind.RepeaterCreate && op.emptyView !== null) {\n op.emptyAttributes = getConstIndex(job, allElementAttributes, op.emptyView);\n }\n }\n }\n }\n } else if (job instanceof HostBindingCompilationJob) {\n // TODO: If the host binding case further diverges, we may want to split it into its own\n // phase.\n for (const [xref, attributes] of allElementAttributes.entries()) {\n if (xref !== job.root.xref) {\n throw new Error(\n `An attribute would be const collected into the host binding's template function, but is not associated with the root xref.`,\n );\n }\n const attrArray = serializeAttributes(attributes);\n if (attrArray.entries.length > 0) {\n job.root.attributes = attrArray;\n }\n }\n }\n}\n\nfunction getConstIndex(\n job: ComponentCompilationJob,\n allElementAttributes: Map,\n xref: ir.XrefId,\n): ir.ConstIndex | null {\n const attributes = allElementAttributes.get(xref);\n if (attributes !== undefined) {\n const attrArray = serializeAttributes(attributes);\n if (attrArray.entries.length > 0) {\n return job.addConst(attrArray);\n }\n }\n return null;\n}\n\n/**\n * Shared instance of an empty array to avoid unnecessary array allocations.\n */\nconst FLYWEIGHT_ARRAY: ReadonlyArray = Object.freeze([]);\n\n/**\n * Container for all of the various kinds of attributes which are applied on an element.\n */\nclass ElementAttributes {\n private known = new Map>();\n private byKind = new Map<\n // Property bindings are excluded here, because they need to be tracked in the same\n // array to maintain their order. They're tracked in the `propertyBindings` array.\n Exclude,\n o.Expression[]\n >();\n private propertyBindings: o.Expression[] | null = null;\n\n projectAs: string | null = null;\n\n get attributes(): ReadonlyArray {\n return this.byKind.get(ir.BindingKind.Attribute) ?? FLYWEIGHT_ARRAY;\n }\n\n get classes(): ReadonlyArray {\n return this.byKind.get(ir.BindingKind.ClassName) ?? FLYWEIGHT_ARRAY;\n }\n\n get styles(): ReadonlyArray {\n return this.byKind.get(ir.BindingKind.StyleProperty) ?? FLYWEIGHT_ARRAY;\n }\n\n get bindings(): ReadonlyArray {\n return this.propertyBindings ?? FLYWEIGHT_ARRAY;\n }\n\n get template(): ReadonlyArray {\n return this.byKind.get(ir.BindingKind.Template) ?? FLYWEIGHT_ARRAY;\n }\n\n get i18n(): ReadonlyArray {\n return this.byKind.get(ir.BindingKind.I18n) ?? FLYWEIGHT_ARRAY;\n }\n\n constructor(private compatibility: ir.CompatibilityMode) {}\n\n private isKnown(kind: ir.BindingKind, name: string) {\n const nameToValue = this.known.get(kind) ?? new Set();\n this.known.set(kind, nameToValue);\n if (nameToValue.has(name)) {\n return true;\n }\n nameToValue.add(name);\n return false;\n }\n\n add(\n kind: ir.BindingKind,\n name: string,\n value: o.Expression | null,\n namespace: string | null,\n trustedValueFn: o.Expression | null,\n ): void {\n // TemplateDefinitionBuilder puts duplicate attribute, class, and style values into the consts\n // array. This seems inefficient, we can probably keep just the first one or the last value\n // (whichever actually gets applied when multiple values are listed for the same attribute).\n const allowDuplicates =\n this.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder &&\n (kind === ir.BindingKind.Attribute ||\n kind === ir.BindingKind.ClassName ||\n kind === ir.BindingKind.StyleProperty);\n if (!allowDuplicates && this.isKnown(kind, name)) {\n return;\n }\n\n // TODO: Can this be its own phase\n if (name === 'ngProjectAs') {\n if (\n value === null ||\n !(value instanceof o.LiteralExpr) ||\n value.value == null ||\n typeof value.value?.toString() !== 'string'\n ) {\n throw Error('ngProjectAs must have a string literal value');\n }\n this.projectAs = value.value.toString();\n // TODO: TemplateDefinitionBuilder allows `ngProjectAs` to also be assigned as a literal\n // attribute. Is this sane?\n }\n\n const array = this.arrayFor(kind);\n array.push(...getAttributeNameLiterals(namespace, name));\n if (kind === ir.BindingKind.Attribute || kind === ir.BindingKind.StyleProperty) {\n if (value === null) {\n throw Error('Attribute, i18n attribute, & style element attributes must have a value');\n }\n if (trustedValueFn !== null) {\n if (!ir.isStringLiteral(value)) {\n throw Error('AssertionError: extracted attribute value should be string literal');\n }\n array.push(\n o.taggedTemplate(\n trustedValueFn,\n new o.TemplateLiteral([new o.TemplateLiteralElement(value.value)], []),\n undefined,\n value.sourceSpan,\n ),\n );\n } else {\n array.push(value);\n }\n }\n }\n\n private arrayFor(kind: ir.BindingKind): o.Expression[] {\n if (kind === ir.BindingKind.Property || kind === ir.BindingKind.TwoWayProperty) {\n this.propertyBindings ??= [];\n return this.propertyBindings;\n } else {\n if (!this.byKind.has(kind)) {\n this.byKind.set(kind, []);\n }\n return this.byKind.get(kind)!;\n }\n }\n}\n\n/**\n * Gets an array of literal expressions representing the attribute's namespaced name.\n */\nfunction getAttributeNameLiterals(namespace: string | null, name: string): o.LiteralExpr[] {\n const nameLiteral = o.literal(name);\n\n if (namespace) {\n return [o.literal(core.AttributeMarker.NamespaceURI), o.literal(namespace), nameLiteral];\n }\n\n return [nameLiteral];\n}\n\n/**\n * Serializes an ElementAttributes object into an array expression.\n */\nfunction serializeAttributes({\n attributes,\n bindings,\n classes,\n i18n,\n projectAs,\n styles,\n template,\n}: ElementAttributes): o.LiteralArrayExpr {\n const attrArray = [...attributes];\n\n if (projectAs !== null) {\n // Parse the attribute value into a CssSelectorList. Note that we only take the\n // first selector, because we don't support multiple selectors in ngProjectAs.\n const parsedR3Selector = core.parseSelectorToR3Selector(projectAs)[0];\n attrArray.push(\n o.literal(core.AttributeMarker.ProjectAs),\n literalOrArrayLiteral(parsedR3Selector),\n );\n }\n if (classes.length > 0) {\n attrArray.push(o.literal(core.AttributeMarker.Classes), ...classes);\n }\n if (styles.length > 0) {\n attrArray.push(o.literal(core.AttributeMarker.Styles), ...styles);\n }\n if (bindings.length > 0) {\n attrArray.push(o.literal(core.AttributeMarker.Bindings), ...bindings);\n }\n if (template.length > 0) {\n attrArray.push(o.literal(core.AttributeMarker.Template), ...template);\n }\n if (i18n.length > 0) {\n attrArray.push(o.literal(core.AttributeMarker.I18n), ...i18n);\n }\n return o.literalArr(attrArray);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\n/**\n * Some binding instructions in the update block may actually correspond to i18n bindings. In that\n * case, they should be replaced with i18nExp instructions for the dynamic portions.\n */\nexport function convertI18nBindings(job: CompilationJob): void {\n const i18nAttributesByElem: Map = new Map();\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind === ir.OpKind.I18nAttributes) {\n i18nAttributesByElem.set(op.target, op);\n }\n }\n\n for (const op of unit.update) {\n switch (op.kind) {\n case ir.OpKind.Property:\n case ir.OpKind.Attribute:\n if (op.i18nContext === null) {\n continue;\n }\n\n if (!(op.expression instanceof ir.Interpolation)) {\n continue;\n }\n\n const i18nAttributesForElem = i18nAttributesByElem.get(op.target);\n if (i18nAttributesForElem === undefined) {\n throw new Error(\n 'AssertionError: An i18n attribute binding instruction requires the owning element to have an I18nAttributes create instruction',\n );\n }\n\n if (i18nAttributesForElem.target !== op.target) {\n throw new Error(\n 'AssertionError: Expected i18nAttributes target element to match binding target element',\n );\n }\n\n const ops: ir.UpdateOp[] = [];\n for (let i = 0; i < op.expression.expressions.length; i++) {\n const expr = op.expression.expressions[i];\n\n if (op.expression.i18nPlaceholders.length !== op.expression.expressions.length) {\n throw new Error(\n `AssertionError: An i18n attribute binding instruction requires the same number of expressions and placeholders, but found ${op.expression.i18nPlaceholders.length} placeholders and ${op.expression.expressions.length} expressions`,\n );\n }\n\n ops.push(\n ir.createI18nExpressionOp(\n op.i18nContext,\n i18nAttributesForElem.target,\n i18nAttributesForElem.xref,\n i18nAttributesForElem.handle,\n expr,\n null,\n op.expression.i18nPlaceholders[i],\n ir.I18nParamResolutionTime.Creation,\n ir.I18nExpressionFor.I18nAttribute,\n op.name,\n op.sourceSpan,\n ),\n );\n }\n ir.OpList.replaceWithMany(op as ir.UpdateOp, ops);\n break;\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport {ComponentCompilationJob} from '../compilation';\n\n/**\n * Resolve the dependency function of a deferred block.\n */\nexport function resolveDeferDepsFns(job: ComponentCompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind === ir.OpKind.Defer) {\n if (op.resolverFn !== null) {\n continue;\n }\n\n if (op.ownResolverFn !== null) {\n if (op.handle.slot === null) {\n throw new Error(\n 'AssertionError: slot must be assigned before extracting defer deps functions',\n );\n }\n const fullPathName = unit.fnName?.replace('_Template', '');\n op.resolverFn = job.pool.getSharedFunctionReference(\n op.ownResolverFn,\n `${fullPathName}_Defer_${op.handle.slot}_DepsFn`,\n /* Don't use unique names for TDB compatibility */ false,\n );\n }\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as i18n from '../../../../i18n/i18n_ast';\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\n/**\n * Create one helper context op per i18n block (including generate descending blocks).\n *\n * Also, if an ICU exists inside an i18n block that also contains other localizable content (such as\n * string), create an additional helper context op for the ICU.\n *\n * These context ops are later used for generating i18n messages. (Although we generate at least one\n * context op per nested view, we will collect them up the tree later, to generate a top-level\n * message.)\n */\nexport function createI18nContexts(job: CompilationJob) {\n // Create i18n context ops for i18n attrs.\n const attrContextByMessage = new Map();\n for (const unit of job.units) {\n for (const op of unit.ops()) {\n switch (op.kind) {\n case ir.OpKind.Binding:\n case ir.OpKind.Property:\n case ir.OpKind.Attribute:\n case ir.OpKind.ExtractedAttribute:\n if (op.i18nMessage === null) {\n continue;\n }\n if (!attrContextByMessage.has(op.i18nMessage)) {\n const i18nContext = ir.createI18nContextOp(\n ir.I18nContextKind.Attr,\n job.allocateXrefId(),\n null,\n op.i18nMessage,\n null!,\n );\n unit.create.push(i18nContext);\n attrContextByMessage.set(op.i18nMessage, i18nContext.xref);\n }\n op.i18nContext = attrContextByMessage.get(op.i18nMessage)!;\n break;\n }\n }\n }\n\n // Create i18n context ops for root i18n blocks.\n const blockContextByI18nBlock = new Map();\n for (const unit of job.units) {\n for (const op of unit.create) {\n switch (op.kind) {\n case ir.OpKind.I18nStart:\n if (op.xref === op.root) {\n const contextOp = ir.createI18nContextOp(\n ir.I18nContextKind.RootI18n,\n job.allocateXrefId(),\n op.xref,\n op.message,\n null!,\n );\n unit.create.push(contextOp);\n op.context = contextOp.xref;\n blockContextByI18nBlock.set(op.xref, contextOp);\n }\n break;\n }\n }\n }\n\n // Assign i18n contexts for child i18n blocks. These don't need their own conext, instead they\n // should inherit from their root i18n block.\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind === ir.OpKind.I18nStart && op.xref !== op.root) {\n const rootContext = blockContextByI18nBlock.get(op.root);\n if (rootContext === undefined) {\n throw Error('AssertionError: Root i18n block i18n context should have been created.');\n }\n op.context = rootContext.xref;\n blockContextByI18nBlock.set(op.xref, rootContext);\n }\n }\n }\n\n // Create or assign i18n contexts for ICUs.\n let currentI18nOp: ir.I18nStartOp | null = null;\n for (const unit of job.units) {\n for (const op of unit.create) {\n switch (op.kind) {\n case ir.OpKind.I18nStart:\n currentI18nOp = op;\n break;\n case ir.OpKind.I18nEnd:\n currentI18nOp = null;\n break;\n case ir.OpKind.IcuStart:\n if (currentI18nOp === null) {\n throw Error('AssertionError: Unexpected ICU outside of an i18n block.');\n }\n if (op.message.id !== currentI18nOp.message.id) {\n // This ICU is a sub-message inside its parent i18n block message. We need to give it\n // its own context.\n const contextOp = ir.createI18nContextOp(\n ir.I18nContextKind.Icu,\n job.allocateXrefId(),\n currentI18nOp.root,\n op.message,\n null!,\n );\n unit.create.push(contextOp);\n op.context = contextOp.xref;\n } else {\n // This ICU is the only translatable content in its parent i18n block. We need to\n // convert the parent's context into an ICU context.\n op.context = currentI18nOp.context;\n blockContextByI18nBlock.get(currentI18nOp.xref)!.contextKind = ir.I18nContextKind.Icu;\n }\n break;\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport type {CompilationJob} from '../compilation';\n\n/**\n * Deduplicate text bindings, e.g.
\n */\nexport function deduplicateTextBindings(job: CompilationJob): void {\n const seen = new Map>();\n for (const unit of job.units) {\n for (const op of unit.update.reversed()) {\n if (op.kind === ir.OpKind.Binding && op.isTextAttribute) {\n const seenForElement = seen.get(op.target) || new Set();\n if (seenForElement.has(op.name)) {\n if (job.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder) {\n // For most duplicated attributes, TemplateDefinitionBuilder lists all of the values in\n // the consts array. However, for style and class attributes it only keeps the last one.\n // We replicate that behavior here since it has actual consequences for apps with\n // duplicate class or style attrs.\n if (op.name === 'style' || op.name === 'class') {\n ir.OpList.remove(op);\n }\n } else {\n // TODO: Determine the correct behavior. It would probably make sense to merge multiple\n // style and class attributes. Alternatively we could just throw an error, as HTML\n // doesn't permit duplicate attributes.\n }\n }\n seenForElement.add(op.name);\n seen.set(op.target, seenForElement);\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport type {ComponentCompilationJob} from '../compilation';\nimport {literalOrArrayLiteral} from '../conversion';\n\n/**\n * Defer instructions take a configuration array, which should be collected into the component\n * consts. This phase finds the config options, and creates the corresponding const array.\n */\nexport function configureDeferInstructions(job: ComponentCompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind !== ir.OpKind.Defer) {\n continue;\n }\n\n if (op.placeholderMinimumTime !== null) {\n op.placeholderConfig = new ir.ConstCollectedExpr(\n literalOrArrayLiteral([op.placeholderMinimumTime]),\n );\n }\n if (op.loadingMinimumTime !== null || op.loadingAfterTime !== null) {\n op.loadingConfig = new ir.ConstCollectedExpr(\n literalOrArrayLiteral([op.loadingMinimumTime, op.loadingAfterTime]),\n );\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport type {ComponentCompilationJob, ViewCompilationUnit} from '../compilation';\n\n/**\n * Some `defer` conditions can reference other elements in the template, using their local reference\n * names. However, the semantics are quite different from the normal local reference system: in\n * particular, we need to look at local reference names in enclosing views. This phase resolves\n * all such references to actual xrefs.\n */\nexport function resolveDeferTargetNames(job: ComponentCompilationJob): void {\n const scopes = new Map();\n\n function getScopeForView(view: ViewCompilationUnit): Scope {\n if (scopes.has(view.xref)) {\n return scopes.get(view.xref)!;\n }\n\n const scope = new Scope();\n for (const op of view.create) {\n // add everything that can be referenced.\n if (!ir.isElementOrContainerOp(op) || op.localRefs === null) {\n continue;\n }\n if (!Array.isArray(op.localRefs)) {\n throw new Error(\n 'LocalRefs were already processed, but were needed to resolve defer targets.',\n );\n }\n\n for (const ref of op.localRefs) {\n if (ref.target !== '') {\n continue;\n }\n scope.targets.set(ref.name, {xref: op.xref, slot: op.handle});\n }\n }\n\n scopes.set(view.xref, scope);\n return scope;\n }\n\n function resolveTrigger(\n deferOwnerView: ViewCompilationUnit,\n op: ir.DeferOnOp,\n placeholderView: ir.XrefId | null,\n ): void {\n switch (op.trigger.kind) {\n case ir.DeferTriggerKind.Idle:\n case ir.DeferTriggerKind.Immediate:\n case ir.DeferTriggerKind.Timer:\n return;\n case ir.DeferTriggerKind.Hover:\n case ir.DeferTriggerKind.Interaction:\n case ir.DeferTriggerKind.Viewport:\n if (op.trigger.targetName === null) {\n // A `null` target name indicates we should default to the first element in the\n // placeholder block.\n if (placeholderView === null) {\n throw new Error('defer on trigger with no target name must have a placeholder block');\n }\n const placeholder = job.views.get(placeholderView);\n if (placeholder == undefined) {\n throw new Error('AssertionError: could not find placeholder view for defer on trigger');\n }\n for (const placeholderOp of placeholder.create) {\n if (\n ir.hasConsumesSlotTrait(placeholderOp) &&\n (ir.isElementOrContainerOp(placeholderOp) ||\n placeholderOp.kind === ir.OpKind.Projection)\n ) {\n op.trigger.targetXref = placeholderOp.xref;\n op.trigger.targetView = placeholderView;\n op.trigger.targetSlotViewSteps = -1;\n op.trigger.targetSlot = placeholderOp.handle;\n return;\n }\n }\n return;\n }\n let view: ViewCompilationUnit | null =\n placeholderView !== null ? job.views.get(placeholderView)! : deferOwnerView;\n let step = placeholderView !== null ? -1 : 0;\n\n while (view !== null) {\n const scope = getScopeForView(view);\n if (scope.targets.has(op.trigger.targetName)) {\n const {xref, slot} = scope.targets.get(op.trigger.targetName)!;\n\n op.trigger.targetXref = xref;\n op.trigger.targetView = view.xref;\n op.trigger.targetSlotViewSteps = step;\n op.trigger.targetSlot = slot;\n return;\n }\n\n view = view.parent !== null ? job.views.get(view.parent)! : null;\n step++;\n }\n break;\n default:\n throw new Error(`Trigger kind ${(op.trigger as any).kind} not handled`);\n }\n }\n\n // Find the defer ops, and assign the data about their targets.\n for (const unit of job.units) {\n const defers = new Map();\n for (const op of unit.create) {\n switch (op.kind) {\n case ir.OpKind.Defer:\n defers.set(op.xref, op);\n break;\n case ir.OpKind.DeferOn:\n const deferOp = defers.get(op.defer)!;\n resolveTrigger(unit, op, deferOp.placeholderView);\n break;\n }\n }\n }\n}\n\nclass Scope {\n targets = new Map();\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport type {CompilationJob} from '../compilation';\n\nconst REPLACEMENTS = new Map([\n [ir.OpKind.ElementEnd, [ir.OpKind.ElementStart, ir.OpKind.Element]],\n [ir.OpKind.ContainerEnd, [ir.OpKind.ContainerStart, ir.OpKind.Container]],\n [ir.OpKind.I18nEnd, [ir.OpKind.I18nStart, ir.OpKind.I18n]],\n]);\n\n/**\n * Op kinds that should not prevent merging of start/end ops.\n */\nconst IGNORED_OP_KINDS = new Set([ir.OpKind.Pipe]);\n\n/**\n * Replace sequences of mergable instructions (e.g. `ElementStart` and `ElementEnd`) with a\n * consolidated instruction (e.g. `Element`).\n */\nexport function collapseEmptyInstructions(job: CompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.create) {\n // Find end ops that may be able to be merged.\n const opReplacements = REPLACEMENTS.get(op.kind);\n if (opReplacements === undefined) {\n continue;\n }\n const [startKind, mergedKind] = opReplacements;\n\n // Locate the previous (non-ignored) op.\n let prevOp: ir.CreateOp | null = op.prev;\n while (prevOp !== null && IGNORED_OP_KINDS.has(prevOp.kind)) {\n prevOp = prevOp.prev;\n }\n\n // If the previous op is the corresponding start op, we can megre.\n if (prevOp !== null && prevOp.kind === startKind) {\n // Transmute the start instruction to the merged version. This is safe as they're designed\n // to be identical apart from the `kind`.\n (prevOp as ir.Op).kind = mergedKind;\n\n // Remove the end instruction.\n ir.OpList.remove(op);\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\ninterface SafeTransformContext {\n job: CompilationJob;\n}\n\n/**\n * Safe read expressions such as `a?.b` have different semantics in Angular templates as\n * compared to JavaScript. In particular, they default to `null` instead of `undefined`. This phase\n * finds all unresolved safe read expressions, and converts them into the appropriate output AST\n * reads, guarded by null checks. We generate temporaries as needed, to avoid re-evaluating the same\n * sub-expression multiple times.\n */\nexport function expandSafeReads(job: CompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.ops()) {\n ir.transformExpressionsInOp(op, (e) => safeTransform(e, {job}), ir.VisitorContextFlag.None);\n ir.transformExpressionsInOp(op, ternaryTransform, ir.VisitorContextFlag.None);\n }\n }\n}\n\n// A lookup set of all the expression kinds that require a temporary variable to be generated.\nconst requiresTemporary = [\n o.InvokeFunctionExpr,\n o.LiteralArrayExpr,\n o.LiteralMapExpr,\n ir.SafeInvokeFunctionExpr,\n ir.PipeBindingExpr,\n].map((e) => e.constructor.name);\n\nfunction needsTemporaryInSafeAccess(e: o.Expression): boolean {\n // TODO: We probably want to use an expression visitor to recursively visit all descendents.\n // However, that would potentially do a lot of extra work (because it cannot short circuit), so we\n // implement the logic ourselves for now.\n if (e instanceof o.UnaryOperatorExpr) {\n return needsTemporaryInSafeAccess(e.expr);\n } else if (e instanceof o.BinaryOperatorExpr) {\n return needsTemporaryInSafeAccess(e.lhs) || needsTemporaryInSafeAccess(e.rhs);\n } else if (e instanceof o.ConditionalExpr) {\n if (e.falseCase && needsTemporaryInSafeAccess(e.falseCase)) return true;\n return needsTemporaryInSafeAccess(e.condition) || needsTemporaryInSafeAccess(e.trueCase);\n } else if (e instanceof o.NotExpr) {\n return needsTemporaryInSafeAccess(e.condition);\n } else if (e instanceof ir.AssignTemporaryExpr) {\n return needsTemporaryInSafeAccess(e.expr);\n } else if (e instanceof o.ReadPropExpr) {\n return needsTemporaryInSafeAccess(e.receiver);\n } else if (e instanceof o.ReadKeyExpr) {\n return needsTemporaryInSafeAccess(e.receiver) || needsTemporaryInSafeAccess(e.index);\n }\n // TODO: Switch to a method which is exhaustive of newly added expression subtypes.\n return (\n e instanceof o.InvokeFunctionExpr ||\n e instanceof o.LiteralArrayExpr ||\n e instanceof o.LiteralMapExpr ||\n e instanceof ir.SafeInvokeFunctionExpr ||\n e instanceof ir.PipeBindingExpr\n );\n}\n\nfunction temporariesIn(e: o.Expression): Set {\n const temporaries = new Set();\n // TODO: Although it's not currently supported by the transform helper, we should be able to\n // short-circuit exploring the tree to do less work. In particular, we don't have to penetrate\n // into the subexpressions of temporary assignments.\n ir.transformExpressionsInExpression(\n e,\n (e) => {\n if (e instanceof ir.AssignTemporaryExpr) {\n temporaries.add(e.xref);\n }\n return e;\n },\n ir.VisitorContextFlag.None,\n );\n return temporaries;\n}\n\nfunction eliminateTemporaryAssignments(\n e: o.Expression,\n tmps: Set,\n ctx: SafeTransformContext,\n): o.Expression {\n // TODO: We can be more efficient than the transform helper here. We don't need to visit any\n // descendents of temporary assignments.\n ir.transformExpressionsInExpression(\n e,\n (e) => {\n if (e instanceof ir.AssignTemporaryExpr && tmps.has(e.xref)) {\n const read = new ir.ReadTemporaryExpr(e.xref);\n // `TemplateDefinitionBuilder` has the (accidental?) behavior of generating assignments of\n // temporary variables to themselves. This happens because some subexpression that the\n // temporary refers to, possibly through nested temporaries, has a function call. We copy that\n // behavior here.\n return ctx.job.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder\n ? new ir.AssignTemporaryExpr(read, read.xref)\n : read;\n }\n return e;\n },\n ir.VisitorContextFlag.None,\n );\n return e;\n}\n\n/**\n * Creates a safe ternary guarded by the input expression, and with a body generated by the provided\n * callback on the input expression. Generates a temporary variable assignment if needed, and\n * deduplicates nested temporary assignments if needed.\n */\nfunction safeTernaryWithTemporary(\n guard: o.Expression,\n body: (e: o.Expression) => o.Expression,\n ctx: SafeTransformContext,\n): ir.SafeTernaryExpr {\n let result: [o.Expression, o.Expression];\n if (needsTemporaryInSafeAccess(guard)) {\n const xref = ctx.job.allocateXrefId();\n result = [new ir.AssignTemporaryExpr(guard, xref), new ir.ReadTemporaryExpr(xref)];\n } else {\n result = [guard, guard.clone()];\n // Consider an expression like `a?.[b?.c()]?.d`. The `b?.c()` will be transformed first,\n // introducing a temporary assignment into the key. Then, as part of expanding the `?.d`. That\n // assignment will be duplicated into both the guard and expression sides. We de-duplicate it,\n // by transforming it from an assignment into a read on the expression side.\n eliminateTemporaryAssignments(result[1], temporariesIn(result[0]), ctx);\n }\n return new ir.SafeTernaryExpr(result[0], body(result[1]));\n}\n\nfunction isSafeAccessExpression(\n e: o.Expression,\n): e is ir.SafePropertyReadExpr | ir.SafeKeyedReadExpr | ir.SafeInvokeFunctionExpr {\n return (\n e instanceof ir.SafePropertyReadExpr ||\n e instanceof ir.SafeKeyedReadExpr ||\n e instanceof ir.SafeInvokeFunctionExpr\n );\n}\n\nfunction isUnsafeAccessExpression(\n e: o.Expression,\n): e is o.ReadPropExpr | o.ReadKeyExpr | o.InvokeFunctionExpr {\n return (\n e instanceof o.ReadPropExpr || e instanceof o.ReadKeyExpr || e instanceof o.InvokeFunctionExpr\n );\n}\n\nfunction isAccessExpression(\n e: o.Expression,\n): e is\n | o.ReadPropExpr\n | ir.SafePropertyReadExpr\n | o.ReadKeyExpr\n | ir.SafeKeyedReadExpr\n | o.InvokeFunctionExpr\n | ir.SafeInvokeFunctionExpr {\n return isSafeAccessExpression(e) || isUnsafeAccessExpression(e);\n}\n\nfunction deepestSafeTernary(e: o.Expression): ir.SafeTernaryExpr | null {\n if (isAccessExpression(e) && e.receiver instanceof ir.SafeTernaryExpr) {\n let st = e.receiver;\n while (st.expr instanceof ir.SafeTernaryExpr) {\n st = st.expr;\n }\n return st;\n }\n return null;\n}\n\n// TODO: When strict compatibility with TemplateDefinitionBuilder is not required, we can use `&&`\n// instead to save some code size.\nfunction safeTransform(e: o.Expression, ctx: SafeTransformContext): o.Expression {\n if (!isAccessExpression(e)) {\n return e;\n }\n\n const dst = deepestSafeTernary(e);\n\n if (dst) {\n if (e instanceof o.InvokeFunctionExpr) {\n dst.expr = dst.expr.callFn(e.args);\n return e.receiver;\n }\n if (e instanceof o.ReadPropExpr) {\n dst.expr = dst.expr.prop(e.name);\n return e.receiver;\n }\n if (e instanceof o.ReadKeyExpr) {\n dst.expr = dst.expr.key(e.index);\n return e.receiver;\n }\n if (e instanceof ir.SafeInvokeFunctionExpr) {\n dst.expr = safeTernaryWithTemporary(dst.expr, (r: o.Expression) => r.callFn(e.args), ctx);\n return e.receiver;\n }\n if (e instanceof ir.SafePropertyReadExpr) {\n dst.expr = safeTernaryWithTemporary(dst.expr, (r: o.Expression) => r.prop(e.name), ctx);\n return e.receiver;\n }\n if (e instanceof ir.SafeKeyedReadExpr) {\n dst.expr = safeTernaryWithTemporary(dst.expr, (r: o.Expression) => r.key(e.index), ctx);\n return e.receiver;\n }\n } else {\n if (e instanceof ir.SafeInvokeFunctionExpr) {\n return safeTernaryWithTemporary(e.receiver, (r: o.Expression) => r.callFn(e.args), ctx);\n }\n if (e instanceof ir.SafePropertyReadExpr) {\n return safeTernaryWithTemporary(e.receiver, (r: o.Expression) => r.prop(e.name), ctx);\n }\n if (e instanceof ir.SafeKeyedReadExpr) {\n return safeTernaryWithTemporary(e.receiver, (r: o.Expression) => r.key(e.index), ctx);\n }\n }\n\n return e;\n}\n\nfunction ternaryTransform(e: o.Expression): o.Expression {\n if (!(e instanceof ir.SafeTernaryExpr)) {\n return e;\n }\n return new o.ConditionalExpr(\n new o.BinaryOperatorExpr(o.BinaryOperator.Equals, e.guard, o.NULL_EXPR),\n o.NULL_EXPR,\n e.expr,\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport {CompilationJob} from '../compilation';\n\n/**\n * The escape sequence used indicate message param values.\n */\nconst ESCAPE = '\\uFFFD';\n\n/**\n * Marker used to indicate an element tag.\n */\nconst ELEMENT_MARKER = '#';\n\n/**\n * Marker used to indicate a template tag.\n */\nconst TEMPLATE_MARKER = '*';\n\n/**\n * Marker used to indicate closing of an element or template tag.\n */\nconst TAG_CLOSE_MARKER = '/';\n\n/**\n * Marker used to indicate the sub-template context.\n */\nconst CONTEXT_MARKER = ':';\n\n/**\n * Marker used to indicate the start of a list of values.\n */\nconst LIST_START_MARKER = '[';\n\n/**\n * Marker used to indicate the end of a list of values.\n */\nconst LIST_END_MARKER = ']';\n\n/**\n * Delimiter used to separate multiple values in a list.\n */\nconst LIST_DELIMITER = '|';\n\n/**\n * Formats the param maps on extracted message ops into a maps of `Expression` objects that can be\n * used in the final output.\n */\nexport function extractI18nMessages(job: CompilationJob): void {\n // Create an i18n message for each context.\n // TODO: Merge the context op with the message op since they're 1:1 anyways.\n const i18nMessagesByContext = new Map();\n const i18nBlocks = new Map();\n const i18nContexts = new Map();\n for (const unit of job.units) {\n for (const op of unit.create) {\n switch (op.kind) {\n case ir.OpKind.I18nContext:\n const i18nMessageOp = createI18nMessage(job, op);\n unit.create.push(i18nMessageOp);\n i18nMessagesByContext.set(op.xref, i18nMessageOp);\n i18nContexts.set(op.xref, op);\n break;\n case ir.OpKind.I18nStart:\n i18nBlocks.set(op.xref, op);\n break;\n }\n }\n }\n\n // Associate sub-messages for ICUs with their root message. At this point we can also remove the\n // ICU start/end ops, as they are no longer needed.\n let currentIcu: ir.IcuStartOp | null = null;\n for (const unit of job.units) {\n for (const op of unit.create) {\n switch (op.kind) {\n case ir.OpKind.IcuStart:\n currentIcu = op;\n ir.OpList.remove(op);\n // Skip any contexts not associated with an ICU.\n const icuContext = i18nContexts.get(op.context!)!;\n if (icuContext.contextKind !== ir.I18nContextKind.Icu) {\n continue;\n }\n // Skip ICUs that share a context with their i18n message. These represent root-level\n // ICUs, not sub-messages.\n const i18nBlock = i18nBlocks.get(icuContext.i18nBlock!)!;\n if (i18nBlock.context === icuContext.xref) {\n continue;\n }\n // Find the root message and push this ICUs message as a sub-message.\n const rootI18nBlock = i18nBlocks.get(i18nBlock.root)!;\n const rootMessage = i18nMessagesByContext.get(rootI18nBlock.context!);\n if (rootMessage === undefined) {\n throw Error('AssertionError: ICU sub-message should belong to a root message.');\n }\n const subMessage = i18nMessagesByContext.get(icuContext.xref)!;\n subMessage.messagePlaceholder = op.messagePlaceholder;\n rootMessage.subMessages.push(subMessage.xref);\n break;\n case ir.OpKind.IcuEnd:\n currentIcu = null;\n ir.OpList.remove(op);\n break;\n case ir.OpKind.IcuPlaceholder:\n // Add ICU placeholders to the message, then remove the ICU placeholder ops.\n if (currentIcu === null || currentIcu.context == null) {\n throw Error('AssertionError: Unexpected ICU placeholder outside of i18n context');\n }\n const msg = i18nMessagesByContext.get(currentIcu.context)!;\n msg.postprocessingParams.set(op.name, o.literal(formatIcuPlaceholder(op)));\n ir.OpList.remove(op);\n break;\n }\n }\n }\n}\n\n/**\n * Create an i18n message op from an i18n context op.\n */\nfunction createI18nMessage(\n job: CompilationJob,\n context: ir.I18nContextOp,\n messagePlaceholder?: string,\n): ir.I18nMessageOp {\n let formattedParams = formatParams(context.params);\n const formattedPostprocessingParams = formatParams(context.postprocessingParams);\n let needsPostprocessing = [...context.params.values()].some((v) => v.length > 1);\n return ir.createI18nMessageOp(\n job.allocateXrefId(),\n context.xref,\n context.i18nBlock,\n context.message,\n messagePlaceholder ?? null,\n formattedParams,\n formattedPostprocessingParams,\n needsPostprocessing,\n );\n}\n\n/**\n * Formats an ICU placeholder into a single string with expression placeholders.\n */\nfunction formatIcuPlaceholder(op: ir.IcuPlaceholderOp) {\n if (op.strings.length !== op.expressionPlaceholders.length + 1) {\n throw Error(\n `AssertionError: Invalid ICU placeholder with ${op.strings.length} strings and ${op.expressionPlaceholders.length} expressions`,\n );\n }\n const values = op.expressionPlaceholders.map(formatValue);\n return op.strings.flatMap((str, i) => [str, values[i] || '']).join('');\n}\n\n/**\n * Formats a map of `I18nParamValue[]` values into a map of `Expression` values.\n */\nfunction formatParams(params: Map) {\n const formattedParams = new Map();\n for (const [placeholder, placeholderValues] of params) {\n const serializedValues = formatParamValues(placeholderValues);\n if (serializedValues !== null) {\n formattedParams.set(placeholder, o.literal(serializedValues));\n }\n }\n return formattedParams;\n}\n\n/**\n * Formats an `I18nParamValue[]` into a string (or null for empty array).\n */\nfunction formatParamValues(values: ir.I18nParamValue[]): string | null {\n if (values.length === 0) {\n return null;\n }\n const serializedValues = values.map((value) => formatValue(value));\n return serializedValues.length === 1\n ? serializedValues[0]\n : `${LIST_START_MARKER}${serializedValues.join(LIST_DELIMITER)}${LIST_END_MARKER}`;\n}\n\n/**\n * Formats a single `I18nParamValue` into a string\n */\nfunction formatValue(value: ir.I18nParamValue): string {\n // Element tags with a structural directive use a special form that concatenates the element and\n // template values.\n if (\n value.flags & ir.I18nParamValueFlags.ElementTag &&\n value.flags & ir.I18nParamValueFlags.TemplateTag\n ) {\n if (typeof value.value !== 'object') {\n throw Error('AssertionError: Expected i18n param value to have an element and template slot');\n }\n const elementValue = formatValue({\n ...value,\n value: value.value.element,\n flags: value.flags & ~ir.I18nParamValueFlags.TemplateTag,\n });\n const templateValue = formatValue({\n ...value,\n value: value.value.template,\n flags: value.flags & ~ir.I18nParamValueFlags.ElementTag,\n });\n // TODO(mmalerba): This is likely a bug in TemplateDefinitionBuilder, we should not need to\n // record the template value twice. For now I'm re-implementing the behavior here to keep the\n // output consistent with TemplateDefinitionBuilder.\n if (\n value.flags & ir.I18nParamValueFlags.OpenTag &&\n value.flags & ir.I18nParamValueFlags.CloseTag\n ) {\n return `${templateValue}${elementValue}${templateValue}`;\n }\n // To match the TemplateDefinitionBuilder output, flip the order depending on whether the\n // values represent a closing or opening tag (or both).\n // TODO(mmalerba): Figure out if this makes a difference in terms of either functionality,\n // or the resulting message ID. If not, we can remove the special-casing in the future.\n return value.flags & ir.I18nParamValueFlags.CloseTag\n ? `${elementValue}${templateValue}`\n : `${templateValue}${elementValue}`;\n }\n\n // Self-closing tags use a special form that concatenates the start and close tag values.\n if (\n value.flags & ir.I18nParamValueFlags.OpenTag &&\n value.flags & ir.I18nParamValueFlags.CloseTag\n ) {\n return `${formatValue({...value, flags: value.flags & ~ir.I18nParamValueFlags.CloseTag})}${formatValue(\n {...value, flags: value.flags & ~ir.I18nParamValueFlags.OpenTag},\n )}`;\n }\n\n // If there are no special flags, just return the raw value.\n if (value.flags === ir.I18nParamValueFlags.None) {\n return `${value.value}`;\n }\n\n // Encode the remaining flags as part of the value.\n let tagMarker = '';\n let closeMarker = '';\n if (value.flags & ir.I18nParamValueFlags.ElementTag) {\n tagMarker = ELEMENT_MARKER;\n } else if (value.flags & ir.I18nParamValueFlags.TemplateTag) {\n tagMarker = TEMPLATE_MARKER;\n }\n if (tagMarker !== '') {\n closeMarker = value.flags & ir.I18nParamValueFlags.CloseTag ? TAG_CLOSE_MARKER : '';\n }\n const context =\n value.subTemplateIndex === null ? '' : `${CONTEXT_MARKER}${value.subTemplateIndex}`;\n return `${ESCAPE}${closeMarker}${tagMarker}${value.value}${context}${ESCAPE}`;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\nimport type {CompilationJob} from '../compilation';\n\n/**\n * Generate `ir.AdvanceOp`s in between `ir.UpdateOp`s that ensure the runtime's implicit slot\n * context will be advanced correctly.\n */\nexport function generateAdvance(job: CompilationJob): void {\n for (const unit of job.units) {\n // First build a map of all of the declarations in the view that have assigned slots.\n const slotMap = new Map();\n for (const op of unit.create) {\n if (!ir.hasConsumesSlotTrait(op)) {\n continue;\n } else if (op.handle.slot === null) {\n throw new Error(\n `AssertionError: expected slots to have been allocated before generating advance() calls`,\n );\n }\n\n slotMap.set(op.xref, op.handle.slot);\n }\n\n // Next, step through the update operations and generate `ir.AdvanceOp`s as required to ensure\n // the runtime's implicit slot counter will be set to the correct slot before executing each\n // update operation which depends on it.\n //\n // To do that, we track what the runtime's slot counter will be through the update operations.\n let slotContext = 0;\n for (const op of unit.update) {\n let consumer: ir.DependsOnSlotContextOpTrait | null = null;\n\n if (ir.hasDependsOnSlotContextTrait(op)) {\n consumer = op;\n } else {\n ir.visitExpressionsInOp(op, (expr) => {\n if (consumer === null && ir.hasDependsOnSlotContextTrait(expr)) {\n consumer = expr;\n }\n });\n }\n\n if (consumer === null) {\n continue;\n }\n\n if (!slotMap.has(consumer.target)) {\n // We expect ops that _do_ depend on the slot counter to point at declarations that exist in\n // the `slotMap`.\n throw new Error(`AssertionError: reference to unknown slot for target ${consumer.target}`);\n }\n\n const slot = slotMap.get(consumer.target)!;\n\n // Does the slot counter need to be adjusted?\n if (slotContext !== slot) {\n // If so, generate an `ir.AdvanceOp` to advance the counter.\n const delta = slot - slotContext;\n if (delta < 0) {\n throw new Error(`AssertionError: slot counter should never need to move backwards`);\n }\n\n ir.OpList.insertBefore(ir.createAdvanceOp(delta, consumer.sourceSpan), op);\n slotContext = slot;\n }\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {parseSelectorToR3Selector} from '../../../../core';\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport type {ComponentCompilationJob} from '../compilation';\nimport {literalOrArrayLiteral} from '../conversion';\n\n/**\n * Locate projection slots, populate the each component's `ngContentSelectors` literal field,\n * populate `project` arguments, and generate the required `projectionDef` instruction for the job's\n * root view.\n */\nexport function generateProjectionDefs(job: ComponentCompilationJob): void {\n // TODO: Why does TemplateDefinitionBuilder force a shared constant?\n const share = job.compatibility === ir.CompatibilityMode.TemplateDefinitionBuilder;\n\n // Collect all selectors from this component, and its nested views. Also, assign each projection a\n // unique ascending projection slot index.\n const selectors = [];\n let projectionSlotIndex = 0;\n for (const unit of job.units) {\n for (const op of unit.create) {\n if (op.kind === ir.OpKind.Projection) {\n selectors.push(op.selector);\n op.projectionSlotIndex = projectionSlotIndex++;\n }\n }\n }\n\n if (selectors.length > 0) {\n // Create the projectionDef array. If we only found a single wildcard selector, then we use the\n // default behavior with no arguments instead.\n let defExpr: o.Expression | null = null;\n if (selectors.length > 1 || selectors[0] !== '*') {\n const def = selectors.map((s) => (s === '*' ? s : parseSelectorToR3Selector(s)));\n defExpr = job.pool.getConstLiteral(literalOrArrayLiteral(def), share);\n }\n\n // Create the ngContentSelectors constant.\n job.contentSelectors = job.pool.getConstLiteral(literalOrArrayLiteral(selectors), share);\n\n // The projection def instruction goes at the beginning of the root view, before any\n // `projection` instructions.\n job.root.create.prepend([ir.createProjectionDefOp(defExpr)]);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\n\nimport type {ComponentCompilationJob, ViewCompilationUnit} from '../compilation';\n\n/**\n * Generate a preamble sequence for each view creation block and listener function which declares\n * any variables that be referenced in other operations in the block.\n *\n * Variables generated include:\n * * a saved view context to be used to restore the current view in event listeners.\n * * the context of the restored view within event listener handlers.\n * * context variables from the current view as well as all parent views (including the root\n * context if needed).\n * * local references from elements within the current view and any lexical parents.\n *\n * Variables are generated here unconditionally, and may optimized away in future operations if it\n * turns out their values (and any side effects) are unused.\n */\nexport function generateVariables(job: ComponentCompilationJob): void {\n recursivelyProcessView(job.root, /* there is no parent scope for the root view */ null);\n}\n\n/**\n * Process the given `ViewCompilation` and generate preambles for it and any listeners that it\n * declares.\n *\n * @param `parentScope` a scope extracted from the parent view which captures any variables which\n * should be inherited by this view. `null` if the current view is the root view.\n */\nfunction recursivelyProcessView(view: ViewCompilationUnit, parentScope: Scope | null): void {\n // Extract a `Scope` from this view.\n const scope = getScopeForView(view, parentScope);\n\n for (const op of view.create) {\n switch (op.kind) {\n case ir.OpKind.Template:\n // Descend into child embedded views.\n recursivelyProcessView(view.job.views.get(op.xref)!, scope);\n break;\n case ir.OpKind.Projection:\n if (op.fallbackView !== null) {\n recursivelyProcessView(view.job.views.get(op.fallbackView)!, scope);\n }\n break;\n case ir.OpKind.RepeaterCreate:\n // Descend into child embedded views.\n recursivelyProcessView(view.job.views.get(op.xref)!, scope);\n if (op.emptyView) {\n recursivelyProcessView(view.job.views.get(op.emptyView)!, scope);\n }\n break;\n case ir.OpKind.Listener:\n case ir.OpKind.TwoWayListener:\n // Prepend variables to listener handler functions.\n op.handlerOps.prepend(generateVariablesInScopeForView(view, scope, true));\n break;\n }\n }\n\n view.update.prepend(generateVariablesInScopeForView(view, scope, false));\n}\n\n/**\n * Lexical scope of a view, including a reference to its parent view's scope, if any.\n */\ninterface Scope {\n /**\n * `XrefId` of the view to which this scope corresponds.\n */\n view: ir.XrefId;\n\n viewContextVariable: ir.SemanticVariable;\n\n contextVariables: Map;\n\n aliases: Set;\n\n /**\n * Local references collected from elements within the view.\n */\n references: Reference[];\n\n /**\n * `@let` declarations collected from the view.\n */\n letDeclarations: LetDeclaration[];\n\n /**\n * `Scope` of the parent view, if any.\n */\n parent: Scope | null;\n}\n\n/**\n * Information needed about a local reference collected from an element within a view.\n */\ninterface Reference {\n /**\n * Name given to the local reference variable within the template.\n *\n * This is not the name which will be used for the variable declaration in the generated\n * template code.\n */\n name: string;\n\n /**\n * `XrefId` of the element-like node which this reference targets.\n *\n * The reference may be either to the element (or template) itself, or to a directive on it.\n */\n targetId: ir.XrefId;\n\n targetSlot: ir.SlotHandle;\n\n /**\n * A generated offset of this reference among all the references on a specific element.\n */\n offset: number;\n\n variable: ir.SemanticVariable;\n}\n\n/**\n * Information about `@let` declaration collected from a view.\n */\ninterface LetDeclaration {\n /** `XrefId` of the `@let` declaration that the reference is pointing to. */\n targetId: ir.XrefId;\n\n /** Slot in which the declaration is stored. */\n targetSlot: ir.SlotHandle;\n\n /** Variable referring to the declaration. */\n variable: ir.IdentifierVariable;\n}\n\n/**\n * Process a view and generate a `Scope` representing the variables available for reference within\n * that view.\n */\nfunction getScopeForView(view: ViewCompilationUnit, parent: Scope | null): Scope {\n const scope: Scope = {\n view: view.xref,\n viewContextVariable: {\n kind: ir.SemanticVariableKind.Context,\n name: null,\n view: view.xref,\n },\n contextVariables: new Map(),\n aliases: view.aliases,\n references: [],\n letDeclarations: [],\n parent,\n };\n\n for (const identifier of view.contextVariables.keys()) {\n scope.contextVariables.set(identifier, {\n kind: ir.SemanticVariableKind.Identifier,\n name: null,\n identifier,\n local: false,\n });\n }\n\n for (const op of view.create) {\n switch (op.kind) {\n case ir.OpKind.ElementStart:\n case ir.OpKind.Template:\n if (!Array.isArray(op.localRefs)) {\n throw new Error(`AssertionError: expected localRefs to be an array`);\n }\n\n // Record available local references from this element.\n for (let offset = 0; offset < op.localRefs.length; offset++) {\n scope.references.push({\n name: op.localRefs[offset].name,\n targetId: op.xref,\n targetSlot: op.handle,\n offset,\n variable: {\n kind: ir.SemanticVariableKind.Identifier,\n name: null,\n identifier: op.localRefs[offset].name,\n local: false,\n },\n });\n }\n break;\n\n case ir.OpKind.DeclareLet:\n scope.letDeclarations.push({\n targetId: op.xref,\n targetSlot: op.handle,\n variable: {\n kind: ir.SemanticVariableKind.Identifier,\n name: null,\n identifier: op.declaredName,\n local: false,\n },\n });\n break;\n }\n }\n\n return scope;\n}\n\n/**\n * Generate declarations for all variables that are in scope for a given view.\n *\n * This is a recursive process, as views inherit variables available from their parent view, which\n * itself may have inherited variables, etc.\n */\nfunction generateVariablesInScopeForView(\n view: ViewCompilationUnit,\n scope: Scope,\n isListener: boolean,\n): ir.VariableOp[] {\n const newOps: ir.VariableOp[] = [];\n\n if (scope.view !== view.xref) {\n // Before generating variables for a parent view, we need to switch to the context of the parent\n // view with a `nextContext` expression. This context switching operation itself declares a\n // variable, because the context of the view may be referenced directly.\n newOps.push(\n ir.createVariableOp(\n view.job.allocateXrefId(),\n scope.viewContextVariable,\n new ir.NextContextExpr(),\n ir.VariableFlags.None,\n ),\n );\n }\n\n // Add variables for all context variables available in this scope's view.\n const scopeView = view.job.views.get(scope.view)!;\n for (const [name, value] of scopeView.contextVariables) {\n const context = new ir.ContextExpr(scope.view);\n // We either read the context, or, if the variable is CTX_REF, use the context directly.\n const variable = value === ir.CTX_REF ? context : new o.ReadPropExpr(context, value);\n // Add the variable declaration.\n newOps.push(\n ir.createVariableOp(\n view.job.allocateXrefId(),\n scope.contextVariables.get(name)!,\n variable,\n ir.VariableFlags.None,\n ),\n );\n }\n\n for (const alias of scopeView.aliases) {\n newOps.push(\n ir.createVariableOp(\n view.job.allocateXrefId(),\n alias,\n alias.expression.clone(),\n ir.VariableFlags.AlwaysInline,\n ),\n );\n }\n\n // Add variables for all local references declared for elements in this scope.\n for (const ref of scope.references) {\n newOps.push(\n ir.createVariableOp(\n view.job.allocateXrefId(),\n ref.variable,\n new ir.ReferenceExpr(ref.targetId, ref.targetSlot, ref.offset),\n ir.VariableFlags.None,\n ),\n );\n }\n\n if (scope.view !== view.xref || isListener) {\n for (const decl of scope.letDeclarations) {\n newOps.push(\n ir.createVariableOp(\n view.job.allocateXrefId(),\n decl.variable,\n new ir.ContextLetReferenceExpr(decl.targetId, decl.targetSlot),\n ir.VariableFlags.None,\n ),\n );\n }\n }\n\n if (scope.parent !== null) {\n // Recursively add variables from the parent scope.\n newOps.push(...generateVariablesInScopeForView(view, scope.parent, false));\n }\n return newOps;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from '../../../../output/output_ast';\nimport * as ir from '../../ir';\nimport type {ComponentCompilationJob} from '../compilation';\n\n/**\n * `ir.ConstCollectedExpr` may be present in any IR expression. This means that expression needs to\n * be lifted into the component const array, and replaced with a reference to the const array at its\n *\n * usage site. This phase walks the IR and performs this transformation.\n */\nexport function collectConstExpressions(job: ComponentCompilationJob): void {\n for (const unit of job.units) {\n for (const op of unit.ops()) {\n ir.transformExpressionsInOp(\n op,\n (expr) => {\n if (!(expr instanceof ir.ConstCollectedExpr)) {\n return expr;\n }\n return o.literal(job.addConst(expr.expr));\n },\n ir.VisitorContextFlag.None,\n );\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as ir from '../../ir';\n\nimport type {CompilationJob} from '../compilation';\n\nconst STYLE_DOT = 'style.';\nconst CLASS_DOT = 'class.';\n\nconst STYLE_BANG = 'style!';\nconst CLASS_BANG = 'class!';\nconst BANG_IMPORTANT = '!important';\n\n/**\n * Host bindings are compiled using a different parser entrypoint, and are parsed quite differently\n * as a result. Therefore, we need to do some extra parsing for host style properties, as compared\n * to non-host style properties.\n * TODO: Unify host bindings and non-host bindings in the parser.\n */\nexport function parseHostStyleProperties(job: CompilationJob): void {\n for (const op of job.root.update) {\n if (!(op.kind === ir.OpKind.Binding && op.bindingKind === ir.BindingKind.Property)) {\n continue;\n }\n\n if (op.name.endsWith(BANG_IMPORTANT)) {\n // Delete any `!important` suffixes from the binding name.\n op.name = op.name.substring(0, op.name.length - BANG_IMPORTANT.length);\n }\n\n if (op.name.startsWith(STYLE_DOT)) {\n op.bindingKind = ir.BindingKind.StyleProperty;\n op.name = op.name.substring(STYLE_DOT.length);\n\n if (!isCssCustomProperty(op.name)) {\n op.name = hyphenate(op.name);\n }\n\n const {property, suffix} = parseProperty(op.name);\n op.name = property;\n op.unit = suffix;\n } else if (op.name.startsWith(STYLE_BANG)) {\n op.bindingKind = ir.BindingKind.StyleProperty;\n op.name = 'style';\n } else if (op.name.startsWith(CLASS_DOT)) {\n op.bindingKind = ir.BindingKind.ClassName;\n op.name = parseProperty(op.name.substring(CLASS_DOT.length)).property;\n } else if (op.name.startsWith(CLASS_BANG)) {\n op.bindingKind = ir.BindingKind.ClassName;\n op.name = parseProperty(op.name.substring(CLASS_BANG.length)).property;\n }\n }\n}\n\n/**\n * Checks whether property name is a custom CSS property.\n * See: https://www.w3.org/TR/css-variables-1\n */\nfunction isCssCustomProperty(name: string): boolean {\n return name.startsWith('--');\n}\n\nfunction hyphenate(value: string): string {\n return value\n .replace(/[a-z][A-Z]/g, (v) => {\n return v.charAt(0) + '-' + v.charAt(1);\n })\n .toLowerCase();\n}\n\nfunction parseProperty(name: string): {property: string; suffix: string | null} {\n const overrideIndex = name.indexOf('!important');\n if (overrideIndex !== -1) {\n name = overrideIndex > 0 ? name.substring(0, overrideIndex) : '';\n }\n\n let suffix: string | null = null;\n let property = name;\n const unitIndex = name.lastIndexOf('.');\n if (unitIndex > 0) {\n suffix = name.slice(unitIndex + 1);\n property = name.substring(0, unitIndex);\n }\n\n return {property, suffix};\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as o from './output_ast';\n\nexport type MapEntry = {\n key: string;\n quoted: boolean;\n value: o.Expression;\n};\n\nexport type MapLiteral = MapEntry[];\n\nexport function mapEntry(key: string, value: o.Expression): MapEntry {\n return {key, value, quoted: false};\n}\n\nexport function mapLiteral(\n obj: {[key: string]: o.Expression},\n quoted: boolean = false,\n): o.Expression {\n return o.literalMap(\n Object.keys(obj).map((key) => ({\n key,\n quoted,\n value: obj[key],\n })),\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as i18n from '../../../i18n/i18n_ast';\n\nimport {formatI18nPlaceholderName} from './util';\n\nclass IcuSerializerVisitor implements i18n.Visitor {\n visitText(text: i18n.Text): any {\n return text.value;\n }\n\n visitContainer(container: i18n.Container): any {\n return container.children.map((child) => child.visit(this)).join('');\n }\n\n visitIcu(icu: i18n.Icu): any {\n const strCases = Object.keys(icu.cases).map(\n (k: string) => `${k} {${icu.cases[k].visit(this)}}`,\n );\n const result = `{${icu.expressionPlaceholder}, ${icu.type}, ${strCases.join(' ')}}`;\n return result;\n }\n\n visitTagPlaceholder(ph: i18n.TagPlaceholder): any {\n return ph.isVoid\n ? this.formatPh(ph.startName)\n : `${this.formatPh(ph.startName)}${ph.children.map((child) => child.visit(this)).join('')}${this.formatPh(\n ph.closeName,\n )}`;\n }\n\n visitPlaceholder(ph: i18n.Placeholder): any {\n return this.formatPh(ph.name);\n }\n\n visitBlockPlaceholder(ph: i18n.BlockPlaceholder): any {\n return `${this.formatPh(ph.startName)}${ph.children.map((child) => child.visit(this)).join('')}${this.formatPh(\n ph.closeName,\n )}`;\n }\n\n visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any {\n return this.formatPh(ph.name);\n }\n\n private formatPh(value: string): string {\n return `{${formatI18nPlaceholderName(value, /* useCamelCase */ false)}}`;\n }\n}\n\nconst serializer = new IcuSerializerVisitor();\nexport function serializeIcuNode(icu: i18n.Icu): string {\n return icu.visit(serializer);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {I18nMeta} from '../i18n/i18n_ast';\nimport {ParseSourceSpan} from '../parse_util';\n\nimport {InterpolatedAttributeToken, InterpolatedTextToken} from './tokens';\n\ninterface BaseNode {\n sourceSpan: ParseSourceSpan;\n visit(visitor: Visitor, context: any): any;\n}\n\nexport type Node =\n | Attribute\n | Comment\n | Element\n | Expansion\n | ExpansionCase\n | Text\n | Block\n | BlockParameter;\n\nexport abstract class NodeWithI18n implements BaseNode {\n constructor(\n public sourceSpan: ParseSourceSpan,\n public i18n?: I18nMeta,\n ) {}\n abstract visit(visitor: Visitor, context: any): any;\n}\n\nexport class Text extends NodeWithI18n {\n constructor(\n public value: string,\n sourceSpan: ParseSourceSpan,\n public tokens: InterpolatedTextToken[],\n i18n?: I18nMeta,\n ) {\n super(sourceSpan, i18n);\n }\n override visit(visitor: Visitor, context: any): any {\n return visitor.visitText(this, context);\n }\n}\n\nexport class Expansion extends NodeWithI18n {\n constructor(\n public switchValue: string,\n public type: string,\n public cases: ExpansionCase[],\n sourceSpan: ParseSourceSpan,\n public switchValueSourceSpan: ParseSourceSpan,\n i18n?: I18nMeta,\n ) {\n super(sourceSpan, i18n);\n }\n override visit(visitor: Visitor, context: any): any {\n return visitor.visitExpansion(this, context);\n }\n}\n\nexport class ExpansionCase implements BaseNode {\n constructor(\n public value: string,\n public expression: Node[],\n public sourceSpan: ParseSourceSpan,\n public valueSourceSpan: ParseSourceSpan,\n public expSourceSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context: any): any {\n return visitor.visitExpansionCase(this, context);\n }\n}\n\nexport class Attribute extends NodeWithI18n {\n constructor(\n public name: string,\n public value: string,\n sourceSpan: ParseSourceSpan,\n readonly keySpan: ParseSourceSpan | undefined,\n public valueSpan: ParseSourceSpan | undefined,\n public valueTokens: InterpolatedAttributeToken[] | undefined,\n i18n: I18nMeta | undefined,\n ) {\n super(sourceSpan, i18n);\n }\n override visit(visitor: Visitor, context: any): any {\n return visitor.visitAttribute(this, context);\n }\n}\n\nexport class Element extends NodeWithI18n {\n constructor(\n public name: string,\n public attrs: Attribute[],\n public children: Node[],\n sourceSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan,\n public endSourceSpan: ParseSourceSpan | null = null,\n i18n?: I18nMeta,\n ) {\n super(sourceSpan, i18n);\n }\n override visit(visitor: Visitor, context: any): any {\n return visitor.visitElement(this, context);\n }\n}\n\nexport class Comment implements BaseNode {\n constructor(\n public value: string | null,\n public sourceSpan: ParseSourceSpan,\n ) {}\n visit(visitor: Visitor, context: any): any {\n return visitor.visitComment(this, context);\n }\n}\n\nexport class Block extends NodeWithI18n {\n constructor(\n public name: string,\n public parameters: BlockParameter[],\n public children: Node[],\n sourceSpan: ParseSourceSpan,\n public nameSpan: ParseSourceSpan,\n public startSourceSpan: ParseSourceSpan,\n public endSourceSpan: ParseSourceSpan | null = null,\n i18n?: I18nMeta,\n ) {\n super(sourceSpan, i18n);\n }\n\n override visit(visitor: Visitor, context: any) {\n return visitor.visitBlock(this, context);\n }\n}\n\nexport class BlockParameter implements BaseNode {\n constructor(\n public expression: string,\n public sourceSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context: any): any {\n return visitor.visitBlockParameter(this, context);\n }\n}\n\nexport class LetDeclaration implements BaseNode {\n constructor(\n public name: string,\n public value: string,\n public sourceSpan: ParseSourceSpan,\n readonly nameSpan: ParseSourceSpan,\n public valueSpan: ParseSourceSpan,\n ) {}\n\n visit(visitor: Visitor, context: any): any {\n return visitor.visitLetDeclaration(this, context);\n }\n}\n\nexport interface Visitor {\n // Returning a truthy value from `visit()` will prevent `visitAll()` from the call to the typed\n // method and result returned will become the result included in `visitAll()`s result array.\n visit?(node: Node, context: any): any;\n\n visitElement(element: Element, context: any): any;\n visitAttribute(attribute: Attribute, context: any): any;\n visitText(text: Text, context: any): any;\n visitComment(comment: Comment, context: any): any;\n visitExpansion(expansion: Expansion, context: any): any;\n visitExpansionCase(expansionCase: ExpansionCase, context: any): any;\n visitBlock(block: Block, context: any): any;\n visitBlockParameter(parameter: BlockParameter, context: any): any;\n visitLetDeclaration(decl: LetDeclaration, context: any): any;\n}\n\nexport function visitAll(visitor: Visitor, nodes: Node[], context: any = null): any[] {\n const result: any[] = [];\n\n const visit = visitor.visit\n ? (ast: Node) => visitor.visit!(ast, context) || ast.visit(visitor, context)\n : (ast: Node) => ast.visit(visitor, context);\n nodes.forEach((ast) => {\n const astResult = visit(ast);\n if (astResult) {\n result.push(astResult);\n }\n });\n return result;\n}\n\nexport class RecursiveVisitor implements Visitor {\n constructor() {}\n\n visitElement(ast: Element, context: any): any {\n this.visitChildren(context, (visit) => {\n visit(ast.attrs);\n visit(ast.children);\n });\n }\n\n visitAttribute(ast: Attribute, context: any): any {}\n visitText(ast: Text, context: any): any {}\n visitComment(ast: Comment, context: any): any {}\n\n visitExpansion(ast: Expansion, context: any): any {\n return this.visitChildren(context, (visit) => {\n visit(ast.cases);\n });\n }\n\n visitExpansionCase(ast: ExpansionCase, context: any): any {}\n\n visitBlock(block: Block, context: any): any {\n this.visitChildren(context, (visit) => {\n visit(block.parameters);\n visit(block.children);\n });\n }\n\n visitBlockParameter(ast: BlockParameter, context: any): any {}\n\n visitLetDeclaration(decl: LetDeclaration, context: any) {}\n\n private visitChildren(\n context: any,\n cb: (visit: (children: V[] | undefined) => void) => void,\n ) {\n let results: any[][] = [];\n let t = this;\n function visit(children: T[] | undefined) {\n if (children) results.push(visitAll(t, children, context));\n }\n cb(visit);\n return Array.prototype.concat.apply([], results);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// Mapping between all HTML entity names and their unicode representation.\n// Generated from https://html.spec.whatwg.org/multipage/entities.json by stripping\n// the `&` and `;` from the keys and removing the duplicates.\n// see https://www.w3.org/TR/html51/syntax.html#named-character-references\nexport const NAMED_ENTITIES: Record = {\n 'AElig': '\\u00C6',\n 'AMP': '\\u0026',\n 'amp': '\\u0026',\n 'Aacute': '\\u00C1',\n 'Abreve': '\\u0102',\n 'Acirc': '\\u00C2',\n 'Acy': '\\u0410',\n 'Afr': '\\uD835\\uDD04',\n 'Agrave': '\\u00C0',\n 'Alpha': '\\u0391',\n 'Amacr': '\\u0100',\n 'And': '\\u2A53',\n 'Aogon': '\\u0104',\n 'Aopf': '\\uD835\\uDD38',\n 'ApplyFunction': '\\u2061',\n 'af': '\\u2061',\n 'Aring': '\\u00C5',\n 'angst': '\\u00C5',\n 'Ascr': '\\uD835\\uDC9C',\n 'Assign': '\\u2254',\n 'colone': '\\u2254',\n 'coloneq': '\\u2254',\n 'Atilde': '\\u00C3',\n 'Auml': '\\u00C4',\n 'Backslash': '\\u2216',\n 'setminus': '\\u2216',\n 'setmn': '\\u2216',\n 'smallsetminus': '\\u2216',\n 'ssetmn': '\\u2216',\n 'Barv': '\\u2AE7',\n 'Barwed': '\\u2306',\n 'doublebarwedge': '\\u2306',\n 'Bcy': '\\u0411',\n 'Because': '\\u2235',\n 'becaus': '\\u2235',\n 'because': '\\u2235',\n 'Bernoullis': '\\u212C',\n 'Bscr': '\\u212C',\n 'bernou': '\\u212C',\n 'Beta': '\\u0392',\n 'Bfr': '\\uD835\\uDD05',\n 'Bopf': '\\uD835\\uDD39',\n 'Breve': '\\u02D8',\n 'breve': '\\u02D8',\n 'Bumpeq': '\\u224E',\n 'HumpDownHump': '\\u224E',\n 'bump': '\\u224E',\n 'CHcy': '\\u0427',\n 'COPY': '\\u00A9',\n 'copy': '\\u00A9',\n 'Cacute': '\\u0106',\n 'Cap': '\\u22D2',\n 'CapitalDifferentialD': '\\u2145',\n 'DD': '\\u2145',\n 'Cayleys': '\\u212D',\n 'Cfr': '\\u212D',\n 'Ccaron': '\\u010C',\n 'Ccedil': '\\u00C7',\n 'Ccirc': '\\u0108',\n 'Cconint': '\\u2230',\n 'Cdot': '\\u010A',\n 'Cedilla': '\\u00B8',\n 'cedil': '\\u00B8',\n 'CenterDot': '\\u00B7',\n 'centerdot': '\\u00B7',\n 'middot': '\\u00B7',\n 'Chi': '\\u03A7',\n 'CircleDot': '\\u2299',\n 'odot': '\\u2299',\n 'CircleMinus': '\\u2296',\n 'ominus': '\\u2296',\n 'CirclePlus': '\\u2295',\n 'oplus': '\\u2295',\n 'CircleTimes': '\\u2297',\n 'otimes': '\\u2297',\n 'ClockwiseContourIntegral': '\\u2232',\n 'cwconint': '\\u2232',\n 'CloseCurlyDoubleQuote': '\\u201D',\n 'rdquo': '\\u201D',\n 'rdquor': '\\u201D',\n 'CloseCurlyQuote': '\\u2019',\n 'rsquo': '\\u2019',\n 'rsquor': '\\u2019',\n 'Colon': '\\u2237',\n 'Proportion': '\\u2237',\n 'Colone': '\\u2A74',\n 'Congruent': '\\u2261',\n 'equiv': '\\u2261',\n 'Conint': '\\u222F',\n 'DoubleContourIntegral': '\\u222F',\n 'ContourIntegral': '\\u222E',\n 'conint': '\\u222E',\n 'oint': '\\u222E',\n 'Copf': '\\u2102',\n 'complexes': '\\u2102',\n 'Coproduct': '\\u2210',\n 'coprod': '\\u2210',\n 'CounterClockwiseContourIntegral': '\\u2233',\n 'awconint': '\\u2233',\n 'Cross': '\\u2A2F',\n 'Cscr': '\\uD835\\uDC9E',\n 'Cup': '\\u22D3',\n 'CupCap': '\\u224D',\n 'asympeq': '\\u224D',\n 'DDotrahd': '\\u2911',\n 'DJcy': '\\u0402',\n 'DScy': '\\u0405',\n 'DZcy': '\\u040F',\n 'Dagger': '\\u2021',\n 'ddagger': '\\u2021',\n 'Darr': '\\u21A1',\n 'Dashv': '\\u2AE4',\n 'DoubleLeftTee': '\\u2AE4',\n 'Dcaron': '\\u010E',\n 'Dcy': '\\u0414',\n 'Del': '\\u2207',\n 'nabla': '\\u2207',\n 'Delta': '\\u0394',\n 'Dfr': '\\uD835\\uDD07',\n 'DiacriticalAcute': '\\u00B4',\n 'acute': '\\u00B4',\n 'DiacriticalDot': '\\u02D9',\n 'dot': '\\u02D9',\n 'DiacriticalDoubleAcute': '\\u02DD',\n 'dblac': '\\u02DD',\n 'DiacriticalGrave': '\\u0060',\n 'grave': '\\u0060',\n 'DiacriticalTilde': '\\u02DC',\n 'tilde': '\\u02DC',\n 'Diamond': '\\u22C4',\n 'diam': '\\u22C4',\n 'diamond': '\\u22C4',\n 'DifferentialD': '\\u2146',\n 'dd': '\\u2146',\n 'Dopf': '\\uD835\\uDD3B',\n 'Dot': '\\u00A8',\n 'DoubleDot': '\\u00A8',\n 'die': '\\u00A8',\n 'uml': '\\u00A8',\n 'DotDot': '\\u20DC',\n 'DotEqual': '\\u2250',\n 'doteq': '\\u2250',\n 'esdot': '\\u2250',\n 'DoubleDownArrow': '\\u21D3',\n 'Downarrow': '\\u21D3',\n 'dArr': '\\u21D3',\n 'DoubleLeftArrow': '\\u21D0',\n 'Leftarrow': '\\u21D0',\n 'lArr': '\\u21D0',\n 'DoubleLeftRightArrow': '\\u21D4',\n 'Leftrightarrow': '\\u21D4',\n 'hArr': '\\u21D4',\n 'iff': '\\u21D4',\n 'DoubleLongLeftArrow': '\\u27F8',\n 'Longleftarrow': '\\u27F8',\n 'xlArr': '\\u27F8',\n 'DoubleLongLeftRightArrow': '\\u27FA',\n 'Longleftrightarrow': '\\u27FA',\n 'xhArr': '\\u27FA',\n 'DoubleLongRightArrow': '\\u27F9',\n 'Longrightarrow': '\\u27F9',\n 'xrArr': '\\u27F9',\n 'DoubleRightArrow': '\\u21D2',\n 'Implies': '\\u21D2',\n 'Rightarrow': '\\u21D2',\n 'rArr': '\\u21D2',\n 'DoubleRightTee': '\\u22A8',\n 'vDash': '\\u22A8',\n 'DoubleUpArrow': '\\u21D1',\n 'Uparrow': '\\u21D1',\n 'uArr': '\\u21D1',\n 'DoubleUpDownArrow': '\\u21D5',\n 'Updownarrow': '\\u21D5',\n 'vArr': '\\u21D5',\n 'DoubleVerticalBar': '\\u2225',\n 'par': '\\u2225',\n 'parallel': '\\u2225',\n 'shortparallel': '\\u2225',\n 'spar': '\\u2225',\n 'DownArrow': '\\u2193',\n 'ShortDownArrow': '\\u2193',\n 'darr': '\\u2193',\n 'downarrow': '\\u2193',\n 'DownArrowBar': '\\u2913',\n 'DownArrowUpArrow': '\\u21F5',\n 'duarr': '\\u21F5',\n 'DownBreve': '\\u0311',\n 'DownLeftRightVector': '\\u2950',\n 'DownLeftTeeVector': '\\u295E',\n 'DownLeftVector': '\\u21BD',\n 'leftharpoondown': '\\u21BD',\n 'lhard': '\\u21BD',\n 'DownLeftVectorBar': '\\u2956',\n 'DownRightTeeVector': '\\u295F',\n 'DownRightVector': '\\u21C1',\n 'rhard': '\\u21C1',\n 'rightharpoondown': '\\u21C1',\n 'DownRightVectorBar': '\\u2957',\n 'DownTee': '\\u22A4',\n 'top': '\\u22A4',\n 'DownTeeArrow': '\\u21A7',\n 'mapstodown': '\\u21A7',\n 'Dscr': '\\uD835\\uDC9F',\n 'Dstrok': '\\u0110',\n 'ENG': '\\u014A',\n 'ETH': '\\u00D0',\n 'Eacute': '\\u00C9',\n 'Ecaron': '\\u011A',\n 'Ecirc': '\\u00CA',\n 'Ecy': '\\u042D',\n 'Edot': '\\u0116',\n 'Efr': '\\uD835\\uDD08',\n 'Egrave': '\\u00C8',\n 'Element': '\\u2208',\n 'in': '\\u2208',\n 'isin': '\\u2208',\n 'isinv': '\\u2208',\n 'Emacr': '\\u0112',\n 'EmptySmallSquare': '\\u25FB',\n 'EmptyVerySmallSquare': '\\u25AB',\n 'Eogon': '\\u0118',\n 'Eopf': '\\uD835\\uDD3C',\n 'Epsilon': '\\u0395',\n 'Equal': '\\u2A75',\n 'EqualTilde': '\\u2242',\n 'eqsim': '\\u2242',\n 'esim': '\\u2242',\n 'Equilibrium': '\\u21CC',\n 'rightleftharpoons': '\\u21CC',\n 'rlhar': '\\u21CC',\n 'Escr': '\\u2130',\n 'expectation': '\\u2130',\n 'Esim': '\\u2A73',\n 'Eta': '\\u0397',\n 'Euml': '\\u00CB',\n 'Exists': '\\u2203',\n 'exist': '\\u2203',\n 'ExponentialE': '\\u2147',\n 'ee': '\\u2147',\n 'exponentiale': '\\u2147',\n 'Fcy': '\\u0424',\n 'Ffr': '\\uD835\\uDD09',\n 'FilledSmallSquare': '\\u25FC',\n 'FilledVerySmallSquare': '\\u25AA',\n 'blacksquare': '\\u25AA',\n 'squarf': '\\u25AA',\n 'squf': '\\u25AA',\n 'Fopf': '\\uD835\\uDD3D',\n 'ForAll': '\\u2200',\n 'forall': '\\u2200',\n 'Fouriertrf': '\\u2131',\n 'Fscr': '\\u2131',\n 'GJcy': '\\u0403',\n 'GT': '\\u003E',\n 'gt': '\\u003E',\n 'Gamma': '\\u0393',\n 'Gammad': '\\u03DC',\n 'Gbreve': '\\u011E',\n 'Gcedil': '\\u0122',\n 'Gcirc': '\\u011C',\n 'Gcy': '\\u0413',\n 'Gdot': '\\u0120',\n 'Gfr': '\\uD835\\uDD0A',\n 'Gg': '\\u22D9',\n 'ggg': '\\u22D9',\n 'Gopf': '\\uD835\\uDD3E',\n 'GreaterEqual': '\\u2265',\n 'ge': '\\u2265',\n 'geq': '\\u2265',\n 'GreaterEqualLess': '\\u22DB',\n 'gel': '\\u22DB',\n 'gtreqless': '\\u22DB',\n 'GreaterFullEqual': '\\u2267',\n 'gE': '\\u2267',\n 'geqq': '\\u2267',\n 'GreaterGreater': '\\u2AA2',\n 'GreaterLess': '\\u2277',\n 'gl': '\\u2277',\n 'gtrless': '\\u2277',\n 'GreaterSlantEqual': '\\u2A7E',\n 'geqslant': '\\u2A7E',\n 'ges': '\\u2A7E',\n 'GreaterTilde': '\\u2273',\n 'gsim': '\\u2273',\n 'gtrsim': '\\u2273',\n 'Gscr': '\\uD835\\uDCA2',\n 'Gt': '\\u226B',\n 'NestedGreaterGreater': '\\u226B',\n 'gg': '\\u226B',\n 'HARDcy': '\\u042A',\n 'Hacek': '\\u02C7',\n 'caron': '\\u02C7',\n 'Hat': '\\u005E',\n 'Hcirc': '\\u0124',\n 'Hfr': '\\u210C',\n 'Poincareplane': '\\u210C',\n 'HilbertSpace': '\\u210B',\n 'Hscr': '\\u210B',\n 'hamilt': '\\u210B',\n 'Hopf': '\\u210D',\n 'quaternions': '\\u210D',\n 'HorizontalLine': '\\u2500',\n 'boxh': '\\u2500',\n 'Hstrok': '\\u0126',\n 'HumpEqual': '\\u224F',\n 'bumpe': '\\u224F',\n 'bumpeq': '\\u224F',\n 'IEcy': '\\u0415',\n 'IJlig': '\\u0132',\n 'IOcy': '\\u0401',\n 'Iacute': '\\u00CD',\n 'Icirc': '\\u00CE',\n 'Icy': '\\u0418',\n 'Idot': '\\u0130',\n 'Ifr': '\\u2111',\n 'Im': '\\u2111',\n 'image': '\\u2111',\n 'imagpart': '\\u2111',\n 'Igrave': '\\u00CC',\n 'Imacr': '\\u012A',\n 'ImaginaryI': '\\u2148',\n 'ii': '\\u2148',\n 'Int': '\\u222C',\n 'Integral': '\\u222B',\n 'int': '\\u222B',\n 'Intersection': '\\u22C2',\n 'bigcap': '\\u22C2',\n 'xcap': '\\u22C2',\n 'InvisibleComma': '\\u2063',\n 'ic': '\\u2063',\n 'InvisibleTimes': '\\u2062',\n 'it': '\\u2062',\n 'Iogon': '\\u012E',\n 'Iopf': '\\uD835\\uDD40',\n 'Iota': '\\u0399',\n 'Iscr': '\\u2110',\n 'imagline': '\\u2110',\n 'Itilde': '\\u0128',\n 'Iukcy': '\\u0406',\n 'Iuml': '\\u00CF',\n 'Jcirc': '\\u0134',\n 'Jcy': '\\u0419',\n 'Jfr': '\\uD835\\uDD0D',\n 'Jopf': '\\uD835\\uDD41',\n 'Jscr': '\\uD835\\uDCA5',\n 'Jsercy': '\\u0408',\n 'Jukcy': '\\u0404',\n 'KHcy': '\\u0425',\n 'KJcy': '\\u040C',\n 'Kappa': '\\u039A',\n 'Kcedil': '\\u0136',\n 'Kcy': '\\u041A',\n 'Kfr': '\\uD835\\uDD0E',\n 'Kopf': '\\uD835\\uDD42',\n 'Kscr': '\\uD835\\uDCA6',\n 'LJcy': '\\u0409',\n 'LT': '\\u003C',\n 'lt': '\\u003C',\n 'Lacute': '\\u0139',\n 'Lambda': '\\u039B',\n 'Lang': '\\u27EA',\n 'Laplacetrf': '\\u2112',\n 'Lscr': '\\u2112',\n 'lagran': '\\u2112',\n 'Larr': '\\u219E',\n 'twoheadleftarrow': '\\u219E',\n 'Lcaron': '\\u013D',\n 'Lcedil': '\\u013B',\n 'Lcy': '\\u041B',\n 'LeftAngleBracket': '\\u27E8',\n 'lang': '\\u27E8',\n 'langle': '\\u27E8',\n 'LeftArrow': '\\u2190',\n 'ShortLeftArrow': '\\u2190',\n 'larr': '\\u2190',\n 'leftarrow': '\\u2190',\n 'slarr': '\\u2190',\n 'LeftArrowBar': '\\u21E4',\n 'larrb': '\\u21E4',\n 'LeftArrowRightArrow': '\\u21C6',\n 'leftrightarrows': '\\u21C6',\n 'lrarr': '\\u21C6',\n 'LeftCeiling': '\\u2308',\n 'lceil': '\\u2308',\n 'LeftDoubleBracket': '\\u27E6',\n 'lobrk': '\\u27E6',\n 'LeftDownTeeVector': '\\u2961',\n 'LeftDownVector': '\\u21C3',\n 'dharl': '\\u21C3',\n 'downharpoonleft': '\\u21C3',\n 'LeftDownVectorBar': '\\u2959',\n 'LeftFloor': '\\u230A',\n 'lfloor': '\\u230A',\n 'LeftRightArrow': '\\u2194',\n 'harr': '\\u2194',\n 'leftrightarrow': '\\u2194',\n 'LeftRightVector': '\\u294E',\n 'LeftTee': '\\u22A3',\n 'dashv': '\\u22A3',\n 'LeftTeeArrow': '\\u21A4',\n 'mapstoleft': '\\u21A4',\n 'LeftTeeVector': '\\u295A',\n 'LeftTriangle': '\\u22B2',\n 'vartriangleleft': '\\u22B2',\n 'vltri': '\\u22B2',\n 'LeftTriangleBar': '\\u29CF',\n 'LeftTriangleEqual': '\\u22B4',\n 'ltrie': '\\u22B4',\n 'trianglelefteq': '\\u22B4',\n 'LeftUpDownVector': '\\u2951',\n 'LeftUpTeeVector': '\\u2960',\n 'LeftUpVector': '\\u21BF',\n 'uharl': '\\u21BF',\n 'upharpoonleft': '\\u21BF',\n 'LeftUpVectorBar': '\\u2958',\n 'LeftVector': '\\u21BC',\n 'leftharpoonup': '\\u21BC',\n 'lharu': '\\u21BC',\n 'LeftVectorBar': '\\u2952',\n 'LessEqualGreater': '\\u22DA',\n 'leg': '\\u22DA',\n 'lesseqgtr': '\\u22DA',\n 'LessFullEqual': '\\u2266',\n 'lE': '\\u2266',\n 'leqq': '\\u2266',\n 'LessGreater': '\\u2276',\n 'lessgtr': '\\u2276',\n 'lg': '\\u2276',\n 'LessLess': '\\u2AA1',\n 'LessSlantEqual': '\\u2A7D',\n 'leqslant': '\\u2A7D',\n 'les': '\\u2A7D',\n 'LessTilde': '\\u2272',\n 'lesssim': '\\u2272',\n 'lsim': '\\u2272',\n 'Lfr': '\\uD835\\uDD0F',\n 'Ll': '\\u22D8',\n 'Lleftarrow': '\\u21DA',\n 'lAarr': '\\u21DA',\n 'Lmidot': '\\u013F',\n 'LongLeftArrow': '\\u27F5',\n 'longleftarrow': '\\u27F5',\n 'xlarr': '\\u27F5',\n 'LongLeftRightArrow': '\\u27F7',\n 'longleftrightarrow': '\\u27F7',\n 'xharr': '\\u27F7',\n 'LongRightArrow': '\\u27F6',\n 'longrightarrow': '\\u27F6',\n 'xrarr': '\\u27F6',\n 'Lopf': '\\uD835\\uDD43',\n 'LowerLeftArrow': '\\u2199',\n 'swarr': '\\u2199',\n 'swarrow': '\\u2199',\n 'LowerRightArrow': '\\u2198',\n 'searr': '\\u2198',\n 'searrow': '\\u2198',\n 'Lsh': '\\u21B0',\n 'lsh': '\\u21B0',\n 'Lstrok': '\\u0141',\n 'Lt': '\\u226A',\n 'NestedLessLess': '\\u226A',\n 'll': '\\u226A',\n 'Map': '\\u2905',\n 'Mcy': '\\u041C',\n 'MediumSpace': '\\u205F',\n 'Mellintrf': '\\u2133',\n 'Mscr': '\\u2133',\n 'phmmat': '\\u2133',\n 'Mfr': '\\uD835\\uDD10',\n 'MinusPlus': '\\u2213',\n 'mnplus': '\\u2213',\n 'mp': '\\u2213',\n 'Mopf': '\\uD835\\uDD44',\n 'Mu': '\\u039C',\n 'NJcy': '\\u040A',\n 'Nacute': '\\u0143',\n 'Ncaron': '\\u0147',\n 'Ncedil': '\\u0145',\n 'Ncy': '\\u041D',\n 'NegativeMediumSpace': '\\u200B',\n 'NegativeThickSpace': '\\u200B',\n 'NegativeThinSpace': '\\u200B',\n 'NegativeVeryThinSpace': '\\u200B',\n 'ZeroWidthSpace': '\\u200B',\n 'NewLine': '\\u000A',\n 'Nfr': '\\uD835\\uDD11',\n 'NoBreak': '\\u2060',\n 'NonBreakingSpace': '\\u00A0',\n 'nbsp': '\\u00A0',\n 'Nopf': '\\u2115',\n 'naturals': '\\u2115',\n 'Not': '\\u2AEC',\n 'NotCongruent': '\\u2262',\n 'nequiv': '\\u2262',\n 'NotCupCap': '\\u226D',\n 'NotDoubleVerticalBar': '\\u2226',\n 'npar': '\\u2226',\n 'nparallel': '\\u2226',\n 'nshortparallel': '\\u2226',\n 'nspar': '\\u2226',\n 'NotElement': '\\u2209',\n 'notin': '\\u2209',\n 'notinva': '\\u2209',\n 'NotEqual': '\\u2260',\n 'ne': '\\u2260',\n 'NotEqualTilde': '\\u2242\\u0338',\n 'nesim': '\\u2242\\u0338',\n 'NotExists': '\\u2204',\n 'nexist': '\\u2204',\n 'nexists': '\\u2204',\n 'NotGreater': '\\u226F',\n 'ngt': '\\u226F',\n 'ngtr': '\\u226F',\n 'NotGreaterEqual': '\\u2271',\n 'nge': '\\u2271',\n 'ngeq': '\\u2271',\n 'NotGreaterFullEqual': '\\u2267\\u0338',\n 'ngE': '\\u2267\\u0338',\n 'ngeqq': '\\u2267\\u0338',\n 'NotGreaterGreater': '\\u226B\\u0338',\n 'nGtv': '\\u226B\\u0338',\n 'NotGreaterLess': '\\u2279',\n 'ntgl': '\\u2279',\n 'NotGreaterSlantEqual': '\\u2A7E\\u0338',\n 'ngeqslant': '\\u2A7E\\u0338',\n 'nges': '\\u2A7E\\u0338',\n 'NotGreaterTilde': '\\u2275',\n 'ngsim': '\\u2275',\n 'NotHumpDownHump': '\\u224E\\u0338',\n 'nbump': '\\u224E\\u0338',\n 'NotHumpEqual': '\\u224F\\u0338',\n 'nbumpe': '\\u224F\\u0338',\n 'NotLeftTriangle': '\\u22EA',\n 'nltri': '\\u22EA',\n 'ntriangleleft': '\\u22EA',\n 'NotLeftTriangleBar': '\\u29CF\\u0338',\n 'NotLeftTriangleEqual': '\\u22EC',\n 'nltrie': '\\u22EC',\n 'ntrianglelefteq': '\\u22EC',\n 'NotLess': '\\u226E',\n 'nless': '\\u226E',\n 'nlt': '\\u226E',\n 'NotLessEqual': '\\u2270',\n 'nle': '\\u2270',\n 'nleq': '\\u2270',\n 'NotLessGreater': '\\u2278',\n 'ntlg': '\\u2278',\n 'NotLessLess': '\\u226A\\u0338',\n 'nLtv': '\\u226A\\u0338',\n 'NotLessSlantEqual': '\\u2A7D\\u0338',\n 'nleqslant': '\\u2A7D\\u0338',\n 'nles': '\\u2A7D\\u0338',\n 'NotLessTilde': '\\u2274',\n 'nlsim': '\\u2274',\n 'NotNestedGreaterGreater': '\\u2AA2\\u0338',\n 'NotNestedLessLess': '\\u2AA1\\u0338',\n 'NotPrecedes': '\\u2280',\n 'npr': '\\u2280',\n 'nprec': '\\u2280',\n 'NotPrecedesEqual': '\\u2AAF\\u0338',\n 'npre': '\\u2AAF\\u0338',\n 'npreceq': '\\u2AAF\\u0338',\n 'NotPrecedesSlantEqual': '\\u22E0',\n 'nprcue': '\\u22E0',\n 'NotReverseElement': '\\u220C',\n 'notni': '\\u220C',\n 'notniva': '\\u220C',\n 'NotRightTriangle': '\\u22EB',\n 'nrtri': '\\u22EB',\n 'ntriangleright': '\\u22EB',\n 'NotRightTriangleBar': '\\u29D0\\u0338',\n 'NotRightTriangleEqual': '\\u22ED',\n 'nrtrie': '\\u22ED',\n 'ntrianglerighteq': '\\u22ED',\n 'NotSquareSubset': '\\u228F\\u0338',\n 'NotSquareSubsetEqual': '\\u22E2',\n 'nsqsube': '\\u22E2',\n 'NotSquareSuperset': '\\u2290\\u0338',\n 'NotSquareSupersetEqual': '\\u22E3',\n 'nsqsupe': '\\u22E3',\n 'NotSubset': '\\u2282\\u20D2',\n 'nsubset': '\\u2282\\u20D2',\n 'vnsub': '\\u2282\\u20D2',\n 'NotSubsetEqual': '\\u2288',\n 'nsube': '\\u2288',\n 'nsubseteq': '\\u2288',\n 'NotSucceeds': '\\u2281',\n 'nsc': '\\u2281',\n 'nsucc': '\\u2281',\n 'NotSucceedsEqual': '\\u2AB0\\u0338',\n 'nsce': '\\u2AB0\\u0338',\n 'nsucceq': '\\u2AB0\\u0338',\n 'NotSucceedsSlantEqual': '\\u22E1',\n 'nsccue': '\\u22E1',\n 'NotSucceedsTilde': '\\u227F\\u0338',\n 'NotSuperset': '\\u2283\\u20D2',\n 'nsupset': '\\u2283\\u20D2',\n 'vnsup': '\\u2283\\u20D2',\n 'NotSupersetEqual': '\\u2289',\n 'nsupe': '\\u2289',\n 'nsupseteq': '\\u2289',\n 'NotTilde': '\\u2241',\n 'nsim': '\\u2241',\n 'NotTildeEqual': '\\u2244',\n 'nsime': '\\u2244',\n 'nsimeq': '\\u2244',\n 'NotTildeFullEqual': '\\u2247',\n 'ncong': '\\u2247',\n 'NotTildeTilde': '\\u2249',\n 'nap': '\\u2249',\n 'napprox': '\\u2249',\n 'NotVerticalBar': '\\u2224',\n 'nmid': '\\u2224',\n 'nshortmid': '\\u2224',\n 'nsmid': '\\u2224',\n 'Nscr': '\\uD835\\uDCA9',\n 'Ntilde': '\\u00D1',\n 'Nu': '\\u039D',\n 'OElig': '\\u0152',\n 'Oacute': '\\u00D3',\n 'Ocirc': '\\u00D4',\n 'Ocy': '\\u041E',\n 'Odblac': '\\u0150',\n 'Ofr': '\\uD835\\uDD12',\n 'Ograve': '\\u00D2',\n 'Omacr': '\\u014C',\n 'Omega': '\\u03A9',\n 'ohm': '\\u03A9',\n 'Omicron': '\\u039F',\n 'Oopf': '\\uD835\\uDD46',\n 'OpenCurlyDoubleQuote': '\\u201C',\n 'ldquo': '\\u201C',\n 'OpenCurlyQuote': '\\u2018',\n 'lsquo': '\\u2018',\n 'Or': '\\u2A54',\n 'Oscr': '\\uD835\\uDCAA',\n 'Oslash': '\\u00D8',\n 'Otilde': '\\u00D5',\n 'Otimes': '\\u2A37',\n 'Ouml': '\\u00D6',\n 'OverBar': '\\u203E',\n 'oline': '\\u203E',\n 'OverBrace': '\\u23DE',\n 'OverBracket': '\\u23B4',\n 'tbrk': '\\u23B4',\n 'OverParenthesis': '\\u23DC',\n 'PartialD': '\\u2202',\n 'part': '\\u2202',\n 'Pcy': '\\u041F',\n 'Pfr': '\\uD835\\uDD13',\n 'Phi': '\\u03A6',\n 'Pi': '\\u03A0',\n 'PlusMinus': '\\u00B1',\n 'plusmn': '\\u00B1',\n 'pm': '\\u00B1',\n 'Popf': '\\u2119',\n 'primes': '\\u2119',\n 'Pr': '\\u2ABB',\n 'Precedes': '\\u227A',\n 'pr': '\\u227A',\n 'prec': '\\u227A',\n 'PrecedesEqual': '\\u2AAF',\n 'pre': '\\u2AAF',\n 'preceq': '\\u2AAF',\n 'PrecedesSlantEqual': '\\u227C',\n 'prcue': '\\u227C',\n 'preccurlyeq': '\\u227C',\n 'PrecedesTilde': '\\u227E',\n 'precsim': '\\u227E',\n 'prsim': '\\u227E',\n 'Prime': '\\u2033',\n 'Product': '\\u220F',\n 'prod': '\\u220F',\n 'Proportional': '\\u221D',\n 'prop': '\\u221D',\n 'propto': '\\u221D',\n 'varpropto': '\\u221D',\n 'vprop': '\\u221D',\n 'Pscr': '\\uD835\\uDCAB',\n 'Psi': '\\u03A8',\n 'QUOT': '\\u0022',\n 'quot': '\\u0022',\n 'Qfr': '\\uD835\\uDD14',\n 'Qopf': '\\u211A',\n 'rationals': '\\u211A',\n 'Qscr': '\\uD835\\uDCAC',\n 'RBarr': '\\u2910',\n 'drbkarow': '\\u2910',\n 'REG': '\\u00AE',\n 'circledR': '\\u00AE',\n 'reg': '\\u00AE',\n 'Racute': '\\u0154',\n 'Rang': '\\u27EB',\n 'Rarr': '\\u21A0',\n 'twoheadrightarrow': '\\u21A0',\n 'Rarrtl': '\\u2916',\n 'Rcaron': '\\u0158',\n 'Rcedil': '\\u0156',\n 'Rcy': '\\u0420',\n 'Re': '\\u211C',\n 'Rfr': '\\u211C',\n 'real': '\\u211C',\n 'realpart': '\\u211C',\n 'ReverseElement': '\\u220B',\n 'SuchThat': '\\u220B',\n 'ni': '\\u220B',\n 'niv': '\\u220B',\n 'ReverseEquilibrium': '\\u21CB',\n 'leftrightharpoons': '\\u21CB',\n 'lrhar': '\\u21CB',\n 'ReverseUpEquilibrium': '\\u296F',\n 'duhar': '\\u296F',\n 'Rho': '\\u03A1',\n 'RightAngleBracket': '\\u27E9',\n 'rang': '\\u27E9',\n 'rangle': '\\u27E9',\n 'RightArrow': '\\u2192',\n 'ShortRightArrow': '\\u2192',\n 'rarr': '\\u2192',\n 'rightarrow': '\\u2192',\n 'srarr': '\\u2192',\n 'RightArrowBar': '\\u21E5',\n 'rarrb': '\\u21E5',\n 'RightArrowLeftArrow': '\\u21C4',\n 'rightleftarrows': '\\u21C4',\n 'rlarr': '\\u21C4',\n 'RightCeiling': '\\u2309',\n 'rceil': '\\u2309',\n 'RightDoubleBracket': '\\u27E7',\n 'robrk': '\\u27E7',\n 'RightDownTeeVector': '\\u295D',\n 'RightDownVector': '\\u21C2',\n 'dharr': '\\u21C2',\n 'downharpoonright': '\\u21C2',\n 'RightDownVectorBar': '\\u2955',\n 'RightFloor': '\\u230B',\n 'rfloor': '\\u230B',\n 'RightTee': '\\u22A2',\n 'vdash': '\\u22A2',\n 'RightTeeArrow': '\\u21A6',\n 'map': '\\u21A6',\n 'mapsto': '\\u21A6',\n 'RightTeeVector': '\\u295B',\n 'RightTriangle': '\\u22B3',\n 'vartriangleright': '\\u22B3',\n 'vrtri': '\\u22B3',\n 'RightTriangleBar': '\\u29D0',\n 'RightTriangleEqual': '\\u22B5',\n 'rtrie': '\\u22B5',\n 'trianglerighteq': '\\u22B5',\n 'RightUpDownVector': '\\u294F',\n 'RightUpTeeVector': '\\u295C',\n 'RightUpVector': '\\u21BE',\n 'uharr': '\\u21BE',\n 'upharpoonright': '\\u21BE',\n 'RightUpVectorBar': '\\u2954',\n 'RightVector': '\\u21C0',\n 'rharu': '\\u21C0',\n 'rightharpoonup': '\\u21C0',\n 'RightVectorBar': '\\u2953',\n 'Ropf': '\\u211D',\n 'reals': '\\u211D',\n 'RoundImplies': '\\u2970',\n 'Rrightarrow': '\\u21DB',\n 'rAarr': '\\u21DB',\n 'Rscr': '\\u211B',\n 'realine': '\\u211B',\n 'Rsh': '\\u21B1',\n 'rsh': '\\u21B1',\n 'RuleDelayed': '\\u29F4',\n 'SHCHcy': '\\u0429',\n 'SHcy': '\\u0428',\n 'SOFTcy': '\\u042C',\n 'Sacute': '\\u015A',\n 'Sc': '\\u2ABC',\n 'Scaron': '\\u0160',\n 'Scedil': '\\u015E',\n 'Scirc': '\\u015C',\n 'Scy': '\\u0421',\n 'Sfr': '\\uD835\\uDD16',\n 'ShortUpArrow': '\\u2191',\n 'UpArrow': '\\u2191',\n 'uarr': '\\u2191',\n 'uparrow': '\\u2191',\n 'Sigma': '\\u03A3',\n 'SmallCircle': '\\u2218',\n 'compfn': '\\u2218',\n 'Sopf': '\\uD835\\uDD4A',\n 'Sqrt': '\\u221A',\n 'radic': '\\u221A',\n 'Square': '\\u25A1',\n 'squ': '\\u25A1',\n 'square': '\\u25A1',\n 'SquareIntersection': '\\u2293',\n 'sqcap': '\\u2293',\n 'SquareSubset': '\\u228F',\n 'sqsub': '\\u228F',\n 'sqsubset': '\\u228F',\n 'SquareSubsetEqual': '\\u2291',\n 'sqsube': '\\u2291',\n 'sqsubseteq': '\\u2291',\n 'SquareSuperset': '\\u2290',\n 'sqsup': '\\u2290',\n 'sqsupset': '\\u2290',\n 'SquareSupersetEqual': '\\u2292',\n 'sqsupe': '\\u2292',\n 'sqsupseteq': '\\u2292',\n 'SquareUnion': '\\u2294',\n 'sqcup': '\\u2294',\n 'Sscr': '\\uD835\\uDCAE',\n 'Star': '\\u22C6',\n 'sstarf': '\\u22C6',\n 'Sub': '\\u22D0',\n 'Subset': '\\u22D0',\n 'SubsetEqual': '\\u2286',\n 'sube': '\\u2286',\n 'subseteq': '\\u2286',\n 'Succeeds': '\\u227B',\n 'sc': '\\u227B',\n 'succ': '\\u227B',\n 'SucceedsEqual': '\\u2AB0',\n 'sce': '\\u2AB0',\n 'succeq': '\\u2AB0',\n 'SucceedsSlantEqual': '\\u227D',\n 'sccue': '\\u227D',\n 'succcurlyeq': '\\u227D',\n 'SucceedsTilde': '\\u227F',\n 'scsim': '\\u227F',\n 'succsim': '\\u227F',\n 'Sum': '\\u2211',\n 'sum': '\\u2211',\n 'Sup': '\\u22D1',\n 'Supset': '\\u22D1',\n 'Superset': '\\u2283',\n 'sup': '\\u2283',\n 'supset': '\\u2283',\n 'SupersetEqual': '\\u2287',\n 'supe': '\\u2287',\n 'supseteq': '\\u2287',\n 'THORN': '\\u00DE',\n 'TRADE': '\\u2122',\n 'trade': '\\u2122',\n 'TSHcy': '\\u040B',\n 'TScy': '\\u0426',\n 'Tab': '\\u0009',\n 'Tau': '\\u03A4',\n 'Tcaron': '\\u0164',\n 'Tcedil': '\\u0162',\n 'Tcy': '\\u0422',\n 'Tfr': '\\uD835\\uDD17',\n 'Therefore': '\\u2234',\n 'there4': '\\u2234',\n 'therefore': '\\u2234',\n 'Theta': '\\u0398',\n 'ThickSpace': '\\u205F\\u200A',\n 'ThinSpace': '\\u2009',\n 'thinsp': '\\u2009',\n 'Tilde': '\\u223C',\n 'sim': '\\u223C',\n 'thicksim': '\\u223C',\n 'thksim': '\\u223C',\n 'TildeEqual': '\\u2243',\n 'sime': '\\u2243',\n 'simeq': '\\u2243',\n 'TildeFullEqual': '\\u2245',\n 'cong': '\\u2245',\n 'TildeTilde': '\\u2248',\n 'ap': '\\u2248',\n 'approx': '\\u2248',\n 'asymp': '\\u2248',\n 'thickapprox': '\\u2248',\n 'thkap': '\\u2248',\n 'Topf': '\\uD835\\uDD4B',\n 'TripleDot': '\\u20DB',\n 'tdot': '\\u20DB',\n 'Tscr': '\\uD835\\uDCAF',\n 'Tstrok': '\\u0166',\n 'Uacute': '\\u00DA',\n 'Uarr': '\\u219F',\n 'Uarrocir': '\\u2949',\n 'Ubrcy': '\\u040E',\n 'Ubreve': '\\u016C',\n 'Ucirc': '\\u00DB',\n 'Ucy': '\\u0423',\n 'Udblac': '\\u0170',\n 'Ufr': '\\uD835\\uDD18',\n 'Ugrave': '\\u00D9',\n 'Umacr': '\\u016A',\n 'UnderBar': '\\u005F',\n 'lowbar': '\\u005F',\n 'UnderBrace': '\\u23DF',\n 'UnderBracket': '\\u23B5',\n 'bbrk': '\\u23B5',\n 'UnderParenthesis': '\\u23DD',\n 'Union': '\\u22C3',\n 'bigcup': '\\u22C3',\n 'xcup': '\\u22C3',\n 'UnionPlus': '\\u228E',\n 'uplus': '\\u228E',\n 'Uogon': '\\u0172',\n 'Uopf': '\\uD835\\uDD4C',\n 'UpArrowBar': '\\u2912',\n 'UpArrowDownArrow': '\\u21C5',\n 'udarr': '\\u21C5',\n 'UpDownArrow': '\\u2195',\n 'updownarrow': '\\u2195',\n 'varr': '\\u2195',\n 'UpEquilibrium': '\\u296E',\n 'udhar': '\\u296E',\n 'UpTee': '\\u22A5',\n 'bot': '\\u22A5',\n 'bottom': '\\u22A5',\n 'perp': '\\u22A5',\n 'UpTeeArrow': '\\u21A5',\n 'mapstoup': '\\u21A5',\n 'UpperLeftArrow': '\\u2196',\n 'nwarr': '\\u2196',\n 'nwarrow': '\\u2196',\n 'UpperRightArrow': '\\u2197',\n 'nearr': '\\u2197',\n 'nearrow': '\\u2197',\n 'Upsi': '\\u03D2',\n 'upsih': '\\u03D2',\n 'Upsilon': '\\u03A5',\n 'Uring': '\\u016E',\n 'Uscr': '\\uD835\\uDCB0',\n 'Utilde': '\\u0168',\n 'Uuml': '\\u00DC',\n 'VDash': '\\u22AB',\n 'Vbar': '\\u2AEB',\n 'Vcy': '\\u0412',\n 'Vdash': '\\u22A9',\n 'Vdashl': '\\u2AE6',\n 'Vee': '\\u22C1',\n 'bigvee': '\\u22C1',\n 'xvee': '\\u22C1',\n 'Verbar': '\\u2016',\n 'Vert': '\\u2016',\n 'VerticalBar': '\\u2223',\n 'mid': '\\u2223',\n 'shortmid': '\\u2223',\n 'smid': '\\u2223',\n 'VerticalLine': '\\u007C',\n 'verbar': '\\u007C',\n 'vert': '\\u007C',\n 'VerticalSeparator': '\\u2758',\n 'VerticalTilde': '\\u2240',\n 'wr': '\\u2240',\n 'wreath': '\\u2240',\n 'VeryThinSpace': '\\u200A',\n 'hairsp': '\\u200A',\n 'Vfr': '\\uD835\\uDD19',\n 'Vopf': '\\uD835\\uDD4D',\n 'Vscr': '\\uD835\\uDCB1',\n 'Vvdash': '\\u22AA',\n 'Wcirc': '\\u0174',\n 'Wedge': '\\u22C0',\n 'bigwedge': '\\u22C0',\n 'xwedge': '\\u22C0',\n 'Wfr': '\\uD835\\uDD1A',\n 'Wopf': '\\uD835\\uDD4E',\n 'Wscr': '\\uD835\\uDCB2',\n 'Xfr': '\\uD835\\uDD1B',\n 'Xi': '\\u039E',\n 'Xopf': '\\uD835\\uDD4F',\n 'Xscr': '\\uD835\\uDCB3',\n 'YAcy': '\\u042F',\n 'YIcy': '\\u0407',\n 'YUcy': '\\u042E',\n 'Yacute': '\\u00DD',\n 'Ycirc': '\\u0176',\n 'Ycy': '\\u042B',\n 'Yfr': '\\uD835\\uDD1C',\n 'Yopf': '\\uD835\\uDD50',\n 'Yscr': '\\uD835\\uDCB4',\n 'Yuml': '\\u0178',\n 'ZHcy': '\\u0416',\n 'Zacute': '\\u0179',\n 'Zcaron': '\\u017D',\n 'Zcy': '\\u0417',\n 'Zdot': '\\u017B',\n 'Zeta': '\\u0396',\n 'Zfr': '\\u2128',\n 'zeetrf': '\\u2128',\n 'Zopf': '\\u2124',\n 'integers': '\\u2124',\n 'Zscr': '\\uD835\\uDCB5',\n 'aacute': '\\u00E1',\n 'abreve': '\\u0103',\n 'ac': '\\u223E',\n 'mstpos': '\\u223E',\n 'acE': '\\u223E\\u0333',\n 'acd': '\\u223F',\n 'acirc': '\\u00E2',\n 'acy': '\\u0430',\n 'aelig': '\\u00E6',\n 'afr': '\\uD835\\uDD1E',\n 'agrave': '\\u00E0',\n 'alefsym': '\\u2135',\n 'aleph': '\\u2135',\n 'alpha': '\\u03B1',\n 'amacr': '\\u0101',\n 'amalg': '\\u2A3F',\n 'and': '\\u2227',\n 'wedge': '\\u2227',\n 'andand': '\\u2A55',\n 'andd': '\\u2A5C',\n 'andslope': '\\u2A58',\n 'andv': '\\u2A5A',\n 'ang': '\\u2220',\n 'angle': '\\u2220',\n 'ange': '\\u29A4',\n 'angmsd': '\\u2221',\n 'measuredangle': '\\u2221',\n 'angmsdaa': '\\u29A8',\n 'angmsdab': '\\u29A9',\n 'angmsdac': '\\u29AA',\n 'angmsdad': '\\u29AB',\n 'angmsdae': '\\u29AC',\n 'angmsdaf': '\\u29AD',\n 'angmsdag': '\\u29AE',\n 'angmsdah': '\\u29AF',\n 'angrt': '\\u221F',\n 'angrtvb': '\\u22BE',\n 'angrtvbd': '\\u299D',\n 'angsph': '\\u2222',\n 'angzarr': '\\u237C',\n 'aogon': '\\u0105',\n 'aopf': '\\uD835\\uDD52',\n 'apE': '\\u2A70',\n 'apacir': '\\u2A6F',\n 'ape': '\\u224A',\n 'approxeq': '\\u224A',\n 'apid': '\\u224B',\n 'apos': '\\u0027',\n 'aring': '\\u00E5',\n 'ascr': '\\uD835\\uDCB6',\n 'ast': '\\u002A',\n 'midast': '\\u002A',\n 'atilde': '\\u00E3',\n 'auml': '\\u00E4',\n 'awint': '\\u2A11',\n 'bNot': '\\u2AED',\n 'backcong': '\\u224C',\n 'bcong': '\\u224C',\n 'backepsilon': '\\u03F6',\n 'bepsi': '\\u03F6',\n 'backprime': '\\u2035',\n 'bprime': '\\u2035',\n 'backsim': '\\u223D',\n 'bsim': '\\u223D',\n 'backsimeq': '\\u22CD',\n 'bsime': '\\u22CD',\n 'barvee': '\\u22BD',\n 'barwed': '\\u2305',\n 'barwedge': '\\u2305',\n 'bbrktbrk': '\\u23B6',\n 'bcy': '\\u0431',\n 'bdquo': '\\u201E',\n 'ldquor': '\\u201E',\n 'bemptyv': '\\u29B0',\n 'beta': '\\u03B2',\n 'beth': '\\u2136',\n 'between': '\\u226C',\n 'twixt': '\\u226C',\n 'bfr': '\\uD835\\uDD1F',\n 'bigcirc': '\\u25EF',\n 'xcirc': '\\u25EF',\n 'bigodot': '\\u2A00',\n 'xodot': '\\u2A00',\n 'bigoplus': '\\u2A01',\n 'xoplus': '\\u2A01',\n 'bigotimes': '\\u2A02',\n 'xotime': '\\u2A02',\n 'bigsqcup': '\\u2A06',\n 'xsqcup': '\\u2A06',\n 'bigstar': '\\u2605',\n 'starf': '\\u2605',\n 'bigtriangledown': '\\u25BD',\n 'xdtri': '\\u25BD',\n 'bigtriangleup': '\\u25B3',\n 'xutri': '\\u25B3',\n 'biguplus': '\\u2A04',\n 'xuplus': '\\u2A04',\n 'bkarow': '\\u290D',\n 'rbarr': '\\u290D',\n 'blacklozenge': '\\u29EB',\n 'lozf': '\\u29EB',\n 'blacktriangle': '\\u25B4',\n 'utrif': '\\u25B4',\n 'blacktriangledown': '\\u25BE',\n 'dtrif': '\\u25BE',\n 'blacktriangleleft': '\\u25C2',\n 'ltrif': '\\u25C2',\n 'blacktriangleright': '\\u25B8',\n 'rtrif': '\\u25B8',\n 'blank': '\\u2423',\n 'blk12': '\\u2592',\n 'blk14': '\\u2591',\n 'blk34': '\\u2593',\n 'block': '\\u2588',\n 'bne': '\\u003D\\u20E5',\n 'bnequiv': '\\u2261\\u20E5',\n 'bnot': '\\u2310',\n 'bopf': '\\uD835\\uDD53',\n 'bowtie': '\\u22C8',\n 'boxDL': '\\u2557',\n 'boxDR': '\\u2554',\n 'boxDl': '\\u2556',\n 'boxDr': '\\u2553',\n 'boxH': '\\u2550',\n 'boxHD': '\\u2566',\n 'boxHU': '\\u2569',\n 'boxHd': '\\u2564',\n 'boxHu': '\\u2567',\n 'boxUL': '\\u255D',\n 'boxUR': '\\u255A',\n 'boxUl': '\\u255C',\n 'boxUr': '\\u2559',\n 'boxV': '\\u2551',\n 'boxVH': '\\u256C',\n 'boxVL': '\\u2563',\n 'boxVR': '\\u2560',\n 'boxVh': '\\u256B',\n 'boxVl': '\\u2562',\n 'boxVr': '\\u255F',\n 'boxbox': '\\u29C9',\n 'boxdL': '\\u2555',\n 'boxdR': '\\u2552',\n 'boxdl': '\\u2510',\n 'boxdr': '\\u250C',\n 'boxhD': '\\u2565',\n 'boxhU': '\\u2568',\n 'boxhd': '\\u252C',\n 'boxhu': '\\u2534',\n 'boxminus': '\\u229F',\n 'minusb': '\\u229F',\n 'boxplus': '\\u229E',\n 'plusb': '\\u229E',\n 'boxtimes': '\\u22A0',\n 'timesb': '\\u22A0',\n 'boxuL': '\\u255B',\n 'boxuR': '\\u2558',\n 'boxul': '\\u2518',\n 'boxur': '\\u2514',\n 'boxv': '\\u2502',\n 'boxvH': '\\u256A',\n 'boxvL': '\\u2561',\n 'boxvR': '\\u255E',\n 'boxvh': '\\u253C',\n 'boxvl': '\\u2524',\n 'boxvr': '\\u251C',\n 'brvbar': '\\u00A6',\n 'bscr': '\\uD835\\uDCB7',\n 'bsemi': '\\u204F',\n 'bsol': '\\u005C',\n 'bsolb': '\\u29C5',\n 'bsolhsub': '\\u27C8',\n 'bull': '\\u2022',\n 'bullet': '\\u2022',\n 'bumpE': '\\u2AAE',\n 'cacute': '\\u0107',\n 'cap': '\\u2229',\n 'capand': '\\u2A44',\n 'capbrcup': '\\u2A49',\n 'capcap': '\\u2A4B',\n 'capcup': '\\u2A47',\n 'capdot': '\\u2A40',\n 'caps': '\\u2229\\uFE00',\n 'caret': '\\u2041',\n 'ccaps': '\\u2A4D',\n 'ccaron': '\\u010D',\n 'ccedil': '\\u00E7',\n 'ccirc': '\\u0109',\n 'ccups': '\\u2A4C',\n 'ccupssm': '\\u2A50',\n 'cdot': '\\u010B',\n 'cemptyv': '\\u29B2',\n 'cent': '\\u00A2',\n 'cfr': '\\uD835\\uDD20',\n 'chcy': '\\u0447',\n 'check': '\\u2713',\n 'checkmark': '\\u2713',\n 'chi': '\\u03C7',\n 'cir': '\\u25CB',\n 'cirE': '\\u29C3',\n 'circ': '\\u02C6',\n 'circeq': '\\u2257',\n 'cire': '\\u2257',\n 'circlearrowleft': '\\u21BA',\n 'olarr': '\\u21BA',\n 'circlearrowright': '\\u21BB',\n 'orarr': '\\u21BB',\n 'circledS': '\\u24C8',\n 'oS': '\\u24C8',\n 'circledast': '\\u229B',\n 'oast': '\\u229B',\n 'circledcirc': '\\u229A',\n 'ocir': '\\u229A',\n 'circleddash': '\\u229D',\n 'odash': '\\u229D',\n 'cirfnint': '\\u2A10',\n 'cirmid': '\\u2AEF',\n 'cirscir': '\\u29C2',\n 'clubs': '\\u2663',\n 'clubsuit': '\\u2663',\n 'colon': '\\u003A',\n 'comma': '\\u002C',\n 'commat': '\\u0040',\n 'comp': '\\u2201',\n 'complement': '\\u2201',\n 'congdot': '\\u2A6D',\n 'copf': '\\uD835\\uDD54',\n 'copysr': '\\u2117',\n 'crarr': '\\u21B5',\n 'cross': '\\u2717',\n 'cscr': '\\uD835\\uDCB8',\n 'csub': '\\u2ACF',\n 'csube': '\\u2AD1',\n 'csup': '\\u2AD0',\n 'csupe': '\\u2AD2',\n 'ctdot': '\\u22EF',\n 'cudarrl': '\\u2938',\n 'cudarrr': '\\u2935',\n 'cuepr': '\\u22DE',\n 'curlyeqprec': '\\u22DE',\n 'cuesc': '\\u22DF',\n 'curlyeqsucc': '\\u22DF',\n 'cularr': '\\u21B6',\n 'curvearrowleft': '\\u21B6',\n 'cularrp': '\\u293D',\n 'cup': '\\u222A',\n 'cupbrcap': '\\u2A48',\n 'cupcap': '\\u2A46',\n 'cupcup': '\\u2A4A',\n 'cupdot': '\\u228D',\n 'cupor': '\\u2A45',\n 'cups': '\\u222A\\uFE00',\n 'curarr': '\\u21B7',\n 'curvearrowright': '\\u21B7',\n 'curarrm': '\\u293C',\n 'curlyvee': '\\u22CE',\n 'cuvee': '\\u22CE',\n 'curlywedge': '\\u22CF',\n 'cuwed': '\\u22CF',\n 'curren': '\\u00A4',\n 'cwint': '\\u2231',\n 'cylcty': '\\u232D',\n 'dHar': '\\u2965',\n 'dagger': '\\u2020',\n 'daleth': '\\u2138',\n 'dash': '\\u2010',\n 'hyphen': '\\u2010',\n 'dbkarow': '\\u290F',\n 'rBarr': '\\u290F',\n 'dcaron': '\\u010F',\n 'dcy': '\\u0434',\n 'ddarr': '\\u21CA',\n 'downdownarrows': '\\u21CA',\n 'ddotseq': '\\u2A77',\n 'eDDot': '\\u2A77',\n 'deg': '\\u00B0',\n 'delta': '\\u03B4',\n 'demptyv': '\\u29B1',\n 'dfisht': '\\u297F',\n 'dfr': '\\uD835\\uDD21',\n 'diamondsuit': '\\u2666',\n 'diams': '\\u2666',\n 'digamma': '\\u03DD',\n 'gammad': '\\u03DD',\n 'disin': '\\u22F2',\n 'div': '\\u00F7',\n 'divide': '\\u00F7',\n 'divideontimes': '\\u22C7',\n 'divonx': '\\u22C7',\n 'djcy': '\\u0452',\n 'dlcorn': '\\u231E',\n 'llcorner': '\\u231E',\n 'dlcrop': '\\u230D',\n 'dollar': '\\u0024',\n 'dopf': '\\uD835\\uDD55',\n 'doteqdot': '\\u2251',\n 'eDot': '\\u2251',\n 'dotminus': '\\u2238',\n 'minusd': '\\u2238',\n 'dotplus': '\\u2214',\n 'plusdo': '\\u2214',\n 'dotsquare': '\\u22A1',\n 'sdotb': '\\u22A1',\n 'drcorn': '\\u231F',\n 'lrcorner': '\\u231F',\n 'drcrop': '\\u230C',\n 'dscr': '\\uD835\\uDCB9',\n 'dscy': '\\u0455',\n 'dsol': '\\u29F6',\n 'dstrok': '\\u0111',\n 'dtdot': '\\u22F1',\n 'dtri': '\\u25BF',\n 'triangledown': '\\u25BF',\n 'dwangle': '\\u29A6',\n 'dzcy': '\\u045F',\n 'dzigrarr': '\\u27FF',\n 'eacute': '\\u00E9',\n 'easter': '\\u2A6E',\n 'ecaron': '\\u011B',\n 'ecir': '\\u2256',\n 'eqcirc': '\\u2256',\n 'ecirc': '\\u00EA',\n 'ecolon': '\\u2255',\n 'eqcolon': '\\u2255',\n 'ecy': '\\u044D',\n 'edot': '\\u0117',\n 'efDot': '\\u2252',\n 'fallingdotseq': '\\u2252',\n 'efr': '\\uD835\\uDD22',\n 'eg': '\\u2A9A',\n 'egrave': '\\u00E8',\n 'egs': '\\u2A96',\n 'eqslantgtr': '\\u2A96',\n 'egsdot': '\\u2A98',\n 'el': '\\u2A99',\n 'elinters': '\\u23E7',\n 'ell': '\\u2113',\n 'els': '\\u2A95',\n 'eqslantless': '\\u2A95',\n 'elsdot': '\\u2A97',\n 'emacr': '\\u0113',\n 'empty': '\\u2205',\n 'emptyset': '\\u2205',\n 'emptyv': '\\u2205',\n 'varnothing': '\\u2205',\n 'emsp13': '\\u2004',\n 'emsp14': '\\u2005',\n 'emsp': '\\u2003',\n 'eng': '\\u014B',\n 'ensp': '\\u2002',\n 'eogon': '\\u0119',\n 'eopf': '\\uD835\\uDD56',\n 'epar': '\\u22D5',\n 'eparsl': '\\u29E3',\n 'eplus': '\\u2A71',\n 'epsi': '\\u03B5',\n 'epsilon': '\\u03B5',\n 'epsiv': '\\u03F5',\n 'straightepsilon': '\\u03F5',\n 'varepsilon': '\\u03F5',\n 'equals': '\\u003D',\n 'equest': '\\u225F',\n 'questeq': '\\u225F',\n 'equivDD': '\\u2A78',\n 'eqvparsl': '\\u29E5',\n 'erDot': '\\u2253',\n 'risingdotseq': '\\u2253',\n 'erarr': '\\u2971',\n 'escr': '\\u212F',\n 'eta': '\\u03B7',\n 'eth': '\\u00F0',\n 'euml': '\\u00EB',\n 'euro': '\\u20AC',\n 'excl': '\\u0021',\n 'fcy': '\\u0444',\n 'female': '\\u2640',\n 'ffilig': '\\uFB03',\n 'fflig': '\\uFB00',\n 'ffllig': '\\uFB04',\n 'ffr': '\\uD835\\uDD23',\n 'filig': '\\uFB01',\n 'fjlig': '\\u0066\\u006A',\n 'flat': '\\u266D',\n 'fllig': '\\uFB02',\n 'fltns': '\\u25B1',\n 'fnof': '\\u0192',\n 'fopf': '\\uD835\\uDD57',\n 'fork': '\\u22D4',\n 'pitchfork': '\\u22D4',\n 'forkv': '\\u2AD9',\n 'fpartint': '\\u2A0D',\n 'frac12': '\\u00BD',\n 'half': '\\u00BD',\n 'frac13': '\\u2153',\n 'frac14': '\\u00BC',\n 'frac15': '\\u2155',\n 'frac16': '\\u2159',\n 'frac18': '\\u215B',\n 'frac23': '\\u2154',\n 'frac25': '\\u2156',\n 'frac34': '\\u00BE',\n 'frac35': '\\u2157',\n 'frac38': '\\u215C',\n 'frac45': '\\u2158',\n 'frac56': '\\u215A',\n 'frac58': '\\u215D',\n 'frac78': '\\u215E',\n 'frasl': '\\u2044',\n 'frown': '\\u2322',\n 'sfrown': '\\u2322',\n 'fscr': '\\uD835\\uDCBB',\n 'gEl': '\\u2A8C',\n 'gtreqqless': '\\u2A8C',\n 'gacute': '\\u01F5',\n 'gamma': '\\u03B3',\n 'gap': '\\u2A86',\n 'gtrapprox': '\\u2A86',\n 'gbreve': '\\u011F',\n 'gcirc': '\\u011D',\n 'gcy': '\\u0433',\n 'gdot': '\\u0121',\n 'gescc': '\\u2AA9',\n 'gesdot': '\\u2A80',\n 'gesdoto': '\\u2A82',\n 'gesdotol': '\\u2A84',\n 'gesl': '\\u22DB\\uFE00',\n 'gesles': '\\u2A94',\n 'gfr': '\\uD835\\uDD24',\n 'gimel': '\\u2137',\n 'gjcy': '\\u0453',\n 'glE': '\\u2A92',\n 'gla': '\\u2AA5',\n 'glj': '\\u2AA4',\n 'gnE': '\\u2269',\n 'gneqq': '\\u2269',\n 'gnap': '\\u2A8A',\n 'gnapprox': '\\u2A8A',\n 'gne': '\\u2A88',\n 'gneq': '\\u2A88',\n 'gnsim': '\\u22E7',\n 'gopf': '\\uD835\\uDD58',\n 'gscr': '\\u210A',\n 'gsime': '\\u2A8E',\n 'gsiml': '\\u2A90',\n 'gtcc': '\\u2AA7',\n 'gtcir': '\\u2A7A',\n 'gtdot': '\\u22D7',\n 'gtrdot': '\\u22D7',\n 'gtlPar': '\\u2995',\n 'gtquest': '\\u2A7C',\n 'gtrarr': '\\u2978',\n 'gvertneqq': '\\u2269\\uFE00',\n 'gvnE': '\\u2269\\uFE00',\n 'hardcy': '\\u044A',\n 'harrcir': '\\u2948',\n 'harrw': '\\u21AD',\n 'leftrightsquigarrow': '\\u21AD',\n 'hbar': '\\u210F',\n 'hslash': '\\u210F',\n 'planck': '\\u210F',\n 'plankv': '\\u210F',\n 'hcirc': '\\u0125',\n 'hearts': '\\u2665',\n 'heartsuit': '\\u2665',\n 'hellip': '\\u2026',\n 'mldr': '\\u2026',\n 'hercon': '\\u22B9',\n 'hfr': '\\uD835\\uDD25',\n 'hksearow': '\\u2925',\n 'searhk': '\\u2925',\n 'hkswarow': '\\u2926',\n 'swarhk': '\\u2926',\n 'hoarr': '\\u21FF',\n 'homtht': '\\u223B',\n 'hookleftarrow': '\\u21A9',\n 'larrhk': '\\u21A9',\n 'hookrightarrow': '\\u21AA',\n 'rarrhk': '\\u21AA',\n 'hopf': '\\uD835\\uDD59',\n 'horbar': '\\u2015',\n 'hscr': '\\uD835\\uDCBD',\n 'hstrok': '\\u0127',\n 'hybull': '\\u2043',\n 'iacute': '\\u00ED',\n 'icirc': '\\u00EE',\n 'icy': '\\u0438',\n 'iecy': '\\u0435',\n 'iexcl': '\\u00A1',\n 'ifr': '\\uD835\\uDD26',\n 'igrave': '\\u00EC',\n 'iiiint': '\\u2A0C',\n 'qint': '\\u2A0C',\n 'iiint': '\\u222D',\n 'tint': '\\u222D',\n 'iinfin': '\\u29DC',\n 'iiota': '\\u2129',\n 'ijlig': '\\u0133',\n 'imacr': '\\u012B',\n 'imath': '\\u0131',\n 'inodot': '\\u0131',\n 'imof': '\\u22B7',\n 'imped': '\\u01B5',\n 'incare': '\\u2105',\n 'infin': '\\u221E',\n 'infintie': '\\u29DD',\n 'intcal': '\\u22BA',\n 'intercal': '\\u22BA',\n 'intlarhk': '\\u2A17',\n 'intprod': '\\u2A3C',\n 'iprod': '\\u2A3C',\n 'iocy': '\\u0451',\n 'iogon': '\\u012F',\n 'iopf': '\\uD835\\uDD5A',\n 'iota': '\\u03B9',\n 'iquest': '\\u00BF',\n 'iscr': '\\uD835\\uDCBE',\n 'isinE': '\\u22F9',\n 'isindot': '\\u22F5',\n 'isins': '\\u22F4',\n 'isinsv': '\\u22F3',\n 'itilde': '\\u0129',\n 'iukcy': '\\u0456',\n 'iuml': '\\u00EF',\n 'jcirc': '\\u0135',\n 'jcy': '\\u0439',\n 'jfr': '\\uD835\\uDD27',\n 'jmath': '\\u0237',\n 'jopf': '\\uD835\\uDD5B',\n 'jscr': '\\uD835\\uDCBF',\n 'jsercy': '\\u0458',\n 'jukcy': '\\u0454',\n 'kappa': '\\u03BA',\n 'kappav': '\\u03F0',\n 'varkappa': '\\u03F0',\n 'kcedil': '\\u0137',\n 'kcy': '\\u043A',\n 'kfr': '\\uD835\\uDD28',\n 'kgreen': '\\u0138',\n 'khcy': '\\u0445',\n 'kjcy': '\\u045C',\n 'kopf': '\\uD835\\uDD5C',\n 'kscr': '\\uD835\\uDCC0',\n 'lAtail': '\\u291B',\n 'lBarr': '\\u290E',\n 'lEg': '\\u2A8B',\n 'lesseqqgtr': '\\u2A8B',\n 'lHar': '\\u2962',\n 'lacute': '\\u013A',\n 'laemptyv': '\\u29B4',\n 'lambda': '\\u03BB',\n 'langd': '\\u2991',\n 'lap': '\\u2A85',\n 'lessapprox': '\\u2A85',\n 'laquo': '\\u00AB',\n 'larrbfs': '\\u291F',\n 'larrfs': '\\u291D',\n 'larrlp': '\\u21AB',\n 'looparrowleft': '\\u21AB',\n 'larrpl': '\\u2939',\n 'larrsim': '\\u2973',\n 'larrtl': '\\u21A2',\n 'leftarrowtail': '\\u21A2',\n 'lat': '\\u2AAB',\n 'latail': '\\u2919',\n 'late': '\\u2AAD',\n 'lates': '\\u2AAD\\uFE00',\n 'lbarr': '\\u290C',\n 'lbbrk': '\\u2772',\n 'lbrace': '\\u007B',\n 'lcub': '\\u007B',\n 'lbrack': '\\u005B',\n 'lsqb': '\\u005B',\n 'lbrke': '\\u298B',\n 'lbrksld': '\\u298F',\n 'lbrkslu': '\\u298D',\n 'lcaron': '\\u013E',\n 'lcedil': '\\u013C',\n 'lcy': '\\u043B',\n 'ldca': '\\u2936',\n 'ldrdhar': '\\u2967',\n 'ldrushar': '\\u294B',\n 'ldsh': '\\u21B2',\n 'le': '\\u2264',\n 'leq': '\\u2264',\n 'leftleftarrows': '\\u21C7',\n 'llarr': '\\u21C7',\n 'leftthreetimes': '\\u22CB',\n 'lthree': '\\u22CB',\n 'lescc': '\\u2AA8',\n 'lesdot': '\\u2A7F',\n 'lesdoto': '\\u2A81',\n 'lesdotor': '\\u2A83',\n 'lesg': '\\u22DA\\uFE00',\n 'lesges': '\\u2A93',\n 'lessdot': '\\u22D6',\n 'ltdot': '\\u22D6',\n 'lfisht': '\\u297C',\n 'lfr': '\\uD835\\uDD29',\n 'lgE': '\\u2A91',\n 'lharul': '\\u296A',\n 'lhblk': '\\u2584',\n 'ljcy': '\\u0459',\n 'llhard': '\\u296B',\n 'lltri': '\\u25FA',\n 'lmidot': '\\u0140',\n 'lmoust': '\\u23B0',\n 'lmoustache': '\\u23B0',\n 'lnE': '\\u2268',\n 'lneqq': '\\u2268',\n 'lnap': '\\u2A89',\n 'lnapprox': '\\u2A89',\n 'lne': '\\u2A87',\n 'lneq': '\\u2A87',\n 'lnsim': '\\u22E6',\n 'loang': '\\u27EC',\n 'loarr': '\\u21FD',\n 'longmapsto': '\\u27FC',\n 'xmap': '\\u27FC',\n 'looparrowright': '\\u21AC',\n 'rarrlp': '\\u21AC',\n 'lopar': '\\u2985',\n 'lopf': '\\uD835\\uDD5D',\n 'loplus': '\\u2A2D',\n 'lotimes': '\\u2A34',\n 'lowast': '\\u2217',\n 'loz': '\\u25CA',\n 'lozenge': '\\u25CA',\n 'lpar': '\\u0028',\n 'lparlt': '\\u2993',\n 'lrhard': '\\u296D',\n 'lrm': '\\u200E',\n 'lrtri': '\\u22BF',\n 'lsaquo': '\\u2039',\n 'lscr': '\\uD835\\uDCC1',\n 'lsime': '\\u2A8D',\n 'lsimg': '\\u2A8F',\n 'lsquor': '\\u201A',\n 'sbquo': '\\u201A',\n 'lstrok': '\\u0142',\n 'ltcc': '\\u2AA6',\n 'ltcir': '\\u2A79',\n 'ltimes': '\\u22C9',\n 'ltlarr': '\\u2976',\n 'ltquest': '\\u2A7B',\n 'ltrPar': '\\u2996',\n 'ltri': '\\u25C3',\n 'triangleleft': '\\u25C3',\n 'lurdshar': '\\u294A',\n 'luruhar': '\\u2966',\n 'lvertneqq': '\\u2268\\uFE00',\n 'lvnE': '\\u2268\\uFE00',\n 'mDDot': '\\u223A',\n 'macr': '\\u00AF',\n 'strns': '\\u00AF',\n 'male': '\\u2642',\n 'malt': '\\u2720',\n 'maltese': '\\u2720',\n 'marker': '\\u25AE',\n 'mcomma': '\\u2A29',\n 'mcy': '\\u043C',\n 'mdash': '\\u2014',\n 'mfr': '\\uD835\\uDD2A',\n 'mho': '\\u2127',\n 'micro': '\\u00B5',\n 'midcir': '\\u2AF0',\n 'minus': '\\u2212',\n 'minusdu': '\\u2A2A',\n 'mlcp': '\\u2ADB',\n 'models': '\\u22A7',\n 'mopf': '\\uD835\\uDD5E',\n 'mscr': '\\uD835\\uDCC2',\n 'mu': '\\u03BC',\n 'multimap': '\\u22B8',\n 'mumap': '\\u22B8',\n 'nGg': '\\u22D9\\u0338',\n 'nGt': '\\u226B\\u20D2',\n 'nLeftarrow': '\\u21CD',\n 'nlArr': '\\u21CD',\n 'nLeftrightarrow': '\\u21CE',\n 'nhArr': '\\u21CE',\n 'nLl': '\\u22D8\\u0338',\n 'nLt': '\\u226A\\u20D2',\n 'nRightarrow': '\\u21CF',\n 'nrArr': '\\u21CF',\n 'nVDash': '\\u22AF',\n 'nVdash': '\\u22AE',\n 'nacute': '\\u0144',\n 'nang': '\\u2220\\u20D2',\n 'napE': '\\u2A70\\u0338',\n 'napid': '\\u224B\\u0338',\n 'napos': '\\u0149',\n 'natur': '\\u266E',\n 'natural': '\\u266E',\n 'ncap': '\\u2A43',\n 'ncaron': '\\u0148',\n 'ncedil': '\\u0146',\n 'ncongdot': '\\u2A6D\\u0338',\n 'ncup': '\\u2A42',\n 'ncy': '\\u043D',\n 'ndash': '\\u2013',\n 'neArr': '\\u21D7',\n 'nearhk': '\\u2924',\n 'nedot': '\\u2250\\u0338',\n 'nesear': '\\u2928',\n 'toea': '\\u2928',\n 'nfr': '\\uD835\\uDD2B',\n 'nharr': '\\u21AE',\n 'nleftrightarrow': '\\u21AE',\n 'nhpar': '\\u2AF2',\n 'nis': '\\u22FC',\n 'nisd': '\\u22FA',\n 'njcy': '\\u045A',\n 'nlE': '\\u2266\\u0338',\n 'nleqq': '\\u2266\\u0338',\n 'nlarr': '\\u219A',\n 'nleftarrow': '\\u219A',\n 'nldr': '\\u2025',\n 'nopf': '\\uD835\\uDD5F',\n 'not': '\\u00AC',\n 'notinE': '\\u22F9\\u0338',\n 'notindot': '\\u22F5\\u0338',\n 'notinvb': '\\u22F7',\n 'notinvc': '\\u22F6',\n 'notnivb': '\\u22FE',\n 'notnivc': '\\u22FD',\n 'nparsl': '\\u2AFD\\u20E5',\n 'npart': '\\u2202\\u0338',\n 'npolint': '\\u2A14',\n 'nrarr': '\\u219B',\n 'nrightarrow': '\\u219B',\n 'nrarrc': '\\u2933\\u0338',\n 'nrarrw': '\\u219D\\u0338',\n 'nscr': '\\uD835\\uDCC3',\n 'nsub': '\\u2284',\n 'nsubE': '\\u2AC5\\u0338',\n 'nsubseteqq': '\\u2AC5\\u0338',\n 'nsup': '\\u2285',\n 'nsupE': '\\u2AC6\\u0338',\n 'nsupseteqq': '\\u2AC6\\u0338',\n 'ntilde': '\\u00F1',\n 'nu': '\\u03BD',\n 'num': '\\u0023',\n 'numero': '\\u2116',\n 'numsp': '\\u2007',\n 'nvDash': '\\u22AD',\n 'nvHarr': '\\u2904',\n 'nvap': '\\u224D\\u20D2',\n 'nvdash': '\\u22AC',\n 'nvge': '\\u2265\\u20D2',\n 'nvgt': '\\u003E\\u20D2',\n 'nvinfin': '\\u29DE',\n 'nvlArr': '\\u2902',\n 'nvle': '\\u2264\\u20D2',\n 'nvlt': '\\u003C\\u20D2',\n 'nvltrie': '\\u22B4\\u20D2',\n 'nvrArr': '\\u2903',\n 'nvrtrie': '\\u22B5\\u20D2',\n 'nvsim': '\\u223C\\u20D2',\n 'nwArr': '\\u21D6',\n 'nwarhk': '\\u2923',\n 'nwnear': '\\u2927',\n 'oacute': '\\u00F3',\n 'ocirc': '\\u00F4',\n 'ocy': '\\u043E',\n 'odblac': '\\u0151',\n 'odiv': '\\u2A38',\n 'odsold': '\\u29BC',\n 'oelig': '\\u0153',\n 'ofcir': '\\u29BF',\n 'ofr': '\\uD835\\uDD2C',\n 'ogon': '\\u02DB',\n 'ograve': '\\u00F2',\n 'ogt': '\\u29C1',\n 'ohbar': '\\u29B5',\n 'olcir': '\\u29BE',\n 'olcross': '\\u29BB',\n 'olt': '\\u29C0',\n 'omacr': '\\u014D',\n 'omega': '\\u03C9',\n 'omicron': '\\u03BF',\n 'omid': '\\u29B6',\n 'oopf': '\\uD835\\uDD60',\n 'opar': '\\u29B7',\n 'operp': '\\u29B9',\n 'or': '\\u2228',\n 'vee': '\\u2228',\n 'ord': '\\u2A5D',\n 'order': '\\u2134',\n 'orderof': '\\u2134',\n 'oscr': '\\u2134',\n 'ordf': '\\u00AA',\n 'ordm': '\\u00BA',\n 'origof': '\\u22B6',\n 'oror': '\\u2A56',\n 'orslope': '\\u2A57',\n 'orv': '\\u2A5B',\n 'oslash': '\\u00F8',\n 'osol': '\\u2298',\n 'otilde': '\\u00F5',\n 'otimesas': '\\u2A36',\n 'ouml': '\\u00F6',\n 'ovbar': '\\u233D',\n 'para': '\\u00B6',\n 'parsim': '\\u2AF3',\n 'parsl': '\\u2AFD',\n 'pcy': '\\u043F',\n 'percnt': '\\u0025',\n 'period': '\\u002E',\n 'permil': '\\u2030',\n 'pertenk': '\\u2031',\n 'pfr': '\\uD835\\uDD2D',\n 'phi': '\\u03C6',\n 'phiv': '\\u03D5',\n 'straightphi': '\\u03D5',\n 'varphi': '\\u03D5',\n 'phone': '\\u260E',\n 'pi': '\\u03C0',\n 'piv': '\\u03D6',\n 'varpi': '\\u03D6',\n 'planckh': '\\u210E',\n 'plus': '\\u002B',\n 'plusacir': '\\u2A23',\n 'pluscir': '\\u2A22',\n 'plusdu': '\\u2A25',\n 'pluse': '\\u2A72',\n 'plussim': '\\u2A26',\n 'plustwo': '\\u2A27',\n 'pointint': '\\u2A15',\n 'popf': '\\uD835\\uDD61',\n 'pound': '\\u00A3',\n 'prE': '\\u2AB3',\n 'prap': '\\u2AB7',\n 'precapprox': '\\u2AB7',\n 'precnapprox': '\\u2AB9',\n 'prnap': '\\u2AB9',\n 'precneqq': '\\u2AB5',\n 'prnE': '\\u2AB5',\n 'precnsim': '\\u22E8',\n 'prnsim': '\\u22E8',\n 'prime': '\\u2032',\n 'profalar': '\\u232E',\n 'profline': '\\u2312',\n 'profsurf': '\\u2313',\n 'prurel': '\\u22B0',\n 'pscr': '\\uD835\\uDCC5',\n 'psi': '\\u03C8',\n 'puncsp': '\\u2008',\n 'qfr': '\\uD835\\uDD2E',\n 'qopf': '\\uD835\\uDD62',\n 'qprime': '\\u2057',\n 'qscr': '\\uD835\\uDCC6',\n 'quatint': '\\u2A16',\n 'quest': '\\u003F',\n 'rAtail': '\\u291C',\n 'rHar': '\\u2964',\n 'race': '\\u223D\\u0331',\n 'racute': '\\u0155',\n 'raemptyv': '\\u29B3',\n 'rangd': '\\u2992',\n 'range': '\\u29A5',\n 'raquo': '\\u00BB',\n 'rarrap': '\\u2975',\n 'rarrbfs': '\\u2920',\n 'rarrc': '\\u2933',\n 'rarrfs': '\\u291E',\n 'rarrpl': '\\u2945',\n 'rarrsim': '\\u2974',\n 'rarrtl': '\\u21A3',\n 'rightarrowtail': '\\u21A3',\n 'rarrw': '\\u219D',\n 'rightsquigarrow': '\\u219D',\n 'ratail': '\\u291A',\n 'ratio': '\\u2236',\n 'rbbrk': '\\u2773',\n 'rbrace': '\\u007D',\n 'rcub': '\\u007D',\n 'rbrack': '\\u005D',\n 'rsqb': '\\u005D',\n 'rbrke': '\\u298C',\n 'rbrksld': '\\u298E',\n 'rbrkslu': '\\u2990',\n 'rcaron': '\\u0159',\n 'rcedil': '\\u0157',\n 'rcy': '\\u0440',\n 'rdca': '\\u2937',\n 'rdldhar': '\\u2969',\n 'rdsh': '\\u21B3',\n 'rect': '\\u25AD',\n 'rfisht': '\\u297D',\n 'rfr': '\\uD835\\uDD2F',\n 'rharul': '\\u296C',\n 'rho': '\\u03C1',\n 'rhov': '\\u03F1',\n 'varrho': '\\u03F1',\n 'rightrightarrows': '\\u21C9',\n 'rrarr': '\\u21C9',\n 'rightthreetimes': '\\u22CC',\n 'rthree': '\\u22CC',\n 'ring': '\\u02DA',\n 'rlm': '\\u200F',\n 'rmoust': '\\u23B1',\n 'rmoustache': '\\u23B1',\n 'rnmid': '\\u2AEE',\n 'roang': '\\u27ED',\n 'roarr': '\\u21FE',\n 'ropar': '\\u2986',\n 'ropf': '\\uD835\\uDD63',\n 'roplus': '\\u2A2E',\n 'rotimes': '\\u2A35',\n 'rpar': '\\u0029',\n 'rpargt': '\\u2994',\n 'rppolint': '\\u2A12',\n 'rsaquo': '\\u203A',\n 'rscr': '\\uD835\\uDCC7',\n 'rtimes': '\\u22CA',\n 'rtri': '\\u25B9',\n 'triangleright': '\\u25B9',\n 'rtriltri': '\\u29CE',\n 'ruluhar': '\\u2968',\n 'rx': '\\u211E',\n 'sacute': '\\u015B',\n 'scE': '\\u2AB4',\n 'scap': '\\u2AB8',\n 'succapprox': '\\u2AB8',\n 'scaron': '\\u0161',\n 'scedil': '\\u015F',\n 'scirc': '\\u015D',\n 'scnE': '\\u2AB6',\n 'succneqq': '\\u2AB6',\n 'scnap': '\\u2ABA',\n 'succnapprox': '\\u2ABA',\n 'scnsim': '\\u22E9',\n 'succnsim': '\\u22E9',\n 'scpolint': '\\u2A13',\n 'scy': '\\u0441',\n 'sdot': '\\u22C5',\n 'sdote': '\\u2A66',\n 'seArr': '\\u21D8',\n 'sect': '\\u00A7',\n 'semi': '\\u003B',\n 'seswar': '\\u2929',\n 'tosa': '\\u2929',\n 'sext': '\\u2736',\n 'sfr': '\\uD835\\uDD30',\n 'sharp': '\\u266F',\n 'shchcy': '\\u0449',\n 'shcy': '\\u0448',\n 'shy': '\\u00AD',\n 'sigma': '\\u03C3',\n 'sigmaf': '\\u03C2',\n 'sigmav': '\\u03C2',\n 'varsigma': '\\u03C2',\n 'simdot': '\\u2A6A',\n 'simg': '\\u2A9E',\n 'simgE': '\\u2AA0',\n 'siml': '\\u2A9D',\n 'simlE': '\\u2A9F',\n 'simne': '\\u2246',\n 'simplus': '\\u2A24',\n 'simrarr': '\\u2972',\n 'smashp': '\\u2A33',\n 'smeparsl': '\\u29E4',\n 'smile': '\\u2323',\n 'ssmile': '\\u2323',\n 'smt': '\\u2AAA',\n 'smte': '\\u2AAC',\n 'smtes': '\\u2AAC\\uFE00',\n 'softcy': '\\u044C',\n 'sol': '\\u002F',\n 'solb': '\\u29C4',\n 'solbar': '\\u233F',\n 'sopf': '\\uD835\\uDD64',\n 'spades': '\\u2660',\n 'spadesuit': '\\u2660',\n 'sqcaps': '\\u2293\\uFE00',\n 'sqcups': '\\u2294\\uFE00',\n 'sscr': '\\uD835\\uDCC8',\n 'star': '\\u2606',\n 'sub': '\\u2282',\n 'subset': '\\u2282',\n 'subE': '\\u2AC5',\n 'subseteqq': '\\u2AC5',\n 'subdot': '\\u2ABD',\n 'subedot': '\\u2AC3',\n 'submult': '\\u2AC1',\n 'subnE': '\\u2ACB',\n 'subsetneqq': '\\u2ACB',\n 'subne': '\\u228A',\n 'subsetneq': '\\u228A',\n 'subplus': '\\u2ABF',\n 'subrarr': '\\u2979',\n 'subsim': '\\u2AC7',\n 'subsub': '\\u2AD5',\n 'subsup': '\\u2AD3',\n 'sung': '\\u266A',\n 'sup1': '\\u00B9',\n 'sup2': '\\u00B2',\n 'sup3': '\\u00B3',\n 'supE': '\\u2AC6',\n 'supseteqq': '\\u2AC6',\n 'supdot': '\\u2ABE',\n 'supdsub': '\\u2AD8',\n 'supedot': '\\u2AC4',\n 'suphsol': '\\u27C9',\n 'suphsub': '\\u2AD7',\n 'suplarr': '\\u297B',\n 'supmult': '\\u2AC2',\n 'supnE': '\\u2ACC',\n 'supsetneqq': '\\u2ACC',\n 'supne': '\\u228B',\n 'supsetneq': '\\u228B',\n 'supplus': '\\u2AC0',\n 'supsim': '\\u2AC8',\n 'supsub': '\\u2AD4',\n 'supsup': '\\u2AD6',\n 'swArr': '\\u21D9',\n 'swnwar': '\\u292A',\n 'szlig': '\\u00DF',\n 'target': '\\u2316',\n 'tau': '\\u03C4',\n 'tcaron': '\\u0165',\n 'tcedil': '\\u0163',\n 'tcy': '\\u0442',\n 'telrec': '\\u2315',\n 'tfr': '\\uD835\\uDD31',\n 'theta': '\\u03B8',\n 'thetasym': '\\u03D1',\n 'thetav': '\\u03D1',\n 'vartheta': '\\u03D1',\n 'thorn': '\\u00FE',\n 'times': '\\u00D7',\n 'timesbar': '\\u2A31',\n 'timesd': '\\u2A30',\n 'topbot': '\\u2336',\n 'topcir': '\\u2AF1',\n 'topf': '\\uD835\\uDD65',\n 'topfork': '\\u2ADA',\n 'tprime': '\\u2034',\n 'triangle': '\\u25B5',\n 'utri': '\\u25B5',\n 'triangleq': '\\u225C',\n 'trie': '\\u225C',\n 'tridot': '\\u25EC',\n 'triminus': '\\u2A3A',\n 'triplus': '\\u2A39',\n 'trisb': '\\u29CD',\n 'tritime': '\\u2A3B',\n 'trpezium': '\\u23E2',\n 'tscr': '\\uD835\\uDCC9',\n 'tscy': '\\u0446',\n 'tshcy': '\\u045B',\n 'tstrok': '\\u0167',\n 'uHar': '\\u2963',\n 'uacute': '\\u00FA',\n 'ubrcy': '\\u045E',\n 'ubreve': '\\u016D',\n 'ucirc': '\\u00FB',\n 'ucy': '\\u0443',\n 'udblac': '\\u0171',\n 'ufisht': '\\u297E',\n 'ufr': '\\uD835\\uDD32',\n 'ugrave': '\\u00F9',\n 'uhblk': '\\u2580',\n 'ulcorn': '\\u231C',\n 'ulcorner': '\\u231C',\n 'ulcrop': '\\u230F',\n 'ultri': '\\u25F8',\n 'umacr': '\\u016B',\n 'uogon': '\\u0173',\n 'uopf': '\\uD835\\uDD66',\n 'upsi': '\\u03C5',\n 'upsilon': '\\u03C5',\n 'upuparrows': '\\u21C8',\n 'uuarr': '\\u21C8',\n 'urcorn': '\\u231D',\n 'urcorner': '\\u231D',\n 'urcrop': '\\u230E',\n 'uring': '\\u016F',\n 'urtri': '\\u25F9',\n 'uscr': '\\uD835\\uDCCA',\n 'utdot': '\\u22F0',\n 'utilde': '\\u0169',\n 'uuml': '\\u00FC',\n 'uwangle': '\\u29A7',\n 'vBar': '\\u2AE8',\n 'vBarv': '\\u2AE9',\n 'vangrt': '\\u299C',\n 'varsubsetneq': '\\u228A\\uFE00',\n 'vsubne': '\\u228A\\uFE00',\n 'varsubsetneqq': '\\u2ACB\\uFE00',\n 'vsubnE': '\\u2ACB\\uFE00',\n 'varsupsetneq': '\\u228B\\uFE00',\n 'vsupne': '\\u228B\\uFE00',\n 'varsupsetneqq': '\\u2ACC\\uFE00',\n 'vsupnE': '\\u2ACC\\uFE00',\n 'vcy': '\\u0432',\n 'veebar': '\\u22BB',\n 'veeeq': '\\u225A',\n 'vellip': '\\u22EE',\n 'vfr': '\\uD835\\uDD33',\n 'vopf': '\\uD835\\uDD67',\n 'vscr': '\\uD835\\uDCCB',\n 'vzigzag': '\\u299A',\n 'wcirc': '\\u0175',\n 'wedbar': '\\u2A5F',\n 'wedgeq': '\\u2259',\n 'weierp': '\\u2118',\n 'wp': '\\u2118',\n 'wfr': '\\uD835\\uDD34',\n 'wopf': '\\uD835\\uDD68',\n 'wscr': '\\uD835\\uDCCC',\n 'xfr': '\\uD835\\uDD35',\n 'xi': '\\u03BE',\n 'xnis': '\\u22FB',\n 'xopf': '\\uD835\\uDD69',\n 'xscr': '\\uD835\\uDCCD',\n 'yacute': '\\u00FD',\n 'yacy': '\\u044F',\n 'ycirc': '\\u0177',\n 'ycy': '\\u044B',\n 'yen': '\\u00A5',\n 'yfr': '\\uD835\\uDD36',\n 'yicy': '\\u0457',\n 'yopf': '\\uD835\\uDD6A',\n 'yscr': '\\uD835\\uDCCE',\n 'yucy': '\\u044E',\n 'yuml': '\\u00FF',\n 'zacute': '\\u017A',\n 'zcaron': '\\u017E',\n 'zcy': '\\u0437',\n 'zdot': '\\u017C',\n 'zeta': '\\u03B6',\n 'zfr': '\\uD835\\uDD37',\n 'zhcy': '\\u0436',\n 'zigrarr': '\\u21DD',\n 'zopf': '\\uD835\\uDD6B',\n 'zscr': '\\uD835\\uDCCF',\n 'zwj': '\\u200D',\n 'zwnj': '\\u200C',\n};\n\n// The &ngsp; pseudo-entity is denoting a space.\n// 0xE500 is a PUA (Private Use Areas) unicode character\n// This is inspired by the Angular Dart implementation.\nexport const NGSP_UNICODE = '\\uE500';\n\nNAMED_ENTITIES['ngsp'] = NGSP_UNICODE;\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as chars from '../chars';\nimport {ParseError, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../parse_util';\n\nimport {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from './defaults';\nimport {NAMED_ENTITIES} from './entities';\nimport {TagContentType, TagDefinition} from './tags';\nimport {IncompleteTagOpenToken, TagOpenStartToken, Token, TokenType} from './tokens';\n\nexport class TokenError extends ParseError {\n constructor(\n errorMsg: string,\n public tokenType: TokenType | null,\n span: ParseSourceSpan,\n ) {\n super(span, errorMsg);\n }\n}\n\nexport class TokenizeResult {\n constructor(\n public tokens: Token[],\n public errors: TokenError[],\n public nonNormalizedIcuExpressions: Token[],\n ) {}\n}\n\nexport interface LexerRange {\n startPos: number;\n startLine: number;\n startCol: number;\n endPos: number;\n}\n\n/**\n * Options that modify how the text is tokenized.\n */\nexport interface TokenizeOptions {\n /** Whether to tokenize ICU messages (considered as text nodes when false). */\n tokenizeExpansionForms?: boolean;\n /** How to tokenize interpolation markers. */\n interpolationConfig?: InterpolationConfig;\n /**\n * The start and end point of the text to parse within the `source` string.\n * The entire `source` string is parsed if this is not provided.\n * */\n range?: LexerRange;\n /**\n * If this text is stored in a JavaScript string, then we have to deal with escape sequences.\n *\n * **Example 1:**\n *\n * ```\n * \"abc\\\"def\\nghi\"\n * ```\n *\n * - The `\\\"` must be converted to `\"`.\n * - The `\\n` must be converted to a new line character in a token,\n * but it should not increment the current line for source mapping.\n *\n * **Example 2:**\n *\n * ```\n * \"abc\\\n * def\"\n * ```\n *\n * The line continuation (`\\` followed by a newline) should be removed from a token\n * but the new line should increment the current line for source mapping.\n */\n escapedString?: boolean;\n /**\n * If this text is stored in an external template (e.g. via `templateUrl`) then we need to decide\n * whether or not to normalize the line-endings (from `\\r\\n` to `\\n`) when processing ICU\n * expressions.\n *\n * If `true` then we will normalize ICU expression line endings.\n * The default is `false`, but this will be switched in a future major release.\n */\n i18nNormalizeLineEndingsInICUs?: boolean;\n /**\n * An array of characters that should be considered as leading trivia.\n * Leading trivia are characters that are not important to the developer, and so should not be\n * included in source-map segments. A common example is whitespace.\n */\n leadingTriviaChars?: string[];\n /**\n * If true, do not convert CRLF to LF.\n */\n preserveLineEndings?: boolean;\n\n /**\n * Whether to tokenize @ block syntax. Otherwise considered text,\n * or ICU tokens if `tokenizeExpansionForms` is enabled.\n */\n tokenizeBlocks?: boolean;\n\n /**\n * Whether to tokenize the `@let` syntax. Otherwise will be considered either\n * text or an incomplete block, depending on whether `tokenizeBlocks` is enabled.\n */\n tokenizeLet?: boolean;\n}\n\nexport function tokenize(\n source: string,\n url: string,\n getTagDefinition: (tagName: string) => TagDefinition,\n options: TokenizeOptions = {},\n): TokenizeResult {\n const tokenizer = new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, options);\n tokenizer.tokenize();\n return new TokenizeResult(\n mergeTextTokens(tokenizer.tokens),\n tokenizer.errors,\n tokenizer.nonNormalizedIcuExpressions,\n );\n}\n\nconst _CR_OR_CRLF_REGEXP = /\\r\\n?/g;\n\nfunction _unexpectedCharacterErrorMsg(charCode: number): string {\n const char = charCode === chars.$EOF ? 'EOF' : String.fromCharCode(charCode);\n return `Unexpected character \"${char}\"`;\n}\n\nfunction _unknownEntityErrorMsg(entitySrc: string): string {\n return `Unknown entity \"${entitySrc}\" - use the \"&#;\" or \"&#x;\" syntax`;\n}\n\nfunction _unparsableEntityErrorMsg(type: CharacterReferenceType, entityStr: string): string {\n return `Unable to parse entity \"${entityStr}\" - ${type} character reference entities must end with \";\"`;\n}\n\nenum CharacterReferenceType {\n HEX = 'hexadecimal',\n DEC = 'decimal',\n}\n\nclass _ControlFlowError {\n constructor(public error: TokenError) {}\n}\n\n// See https://www.w3.org/TR/html51/syntax.html#writing-html-documents\nclass _Tokenizer {\n private _cursor: CharacterCursor;\n private _tokenizeIcu: boolean;\n private _interpolationConfig: InterpolationConfig;\n private _leadingTriviaCodePoints: number[] | undefined;\n private _currentTokenStart: CharacterCursor | null = null;\n private _currentTokenType: TokenType | null = null;\n private _expansionCaseStack: TokenType[] = [];\n private _inInterpolation: boolean = false;\n private readonly _preserveLineEndings: boolean;\n private readonly _i18nNormalizeLineEndingsInICUs: boolean;\n private readonly _tokenizeBlocks: boolean;\n private readonly _tokenizeLet: boolean;\n tokens: Token[] = [];\n errors: TokenError[] = [];\n nonNormalizedIcuExpressions: Token[] = [];\n\n /**\n * @param _file The html source file being tokenized.\n * @param _getTagDefinition A function that will retrieve a tag definition for a given tag name.\n * @param options Configuration of the tokenization.\n */\n constructor(\n _file: ParseSourceFile,\n private _getTagDefinition: (tagName: string) => TagDefinition,\n options: TokenizeOptions,\n ) {\n this._tokenizeIcu = options.tokenizeExpansionForms || false;\n this._interpolationConfig = options.interpolationConfig || DEFAULT_INTERPOLATION_CONFIG;\n this._leadingTriviaCodePoints =\n options.leadingTriviaChars && options.leadingTriviaChars.map((c) => c.codePointAt(0) || 0);\n const range = options.range || {\n endPos: _file.content.length,\n startPos: 0,\n startLine: 0,\n startCol: 0,\n };\n this._cursor = options.escapedString\n ? new EscapedCharacterCursor(_file, range)\n : new PlainCharacterCursor(_file, range);\n this._preserveLineEndings = options.preserveLineEndings || false;\n this._i18nNormalizeLineEndingsInICUs = options.i18nNormalizeLineEndingsInICUs || false;\n this._tokenizeBlocks = options.tokenizeBlocks ?? true;\n this._tokenizeLet = options.tokenizeLet ?? true;\n try {\n this._cursor.init();\n } catch (e) {\n this.handleError(e);\n }\n }\n\n private _processCarriageReturns(content: string): string {\n if (this._preserveLineEndings) {\n return content;\n }\n // https://www.w3.org/TR/html51/syntax.html#preprocessing-the-input-stream\n // In order to keep the original position in the source, we can not\n // pre-process it.\n // Instead CRs are processed right before instantiating the tokens.\n return content.replace(_CR_OR_CRLF_REGEXP, '\\n');\n }\n\n tokenize(): void {\n while (this._cursor.peek() !== chars.$EOF) {\n const start = this._cursor.clone();\n try {\n if (this._attemptCharCode(chars.$LT)) {\n if (this._attemptCharCode(chars.$BANG)) {\n if (this._attemptCharCode(chars.$LBRACKET)) {\n this._consumeCdata(start);\n } else if (this._attemptCharCode(chars.$MINUS)) {\n this._consumeComment(start);\n } else {\n this._consumeDocType(start);\n }\n } else if (this._attemptCharCode(chars.$SLASH)) {\n this._consumeTagClose(start);\n } else {\n this._consumeTagOpen(start);\n }\n } else if (\n this._tokenizeLet &&\n // Use `peek` instead of `attempCharCode` since we\n // don't want to advance in case it's not `@let`.\n this._cursor.peek() === chars.$AT &&\n !this._inInterpolation &&\n this._attemptStr('@let')\n ) {\n this._consumeLetDeclaration(start);\n } else if (this._tokenizeBlocks && this._attemptCharCode(chars.$AT)) {\n this._consumeBlockStart(start);\n } else if (\n this._tokenizeBlocks &&\n !this._inInterpolation &&\n !this._isInExpansionCase() &&\n !this._isInExpansionForm() &&\n this._attemptCharCode(chars.$RBRACE)\n ) {\n this._consumeBlockEnd(start);\n } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {\n // In (possibly interpolated) text the end of the text is given by `isTextEnd()`, while\n // the premature end of an interpolation is given by the start of a new HTML element.\n this._consumeWithInterpolation(\n TokenType.TEXT,\n TokenType.INTERPOLATION,\n () => this._isTextEnd(),\n () => this._isTagStart(),\n );\n }\n } catch (e) {\n this.handleError(e);\n }\n }\n this._beginToken(TokenType.EOF);\n this._endToken([]);\n }\n\n private _getBlockName(): string {\n // This allows us to capture up something like `@else if`, but not `@ if`.\n let spacesInNameAllowed = false;\n const nameCursor = this._cursor.clone();\n\n this._attemptCharCodeUntilFn((code) => {\n if (chars.isWhitespace(code)) {\n return !spacesInNameAllowed;\n }\n if (isBlockNameChar(code)) {\n spacesInNameAllowed = true;\n return false;\n }\n return true;\n });\n return this._cursor.getChars(nameCursor).trim();\n }\n\n private _consumeBlockStart(start: CharacterCursor) {\n this._beginToken(TokenType.BLOCK_OPEN_START, start);\n const startToken = this._endToken([this._getBlockName()]);\n\n if (this._cursor.peek() === chars.$LPAREN) {\n // Advance past the opening paren.\n this._cursor.advance();\n // Capture the parameters.\n this._consumeBlockParameters();\n // Allow spaces before the closing paren.\n this._attemptCharCodeUntilFn(isNotWhitespace);\n\n if (this._attemptCharCode(chars.$RPAREN)) {\n // Allow spaces after the paren.\n this._attemptCharCodeUntilFn(isNotWhitespace);\n } else {\n startToken.type = TokenType.INCOMPLETE_BLOCK_OPEN;\n return;\n }\n }\n\n if (this._attemptCharCode(chars.$LBRACE)) {\n this._beginToken(TokenType.BLOCK_OPEN_END);\n this._endToken([]);\n } else {\n startToken.type = TokenType.INCOMPLETE_BLOCK_OPEN;\n }\n }\n\n private _consumeBlockEnd(start: CharacterCursor) {\n this._beginToken(TokenType.BLOCK_CLOSE, start);\n this._endToken([]);\n }\n\n private _consumeBlockParameters() {\n // Trim the whitespace until the first parameter.\n this._attemptCharCodeUntilFn(isBlockParameterChar);\n\n while (this._cursor.peek() !== chars.$RPAREN && this._cursor.peek() !== chars.$EOF) {\n this._beginToken(TokenType.BLOCK_PARAMETER);\n const start = this._cursor.clone();\n let inQuote: number | null = null;\n let openParens = 0;\n\n // Consume the parameter until the next semicolon or brace.\n // Note that we skip over semicolons/braces inside of strings.\n while (\n (this._cursor.peek() !== chars.$SEMICOLON && this._cursor.peek() !== chars.$EOF) ||\n inQuote !== null\n ) {\n const char = this._cursor.peek();\n\n // Skip to the next character if it was escaped.\n if (char === chars.$BACKSLASH) {\n this._cursor.advance();\n } else if (char === inQuote) {\n inQuote = null;\n } else if (inQuote === null && chars.isQuote(char)) {\n inQuote = char;\n } else if (char === chars.$LPAREN && inQuote === null) {\n openParens++;\n } else if (char === chars.$RPAREN && inQuote === null) {\n if (openParens === 0) {\n break;\n } else if (openParens > 0) {\n openParens--;\n }\n }\n\n this._cursor.advance();\n }\n\n this._endToken([this._cursor.getChars(start)]);\n\n // Skip to the next parameter.\n this._attemptCharCodeUntilFn(isBlockParameterChar);\n }\n }\n\n private _consumeLetDeclaration(start: CharacterCursor) {\n this._beginToken(TokenType.LET_START, start);\n\n // Require at least one white space after the `@let`.\n if (chars.isWhitespace(this._cursor.peek())) {\n this._attemptCharCodeUntilFn(isNotWhitespace);\n } else {\n const token = this._endToken([this._cursor.getChars(start)]);\n token.type = TokenType.INCOMPLETE_LET;\n return;\n }\n\n const startToken = this._endToken([this._getLetDeclarationName()]);\n\n // Skip over white space before the equals character.\n this._attemptCharCodeUntilFn(isNotWhitespace);\n\n // Expect an equals sign.\n if (!this._attemptCharCode(chars.$EQ)) {\n startToken.type = TokenType.INCOMPLETE_LET;\n return;\n }\n\n // Skip spaces after the equals.\n this._attemptCharCodeUntilFn((code) => isNotWhitespace(code) && !chars.isNewLine(code));\n this._consumeLetDeclarationValue();\n\n // Terminate the `@let` with a semicolon.\n const endChar = this._cursor.peek();\n if (endChar === chars.$SEMICOLON) {\n this._beginToken(TokenType.LET_END);\n this._endToken([]);\n this._cursor.advance();\n } else {\n startToken.type = TokenType.INCOMPLETE_LET;\n startToken.sourceSpan = this._cursor.getSpan(start);\n }\n }\n\n private _getLetDeclarationName(): string {\n const nameCursor = this._cursor.clone();\n let allowDigit = false;\n\n this._attemptCharCodeUntilFn((code) => {\n if (\n chars.isAsciiLetter(code) ||\n code === chars.$$ ||\n code === chars.$_ ||\n // `@let` names can't start with a digit, but digits are valid anywhere else in the name.\n (allowDigit && chars.isDigit(code))\n ) {\n allowDigit = true;\n return false;\n }\n return true;\n });\n\n return this._cursor.getChars(nameCursor).trim();\n }\n\n private _consumeLetDeclarationValue(): void {\n const start = this._cursor.clone();\n this._beginToken(TokenType.LET_VALUE, start);\n\n while (this._cursor.peek() !== chars.$EOF) {\n const char = this._cursor.peek();\n\n // `@let` declarations terminate with a semicolon.\n if (char === chars.$SEMICOLON) {\n break;\n }\n\n // If we hit a quote, skip over its content since we don't care what's inside.\n if (chars.isQuote(char)) {\n this._cursor.advance();\n this._attemptCharCodeUntilFn((inner) => {\n if (inner === chars.$BACKSLASH) {\n this._cursor.advance();\n return false;\n }\n return inner === char;\n });\n }\n\n this._cursor.advance();\n }\n\n this._endToken([this._cursor.getChars(start)]);\n }\n\n /**\n * @returns whether an ICU token has been created\n * @internal\n */\n private _tokenizeExpansionForm(): boolean {\n if (this.isExpansionFormStart()) {\n this._consumeExpansionFormStart();\n return true;\n }\n\n if (isExpansionCaseStart(this._cursor.peek()) && this._isInExpansionForm()) {\n this._consumeExpansionCaseStart();\n return true;\n }\n\n if (this._cursor.peek() === chars.$RBRACE) {\n if (this._isInExpansionCase()) {\n this._consumeExpansionCaseEnd();\n return true;\n }\n\n if (this._isInExpansionForm()) {\n this._consumeExpansionFormEnd();\n return true;\n }\n }\n\n return false;\n }\n\n private _beginToken(type: TokenType, start = this._cursor.clone()) {\n this._currentTokenStart = start;\n this._currentTokenType = type;\n }\n\n private _endToken(parts: string[], end?: CharacterCursor): Token {\n if (this._currentTokenStart === null) {\n throw new TokenError(\n 'Programming error - attempted to end a token when there was no start to the token',\n this._currentTokenType,\n this._cursor.getSpan(end),\n );\n }\n if (this._currentTokenType === null) {\n throw new TokenError(\n 'Programming error - attempted to end a token which has no token type',\n null,\n this._cursor.getSpan(this._currentTokenStart),\n );\n }\n const token = {\n type: this._currentTokenType,\n parts,\n sourceSpan: (end ?? this._cursor).getSpan(\n this._currentTokenStart,\n this._leadingTriviaCodePoints,\n ),\n } as Token;\n this.tokens.push(token);\n this._currentTokenStart = null;\n this._currentTokenType = null;\n return token;\n }\n\n private _createError(msg: string, span: ParseSourceSpan): _ControlFlowError {\n if (this._isInExpansionForm()) {\n msg += ` (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)`;\n }\n const error = new TokenError(msg, this._currentTokenType, span);\n this._currentTokenStart = null;\n this._currentTokenType = null;\n return new _ControlFlowError(error);\n }\n\n private handleError(e: any) {\n if (e instanceof CursorError) {\n e = this._createError(e.msg, this._cursor.getSpan(e.cursor));\n }\n if (e instanceof _ControlFlowError) {\n this.errors.push(e.error);\n } else {\n throw e;\n }\n }\n\n private _attemptCharCode(charCode: number): boolean {\n if (this._cursor.peek() === charCode) {\n this._cursor.advance();\n return true;\n }\n return false;\n }\n\n private _attemptCharCodeCaseInsensitive(charCode: number): boolean {\n if (compareCharCodeCaseInsensitive(this._cursor.peek(), charCode)) {\n this._cursor.advance();\n return true;\n }\n return false;\n }\n\n private _requireCharCode(charCode: number) {\n const location = this._cursor.clone();\n if (!this._attemptCharCode(charCode)) {\n throw this._createError(\n _unexpectedCharacterErrorMsg(this._cursor.peek()),\n this._cursor.getSpan(location),\n );\n }\n }\n\n private _attemptStr(chars: string): boolean {\n const len = chars.length;\n if (this._cursor.charsLeft() < len) {\n return false;\n }\n const initialPosition = this._cursor.clone();\n for (let i = 0; i < len; i++) {\n if (!this._attemptCharCode(chars.charCodeAt(i))) {\n // If attempting to parse the string fails, we want to reset the parser\n // to where it was before the attempt\n this._cursor = initialPosition;\n return false;\n }\n }\n return true;\n }\n\n private _attemptStrCaseInsensitive(chars: string): boolean {\n for (let i = 0; i < chars.length; i++) {\n if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) {\n return false;\n }\n }\n return true;\n }\n\n private _requireStr(chars: string) {\n const location = this._cursor.clone();\n if (!this._attemptStr(chars)) {\n throw this._createError(\n _unexpectedCharacterErrorMsg(this._cursor.peek()),\n this._cursor.getSpan(location),\n );\n }\n }\n\n private _attemptCharCodeUntilFn(predicate: (code: number) => boolean) {\n while (!predicate(this._cursor.peek())) {\n this._cursor.advance();\n }\n }\n\n private _requireCharCodeUntilFn(predicate: (code: number) => boolean, len: number) {\n const start = this._cursor.clone();\n this._attemptCharCodeUntilFn(predicate);\n if (this._cursor.diff(start) < len) {\n throw this._createError(\n _unexpectedCharacterErrorMsg(this._cursor.peek()),\n this._cursor.getSpan(start),\n );\n }\n }\n\n private _attemptUntilChar(char: number) {\n while (this._cursor.peek() !== char) {\n this._cursor.advance();\n }\n }\n\n private _readChar(): string {\n // Don't rely upon reading directly from `_input` as the actual char value\n // may have been generated from an escape sequence.\n const char = String.fromCodePoint(this._cursor.peek());\n this._cursor.advance();\n return char;\n }\n\n private _consumeEntity(textTokenType: TokenType): void {\n this._beginToken(TokenType.ENCODED_ENTITY);\n const start = this._cursor.clone();\n this._cursor.advance();\n if (this._attemptCharCode(chars.$HASH)) {\n const isHex = this._attemptCharCode(chars.$x) || this._attemptCharCode(chars.$X);\n const codeStart = this._cursor.clone();\n this._attemptCharCodeUntilFn(isDigitEntityEnd);\n if (this._cursor.peek() != chars.$SEMICOLON) {\n // Advance cursor to include the peeked character in the string provided to the error\n // message.\n this._cursor.advance();\n const entityType = isHex ? CharacterReferenceType.HEX : CharacterReferenceType.DEC;\n throw this._createError(\n _unparsableEntityErrorMsg(entityType, this._cursor.getChars(start)),\n this._cursor.getSpan(),\n );\n }\n const strNum = this._cursor.getChars(codeStart);\n this._cursor.advance();\n try {\n const charCode = parseInt(strNum, isHex ? 16 : 10);\n this._endToken([String.fromCharCode(charCode), this._cursor.getChars(start)]);\n } catch {\n throw this._createError(\n _unknownEntityErrorMsg(this._cursor.getChars(start)),\n this._cursor.getSpan(),\n );\n }\n } else {\n const nameStart = this._cursor.clone();\n this._attemptCharCodeUntilFn(isNamedEntityEnd);\n if (this._cursor.peek() != chars.$SEMICOLON) {\n // No semicolon was found so abort the encoded entity token that was in progress, and treat\n // this as a text token\n this._beginToken(textTokenType, start);\n this._cursor = nameStart;\n this._endToken(['&']);\n } else {\n const name = this._cursor.getChars(nameStart);\n this._cursor.advance();\n const char = NAMED_ENTITIES[name];\n if (!char) {\n throw this._createError(_unknownEntityErrorMsg(name), this._cursor.getSpan(start));\n }\n this._endToken([char, `&${name};`]);\n }\n }\n }\n\n private _consumeRawText(consumeEntities: boolean, endMarkerPredicate: () => boolean): void {\n this._beginToken(consumeEntities ? TokenType.ESCAPABLE_RAW_TEXT : TokenType.RAW_TEXT);\n const parts: string[] = [];\n while (true) {\n const tagCloseStart = this._cursor.clone();\n const foundEndMarker = endMarkerPredicate();\n this._cursor = tagCloseStart;\n if (foundEndMarker) {\n break;\n }\n if (consumeEntities && this._cursor.peek() === chars.$AMPERSAND) {\n this._endToken([this._processCarriageReturns(parts.join(''))]);\n parts.length = 0;\n this._consumeEntity(TokenType.ESCAPABLE_RAW_TEXT);\n this._beginToken(TokenType.ESCAPABLE_RAW_TEXT);\n } else {\n parts.push(this._readChar());\n }\n }\n this._endToken([this._processCarriageReturns(parts.join(''))]);\n }\n\n private _consumeComment(start: CharacterCursor) {\n this._beginToken(TokenType.COMMENT_START, start);\n this._requireCharCode(chars.$MINUS);\n this._endToken([]);\n this._consumeRawText(false, () => this._attemptStr('-->'));\n this._beginToken(TokenType.COMMENT_END);\n this._requireStr('-->');\n this._endToken([]);\n }\n\n private _consumeCdata(start: CharacterCursor) {\n this._beginToken(TokenType.CDATA_START, start);\n this._requireStr('CDATA[');\n this._endToken([]);\n this._consumeRawText(false, () => this._attemptStr(']]>'));\n this._beginToken(TokenType.CDATA_END);\n this._requireStr(']]>');\n this._endToken([]);\n }\n\n private _consumeDocType(start: CharacterCursor) {\n this._beginToken(TokenType.DOC_TYPE, start);\n const contentStart = this._cursor.clone();\n this._attemptUntilChar(chars.$GT);\n const content = this._cursor.getChars(contentStart);\n this._cursor.advance();\n this._endToken([content]);\n }\n\n private _consumePrefixAndName(): string[] {\n const nameOrPrefixStart = this._cursor.clone();\n let prefix: string = '';\n while (this._cursor.peek() !== chars.$COLON && !isPrefixEnd(this._cursor.peek())) {\n this._cursor.advance();\n }\n let nameStart: CharacterCursor;\n if (this._cursor.peek() === chars.$COLON) {\n prefix = this._cursor.getChars(nameOrPrefixStart);\n this._cursor.advance();\n nameStart = this._cursor.clone();\n } else {\n nameStart = nameOrPrefixStart;\n }\n this._requireCharCodeUntilFn(isNameEnd, prefix === '' ? 0 : 1);\n const name = this._cursor.getChars(nameStart);\n return [prefix, name];\n }\n\n private _consumeTagOpen(start: CharacterCursor) {\n let tagName: string;\n let prefix: string;\n let openTagToken: TagOpenStartToken | IncompleteTagOpenToken | undefined;\n try {\n if (!chars.isAsciiLetter(this._cursor.peek())) {\n throw this._createError(\n _unexpectedCharacterErrorMsg(this._cursor.peek()),\n this._cursor.getSpan(start),\n );\n }\n\n openTagToken = this._consumeTagOpenStart(start);\n prefix = openTagToken.parts[0];\n tagName = openTagToken.parts[1];\n this._attemptCharCodeUntilFn(isNotWhitespace);\n while (\n this._cursor.peek() !== chars.$SLASH &&\n this._cursor.peek() !== chars.$GT &&\n this._cursor.peek() !== chars.$LT &&\n this._cursor.peek() !== chars.$EOF\n ) {\n this._consumeAttributeName();\n this._attemptCharCodeUntilFn(isNotWhitespace);\n if (this._attemptCharCode(chars.$EQ)) {\n this._attemptCharCodeUntilFn(isNotWhitespace);\n this._consumeAttributeValue();\n }\n this._attemptCharCodeUntilFn(isNotWhitespace);\n }\n this._consumeTagOpenEnd();\n } catch (e) {\n if (e instanceof _ControlFlowError) {\n if (openTagToken) {\n // We errored before we could close the opening tag, so it is incomplete.\n openTagToken.type = TokenType.INCOMPLETE_TAG_OPEN;\n } else {\n // When the start tag is invalid, assume we want a \"<\" as text.\n // Back to back text tokens are merged at the end.\n this._beginToken(TokenType.TEXT, start);\n this._endToken(['<']);\n }\n return;\n }\n\n throw e;\n }\n\n const contentTokenType = this._getTagDefinition(tagName).getContentType(prefix);\n\n if (contentTokenType === TagContentType.RAW_TEXT) {\n this._consumeRawTextWithTagClose(prefix, tagName, false);\n } else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) {\n this._consumeRawTextWithTagClose(prefix, tagName, true);\n }\n }\n\n private _consumeRawTextWithTagClose(prefix: string, tagName: string, consumeEntities: boolean) {\n this._consumeRawText(consumeEntities, () => {\n if (!this._attemptCharCode(chars.$LT)) return false;\n if (!this._attemptCharCode(chars.$SLASH)) return false;\n this._attemptCharCodeUntilFn(isNotWhitespace);\n if (!this._attemptStrCaseInsensitive(tagName)) return false;\n this._attemptCharCodeUntilFn(isNotWhitespace);\n return this._attemptCharCode(chars.$GT);\n });\n this._beginToken(TokenType.TAG_CLOSE);\n this._requireCharCodeUntilFn((code) => code === chars.$GT, 3);\n this._cursor.advance(); // Consume the `>`\n this._endToken([prefix, tagName]);\n }\n\n private _consumeTagOpenStart(start: CharacterCursor): TagOpenStartToken {\n this._beginToken(TokenType.TAG_OPEN_START, start);\n const parts = this._consumePrefixAndName();\n return this._endToken(parts) as TagOpenStartToken;\n }\n\n private _consumeAttributeName() {\n const attrNameStart = this._cursor.peek();\n if (attrNameStart === chars.$SQ || attrNameStart === chars.$DQ) {\n throw this._createError(_unexpectedCharacterErrorMsg(attrNameStart), this._cursor.getSpan());\n }\n this._beginToken(TokenType.ATTR_NAME);\n const prefixAndName = this._consumePrefixAndName();\n this._endToken(prefixAndName);\n }\n\n private _consumeAttributeValue() {\n if (this._cursor.peek() === chars.$SQ || this._cursor.peek() === chars.$DQ) {\n const quoteChar = this._cursor.peek();\n this._consumeQuote(quoteChar);\n // In an attribute then end of the attribute value and the premature end to an interpolation\n // are both triggered by the `quoteChar`.\n const endPredicate = () => this._cursor.peek() === quoteChar;\n this._consumeWithInterpolation(\n TokenType.ATTR_VALUE_TEXT,\n TokenType.ATTR_VALUE_INTERPOLATION,\n endPredicate,\n endPredicate,\n );\n this._consumeQuote(quoteChar);\n } else {\n const endPredicate = () => isNameEnd(this._cursor.peek());\n this._consumeWithInterpolation(\n TokenType.ATTR_VALUE_TEXT,\n TokenType.ATTR_VALUE_INTERPOLATION,\n endPredicate,\n endPredicate,\n );\n }\n }\n\n private _consumeQuote(quoteChar: number) {\n this._beginToken(TokenType.ATTR_QUOTE);\n this._requireCharCode(quoteChar);\n this._endToken([String.fromCodePoint(quoteChar)]);\n }\n\n private _consumeTagOpenEnd() {\n const tokenType = this._attemptCharCode(chars.$SLASH)\n ? TokenType.TAG_OPEN_END_VOID\n : TokenType.TAG_OPEN_END;\n this._beginToken(tokenType);\n this._requireCharCode(chars.$GT);\n this._endToken([]);\n }\n\n private _consumeTagClose(start: CharacterCursor) {\n this._beginToken(TokenType.TAG_CLOSE, start);\n this._attemptCharCodeUntilFn(isNotWhitespace);\n const prefixAndName = this._consumePrefixAndName();\n this._attemptCharCodeUntilFn(isNotWhitespace);\n this._requireCharCode(chars.$GT);\n this._endToken(prefixAndName);\n }\n\n private _consumeExpansionFormStart() {\n this._beginToken(TokenType.EXPANSION_FORM_START);\n this._requireCharCode(chars.$LBRACE);\n this._endToken([]);\n\n this._expansionCaseStack.push(TokenType.EXPANSION_FORM_START);\n\n this._beginToken(TokenType.RAW_TEXT);\n const condition = this._readUntil(chars.$COMMA);\n const normalizedCondition = this._processCarriageReturns(condition);\n if (this._i18nNormalizeLineEndingsInICUs) {\n // We explicitly want to normalize line endings for this text.\n this._endToken([normalizedCondition]);\n } else {\n // We are not normalizing line endings.\n const conditionToken = this._endToken([condition]);\n if (normalizedCondition !== condition) {\n this.nonNormalizedIcuExpressions.push(conditionToken);\n }\n }\n this._requireCharCode(chars.$COMMA);\n this._attemptCharCodeUntilFn(isNotWhitespace);\n\n this._beginToken(TokenType.RAW_TEXT);\n const type = this._readUntil(chars.$COMMA);\n this._endToken([type]);\n this._requireCharCode(chars.$COMMA);\n this._attemptCharCodeUntilFn(isNotWhitespace);\n }\n\n private _consumeExpansionCaseStart() {\n this._beginToken(TokenType.EXPANSION_CASE_VALUE);\n const value = this._readUntil(chars.$LBRACE).trim();\n this._endToken([value]);\n this._attemptCharCodeUntilFn(isNotWhitespace);\n\n this._beginToken(TokenType.EXPANSION_CASE_EXP_START);\n this._requireCharCode(chars.$LBRACE);\n this._endToken([]);\n this._attemptCharCodeUntilFn(isNotWhitespace);\n\n this._expansionCaseStack.push(TokenType.EXPANSION_CASE_EXP_START);\n }\n\n private _consumeExpansionCaseEnd() {\n this._beginToken(TokenType.EXPANSION_CASE_EXP_END);\n this._requireCharCode(chars.$RBRACE);\n this._endToken([]);\n this._attemptCharCodeUntilFn(isNotWhitespace);\n\n this._expansionCaseStack.pop();\n }\n\n private _consumeExpansionFormEnd() {\n this._beginToken(TokenType.EXPANSION_FORM_END);\n this._requireCharCode(chars.$RBRACE);\n this._endToken([]);\n\n this._expansionCaseStack.pop();\n }\n\n /**\n * Consume a string that may contain interpolation expressions.\n *\n * The first token consumed will be of `tokenType` and then there will be alternating\n * `interpolationTokenType` and `tokenType` tokens until the `endPredicate()` returns true.\n *\n * If an interpolation token ends prematurely it will have no end marker in its `parts` array.\n *\n * @param textTokenType the kind of tokens to interleave around interpolation tokens.\n * @param interpolationTokenType the kind of tokens that contain interpolation.\n * @param endPredicate a function that should return true when we should stop consuming.\n * @param endInterpolation a function that should return true if there is a premature end to an\n * interpolation expression - i.e. before we get to the normal interpolation closing marker.\n */\n private _consumeWithInterpolation(\n textTokenType: TokenType,\n interpolationTokenType: TokenType,\n endPredicate: () => boolean,\n endInterpolation: () => boolean,\n ) {\n this._beginToken(textTokenType);\n const parts: string[] = [];\n\n while (!endPredicate()) {\n const current = this._cursor.clone();\n if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) {\n this._endToken([this._processCarriageReturns(parts.join(''))], current);\n parts.length = 0;\n this._consumeInterpolation(interpolationTokenType, current, endInterpolation);\n this._beginToken(textTokenType);\n } else if (this._cursor.peek() === chars.$AMPERSAND) {\n this._endToken([this._processCarriageReturns(parts.join(''))]);\n parts.length = 0;\n this._consumeEntity(textTokenType);\n this._beginToken(textTokenType);\n } else {\n parts.push(this._readChar());\n }\n }\n\n // It is possible that an interpolation was started but not ended inside this text token.\n // Make sure that we reset the state of the lexer correctly.\n this._inInterpolation = false;\n\n this._endToken([this._processCarriageReturns(parts.join(''))]);\n }\n\n /**\n * Consume a block of text that has been interpreted as an Angular interpolation.\n *\n * @param interpolationTokenType the type of the interpolation token to generate.\n * @param interpolationStart a cursor that points to the start of this interpolation.\n * @param prematureEndPredicate a function that should return true if the next characters indicate\n * an end to the interpolation before its normal closing marker.\n */\n private _consumeInterpolation(\n interpolationTokenType: TokenType,\n interpolationStart: CharacterCursor,\n prematureEndPredicate: (() => boolean) | null,\n ): void {\n const parts: string[] = [];\n this._beginToken(interpolationTokenType, interpolationStart);\n parts.push(this._interpolationConfig.start);\n\n // Find the end of the interpolation, ignoring content inside quotes.\n const expressionStart = this._cursor.clone();\n let inQuote: number | null = null;\n let inComment = false;\n while (\n this._cursor.peek() !== chars.$EOF &&\n (prematureEndPredicate === null || !prematureEndPredicate())\n ) {\n const current = this._cursor.clone();\n\n if (this._isTagStart()) {\n // We are starting what looks like an HTML element in the middle of this interpolation.\n // Reset the cursor to before the `<` character and end the interpolation token.\n // (This is actually wrong but here for backward compatibility).\n this._cursor = current;\n parts.push(this._getProcessedChars(expressionStart, current));\n this._endToken(parts);\n return;\n }\n\n if (inQuote === null) {\n if (this._attemptStr(this._interpolationConfig.end)) {\n // We are not in a string, and we hit the end interpolation marker\n parts.push(this._getProcessedChars(expressionStart, current));\n parts.push(this._interpolationConfig.end);\n this._endToken(parts);\n return;\n } else if (this._attemptStr('//')) {\n // Once we are in a comment we ignore any quotes\n inComment = true;\n }\n }\n\n const char = this._cursor.peek();\n this._cursor.advance();\n if (char === chars.$BACKSLASH) {\n // Skip the next character because it was escaped.\n this._cursor.advance();\n } else if (char === inQuote) {\n // Exiting the current quoted string\n inQuote = null;\n } else if (!inComment && inQuote === null && chars.isQuote(char)) {\n // Entering a new quoted string\n inQuote = char;\n }\n }\n\n // We hit EOF without finding a closing interpolation marker\n parts.push(this._getProcessedChars(expressionStart, this._cursor));\n this._endToken(parts);\n }\n\n private _getProcessedChars(start: CharacterCursor, end: CharacterCursor): string {\n return this._processCarriageReturns(end.getChars(start));\n }\n\n private _isTextEnd(): boolean {\n if (this._isTagStart() || this._cursor.peek() === chars.$EOF) {\n return true;\n }\n\n if (this._tokenizeIcu && !this._inInterpolation) {\n if (this.isExpansionFormStart()) {\n // start of an expansion form\n return true;\n }\n\n if (this._cursor.peek() === chars.$RBRACE && this._isInExpansionCase()) {\n // end of and expansion case\n return true;\n }\n }\n\n if (\n this._tokenizeBlocks &&\n !this._inInterpolation &&\n !this._isInExpansion() &&\n (this._cursor.peek() === chars.$AT || this._cursor.peek() === chars.$RBRACE)\n ) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Returns true if the current cursor is pointing to the start of a tag\n * (opening/closing/comments/cdata/etc).\n */\n private _isTagStart(): boolean {\n if (this._cursor.peek() === chars.$LT) {\n // We assume that `<` followed by whitespace is not the start of an HTML element.\n const tmp = this._cursor.clone();\n tmp.advance();\n // If the next character is alphabetic, ! nor / then it is a tag start\n const code = tmp.peek();\n if (\n (chars.$a <= code && code <= chars.$z) ||\n (chars.$A <= code && code <= chars.$Z) ||\n code === chars.$SLASH ||\n code === chars.$BANG\n ) {\n return true;\n }\n }\n return false;\n }\n\n private _readUntil(char: number): string {\n const start = this._cursor.clone();\n this._attemptUntilChar(char);\n return this._cursor.getChars(start);\n }\n\n private _isInExpansion(): boolean {\n return this._isInExpansionCase() || this._isInExpansionForm();\n }\n\n private _isInExpansionCase(): boolean {\n return (\n this._expansionCaseStack.length > 0 &&\n this._expansionCaseStack[this._expansionCaseStack.length - 1] ===\n TokenType.EXPANSION_CASE_EXP_START\n );\n }\n\n private _isInExpansionForm(): boolean {\n return (\n this._expansionCaseStack.length > 0 &&\n this._expansionCaseStack[this._expansionCaseStack.length - 1] ===\n TokenType.EXPANSION_FORM_START\n );\n }\n\n private isExpansionFormStart(): boolean {\n if (this._cursor.peek() !== chars.$LBRACE) {\n return false;\n }\n if (this._interpolationConfig) {\n const start = this._cursor.clone();\n const isInterpolation = this._attemptStr(this._interpolationConfig.start);\n this._cursor = start;\n return !isInterpolation;\n }\n return true;\n }\n}\n\nfunction isNotWhitespace(code: number): boolean {\n return !chars.isWhitespace(code) || code === chars.$EOF;\n}\n\nfunction isNameEnd(code: number): boolean {\n return (\n chars.isWhitespace(code) ||\n code === chars.$GT ||\n code === chars.$LT ||\n code === chars.$SLASH ||\n code === chars.$SQ ||\n code === chars.$DQ ||\n code === chars.$EQ ||\n code === chars.$EOF\n );\n}\n\nfunction isPrefixEnd(code: number): boolean {\n return (\n (code < chars.$a || chars.$z < code) &&\n (code < chars.$A || chars.$Z < code) &&\n (code < chars.$0 || code > chars.$9)\n );\n}\n\nfunction isDigitEntityEnd(code: number): boolean {\n return code === chars.$SEMICOLON || code === chars.$EOF || !chars.isAsciiHexDigit(code);\n}\n\nfunction isNamedEntityEnd(code: number): boolean {\n return code === chars.$SEMICOLON || code === chars.$EOF || !chars.isAsciiLetter(code);\n}\n\nfunction isExpansionCaseStart(peek: number): boolean {\n return peek !== chars.$RBRACE;\n}\n\nfunction compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {\n return toUpperCaseCharCode(code1) === toUpperCaseCharCode(code2);\n}\n\nfunction toUpperCaseCharCode(code: number): number {\n return code >= chars.$a && code <= chars.$z ? code - chars.$a + chars.$A : code;\n}\n\nfunction isBlockNameChar(code: number): boolean {\n return chars.isAsciiLetter(code) || chars.isDigit(code) || code === chars.$_;\n}\n\nfunction isBlockParameterChar(code: number): boolean {\n return code !== chars.$SEMICOLON && isNotWhitespace(code);\n}\n\nfunction mergeTextTokens(srcTokens: Token[]): Token[] {\n const dstTokens: Token[] = [];\n let lastDstToken: Token | undefined = undefined;\n for (let i = 0; i < srcTokens.length; i++) {\n const token = srcTokens[i];\n if (\n (lastDstToken && lastDstToken.type === TokenType.TEXT && token.type === TokenType.TEXT) ||\n (lastDstToken &&\n lastDstToken.type === TokenType.ATTR_VALUE_TEXT &&\n token.type === TokenType.ATTR_VALUE_TEXT)\n ) {\n lastDstToken.parts[0]! += token.parts[0];\n lastDstToken.sourceSpan.end = token.sourceSpan.end;\n } else {\n lastDstToken = token;\n dstTokens.push(lastDstToken);\n }\n }\n\n return dstTokens;\n}\n\n/**\n * The _Tokenizer uses objects of this type to move through the input text,\n * extracting \"parsed characters\". These could be more than one actual character\n * if the text contains escape sequences.\n */\ninterface CharacterCursor {\n /** Initialize the cursor. */\n init(): void;\n /** The parsed character at the current cursor position. */\n peek(): number;\n /** Advance the cursor by one parsed character. */\n advance(): void;\n /** Get a span from the marked start point to the current point. */\n getSpan(start?: this, leadingTriviaCodePoints?: number[]): ParseSourceSpan;\n /** Get the parsed characters from the marked start point to the current point. */\n getChars(start: this): string;\n /** The number of characters left before the end of the cursor. */\n charsLeft(): number;\n /** The number of characters between `this` cursor and `other` cursor. */\n diff(other: this): number;\n /** Make a copy of this cursor */\n clone(): CharacterCursor;\n}\n\ninterface CursorState {\n peek: number;\n offset: number;\n line: number;\n column: number;\n}\n\nclass PlainCharacterCursor implements CharacterCursor {\n protected state: CursorState;\n protected file: ParseSourceFile;\n protected input: string;\n protected end: number;\n\n constructor(fileOrCursor: PlainCharacterCursor);\n constructor(fileOrCursor: ParseSourceFile, range: LexerRange);\n constructor(fileOrCursor: ParseSourceFile | PlainCharacterCursor, range?: LexerRange) {\n if (fileOrCursor instanceof PlainCharacterCursor) {\n this.file = fileOrCursor.file;\n this.input = fileOrCursor.input;\n this.end = fileOrCursor.end;\n\n const state = fileOrCursor.state;\n // Note: avoid using `{...fileOrCursor.state}` here as that has a severe performance penalty.\n // In ES5 bundles the object spread operator is translated into the `__assign` helper, which\n // is not optimized by VMs as efficiently as a raw object literal. Since this constructor is\n // called in tight loops, this difference matters.\n this.state = {\n peek: state.peek,\n offset: state.offset,\n line: state.line,\n column: state.column,\n };\n } else {\n if (!range) {\n throw new Error(\n 'Programming error: the range argument must be provided with a file argument.',\n );\n }\n this.file = fileOrCursor;\n this.input = fileOrCursor.content;\n this.end = range.endPos;\n this.state = {\n peek: -1,\n offset: range.startPos,\n line: range.startLine,\n column: range.startCol,\n };\n }\n }\n\n clone(): PlainCharacterCursor {\n return new PlainCharacterCursor(this);\n }\n\n peek() {\n return this.state.peek;\n }\n charsLeft() {\n return this.end - this.state.offset;\n }\n diff(other: this) {\n return this.state.offset - other.state.offset;\n }\n\n advance(): void {\n this.advanceState(this.state);\n }\n\n init(): void {\n this.updatePeek(this.state);\n }\n\n getSpan(start?: this, leadingTriviaCodePoints?: number[]): ParseSourceSpan {\n start = start || this;\n let fullStart = start;\n if (leadingTriviaCodePoints) {\n while (this.diff(start) > 0 && leadingTriviaCodePoints.indexOf(start.peek()) !== -1) {\n if (fullStart === start) {\n start = start.clone() as this;\n }\n start.advance();\n }\n }\n const startLocation = this.locationFromCursor(start);\n const endLocation = this.locationFromCursor(this);\n const fullStartLocation =\n fullStart !== start ? this.locationFromCursor(fullStart) : startLocation;\n return new ParseSourceSpan(startLocation, endLocation, fullStartLocation);\n }\n\n getChars(start: this): string {\n return this.input.substring(start.state.offset, this.state.offset);\n }\n\n charAt(pos: number): number {\n return this.input.charCodeAt(pos);\n }\n\n protected advanceState(state: CursorState) {\n if (state.offset >= this.end) {\n this.state = state;\n throw new CursorError('Unexpected character \"EOF\"', this);\n }\n const currentChar = this.charAt(state.offset);\n if (currentChar === chars.$LF) {\n state.line++;\n state.column = 0;\n } else if (!chars.isNewLine(currentChar)) {\n state.column++;\n }\n state.offset++;\n this.updatePeek(state);\n }\n\n protected updatePeek(state: CursorState): void {\n state.peek = state.offset >= this.end ? chars.$EOF : this.charAt(state.offset);\n }\n\n private locationFromCursor(cursor: this): ParseLocation {\n return new ParseLocation(\n cursor.file,\n cursor.state.offset,\n cursor.state.line,\n cursor.state.column,\n );\n }\n}\n\nclass EscapedCharacterCursor extends PlainCharacterCursor {\n protected internalState: CursorState;\n\n constructor(fileOrCursor: EscapedCharacterCursor);\n constructor(fileOrCursor: ParseSourceFile, range: LexerRange);\n constructor(fileOrCursor: ParseSourceFile | EscapedCharacterCursor, range?: LexerRange) {\n if (fileOrCursor instanceof EscapedCharacterCursor) {\n super(fileOrCursor);\n this.internalState = {...fileOrCursor.internalState};\n } else {\n super(fileOrCursor, range!);\n this.internalState = this.state;\n }\n }\n\n override advance(): void {\n this.state = this.internalState;\n super.advance();\n this.processEscapeSequence();\n }\n\n override init(): void {\n super.init();\n this.processEscapeSequence();\n }\n\n override clone(): EscapedCharacterCursor {\n return new EscapedCharacterCursor(this);\n }\n\n override getChars(start: this): string {\n const cursor = start.clone();\n let chars = '';\n while (cursor.internalState.offset < this.internalState.offset) {\n chars += String.fromCodePoint(cursor.peek());\n cursor.advance();\n }\n return chars;\n }\n\n /**\n * Process the escape sequence that starts at the current position in the text.\n *\n * This method is called to ensure that `peek` has the unescaped value of escape sequences.\n */\n protected processEscapeSequence(): void {\n const peek = () => this.internalState.peek;\n\n if (peek() === chars.$BACKSLASH) {\n // We have hit an escape sequence so we need the internal state to become independent\n // of the external state.\n this.internalState = {...this.state};\n\n // Move past the backslash\n this.advanceState(this.internalState);\n\n // First check for standard control char sequences\n if (peek() === chars.$n) {\n this.state.peek = chars.$LF;\n } else if (peek() === chars.$r) {\n this.state.peek = chars.$CR;\n } else if (peek() === chars.$v) {\n this.state.peek = chars.$VTAB;\n } else if (peek() === chars.$t) {\n this.state.peek = chars.$TAB;\n } else if (peek() === chars.$b) {\n this.state.peek = chars.$BSPACE;\n } else if (peek() === chars.$f) {\n this.state.peek = chars.$FF;\n }\n\n // Now consider more complex sequences\n else if (peek() === chars.$u) {\n // Unicode code-point sequence\n this.advanceState(this.internalState); // advance past the `u` char\n if (peek() === chars.$LBRACE) {\n // Variable length Unicode, e.g. `\\x{123}`\n this.advanceState(this.internalState); // advance past the `{` char\n // Advance past the variable number of hex digits until we hit a `}` char\n const digitStart = this.clone();\n let length = 0;\n while (peek() !== chars.$RBRACE) {\n this.advanceState(this.internalState);\n length++;\n }\n this.state.peek = this.decodeHexDigits(digitStart, length);\n } else {\n // Fixed length Unicode, e.g. `\\u1234`\n const digitStart = this.clone();\n this.advanceState(this.internalState);\n this.advanceState(this.internalState);\n this.advanceState(this.internalState);\n this.state.peek = this.decodeHexDigits(digitStart, 4);\n }\n } else if (peek() === chars.$x) {\n // Hex char code, e.g. `\\x2F`\n this.advanceState(this.internalState); // advance past the `x` char\n const digitStart = this.clone();\n this.advanceState(this.internalState);\n this.state.peek = this.decodeHexDigits(digitStart, 2);\n } else if (chars.isOctalDigit(peek())) {\n // Octal char code, e.g. `\\012`,\n let octal = '';\n let length = 0;\n let previous = this.clone();\n while (chars.isOctalDigit(peek()) && length < 3) {\n previous = this.clone();\n octal += String.fromCodePoint(peek());\n this.advanceState(this.internalState);\n length++;\n }\n this.state.peek = parseInt(octal, 8);\n // Backup one char\n this.internalState = previous.internalState;\n } else if (chars.isNewLine(this.internalState.peek)) {\n // Line continuation `\\` followed by a new line\n this.advanceState(this.internalState); // advance over the newline\n this.state = this.internalState;\n } else {\n // If none of the `if` blocks were executed then we just have an escaped normal character.\n // In that case we just, effectively, skip the backslash from the character.\n this.state.peek = this.internalState.peek;\n }\n }\n }\n\n protected decodeHexDigits(start: EscapedCharacterCursor, length: number): number {\n const hex = this.input.slice(start.internalState.offset, start.internalState.offset + length);\n const charCode = parseInt(hex, 16);\n if (!isNaN(charCode)) {\n return charCode;\n } else {\n start.state = start.internalState;\n throw new CursorError('Invalid hexadecimal escape sequence', start);\n }\n }\n}\n\nexport class CursorError {\n constructor(\n public msg: string,\n public cursor: CharacterCursor,\n ) {}\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ParseError, ParseLocation, ParseSourceSpan} from '../parse_util';\n\nimport * as html from './ast';\nimport {NAMED_ENTITIES} from './entities';\nimport {tokenize, TokenizeOptions} from './lexer';\nimport {getNsPrefix, mergeNsAndName, splitNsName, TagDefinition} from './tags';\nimport {\n AttributeNameToken,\n AttributeQuoteToken,\n BlockCloseToken,\n BlockOpenStartToken,\n BlockParameterToken,\n CdataStartToken,\n CommentStartToken,\n ExpansionCaseExpressionEndToken,\n ExpansionCaseExpressionStartToken,\n ExpansionCaseValueToken,\n ExpansionFormStartToken,\n IncompleteBlockOpenToken,\n IncompleteLetToken,\n IncompleteTagOpenToken,\n InterpolatedAttributeToken,\n InterpolatedTextToken,\n LetEndToken,\n LetStartToken,\n LetValueToken,\n TagCloseToken,\n TagOpenStartToken,\n TextToken,\n Token,\n TokenType,\n} from './tokens';\n\n/** Nodes that can contain other nodes. */\ntype NodeContainer = html.Element | html.Block;\n\n/** Class that can construct a `NodeContainer`. */\ninterface NodeContainerConstructor extends Function {\n new (...args: any[]): NodeContainer;\n}\n\nexport class TreeError extends ParseError {\n static create(elementName: string | null, span: ParseSourceSpan, msg: string): TreeError {\n return new TreeError(elementName, span, msg);\n }\n\n constructor(\n public elementName: string | null,\n span: ParseSourceSpan,\n msg: string,\n ) {\n super(span, msg);\n }\n}\n\nexport class ParseTreeResult {\n constructor(\n public rootNodes: html.Node[],\n public errors: ParseError[],\n ) {}\n}\n\nexport class Parser {\n constructor(public getTagDefinition: (tagName: string) => TagDefinition) {}\n\n parse(source: string, url: string, options?: TokenizeOptions): ParseTreeResult {\n const tokenizeResult = tokenize(source, url, this.getTagDefinition, options);\n const parser = new _TreeBuilder(tokenizeResult.tokens, this.getTagDefinition);\n parser.build();\n return new ParseTreeResult(\n parser.rootNodes,\n (tokenizeResult.errors as ParseError[]).concat(parser.errors),\n );\n }\n}\n\nclass _TreeBuilder {\n private _index: number = -1;\n // `_peek` will be initialized by the call to `_advance()` in the constructor.\n private _peek!: Token;\n private _containerStack: NodeContainer[] = [];\n\n rootNodes: html.Node[] = [];\n errors: TreeError[] = [];\n\n constructor(\n private tokens: Token[],\n private getTagDefinition: (tagName: string) => TagDefinition,\n ) {\n this._advance();\n }\n\n build(): void {\n while (this._peek.type !== TokenType.EOF) {\n if (\n this._peek.type === TokenType.TAG_OPEN_START ||\n this._peek.type === TokenType.INCOMPLETE_TAG_OPEN\n ) {\n this._consumeStartTag(this._advance());\n } else if (this._peek.type === TokenType.TAG_CLOSE) {\n this._consumeEndTag(this._advance());\n } else if (this._peek.type === TokenType.CDATA_START) {\n this._closeVoidElement();\n this._consumeCdata(this._advance());\n } else if (this._peek.type === TokenType.COMMENT_START) {\n this._closeVoidElement();\n this._consumeComment(this._advance());\n } else if (\n this._peek.type === TokenType.TEXT ||\n this._peek.type === TokenType.RAW_TEXT ||\n this._peek.type === TokenType.ESCAPABLE_RAW_TEXT\n ) {\n this._closeVoidElement();\n this._consumeText(this._advance());\n } else if (this._peek.type === TokenType.EXPANSION_FORM_START) {\n this._consumeExpansion(this._advance());\n } else if (this._peek.type === TokenType.BLOCK_OPEN_START) {\n this._closeVoidElement();\n this._consumeBlockOpen(this._advance());\n } else if (this._peek.type === TokenType.BLOCK_CLOSE) {\n this._closeVoidElement();\n this._consumeBlockClose(this._advance());\n } else if (this._peek.type === TokenType.INCOMPLETE_BLOCK_OPEN) {\n this._closeVoidElement();\n this._consumeIncompleteBlock(this._advance());\n } else if (this._peek.type === TokenType.LET_START) {\n this._closeVoidElement();\n this._consumeLet(this._advance());\n } else if (this._peek.type === TokenType.INCOMPLETE_LET) {\n this._closeVoidElement();\n this._consumeIncompleteLet(this._advance());\n } else {\n // Skip all other tokens...\n this._advance();\n }\n }\n\n for (const leftoverContainer of this._containerStack) {\n // Unlike HTML elements, blocks aren't closed implicitly by the end of the file.\n if (leftoverContainer instanceof html.Block) {\n this.errors.push(\n TreeError.create(\n leftoverContainer.name,\n leftoverContainer.sourceSpan,\n `Unclosed block \"${leftoverContainer.name}\"`,\n ),\n );\n }\n }\n }\n\n private _advance(): T {\n const prev = this._peek;\n if (this._index < this.tokens.length - 1) {\n // Note: there is always an EOF token at the end\n this._index++;\n }\n this._peek = this.tokens[this._index];\n return prev as T;\n }\n\n private _advanceIf(type: T): (Token & {type: T}) | null {\n if (this._peek.type === type) {\n return this._advance();\n }\n return null;\n }\n\n private _consumeCdata(_startToken: CdataStartToken) {\n this._consumeText(this._advance());\n this._advanceIf(TokenType.CDATA_END);\n }\n\n private _consumeComment(token: CommentStartToken) {\n const text = this._advanceIf(TokenType.RAW_TEXT);\n const endToken = this._advanceIf(TokenType.COMMENT_END);\n const value = text != null ? text.parts[0].trim() : null;\n const sourceSpan =\n endToken == null\n ? token.sourceSpan\n : new ParseSourceSpan(\n token.sourceSpan.start,\n endToken.sourceSpan.end,\n token.sourceSpan.fullStart,\n );\n this._addToParent(new html.Comment(value, sourceSpan));\n }\n\n private _consumeExpansion(token: ExpansionFormStartToken) {\n const switchValue = this._advance();\n\n const type = this._advance();\n const cases: html.ExpansionCase[] = [];\n\n // read =\n while (this._peek.type === TokenType.EXPANSION_CASE_VALUE) {\n const expCase = this._parseExpansionCase();\n if (!expCase) return; // error\n cases.push(expCase);\n }\n\n // read the final }\n if (this._peek.type !== TokenType.EXPANSION_FORM_END) {\n this.errors.push(\n TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '}'.`),\n );\n return;\n }\n const sourceSpan = new ParseSourceSpan(\n token.sourceSpan.start,\n this._peek.sourceSpan.end,\n token.sourceSpan.fullStart,\n );\n this._addToParent(\n new html.Expansion(\n switchValue.parts[0],\n type.parts[0],\n cases,\n sourceSpan,\n switchValue.sourceSpan,\n ),\n );\n\n this._advance();\n }\n\n private _parseExpansionCase(): html.ExpansionCase | null {\n const value = this._advance();\n\n // read {\n if (this._peek.type !== TokenType.EXPANSION_CASE_EXP_START) {\n this.errors.push(\n TreeError.create(null, this._peek.sourceSpan, `Invalid ICU message. Missing '{'.`),\n );\n return null;\n }\n\n // read until }\n const start = this._advance();\n\n const exp = this._collectExpansionExpTokens(start);\n if (!exp) return null;\n\n const end = this._advance();\n exp.push({type: TokenType.EOF, parts: [], sourceSpan: end.sourceSpan});\n\n // parse everything in between { and }\n const expansionCaseParser = new _TreeBuilder(exp, this.getTagDefinition);\n expansionCaseParser.build();\n if (expansionCaseParser.errors.length > 0) {\n this.errors = this.errors.concat(expansionCaseParser.errors);\n return null;\n }\n\n const sourceSpan = new ParseSourceSpan(\n value.sourceSpan.start,\n end.sourceSpan.end,\n value.sourceSpan.fullStart,\n );\n const expSourceSpan = new ParseSourceSpan(\n start.sourceSpan.start,\n end.sourceSpan.end,\n start.sourceSpan.fullStart,\n );\n return new html.ExpansionCase(\n value.parts[0],\n expansionCaseParser.rootNodes,\n sourceSpan,\n value.sourceSpan,\n expSourceSpan,\n );\n }\n\n private _collectExpansionExpTokens(start: Token): Token[] | null {\n const exp: Token[] = [];\n const expansionFormStack = [TokenType.EXPANSION_CASE_EXP_START];\n\n while (true) {\n if (\n this._peek.type === TokenType.EXPANSION_FORM_START ||\n this._peek.type === TokenType.EXPANSION_CASE_EXP_START\n ) {\n expansionFormStack.push(this._peek.type);\n }\n\n if (this._peek.type === TokenType.EXPANSION_CASE_EXP_END) {\n if (lastOnStack(expansionFormStack, TokenType.EXPANSION_CASE_EXP_START)) {\n expansionFormStack.pop();\n if (expansionFormStack.length === 0) return exp;\n } else {\n this.errors.push(\n TreeError.create(null, start.sourceSpan, `Invalid ICU message. Missing '}'.`),\n );\n return null;\n }\n }\n\n if (this._peek.type === TokenType.EXPANSION_FORM_END) {\n if (lastOnStack(expansionFormStack, TokenType.EXPANSION_FORM_START)) {\n expansionFormStack.pop();\n } else {\n this.errors.push(\n TreeError.create(null, start.sourceSpan, `Invalid ICU message. Missing '}'.`),\n );\n return null;\n }\n }\n\n if (this._peek.type === TokenType.EOF) {\n this.errors.push(\n TreeError.create(null, start.sourceSpan, `Invalid ICU message. Missing '}'.`),\n );\n return null;\n }\n\n exp.push(this._advance());\n }\n }\n\n private _consumeText(token: InterpolatedTextToken) {\n const tokens = [token];\n const startSpan = token.sourceSpan;\n let text = token.parts[0];\n if (text.length > 0 && text[0] === '\\n') {\n const parent = this._getContainer();\n\n if (\n parent != null &&\n parent.children.length === 0 &&\n this.getTagDefinition(parent.name).ignoreFirstLf\n ) {\n text = text.substring(1);\n tokens[0] = {type: token.type, sourceSpan: token.sourceSpan, parts: [text]} as typeof token;\n }\n }\n\n while (\n this._peek.type === TokenType.INTERPOLATION ||\n this._peek.type === TokenType.TEXT ||\n this._peek.type === TokenType.ENCODED_ENTITY\n ) {\n token = this._advance();\n tokens.push(token);\n if (token.type === TokenType.INTERPOLATION) {\n // For backward compatibility we decode HTML entities that appear in interpolation\n // expressions. This is arguably a bug, but it could be a considerable breaking change to\n // fix it. It should be addressed in a larger project to refactor the entire parser/lexer\n // chain after View Engine has been removed.\n text += token.parts.join('').replace(/&([^;]+);/g, decodeEntity);\n } else if (token.type === TokenType.ENCODED_ENTITY) {\n text += token.parts[0];\n } else {\n text += token.parts.join('');\n }\n }\n\n if (text.length > 0) {\n const endSpan = token.sourceSpan;\n this._addToParent(\n new html.Text(\n text,\n new ParseSourceSpan(startSpan.start, endSpan.end, startSpan.fullStart, startSpan.details),\n tokens,\n ),\n );\n }\n }\n\n private _closeVoidElement(): void {\n const el = this._getContainer();\n if (el instanceof html.Element && this.getTagDefinition(el.name).isVoid) {\n this._containerStack.pop();\n }\n }\n\n private _consumeStartTag(startTagToken: TagOpenStartToken | IncompleteTagOpenToken) {\n const [prefix, name] = startTagToken.parts;\n const attrs: html.Attribute[] = [];\n while (this._peek.type === TokenType.ATTR_NAME) {\n attrs.push(this._consumeAttr(this._advance()));\n }\n const fullName = this._getElementFullName(prefix, name, this._getClosestParentElement());\n let selfClosing = false;\n // Note: There could have been a tokenizer error\n // so that we don't get a token for the end tag...\n if (this._peek.type === TokenType.TAG_OPEN_END_VOID) {\n this._advance();\n selfClosing = true;\n const tagDef = this.getTagDefinition(fullName);\n if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) {\n this.errors.push(\n TreeError.create(\n fullName,\n startTagToken.sourceSpan,\n `Only void, custom and foreign elements can be self closed \"${startTagToken.parts[1]}\"`,\n ),\n );\n }\n } else if (this._peek.type === TokenType.TAG_OPEN_END) {\n this._advance();\n selfClosing = false;\n }\n const end = this._peek.sourceSpan.fullStart;\n const span = new ParseSourceSpan(\n startTagToken.sourceSpan.start,\n end,\n startTagToken.sourceSpan.fullStart,\n );\n // Create a separate `startSpan` because `span` will be modified when there is an `end` span.\n const startSpan = new ParseSourceSpan(\n startTagToken.sourceSpan.start,\n end,\n startTagToken.sourceSpan.fullStart,\n );\n const el = new html.Element(fullName, attrs, [], span, startSpan, undefined);\n const parentEl = this._getContainer();\n this._pushContainer(\n el,\n parentEl instanceof html.Element &&\n this.getTagDefinition(parentEl.name).isClosedByChild(el.name),\n );\n if (selfClosing) {\n // Elements that are self-closed have their `endSourceSpan` set to the full span, as the\n // element start tag also represents the end tag.\n this._popContainer(fullName, html.Element, span);\n } else if (startTagToken.type === TokenType.INCOMPLETE_TAG_OPEN) {\n // We already know the opening tag is not complete, so it is unlikely it has a corresponding\n // close tag. Let's optimistically parse it as a full element and emit an error.\n this._popContainer(fullName, html.Element, null);\n this.errors.push(\n TreeError.create(fullName, span, `Opening tag \"${fullName}\" not terminated.`),\n );\n }\n }\n\n private _pushContainer(node: NodeContainer, isClosedByChild: boolean) {\n if (isClosedByChild) {\n this._containerStack.pop();\n }\n\n this._addToParent(node);\n this._containerStack.push(node);\n }\n\n private _consumeEndTag(endTagToken: TagCloseToken) {\n const fullName = this._getElementFullName(\n endTagToken.parts[0],\n endTagToken.parts[1],\n this._getClosestParentElement(),\n );\n\n if (this.getTagDefinition(fullName).isVoid) {\n this.errors.push(\n TreeError.create(\n fullName,\n endTagToken.sourceSpan,\n `Void elements do not have end tags \"${endTagToken.parts[1]}\"`,\n ),\n );\n } else if (!this._popContainer(fullName, html.Element, endTagToken.sourceSpan)) {\n const errMsg = `Unexpected closing tag \"${fullName}\". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags`;\n this.errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg));\n }\n }\n\n /**\n * Closes the nearest element with the tag name `fullName` in the parse tree.\n * `endSourceSpan` is the span of the closing tag, or null if the element does\n * not have a closing tag (for example, this happens when an incomplete\n * opening tag is recovered).\n */\n private _popContainer(\n expectedName: string | null,\n expectedType: NodeContainerConstructor,\n endSourceSpan: ParseSourceSpan | null,\n ): boolean {\n let unexpectedCloseTagDetected = false;\n for (let stackIndex = this._containerStack.length - 1; stackIndex >= 0; stackIndex--) {\n const node = this._containerStack[stackIndex];\n\n if ((node.name === expectedName || expectedName === null) && node instanceof expectedType) {\n // Record the parse span with the element that is being closed. Any elements that are\n // removed from the element stack at this point are closed implicitly, so they won't get\n // an end source span (as there is no explicit closing element).\n node.endSourceSpan = endSourceSpan;\n node.sourceSpan.end = endSourceSpan !== null ? endSourceSpan.end : node.sourceSpan.end;\n this._containerStack.splice(stackIndex, this._containerStack.length - stackIndex);\n return !unexpectedCloseTagDetected;\n }\n\n // Blocks and most elements are not self closing.\n if (\n node instanceof html.Block ||\n (node instanceof html.Element && !this.getTagDefinition(node.name).closedByParent)\n ) {\n // Note that we encountered an unexpected close tag but continue processing the element\n // stack so we can assign an `endSourceSpan` if there is a corresponding start tag for this\n // end tag in the stack.\n unexpectedCloseTagDetected = true;\n }\n }\n return false;\n }\n\n private _consumeAttr(attrName: AttributeNameToken): html.Attribute {\n const fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);\n let attrEnd = attrName.sourceSpan.end;\n\n // Consume any quote\n if (this._peek.type === TokenType.ATTR_QUOTE) {\n this._advance();\n }\n\n // Consume the attribute value\n let value = '';\n const valueTokens: InterpolatedAttributeToken[] = [];\n let valueStartSpan: ParseSourceSpan | undefined = undefined;\n let valueEnd: ParseLocation | undefined = undefined;\n // NOTE: We need to use a new variable `nextTokenType` here to hide the actual type of\n // `_peek.type` from TS. Otherwise TS will narrow the type of `_peek.type` preventing it from\n // being able to consider `ATTR_VALUE_INTERPOLATION` as an option. This is because TS is not\n // able to see that `_advance()` will actually mutate `_peek`.\n const nextTokenType = this._peek.type as TokenType;\n if (nextTokenType === TokenType.ATTR_VALUE_TEXT) {\n valueStartSpan = this._peek.sourceSpan;\n valueEnd = this._peek.sourceSpan.end;\n while (\n this._peek.type === TokenType.ATTR_VALUE_TEXT ||\n this._peek.type === TokenType.ATTR_VALUE_INTERPOLATION ||\n this._peek.type === TokenType.ENCODED_ENTITY\n ) {\n const valueToken = this._advance();\n valueTokens.push(valueToken);\n if (valueToken.type === TokenType.ATTR_VALUE_INTERPOLATION) {\n // For backward compatibility we decode HTML entities that appear in interpolation\n // expressions. This is arguably a bug, but it could be a considerable breaking change to\n // fix it. It should be addressed in a larger project to refactor the entire parser/lexer\n // chain after View Engine has been removed.\n value += valueToken.parts.join('').replace(/&([^;]+);/g, decodeEntity);\n } else if (valueToken.type === TokenType.ENCODED_ENTITY) {\n value += valueToken.parts[0];\n } else {\n value += valueToken.parts.join('');\n }\n valueEnd = attrEnd = valueToken.sourceSpan.end;\n }\n }\n\n // Consume any quote\n if (this._peek.type === TokenType.ATTR_QUOTE) {\n const quoteToken = this._advance();\n attrEnd = quoteToken.sourceSpan.end;\n }\n\n const valueSpan =\n valueStartSpan &&\n valueEnd &&\n new ParseSourceSpan(valueStartSpan.start, valueEnd, valueStartSpan.fullStart);\n return new html.Attribute(\n fullName,\n value,\n new ParseSourceSpan(attrName.sourceSpan.start, attrEnd, attrName.sourceSpan.fullStart),\n attrName.sourceSpan,\n valueSpan,\n valueTokens.length > 0 ? valueTokens : undefined,\n undefined,\n );\n }\n\n private _consumeBlockOpen(token: BlockOpenStartToken) {\n const parameters: html.BlockParameter[] = [];\n\n while (this._peek.type === TokenType.BLOCK_PARAMETER) {\n const paramToken = this._advance();\n parameters.push(new html.BlockParameter(paramToken.parts[0], paramToken.sourceSpan));\n }\n\n if (this._peek.type === TokenType.BLOCK_OPEN_END) {\n this._advance();\n }\n\n const end = this._peek.sourceSpan.fullStart;\n const span = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);\n // Create a separate `startSpan` because `span` will be modified when there is an `end` span.\n const startSpan = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);\n const block = new html.Block(token.parts[0], parameters, [], span, token.sourceSpan, startSpan);\n this._pushContainer(block, false);\n }\n\n private _consumeBlockClose(token: BlockCloseToken) {\n if (!this._popContainer(null, html.Block, token.sourceSpan)) {\n this.errors.push(\n TreeError.create(\n null,\n token.sourceSpan,\n `Unexpected closing block. The block may have been closed earlier. ` +\n `If you meant to write the } character, you should use the \"}\" ` +\n `HTML entity instead.`,\n ),\n );\n }\n }\n\n private _consumeIncompleteBlock(token: IncompleteBlockOpenToken) {\n const parameters: html.BlockParameter[] = [];\n\n while (this._peek.type === TokenType.BLOCK_PARAMETER) {\n const paramToken = this._advance();\n parameters.push(new html.BlockParameter(paramToken.parts[0], paramToken.sourceSpan));\n }\n\n const end = this._peek.sourceSpan.fullStart;\n const span = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);\n // Create a separate `startSpan` because `span` will be modified when there is an `end` span.\n const startSpan = new ParseSourceSpan(token.sourceSpan.start, end, token.sourceSpan.fullStart);\n const block = new html.Block(token.parts[0], parameters, [], span, token.sourceSpan, startSpan);\n this._pushContainer(block, false);\n\n // Incomplete blocks don't have children so we close them immediately and report an error.\n this._popContainer(null, html.Block, null);\n\n this.errors.push(\n TreeError.create(\n token.parts[0],\n span,\n `Incomplete block \"${token.parts[0]}\". If you meant to write the @ character, ` +\n `you should use the \"@\" HTML entity instead.`,\n ),\n );\n }\n\n private _consumeLet(startToken: LetStartToken) {\n const name = startToken.parts[0];\n let valueToken: LetValueToken;\n let endToken: LetEndToken;\n\n if (this._peek.type !== TokenType.LET_VALUE) {\n this.errors.push(\n TreeError.create(\n startToken.parts[0],\n startToken.sourceSpan,\n `Invalid @let declaration \"${name}\". Declaration must have a value.`,\n ),\n );\n return;\n } else {\n valueToken = this._advance();\n }\n\n // Type cast is necessary here since TS narrowed the type of `peek` above.\n if ((this._peek as Token).type !== TokenType.LET_END) {\n this.errors.push(\n TreeError.create(\n startToken.parts[0],\n startToken.sourceSpan,\n `Unterminated @let declaration \"${name}\". Declaration must be terminated with a semicolon.`,\n ),\n );\n return;\n } else {\n endToken = this._advance();\n }\n\n const end = endToken.sourceSpan.fullStart;\n const span = new ParseSourceSpan(\n startToken.sourceSpan.start,\n end,\n startToken.sourceSpan.fullStart,\n );\n\n // The start token usually captures the `@let`. Construct a name span by\n // offsetting the start by the length of any text before the name.\n const startOffset = startToken.sourceSpan.toString().lastIndexOf(name);\n const nameStart = startToken.sourceSpan.start.moveBy(startOffset);\n const nameSpan = new ParseSourceSpan(nameStart, startToken.sourceSpan.end);\n const node = new html.LetDeclaration(\n name,\n valueToken.parts[0],\n span,\n nameSpan,\n valueToken.sourceSpan,\n );\n\n this._addToParent(node);\n }\n\n private _consumeIncompleteLet(token: IncompleteLetToken) {\n // Incomplete `@let` declaration may end up with an empty name.\n const name = token.parts[0] ?? '';\n const nameString = name ? ` \"${name}\"` : '';\n\n // If there's at least a name, we can salvage an AST node that can be used for completions.\n if (name.length > 0) {\n const startOffset = token.sourceSpan.toString().lastIndexOf(name);\n const nameStart = token.sourceSpan.start.moveBy(startOffset);\n const nameSpan = new ParseSourceSpan(nameStart, token.sourceSpan.end);\n const valueSpan = new ParseSourceSpan(\n token.sourceSpan.start,\n token.sourceSpan.start.moveBy(0),\n );\n const node = new html.LetDeclaration(name, '', token.sourceSpan, nameSpan, valueSpan);\n this._addToParent(node);\n }\n\n this.errors.push(\n TreeError.create(\n token.parts[0],\n token.sourceSpan,\n `Incomplete @let declaration${nameString}. ` +\n `@let declarations must be written as \\`@let = ;\\``,\n ),\n );\n }\n\n private _getContainer(): NodeContainer | null {\n return this._containerStack.length > 0\n ? this._containerStack[this._containerStack.length - 1]\n : null;\n }\n\n private _getClosestParentElement(): html.Element | null {\n for (let i = this._containerStack.length - 1; i > -1; i--) {\n if (this._containerStack[i] instanceof html.Element) {\n return this._containerStack[i] as html.Element;\n }\n }\n\n return null;\n }\n\n private _addToParent(node: html.Node) {\n const parent = this._getContainer();\n\n if (parent === null) {\n this.rootNodes.push(node);\n } else {\n parent.children.push(node);\n }\n }\n\n private _getElementFullName(\n prefix: string,\n localName: string,\n parentElement: html.Element | null,\n ): string {\n if (prefix === '') {\n prefix = this.getTagDefinition(localName).implicitNamespacePrefix || '';\n if (prefix === '' && parentElement != null) {\n const parentTagName = splitNsName(parentElement.name)[1];\n const parentTagDefinition = this.getTagDefinition(parentTagName);\n if (!parentTagDefinition.preventNamespaceInheritance) {\n prefix = getNsPrefix(parentElement.name);\n }\n }\n }\n\n return mergeNsAndName(prefix, localName);\n }\n}\n\nfunction lastOnStack(stack: any[], element: any): boolean {\n return stack.length > 0 && stack[stack.length - 1] === element;\n}\n\n/**\n * Decode the `entity` string, which we believe is the contents of an HTML entity.\n *\n * If the string is not actually a valid/known entity then just return the original `match` string.\n */\nfunction decodeEntity(match: string, entity: string): string {\n if (NAMED_ENTITIES[entity] !== undefined) {\n return NAMED_ENTITIES[entity] || match;\n }\n if (/^#x[a-f0-9]+$/i.test(entity)) {\n return String.fromCodePoint(parseInt(entity.slice(2), 16));\n }\n if (/^#\\d+$/.test(entity)) {\n return String.fromCodePoint(parseInt(entity.slice(1), 10));\n }\n return match;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as html from './ast';\nimport {NGSP_UNICODE} from './entities';\nimport {ParseTreeResult} from './parser';\nimport {InterpolatedTextToken, TextToken, TokenType} from './tokens';\n\nexport const PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces';\n\nconst SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']);\n\n// Equivalent to \\s with \\u00a0 (non-breaking space) excluded.\n// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\nconst WS_CHARS = ' \\f\\n\\r\\t\\v\\u1680\\u180e\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff';\nconst NO_WS_REGEXP = new RegExp(`[^${WS_CHARS}]`);\nconst WS_REPLACE_REGEXP = new RegExp(`[${WS_CHARS}]{2,}`, 'g');\n\nfunction hasPreserveWhitespacesAttr(attrs: html.Attribute[]): boolean {\n return attrs.some((attr: html.Attribute) => attr.name === PRESERVE_WS_ATTR_NAME);\n}\n\n/**\n * &ngsp; is a placeholder for non-removable space\n * &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character\n * and later on replaced by a space.\n */\nexport function replaceNgsp(value: string): string {\n // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE\n return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' ');\n}\n\n/**\n * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules:\n * - consider spaces, tabs and new lines as whitespace characters;\n * - drop text nodes consisting of whitespace characters only;\n * - for all other text nodes replace consecutive whitespace characters with one space;\n * - convert &ngsp; pseudo-entity to a single space;\n *\n * Removal and trimming of whitespaces have positive performance impact (less code to generate\n * while compiling templates, faster view creation). At the same time it can be \"destructive\"\n * in some cases (whitespaces can influence layout). Because of the potential of breaking layout\n * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for\n * whitespace removal. The default option for whitespace removal will be revisited in Angular 6\n * and might be changed to \"on\" by default.\n *\n * If `originalNodeMap` is provided, the transformed nodes will be mapped back to their original\n * inputs. Any output nodes not in the map were not transformed. This supports correlating and\n * porting information between the trimmed nodes and original nodes (such as `i18n` properties)\n * such that trimming whitespace does not does not drop required information from the node.\n */\nexport class WhitespaceVisitor implements html.Visitor {\n // How many ICU expansions which are currently being visited. ICUs can be nested, so this\n // tracks the current depth of nesting. If this depth is greater than 0, then this visitor is\n // currently processing content inside an ICU expansion.\n private icuExpansionDepth = 0;\n\n constructor(\n private readonly preserveSignificantWhitespace: boolean,\n private readonly originalNodeMap?: Map,\n private readonly requireContext = true,\n ) {}\n\n visitElement(element: html.Element, context: any): any {\n if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {\n // don't descent into elements where we need to preserve whitespaces\n // but still visit all attributes to eliminate one used as a market to preserve WS\n const newElement = new html.Element(\n element.name,\n visitAllWithSiblings(this, element.attrs),\n element.children,\n element.sourceSpan,\n element.startSourceSpan,\n element.endSourceSpan,\n element.i18n,\n );\n this.originalNodeMap?.set(newElement, element);\n return newElement;\n }\n\n const newElement = new html.Element(\n element.name,\n element.attrs,\n visitAllWithSiblings(this, element.children),\n element.sourceSpan,\n element.startSourceSpan,\n element.endSourceSpan,\n element.i18n,\n );\n this.originalNodeMap?.set(newElement, element);\n return newElement;\n }\n\n visitAttribute(attribute: html.Attribute, context: any): any {\n return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null;\n }\n\n visitText(text: html.Text, context: SiblingVisitorContext | null): any {\n const isNotBlank = text.value.match(NO_WS_REGEXP);\n const hasExpansionSibling =\n context && (context.prev instanceof html.Expansion || context.next instanceof html.Expansion);\n\n // Do not trim whitespace within ICU expansions when preserving significant whitespace.\n // Historically, ICU whitespace was never trimmed and this is really a bug. However fixing it\n // would change message IDs which we can't easily do. Instead we only trim ICU whitespace within\n // ICU expansions when not preserving significant whitespace, which is the new behavior where it\n // most matters.\n const inIcuExpansion = this.icuExpansionDepth > 0;\n if (inIcuExpansion && this.preserveSignificantWhitespace) return text;\n\n if (isNotBlank || hasExpansionSibling) {\n // Process the whitespace in the tokens of this Text node\n const tokens = text.tokens.map((token) =>\n token.type === TokenType.TEXT ? createWhitespaceProcessedTextToken(token) : token,\n );\n\n // Fully trim message when significant whitespace is not preserved.\n if (!this.preserveSignificantWhitespace && tokens.length > 0) {\n // The first token should only call `.trimStart()` and the last token\n // should only call `.trimEnd()`, but there might be only one token which\n // needs to call both.\n const firstToken = tokens[0]!;\n tokens.splice(0, 1, trimLeadingWhitespace(firstToken, context));\n\n const lastToken = tokens[tokens.length - 1]; // Could be the same as the first token.\n tokens.splice(tokens.length - 1, 1, trimTrailingWhitespace(lastToken, context));\n }\n\n // Process the whitespace of the value of this Text node. Also trim the leading/trailing\n // whitespace when we don't need to preserve significant whitespace.\n const processed = processWhitespace(text.value);\n const value = this.preserveSignificantWhitespace\n ? processed\n : trimLeadingAndTrailingWhitespace(processed, context);\n const result = new html.Text(value, text.sourceSpan, tokens, text.i18n);\n this.originalNodeMap?.set(result, text);\n return result;\n }\n\n return null;\n }\n\n visitComment(comment: html.Comment, context: any): any {\n return comment;\n }\n\n visitExpansion(expansion: html.Expansion, context: any): any {\n this.icuExpansionDepth++;\n let newExpansion: html.Expansion;\n try {\n newExpansion = new html.Expansion(\n expansion.switchValue,\n expansion.type,\n visitAllWithSiblings(this, expansion.cases),\n expansion.sourceSpan,\n expansion.switchValueSourceSpan,\n expansion.i18n,\n );\n } finally {\n this.icuExpansionDepth--;\n }\n\n this.originalNodeMap?.set(newExpansion, expansion);\n\n return newExpansion;\n }\n\n visitExpansionCase(expansionCase: html.ExpansionCase, context: any): any {\n const newExpansionCase = new html.ExpansionCase(\n expansionCase.value,\n visitAllWithSiblings(this, expansionCase.expression),\n expansionCase.sourceSpan,\n expansionCase.valueSourceSpan,\n expansionCase.expSourceSpan,\n );\n this.originalNodeMap?.set(newExpansionCase, expansionCase);\n return newExpansionCase;\n }\n\n visitBlock(block: html.Block, context: any): any {\n const newBlock = new html.Block(\n block.name,\n block.parameters,\n visitAllWithSiblings(this, block.children),\n block.sourceSpan,\n block.nameSpan,\n block.startSourceSpan,\n block.endSourceSpan,\n );\n this.originalNodeMap?.set(newBlock, block);\n return newBlock;\n }\n\n visitBlockParameter(parameter: html.BlockParameter, context: any) {\n return parameter;\n }\n\n visitLetDeclaration(decl: html.LetDeclaration, context: any) {\n return decl;\n }\n\n visit(_node: html.Node, context: any) {\n // `visitAllWithSiblings` provides context necessary for ICU messages to be handled correctly.\n // Prefer that over calling `html.visitAll` directly on this visitor.\n if (this.requireContext && !context) {\n throw new Error(\n `WhitespaceVisitor requires context. Visit via \\`visitAllWithSiblings\\` to get this context.`,\n );\n }\n\n return false;\n }\n}\n\nfunction trimLeadingWhitespace(\n token: InterpolatedTextToken,\n context: SiblingVisitorContext | null,\n): InterpolatedTextToken {\n if (token.type !== TokenType.TEXT) return token;\n\n const isFirstTokenInTag = !context?.prev;\n if (!isFirstTokenInTag) return token;\n\n return transformTextToken(token, (text) => text.trimStart());\n}\n\nfunction trimTrailingWhitespace(\n token: InterpolatedTextToken,\n context: SiblingVisitorContext | null,\n): InterpolatedTextToken {\n if (token.type !== TokenType.TEXT) return token;\n\n const isLastTokenInTag = !context?.next;\n if (!isLastTokenInTag) return token;\n\n return transformTextToken(token, (text) => text.trimEnd());\n}\n\nfunction trimLeadingAndTrailingWhitespace(\n text: string,\n context: SiblingVisitorContext | null,\n): string {\n const isFirstTokenInTag = !context?.prev;\n const isLastTokenInTag = !context?.next;\n\n const maybeTrimmedStart = isFirstTokenInTag ? text.trimStart() : text;\n const maybeTrimmed = isLastTokenInTag ? maybeTrimmedStart.trimEnd() : maybeTrimmedStart;\n return maybeTrimmed;\n}\n\nfunction createWhitespaceProcessedTextToken({type, parts, sourceSpan}: TextToken): TextToken {\n return {type, parts: [processWhitespace(parts[0])], sourceSpan};\n}\n\nfunction transformTextToken(\n {type, parts, sourceSpan}: TextToken,\n transform: (parts: string) => string,\n): TextToken {\n // `TextToken` only ever has one part as defined in its type, so we just transform the first element.\n return {type, parts: [transform(parts[0])], sourceSpan};\n}\n\nfunction processWhitespace(text: string): string {\n return replaceNgsp(text).replace(WS_REPLACE_REGEXP, ' ');\n}\n\nexport function removeWhitespaces(\n htmlAstWithErrors: ParseTreeResult,\n preserveSignificantWhitespace: boolean,\n): ParseTreeResult {\n return new ParseTreeResult(\n visitAllWithSiblings(\n new WhitespaceVisitor(preserveSignificantWhitespace),\n htmlAstWithErrors.rootNodes,\n ),\n htmlAstWithErrors.errors,\n );\n}\n\ninterface SiblingVisitorContext {\n prev: html.Node | undefined;\n next: html.Node | undefined;\n}\n\nexport function visitAllWithSiblings(visitor: WhitespaceVisitor, nodes: html.Node[]): any[] {\n const result: any[] = [];\n\n nodes.forEach((ast, i) => {\n const context: SiblingVisitorContext = {prev: nodes[i - 1], next: nodes[i + 1]};\n const astResult = ast.visit(visitor, context);\n if (astResult) {\n result.push(astResult);\n }\n });\n return result;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as chars from '../chars';\n\nexport enum TokenType {\n Character,\n Identifier,\n PrivateIdentifier,\n Keyword,\n String,\n Operator,\n Number,\n Error,\n}\n\nconst KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this'];\n\nexport class Lexer {\n tokenize(text: string): Token[] {\n const scanner = new _Scanner(text);\n const tokens: Token[] = [];\n let token = scanner.scanToken();\n while (token != null) {\n tokens.push(token);\n token = scanner.scanToken();\n }\n return tokens;\n }\n}\n\nexport class Token {\n constructor(\n public index: number,\n public end: number,\n public type: TokenType,\n public numValue: number,\n public strValue: string,\n ) {}\n\n isCharacter(code: number): boolean {\n return this.type == TokenType.Character && this.numValue == code;\n }\n\n isNumber(): boolean {\n return this.type == TokenType.Number;\n }\n\n isString(): boolean {\n return this.type == TokenType.String;\n }\n\n isOperator(operator: string): boolean {\n return this.type == TokenType.Operator && this.strValue == operator;\n }\n\n isIdentifier(): boolean {\n return this.type == TokenType.Identifier;\n }\n\n isPrivateIdentifier(): boolean {\n return this.type == TokenType.PrivateIdentifier;\n }\n\n isKeyword(): boolean {\n return this.type == TokenType.Keyword;\n }\n\n isKeywordLet(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'let';\n }\n\n isKeywordAs(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'as';\n }\n\n isKeywordNull(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'null';\n }\n\n isKeywordUndefined(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'undefined';\n }\n\n isKeywordTrue(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'true';\n }\n\n isKeywordFalse(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'false';\n }\n\n isKeywordThis(): boolean {\n return this.type == TokenType.Keyword && this.strValue == 'this';\n }\n\n isError(): boolean {\n return this.type == TokenType.Error;\n }\n\n toNumber(): number {\n return this.type == TokenType.Number ? this.numValue : -1;\n }\n\n toString(): string | null {\n switch (this.type) {\n case TokenType.Character:\n case TokenType.Identifier:\n case TokenType.Keyword:\n case TokenType.Operator:\n case TokenType.PrivateIdentifier:\n case TokenType.String:\n case TokenType.Error:\n return this.strValue;\n case TokenType.Number:\n return this.numValue.toString();\n default:\n return null;\n }\n }\n}\n\nfunction newCharacterToken(index: number, end: number, code: number): Token {\n return new Token(index, end, TokenType.Character, code, String.fromCharCode(code));\n}\n\nfunction newIdentifierToken(index: number, end: number, text: string): Token {\n return new Token(index, end, TokenType.Identifier, 0, text);\n}\n\nfunction newPrivateIdentifierToken(index: number, end: number, text: string): Token {\n return new Token(index, end, TokenType.PrivateIdentifier, 0, text);\n}\n\nfunction newKeywordToken(index: number, end: number, text: string): Token {\n return new Token(index, end, TokenType.Keyword, 0, text);\n}\n\nfunction newOperatorToken(index: number, end: number, text: string): Token {\n return new Token(index, end, TokenType.Operator, 0, text);\n}\n\nfunction newStringToken(index: number, end: number, text: string): Token {\n return new Token(index, end, TokenType.String, 0, text);\n}\n\nfunction newNumberToken(index: number, end: number, n: number): Token {\n return new Token(index, end, TokenType.Number, n, '');\n}\n\nfunction newErrorToken(index: number, end: number, message: string): Token {\n return new Token(index, end, TokenType.Error, 0, message);\n}\n\nexport const EOF: Token = new Token(-1, -1, TokenType.Character, 0, '');\n\nclass _Scanner {\n length: number;\n peek: number = 0;\n index: number = -1;\n\n constructor(public input: string) {\n this.length = input.length;\n this.advance();\n }\n\n advance() {\n this.peek = ++this.index >= this.length ? chars.$EOF : this.input.charCodeAt(this.index);\n }\n\n scanToken(): Token | null {\n const input = this.input,\n length = this.length;\n let peek = this.peek,\n index = this.index;\n\n // Skip whitespace.\n while (peek <= chars.$SPACE) {\n if (++index >= length) {\n peek = chars.$EOF;\n break;\n } else {\n peek = input.charCodeAt(index);\n }\n }\n\n this.peek = peek;\n this.index = index;\n\n if (index >= length) {\n return null;\n }\n\n // Handle identifiers and numbers.\n if (isIdentifierStart(peek)) return this.scanIdentifier();\n if (chars.isDigit(peek)) return this.scanNumber(index);\n\n const start: number = index;\n switch (peek) {\n case chars.$PERIOD:\n this.advance();\n return chars.isDigit(this.peek)\n ? this.scanNumber(start)\n : newCharacterToken(start, this.index, chars.$PERIOD);\n case chars.$LPAREN:\n case chars.$RPAREN:\n case chars.$LBRACE:\n case chars.$RBRACE:\n case chars.$LBRACKET:\n case chars.$RBRACKET:\n case chars.$COMMA:\n case chars.$COLON:\n case chars.$SEMICOLON:\n return this.scanCharacter(start, peek);\n case chars.$SQ:\n case chars.$DQ:\n return this.scanString();\n case chars.$HASH:\n return this.scanPrivateIdentifier();\n case chars.$PLUS:\n case chars.$MINUS:\n case chars.$STAR:\n case chars.$SLASH:\n case chars.$PERCENT:\n case chars.$CARET:\n return this.scanOperator(start, String.fromCharCode(peek));\n case chars.$QUESTION:\n return this.scanQuestion(start);\n case chars.$LT:\n case chars.$GT:\n return this.scanComplexOperator(start, String.fromCharCode(peek), chars.$EQ, '=');\n case chars.$BANG:\n case chars.$EQ:\n return this.scanComplexOperator(\n start,\n String.fromCharCode(peek),\n chars.$EQ,\n '=',\n chars.$EQ,\n '=',\n );\n case chars.$AMPERSAND:\n return this.scanComplexOperator(start, '&', chars.$AMPERSAND, '&');\n case chars.$BAR:\n return this.scanComplexOperator(start, '|', chars.$BAR, '|');\n case chars.$NBSP:\n while (chars.isWhitespace(this.peek)) this.advance();\n return this.scanToken();\n }\n\n this.advance();\n return this.error(`Unexpected character [${String.fromCharCode(peek)}]`, 0);\n }\n\n scanCharacter(start: number, code: number): Token {\n this.advance();\n return newCharacterToken(start, this.index, code);\n }\n\n scanOperator(start: number, str: string): Token {\n this.advance();\n return newOperatorToken(start, this.index, str);\n }\n\n /**\n * Tokenize a 2/3 char long operator\n *\n * @param start start index in the expression\n * @param one first symbol (always part of the operator)\n * @param twoCode code point for the second symbol\n * @param two second symbol (part of the operator when the second code point matches)\n * @param threeCode code point for the third symbol\n * @param three third symbol (part of the operator when provided and matches source expression)\n */\n scanComplexOperator(\n start: number,\n one: string,\n twoCode: number,\n two: string,\n threeCode?: number,\n three?: string,\n ): Token {\n this.advance();\n let str: string = one;\n if (this.peek == twoCode) {\n this.advance();\n str += two;\n }\n if (threeCode != null && this.peek == threeCode) {\n this.advance();\n str += three;\n }\n return newOperatorToken(start, this.index, str);\n }\n\n scanIdentifier(): Token {\n const start: number = this.index;\n this.advance();\n while (isIdentifierPart(this.peek)) this.advance();\n const str: string = this.input.substring(start, this.index);\n return KEYWORDS.indexOf(str) > -1\n ? newKeywordToken(start, this.index, str)\n : newIdentifierToken(start, this.index, str);\n }\n\n /** Scans an ECMAScript private identifier. */\n scanPrivateIdentifier(): Token {\n const start: number = this.index;\n this.advance();\n if (!isIdentifierStart(this.peek)) {\n return this.error('Invalid character [#]', -1);\n }\n while (isIdentifierPart(this.peek)) this.advance();\n const identifierName: string = this.input.substring(start, this.index);\n return newPrivateIdentifierToken(start, this.index, identifierName);\n }\n\n scanNumber(start: number): Token {\n let simple = this.index === start;\n let hasSeparators = false;\n this.advance(); // Skip initial digit.\n while (true) {\n if (chars.isDigit(this.peek)) {\n // Do nothing.\n } else if (this.peek === chars.$_) {\n // Separators are only valid when they're surrounded by digits. E.g. `1_0_1` is\n // valid while `_101` and `101_` are not. The separator can't be next to the decimal\n // point or another separator either. Note that it's unlikely that we'll hit a case where\n // the underscore is at the start, because that's a valid identifier and it will be picked\n // up earlier in the parsing. We validate for it anyway just in case.\n if (\n !chars.isDigit(this.input.charCodeAt(this.index - 1)) ||\n !chars.isDigit(this.input.charCodeAt(this.index + 1))\n ) {\n return this.error('Invalid numeric separator', 0);\n }\n hasSeparators = true;\n } else if (this.peek === chars.$PERIOD) {\n simple = false;\n } else if (isExponentStart(this.peek)) {\n this.advance();\n if (isExponentSign(this.peek)) this.advance();\n if (!chars.isDigit(this.peek)) return this.error('Invalid exponent', -1);\n simple = false;\n } else {\n break;\n }\n this.advance();\n }\n\n let str = this.input.substring(start, this.index);\n if (hasSeparators) {\n str = str.replace(/_/g, '');\n }\n const value = simple ? parseIntAutoRadix(str) : parseFloat(str);\n return newNumberToken(start, this.index, value);\n }\n\n scanString(): Token {\n const start: number = this.index;\n const quote: number = this.peek;\n this.advance(); // Skip initial quote.\n\n let buffer: string = '';\n let marker: number = this.index;\n const input: string = this.input;\n\n while (this.peek != quote) {\n if (this.peek == chars.$BACKSLASH) {\n buffer += input.substring(marker, this.index);\n let unescapedCode: number;\n this.advance(); // mutates this.peek\n // @ts-expect-error see microsoft/TypeScript#9998\n if (this.peek == chars.$u) {\n // 4 character hex code for unicode character.\n const hex: string = input.substring(this.index + 1, this.index + 5);\n if (/^[0-9a-f]+$/i.test(hex)) {\n unescapedCode = parseInt(hex, 16);\n } else {\n return this.error(`Invalid unicode escape [\\\\u${hex}]`, 0);\n }\n for (let i: number = 0; i < 5; i++) {\n this.advance();\n }\n } else {\n unescapedCode = unescape(this.peek);\n this.advance();\n }\n buffer += String.fromCharCode(unescapedCode);\n marker = this.index;\n } else if (this.peek == chars.$EOF) {\n return this.error('Unterminated quote', 0);\n } else {\n this.advance();\n }\n }\n\n const last: string = input.substring(marker, this.index);\n this.advance(); // Skip terminating quote.\n\n return newStringToken(start, this.index, buffer + last);\n }\n\n scanQuestion(start: number): Token {\n this.advance();\n let str: string = '?';\n // Either `a ?? b` or 'a?.b'.\n if (this.peek === chars.$QUESTION || this.peek === chars.$PERIOD) {\n str += this.peek === chars.$PERIOD ? '.' : '?';\n this.advance();\n }\n return newOperatorToken(start, this.index, str);\n }\n\n error(message: string, offset: number): Token {\n const position: number = this.index + offset;\n return newErrorToken(\n position,\n this.index,\n `Lexer Error: ${message} at column ${position} in expression [${this.input}]`,\n );\n }\n}\n\nfunction isIdentifierStart(code: number): boolean {\n return (\n (chars.$a <= code && code <= chars.$z) ||\n (chars.$A <= code && code <= chars.$Z) ||\n code == chars.$_ ||\n code == chars.$$\n );\n}\n\nexport function isIdentifier(input: string): boolean {\n if (input.length == 0) return false;\n const scanner = new _Scanner(input);\n if (!isIdentifierStart(scanner.peek)) return false;\n scanner.advance();\n while (scanner.peek !== chars.$EOF) {\n if (!isIdentifierPart(scanner.peek)) return false;\n scanner.advance();\n }\n return true;\n}\n\nfunction isIdentifierPart(code: number): boolean {\n return chars.isAsciiLetter(code) || chars.isDigit(code) || code == chars.$_ || code == chars.$$;\n}\n\nfunction isExponentStart(code: number): boolean {\n return code == chars.$e || code == chars.$E;\n}\n\nfunction isExponentSign(code: number): boolean {\n return code == chars.$MINUS || code == chars.$PLUS;\n}\n\nfunction unescape(code: number): number {\n switch (code) {\n case chars.$n:\n return chars.$LF;\n case chars.$f:\n return chars.$FF;\n case chars.$r:\n return chars.$CR;\n case chars.$t:\n return chars.$TAB;\n case chars.$v:\n return chars.$VTAB;\n default:\n return code;\n }\n}\n\nfunction parseIntAutoRadix(text: string): number {\n const result: number = parseInt(text);\n if (isNaN(result)) {\n throw new Error('Invalid integer literal when parsing ' + text);\n }\n return result;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport * as chars from '../chars';\nimport {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/defaults';\nimport {\n InterpolatedAttributeToken,\n InterpolatedTextToken,\n TokenType as MlParserTokenType,\n} from '../ml_parser/tokens';\n\nimport {\n AbsoluteSourceSpan,\n AST,\n ASTWithSource,\n Binary,\n BindingPipe,\n Call,\n Chain,\n Conditional,\n EmptyExpr,\n ExpressionBinding,\n ImplicitReceiver,\n Interpolation,\n KeyedRead,\n KeyedWrite,\n LiteralArray,\n LiteralMap,\n LiteralMapKey,\n LiteralPrimitive,\n NonNullAssert,\n ParserError,\n ParseSpan,\n PrefixNot,\n PropertyRead,\n PropertyWrite,\n RecursiveAstVisitor,\n SafeCall,\n SafeKeyedRead,\n SafePropertyRead,\n TemplateBinding,\n TemplateBindingIdentifier,\n ThisReceiver,\n Unary,\n VariableBinding,\n} from './ast';\nimport {EOF, Lexer, Token, TokenType} from './lexer';\n\nexport interface InterpolationPiece {\n text: string;\n start: number;\n end: number;\n}\nexport class SplitInterpolation {\n constructor(\n public strings: InterpolationPiece[],\n public expressions: InterpolationPiece[],\n public offsets: number[],\n ) {}\n}\n\nexport class TemplateBindingParseResult {\n constructor(\n public templateBindings: TemplateBinding[],\n public warnings: string[],\n public errors: ParserError[],\n ) {}\n}\n\n/**\n * Represents the possible parse modes to be used as a bitmask.\n */\nexport const enum ParseFlags {\n None = 0,\n\n /**\n * Whether an output binding is being parsed.\n */\n Action = 1 << 0,\n}\n\nexport class Parser {\n private errors: ParserError[] = [];\n\n constructor(private _lexer: Lexer) {}\n\n parseAction(\n input: string,\n location: string,\n absoluteOffset: number,\n interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG,\n ): ASTWithSource {\n this._checkNoInterpolation(input, location, interpolationConfig);\n const sourceToLex = this._stripComments(input);\n const tokens = this._lexer.tokenize(sourceToLex);\n const ast = new _ParseAST(\n input,\n location,\n absoluteOffset,\n tokens,\n ParseFlags.Action,\n this.errors,\n 0,\n ).parseChain();\n\n return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);\n }\n\n parseBinding(\n input: string,\n location: string,\n absoluteOffset: number,\n interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG,\n ): ASTWithSource {\n const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig);\n return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);\n }\n\n private checkSimpleExpression(ast: AST): string[] {\n const checker = new SimpleExpressionChecker();\n ast.visit(checker);\n return checker.errors;\n }\n\n // Host bindings parsed here\n parseSimpleBinding(\n input: string,\n location: string,\n absoluteOffset: number,\n interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG,\n ): ASTWithSource {\n const ast = this._parseBindingAst(input, location, absoluteOffset, interpolationConfig);\n const errors = this.checkSimpleExpression(ast);\n if (errors.length > 0) {\n this._reportError(\n `Host binding expression cannot contain ${errors.join(' ')}`,\n input,\n location,\n );\n }\n return new ASTWithSource(ast, input, location, absoluteOffset, this.errors);\n }\n\n private _reportError(message: string, input: string, errLocation: string, ctxLocation?: string) {\n this.errors.push(new ParserError(message, input, errLocation, ctxLocation));\n }\n\n private _parseBindingAst(\n input: string,\n location: string,\n absoluteOffset: number,\n interpolationConfig: InterpolationConfig,\n ): AST {\n this._checkNoInterpolation(input, location, interpolationConfig);\n const sourceToLex = this._stripComments(input);\n const tokens = this._lexer.tokenize(sourceToLex);\n return new _ParseAST(\n input,\n location,\n absoluteOffset,\n tokens,\n ParseFlags.None,\n this.errors,\n 0,\n ).parseChain();\n }\n\n /**\n * Parse microsyntax template expression and return a list of bindings or\n * parsing errors in case the given expression is invalid.\n *\n * For example,\n * ```\n *
\n * ^ ^ absoluteValueOffset for `templateValue`\n * absoluteKeyOffset for `templateKey`\n * ```\n * contains three bindings:\n * 1. ngFor -> null\n * 2. item -> NgForOfContext.$implicit\n * 3. ngForOf -> items\n *\n * This is apparent from the de-sugared template:\n * ```\n * \n * ```\n *\n * @param templateKey name of directive, without the * prefix. For example: ngIf, ngFor\n * @param templateValue RHS of the microsyntax attribute\n * @param templateUrl template filename if it's external, component filename if it's inline\n * @param absoluteKeyOffset start of the `templateKey`\n * @param absoluteValueOffset start of the `templateValue`\n */\n parseTemplateBindings(\n templateKey: string,\n templateValue: string,\n templateUrl: string,\n absoluteKeyOffset: number,\n absoluteValueOffset: number,\n ): TemplateBindingParseResult {\n const tokens = this._lexer.tokenize(templateValue);\n const parser = new _ParseAST(\n templateValue,\n templateUrl,\n absoluteValueOffset,\n tokens,\n ParseFlags.None,\n this.errors,\n 0 /* relative offset */,\n );\n return parser.parseTemplateBindings({\n source: templateKey,\n span: new AbsoluteSourceSpan(absoluteKeyOffset, absoluteKeyOffset + templateKey.length),\n });\n }\n\n parseInterpolation(\n input: string,\n location: string,\n absoluteOffset: number,\n interpolatedTokens: InterpolatedAttributeToken[] | InterpolatedTextToken[] | null,\n interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG,\n ): ASTWithSource | null {\n const {strings, expressions, offsets} = this.splitInterpolation(\n input,\n location,\n interpolatedTokens,\n interpolationConfig,\n );\n if (expressions.length === 0) return null;\n\n const expressionNodes: AST[] = [];\n\n for (let i = 0; i < expressions.length; ++i) {\n const expressionText = expressions[i].text;\n const sourceToLex = this._stripComments(expressionText);\n const tokens = this._lexer.tokenize(sourceToLex);\n const ast = new _ParseAST(\n input,\n location,\n absoluteOffset,\n tokens,\n ParseFlags.None,\n this.errors,\n offsets[i],\n ).parseChain();\n expressionNodes.push(ast);\n }\n\n return this.createInterpolationAst(\n strings.map((s) => s.text),\n expressionNodes,\n input,\n location,\n absoluteOffset,\n );\n }\n\n /**\n * Similar to `parseInterpolation`, but treats the provided string as a single expression\n * element that would normally appear within the interpolation prefix and suffix (`{{` and `}}`).\n * This is used for parsing the switch expression in ICUs.\n */\n parseInterpolationExpression(\n expression: string,\n location: string,\n absoluteOffset: number,\n ): ASTWithSource {\n const sourceToLex = this._stripComments(expression);\n const tokens = this._lexer.tokenize(sourceToLex);\n const ast = new _ParseAST(\n expression,\n location,\n absoluteOffset,\n tokens,\n ParseFlags.None,\n this.errors,\n 0,\n ).parseChain();\n const strings = ['', '']; // The prefix and suffix strings are both empty\n return this.createInterpolationAst(strings, [ast], expression, location, absoluteOffset);\n }\n\n private createInterpolationAst(\n strings: string[],\n expressions: AST[],\n input: string,\n location: string,\n absoluteOffset: number,\n ): ASTWithSource {\n const span = new ParseSpan(0, input.length);\n const interpolation = new Interpolation(\n span,\n span.toAbsolute(absoluteOffset),\n strings,\n expressions,\n );\n return new ASTWithSource(interpolation, input, location, absoluteOffset, this.errors);\n }\n\n /**\n * Splits a string of text into \"raw\" text segments and expressions present in interpolations in\n * the string.\n * Returns `null` if there are no interpolations, otherwise a\n * `SplitInterpolation` with splits that look like\n * ... \n */\n splitInterpolation(\n input: string,\n location: string,\n interpolatedTokens: InterpolatedAttributeToken[] | InterpolatedTextToken[] | null,\n interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG,\n ): SplitInterpolation {\n const strings: InterpolationPiece[] = [];\n const expressions: InterpolationPiece[] = [];\n const offsets: number[] = [];\n const inputToTemplateIndexMap = interpolatedTokens\n ? getIndexMapForOriginalTemplate(interpolatedTokens)\n : null;\n let i = 0;\n let atInterpolation = false;\n let extendLastString = false;\n let {start: interpStart, end: interpEnd} = interpolationConfig;\n while (i < input.length) {\n if (!atInterpolation) {\n // parse until starting {{\n const start = i;\n i = input.indexOf(interpStart, i);\n if (i === -1) {\n i = input.length;\n }\n const text = input.substring(start, i);\n strings.push({text, start, end: i});\n\n atInterpolation = true;\n } else {\n // parse from starting {{ to ending }} while ignoring content inside quotes.\n const fullStart = i;\n const exprStart = fullStart + interpStart.length;\n const exprEnd = this._getInterpolationEndIndex(input, interpEnd, exprStart);\n if (exprEnd === -1) {\n // Could not find the end of the interpolation; do not parse an expression.\n // Instead we should extend the content on the last raw string.\n atInterpolation = false;\n extendLastString = true;\n break;\n }\n const fullEnd = exprEnd + interpEnd.length;\n\n const text = input.substring(exprStart, exprEnd);\n if (text.trim().length === 0) {\n this._reportError(\n 'Blank expressions are not allowed in interpolated strings',\n input,\n `at column ${i} in`,\n location,\n );\n }\n expressions.push({text, start: fullStart, end: fullEnd});\n const startInOriginalTemplate = inputToTemplateIndexMap?.get(fullStart) ?? fullStart;\n const offset = startInOriginalTemplate + interpStart.length;\n offsets.push(offset);\n\n i = fullEnd;\n atInterpolation = false;\n }\n }\n if (!atInterpolation) {\n // If we are now at a text section, add the remaining content as a raw string.\n if (extendLastString) {\n const piece = strings[strings.length - 1];\n piece.text += input.substring(i);\n piece.end = input.length;\n } else {\n strings.push({text: input.substring(i), start: i, end: input.length});\n }\n }\n return new SplitInterpolation(strings, expressions, offsets);\n }\n\n wrapLiteralPrimitive(\n input: string | null,\n location: string,\n absoluteOffset: number,\n ): ASTWithSource {\n const span = new ParseSpan(0, input == null ? 0 : input.length);\n return new ASTWithSource(\n new LiteralPrimitive(span, span.toAbsolute(absoluteOffset), input),\n input,\n location,\n absoluteOffset,\n this.errors,\n );\n }\n\n private _stripComments(input: string): string {\n const i = this._commentStart(input);\n return i != null ? input.substring(0, i) : input;\n }\n\n private _commentStart(input: string): number | null {\n let outerQuote: number | null = null;\n for (let i = 0; i < input.length - 1; i++) {\n const char = input.charCodeAt(i);\n const nextChar = input.charCodeAt(i + 1);\n\n if (char === chars.$SLASH && nextChar == chars.$SLASH && outerQuote == null) return i;\n\n if (outerQuote === char) {\n outerQuote = null;\n } else if (outerQuote == null && chars.isQuote(char)) {\n outerQuote = char;\n }\n }\n return null;\n }\n\n private _checkNoInterpolation(\n input: string,\n location: string,\n {start, end}: InterpolationConfig,\n ): void {\n let startIndex = -1;\n let endIndex = -1;\n\n for (const charIndex of this._forEachUnquotedChar(input, 0)) {\n if (startIndex === -1) {\n if (input.startsWith(start)) {\n startIndex = charIndex;\n }\n } else {\n endIndex = this._getInterpolationEndIndex(input, end, charIndex);\n if (endIndex > -1) {\n break;\n }\n }\n }\n\n if (startIndex > -1 && endIndex > -1) {\n this._reportError(\n `Got interpolation (${start}${end}) where expression was expected`,\n input,\n `at column ${startIndex} in`,\n location,\n );\n }\n }\n\n /**\n * Finds the index of the end of an interpolation expression\n * while ignoring comments and quoted content.\n */\n private _getInterpolationEndIndex(input: string, expressionEnd: string, start: number): number {\n for (const charIndex of this._forEachUnquotedChar(input, start)) {\n if (input.startsWith(expressionEnd, charIndex)) {\n return charIndex;\n }\n\n // Nothing else in the expression matters after we've\n // hit a comment so look directly for the end token.\n if (input.startsWith('//', charIndex)) {\n return input.indexOf(expressionEnd, charIndex);\n }\n }\n\n return -1;\n }\n\n /**\n * Generator used to iterate over the character indexes of a string that are outside of quotes.\n * @param input String to loop through.\n * @param start Index within the string at which to start.\n */\n private *_forEachUnquotedChar(input: string, start: number) {\n let currentQuote: string | null = null;\n let escapeCount = 0;\n for (let i = start; i < input.length; i++) {\n const char = input[i];\n // Skip the characters inside quotes. Note that we only care about the outer-most\n // quotes matching up and we need to account for escape characters.\n if (\n chars.isQuote(input.charCodeAt(i)) &&\n (currentQuote === null || currentQuote === char) &&\n escapeCount % 2 === 0\n ) {\n currentQuote = currentQuote === null ? char : null;\n } else if (currentQuote === null) {\n yield i;\n }\n escapeCount = char === '\\\\' ? escapeCount + 1 : 0;\n }\n }\n}\n\n/** Describes a stateful context an expression parser is in. */\nenum ParseContextFlags {\n None = 0,\n /**\n * A Writable context is one in which a value may be written to an lvalue.\n * For example, after we see a property access, we may expect a write to the\n * property via the \"=\" operator.\n * prop\n * ^ possible \"=\" after\n */\n Writable = 1,\n}\n\nclass _ParseAST {\n private rparensExpected = 0;\n private rbracketsExpected = 0;\n private rbracesExpected = 0;\n private context = ParseContextFlags.None;\n\n // Cache of expression start and input indeces to the absolute source span they map to, used to\n // prevent creating superfluous source spans in `sourceSpan`.\n // A serial of the expression start and input index is used for mapping because both are stateful\n // and may change for subsequent expressions visited by the parser.\n private sourceSpanCache = new Map();\n\n private index: number = 0;\n\n constructor(\n private input: string,\n private location: string,\n private absoluteOffset: number,\n private tokens: Token[],\n private parseFlags: ParseFlags,\n private errors: ParserError[],\n private offset: number,\n ) {}\n\n private peek(offset: number): Token {\n const i = this.index + offset;\n return i < this.tokens.length ? this.tokens[i] : EOF;\n }\n\n private get next(): Token {\n return this.peek(0);\n }\n\n /** Whether all the parser input has been processed. */\n private get atEOF(): boolean {\n return this.index >= this.tokens.length;\n }\n\n /**\n * Index of the next token to be processed, or the end of the last token if all have been\n * processed.\n */\n private get inputIndex(): number {\n return this.atEOF ? this.currentEndIndex : this.next.index + this.offset;\n }\n\n /**\n * End index of the last processed token, or the start of the first token if none have been\n * processed.\n */\n private get currentEndIndex(): number {\n if (this.index > 0) {\n const curToken = this.peek(-1);\n return curToken.end + this.offset;\n }\n // No tokens have been processed yet; return the next token's start or the length of the input\n // if there is no token.\n if (this.tokens.length === 0) {\n return this.input.length + this.offset;\n }\n return this.next.index + this.offset;\n }\n\n /**\n * Returns the absolute offset of the start of the current token.\n */\n private get currentAbsoluteOffset(): number {\n return this.absoluteOffset + this.inputIndex;\n }\n\n /**\n * Retrieve a `ParseSpan` from `start` to the current position (or to `artificialEndIndex` if\n * provided).\n *\n * @param start Position from which the `ParseSpan` will start.\n * @param artificialEndIndex Optional ending index to be used if provided (and if greater than the\n * natural ending index)\n */\n private span(start: number, artificialEndIndex?: number): ParseSpan {\n let endIndex = this.currentEndIndex;\n if (artificialEndIndex !== undefined && artificialEndIndex > this.currentEndIndex) {\n endIndex = artificialEndIndex;\n }\n\n // In some unusual parsing scenarios (like when certain tokens are missing and an `EmptyExpr` is\n // being created), the current token may already be advanced beyond the `currentEndIndex`. This\n // appears to be a deep-seated parser bug.\n //\n // As a workaround for now, swap the start and end indices to ensure a valid `ParseSpan`.\n // TODO(alxhub): fix the bug upstream in the parser state, and remove this workaround.\n if (start > endIndex) {\n const tmp = endIndex;\n endIndex = start;\n start = tmp;\n }\n\n return new ParseSpan(start, endIndex);\n }\n\n private sourceSpan(start: number, artificialEndIndex?: number): AbsoluteSourceSpan {\n const serial = `${start}@${this.inputIndex}:${artificialEndIndex}`;\n if (!this.sourceSpanCache.has(serial)) {\n this.sourceSpanCache.set(\n serial,\n this.span(start, artificialEndIndex).toAbsolute(this.absoluteOffset),\n );\n }\n return this.sourceSpanCache.get(serial)!;\n }\n\n private advance() {\n this.index++;\n }\n\n /**\n * Executes a callback in the provided context.\n */\n private withContext(context: ParseContextFlags, cb: () => T): T {\n this.context |= context;\n const ret = cb();\n this.context ^= context;\n return ret;\n }\n\n private consumeOptionalCharacter(code: number): boolean {\n if (this.next.isCharacter(code)) {\n this.advance();\n return true;\n } else {\n return false;\n }\n }\n\n private peekKeywordLet(): boolean {\n return this.next.isKeywordLet();\n }\n\n private peekKeywordAs(): boolean {\n return this.next.isKeywordAs();\n }\n\n /**\n * Consumes an expected character, otherwise emits an error about the missing expected character\n * and skips over the token stream until reaching a recoverable point.\n *\n * See `this.error` and `this.skip` for more details.\n */\n private expectCharacter(code: number) {\n if (this.consumeOptionalCharacter(code)) return;\n this.error(`Missing expected ${String.fromCharCode(code)}`);\n }\n\n private consumeOptionalOperator(op: string): boolean {\n if (this.next.isOperator(op)) {\n this.advance();\n return true;\n } else {\n return false;\n }\n }\n\n private expectOperator(operator: string) {\n if (this.consumeOptionalOperator(operator)) return;\n this.error(`Missing expected operator ${operator}`);\n }\n\n private prettyPrintToken(tok: Token): string {\n return tok === EOF ? 'end of input' : `token ${tok}`;\n }\n\n private expectIdentifierOrKeyword(): string | null {\n const n = this.next;\n if (!n.isIdentifier() && !n.isKeyword()) {\n if (n.isPrivateIdentifier()) {\n this._reportErrorForPrivateIdentifier(n, 'expected identifier or keyword');\n } else {\n this.error(`Unexpected ${this.prettyPrintToken(n)}, expected identifier or keyword`);\n }\n return null;\n }\n this.advance();\n return n.toString() as string;\n }\n\n private expectIdentifierOrKeywordOrString(): string {\n const n = this.next;\n if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {\n if (n.isPrivateIdentifier()) {\n this._reportErrorForPrivateIdentifier(n, 'expected identifier, keyword or string');\n } else {\n this.error(\n `Unexpected ${this.prettyPrintToken(n)}, expected identifier, keyword, or string`,\n );\n }\n return '';\n }\n this.advance();\n return n.toString() as string;\n }\n\n parseChain(): AST {\n const exprs: AST[] = [];\n const start = this.inputIndex;\n while (this.index < this.tokens.length) {\n const expr = this.parsePipe();\n exprs.push(expr);\n\n if (this.consumeOptionalCharacter(chars.$SEMICOLON)) {\n if (!(this.parseFlags & ParseFlags.Action)) {\n this.error('Binding expression cannot contain chained expression');\n }\n while (this.consumeOptionalCharacter(chars.$SEMICOLON)) {} // read all semicolons\n } else if (this.index < this.tokens.length) {\n const errorIndex = this.index;\n this.error(`Unexpected token '${this.next}'`);\n // The `error` call above will skip ahead to the next recovery point in an attempt to\n // recover part of the expression, but that might be the token we started from which will\n // lead to an infinite loop. If that's the case, break the loop assuming that we can't\n // parse further.\n if (this.index === errorIndex) {\n break;\n }\n }\n }\n if (exprs.length === 0) {\n // We have no expressions so create an empty expression that spans the entire input length\n const artificialStart = this.offset;\n const artificialEnd = this.offset + this.input.length;\n return new EmptyExpr(\n this.span(artificialStart, artificialEnd),\n this.sourceSpan(artificialStart, artificialEnd),\n );\n }\n if (exprs.length == 1) return exprs[0];\n return new Chain(this.span(start), this.sourceSpan(start), exprs);\n }\n\n private parsePipe(): AST {\n const start = this.inputIndex;\n let result = this.parseExpression();\n if (this.consumeOptionalOperator('|')) {\n if (this.parseFlags & ParseFlags.Action) {\n this.error(`Cannot have a pipe in an action expression`);\n }\n\n do {\n const nameStart = this.inputIndex;\n let nameId = this.expectIdentifierOrKeyword();\n let nameSpan: AbsoluteSourceSpan;\n let fullSpanEnd: number | undefined = undefined;\n if (nameId !== null) {\n nameSpan = this.sourceSpan(nameStart);\n } else {\n // No valid identifier was found, so we'll assume an empty pipe name ('').\n nameId = '';\n\n // However, there may have been whitespace present between the pipe character and the next\n // token in the sequence (or the end of input). We want to track this whitespace so that\n // the `BindingPipe` we produce covers not just the pipe character, but any trailing\n // whitespace beyond it. Another way of thinking about this is that the zero-length name\n // is assumed to be at the end of any whitespace beyond the pipe character.\n //\n // Therefore, we push the end of the `ParseSpan` for this pipe all the way up to the\n // beginning of the next token, or until the end of input if the next token is EOF.\n fullSpanEnd = this.next.index !== -1 ? this.next.index : this.input.length + this.offset;\n\n // The `nameSpan` for an empty pipe name is zero-length at the end of any whitespace\n // beyond the pipe character.\n nameSpan = new ParseSpan(fullSpanEnd, fullSpanEnd).toAbsolute(this.absoluteOffset);\n }\n\n const args: AST[] = [];\n while (this.consumeOptionalCharacter(chars.$COLON)) {\n args.push(this.parseExpression());\n\n // If there are additional expressions beyond the name, then the artificial end for the\n // name is no longer relevant.\n }\n result = new BindingPipe(\n this.span(start),\n this.sourceSpan(start, fullSpanEnd),\n result,\n nameId,\n args,\n nameSpan,\n );\n } while (this.consumeOptionalOperator('|'));\n }\n\n return result;\n }\n\n private parseExpression(): AST {\n return this.parseConditional();\n }\n\n private parseConditional(): AST {\n const start = this.inputIndex;\n const result = this.parseLogicalOr();\n\n if (this.consumeOptionalOperator('?')) {\n const yes = this.parsePipe();\n let no: AST;\n if (!this.consumeOptionalCharacter(chars.$COLON)) {\n const end = this.inputIndex;\n const expression = this.input.substring(start, end);\n this.error(`Conditional expression ${expression} requires all 3 expressions`);\n no = new EmptyExpr(this.span(start), this.sourceSpan(start));\n } else {\n no = this.parsePipe();\n }\n return new Conditional(this.span(start), this.sourceSpan(start), result, yes, no);\n } else {\n return result;\n }\n }\n\n private parseLogicalOr(): AST {\n // '||'\n const start = this.inputIndex;\n let result = this.parseLogicalAnd();\n while (this.consumeOptionalOperator('||')) {\n const right = this.parseLogicalAnd();\n result = new Binary(this.span(start), this.sourceSpan(start), '||', result, right);\n }\n return result;\n }\n\n private parseLogicalAnd(): AST {\n // '&&'\n const start = this.inputIndex;\n let result = this.parseNullishCoalescing();\n while (this.consumeOptionalOperator('&&')) {\n const right = this.parseNullishCoalescing();\n result = new Binary(this.span(start), this.sourceSpan(start), '&&', result, right);\n }\n return result;\n }\n\n private parseNullishCoalescing(): AST {\n // '??'\n const start = this.inputIndex;\n let result = this.parseEquality();\n while (this.consumeOptionalOperator('??')) {\n const right = this.parseEquality();\n result = new Binary(this.span(start), this.sourceSpan(start), '??', result, right);\n }\n return result;\n }\n\n private parseEquality(): AST {\n // '==','!=','===','!=='\n const start = this.inputIndex;\n let result = this.parseRelational();\n while (this.next.type == TokenType.Operator) {\n const operator = this.next.strValue;\n switch (operator) {\n case '==':\n case '===':\n case '!=':\n case '!==':\n this.advance();\n const right = this.parseRelational();\n result = new Binary(this.span(start), this.sourceSpan(start), operator, result, right);\n continue;\n }\n break;\n }\n return result;\n }\n\n private parseRelational(): AST {\n // '<', '>', '<=', '>='\n const start = this.inputIndex;\n let result = this.parseAdditive();\n while (this.next.type == TokenType.Operator) {\n const operator = this.next.strValue;\n switch (operator) {\n case '<':\n case '>':\n case '<=':\n case '>=':\n this.advance();\n const right = this.parseAdditive();\n result = new Binary(this.span(start), this.sourceSpan(start), operator, result, right);\n continue;\n }\n break;\n }\n return result;\n }\n\n private parseAdditive(): AST {\n // '+', '-'\n const start = this.inputIndex;\n let result = this.parseMultiplicative();\n while (this.next.type == TokenType.Operator) {\n const operator = this.next.strValue;\n switch (operator) {\n case '+':\n case '-':\n this.advance();\n let right = this.parseMultiplicative();\n result = new Binary(this.span(start), this.sourceSpan(start), operator, result, right);\n continue;\n }\n break;\n }\n return result;\n }\n\n private parseMultiplicative(): AST {\n // '*', '%', '/'\n const start = this.inputIndex;\n let result = this.parsePrefix();\n while (this.next.type == TokenType.Operator) {\n const operator = this.next.strValue;\n switch (operator) {\n case '*':\n case '%':\n case '/':\n this.advance();\n let right = this.parsePrefix();\n result = new Binary(this.span(start), this.sourceSpan(start), operator, result, right);\n continue;\n }\n break;\n }\n return result;\n }\n\n private parsePrefix(): AST {\n if (this.next.type == TokenType.Operator) {\n const start = this.inputIndex;\n const operator = this.next.strValue;\n let result: AST;\n switch (operator) {\n case '+':\n this.advance();\n result = this.parsePrefix();\n return Unary.createPlus(this.span(start), this.sourceSpan(start), result);\n case '-':\n this.advance();\n result = this.parsePrefix();\n return Unary.createMinus(this.span(start), this.sourceSpan(start), result);\n case '!':\n this.advance();\n result = this.parsePrefix();\n return new PrefixNot(this.span(start), this.sourceSpan(start), result);\n }\n }\n return this.parseCallChain();\n }\n\n private parseCallChain(): AST {\n const start = this.inputIndex;\n let result = this.parsePrimary();\n while (true) {\n if (this.consumeOptionalCharacter(chars.$PERIOD)) {\n result = this.parseAccessMember(result, start, false);\n } else if (this.consumeOptionalOperator('?.')) {\n if (this.consumeOptionalCharacter(chars.$LPAREN)) {\n result = this.parseCall(result, start, true);\n } else {\n result = this.consumeOptionalCharacter(chars.$LBRACKET)\n ? this.parseKeyedReadOrWrite(result, start, true)\n : this.parseAccessMember(result, start, true);\n }\n } else if (this.consumeOptionalCharacter(chars.$LBRACKET)) {\n result = this.parseKeyedReadOrWrite(result, start, false);\n } else if (this.consumeOptionalCharacter(chars.$LPAREN)) {\n result = this.parseCall(result, start, false);\n } else if (this.consumeOptionalOperator('!')) {\n result = new NonNullAssert(this.span(start), this.sourceSpan(start), result);\n } else {\n return result;\n }\n }\n }\n\n private parsePrimary(): AST {\n const start = this.inputIndex;\n if (this.consumeOptionalCharacter(chars.$LPAREN)) {\n this.rparensExpected++;\n const result = this.parsePipe();\n this.rparensExpected--;\n this.expectCharacter(chars.$RPAREN);\n return result;\n } else if (this.next.isKeywordNull()) {\n this.advance();\n return new LiteralPrimitive(this.span(start), this.sourceSpan(start), null);\n } else if (this.next.isKeywordUndefined()) {\n this.advance();\n return new LiteralPrimitive(this.span(start), this.sourceSpan(start), void 0);\n } else if (this.next.isKeywordTrue()) {\n this.advance();\n return new LiteralPrimitive(this.span(start), this.sourceSpan(start), true);\n } else if (this.next.isKeywordFalse()) {\n this.advance();\n return new LiteralPrimitive(this.span(start), this.sourceSpan(start), false);\n } else if (this.next.isKeywordThis()) {\n this.advance();\n return new ThisReceiver(this.span(start), this.sourceSpan(start));\n } else if (this.consumeOptionalCharacter(chars.$LBRACKET)) {\n this.rbracketsExpected++;\n const elements = this.parseExpressionList(chars.$RBRACKET);\n this.rbracketsExpected--;\n this.expectCharacter(chars.$RBRACKET);\n return new LiteralArray(this.span(start), this.sourceSpan(start), elements);\n } else if (this.next.isCharacter(chars.$LBRACE)) {\n return this.parseLiteralMap();\n } else if (this.next.isIdentifier()) {\n return this.parseAccessMember(\n new ImplicitReceiver(this.span(start), this.sourceSpan(start)),\n start,\n false,\n );\n } else if (this.next.isNumber()) {\n const value = this.next.toNumber();\n this.advance();\n return new LiteralPrimitive(this.span(start), this.sourceSpan(start), value);\n } else if (this.next.isString()) {\n const literalValue = this.next.toString();\n this.advance();\n return new LiteralPrimitive(this.span(start), this.sourceSpan(start), literalValue);\n } else if (this.next.isPrivateIdentifier()) {\n this._reportErrorForPrivateIdentifier(this.next, null);\n return new EmptyExpr(this.span(start), this.sourceSpan(start));\n } else if (this.index >= this.tokens.length) {\n this.error(`Unexpected end of expression: ${this.input}`);\n return new EmptyExpr(this.span(start), this.sourceSpan(start));\n } else {\n this.error(`Unexpected token ${this.next}`);\n return new EmptyExpr(this.span(start), this.sourceSpan(start));\n }\n }\n\n private parseExpressionList(terminator: number): AST[] {\n const result: AST[] = [];\n\n do {\n if (!this.next.isCharacter(terminator)) {\n result.push(this.parsePipe());\n } else {\n break;\n }\n } while (this.consumeOptionalCharacter(chars.$COMMA));\n return result;\n }\n\n private parseLiteralMap(): LiteralMap {\n const keys: LiteralMapKey[] = [];\n const values: AST[] = [];\n const start = this.inputIndex;\n this.expectCharacter(chars.$LBRACE);\n if (!this.consumeOptionalCharacter(chars.$RBRACE)) {\n this.rbracesExpected++;\n do {\n const keyStart = this.inputIndex;\n const quoted = this.next.isString();\n const key = this.expectIdentifierOrKeywordOrString();\n const literalMapKey: LiteralMapKey = {key, quoted};\n keys.push(literalMapKey);\n\n // Properties with quoted keys can't use the shorthand syntax.\n if (quoted) {\n this.expectCharacter(chars.$COLON);\n values.push(this.parsePipe());\n } else if (this.consumeOptionalCharacter(chars.$COLON)) {\n values.push(this.parsePipe());\n } else {\n literalMapKey.isShorthandInitialized = true;\n\n const span = this.span(keyStart);\n const sourceSpan = this.sourceSpan(keyStart);\n values.push(\n new PropertyRead(\n span,\n sourceSpan,\n sourceSpan,\n new ImplicitReceiver(span, sourceSpan),\n key,\n ),\n );\n }\n } while (\n this.consumeOptionalCharacter(chars.$COMMA) &&\n !this.next.isCharacter(chars.$RBRACE)\n );\n this.rbracesExpected--;\n this.expectCharacter(chars.$RBRACE);\n }\n return new LiteralMap(this.span(start), this.sourceSpan(start), keys, values);\n }\n\n private parseAccessMember(readReceiver: AST, start: number, isSafe: boolean): AST {\n const nameStart = this.inputIndex;\n const id = this.withContext(ParseContextFlags.Writable, () => {\n const id = this.expectIdentifierOrKeyword() ?? '';\n if (id.length === 0) {\n this.error(`Expected identifier for property access`, readReceiver.span.end);\n }\n return id;\n });\n const nameSpan = this.sourceSpan(nameStart);\n let receiver: AST;\n\n if (isSafe) {\n if (this.consumeOptionalOperator('=')) {\n this.error(\"The '?.' operator cannot be used in the assignment\");\n receiver = new EmptyExpr(this.span(start), this.sourceSpan(start));\n } else {\n receiver = new SafePropertyRead(\n this.span(start),\n this.sourceSpan(start),\n nameSpan,\n readReceiver,\n id,\n );\n }\n } else {\n if (this.consumeOptionalOperator('=')) {\n if (!(this.parseFlags & ParseFlags.Action)) {\n this.error('Bindings cannot contain assignments');\n return new EmptyExpr(this.span(start), this.sourceSpan(start));\n }\n\n const value = this.parseConditional();\n receiver = new PropertyWrite(\n this.span(start),\n this.sourceSpan(start),\n nameSpan,\n readReceiver,\n id,\n value,\n );\n } else {\n receiver = new PropertyRead(\n this.span(start),\n this.sourceSpan(start),\n nameSpan,\n readReceiver,\n id,\n );\n }\n }\n\n return receiver;\n }\n\n private parseCall(receiver: AST, start: number, isSafe: boolean): AST {\n const argumentStart = this.inputIndex;\n this.rparensExpected++;\n const args = this.parseCallArguments();\n const argumentSpan = this.span(argumentStart, this.inputIndex).toAbsolute(this.absoluteOffset);\n this.expectCharacter(chars.$RPAREN);\n this.rparensExpected--;\n const span = this.span(start);\n const sourceSpan = this.sourceSpan(start);\n return isSafe\n ? new SafeCall(span, sourceSpan, receiver, args, argumentSpan)\n : new Call(span, sourceSpan, receiver, args, argumentSpan);\n }\n\n private parseCallArguments(): BindingPipe[] {\n if (this.next.isCharacter(chars.$RPAREN)) return [];\n const positionals: AST[] = [];\n do {\n positionals.push(this.parsePipe());\n } while (this.consumeOptionalCharacter(chars.$COMMA));\n return positionals as BindingPipe[];\n }\n\n /**\n * Parses an identifier, a keyword, a string with an optional `-` in between,\n * and returns the string along with its absolute source span.\n */\n private expectTemplateBindingKey(): TemplateBindingIdentifier {\n let result = '';\n let operatorFound = false;\n const start = this.currentAbsoluteOffset;\n do {\n result += this.expectIdentifierOrKeywordOrString();\n operatorFound = this.consumeOptionalOperator('-');\n if (operatorFound) {\n result += '-';\n }\n } while (operatorFound);\n return {\n source: result,\n span: new AbsoluteSourceSpan(start, start + result.length),\n };\n }\n\n /**\n * Parse microsyntax template expression and return a list of bindings or\n * parsing errors in case the given expression is invalid.\n *\n * For example,\n * ```\n *
\n * ```\n * contains five bindings:\n * 1. ngFor -> null\n * 2. item -> NgForOfContext.$implicit\n * 3. ngForOf -> items\n * 4. i -> NgForOfContext.index\n * 5. ngForTrackBy -> func\n *\n * For a full description of the microsyntax grammar, see\n * https://gist.github.com/mhevery/d3530294cff2e4a1b3fe15ff75d08855\n *\n * @param templateKey name of the microsyntax directive, like ngIf, ngFor,\n * without the *, along with its absolute span.\n */\n parseTemplateBindings(templateKey: TemplateBindingIdentifier): TemplateBindingParseResult {\n const bindings: TemplateBinding[] = [];\n\n // The first binding is for the template key itself\n // In *ngFor=\"let item of items\", key = \"ngFor\", value = null\n // In *ngIf=\"cond | pipe\", key = \"ngIf\", value = \"cond | pipe\"\n bindings.push(...this.parseDirectiveKeywordBindings(templateKey));\n\n while (this.index < this.tokens.length) {\n // If it starts with 'let', then this must be variable declaration\n const letBinding = this.parseLetBinding();\n if (letBinding) {\n bindings.push(letBinding);\n } else {\n // Two possible cases here, either `value \"as\" key` or\n // \"directive-keyword expression\". We don't know which case, but both\n // \"value\" and \"directive-keyword\" are template binding key, so consume\n // the key first.\n const key = this.expectTemplateBindingKey();\n // Peek at the next token, if it is \"as\" then this must be variable\n // declaration.\n const binding = this.parseAsBinding(key);\n if (binding) {\n bindings.push(binding);\n } else {\n // Otherwise the key must be a directive keyword, like \"of\". Transform\n // the key to actual key. Eg. of -> ngForOf, trackBy -> ngForTrackBy\n key.source =\n templateKey.source + key.source.charAt(0).toUpperCase() + key.source.substring(1);\n bindings.push(...this.parseDirectiveKeywordBindings(key));\n }\n }\n this.consumeStatementTerminator();\n }\n\n return new TemplateBindingParseResult(bindings, [] /* warnings */, this.errors);\n }\n\n private parseKeyedReadOrWrite(receiver: AST, start: number, isSafe: boolean): AST {\n return this.withContext(ParseContextFlags.Writable, () => {\n this.rbracketsExpected++;\n const key = this.parsePipe();\n if (key instanceof EmptyExpr) {\n this.error(`Key access cannot be empty`);\n }\n this.rbracketsExpected--;\n this.expectCharacter(chars.$RBRACKET);\n if (this.consumeOptionalOperator('=')) {\n if (isSafe) {\n this.error(\"The '?.' operator cannot be used in the assignment\");\n } else {\n const value = this.parseConditional();\n return new KeyedWrite(this.span(start), this.sourceSpan(start), receiver, key, value);\n }\n } else {\n return isSafe\n ? new SafeKeyedRead(this.span(start), this.sourceSpan(start), receiver, key)\n : new KeyedRead(this.span(start), this.sourceSpan(start), receiver, key);\n }\n\n return new EmptyExpr(this.span(start), this.sourceSpan(start));\n });\n }\n\n /**\n * Parse a directive keyword, followed by a mandatory expression.\n * For example, \"of items\", \"trackBy: func\".\n * The bindings are: ngForOf -> items, ngForTrackBy -> func\n * There could be an optional \"as\" binding that follows the expression.\n * For example,\n * ```\n * *ngFor=\"let item of items | slice:0:1 as collection\".\n * ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^\n * keyword bound target optional 'as' binding\n * ```\n *\n * @param key binding key, for example, ngFor, ngIf, ngForOf, along with its\n * absolute span.\n */\n private parseDirectiveKeywordBindings(key: TemplateBindingIdentifier): TemplateBinding[] {\n const bindings: TemplateBinding[] = [];\n this.consumeOptionalCharacter(chars.$COLON); // trackBy: trackByFunction\n const value = this.getDirectiveBoundTarget();\n let spanEnd = this.currentAbsoluteOffset;\n // The binding could optionally be followed by \"as\". For example,\n // *ngIf=\"cond | pipe as x\". In this case, the key in the \"as\" binding\n // is \"x\" and the value is the template key itself (\"ngIf\"). Note that the\n // 'key' in the current context now becomes the \"value\" in the next binding.\n const asBinding = this.parseAsBinding(key);\n if (!asBinding) {\n this.consumeStatementTerminator();\n spanEnd = this.currentAbsoluteOffset;\n }\n const sourceSpan = new AbsoluteSourceSpan(key.span.start, spanEnd);\n bindings.push(new ExpressionBinding(sourceSpan, key, value));\n if (asBinding) {\n bindings.push(asBinding);\n }\n return bindings;\n }\n\n /**\n * Return the expression AST for the bound target of a directive keyword\n * binding. For example,\n * ```\n * *ngIf=\"condition | pipe\"\n * ^^^^^^^^^^^^^^^^ bound target for \"ngIf\"\n * *ngFor=\"let item of items\"\n * ^^^^^ bound target for \"ngForOf\"\n * ```\n */\n private getDirectiveBoundTarget(): ASTWithSource | null {\n if (this.next === EOF || this.peekKeywordAs() || this.peekKeywordLet()) {\n return null;\n }\n const ast = this.parsePipe(); // example: \"condition | async\"\n const {start, end} = ast.span;\n const value = this.input.substring(start, end);\n return new ASTWithSource(ast, value, this.location, this.absoluteOffset + start, this.errors);\n }\n\n /**\n * Return the binding for a variable declared using `as`. Note that the order\n * of the key-value pair in this declaration is reversed. For example,\n * ```\n * *ngFor=\"let item of items; index as i\"\n * ^^^^^ ^\n * value key\n * ```\n *\n * @param value name of the value in the declaration, \"ngIf\" in the example\n * above, along with its absolute span.\n */\n private parseAsBinding(value: TemplateBindingIdentifier): TemplateBinding | null {\n if (!this.peekKeywordAs()) {\n return null;\n }\n this.advance(); // consume the 'as' keyword\n const key = this.expectTemplateBindingKey();\n this.consumeStatementTerminator();\n const sourceSpan = new AbsoluteSourceSpan(value.span.start, this.currentAbsoluteOffset);\n return new VariableBinding(sourceSpan, key, value);\n }\n\n /**\n * Return the binding for a variable declared using `let`. For example,\n * ```\n * *ngFor=\"let item of items; let i=index;\"\n * ^^^^^^^^ ^^^^^^^^^^^\n * ```\n * In the first binding, `item` is bound to `NgForOfContext.$implicit`.\n * In the second binding, `i` is bound to `NgForOfContext.index`.\n */\n private parseLetBinding(): TemplateBinding | null {\n if (!this.peekKeywordLet()) {\n return null;\n }\n const spanStart = this.currentAbsoluteOffset;\n this.advance(); // consume the 'let' keyword\n const key = this.expectTemplateBindingKey();\n let value: TemplateBindingIdentifier | null = null;\n if (this.consumeOptionalOperator('=')) {\n value = this.expectTemplateBindingKey();\n }\n this.consumeStatementTerminator();\n const sourceSpan = new AbsoluteSourceSpan(spanStart, this.currentAbsoluteOffset);\n return new VariableBinding(sourceSpan, key, value);\n }\n\n /**\n * Consume the optional statement terminator: semicolon or comma.\n */\n private consumeStatementTerminator() {\n this.consumeOptionalCharacter(chars.$SEMICOLON) || this.consumeOptionalCharacter(chars.$COMMA);\n }\n\n /**\n * Records an error and skips over the token stream until reaching a recoverable point. See\n * `this.skip` for more details on token skipping.\n */\n private error(message: string, index: number | null = null) {\n this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location));\n this.skip();\n }\n\n private locationText(index: number | null = null) {\n if (index == null) index = this.index;\n return index < this.tokens.length\n ? `at column ${this.tokens[index].index + 1} in`\n : `at the end of the expression`;\n }\n\n /**\n * Records an error for an unexpected private identifier being discovered.\n * @param token Token representing a private identifier.\n * @param extraMessage Optional additional message being appended to the error.\n */\n private _reportErrorForPrivateIdentifier(token: Token, extraMessage: string | null) {\n let errorMessage = `Private identifiers are not supported. Unexpected private identifier: ${token}`;\n if (extraMessage !== null) {\n errorMessage += `, ${extraMessage}`;\n }\n this.error(errorMessage);\n }\n\n /**\n * Error recovery should skip tokens until it encounters a recovery point.\n *\n * The following are treated as unconditional recovery points:\n * - end of input\n * - ';' (parseChain() is always the root production, and it expects a ';')\n * - '|' (since pipes may be chained and each pipe expression may be treated independently)\n *\n * The following are conditional recovery points:\n * - ')', '}', ']' if one of calling productions is expecting one of these symbols\n * - This allows skip() to recover from errors such as '(a.) + 1' allowing more of the AST to\n * be retained (it doesn't skip any tokens as the ')' is retained because of the '(' begins\n * an '(' ')' production).\n * The recovery points of grouping symbols must be conditional as they must be skipped if\n * none of the calling productions are not expecting the closing token else we will never\n * make progress in the case of an extraneous group closing symbol (such as a stray ')').\n * That is, we skip a closing symbol if we are not in a grouping production.\n * - '=' in a `Writable` context\n * - In this context, we are able to recover after seeing the `=` operator, which\n * signals the presence of an independent rvalue expression following the `=` operator.\n *\n * If a production expects one of these token it increments the corresponding nesting count,\n * and then decrements it just prior to checking if the token is in the input.\n */\n private skip() {\n let n = this.next;\n while (\n this.index < this.tokens.length &&\n !n.isCharacter(chars.$SEMICOLON) &&\n !n.isOperator('|') &&\n (this.rparensExpected <= 0 || !n.isCharacter(chars.$RPAREN)) &&\n (this.rbracesExpected <= 0 || !n.isCharacter(chars.$RBRACE)) &&\n (this.rbracketsExpected <= 0 || !n.isCharacter(chars.$RBRACKET)) &&\n (!(this.context & ParseContextFlags.Writable) || !n.isOperator('='))\n ) {\n if (this.next.isError()) {\n this.errors.push(\n new ParserError(this.next.toString()!, this.input, this.locationText(), this.location),\n );\n }\n this.advance();\n n = this.next;\n }\n }\n}\n\nclass SimpleExpressionChecker extends RecursiveAstVisitor {\n errors: string[] = [];\n\n override visitPipe() {\n this.errors.push('pipes');\n }\n}\n/**\n * Computes the real offset in the original template for indexes in an interpolation.\n *\n * Because templates can have encoded HTML entities and the input passed to the parser at this stage\n * of the compiler is the _decoded_ value, we need to compute the real offset using the original\n * encoded values in the interpolated tokens. Note that this is only a special case handling for\n * `MlParserTokenType.ENCODED_ENTITY` token types. All other interpolated tokens are expected to\n * have parts which exactly match the input string for parsing the interpolation.\n *\n * @param interpolatedTokens The tokens for the interpolated value.\n *\n * @returns A map of index locations in the decoded template to indexes in the original template\n */\nfunction getIndexMapForOriginalTemplate(\n interpolatedTokens: InterpolatedAttributeToken[] | InterpolatedTextToken[],\n): Map {\n let offsetMap = new Map();\n let consumedInOriginalTemplate = 0;\n let consumedInInput = 0;\n let tokenIndex = 0;\n while (tokenIndex < interpolatedTokens.length) {\n const currentToken = interpolatedTokens[tokenIndex];\n if (currentToken.type === MlParserTokenType.ENCODED_ENTITY) {\n const [decoded, encoded] = currentToken.parts;\n consumedInOriginalTemplate += encoded.length;\n consumedInInput += decoded.length;\n } else {\n const lengthOfParts = currentToken.parts.reduce((sum, current) => sum + current.length, 0);\n consumedInInput += lengthOfParts;\n consumedInOriginalTemplate += lengthOfParts;\n }\n offsetMap.set(consumedInInput, consumedInOriginalTemplate);\n tokenIndex++;\n }\n return offsetMap;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SecurityContext} from '../core';\n\n// =================================================================================================\n// =================================================================================================\n// =========== S T O P - S T O P - S T O P - S T O P - S T O P - S T O P ===========\n// =================================================================================================\n// =================================================================================================\n//\n// DO NOT EDIT THIS LIST OF SECURITY SENSITIVE PROPERTIES WITHOUT A SECURITY REVIEW!\n// Reach out to mprobst for details.\n//\n// =================================================================================================\n\n/** Map from tagName|propertyName to SecurityContext. Properties applying to all tags use '*'. */\nlet _SECURITY_SCHEMA!: {[k: string]: SecurityContext};\n\nexport function SECURITY_SCHEMA(): {[k: string]: SecurityContext} {\n if (!_SECURITY_SCHEMA) {\n _SECURITY_SCHEMA = {};\n // Case is insignificant below, all element and attribute names are lower-cased for lookup.\n\n registerContext(SecurityContext.HTML, ['iframe|srcdoc', '*|innerHTML', '*|outerHTML']);\n registerContext(SecurityContext.STYLE, ['*|style']);\n // NB: no SCRIPT contexts here, they are never allowed due to the parser stripping them.\n registerContext(SecurityContext.URL, [\n '*|formAction',\n 'area|href',\n 'area|ping',\n 'audio|src',\n 'a|href',\n 'a|ping',\n 'blockquote|cite',\n 'body|background',\n 'del|cite',\n 'form|action',\n 'img|src',\n 'input|src',\n 'ins|cite',\n 'q|cite',\n 'source|src',\n 'track|src',\n 'video|poster',\n 'video|src',\n ]);\n registerContext(SecurityContext.RESOURCE_URL, [\n 'applet|code',\n 'applet|codebase',\n 'base|href',\n 'embed|src',\n 'frame|src',\n 'head|profile',\n 'html|manifest',\n 'iframe|src',\n 'link|href',\n 'media|src',\n 'object|codebase',\n 'object|data',\n 'script|src',\n ]);\n }\n return _SECURITY_SCHEMA;\n}\n\nfunction registerContext(ctx: SecurityContext, specs: string[]) {\n for (const spec of specs) _SECURITY_SCHEMA[spec.toLowerCase()] = ctx;\n}\n\n/**\n * The set of security-sensitive attributes of an `