/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define("@angular/compiler/src/i18n/serializers/placeholder", ["require", "exports"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaceholderRegistry = void 0; var TAG_TO_PLACEHOLDER_NAMES = { 'A': 'LINK', 'B': 'BOLD_TEXT', 'BR': 'LINE_BREAK', 'EM': 'EMPHASISED_TEXT', 'H1': 'HEADING_LEVEL1', 'H2': 'HEADING_LEVEL2', 'H3': 'HEADING_LEVEL3', 'H4': 'HEADING_LEVEL4', 'H5': 'HEADING_LEVEL5', 'H6': 'HEADING_LEVEL6', 'HR': 'HORIZONTAL_RULE', 'I': 'ITALIC_TEXT', 'LI': 'LIST_ITEM', 'LINK': 'MEDIA_LINK', 'OL': 'ORDERED_LIST', 'P': 'PARAGRAPH', 'Q': 'QUOTATION', 'S': 'STRIKETHROUGH_TEXT', 'SMALL': 'SMALL_TEXT', 'SUB': 'SUBSTRIPT', 'SUP': 'SUPERSCRIPT', 'TBODY': 'TABLE_BODY', 'TD': 'TABLE_CELL', 'TFOOT': 'TABLE_FOOTER', 'TH': 'TABLE_HEADER_CELL', 'THEAD': 'TABLE_HEADER', 'TR': 'TABLE_ROW', 'TT': 'MONOSPACED_TEXT', 'U': 'UNDERLINED_TEXT', 'UL': 'UNORDERED_LIST', }; /** * Creates unique names for placeholder with different content. * * Returns the same placeholder name when the content is identical. */ var PlaceholderRegistry = /** @class */ (function () { function PlaceholderRegistry() { // Count the occurrence of the base name top generate a unique name this._placeHolderNameCounts = {}; // Maps signature to placeholder names this._signatureToName = {}; } PlaceholderRegistry.prototype.getStartTagPlaceholderName = function (tag, attrs, isVoid) { var signature = this._hashTag(tag, attrs, isVoid); if (this._signatureToName[signature]) { return this._signatureToName[signature]; } var upperTag = tag.toUpperCase(); var baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag; var name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName); this._signatureToName[signature] = name; return name; }; PlaceholderRegistry.prototype.getCloseTagPlaceholderName = function (tag) { var signature = this._hashClosingTag(tag); if (this._signatureToName[signature]) { return this._signatureToName[signature]; } var upperTag = tag.toUpperCase(); var baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag; var name = this._generateUniqueName("CLOSE_" + baseName); this._signatureToName[signature] = name; return name; }; PlaceholderRegistry.prototype.getPlaceholderName = function (name, content) { var upperName = name.toUpperCase(); var signature = "PH: " + upperName + "=" + content; if (this._signatureToName[signature]) { return this._signatureToName[signature]; } var uniqueName = this._generateUniqueName(upperName); this._signatureToName[signature] = uniqueName; return uniqueName; }; PlaceholderRegistry.prototype.getUniquePlaceholder = function (name) { return this._generateUniqueName(name.toUpperCase()); }; // Generate a hash for a tag - does not take attribute order into account PlaceholderRegistry.prototype._hashTag = function (tag, attrs, isVoid) { var start = "<" + tag; var strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join(''); var end = isVoid ? '/>' : ">"; return start + strAttrs + end; }; PlaceholderRegistry.prototype._hashClosingTag = function (tag) { return this._hashTag("/" + tag, {}, false); }; PlaceholderRegistry.prototype._generateUniqueName = function (base) { var seen = this._placeHolderNameCounts.hasOwnProperty(base); if (!seen) { this._placeHolderNameCounts[base] = 1; return base; } var id = this._placeHolderNameCounts[base]; this._placeHolderNameCounts[base] = id + 1; return base + "_" + id; }; return PlaceholderRegistry; }()); exports.PlaceholderRegistry = PlaceholderRegistry; }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGxhY2Vob2xkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlc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