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AAE,CAAC,UAAU,CAAC,CAAC,CAAC;iBAChD;aACF;YACD,wDAAwD;YACxD,IAAI,CAAC,MAAM,GAAG,CAA4C,CAAC;SAC5D;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;SACzB;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n TemplateResult,\n ChildPart,\n RootPart,\n render,\n nothing,\n CompiledTemplateResult,\n} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n} from '../directive.js';\nimport {\n clearPart,\n getCommittedValue,\n insertPart,\n isCompiledTemplateResult,\n isTemplateResult,\n setCommittedValue,\n} from '../directive-helpers.js';\n\n/**\n * The template strings array contents are not compatible between the two\n * template result types as the compiled template contains a prepared string;\n * only use the returned template strings array as a cache key.\n */\nconst getStringsFromTemplateResult = (\n result: TemplateResult | CompiledTemplateResult\n): TemplateStringsArray =>\n isCompiledTemplateResult(result) ? result['_$litType$'].h : result.strings;\n\nclass CacheDirective extends Directive {\n private _templateCache = new WeakMap<TemplateStringsArray, RootPart>();\n private _value?: TemplateResult | CompiledTemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n }\n\n render(v: unknown) {\n // Return an array of the value to induce lit-html to create a ChildPart\n // for the value that we can move into the cache.\n return [v];\n }\n\n override update(containerPart: ChildPart, [v]: DirectiveParameters<this>) {\n const _valueKey = isTemplateResult(this._value)\n ? getStringsFromTemplateResult(this._value)\n : null;\n const vKey = isTemplateResult(v) ? getStringsFromTemplateResult(v) : null;\n\n // If the previous value is a Template
|