perlite
Version:
[]()
3 lines (2 loc) • 26.2 kB
JavaScript
var perlite=function(e){"use strict";const t=["String","Number","Object","Array","Boolean","Date"];function n(e){return e&&"object"==typeof e}function s(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!1,configurable:!0})}function r(e,t,n){s(e,"__key",t),s(e,"__parent",n)}const o={computedStack:[],observersMap:new WeakMap,computedDependenciesTracker:new WeakMap};let i=null;const a=new Set;function l(){for(const e of a)e();a.clear(),i=null}function c(e,t){null===i&&(i=setTimeout(l,!0===t?0:t)),a.add(e)}const{observersMap:d,computedStack:u,computedDependenciesTracker:h}=o;const{computedStack:p,computedDependenciesTracker:f}=o;var m={observe:function e(o,i={}){const{props:a,ignore:l,batch:p,deep:f=!0,bubble:m,bind:v}=i;if(o.__observed)return o;const g=e=>(!a||a.includes(e))&&(!l||!l.includes(e));d.set(o,new Map),f&&Object.entries(o).forEach((function([t,s]){n(s)&&(o[t]=e(s,i),m&&r(o[t],t,o))}));const y=new Proxy(o,{get(e,t){if("__observed"===t)return!0;if(g(t)&&u.length){const e=d.get(o);e.has(t)||e.set(t,new Set);const n=h.get(u[0]);n&&(n.has(o)||n.set(o,new Set),n.get(o).add(t)),e.get(t).add(u[0])}return o[t]},set(t,a,l){if("__handler"===a)s(o,"__handler",l);else if(g(a)){if(Array.isArray(o)&&"length"===a||o[a]!==l){const t=f&&n(l),s=d.get(o),v=o[a];n(v)&&delete o[a],o[a]=t?e(l,i):l,t&&m&&r(o[a],a,o);const g=[a];let b=o;for(;b&&(!b.__handler||!1!==b.__handler(g,l,v,y));)b.__key&&b.__parent?(g.unshift(b.__key),b=b.__parent):b=null;const _=s.get(a);if(_)for(const e of _){const t=h.get(e);e.__disposed||t&&(!t.has(o)||!t.get(o).has(a))?_.delete(e):e!==u[0]&&(p?c(e,p):e())}}}else o[a]=l;return!0}});var b;return v&&(b=o,Object.getOwnPropertyNames(b).concat(Object.getPrototypeOf(b)&&t.indexOf(Object.getPrototypeOf(b).constructor.name)<0?Object.getOwnPropertyNames(Object.getPrototypeOf(b)):[]).filter((e=>"constructor"!==e&&"function"==typeof b[e]))).forEach((e=>o[e]=o[e].bind(y))),y},computed:function(e,{autoRun:t=!0,callback:n,bind:s,disableTracking:r=!1}={}){const o=new Proxy(e,{apply(e,t,i){function a(a){r||f.set(n||o,new WeakMap),p.unshift(n||o);const l=a?a():e.apply(s||t,i);return p.shift(),l}return i.push({computeAsync:function(e){return a(e)}}),a()}});return t&&o(),o},dispose:function(e){return o.computedDependenciesTracker.delete(e),e.__disposed=!0}};const v=new WeakMap,g=e=>(...t)=>{const n=e(...t);return v.set(n,!0),n},y=e=>"function"==typeof e&&v.has(e),b="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,_=(e,t,n=null,s=null)=>{for(;t!==n;){const n=t.nextSibling;e.insertBefore(t,s),t=n}},w=(e,t,n=null)=>{for(;t!==n;){const n=t.nextSibling;e.removeChild(t),t=n}},x={},N={},E=`{{lit-${String(Math.random()).slice(2)}}}`,T=`\x3c!--${E}--\x3e`,V=new RegExp(`${E}|${T}`),A="$lit$";class M{constructor(e,t){this.parts=[],this.element=t;const n=[],s=[],r=document.createTreeWalker(t.content,133,null,!1);let o=0,i=-1,a=0;const{strings:l,values:{length:c}}=e;for(;a<c;){const e=r.nextNode();if(null!==e){if(i++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:n}=t;let s=0;for(let e=0;e<n;e++)S(t[e].name,A)&&s++;for(;s-- >0;){const t=l[a],n=O.exec(t)[2],s=n.toLowerCase()+A,r=e.getAttribute(s);e.removeAttribute(s);const o=r.split(V);this.parts.push({type:"attribute",index:i,name:n,strings:o}),a+=o.length-1}}"TEMPLATE"===e.tagName&&(s.push(e),r.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(E)>=0){const s=e.parentNode,r=t.split(V),o=r.length-1;for(let t=0;t<o;t++){let n,o=r[t];if(""===o)n=P();else{const e=O.exec(o);null!==e&&S(e[2],A)&&(o=o.slice(0,e.index)+e[1]+e[2].slice(0,-A.length)+e[3]),n=document.createTextNode(o)}s.insertBefore(n,e),this.parts.push({type:"node",index:++i})}""===r[o]?(s.insertBefore(P(),e),n.push(e)):e.data=r[o],a+=o}}else if(8===e.nodeType)if(e.data===E){const t=e.parentNode;null!==e.previousSibling&&i!==o||(i++,t.insertBefore(P(),e)),o=i,this.parts.push({type:"node",index:i}),null===e.nextSibling?e.data="":(n.push(e),i--),a++}else{let t=-1;for(;-1!==(t=e.data.indexOf(E,t+1));)this.parts.push({type:"node",index:-1}),a++}}else r.currentNode=s.pop()}for(const e of n)e.parentNode.removeChild(e)}}const S=(e,t)=>{const n=e.length-t.length;return n>=0&&e.slice(n)===t},k=e=>-1!==e.index,P=()=>document.createComment(""),O=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class C{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this.options=n}update(e){let t=0;for(const n of this.__parts)void 0!==n&&n.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=b?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],n=this.template.parts,s=document.createTreeWalker(e,133,null,!1);let r,o=0,i=0,a=s.nextNode();for(;o<n.length;)if(r=n[o],k(r)){for(;i<r.index;)i++,"TEMPLATE"===a.nodeName&&(t.push(a),s.currentNode=a.content),null===(a=s.nextNode())&&(s.currentNode=t.pop(),a=s.nextNode());if("node"===r.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(a.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(a,r.name,r.strings,this.options));o++}else this.__parts.push(void 0),o++;return b&&(document.adoptNode(e),customElements.upgrade(e)),e}}const I=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:e=>e}),L=` ${E} `;class W{constructor(e,t,n,s){this.strings=e,this.values=t,this.type=n,this.processor=s}getHTML(){const e=this.strings.length-1;let t="",n=!1;for(let s=0;s<e;s++){const e=this.strings[s],r=e.lastIndexOf("\x3c!--");n=(r>-1||n)&&-1===e.indexOf("--\x3e",r+1);const o=O.exec(e);t+=null===o?e+(n?L:T):e.substr(0,o.index)+o[1]+o[2]+A+o[3]+E}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==I&&(t=I.createHTML(t)),e.innerHTML=t,e}}class H extends W{getHTML(){return`<svg>${super.getHTML()}</svg>`}getTemplateElement(){const e=super.getTemplateElement(),t=e.content,n=t.firstChild;return t.removeChild(n),_(t,n.firstChild),e}}const j=e=>null===e||!("object"==typeof e||"function"==typeof e),R=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class ${constructor(e,t,n){this.dirty=!0,this.element=e,this.name=t,this.strings=n,this.parts=[];for(let e=0;e<n.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new B(this)}_getValue(){const e=this.strings,t=e.length-1,n=this.parts;if(1===t&&""===e[0]&&""===e[1]){const e=n[0].value;if("symbol"==typeof e)return String(e);if("string"==typeof e||!R(e))return e}let s="";for(let r=0;r<t;r++){s+=e[r];const t=n[r];if(void 0!==t){const e=t.value;if(j(e)||!R(e))s+="string"==typeof e?e:String(e);else for(const t of e)s+="string"==typeof t?t:String(t)}}return s+=e[t],s}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class B{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===x||j(e)&&e===this.value||(this.value=e,y(e)||(this.committer.dirty=!0))}commit(){for(;y(this.value);){const e=this.value;this.value=x,e(this)}this.value!==x&&this.committer.commit()}}class D{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(P()),this.endNode=e.appendChild(P())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=P()),e.__insert(this.endNode=P())}insertAfterPart(e){e.__insert(this.startNode=P()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(null===this.startNode.parentNode)return;for(;y(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=x,e(this)}const e=this.__pendingValue;e!==x&&(j(e)?e!==this.value&&this.__commitText(e):e instanceof W?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):R(e)?this.__commitIterable(e):e===N?(this.value=N,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,n="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=n:this.__commitNode(document.createTextNode(n)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof C&&this.value.template===t)this.value.update(e.values);else{const n=new C(t,e.processor,this.options),s=n._clone();n.update(e.values),this.__commitNode(s),this.value=n}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let n,s=0;for(const r of e)n=t[s],void 0===n&&(n=new D(this.options),t.push(n),0===s?n.appendIntoPart(this):n.insertAfterPart(t[s-1])),n.setValue(r),n.commit(),s++;s<t.length&&(t.length=s,this.clear(n&&n.endNode))}clear(e=this.startNode){w(this.startNode.parentNode,e.nextSibling,this.endNode)}}class F{constructor(e,t,n){if(this.value=void 0,this.__pendingValue=void 0,2!==n.length||""!==n[0]||""!==n[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=n}setValue(e){this.__pendingValue=e}commit(){for(;y(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=x,e(this)}if(this.__pendingValue===x)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=x}}class G extends ${constructor(e,t,n){super(e,t,n),this.single=2===n.length&&""===n[0]&&""===n[1]}_createPart(){return new J(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class J extends B{}let U=!1;(()=>{try{const e={get capture(){return U=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class z{constructor(e,t,n){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=n,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;y(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=x,e(this)}if(this.__pendingValue===x)return;const e=this.__pendingValue,t=this.value,n=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),s=null!=e&&(null==t||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=Z(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=x}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const Z=e=>e&&(U?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);class q{handleAttributeExpressions(e,t,n,s){const r=t[0];if("."===r){return new G(e,t.slice(1),n).parts}if("@"===r)return[new z(e,t.slice(1),s.eventContext)];if("?"===r)return[new F(e,t.slice(1),n)];return new $(e,t,n).parts}handleTextExpression(e){return new D(e)}}const K=new q;function Q(e){let t=X.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},X.set(e.type,t));let n=t.stringsArray.get(e.strings);if(void 0!==n)return n;const s=e.strings.join(E);return n=t.keyString.get(s),void 0===n&&(n=new M(e,e.getTemplateElement()),t.keyString.set(s,n)),t.stringsArray.set(e.strings,n),n}const X=new Map,Y=new WeakMap,ee=(e,t,n)=>{let s=Y.get(t);void 0===s&&(w(t,t.firstChild),Y.set(t,s=new D(Object.assign({templateFactory:Q},n))),s.appendInto(t)),s.setValue(e),s.commit()};"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const te=e=>ee(N,e),ne=(...e)=>{};function se(e){if("true"===e||"false"===e)return"true"===e;if("null"===e)return null;if("undefined"!==e){if(""!==e&&!isNaN(Number(e)))return Number(e);try{return JSON.parse(e)}catch(e){}return e}}function re(e,t=!1){const n=e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()));return t?n.replace(/^\w/,(e=>e.toUpperCase())):n}function oe(e){return e.replace(/[A-Z]/g,"-$&").toLowerCase()}const ie=(e,t)=>{const n=e.startNode.parentNode,s=void 0===t?e.endNode:t.startNode,r=n.insertBefore(P(),s);n.insertBefore(P(),s);const o=new D(e.options);return o.insertAfterNode(r),o},ae=(e,t)=>(e.setValue(t),e.commit(),e),le=(e,t,n)=>{const s=e.startNode.parentNode,r=n?n.startNode:e.endNode,o=t.endNode.nextSibling;o!==r&&_(s,t.startNode,o,r)},ce=e=>{w(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},de=(e,t,n)=>{const s=new Map;for(let r=t;r<=n;r++)s.set(e[r],r);return s},ue=new WeakMap,he=new WeakMap,pe=g(((e,t,n)=>{let s;return void 0===n?n=t:void 0!==t&&(s=t),t=>{if(!(t instanceof D))throw new Error("repeat can only be used in text bindings");const r=ue.get(t)||[],o=he.get(t)||[],i=[],a=[],l=[];let c,d,u=0;for(const t of e)l[u]=s?s(t,u):u,a[u]=n(t,u),u++;let h=0,p=r.length-1,f=0,m=a.length-1;for(;h<=p&&f<=m;)if(null===r[h])h++;else if(null===r[p])p--;else if(o[h]===l[f])i[f]=ae(r[h],a[f]),h++,f++;else if(o[p]===l[m])i[m]=ae(r[p],a[m]),p--,m--;else if(o[h]===l[m])i[m]=ae(r[h],a[m]),le(t,r[h],i[m+1]),h++,m--;else if(o[p]===l[f])i[f]=ae(r[p],a[f]),le(t,r[p],r[h]),p--,f++;else if(void 0===c&&(c=de(l,f,m),d=de(o,h,p)),c.has(o[h]))if(c.has(o[p])){const e=d.get(l[f]),n=void 0!==e?r[e]:null;if(null===n){const e=ie(t,r[h]);ae(e,a[f]),i[f]=e}else i[f]=ae(n,a[f]),le(t,n,r[h]),r[e]=null;f++}else ce(r[p]),p--;else ce(r[h]),h++;for(;f<=m;){const e=ie(t,i[m+1]);ae(e,a[f]),i[f++]=e}for(;h<=p;){const e=r[h++];null!==e&&ce(e)}ue.set(t,i),he.set(t,l)}})),fe=new WeakMap,me=g((e=>t=>{if(!(t instanceof D))throw new Error("cache can only be used in text bindings");let n=fe.get(t);void 0===n&&(n=new WeakMap,fe.set(t,n));const s=t.value;if(s instanceof C){if(e instanceof W&&s.template===t.options.templateFactory(e))return void t.setValue(e);{let e=n.get(s.template);void 0===e&&(e={instance:s,nodes:document.createDocumentFragment()},n.set(s.template,e)),_(e.nodes,t.startNode.nextSibling,t.endNode)}}if(e instanceof W){const s=t.options.templateFactory(e),r=n.get(s);void 0!==r&&(t.setValue(r.nodes),t.commit(),t.value=r.instance)}t.setValue(e)})),ve=new WeakMap,ge=2147483647,ye=g(((...e)=>t=>{let n=ve.get(t);void 0===n&&(n={lastRenderedIndex:ge,values:[]},ve.set(t,n));const s=n.values;let r=s.length;n.values=e;for(let o=0;o<e.length&&!(o>n.lastRenderedIndex);o++){const i=e[o];if(j(i)||"function"!=typeof i.then){t.setValue(i),n.lastRenderedIndex=o;break}o<r&&i===s[o]||(n.lastRenderedIndex=ge,r=0,Promise.resolve(i).then((e=>{const s=n.values.indexOf(i);s>-1&&s<n.lastRenderedIndex&&(n.lastRenderedIndex=s,t.setValue(e),t.commit())})))}})),be=g((e=>t=>{let n;if(t instanceof z||t instanceof D)throw new Error("The `live` directive is not allowed on text or event bindings");if(t instanceof F)_e(t.strings),n=t.element.hasAttribute(t.name),t.value=n;else{const{element:s,name:r,strings:o}=t.committer;if(_e(o),t instanceof J){if(n=s[r],n===e)return}else t instanceof B&&(n=s.getAttribute(r));if(n===String(e))return}t.setValue(e)})),_e=e=>{if(2!==e.length||""!==e[0]||""!==e[1])throw new Error("`live` bindings can only contain a single expression")},we=new WeakMap,xe=g(((e,t)=>n=>{const s=we.get(n);if(Array.isArray(e)){if(Array.isArray(s)&&s.length===e.length&&e.every(((e,t)=>e===s[t])))return}else if(s===e&&(void 0!==e||we.has(n)))return;n.setValue(t()),we.set(n,Array.isArray(e)?Array.from(e):e)}));class Ne{constructor(e){this.classes=new Set,this.changed=!1,this.element=e;const t=(e.getAttribute("class")||"").split(/\s+/);for(const e of t)this.classes.add(e)}add(e){this.classes.add(e),this.changed=!0}remove(e){this.classes.delete(e),this.changed=!0}commit(){if(this.changed){let e="";this.classes.forEach((t=>e+=t+" ")),this.element.setAttribute("class",e)}}}const Ee=new WeakMap,Te=g((e=>t=>{if(!(t instanceof B)||t instanceof J||"class"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:n}=t,{element:s}=n;let r=Ee.get(t);void 0===r&&(s.setAttribute("class",n.strings.join(" ")),Ee.set(t,r=new Set));const o=s.classList||new Ne(s);r.forEach((t=>{t in e||(o.remove(t),r.delete(t))}));for(const t in e){const n=e[t];n!=r.has(t)&&(n?(o.add(t),r.add(t)):(o.remove(t),r.delete(t)))}"function"==typeof o.commit&&o.commit()})),Ve=new WeakMap,Ae=g((e=>t=>{if(!(t instanceof B)||t instanceof J||"style"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:n}=t,{style:s}=n.element;let r=Ve.get(t);void 0===r&&(s.cssText=n.strings.join(" "),Ve.set(t,r=new Set)),r.forEach((t=>{t in e||(r.delete(t),-1===t.indexOf("-")?s[t]=null:s.removeProperty(t))}));for(const t in e)r.add(t),-1===t.indexOf("-")?s[t]=e[t]:s.setProperty(t,e[t])})),Me=new WeakMap,Se=g((e=>t=>{const n=Me.get(t);if(void 0===e&&t instanceof B){if(void 0!==n||!Me.has(t)){const e=t.committer.name;t.committer.element.removeAttribute(e)}}else e!==n&&t.setValue(e);Me.set(t,e)}));var ke=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,r){(function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)})(s,r,(t=e[n](t)).done,t.value)}))}}};const Pe=g(((e,t)=>async n=>{var s,r;if(!(n instanceof D))throw new Error("asyncAppend can only be used in text bindings");if(e===n.value)return;let o;n.value=e;let i=0;try{for(var a,l=ke(e);!(a=await l.next()).done;){let s=a.value;if(n.value!==e)break;0===i&&n.clear(),void 0!==t&&(s=t(s,i));let r=n.startNode;void 0!==o&&(r=P(),o.endNode=r,n.endNode.parentNode.insertBefore(r,n.endNode)),o=new D(n.options),o.insertAfterNode(r),o.setValue(s),o.commit(),i++}}catch(e){s={error:e}}finally{try{a&&!a.done&&(r=l.return)&&await r.call(l)}finally{if(s)throw s.error}}}));var Oe=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,r){(function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)})(s,r,(t=e[n](t)).done,t.value)}))}}};const Ce=g(((e,t)=>async n=>{var s,r;if(!(n instanceof D))throw new Error("asyncReplace can only be used in text bindings");if(e===n.value)return;const o=new D(n.options);n.value=e;let i=0;try{for(var a,l=Oe(e);!(a=await l.next()).done;){let s=a.value;if(n.value!==e)break;0===i&&(n.clear(),o.appendIntoPart(n)),void 0!==t&&(s=t(s,i)),o.setValue(s),o.commit(),i++}}catch(e){s={error:e}}finally{try{a&&!a.done&&(r=l.return)&&await r.call(l)}finally{if(s)throw s.error}}})),Ie=new WeakMap,Le=g((e=>t=>{if(!(t instanceof D))throw new Error("templateContent can only be used in text bindings");const n=Ie.get(t);if(void 0!==n&&e===n.template&&t.value===n.fragment)return;const s=document.importNode(e.content,!0);t.setValue(s),Ie.set(t,{template:e,fragment:s})})),We=new WeakMap,He=g((e=>t=>{if(!(t instanceof D))throw new Error("unsafeHTML can only be used in text bindings");const n=We.get(t);if(void 0!==n&&j(e)&&e===n.value&&t.value===n.fragment)return;const s=document.createElement("template");s.innerHTML=e;const r=document.importNode(s.content,!0);t.setValue(r),We.set(t,{value:e,fragment:r})})),je=new WeakMap,Re=window.navigator.userAgent.indexOf("Trident/")>0,$e=g((e=>t=>{if(!(t instanceof D))throw new Error("unsafeSVG can only be used in text bindings");const n=je.get(t);if(void 0!==n&&j(e)&&e===n.value&&t.value===n.fragment)return;const s=document.createElement("template"),r=s.content;let o;Re?(s.innerHTML=`<svg>${e}</svg>`,o=r.firstChild):(o=document.createElementNS("http://www.w3.org/2000/svg","svg"),r.appendChild(o),o.innerHTML=e),r.removeChild(o),_(r,o.firstChild);const i=document.importNode(r,!0);t.setValue(i),je.set(t,{value:e,fragment:i})})),Be=g((e=>t=>e(t.element))),De=new WeakMap,Fe=g(((e,...t)=>{const n=s=>{const r=s.element;if(De.has(s)){const[r,o]=De.get(s);o!==e?(r.destroy(),De.delete(s),n(s)):r.update(...t)}else{const n=e(r,...t);De.set(s,[n,e])}};return n})),Ge=g((e=>t=>{if(!(t instanceof z))throw new Error('"bind" directive can only be used in event listeners');const n=t.element,s=n instanceof HTMLInputElement,r=n instanceof HTMLSelectElement,o=n instanceof HTMLTextAreaElement,i=n instanceof HTMLButtonElement;if(!(s||r||o||i))throw new Error('"bind" directive can only be applied to input/select/textarea/button elements.');t.setValue((function(...t){let o=n.defaultValue;if(r&&n.options.length>0){const e=n.selectedIndex>=0?n.selectedIndex:0;o=n.options[e].value}else if(s)switch(n.type){case"number":case"range":o=n.valueAsNumber;break;case"checkbox":case"radio":o=!!n.checked;break;case"time":case"date":case"datetime":case"datetime-local":o=n.valueAsDate;break;default:o=n.value}else o=n.value;e.call(this,o,...t)}))})),Je=g((e=>t=>{if(!(t instanceof z))throw new Error('"capture" directive can only be used in event listeners');t.setValue("object"==typeof e?{...e,capture:!0}:{handleEvent:e,capture:!0})})),Ue=g((e=>t=>{if(!(t instanceof z))throw new Error('"once" directive can only be used in event listeners');t.setValue("object"==typeof e?{...e,once:!0}:{handleEvent:e,once:!0})})),ze=g((e=>t=>{if(!(t instanceof z))throw new Error('"passive" directive can only be used in event listeners');t.setValue("object"==typeof e?{...e,passive:!0}:{handleEvent:e,passive:!0})})),Ze=g((e=>t=>{if(!(t instanceof z))throw new Error('"prevent" directive can only be used in event listeners');const{handleEvent:n,...s}=e;t.setValue({handleEvent:function(t){t.preventDefault(),(n||e).call(this,t)},...s})})),qe=g(((e,t=!1)=>n=>{if(!(n instanceof z))throw new Error('"stop" directive can only be used in event listeners');const{handleEvent:s,...r}=e;n.setValue({handleEvent:function(n){t?n.stopImmediatePropagation():n.stopPropagation(),(s||e).call(this,n)},...r})})),Ke=g((e=>t=>{if(!(t instanceof z))throw new Error('"self" directive can only be used in event listeners');const{handleEvent:n,...s}=e;t.setValue({handleEvent:function(t){t.target===t.currentTarget&&(n||e).call(this,t)},...s})})),{observe:Qe,computed:Xe,dispose:Ye}=m,et=({render:e=(()=>N),state:t={},target:n=document.body,...s},...r)=>{const o="function"==typeof t?t(...r):t;Object.entries(n.dataset).forEach((([e,t])=>{e in o&&(o[e]=se(t))}));const i=Qe(o,{batch:!0,deep:!0,bind:!0,...s}),a=(e,t,{bubbles:s=!1,cancelable:r=!0}={})=>{n.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:s,cancelable:r}))};let l=!1;const c=()=>{ee(e(i,a,...r),n),l||(a("mount",o),l=!0),a("update",o)},d=Xe((({computeAsync:e})=>l&&!document.contains(n)?f():(a("state",o),Promise.resolve().then((()=>e(c))).catch((e=>a("error",e)))))),u=new Set,h=new Set,p=new MutationObserver((e=>{e.forEach((e=>{if("attributes"!==e.type)return;const t=e.target,n=re(e.attributeName.replace("data-",""));if(!(n in i))return;const s=t.getAttribute(e.attributeName);if(s!==e.oldValue){const e=se(s);i[n]!==e&&(i[n]=e)}}))}));p.observe(n,{attributeFilter:Object.entries(o).reduce(((e,[t,n])=>("function"!=typeof n&&e.push("data-"+oe(t)),e)),[]),attributeOldValue:!0,characterData:!1,childList:!1,subtree:!1});const f=(e=ne)=>{p.disconnect(),Ye(d),h.forEach((e=>e())),h.clear(),a("destroy",o),u.forEach((e=>e())),u.clear(),te(n),e(o)};return{on:(e,t,s)=>{n.addEventListener(e,t,s);const r=()=>(n.removeEventListener(e,t,s),u.delete(r));return u.add(r),r},ctx:e=>e(...r),model:o,state:i,effect:(e,t)=>{const n=Xe(e,t),s=()=>(Ye(n),h.delete(s));return h.add(s),s},target:n,destroy:f,render:c}};return e.$=et,e.$$=({target:e,...t},...n)=>{e.length||(e=[e]);const s=Array.prototype.map.call(e,(e=>et({...t,target:e},...n)));return{...s,effect:(e,t)=>{const n=s.map((n=>n.effect(e(n.state),t)));return()=>n.forEach((e=>e()))},on:(...e)=>{const t=s.map((t=>t.on(...e)));return()=>t.forEach((e=>e()))},destroy:e=>s.forEach((t=>t.destroy(e))),render:()=>s.forEach((e=>e.render())),state:e=>{s.forEach((t=>e(t.state)))},ctx:e=>e(...n),forEach:Array.prototype.forEach.bind(s),target:e}},e.AttributeCommitter=$,e.AttributePart=B,e.BooleanAttributePart=F,e.DefaultTemplateProcessor=q,e.EventPart=z,e.NodePart=D,e.PropertyCommitter=G,e.PropertyPart=J,e.SVGTemplateResult=H,e.Template=M,e.TemplateInstance=C,e.TemplateResult=W,e.asyncAppend=Pe,e.asyncReplace=Ce,e.attrToVal=se,e.bind=Ge,e.cache=me,e.call=(e,...t)=>function(...n){e.call(this,...n,...t)},e.camelCase=re,e.capture=Je,e.classMap=Te,e.computed=Xe,e.createMarker=P,e.decorator=Fe,e.defaultTemplateProcessor=K,e.directive=g,e.dispose=Ye,e.each=(e,t,n=(e=>e))=>pe(e,n,t),e.guard=xe,e.html=(e,...t)=>new W(e,t,"html",K),e.ifDefined=Se,e.isDirective=y,e.isIterable=R,e.isPrimitive=j,e.isTemplatePartActive=k,e.kebabCase=oe,e.live=be,e.memo=(e,t)=>{const n=new Map;return(...s)=>{let r;if("function"==typeof t){const o=t.apply(e,s);!1===o?(r=JSON.stringify(s),n.delete(r)):!0!==o&&(r=o)}if(void 0===r&&(r=JSON.stringify(s)),n.has(r))return n.get(r);const o=e.apply(e,s);return n.set(r,o),o}},e.noChange=x,e.noop=ne,e.nothing=N,e.observe=Qe,e.once=Ue,e.parts=Y,e.passive=ze,e.prevent=Ze,e.ref=Be,e.removeNodes=w,e.render=ee,e.reparentNodes=_,e.repeat=pe,e.self=Ke,e.stop=qe,e.styleMap=Ae,e.svg=(e,...t)=>new H(e,t,"svg",K),e.templateCaches=X,e.templateContent=Le,e.templateFactory=Q,e.tick=(e=ne)=>new Promise((e=>setTimeout(e))).then(e),e.unrender=te,e.unsafeHTML=He,e.unsafeSVG=$e,e.until=ye,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
//# sourceMappingURL=perlite.min.js.map