/*! For license information please see template-result.js.LICENSE.txt */
import{reparentNodes}from"./dom.js";import{boundAttributeSuffix,lastAttributeNameRegex,marker,nodeMarker}from"./template.js";const policy=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:e=>e}),commentMarker=` ${marker} `;export class TemplateResult{constructor(e,t,r,s){this.strings=e,this.values=t,this.type=r,this.processor=s}getHTML(){const e=this.strings.length-1;let t="",r=!1;for(let s=0;s<e;s++){const e=this.strings[s],n=e.lastIndexOf("\x3c!--");r=(n>-1||r)&&-1===e.indexOf("--\x3e",n+1);const l=lastAttributeNameRegex.exec(e);t+=null===l?e+(r?commentMarker:nodeMarker):e.substr(0,l.index)+l[1]+l[2]+boundAttributeSuffix+l[3]+marker}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==policy&&(t=policy.createHTML(t)),e.innerHTML=t,e}}export class SVGTemplateResult extends TemplateResult{getHTML(){return`<svg>${super.getHTML()}</svg>`}getTemplateElement(){const e=super.getTemplateElement(),t=e.content,r=t.firstChild;return t.removeChild(r),reparentNodes(t,r.firstChild),e}}