export default class Fragment{constructor(element){this._element=element;this._elementsById=new Map();} element(){return this._element;} $(elementId){return this._elementsById.get(elementId);} static build(strings,...values){return Fragment._render(Fragment._template(strings),values);} static cached(strings,...values){let template=_templateCache.get(strings);if(!template){template=Fragment._template(strings);_templateCache.set(strings,template);} return Fragment._render(template,values);} static _template(strings){let html='';let insideText=true;for(let i=0;i');const open=strings[i].indexOf('<',close+1);if(close!==-1&&open===-1){insideText=true;}else if(open!==-1){insideText=false;} html+=insideText?Fragment._textMarker:Fragment._attributeMarker(i);} html+=strings[strings.length-1];const template=window.document.createElement('template');template.innerHTML=html;const walker=template.ownerDocument.createTreeWalker(template.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null,false);let valueIndex=0;const emptyTextNodes=[];const binds=[];const nodesToMark=[];while(walker.nextNode()){const node=walker.currentNode;if(node.nodeType===Node.ELEMENT_NODE&&node.hasAttributes()){if(node.hasAttribute('$')){nodesToMark.push(node);binds.push({elementId:node.getAttribute('$')});node.removeAttribute('$');} const attributesToRemove=[];for(let i=0;i'template-attribute'+index;const _attributeMarkerRegex=/template-attribute\d+/;const _class=index=>'template-class-'+index;const _templateCache=new Map();export const html=(strings,...vararg)=>{return Fragment.cached(strings,...vararg).element();};self.UI=self.UI||{};UI=UI||{};UI.Fragment=Fragment;UI.Fragment._textMarker=_textMarker;UI.Fragment._attributeMarker=_attributeMarker;UI.html=html;UI.Fragment._Template;UI.Fragment._Bind;