@lipsjs/lips 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -85
- package/dist/lips.js +6274 -0
- package/dist/lips.js.map +53 -0
- package/dist/lips.min.js +13 -2
- package/dist/lips.min.js.map +47 -43
- package/dist/mf2.min.js +4 -0
- package/dist/mf2.min.js.map +38 -0
- package/dist/precompile.min.js +23 -0
- package/dist/precompile.min.js.map +14 -0
- package/dist/runtime.min.js +5 -0
- package/dist/runtime.min.js.map +20 -0
- package/dist/stylis.min.js +3 -0
- package/dist/stylis.min.js.map +16 -0
- package/dist/types/events.d.ts +1 -1
- package/dist/types/i18n/engine.d.ts +14 -0
- package/dist/types/i18n/index.d.ts +122 -5
- package/dist/types/i18n/intl.d.ts +1 -0
- package/dist/types/i18n/lookup.d.ts +22 -0
- package/dist/types/ir/compiler.d.ts +226 -0
- package/dist/types/ir/expression.d.ts +149 -0
- package/dist/types/ir/facade.d.ts +138 -0
- package/dist/types/ir/host.d.ts +75 -0
- package/dist/types/ir/index.d.ts +18 -0
- package/dist/types/ir/parser.d.ts +124 -0
- package/dist/types/ir/policy.d.ts +95 -0
- package/dist/types/ir/router.d.ts +47 -0
- package/dist/types/ir/runtime.d.ts +130 -0
- package/dist/types/ir/signal.d.ts +28 -0
- package/dist/types/ir/style.d.ts +119 -0
- package/dist/types/ir/swap.d.ts +28 -0
- package/dist/types/ir/tree.d.ts +51 -0
- package/dist/types/lips.d.ts +33 -37
- package/dist/types/lynx/a11y.d.ts +61 -0
- package/dist/types/lynx/background.d.ts +71 -0
- package/dist/types/lynx/main.d.ts +46 -0
- package/dist/types/lynx/protocol.d.ts +52 -0
- package/dist/types/lynx/style.d.ts +49 -0
- package/dist/types/lynx/template.d.ts +37 -0
- package/dist/types/mf2.d.ts +14 -0
- package/dist/types/precompile.d.ts +85 -0
- package/dist/types/runtime.d.ts +16 -0
- package/dist/types/stylesheet.d.ts +21 -41
- package/dist/types/stylis.d.ts +2 -0
- package/dist/types/types.d.ts +176 -185
- package/dist/types/untrusted.d.ts +17 -0
- package/dist/untrusted.min.js +5 -0
- package/dist/untrusted.min.js.map +13 -0
- package/package.json +46 -10
- package/dist/test.component.min.js +0 -3
- package/dist/test.component.min.js.map +0 -50
- package/dist/test.stress.min.js +0 -476
- package/dist/test.stress.min.js.map +0 -50
- package/dist/types/component.d.ts +0 -107
- package/dist/types/constants.d.ts +0 -23
- package/dist/types/dws.d.ts +0 -14
- package/dist/types/iuc/index.d.ts +0 -25
- package/dist/types/iuc/tick.d.ts +0 -38
- package/dist/types/iuc.d.ts +0 -25
- package/dist/types/metrics.d.ts +0 -50
- package/dist/types/preprocess.d.ts +0 -2
- package/dist/types/signal.d.ts +0 -30
- package/dist/types/syntax/async.d.ts +0 -16
- package/dist/types/syntax/for.d.ts +0 -25
- package/dist/types/syntax/if.d.ts +0 -14
- package/dist/types/syntax/router.d.ts +0 -40
- package/dist/types/syntax/switch.d.ts +0 -16
- package/dist/types/tick.d.ts +0 -38
- package/dist/types/tps.d.ts +0 -11
- package/dist/types/uqs.d.ts +0 -37
- package/dist/types/utils.d.ts +0 -25
package/dist/lips.min.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
var D8=Object.create;var{defineProperty:f1,getPrototypeOf:I8,getOwnPropertyNames:F8}=Object;var L8=Object.prototype.hasOwnProperty;var J1=(J,Z,X)=>{X=J!=null?D8(I8(J)):{};const H=Z||!J||!J.__esModule?f1(X,"default",{value:J,enumerable:!0}):X;for(let q of F8(J))if(!L8.call(H,q))f1(H,q,{get:()=>J[q],enumerable:!0});return H};var V8=(J,Z)=>()=>(Z||J((Z={exports:{}}).exports,Z),Z.exports);var s0=(J,Z)=>{for(var X in Z)f1(J,X,{get:Z[X],enumerable:!0,configurable:!0,set:(H)=>Z[X]=()=>H})};var o0=V8((M5,D5)=>{(function(){var J=document,Z=window,X=J.documentElement,H=J.createElement.bind(J),q=H("div"),W=H("table"),B=H("tbody"),Y=H("tr"),K=Array.isArray,G=Array.prototype,D=G.concat,O=G.filter,g=G.indexOf,d=G.map,J0=G.push,a=G.slice,q0=G.some,n=G.splice,v=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,i=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,o=/<.+>/,r=/^\w+$/;function Z0(Q,z){var w=x(z);return!Q||!w&&!F(z)&&!C(z)?[]:!w&&i.test(Q)?z.getElementsByClassName(Q.slice(1).replace(/\\/g,"")):!w&&r.test(Q)?z.getElementsByTagName(Q):z.querySelectorAll(Q)}var p=function(){function Q(z,w){if(!z)return;if($(z))return z;var j=z;if(s(z)){var V=w||J;if(j=v.test(z)&&F(V)?V.getElementById(z.slice(1).replace(/\\/g,"")):o.test(z)?r1(z):$(V)?V.find(z):s(V)?M(V).find(z):Z0(z,V),!j)return}else if(f(z))return this.ready(z);if(j.nodeType||j===Z)j=[j];this.length=j.length;for(var T=0,y=this.length;T<y;T++)this[T]=j[T]}return Q.prototype.init=function(z,w){return new Q(z,w)},Q}(),U=p.prototype,M=U.init;if(M.fn=M.prototype=U,U.length=0,U.splice=n,typeof Symbol==="function")U[Symbol.iterator]=G[Symbol.iterator];function $(Q){return Q instanceof p}function L(Q){return!!Q&&Q===Q.window}function F(Q){return!!Q&&Q.nodeType===9}function x(Q){return!!Q&&Q.nodeType===11}function C(Q){return!!Q&&Q.nodeType===1}function P(Q){return!!Q&&Q.nodeType===3}function m(Q){return typeof Q==="boolean"}function f(Q){return typeof Q==="function"}function s(Q){return typeof Q==="string"}function k(Q){return Q===void 0}function _(Q){return Q===null}function b(Q){return!isNaN(parseFloat(Q))&&isFinite(Q)}function N(Q){if(typeof Q!=="object"||Q===null)return!1;var z=Object.getPrototypeOf(Q);return z===null||z===Object.prototype}M.isWindow=L,M.isFunction=f,M.isArray=K,M.isNumeric=b,M.isPlainObject=N;function R(Q,z,w){if(w){var j=Q.length;while(j--)if(z.call(Q[j],j,Q[j])===!1)return Q}else if(N(Q)){var V=Object.keys(Q);for(var j=0,T=V.length;j<T;j++){var y=V[j];if(z.call(Q[y],y,Q[y])===!1)return Q}}else for(var j=0,T=Q.length;j<T;j++)if(z.call(Q[j],j,Q[j])===!1)return Q;return Q}M.each=R,U.each=function(Q){return R(this,Q)},U.empty=function(){return this.each(function(Q,z){while(z.firstChild)z.removeChild(z.firstChild)})};function I(){var Q=[];for(var z=0;z<arguments.length;z++)Q[z]=arguments[z];var w=m(Q[0])?Q.shift():!1,j=Q.shift(),V=Q.length;if(!j)return{};if(!V)return I(w,M,j);for(var T=0;T<V;T++){var y=Q[T];for(var l in y)if(w&&(K(y[l])||N(y[l]))){if(!j[l]||j[l].constructor!==y[l].constructor)j[l]=new y[l].constructor;I(w,j[l],y[l])}else j[l]=y[l]}return j}M.extend=I,U.extend=function(Q){return I(U,Q)};var A=/\S+/g;function S(Q){return s(Q)?Q.match(A)||[]:[]}U.toggleClass=function(Q,z){var w=S(Q),j=!k(z);return this.each(function(V,T){if(!C(T))return;R(w,function(y,l){if(j)z?T.classList.add(l):T.classList.remove(l);else T.classList.toggle(l)})})},U.addClass=function(Q){return this.toggleClass(Q,!0)},U.removeAttr=function(Q){var z=S(Q);return this.each(function(w,j){if(!C(j))return;R(z,function(V,T){j.removeAttribute(T)})})};function E(Q,z){if(!Q)return;if(s(Q)){if(arguments.length<2){if(!this[0]||!C(this[0]))return;var w=this[0].getAttribute(Q);return _(w)?void 0:w}if(k(z))return this;if(_(z))return this.removeAttr(Q);return this.each(function(V,T){if(!C(T))return;T.setAttribute(Q,z)})}for(var j in Q)this.attr(j,Q[j]);return this}U.attr=E,U.removeClass=function(Q){if(arguments.length)return this.toggleClass(Q,!1);return this.attr("class","")},U.hasClass=function(Q){return!!Q&&q0.call(this,function(z){return C(z)&&z.classList.contains(Q)})},U.get=function(Q){if(k(Q))return a.call(this);return Q=Number(Q),this[Q<0?Q+this.length:Q]},U.eq=function(Q){return M(this.get(Q))},U.first=function(){return this.eq(0)},U.last=function(){return this.eq(-1)};function h(Q){if(k(Q))return this.get().map(function(z){return C(z)||P(z)?z.textContent:""}).join("");return this.each(function(z,w){if(!C(w))return;w.textContent=Q})}U.text=h;function u(Q,z,w){if(!C(Q))return;var j=Z.getComputedStyle(Q,null);return w?j.getPropertyValue(z)||void 0:j[z]||Q.style[z]}function c(Q,z){return parseInt(u(Q,z),10)||0}function Q0(Q,z){return c(Q,"border".concat(z?"Left":"Top","Width"))+c(Q,"padding".concat(z?"Left":"Top"))+c(Q,"padding".concat(z?"Right":"Bottom"))+c(Q,"border".concat(z?"Right":"Bottom","Width"))}var t={};function e(Q){if(t[Q])return t[Q];var z=H(Q);J.body.insertBefore(z,null);var w=u(z,"display");return J.body.removeChild(z),t[Q]=w!=="none"?w:"block"}function w0(Q){return u(Q,"display")==="none"}function I0(Q,z){var w=Q&&(Q.matches||Q.webkitMatchesSelector||Q.msMatchesSelector);return!!w&&!!z&&w.call(Q,z)}function S0(Q){return s(Q)?function(z,w){return I0(w,Q)}:f(Q)?Q:$(Q)?function(z,w){return Q.is(w)}:!Q?function(){return!1}:function(z,w){return w===Q}}U.filter=function(Q){var z=S0(Q);return M(O.call(this,function(w,j){return z.call(w,j,w)}))};function A0(Q,z){return!z?Q:Q.filter(z)}U.detach=function(Q){return A0(this,Q).each(function(z,w){if(w.parentNode)w.parentNode.removeChild(w)}),this};var c5=/^\s*<(\w+)[^>]*>/,p5=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o1={"*":q,tr:B,td:Y,th:Y,thead:W,tbody:W,tfoot:W};function r1(Q){if(!s(Q))return[];if(p5.test(Q))return[H(RegExp.$1)];var z=c5.test(Q)&&RegExp.$1,w=o1[z]||o1["*"];return w.innerHTML=Q,M(w.childNodes).detach().get()}M.parseHTML=r1,U.has=function(Q){var z=s(Q)?function(w,j){return Z0(Q,j).length}:function(w,j){return j.contains(Q)};return this.filter(z)},U.not=function(Q){var z=S0(Q);return this.filter(function(w,j){return(!s(Q)||C(j))&&!z.call(j,w,j)})};function R0(Q,z,w,j){var V=[],T=f(z),y=j&&S0(j);for(var l=0,F0=Q.length;l<F0;l++)if(T){var z0=z(Q[l]);if(z0.length)J0.apply(V,z0)}else{var K0=Q[l][z];while(K0!=null){if(j&&y(-1,K0))break;V.push(K0),K0=w?K0[z]:null}}return V}function n1(Q){if(Q.multiple&&Q.options)return R0(O.call(Q.options,function(z){return z.selected&&!z.disabled&&!z.parentNode.disabled}),"value");return Q.value||""}function s5(Q){if(!arguments.length)return this[0]&&n1(this[0]);return this.each(function(z,w){var j=w.multiple&&w.options;if(j||z5.test(w.type)){var V=K(Q)?d.call(Q,String):_(Q)?[]:[String(Q)];if(j)R(w.options,function(T,y){y.selected=V.indexOf(y.value)>=0},!0);else w.checked=V.indexOf(w.value)>=0}else w.value=k(Q)||_(Q)?"":Q})}U.val=s5,U.is=function(Q){var z=S0(Q);return q0.call(this,function(w,j){return z.call(w,j,w)})},M.guid=1;function N0(Q){return Q.length>1?O.call(Q,function(z,w,j){return g.call(j,z)===w}):Q}M.unique=N0,U.add=function(Q,z){return M(N0(this.get().concat(M(Q,z).get())))},U.children=function(Q){return A0(M(N0(R0(this,function(z){return z.children}))),Q)},U.parent=function(Q){return A0(M(N0(R0(this,"parentNode"))),Q)},U.index=function(Q){var z=Q?M(Q)[0]:this[0],w=Q?this:M(z).parent().children();return g.call(w,z)},U.closest=function(Q){var z=this.filter(Q);if(z.length)return z;var w=this.parent();if(!w.length)return z;return w.closest(Q)},U.siblings=function(Q){return A0(M(N0(R0(this,function(z){return M(z).parent().children().not(z)}))),Q)},U.find=function(Q){return M(N0(R0(this,function(z){return Z0(Q,z)})))};var l5=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,o5=/^$|^module$|\/(java|ecma)script/i,r5=["type","src","nonce","noModule"];function n5(Q,z){var w=M(Q);w.filter("script").add(w.find("script")).each(function(j,V){if(o5.test(V.type)&&X.contains(V)){var T=H("script");T.text=V.textContent.replace(l5,""),R(r5,function(y,l){if(V[l])T[l]=V[l]}),z.head.insertBefore(T,null),z.head.removeChild(T)}})}function a5(Q,z,w,j,V){if(j)Q.insertBefore(z,w?Q.firstChild:null);else if(Q.nodeName==="HTML")Q.parentNode.replaceChild(z,Q);else Q.parentNode.insertBefore(z,w?Q:Q.nextSibling);if(V)n5(z,Q.ownerDocument)}function b0(Q,z,w,j,V,T,y,l){return R(Q,function(F0,z0){R(M(z0),function(K0,h0){R(M(z),function(L0,e0){var x1=w?h0:e0,g1=w?e0:h0,O0=w?K0:L0;a5(x1,!O0?g1:g1.cloneNode(!0),j,V,!O0)},l)},y)},T),z}U.after=function(){return b0(arguments,this,!1,!1,!1,!0,!0)},U.append=function(){return b0(arguments,this,!1,!1,!0)};function t5(Q){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(Q))return this;var z=/<script[\s>]/.test(Q);return this.each(function(w,j){if(!C(j))return;if(z)M(j).empty().append(Q);else j.innerHTML=Q})}U.html=t5,U.appendTo=function(Q){return b0(arguments,this,!0,!1,!0)},U.wrapInner=function(Q){return this.each(function(z,w){var j=M(w),V=j.contents();V.length?V.wrapAll(Q):j.append(Q)})},U.before=function(){return b0(arguments,this,!1,!0)},U.wrapAll=function(Q){var z=M(Q),w=z[0];while(w.children.length)w=w.firstElementChild;return this.first().before(z),this.appendTo(w)},U.wrap=function(Q){return this.each(function(z,w){var j=M(Q)[0];M(w).wrapAll(!z?j:j.cloneNode(!0))})},U.insertAfter=function(Q){return b0(arguments,this,!0,!1,!1,!1,!1,!0)},U.insertBefore=function(Q){return b0(arguments,this,!0,!0)},U.prepend=function(){return b0(arguments,this,!1,!0,!0,!0,!0)},U.prependTo=function(Q){return b0(arguments,this,!0,!0,!0,!1,!1,!0)},U.contents=function(){return M(N0(R0(this,function(Q){return Q.tagName==="IFRAME"?[Q.contentDocument]:Q.tagName==="TEMPLATE"?Q.content.childNodes:Q.childNodes})))},U.next=function(Q,z,w){return A0(M(N0(R0(this,"nextElementSibling",z,w))),Q)},U.nextAll=function(Q){return this.next(Q,!0)},U.nextUntil=function(Q,z){return this.next(z,!0,Q)},U.parents=function(Q,z){return A0(M(N0(R0(this,"parentElement",!0,z))),Q)},U.parentsUntil=function(Q,z){return this.parents(z,Q)},U.prev=function(Q,z,w){return A0(M(N0(R0(this,"previousElementSibling",z,w))),Q)},U.prevAll=function(Q){return this.prev(Q,!0)},U.prevUntil=function(Q,z){return this.prev(z,!0,Q)},U.map=function(Q){return M(D.apply([],d.call(this,function(z,w){return Q.call(z,w,z)})))},U.clone=function(){return this.map(function(Q,z){return z.cloneNode(!0)})},U.offsetParent=function(){return this.map(function(Q,z){var w=z.offsetParent;while(w&&u(w,"position")==="static")w=w.offsetParent;return w||X})},U.slice=function(Q,z){return M(a.call(this,Q,z))};var e5=/-([a-z])/g;function P1(Q){return Q.replace(e5,function(z,w){return w.toUpperCase()})}U.ready=function(Q){var z=function(){return setTimeout(Q,0,M)};if(J.readyState!=="loading")z();else J.addEventListener("DOMContentLoaded",z);return this},U.unwrap=function(){return this.parent().each(function(Q,z){if(z.tagName==="BODY")return;var w=M(z);w.replaceWith(w.children())}),this},U.offset=function(){var Q=this[0];if(!Q)return;var z=Q.getBoundingClientRect();return{top:z.top+Z.pageYOffset,left:z.left+Z.pageXOffset}},U.position=function(){var Q=this[0];if(!Q)return;var z=u(Q,"position")==="fixed",w=z?Q.getBoundingClientRect():this.offset();if(!z){var j=Q.ownerDocument,V=Q.offsetParent||j.documentElement;while((V===j.body||V===j.documentElement)&&u(V,"position")==="static")V=V.parentNode;if(V!==Q&&C(V)){var T=M(V).offset();w.top-=T.top+c(V,"borderTopWidth"),w.left-=T.left+c(V,"borderLeftWidth")}}return{top:w.top-c(Q,"marginTop"),left:w.left-c(Q,"marginLeft")}};var a1={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};U.prop=function(Q,z){if(!Q)return;if(s(Q)){if(Q=a1[Q]||Q,arguments.length<2)return this[0]&&this[0][Q];return this.each(function(j,V){V[Q]=z})}for(var w in Q)this.prop(w,Q[w]);return this},U.removeProp=function(Q){return this.each(function(z,w){delete w[a1[Q]||Q]})};var J8=/^--/;function E1(Q){return J8.test(Q)}var T1={},Z8=q.style,Q8=["webkit","moz","ms"];function W8(Q,z){if(z===void 0)z=E1(Q);if(z)return Q;if(!T1[Q]){var w=P1(Q),j="".concat(w[0].toUpperCase()).concat(w.slice(1)),V="".concat(w," ").concat(Q8.join("".concat(j," "))).concat(j).split(" ");R(V,function(T,y){if(y in Z8)return T1[Q]=y,!1})}return T1[Q]}var X8={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function t1(Q,z,w){if(w===void 0)w=E1(Q);return!w&&!X8[Q]&&b(z)?"".concat(z,"px"):z}function H8(Q,z){if(s(Q)){var w=E1(Q);if(Q=W8(Q,w),arguments.length<2)return this[0]&&u(this[0],Q,w);if(!Q)return this;return z=t1(Q,z,w),this.each(function(V,T){if(!C(T))return;if(w)T.style.setProperty(Q,z);else T.style[Q]=z})}for(var j in Q)this.css(j,Q[j]);return this}U.css=H8;function e1(Q,z){try{return Q(z)}catch(w){return z}}var q8=/^\s+|\s+$/;function J5(Q,z){var w=Q.dataset[z]||Q.dataset[P1(z)];if(q8.test(w))return w;return e1(JSON.parse,w)}function z8(Q,z,w){w=e1(JSON.stringify,w),Q.dataset[P1(z)]=w}function B8(Q,z){if(!Q){if(!this[0])return;var w={};for(var j in this[0].dataset)w[j]=J5(this[0],j);return w}if(s(Q)){if(arguments.length<2)return this[0]&&J5(this[0],Q);if(k(z))return this;return this.each(function(V,T){z8(T,Q,z)})}for(var j in Q)this.data(j,Q[j]);return this}U.data=B8;function Z5(Q,z){var w=Q.documentElement;return Math.max(Q.body["scroll".concat(z)],w["scroll".concat(z)],Q.body["offset".concat(z)],w["offset".concat(z)],w["client".concat(z)])}R([!0,!1],function(Q,z){R(["Width","Height"],function(w,j){var V="".concat(z?"outer":"inner").concat(j);U[V]=function(T){if(!this[0])return;if(L(this[0]))return z?this[0]["inner".concat(j)]:this[0].document.documentElement["client".concat(j)];if(F(this[0]))return Z5(this[0],j);return this[0]["".concat(z?"offset":"client").concat(j)]+(T&&z?c(this[0],"margin".concat(w?"Top":"Left"))+c(this[0],"margin".concat(w?"Bottom":"Right")):0)}})}),R(["Width","Height"],function(Q,z){var w=z.toLowerCase();U[w]=function(j){if(!this[0])return k(j)?void 0:this;if(!arguments.length){if(L(this[0]))return this[0].document.documentElement["client".concat(z)];if(F(this[0]))return Z5(this[0],z);return this[0].getBoundingClientRect()[w]-Q0(this[0],!Q)}var V=parseInt(j,10);return this.each(function(T,y){if(!C(y))return;var l=u(y,"boxSizing");y.style[w]=t1(w,V+(l==="border-box"?Q0(y,!Q):0))})}});var Q5="___cd";U.toggle=function(Q){return this.each(function(z,w){if(!C(w))return;var j=w0(w),V=k(Q)?j:Q;if(V){if(w.style.display=w[Q5]||"",w0(w))w.style.display=e(w.tagName)}else if(!j)w[Q5]=u(w,"display"),w.style.display="none"})},U.hide=function(){return this.toggle(!1)},U.show=function(){return this.toggle(!0)};var W5="___ce",$1=".",S1={focus:"focusin",blur:"focusout"},X5={mouseenter:"mouseover",mouseleave:"mouseout"},w8=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function A1(Q){return X5[Q]||S1[Q]||Q}function b1(Q){var z=Q.split($1);return[z[0],z.slice(1).sort()]}U.trigger=function(Q,z){if(s(Q)){var w=b1(Q),j=w[0],V=w[1],T=A1(j);if(!T)return this;var y=w8.test(T)?"MouseEvents":"HTMLEvents";Q=J.createEvent(y),Q.initEvent(T,!0,!0),Q.namespace=V.join($1),Q.___ot=j}Q.___td=z;var l=Q.___ot in S1;return this.each(function(F0,z0){if(l&&f(z0[Q.___ot]))z0["___i".concat(Q.type)]=!0,z0[Q.___ot](),z0["___i".concat(Q.type)]=!1;z0.dispatchEvent(Q)})};function H5(Q){return Q[W5]=Q[W5]||{}}function G8(Q,z,w,j,V){var T=H5(Q);T[z]=T[z]||[],T[z].push([w,j,V]),Q.addEventListener(z,V)}function q5(Q,z){return!z||!q0.call(z,function(w){return Q.indexOf(w)<0})}function t0(Q,z,w,j,V){var T=H5(Q);if(!z)for(z in T)t0(Q,z,w,j,V);else if(T[z])T[z]=T[z].filter(function(y){var l=y[0],F0=y[1],z0=y[2];if(V&&z0.guid!==V.guid||!q5(l,w)||j&&j!==F0)return!0;Q.removeEventListener(z,z0)})}U.off=function(Q,z,w){var j=this;if(k(Q))this.each(function(T,y){if(!C(y)&&!F(y)&&!L(y))return;t0(y)});else if(!s(Q))for(var V in Q)this.off(V,Q[V]);else{if(f(z))w=z,z="";R(S(Q),function(T,y){var l=b1(y),F0=l[0],z0=l[1],K0=A1(F0);j.each(function(h0,L0){if(!C(L0)&&!F(L0)&&!L(L0))return;t0(L0,K0,z0,z,w)})})}return this},U.remove=function(Q){return A0(this,Q).detach().off(),this},U.replaceWith=function(Q){return this.before(Q).remove()},U.replaceAll=function(Q){return M(Q).replaceWith(this),this};function U8(Q,z,w,j,V){var T=this;if(!s(Q)){for(var y in Q)this.on(y,z,w,Q[y],V);return this}if(!s(z))if(k(z)||_(z))z="";else if(k(w))w=z,z="";else j=w,w=z,z="";if(!f(j))j=w,w=void 0;if(!j)return this;return R(S(Q),function(l,F0){var z0=b1(F0),K0=z0[0],h0=z0[1],L0=A1(K0),e0=K0 in X5,x1=K0 in S1;if(!L0)return;T.each(function(g1,O0){if(!C(O0)&&!F(O0)&&!L(O0))return;var k1=function(B0){if(B0.target["___i".concat(B0.type)])return B0.stopImmediatePropagation();if(B0.namespace&&!q5(h0,B0.namespace.split($1)))return;if(!z&&(x1&&(B0.target!==O0||B0.___ot===L0)||e0&&B0.relatedTarget&&O0.contains(B0.relatedTarget)))return;var h1=O0;if(z){var v0=B0.target;while(!I0(v0,z)){if(v0===O0)return;if(v0=v0.parentNode,!v0)return}h1=v0}Object.defineProperty(B0,"currentTarget",{configurable:!0,get:function(){return h1}}),Object.defineProperty(B0,"delegateTarget",{configurable:!0,get:function(){return O0}}),Object.defineProperty(B0,"data",{configurable:!0,get:function(){return w}});var M8=j.call(h1,B0,B0.___td);if(V)t0(O0,L0,h0,z,k1);if(M8===!1)B0.preventDefault(),B0.stopPropagation()};k1.guid=j.guid=j.guid||M.guid++,G8(O0,L0,h0,z,k1)})}),this}U.on=U8;function Y8(Q,z,w,j){return this.on(Q,z,w,j,!0)}U.one=Y8;var K8=/\r?\n/g;function O8(Q,z){return"&".concat(encodeURIComponent(Q),"=").concat(encodeURIComponent(z.replace(K8,"\r\n")))}var j8=/file|reset|submit|button|image/i,z5=/radio|checkbox/i;if(U.serialize=function(){var Q="";return this.each(function(z,w){R(w.elements||[w],function(j,V){if(V.disabled||!V.name||V.tagName==="FIELDSET"||j8.test(V.type)||z5.test(V.type)&&!V.checked)return;var T=n1(V);if(!k(T)){var y=K(T)?T:[T];R(y,function(l,F0){Q+=O8(V.name,F0)})}})}),Q.slice(1)},typeof M5!=="undefined")D5.exports=M;else Z.cash=Z.$=M})()});var x0="i18n",P0="syn:",V0="fn:",f0="on-",j0=/^\.\.\./,Z1=/^\[(.*?)\]$/,_1=/{\s*([^{}]+)\s*}/g,B5=["@html","@text","@format"],Q1=["if","for","switch","async","router"],w5=["display","visibility","position","width","height"],G5=":n",y1=":pr",U5="m",Y5="c",K5="x",l0="*",g0=":xtag",k0=":dtag",O5=100;var v1=new Map;class W1{templateStore;constructor(J){this.templateStore=J}parse(J,Z){if(v1.has(J))return v1.get(J);let X=(J||"").trim().replace(/>\s*</g,"><").replace(/\s{2,}/g," ").replace(/[\r\n\t]/g,"").replace(/<([a-zA-Z0-9_-]+)([^>]*?)\s*\/>/g,"<$1$2></$1>").replace(/<\{([^}]+)\}\s*(.*?)(\/)>/g,(H,q,W)=>{return W.endsWith("<")?`<lips ${k0}="${q}" ${W}/lips>`:`<lips ${k0}="${q}" ${W}></lips>`}).replace(/(<>)([\s\S]*?)(<\/>)/g,'<lips fragment="true">$2</lips>').replace(/<if\(\s*(.*?)\s*\)>/g,'<if @by="$1">').replace(/<else-if\(\s*(.*?)\s*\)>/g,'<else-if @by="$1">').replace(/<switch\(\s*(.*?)\s*\)>/g,'<switch @by="$1">').replace(/<async await\(\s*(.*?)\s*\)>/g,`<async ${V0}await="\$1">`).replace(/<log\(\s*(.*?)\s*\)>/g,'<log @args="$1">').replace(/\[(.*?)\]/g,(H)=>H.replace(/\s+/g,""));return X=this.matchEventHandlers(X),X=this.markExpressionAttributes(X,Z),v1.set(J,X),X}isExpression(J){if(/\bstate\.|\binput\.|\bself\.|\bcontext\./.test(J))return!0;if(/[\+\*\/\%\(\)\{\}\[\]]|\?\s*:/.test(J))return!0;if(/\b[a-zA-Z_][a-zA-Z0-9_]*\.[a-zA-Z_]/.test(J))return!0;if(J.includes("{")&&J.includes("}"))return!0;return!1}matchEventHandlers(J){const Z=/on-([a-zA-Z-]+)\s*\(/g;let X=J,H;while((H=Z.exec(J))!==null){const q=H[1],W=H.index+H[0].length;let B=1,Y=W;while(Y<J.length&&B>0){if(J[Y]==="(")B++;if(J[Y]===")")B--;Y++}if(B===0){const K=J.slice(W,Y-1).trim(),G=J.slice(0,H.index),D=`${f0}${q}="${K}"`,O=J.slice(Y);X=G+D+O,J=X,Z.lastIndex=G.length+D.length}}return X}markExpressionAttributes(J,Z){const X=[];let q=J.replace(/<([a-zA-Z][a-zA-Z0-9_-]*)((?:[^>'"]*|'[^']*'|"[^"]*")*?)(?:\/?>)/g,(W,B,Y)=>{if(!Q1.includes(B)&&(this.templateStore.has(B)||Z?.has(B)))Y+=` ${g0}="${B}"`;return X.push(Y),`<${B}##TAG_ATTRS_${X.length-1}##>`});for(let W=0;W<X.length;W++){const B=`##TAG_ATTRS_${W}##`,Y=X[W],K=this.processAttributes(Y);q=q.replace(B,K)}return q}processAttributes(J){let Z="",X=0,H=!1,q="",W=0,B=0,Y=0;while(X<J.length){const K=J[X];if((K==='"'||K==="'")&&(X===0||J[X-1]!=="\\")){if(!H)H=!0,q=K;else if(K===q)H=!1}if(!H){if(K==="(")B++;else if(K===")")B--;else if(K==="{")Y++;else if(K==="}")Y--}if(!H&&B===0&&Y===0&&(K===" "||X===J.length-1)){let G=X;if(X===J.length-1)G=X+1;const D=J.substring(W,G).trim();if(D){const O=this.processAttribute(D);Z+=" "+O}W=X+1}X++}return Z}processAttribute(J){const Z=J.indexOf("=");if(Z===-1){if(J===x0||J.startsWith("...")||J.startsWith("["))return J;return`:${J}="${!J.startsWith("!")}"`}let X=J.substring(0,Z).trim(),H=J.substring(Z+1).trim();if(X.startsWith("@"))return X=!B5.includes(X)?X.slice(1):X,`:${X}=${H}`;if(X.startsWith(":")||X.startsWith(V0)||X.startsWith(f0))return J;if(H.startsWith('"')&&H.endsWith('"')||H.startsWith("'")&&H.endsWith("'")){const q=H.substring(1,H.length-1);if(this.isExpression(q))return`:${X}="${q}"`;return J}else return`:${X}="${H}"`}}class X1{pendingComponents=new Set;isPending=!1;callbacks=new Map;register(J,Z){this.callbacks.set(J,Z)}unregister(J){this.callbacks.delete(J)}queue(J){if(!this.callbacks.has(J))return;if(this.pendingComponents.add(J),!this.isPending)this.isPending=!0,this.schedule()}schedule(){Promise.resolve().then(()=>this.process())}process(){const J=Array.from(this.pendingComponents);this.pendingComponents.clear(),this.isPending=!1,J.forEach((Z)=>{try{const X=this.callbacks.get(Z);if(X)X()}catch(X){console.error(`Error updating component ${Z}:`,X)}})}clear(){this.pendingComponents.clear(),this.isPending=!1}dispose(){this.pendingComponents.clear(),this.callbacks.clear(),this.isPending=!1}}class H1{subscriptions=new Map;tick=new X1;register(J,Z){this.subscriptions.set(J,Z),this.tick.register(J,Z)}unregister(J){this.subscriptions.delete(J),this.tick.unregister(J)}queueUpdate(J){this.tick.queue(J)}dispose(){this.subscriptions.clear(),this.tick.dispose()}prepareForPotentialUnload(){this.tick.clear(),this.subscriptions.forEach((J,Z)=>{this.subscriptions.set(Z,()=>{})})}proxyState(J,Z){const X=this,H=new WeakMap,q=(B)=>{if(typeof B.toJSON==="function")return B;if(B instanceof Map)B.forEach((K,G)=>B.set(G,W(K)));else if(Array.isArray(B))B.forEach((K,G)=>B[G]=W(K));else if(typeof B==="object")Object.entries(B).forEach(([K,G])=>B[K]=W(G));let Y=new Proxy(B,{get(K,G){if(G==="toJSON")return function(){const O=(g)=>{if(!g||typeof g!=="object")return g;if(H.has(g)){const d=H.get(g);if(d instanceof Map){const a={};return d.forEach((q0,n)=>a[typeof n==="object"?JSON.stringify(n):String(n)]=O(q0)),a}if(Array.isArray(d))return d.map((a)=>O(a));const J0={};return Object.entries(d).forEach(([a,q0])=>J0[a]=O(q0)),J0}if(typeof g.toJSON==="function"&&!H.has(g))return g.toJSON();return g};return O(Y)};if(G==="reset")return function(){Y=null};const D=K[G];if(B instanceof Map&&typeof D==="function")return function(...O){const g=G.toString();if(g==="set"&&O.length>=2)O[1]=W(O[1]);const d=D.apply(K,O);return["set","delete","clear"].includes(g)&&X.queueUpdate(J),d};if(Array.isArray(B)&&typeof D==="function")return function(...O){const g=G.toString();if(["push","unshift"].includes(g))O=O.map((J0)=>W(J0));else if(g==="splice"&&O.length>2)O=[O[0],O[1],...O.slice(2).map((J0)=>W(J0))];const d=D.apply(K,O);return["push","pop","shift","unshift","splice","sort","reverse","fill"].includes(g)&&X.queueUpdate(J),d};return D},set(K,G,D){if(K[G]===D)return!0;if(D instanceof Map&&K[G]instanceof Map){const O=K[G];return O.clear(),D.forEach((g,d)=>O.set(d,W(g))),X.queueUpdate(J),!0}return K[G]=W(D),X.queueUpdate(J),!0}});return H.set(Y,B),Y},W=(B)=>{if(!B)return B;return B instanceof Map||Array.isArray(B)||typeof B==="object"?q(B):B};return q(Z)}}class q1{domObserver;observedComponents=new Map;TIMEOUT=1e4;constructor(){this.domObserver=new MutationObserver(()=>{this.observedComponents.forEach((J,Z)=>{try{const X=Z.node;if(!X){this.unwatch(Z);return}if(J.type==="attach"&&document.contains(X[0]))this.unwatch(Z),Z.emit("component:attached"),typeof Z.onAttach=="function"&&Z.onAttach.bind(Z)();else if(J.type==="detach"&&!document.contains(X[0]))this.unwatch(Z),Z.emit("component:detached"),typeof Z.onDetach=="function"&&Z.onDetach.bind(Z)()}catch(X){console.log("DWS error --",X)}}),!this.observedComponents.size&&this.domObserver.disconnect()})}watch(J,Z="attach"){const X=J.node;if(!X)return;if(Z==="attach"&&document.contains(X[0])){J.emit("component:attached"),typeof J.onAttach=="function"&&J.onAttach.bind(J)();return}if(Z==="detach"&&!document.contains(X[0])){J.emit("component:detached"),typeof J.onDetach=="function"&&J.onDetach.bind(J)();return}this.unwatch(J);const H=setTimeout(()=>{this.unwatch(J),J.emit(`component:${Z}ment-timeout`)},this.TIMEOUT);this.observedComponents.set(J,{timeout:H,type:Z}),this.observedComponents.size===1&&this.domObserver.observe(document.body,{childList:!0,subtree:!0}),Z==="attach"&&J.once("component:attached",()=>this.watch(J,"detach"))}unwatch(J){const Z=this.observedComponents.get(J);if(Z)clearTimeout(Z.timeout),this.observedComponents.delete(J);!this.observedComponents.size&&this.domObserver.disconnect()}dispose(){this.domObserver.disconnect(),this.observedComponents.forEach((J)=>clearTimeout(J.timeout)),this.observedComponents.clear()}}var z1=function(J,Z){if(!Z)return J;return J.replace(/{(\w+)}/g,(X,H)=>{return Z[H]!==void 0?Z[H].toString():`{${H}}`})},j5=(J,Z,X,H,q)=>{switch(J){case"plural":{if(typeof X==="string"){console.warn("Plural format value cannot be a string");return}if(H.count===void 0){console.warn("Plural format requires <count> parameter or use * by default.");let Y=X["*"];if(typeof Y==="object")Y=Y[q||"*"];return z1(Y,H)}if(typeof H.count==="string")H.count=Number(H.count);let W="*";if(H.count.toString()in X)W=H.count.toString();let B=X[W]||X["*"];if(typeof B==="object")B=B[q||"*"];return z1(B,H)}case"condition":{if(typeof X==="string"){console.warn("Condition format value cannot be a string");return}let W;for(let B in X)try{if(new Function("params",`with( params ){ return ${B}; }`)(H||{})){W=X[B];break}}catch(Y){console.warn(`Invalid <${Z}(${B})> condition expression`)}if(W===void 0)return;if(typeof W==="object")W=W[q||"*"];return z1(W,H)}case"variable":default:{const W=typeof X==="object"?X[q||"*"]:X;if(typeof W==="object"){console.warn(`Invalid <${Z}> variable variant definition`);return}return z1(W,H)}}};class B1{currentLang=window.navigator.language;DICTIONARIES={};set lang(J){if(this.currentLang===J)return;this.currentLang=J}get lang(){return this.currentLang}setDictionary(J,Z){this.DICTIONARIES[J]=Z}translate(J,Z){if(Z&&this.currentLang===Z)return{text:J,lang:this.currentLang};Z=Z||this.currentLang;const[X,H]=Z.split("-");if(this.DICTIONARIES[X]&&J in this.DICTIONARIES[X]){if(typeof this.DICTIONARIES[X][J]==="object"){const q=this.DICTIONARIES[X][J];J=q[H||"*"]||q["*"]}else if(typeof this.DICTIONARIES[X][J]==="string")J=this.DICTIONARIES[X][J]}return{text:J,lang:Z}}format(J,Z,X){X=X||this.currentLang;const[H,q]=X.split("-");if(!this.DICTIONARIES[H]){console.warn(`Undefined <${X}> format dictionary`);return}if(!this.DICTIONARIES[H][J]){console.warn(`Undefined <${X}[${J}]> format reference`);return}const W=this.DICTIONARIES[H][J];if(typeof W==="string"){console.warn(`Invalid <${X}[${J}]> format reference. Expected object`);return}if(typeof W!=="object"||W===null||Array.isArray(W)){console.warn(`Invalid <${X}[${J}]> format value`);return}return j5(W.type,J,W.value,Z,q)}}var _5=J1(o0(),1);var w1="comm",G1="rule",U1="decl";var I5="@import";var F5="@namespace",L5="@keyframes";var V5="@layer";function Y1(J){return J.trim()}function u0(J,Z,X){return J.replace(Z,X)}function N5(J,Z,X){return J.indexOf(Z,X)}function E0(J,Z){return J.charCodeAt(Z)|0}function T0(J,Z,X){return J.slice(Z,X)}function U0(J){return J.length}function K1(J){return J.length}function m0(J,Z){return Z.push(J),J}var u1=Math.abs,r0=String.fromCharCode;function j1(J,Z,X,H,q,W,B,Y){return{value:J,root:Z,parent:X,type:H,props:q,children:W,line:O1,column:d0,length:B,return:"",siblings:Y}}function R5(){return H0}function P5(){if(H0=M0>0?E0(c0,--M0):0,d0--,H0===10)d0=1,O1--;return H0}function D0(){if(H0=M0<C5?E0(c0,M0++):0,d0++,H0===10)d0=1,O1++;return H0}function $0(){return E0(c0,M0)}function n0(){return M0}function M1(J,Z){return T0(c0,J,Z)}function i0(J){switch(J){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function E5(J){return O1=d0=1,C5=U0(c0=J),M0=0,[]}function T5(J){return c0="",J}function D1(J){return Y1(M1(M0-1,m1(J===91?J+2:J===40?J+1:J)))}function $5(J){while(H0=$0())if(H0<33)D0();else break;return i0(J)>2||i0(H0)>3?"":" "}function S5(J,Z){while(--Z&&D0())if(H0<48||H0>102||H0>57&&H0<65||H0>70&&H0<97)break;return M1(J,n0()+(Z<6&&$0()==32&&D0()==32))}function m1(J){while(D0())switch(H0){case J:return M0;case 34:case 39:if(J!==34&&J!==39)m1(H0);break;case 40:if(J===41)m1(J);break;case 92:D0();break}return M0}function A5(J,Z){while(D0())if(J+H0===57)break;else if(J+H0===84&&$0()===47)break;return"/*"+M1(Z,M0-1)+"*"+r0(J===47?J:D0())}function b5(J){while(!i0($0()))D0();return M1(J,M0)}var O1=1,d0=1,C5=0,M0=0,H0=0,c0="";function k5(J){return T5(I1("",null,null,null,[""],J=E5(J),0,[0],J))}function I1(J,Z,X,H,q,W,B,Y,K){var G=0,D=0,O=B,g=0,d=0,J0=0,a=1,q0=1,n=1,v=0,i="",o=q,r=W,Z0=H,p=i;while(q0)switch(J0=v,v=D0()){case 40:if(J0!=108&&E0(p,O-1)==58){if(N5(p+=u0(D1(v),"&","&\f"),"&\f",u1(G?Y[G-1]:0))!=-1)n=-1;break}case 34:case 39:case 91:p+=D1(v);break;case 9:case 10:case 13:case 32:p+=$5(J0);break;case 92:p+=S5(n0()-1,7);continue;case 47:switch($0()){case 42:case 47:if(m0(C8(A5(D0(),n0()),Z,X,K),K),(i0(J0||1)==5||i0($0()||1)==5)&&U0(p)&&T0(p,-1,void 0)!==" ")p+=" ";break;default:p+="/"}break;case 123*a:Y[G++]=U0(p)*n;case 125*a:case 59:case 0:switch(v){case 0:case 125:q0=0;case 59+D:if(n==-1)p=u0(p,/\f/g,"");if(d>0&&(U0(p)-O||a===0&&J0===47))m0(d>32?g5(p+";",H,X,O-1,K):g5(u0(p," ","")+";",H,X,O-2,K),K);break;case 59:p+=";";default:if(m0(Z0=x5(p,Z,X,G,D,q,Y,i,o=[],r=[],O,W),W),v===123)if(D===0)I1(p,Z,Z0,Z0,o,W,O,Y,r);else{switch(g){case 99:if(E0(p,3)===110)break;case 108:if(E0(p,2)===97)break;default:D=0;case 100:case 109:case 115:}if(D)I1(J,Z0,Z0,H&&m0(x5(J,Z0,Z0,0,0,q,Y,i,q,o=[],O,r),r),q,r,O,Y,H?o:r);else I1(p,Z0,Z0,Z0,[""],r,0,Y,r)}}G=D=d=0,a=n=1,i=p="",O=B;break;case 58:O=1+U0(p),d=J0;default:if(a<1){if(v==123)--a;else if(v==125&&a++==0&&P5()==125)continue}switch(p+=r0(v),v*a){case 38:n=D>0?1:(p+="\f",-1);break;case 44:Y[G++]=(U0(p)-1)*n,n=1;break;case 64:if($0()===45)p+=D1(D0());g=$0(),D=O=U0(i=p+=b5(n0())),v++;break;case 45:if(J0===45&&U0(p)==2)a=0}}return W}function x5(J,Z,X,H,q,W,B,Y,K,G,D,O){var g=q-1,d=q===0?W:[""],J0=K1(d);for(var a=0,q0=0,n=0;a<H;++a)for(var v=0,i=T0(J,g+1,g=u1(q0=B[a])),o=J;v<J0;++v)if(o=Y1(q0>0?d[v]+" "+i:u0(i,/&\f/g,d[v])))K[n++]=o;return j1(J,Z,X,q===0?G1:Y,K,G,D,O)}function C8(J,Z,X,H){return j1(J,Z,X,w1,r0(R5()),T0(J,2,-2),0,H)}function g5(J,Z,X,H,q){return j1(J,Z,X,U1,T0(J,0,H),T0(J,H+1,-1),H,q)}function F1(J,Z){var X="";for(var H=0;H<J.length;H++)X+=Z(J[H],H,J,Z)||"";return X}function h5(J,Z,X,H){switch(J.type){case V5:if(J.children.length)break;case I5:case F5:case U1:return J.return=J.return||J.value;case w1:return"";case L5:return J.return=J.value+"{"+F1(J.children,H)+"}";case G1:if(!U0(J.value=J.props.join(",")))return""}return U0(X=F1(J.children,H))?J.return=J.value+"{"+X+"}":""}function f5(J){var Z=K1(J);return function(X,H,q,W){var B="";for(var Y=0;Y<Z;Y++)B+=J[Y](X,H,q,W)||"";return B}}class p0{nsp;settings;$head;constructor(J,Z){if(typeof J!=="string")throw new Error("Undefined or invalid styles attachement element(s) namespace");this.nsp=J,this.$head=_5.default("head"),this.settings=Z||{},this.settings&&this.load(this.settings)}compile(J){try{return F1(k5(J),f5([h5]))}catch(Z){throw new Error(`Style compilation failed: ${Z.message}`)}}waitForStyles(J){return new Promise((Z)=>{const X=new MutationObserver(()=>{const H=document.querySelector(J);if(H&&getComputedStyle(H).cssText)X.disconnect(),Z()});X.observe(document.documentElement,{attributes:!0,childList:!0,subtree:!0})})}async inject(J){if(!J)throw new Error("Invalid injection arguments");const Z=`rel="${this.settings.meta?"@":""}${this.nsp}"`;J=this.settings.meta?J:`[rel="${this.nsp}"] { ${J} }`;try{const X=this.compile(J);if(!X)throw new Error(`<component:${this.nsp}> sheet compilation failed`);const H=document.createElement("style");H.setAttribute("rel",`${this.settings.meta?"@":""}${this.nsp}`),H.textContent=X;let q=0;const W=this.$head.find(`style[${Z}]`);if(W.length)q=parseInt(W.attr("dindex"))+1,W.remove();return H.setAttribute("dindex",String(q)),this.settings.meta?document.head.prepend(H):document.head.appendChild(H),H}catch(X){throw new Error(`Style injection failed: ${X.message}`)}}async load(J){if(this.settings=J,typeof this.settings!=="object")throw new Error("Undefined styles settings");if(this.settings.sheet){const Z=await this.inject(this.settings.sheet);await this.waitForStyles(`style[rel="${this.settings.meta?"@":""}${this.nsp}"]`)}}get(){}async clear(){const J=this.$head.find(`style[rel="${this.settings.meta?"@":""}${this.nsp}"]`);if(!J.length)return;const Z=parseInt(J.attr("dindex"));Z===0?J.remove():J.attr("dindex",String(Z-1))}async custom(){return{}}async style(){return{}}}class L1{pending=new Map;isPending=!1;component;metrics={batchCount:0,updatesProcessed:0,lastBatchSize:0,avgBatchSize:"0.00"};constructor(J){this.component=J}queue(J){const Z=J.priority??2;if(!this.pending.has(Z))this.pending.set(Z,new Set);if(this.pending.get(Z)?.add(J),this.component.metrics.inc("dependencyUpdateCount"),!this.isPending)this.isPending=!0,this.scheduleProcessing()}apply({dep:J,deppath:Z},X="batch-updator"){try{const H=this.component.FGUD.get(J)?.get(Z);if(!H){console.warn(`[batch update]: <${Z}> dependency not found`);return}if(H.garbage){this.component.FGUD.get(J)?.delete(Z),!this.component.FGUD.get(J)?.size&&this.component.FGUD.delete(J);return}const q=this.component.FGUDMemory.get(H.nodepath);if(!q)return;const W=H.update(q.memo||{},X);if(W){if(typeof W.memo==="object")q.memo=W.memo;typeof W.cleanup==="function"&&W.cleanup()}}catch(H){console.error("Failed to update dependency --",H)}}scheduleProcessing(){Promise.resolve().then(()=>this.processQueue())}processQueue(){const J=new Map;this.pending.forEach((H,q)=>J.set(q,new Set(H))),this.pending.clear(),this.isPending=!1;const Z=(H)=>{const q=Array.from(H);this.component.metrics.trackBatch(q.length),this.metrics.batchCount++,this.metrics.lastBatchSize=q.length,this.metrics.updatesProcessed+=q.length,this.metrics.avgBatchSize=(this.metrics.updatesProcessed/this.metrics.batchCount).toFixed(2),q.forEach((W)=>this.apply(W))},X=Array.from(J.keys()).sort((H,q)=>H-q);for(let H of X){const q=J.get(H);q&&q.size&&Z(q)}if(this.pending.size>0&&!this.isPending)this.isPending=!0,this.scheduleProcessing()}getMetrics(){return{batchCount:this.metrics.batchCount,lastBatchSize:this.metrics.lastBatchSize,avgBatchSize:this.metrics.avgBatchSize,totalUpdates:this.metrics.updatesProcessed}}}class V1{options={emit:!0};__events={};__once_events={};constructor(J){if(J)this.options=J}on(J,Z){if(!Array.isArray(this.__events[J]))this.__events[J]=[];return this.__events[J].push(Z),this}once(J,Z){if(!Array.isArray(this.__once_events[J]))this.__once_events[J]=[];return this.__once_events[J].push(Z),this}off(J){return delete this.__events[J],delete this.__once_events[J],this}emit(J,...Z){if(!this.options.emit)return;const X=(q)=>{if(typeof q.toJSON==="function")return q.toJSON();if(Array.isArray(q))return q.map(X);if(typeof q==="object")for(let W in q)q[W]=X(q[W]);return q},H=Z.map(X);this.__events[J]?.forEach((q)=>q(...H)),this.__once_events[J]?.forEach((q)=>q(...H)),delete this.__once_events[J]}}var d1=J1(o0(),1);function G0(J,Z){if(J===Z)return!1;if(typeof J!=="object"||typeof Z!=="object")return!1;if(J===null||Z===null)return!0;if(J instanceof Set){if(!(Z instanceof Set))return!0;if(J.size!==Z.size)return!0;if(y5(J)&&y5(Z)){for(let B of J)if(!Z.has(B))return!0;return!1}const W=new WeakMap;for(let B of J){let Y=!1;if(typeof B!=="object"){if(Z.has(B))Y=!0}else for(let K of Z){if(typeof K!=="object")continue;if(!W.has(B))W.set(B,new WeakMap);const G=W.get(B);if(G.has(K)){if(Y=G.get(K),Y)break;continue}const D=!G0(B,K);if(G.set(K,D),D){Y=!0;break}}if(!Y)return!0}return!1}if(J instanceof Map){if(!(Z instanceof Map))return!0;if(J.size!==Z.size)return!0;if(v5(J)&&v5(Z)){for(let[B,Y]of J)if(Z.get(B)!==Y)return!0;return!1}const W=new WeakMap;for(let[B,Y]of J){if(typeof B!=="object"){if(!Z.has(B))return!0;const D=Z.get(B);if(typeof Y!=="object"){if(Y!==D)return!0;continue}if(typeof D!=="object"||G0(Y,D))return!0;continue}let K=!1,G=!1;for(let[D,O]of Z){if(typeof D!=="object")continue;if(!W.has(B))W.set(B,new WeakMap);const g=W.get(B);if(g.has(D)){const[d,J0]=g.get(D);if(d){K=!0,G=J0;break}continue}if(!G0(B,D)){if(K=!0,G=typeof Y==="object"&&typeof O==="object"?!G0(Y,O):Y===O,g.set(D,[!0,G]),G)break}else g.set(D,[!1,!1])}if(!K||!G)return!0}return!1}if(Array.isArray(J)){if(!Array.isArray(Z))return!0;if(J.length!==Z.length)return!0;for(let W=0;W<J.length;W++){const B=J[W],Y=Z[W];if(B!==Y&&(typeof B!=="object"||G0(B,Y)))return!0}return!1}const X=Object.keys(J),H=Object.keys(Z);if(X.length!==H.length)return!0;X.sort(),H.sort();const q=X.length;for(let W=0;W<q;W++)if(X[W]!==H[W])return!0;for(let W=0;W<q;W++){const B=X[W],Y=J[B],K=Z[B];if(Y===K)continue;if(Y instanceof Date){if(!(K instanceof Date)||String(Y)!==String(K))return!0;continue}if(Y instanceof RegExp){if(!(K instanceof RegExp)||Y.source!==K.source||Y.flags!==K.flags)return!0;continue}if(Y instanceof Map){if(!(K instanceof Map)||G0(Y,K))return!0;continue}if(Y instanceof Set){if(!(K instanceof Set)||G0(Y,K))return!0;continue}if(Y instanceof Function){if(!(K instanceof Function))return!0;continue}if(typeof Y==="object"){if(typeof K!=="object")return!0;if(Y===J){if(K!==Z)return!0}else if(G0(Y,K))return!0}else return!0}return!1}function Y0(J,Z){if(J===Z)return!0;if(J==null||Z==null)return J===Z;const X=typeof J;if(X!==typeof Z)return!1;if(X!=="object"){if(X==="number"&&isNaN(J)&&isNaN(Z))return!0;return!1}if(J instanceof Date)return Z instanceof Date&&J.getTime()===Z.getTime();if(J instanceof RegExp)return Z instanceof RegExp&&J.source===Z.source&&J.flags===Z.flags;if(J instanceof Error)return Z instanceof Error&&J.name===Z.name&&J.message===Z.message&&(J.stack===Z.stack||!J.stack&&!Z.stack);if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView(J)){if(!ArrayBuffer.isView(Z))return!1;if(J.byteLength!==Z.byteLength)return!1;const Y=new Uint8Array(J.buffer,J.byteOffset,J.byteLength),K=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength);for(let G=0;G<Y.length;G++)if(Y[G]!==K[G])return!1;return!0}if(J instanceof Promise||J instanceof WeakMap||J instanceof WeakSet)return J===Z;if(typeof J==="function"){if(typeof Z!=="function")return!1;return J.toString()===Z.toString()&&J.name===Z.name}if(J.constructor!==Z.constructor)return!1;if(J instanceof Map||J instanceof Set||Array.isArray(J)||Object.getPrototypeOf(J)===Object.prototype)return!G0(J,Z);const q=Object.getPrototypeOf(J);if(q!==Object.getPrototypeOf(Z))return!1;const W=Object.getOwnPropertyNames(J),B=Object.getOwnPropertyNames(Z);if(W.length!==B.length)return!1;for(let Y of W){if(!Object.prototype.hasOwnProperty.call(Z,Y))return!1;if(!Y0(J[Y],Z[Y]))return!1}if(q!==null&&q!==Object.prototype){const Y=Object.getOwnPropertyNames(q),K=Object.getOwnPropertyNames(Object.getPrototypeOf(Z));if(Y.length!==K.length)return!1;for(let G of Y){if(G==="constructor")continue;if(!Y0(q[G],Object.getPrototypeOf(Z)[G]))return!1}}return!0}function y5(J){for(let Z of J)if(typeof Z==="object"&&Z!==null)return!1;return!0}function v5(J){for(let[Z,X]of J)if(typeof Z==="object"&&Z!==null||typeof X==="object"&&X!==null)return!1;return!0}function X0(J,Z=new WeakMap){if(J===null||typeof J!=="object"||J instanceof Promise)return J;if(Z.has(J))return Z.get(J);if(J instanceof Date)return new Date(J.getTime());if(J instanceof RegExp)return new RegExp(J.source,J.flags);if(J instanceof Map){const q=new Map;return Z.set(J,q),J.forEach((W,B)=>q.set(X0(B,Z),X0(W,Z))),q}if(J instanceof Set){const q=new Set;return Z.set(J,q),J.forEach((W)=>q.add(X0(W,Z))),q}if(Array.isArray(J)){const q=[];Z.set(J,q);for(let W=0;W<J.length;W++)q[W]=X0(J[W],Z);return q}if(ArrayBuffer.isView(J))return new J.constructor(J);const X=Object.create(Object.getPrototypeOf(J));Z.set(J,X);const H=Object.getOwnPropertySymbols(J);for(let q of H)X[q]=X0(J[q],Z);for(let q in J)if(Object.prototype.hasOwnProperty.call(J,q))X[q]=X0(J[q],Z);return X}function u5(J,Z){if(!J||typeof J!=="object")throw new TypeError("Original argument must be an object");if(!Z||typeof Z!=="object")throw new TypeError("ToSet argument must be an object");if(!Object.keys(Z).length)return{...J};function X(q,W,B){const Y=W.split(/\.|\[|\]/).filter(Boolean);let K=q;for(let G=0;G<Y.length;G++){const D=Y[G],O=!isNaN(Number(D)),g=G===Y.length-1,d=!isNaN(Number(Y[G+1]));if(g){K[D]=B;continue}if(!(D in K))K[D]=d?[]:{};else if(d&&!Array.isArray(K[D]))K[D]=[];else if(!d&&Array.isArray(K[D]))K[D]={};K=K[D]}}const H=X0(J);try{for(let[q,W]of Object.entries(Z)){if(typeof q!=="string")throw new TypeError(`Invalid path: ${q}`);if(!/^[a-zA-Z0-9_\-\[\].]+$/.test(q))throw new Error(`Invalid path format: ${q}`);X(H,q,W)}}catch(q){throw new Error(`Failed to assign value: ${q.message}`)}return H}function N1(J){return JSON.parse(JSON.stringify(J))}d1.default.fn.extend({attrs:function(){const J={},Z=this[0];return Z&&Z.nodeType!==Node.TEXT_NODE&&d1.default.each(Z.attributes,function(){J[this.name]=this.value}),J}});class C1{debug;initialStats={renderCount:0,elementCount:0,renderTime:0,avgRenderTime:0,maxRenderTime:0,componentCount:0,componentUpdateCount:0,partialCount:0,partialUpdateCount:0,memoryUsage:void 0,domOperations:0,domInsertsCount:0,domUpdatesCount:0,domRemovalsCount:0,i18nTrackCount:0,i18nUpdateCount:0,dependencyTrackCount:0,dependencyUpdateCount:0,batchSize:0,batchCount:0,errorCount:0};stats=this.reset();renderStartTime=0;renderTimes=[];measurementCount=0;maxMeasurements=100;loggingInterval=10;autoSaveInterval;constructor(J=!1){if(this.debug=J,this.debug)this.autoSaveInterval=window.setInterval(()=>this.storeMetrics(),5000)}storeMetrics(){try{const J=JSON.parse(localStorage.getItem("lipsPerformanceMetrics")||"[]");J.push({timestamp:Date.now(),metrics:{...this.stats}}),J.length>100&&J.shift(),localStorage.setItem("lipsPerformanceMetrics",JSON.stringify(J))}catch(J){}}startRender(){if(!this.debug)return;this.renderStartTime=performance.now()}endRender(){if(!this.debug||this.renderStartTime===0)return;const J=performance.now()-this.renderStartTime;this.stats.renderTime=J,this.stats.maxRenderTime=Math.max(this.stats.maxRenderTime,J),this.renderTimes.push(J),this.renderTimes.length>this.maxMeasurements&&this.renderTimes.shift(),this.stats.avgRenderTime=this.renderTimes.reduce((Z,X)=>Z+X,0)/this.renderTimes.length,this.renderStartTime=0,this.measurementCount++}inc(J){if(!this.debug)return;if(typeof this.stats[J]==="number")this.stats[J]++}dec(J){if(!this.debug)return;if(typeof this.stats[J]==="number"&&this.stats[J]>0)this.stats[J]--}record(J,Z){if(!this.debug)return;if(typeof this.stats[J]!=="undefined")this.stats[J]=Z}add(J,Z){if(!this.debug)return;if(typeof this.stats[J]==="number")this.stats[J]+=Z}reset(){return this.renderTimes=[],this.measurementCount=0,this.stats=X0(this.initialStats)}log(){if(!this.debug)return;if(this.loggingInterval>1&&this.measurementCount%this.loggingInterval!==0)return;const J={"Render Count":this.stats.renderCount,"Element Count":this.stats.elementCount,"Avg Render Time (ms)":this.stats.avgRenderTime.toFixed(2),"Max Render Time (ms)":this.stats.maxRenderTime.toFixed(2)},Z={"Component Count":this.stats.componentCount,"Component Updates":this.stats.componentUpdateCount},X={"Partial Count":this.stats.partialCount,"Partial Updates":this.stats.partialUpdateCount},H={"DOM Operations":this.stats.domOperations,"DOM Inserts":this.stats.domInsertsCount,"DOM Updates":this.stats.domUpdatesCount,"DOM Removals":this.stats.domRemovalsCount},q={"i18n Tracked":this.stats.i18nTrackCount,"i18n Updates":this.stats.i18nUpdateCount},W={"Dependencies Tracked":this.stats.dependencyTrackCount,"Dependency Updates":this.stats.dependencyUpdateCount},B={"Batch Count":this.stats.batchCount,"Avg Batch Size":this.stats.batchCount>0?(this.stats.batchSize/this.stats.batchCount).toFixed(2):"0"};console.group("Lips Framework Performance Metrics"),console.table(J),console.table(Z),console.table(X),console.table(H),console.table(q),console.table(W),console.table(B),this.stats.memoryUsage&&console.log(`Memory Usage: ${this.stats.memoryUsage.toFixed(2)} MB`),this.stats.errorCount>0&&console.warn(`Errors encountered: ${this.stats.errorCount}`),console.groupEnd(),window.localStorage&&this.measurementCount%10===0&&this.storeMetrics()}trackMemory(){if(!this.debug||!window.performance?.memory)return;this.stats.memoryUsage=window.performance.memory.usedJSHeapSize/1048576}trackBatch(J){if(!this.debug)return;this.stats.batchCount++,this.stats.batchSize+=J}trackError(J){if(!this.debug)return;this.stats.errorCount++,console.error("Lips Framework Error:",J)}setLoggingInterval(J){if(!this.debug)return;this.loggingInterval=J}getSnapshot(){return X0(this.stats)}dispose(){if(!this.debug)return;this.autoSaveInterval&&clearInterval(this.autoSaveInterval)}}var W0=J1(o0(),1);var R8=function(J,Z){if(J.isDisposed)return;Z.add(J),J.dependencies.add(Z)},d5=function(J){for(let Z of J.dependencies)Z.delete(J);J.dependencies.clear()};function _0(J,Z={maxSize:100}){const X=new Set,H=[{value:J,timestamp:Date.now()}];let q=0;const W=()=>{const G=R1[R1.length-1];return G&&R8(G,X),H[q].value},B=()=>{const G=[...X];if(m5)for(let D of G)m5.add(D);else for(let D of G)D.execute()};return[W,(G,D)=>{if(Object.is(H[q].value,G))return;if(q<H.length-1)H.splice(q+1);if(H.push({value:G,timestamp:Date.now(),metadata:D}),H.length>Z.maxSize)H.shift(),q=Math.max(0,q-1);else q++;B()},{undo(){if(q>0)q--,B()},redo(){if(q<H.length-1)q++,B()},jumpTo(G){if(G>=0&&G<H.length&&G!==q)q=G,B()},getHistory(){return[...H]},getCurrentIndex(){return q},canUndo(){return q>0},canRedo(){return q<H.length-1},clear(){const G=H[0];H.length=0,H.push(G),q=0,B()}}]}function a0(J){let Z=!1;const X=()=>{if(Z)throw new Error("Circular dependency detected");if(H.isDisposed)return;Z=!0,d5(H),R1.push(H);try{J()}finally{Z=!1,R1.pop()}},H={execute:X,dependencies:new Set,isDisposed:!1};return X(),{dispose:()=>{H.isDisposed=!0,d5(H)}}}var R1=[],m5=null;class y0 extends V1{declaration;$=null;input;state;static;context;__name__;__path__;__lang__;__template__;__previous;__macros=new Map;__i18nDeps=new Map;FGUD=new Map;FGUDMemory=new Map;PCC=new Map;VER=[];prepath="0";debug=!1;isRendered=!1;__setInput;__setState;__getState;UQS;ICE;lips;metrics;stylesheet;__inpath__="";__inpathCounter__=0;__renderDepth__=0;__boundaries__;constructor(J,Z,{input:X,state:H,context:q,_static:W,handler:B,stylesheet:Y,macros:K,declaration:G},D){super();if(this.lips=D.lips,D?.debug)this.debug=D.debug||this.lips.debug;if(D?.prepath)this.prepath=D.prepath;if(this.__name__=J,this.__lang__=this.lips.i18n.lang,this.__path__=this.__inpath__=`${this.prepath}:${this.__name__}`,this.__boundaries__=D.boundaries,this.declaration=G||{name:J},this.input=X||{},this.static=W||{},this.context={},this.state=this.lips.IUC.proxyState(this.__path__,H||{}),K&&this.setMacros(K),B&&this.setHandler(B),Y&&this.setStylesheet(Y),this.__template__=this.lips.preprocessor.parse(Z,this.__macros),this.metrics=new C1(this.debug),this.metrics.inc("componentCount"),this.UQS=new L1(this),typeof this.onCreate=="function"&&this.onCreate.bind(this)(),this.emit("component:create"),this.input&&Object.keys(this.input).length&&typeof this.onInput=="function")this.onInput.bind(this)(),this.emit("component:input");this.__previous={state:X0(this.state),input:X0(this.input),context:X0(this.context)};const[O,g]=_0(this.input),[d,J0]=_0(this.state),[a,q0]=_0(this.context);this.__setInput=g,this.__setState=J0,this.__getState=d,this.lips.IUC.register(this.__path__,()=>{G0(this.__previous?.state,this.state)&&this.__setState({...this.__getState(),...this.state})}),Array.isArray(q)&&q.length&&this.lips.useContext(q,(n)=>{if(!G0(this.context,n))return;q0(n),this.context=n,typeof this.onContext=="function"&&this.onContext.bind(this)(),this.emit("component:context")}),this.lips.useTranslator("*",(n)=>{if(n===this.__lang__)return;this.__updateI18nDepNodes__(),this.__lang__=n}),this.ICE=a0(()=>{const n=d(),v=this.input=O(),i=this.context=a();if(!this.isRendered){if(this.metrics.reset(),!this.__template__.length||G?.syntax&&typeof this.onSelfRender=="function"){const o=this.onSelfRender.bind(this)(this.input);if(!this.__boundaries__?.start||!this.__boundaries__?.end)throw new Error(`Undefined <${this.__name__} syntax component boundaries`);this.$=o||W0.default()}else{const{$log:o}=this.render("",void 0,void 0,this.FGUD);this.$=o}!G?.syntax&&this.$?.each((o,r)=>{typeof r.setAttribute=="function"&&r.setAttribute("rel",this.__name__)}),this.isRendered=!0,typeof this.onMount=="function"&&this.onMount.bind(this)(),this.emit("component:mount"),this.lips.watcher.watch(this)}else this.__updateDepNodes__(),typeof this.onUpdate=="function"&&this.onUpdate.bind(this)(),this.emit("component:update"),this.__previous={input:X0(v),state:X0(n),context:X0(i)};typeof this.onRender=="function"&&this.onRender.bind(this)(),this.emit("component:render")})}setContext(J,Z){this.lips.setContext(J,Z)}setInput(J,Z){if(!G0(this.input,J))return;this.__setInput(J),typeof this.onInput=="function"&&this.onInput.bind(this)(this.declaration.syntax?Z:void 0)}subInput(J,Z){if(typeof J!=="object")throw new Error("Invalid sub input data argument");return this.setInput(u5(this.input,J),this.declaration.syntax?Z:void 0),this}setMacros(J){const Z=this.lips.preprocessor.parse(J),X=W0.default(Z);if(!X.length)return;const H=this;X.each(function(){const q=W0.default(this),{argv:W,attrs:B}=H.__getAttributes__(q);if(!Object.keys(B))throw new Error("Invalid macro component definition");if(!B.literals.name)throw new Error("Undefined macro `name` attribute.");if(H.__macros.get(B.literals.name))console.warn(`Duplicate macro <${B.literals.name}> will be override`);if(!q.contents()?.length)throw new Error("Invalid macro component definition. Template content expected.");H.__macros.set(B.literals.name,{argv:W,$node:q})})}setHandler(J){Object.entries(J).map(([Z,X])=>this[Z]=X?.bind(this))}setStylesheet(J){const Z={sheet:J,meta:this.__name__==="__ROOT__"};this.stylesheet=new p0(this.__name__,Z)}get node(){if(!this.isRendered)throw new Error("node() is expected to be call after component get rendered");return this.$}get boundaries(){return this.__boundaries__}render(J,Z,X={},H,q){if(Z&&!Z.length)return console.warn("Undefined node element to render"),{$log:Z,dependencies:H||new Map};const W=this,B=H||new Map,Y=[];this.metrics.startRender();let K=W0.default();function G(){return X0(X)}function D(U,M=!1){const $=O(U,M);return W.__inpathCounter__++,W.__inpath__?`${W.__inpath__}/${$}`:`${J?J+"/":""}${$}`}function O(U,M=!1){let $="";switch(U){case"component":$=M?K5:Y5;break;case"macro":$=U5;break}return $+W.__inpathCounter__}function g(U){return U===null||typeof U==="object"&&typeof U.mesh==="function"&&typeof U.fill==="function"&&typeof U.update==="function"&&typeof U.cleanup==="function"}function d(U){return U!==null&&typeof U==="object"&&typeof U.default&&typeof U.default==="string"}function J0(U){const M=U.attr(":args"),$=D("log");if(!M)return;const L=G();if(W.__evaluate__(`console.log(${M})`,L),W.__isReactive__(M,L))W.__extractExpressionDeps__(M,L).forEach((x)=>W.__trackDep__(B,x,L,{nodetype:"log",nodepath:$,target:"argument",$fragment:null,update:(C)=>W.__evaluate__(`console.log(${M})`,C),syntax:!0}))}function a(U){const M=D("var"),{attrs:$}=W.__getAttributes__(U);if(!$)return;Object.entries($.literals).forEach(([L,F])=>{if(X[L]&&X[L].type==="const")throw new Error(`Cannot override <const ${L}=[value]/> variable`);X[L]={value:F,type:"let"}}),Object.entries($.expressions).forEach(([L,F])=>{if(X[L]&&X[L].type==="const")throw new Error(`Cannot override <const ${L}=[value]/> variable`);if(X[L]={value:W.__evaluate__(F,X),type:"let"},W.__isReactive__(F,X)){const x=W.__extractExpressionDeps__(F,X),C=(P,m)=>{if(P[L]&&P[L].type==="const")throw new Error(`Cannot override <const ${L}=[value]/> variable`);if($.map.beforeSpreadAttrs.includes(L))return;const f=W.__evaluate__(F,P);if(Y0(P[L].value,f))return;return P[L]={value:f,type:"let"},W.__updateVarDepNodes__(L,M,P),N1({memo:P})};x.forEach((P)=>W.__trackDep__(B,P,G(),{nodetype:"let",nodepath:M,deppath:`${M}.${L}`,target:"attr",$fragment:null,update:C,syntax:!0}))}}),W.metrics.inc("elementCount")}function q0(U){const{attrs:M}=W.__getAttributes__(U);if(!M)return;Object.entries(M.literals).forEach(([$,L])=>{if(X[$]&&X[$].type==="const")throw new Error(`<const ${$}=[value]/> variable already defined`);if(!L)return;X[$]={value:L,type:"const"}}),Object.entries(M.expressions).forEach(([$,L])=>{if(X[$]&&X[$].type==="const")throw new Error(`<const ${$}=[value]/> variable already defined`);if(!L)return;X[$]={value:W.__evaluate__(L,X),type:"const"}}),W.metrics.inc("elementCount")}function n(U,M,$){const{attrs:L}=W.__getAttributes__(U),F=D("element"),x=W.__getBoundaries__(F),C={};let P=G(),m=W0.default(x.start),f;const s=(k)=>{const _={},b={};return L.literals&&Object.entries(L.literals).forEach(([N,R])=>{b[N]=R,_[N]={type:"arg",value:R}}),L.expressions&&Object.entries(L.expressions).forEach(([N,R])=>{if(!f)return;if(j0.test(N))W.__evaluateSpreadAttr__(N,{memo:k,get keystore(){return C[N]},set keystore(I){if(!C[N])C[N]=[];C[N]=I},each:(I,A)=>{if(b[I]=A,!f?.argv.includes(I))return;_[I]={type:"arg",value:A}}});else{const I=R?W.__evaluate__(R,k):!0;if(b[N]=I,!f.argv.includes(N))return;_[N]={type:"arg",value:I}}}),L.expressions&&Object.entries(L.expressions).forEach(([N,R])=>{if(!f)return;if(j0.test(N)&&W.__isReactive__(N,k)){const I=W.__extractExpressionDeps__(N,k),A=(S,E)=>{if(!f)return;const h={};let u=[];if(W.__evaluateSpreadAttr__(N,{memo:S,get keystore(){return C[N]},set keystore(c){if(!C[N])C[N]=[];C[N]=c},each:(c,Q0)=>{if(L.map.afterSpreadAttrs.includes(c))return;if(!f?.argv.includes(c))return;if(Y0(Q0,S[c]?.value))return;_[c]=h[c]={value:Q0,type:"arg"},b[c]=Q0,u.push(c)},nullify:(c)=>{c.forEach((Q0)=>{h[Q0]={value:void 0,type:"arg"},delete b[Q0]}),u=c}}),u.length)f.argv.length&&W.__updateArgumentsDepNodes__(F,b),f.update(u,h,S,x)};I.forEach((S)=>W.__trackDep__(B,S,k,{nodetype:"dynamic",nodepath:F,deppath:`${F}.${N}`,target:"spread-attr",$fragment:null,boundaries:x,update:A}))}else if(f.argv.includes(N)&&W.__isReactive__(R,k)){const I=W.__extractExpressionDeps__(R,k),A=(S,E)=>{if(!f)return;if(L.map.beforeSpreadAttrs.includes(N))return;const h=R?W.__evaluate__(R,S):!0,u={type:"arg",value:h};if(_[N]=u,f.argv.length)b[N]=h,W.__updateArgumentsDepNodes__(F,b);f.update([N],{[N]:u},S,x)};I.forEach((S)=>W.__trackDep__(B,S,k,{nodetype:"dynamic",nodepath:F,deppath:`${F}.${N}`,target:"attr",$fragment:null,boundaries:x,update:A}))}}),{argvalues:_,__arguments__:b}};if(g($)){f=$;const{argvalues:k,__arguments__:_}=s(P);P.__arguments__=_;const b=f.mesh(k);if(b&&b.length)m=m.add(b)}else if(typeof $==="string")if(W.__macros.has($))m=m.add(i(U,$));else if(W.lips.has($))m=m.add(v(U,{name:$}));else m=m.add(o(U,$));if(W.__isReactive__(M,P)){const k=(b,N)=>{const R=W.__evaluate__(M,b);let I;if(f)f.cleanup(x),f=null;else W.__emptyBoundaries__(x,F);if(g(R)){f=R;const{argvalues:A,__arguments__:S}=s(b);f.argv.length&&W.__updateArgumentsDepNodes__(F,S),I=f.mesh(A,b),I?.length&&f.fill(I,x)}else if(d(R))I=v(U,{template:R},b),W.__fillBoundaries__(I,x);else if(typeof R==="string"&&W.__macros.has(R))I=i(U,R,b),W.__fillBoundaries__(I,x);else if(typeof R==="string"&&W.lips.has(R))I=v(U,{name:R},b),W.__fillBoundaries__(I,x);else if(typeof R==="string")I=o(U,R,b),W.__fillBoundaries__(I,x)};W.__extractExpressionDeps__(M,P).forEach((b)=>W.__trackDep__(B,b,P,{nodetype:"dynamic",nodepath:F,deppath:`${F}.dtag`,target:"dtag",$fragment:null,boundaries:x,update:k}))}return m=m.add(x.end),m}function v(U,M,$){let L,F;if(M?.template)L=M.template,F=O("component",L.declaration?.syntax);else{if(F=M?.name||U.attr(g0)||U.prop("tagName")?.toLowerCase(),!F)throw new Error("Invalid component");if(F===W.__name__)throw new Error("Render component within itself is forbidden");L=W.lips.import(F)}if(!L||!F)throw new Error(`<${F}> template not found`);const x=D("component",L.declaration?.syntax),C=`${x}#${F}`,P=W.__getBoundaries__(x),{argv:m,functions:f,attrs:s,events:k}=W.__getAttributes__(U),_={},b={};let N={},R=W0.default(P.start),I=W.PCC.get(C),A=$||G();s.literals&&Object.entries(s.literals).forEach(([E,h])=>{if(E=="key")return;N[E]=h}),f&&Object.entries(f).forEach(([E,h])=>{N[E]=W.__evaluateFunction__(h,[],A),L.declaration?.syntax?_[P0+V0+E]=h:_[V0+E]=h}),s.expressions&&Object.entries(s.expressions).forEach(([E,h])=>{if(E=="key")return;if(j0.test(E))W.__evaluateSpreadAttr__(E,{memo:A,get keystore(){return b[E]},set keystore(u){if(!b[E])b[E]=[];b[E]=u},each:(u,c)=>N[u]=c});else N[E]=h?W.__evaluate__(h,A):!0;L.declaration?.syntax?_[P0+E]=h:_[E]=h});const S=U.contents();if(S.length){if(N={...N,...W.__meshwire__({$node:U,fragmentPath:x,fragmentBoundaries:P,meshPath:null,scope:A,argv:m,xmlns:q,useAttributes:!0,declaration:L.declaration},_)},L.declaration){if(L.declaration.tags){let E;Object.entries(L.declaration?.tags).forEach(([h,{type:u,many:c,alts:Q0}])=>{switch(u){case"nexted":{let t=U.next(h);if(!t.length&&Array.isArray(Q0)&&E?.length&&E.is(Q0.join(",")))t=E.next(h);if(!t.length)return;if(c){N[h]=[];let e=0,w0=!1;while(!w0){if(N[h].push(W.__meshwire__({$node:t,meshPath:`${h}[${e}]`,fragmentPath:x,fragmentBoundaries:P,scope:A,argv:m,xmlns:q,useAttributes:!0,declaration:L.declaration},_)),!t.next(h).length){w0=!0;break}t=E=t.next(h),e++}}else N[h]=W.__meshwire__({$node:t,meshPath:h,fragmentPath:x,fragmentBoundaries:P,scope:A,argv:m,xmlns:q,useAttributes:!0,declaration:L.declaration},_)}break;case"child":{const t=U.children(h);if(c)N[h]=[],t.each(function(e){const w0=W0.default(this),{argv:I0}=W.__getAttributes__(w0);N[h].push(W.__meshwire__({$node:w0,meshPath:`${h}[${e}]`,fragmentPath:x,fragmentBoundaries:P,scope:A,argv:I0,xmlns:q,useAttributes:!0,declaration:L.declaration},_))});else if(U.children(h).first().length){const e=U.children(h).first(),{argv:w0}=W.__getAttributes__(e);N[h]=W.__meshwire__({$node:e,meshPath:h,fragmentPath:x,fragmentBoundaries:P,scope:A,argv:w0,xmlns:q,useAttributes:!0,declaration:L.declaration},_)}}break}})}else if(L.declaration.contents)N.__contents__=S}}if(I)I.setInput(X0(N)),R=R.add(I.node);else{const{declaration:E,state:h,_static:u,handler:c,context:Q0,default:t,stylesheet:e}=L;I=new y0(F,t||"",{state:X0(h),input:X0(N),context:Q0,_static:X0(u),handler:c,stylesheet:e,declaration:E},{debug:W.debug,lips:W.lips,prepath:x,boundaries:P}),R=R.add(I.node),!L.declaration?.syntax&&W.PCC.set(C,I)}return R=R.add(P.end),Object.entries(k).forEach(([E,h])=>{W.__attachEvent__({nodepath:x,element:I,_event:E,instruction:h,scope:A,get __dependencies__(){return B}})}),_&&Object.entries(_).forEach(([E,h])=>{let u=!1,c=!1;if(E.startsWith(P0))u=!0,E=E.replace(P0,"");if(E.startsWith(V0))c=!0,E=E.replace(V0,"");if(j0.test(E)){if(W.__isReactive__(E,A)){const Q0=(e)=>{const w0={};W.__evaluateSpreadAttr__(E,{memo:e,get keystore(){return b[E]},set keystore(I0){if(!b[E])b[E]=[];b[E]=I0},each:(I0,S0)=>{if(s.map.afterSpreadAttrs.includes(I0))return;w0[I0]=S0},nullify:(I0)=>I0.forEach((S0)=>w0[S0]=void 0)}),I?.subInput(w0,e)};W.__extractExpressionDeps__(E,A).forEach((e)=>W.__trackDep__(B,e,A,{nodetype:"component",nodepath:x,deppath:`${x}.${E}`,target:"spread-attr",$fragment:null,boundaries:P,update:Q0,syntax:u}))}}else if(W.__isReactive__(h,A)){const Q0=(e)=>{if(s.map.beforeSpreadAttrs.includes(E))return;const w0=c?W.__evaluateFunction__(h,[],e):h?W.__evaluate__(h,e):!0;I?.subInput({[E]:w0},e)};W.__extractExpressionDeps__(h,A).forEach((e)=>W.__trackDep__(B,e,A,{nodetype:"component",nodepath:x,deppath:`${x}.${E}`,target:"attr",$fragment:null,boundaries:P,update:Q0,syntax:u}))}}),W.metrics.inc("componentCount"),R}function i(U,M,$){if(M=M||U.attr(g0),!M)throw new Error("Invalid macro rendering call");const L=W.__macros.get(M);if(!L)throw new Error("Macro component not found");const F=D("macro"),x=W.__getBoundaries__(F),{attrs:C}=W.__getAttributes__(U),P={},m=$||G(),f={},s={};C.literals&&Object.entries(C.literals).forEach(([I,A])=>{f[I]=A,s[I]={value:A,type:"arg"}});const k={};C.expressions&&Object.entries(C.expressions).forEach(([I,A])=>{if(j0.test(I))W.__evaluateSpreadAttr__(I,{memo:m,get keystore(){return k[I]},set keystore(S){if(!k[I])k[I]=[];k[I]=S},each:(S,E)=>{if(f[S]=E,L.argv.includes(S))s[S]={value:E,type:"arg"}}}),P[I]=A;else{const S=A?W.__evaluate__(A,m):!0;if(f[I]=S,L.argv.includes(I))s[I]={value:S,type:"arg"},P[I]=A}L.argv.forEach((S)=>{if(s[S]!==void 0)return;s[S]={value:!1,type:"arg"}})}),s.__arguments__=f;let _=W0.default(x.start);const b={$node:L.$node,meshPath:null,fragmentPath:F,fragmentBoundaries:x,argv:L.argv,scope:m,xmlns:q,useAttributes:!0},N=W.__meshwire__(b,P),R=N.renderer.mesh(s,m);return _=_.add(R),P&&Object.entries(P).forEach(([I,A])=>{let S=!1;if(new RegExp(`^${P0}`).test(I))S=!0,I=I.replace(P0,"");if(j0.test(I)){if(!W.__isReactive__(I,m))return;const E=W.__extractExpressionDeps__(I,m),h=(u)=>{const c={};let Q0=[];if(W.__evaluateSpreadAttr__(I,{memo:u,get keystore(){return k[I]},set keystore(t){if(!k[I])k[I]=[];k[I]=t},each:(t,e)=>{if(C.map.afterSpreadAttrs.includes(t))return;if(Y0(e,u[t]?.value))return;c[t]={value:e,type:"arg"},f[t]=e,Q0.push(t)},nullify:(t)=>{t.forEach((e)=>{c[e]={value:void 0,type:"arg"},delete f[e]}),Q0=t}}),Q0.length)W.__updateArgumentsDepNodes__(F,f),N.renderer.update(Q0,c,u);return N1({memo:{...u,...c}})};E.forEach((u)=>W.__trackDep__(B,u,{...m,...s},{nodetype:"macro",nodepath:F,deppath:`${F}.${I}`,target:"spread-attr",$fragment:null,boundaries:x,update:h,syntax:S}))}else if(W.__isReactive__(A,m)){const E=W.__extractExpressionDeps__(A,m),h=(u)=>{if(C.map.beforeSpreadAttrs.includes(I))return;const c=A?W.__evaluate__(A,u):!0;return f[I]=c,W.__updateArgumentsDepNodes__(F,f),N.renderer.update([I],{[I]:{value:c,type:"arg"}},u),N1({memo:u})};E.forEach((u)=>W.__trackDep__(B,u,{...m,...s},{nodetype:"macro",nodepath:F,deppath:`${F}.${I}`,target:"attr",$fragment:null,boundaries:x,update:h,syntax:S}))}}),_=_.add(x.end),W.metrics.inc("elementCount"),_}function o(U,M,$){if(!U.length||!U.prop("tagName")&&!M)return U;M=M||U.prop("tagName").toLowerCase();const L=U.is("svg")||q,F=L?W0.default(document.createElementNS("http://www.w3.org/2000/svg",M)):W0.default(`<${M}/>`),x=U.contents(),C=D("element"),P=$||G();x.length&&F.append(W.__withPath__(C,()=>W.render(C+G5,x,P,B,L).$log));const{attrs:m,events:f}=W.__getAttributes__(U);m.literals&&Object.entries(m.literals).forEach(([k,_])=>{if(k===x0)return;const b=U.is(`[${x0}]`)&&["title","placeholder"].includes(k);F.attr(k,b?W.lips.i18n.translate(_).text:_);const N=(R)=>{F.attr(k,b?W.lips.i18n.translate(_).text:_),b&&W.__trackTranslationDep__(R,{nodetype:"element",nodepath:C,deppath:`${C}.${k}`,target:"attr",$fragment:F,update:N})};b&&W.__trackTranslationDep__(P,{nodetype:"element",nodepath:C,deppath:`${C}.${k}`,target:"attr",$fragment:F,update:N})});const s=(k,_=!1)=>{k&&Object.entries(k).forEach(([b,N])=>{switch(b){case"@html":{const R=(I)=>{F.html(W.__evaluate__(N,I))};if(R(P),_&&W.__isReactive__(N,P))W.__extractExpressionDeps__(N,P).forEach((A)=>W.__trackDep__(B,A,P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"meta-attr",$fragment:F,update:R}))}break;case"@text":{const R=U.is(`[${x0}]`),I=(A)=>{F.text(W.__evaluate__(N,A,{translate:R})),R&&W.__trackTranslationDep__(A,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"meta-attr",$fragment:F,update:I})};if(I(P),_&&W.__isReactive__(N,P))W.__extractExpressionDeps__(N,P).forEach((S)=>W.__trackDep__(B,S,P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"meta-attr",$fragment:F,update:I}));R&&W.__trackTranslationDep__(P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"meta-attr",$fragment:F,update:I})}break;case"@format":{const[R,I]=N.split(",").map((S)=>S.trim());if(!R)throw new Error("Invalid @format reference");if(!I)throw new Error("Invalid @format parameters");const A=(S)=>{const E=W.__evaluate__(`!${I.trim()}`,S);if(typeof E!=="object")throw new Error("Invalid @format parameters");const h=W.lips.i18n.format(R,E);h!==void 0&&F.text(h),W.__trackTranslationDep__(S,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"meta-attr",$fragment:F,update:A})};A(P),W.__extractExpressionDeps__(I,P).forEach((S)=>W.__trackDep__(B,S,P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"meta-attr",$fragment:F,update:A}))}break;case"style":if(_&&W.__isReactive__(N,P)){const R=(A)=>{const S=W.__evaluate__(N,A);if(typeof S==="object"){let E="";Object.entries(S).forEach(([h,u])=>E+=`${h}:${u};`),E.length&&F.attr("style",E)}else F.attr("style",S)};R(P),W.__extractExpressionDeps__(N,P).forEach((A)=>W.__trackDep__(B,A,P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"attr",$fragment:F,update:R}))}else F.attr("style",N);break;default:{const R=U.is(`[${x0}]`)&&["title","placeholder"].includes(b),I=(A)=>{const S=N&&W.__isReactive__(N,P)?W.__evaluate__(N,A,{translate:R}):N!==void 0?N:!0;if(S===void 0||S===!1)F.removeAttr(b);else F.attr(b,S),R&&W.__trackTranslationDep__(A,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"attr",$fragment:F,update:I})};if(I(P),_&&W.__isReactive__(N,P))W.__extractExpressionDeps__(N,P).forEach((S)=>W.__trackDep__(B,S,P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"attr",$fragment:F,update:I}));R&&W.__trackTranslationDep__(P,{nodetype:"element",nodepath:C,deppath:`${C}.${b}`,target:"attr",$fragment:F,update:I})}}})};return m.expressions&&Object.keys(m.expressions).forEach((k)=>{if(!j0.test(k))return;let _=[];const b=(N,R,I=!1)=>{const A={};W.__evaluateSpreadAttr__(k,{memo:N,get keystore(){return _},set keystore(S){_=S},each:(S,E)=>{if(!I&&m.map.afterSpreadAttrs.includes(S))return;A[S]=E},nullify:(S)=>S.forEach((E)=>F.removeAttr(E))}),Object.keys(A).length&&s(A)};if(delete m.expressions[k],b(P,"",!0),k&&W.__isReactive__(k,P))W.__extractExpressionDeps__(k,P).forEach((R)=>W.__trackDep__(B,R,P,{nodetype:"element",nodepath:C,deppath:`${C}.${k}`,target:"spread-attr",$fragment:F,update:b}))}),s(m.expressions,!0),f&&Object.entries(f).forEach(([k,_])=>{Y.push({nodepath:C,element:F,_event:k,instruction:_,scope:P,get __dependencies__(){return B}})}),W.metrics.inc("elementCount"),W.metrics.inc("domInsertsCount"),F}function r(U){const M=U.text(),$=G(),L=D("element"),F=U.parent().is(`[${x0}]`),x=W0.default(document.createTextNode(W.__interpolate__(M,$,F))),C=(P)=>{const m=W.__interpolate__(M,P,F);if(!x[0])return;x[0].textContent=m,F&&W.__trackTranslationDep__(P,{nodetype:"text",nodepath:L,target:"value",$fragment:x,update:C})};if(M&&W.__isReactive__(M,$))W.__extractTextDeps__(M,$).forEach((m)=>W.__trackDep__(B,m,$,{nodetype:"text",nodepath:L,deppath:`${L}.${m}`,target:"value",$fragment:x,update:C}));return F&&W.__trackTranslationDep__($,{nodetype:"text",nodepath:L,target:"value",$fragment:x,update:C}),W.metrics.inc("elementCount"),W.metrics.inc("domInsertsCount"),x}function Z0(U){if(!U.attr(k0)||U.prop("tagName")!=="LIPS")throw new Error("Invalid dynamic tag name");const M=U.attr(k0),$=W.__evaluate__(M,X);if(d($))return v(U,{template:$});else return n(U,M,$)}function p(U){if(U.get(0)?.nodeType===Node.COMMENT_NODE)return U;if(U.get(0)?.nodeType===Node.TEXT_NODE)return r(U);if(U.is("let"))return a(U);else if(U.is("const"))return q0(U);else if(U.is("lips")&&U.attr(k0))return Z0(U);else if(U.is("log"))return J0(U);else if(W.__macros.has(U.attr(g0)))return i(U);else if(U.is(Q1.join(","))||W.lips.has(U.attr(g0)))return v(U);else if(U.is("else-if, else"))return;return o(U)}try{this.__renderDepth__++,Z=!Z&&W0.default(this.__template__).length>1?W0.default("<template>").html(this.__template__).contents():Z||W0.default(this.__template__),Z.each(function(){const U=p(W0.default(this));if(U)K=K.add(U)}),Y.forEach(this.__attachEvent__.bind(this)),W.metrics.inc("renderCount")}catch(U){console.error("Rendering Failed --",U),W.metrics.trackError(U)}finally{if(this.__renderDepth__--,this.metrics.endRender(),this.metrics.trackMemory(),this.__renderDepth__===0)this.__inpath__="",this.__inpathCounter__=0}return{$log:K,dependencies:B,events:Y}}destroy(){this.ICE.dispose(),this.stylesheet?.clear(),this.metrics.dispose(),this.lips.IUC.unregister(this.__path__),this.lips.watcher.unwatch(this),this.VER.forEach(this.__detachEvent__.bind(this)),this.VER=[];for(let J in this.PCC){const Z=this.PCC.get(J);Z?.destroy(),Z?.delete(J)}if(this.$?.remove(),this.PCC?.clear(),this.FGUD?.clear(),this.FGUDMemory?.clear(),this.__macros.clear(),this.__i18nDeps.clear(),this.__previous=null,this.state=null,this.input=null,this.context=null,this.$)this.$.each((J,Z)=>{W0.default(Z).off()}),this.$=null;typeof this.onDestroy==="function"&&this.onDestroy.bind(this)(),this.emit("component:destroy")}__meshwire__(J,Z){const X=this,{$node:H,meshPath:q,fragmentPath:W,fragmentBoundaries:B,argv:Y,xmlns:K,declaration:G,useAttributes:D}=J;let O;const g=new Map,d=W+y1,J0=(v,i,o)=>{if(O=H.contents(),!O?.length)return null;i=i||J.scope;const r=d+(o||""),{$log:Z0,dependencies:p,events:U}=X.__withPath__(r,()=>{return X.render(r,O,{...i,...v},void 0,K)}),M=o||l0;return!g.has(M)&&g.set(M,new Set),g.get(M)?.add(r),p?.forEach(($,L)=>{!X.FGUD?.has(L)&&X.FGUD.set(L,new Map),$.forEach((F,x)=>{if(F.garbage)return;F.partial?.length?F.partial.push(r):F.partial=[r],X.FGUD.get(L)?.set(x,F)})}),X.metrics.inc("partialCount"),Z0},a=(v,i,o,r,Z0)=>{if(!g.get(Z0||l0)?.size)return;o=o||J.scope,r=r||B,X.metrics.startRender();const p=Array.from(g.get(Z0||l0)||[]);v.forEach((U)=>{const M=X.FGUD.get(U);if(!M)return;M.forEach(($)=>{const L=p.find((C)=>{return $.partial?.find((P)=>C==P||X.__hasSamePathParent__(P,C))});if(!$.partial||!L)return;const F=$.deppath||$.nodepath,x=this.FGUDMemory.get($.nodepath);if($.garbage||r?.start&&!document.contains(r.start)){M.delete(F),X.__unbindMemo__($);return}if(!x){console.warn(`unexpected occurence: <${F}> has no memo`);return}if(x.memo?.[U]&&i?.[U]&&!Y0(x.memo[U],i[U]))x.memo={...o,...x.memo,...i};X.UQS.queue({dep:U,deppath:F,priority:$.priority}),X.metrics.inc("dependencyUpdateCount")}),!M.size&&X.FGUD.delete(U)}),X.metrics.inc("partialUpdateCount"),X.metrics.endRender()},q0=(v,i)=>{if(g.delete(typeof i==="string"&&i||l0),v=v||B,X.__emptyBoundaries__(v,d+(i||"")),i)v.start.remove(),v.end.remove()},n={renderer:{path:q,argv:Y,mesh:J0,update:a,cleanup:q0,fill(v,i){X.__fillBoundaries__(v,i||B)},demarcate(v,i){const o=X.__getBoundaries__(d+(i||""));let r=W0.default(o.start);return r=r.add(v),r=r.add(o.end),{$partial:r,boundaries:o}}}};if(D&&q){const{attrs:v}=X.__getAttributes__(H);v.literals&&Object.entries(v.literals).forEach(([i,o])=>n[i]=o),v.expressions&&Object.entries(v.expressions).forEach(([i,o])=>{if(j0.test(i)){let r=[];X.__evaluateSpreadAttr__(i,{memo:J.scope,get keystore(){return r},set keystore(Z0){r=Z0},each:(Z0,p)=>n[Z0]=p}),Z[`${G?.syntax?P0:""}${q}.${i}`]=o}else n[i]=o?X.__evaluate__(o,J.scope):!0,Z[`${G?.syntax?P0:""}${q}.${i}`]=o})}return n}__getBoundaries__(J){return this.metrics.inc("domOperations"),this.metrics.inc("domInsertsCount"),{start:document.createComment(`s:${J}`),end:document.createComment(`e:${J}`)}}__emptyBoundaries__(J,Z){this.FGUD.forEach((q,W)=>{q.forEach((B,Y)=>{if(!this.__hasSamePathParent__(Y,Z))return;this.__unbindMemo__(B),B.garbage=!0}),!q.size&&this.FGUD.delete(W)});const X=[];let H=J.start.nextSibling;while(H&&H!==J.end)X.push(H),H=H.nextSibling;W0.default(X).remove()}__fillBoundaries__(J,Z){if(!document.contains(Z.start)||!document.contains(Z.end)){console.warn("Dynamic element boundaries not found");return}J.length&&W0.default(Z.start).after(J)}__getAttributes__(J){const Z=J.attrs(),X={},H={},q={literals:{},expressions:{},map:{explicitAttrs:[],spreadAttrs:[],beforeSpreadAttrs:[],afterSpreadAttrs:[],metaAttrs:[]}},W=Object.keys(Z).find((K)=>j0.test(K));let B=[],Y=!1;return Z&&Object.entries(Z).forEach(([K,G])=>{if([g0,k0].includes(K))return;if(K.startsWith(":")||K.startsWith(V0)||K.startsWith(f0)||j0.test(K)||Z1.test(K))if(Z1.test(K)){const[D,O]=K.match(Z1)||[];B=O.split(",")}else if(K.startsWith(f0))X[K.replace(f0,"")]=G;else if(K.startsWith(V0))H[K.replace(V0,"")]=G;else{if(K.startsWith(":"))K=K.slice(1,K.length);if(W)if(j0.test(K))q.map.spreadAttrs.push(K),Y=!0;else q.map.explicitAttrs.push(K),!Y?q.map.beforeSpreadAttrs.push(K):q.map.afterSpreadAttrs.push(K);q.expressions[K]=G||""}else if(q.literals[K]=G,W)q.map.explicitAttrs.push(K),!Y?q.map.beforeSpreadAttrs.push(K):q.map.afterSpreadAttrs.push(K)}),{argv:B,events:X,functions:H,attrs:q}}__withPath__(J,Z){const X=this.__inpath__;this.__inpath__=J;const H=Z();return this.__inpath__=X,H}__getPathParent__(J){const Z=J.split("/");if(Z.length>1)Z.pop();return Z.join("/")}__hasSamePathParent__(J,Z){return J.startsWith(Z)&&!J.replace(Z,"").startsWith(".")||J.startsWith(`${Z+y1}`)}__evaluate__(J,Z,X){J=typeof J==="string"?J.trim():J;try{const H=(q)=>{const W=this.state.toJSON(),B=(K,...G)=>{try{return K(...G)}catch(D){!X?.mute&&console.error("Eval error --",D);return}};let Y=`return ${q};`;if(Z){let K={},G;for(let O in Z){if(O==="__arguments__")continue;K[O]=Z[O].value}if(typeof Z.__arguments__==="object")G=Z.__arguments__;Y=`with( scope ){ ${Y} }`;const D=new Function("self","input","state","static","context","scope","arguments",Y);return B(D,this,this.input,W,this.static,this.context,K||{},G)}else{const K=new Function("self","input","state","static","context",Y);return B(K,this,this.input,W,this.static,this.context)}};if(/{\s*([^{}]+)\s*}/.test(J)){if(J.startsWith("!{")&&J.endsWith("}"))return H(J.slice(1));return J.replace(_1,(q,W)=>H(W))}return H(J)}catch(H){!X?.mute&&console.error("Expression evaluation error --",H);return}}__evaluateFunction__(J,Z,X){if(/(\s*\w+|\s*\([^)]*\)|\s*)\s*=>\s*(\s*\{[^}]*\}|\s*[^\n;"]+)/g.test(J))return this.__evaluate__(J,X)(...Z);else{let[H,...q]=J.split(/\s*,\s*/),W;const B=this.__evaluate__(H,X,{mute:!0});if(typeof B==="function")W=B;else{if(typeof this[H]!=="function")throw new Error(`Undefined <${H}> handler method`);W=this[H].bind(this)}if(typeof W!=="function")throw new Error(`Expected <${H}> to be a function or handler method`);let Y=q.map((K)=>this.__evaluate__(K,X));if(Z.length)Y=[...Y,...Z];return W(...Y)}}__evaluateSpreadAttr__(J,Z){const X=this.__evaluate__(J.replace(j0,""),Z.memo);if(!X){if(!Z.keystore.length)throw new Error(`Undefined spread operator ${J}`);typeof Z.nullify==="function"&&Z.nullify(Z.keystore);return}if(typeof X!=="object"||Array.isArray(X))throw new Error(`Invalid spread operator ${J}`);if(Z.keystore=Object.keys(X)||[],typeof Z.each==="function")for(let H in X)Z.each(H,X[H])}__interpolate__(J,Z,X){if(J=J.replace(_1,(H,q)=>this.__evaluate__(q,Z)),X)J=this.lips.i18n.translate(J).text;return J}__attachEvent__(J){const{element:Z,nodepath:X,_event:H,instruction:q,scope:W,__dependencies__:B}=J;let Y=W;if(Z.on(H,(...K)=>this.__evaluateFunction__(q,K,Y)),this.VER.push(J),this.metrics.inc("domUpdatesCount"),this.metrics.inc("domRemovalsCount"),this.__isReactive__(q,W))this.__extractExpressionDeps__(q,W).forEach((G)=>this.__trackDep__(B,G,W||{},{nodetype:"event",nodepath:X,deppath:`${X}.${H}`,target:"event-handler",$fragment:!(Z instanceof y0)?Z:null,boundaries:Z instanceof y0?Z.__boundaries__:void 0,update:(D)=>{Y=D}}))}__detachEvent__({element:J,nodepath:Z,_event:X,instruction:H,scope:q,__dependencies__:W}){if(J.off(X),this.__isReactive__(H,q)){const B=this.__extractExpressionDeps__(H,q),Y=`${Z}.${X}`;B.forEach((K)=>{W.get(K)?.delete(Y),this.FGUD.get(K)?.delete(Y)})}this.metrics.inc("domOperations"),this.metrics.inc("domRemovalsCount")}__extractTextDeps__(J,Z){const X=new Set;return(J.match(/{\s*([^{}]+)\s*}/g)||[]).forEach((q)=>{const W=q.replace(/[{}]/g,"").trim();this.__extractExpressionDeps__(W,Z).forEach((Y)=>X.add(Y))}),Array.from(X)}__extractExpressionDeps__(J,Z){const X=/\b(state|input|context|arguments)(?:\.[a-zA-Z_]\w*)+(?=\[|\.|$|\s|;|,|\))/g,H=/\b(self)(?:\.[a-zA-Z_]\w*)+(?=\()/g,q=/\b(arguments)((?:\.[a-zA-Z_]\w*)+)?(?=\[|\.|$|\s|;|,|\))/g;let W=[...Array.from(J.matchAll(X)),...Array.from(J.matchAll(H)),...Array.from(J.matchAll(q))];if(Z&&Object.keys(Z).length){const B=new RegExp(`\\b(?<!\\.)(${Object.keys(Z).join("|")})`,"g"),Y=new RegExp(`(?:(?<=\\.\\.\\.))(${Object.keys(Z).join("|")})\\b`,"g");W=[...W,...Array.from(J.matchAll(B)),...Array.from(J.matchAll(Y))]}return[...new Set(W.map((B)=>B[0]))]}__isReactive__(J,Z){if(/(self|state|input|context|arguments)(\.[\w.]+)?/.test(J))return!0;if(Z&&Object.keys(Z).length&&new RegExp(Object.keys(Z).join("|")).test(J))return!0;return!1}__bindMemo__(J,Z){const X=Z.deppath||Z.nodepath,H=this.FGUDMemory.get(Z.nodepath);if(H)H.tracks.set(X,Z.priority||2),H.memo=J,this.FGUDMemory.set(Z.nodepath,H);else{const q=new Map;q.set(X,Z.priority),this.FGUDMemory.set(Z.nodepath,{tracks:q,memo:J})}}__unbindMemo__(J){const Z=J.deppath||J.nodepath,X=this.FGUDMemory.get(J.nodepath);if(!X||!X.tracks.get(Z))return;X.tracks.delete(Z),!X.tracks.size&&this.FGUDMemory.delete(J.nodepath)}__trackDep__(J,Z,X,H){if(X&&X[Z]&&X[Z].type==="let")H.haslet=!0;if(H.priority===void 0)if(H.target==="attr"&&Z.split(".").find((W)=>w5.includes(W)))H.priority=0;else if(H.syntax)H.priority=1;else if(["event"].includes(H.nodetype))H.priority=3;else H.priority=2;const q=H.deppath||H.nodepath;H.level=q.split(/\//g).length,H.priority=H.level*O5+H.priority,!J.has(Z)&&J.set(Z,new Map),J.get(Z)?.set(q,H),this.__bindMemo__(X,H),this.metrics.inc("dependencyTrackCount")}__trackTranslationDep__(J,Z){this.__i18nDeps.set(Z.deppath||Z.nodepath,Z),this.__bindMemo__(J,Z),this.metrics.inc("i18nTrackCount")}__valueDep__(J,Z){return Z.reduce((X,H)=>X?.[H],J)}__shouldUpdate__(J,Z){if(J==="self")return!0;const X={state:this.state,input:this.input,context:this.context},H=this.__valueDep__(this.__previous[J],Z),q=this.__valueDep__(X[J],Z);return!Y0(H,q)}__updateDepNodes__(){if(!this.FGUD?.size)return;this.metrics.inc("componentUpdateCount"),this.metrics.startRender(),this.FGUD.forEach((J,Z)=>{const[X,...H]=Z.split(".");if(!this.__shouldUpdate__(X,H))return;J.forEach((q)=>{try{const W=q.deppath||q.nodepath;if(q.garbage||q.boundaries?.start&&!document.contains(q.boundaries.start)||q.$fragment!==null&&!q.$fragment.closest("body").length){J.delete(W),this.__unbindMemo__(q);return}this.UQS.queue({dep:Z,deppath:W,priority:q.priority}),this.metrics.inc("dependencyUpdateCount")}catch(W){console.error("failed to update dependency nodes --",W);return}}),!J.size&&this.FGUD?.delete(Z)}),this.metrics.endRender()}__updateVarDepNodes__(J,Z,X){if(!this.FGUD?.size)return;this.metrics.inc("partialUpdateCount"),this.metrics.startRender(),this.FGUD.get(J)?.forEach((H,q)=>{if(!H.haslet||!this.__hasSamePathParent__(q,this.__getPathParent__(Z)))return;const W=H.deppath||H.nodepath,B=this.FGUDMemory.get(H.nodepath);if(!B){console.warn(`unexpected occurence: <${W}> has no memo`);return}B.memo={...B.memo,...X},this.UQS.queue({dep:J,deppath:W,priority:H.priority}),this.metrics.inc("dependencyUpdateCount")}),this.metrics.endRender()}__updateArgumentsDepNodes__(J,Z){if(!this.FGUD?.size)return;this.metrics.inc("partialUpdateCount"),this.metrics.startRender();const X="arguments";this.FGUD.get(X)?.forEach((H,q)=>{if(!this.__hasSamePathParent__(q,J))return;const W=H.deppath||H.nodepath,B=this.FGUDMemory.get(H.nodepath);if(!B){console.warn(`unexpected occurence: <${W}> has no memo`);return}B.memo.__arguments__=Z,this.UQS.queue({dep:X,deppath:W,priority:H.priority}),this.metrics.inc("dependencyUpdateCount")}),this.metrics.endRender()}__updateI18nDepNodes__(){if(!this.__i18nDeps?.size)return;this.metrics.inc("i18nUpdateCount"),this.metrics.startRender(),this.__i18nDeps?.forEach((J,Z)=>{if(!J.$fragment.closest("body").length){this.__i18nDeps.delete(Z);return}const X=this.FGUDMemory.get(J.nodepath);if(!X){console.warn(`unexpected occurence: <${J.deppath||J.nodepath}> has no memo`);return}J.update(X.memo,"i18n-partial-updator"),this.metrics.inc("dependencyUpdateCount")}),this.metrics.endRender()}appendTo(J){return(typeof J=="string"?W0.default(J):J).append(this.node),this.metrics.inc("domOperations"),this}prependTo(J){return typeof J=="string"?W0.default(J):J.prepend(this.node),this.metrics.inc("domOperations"),this}replaceWith(J){return(typeof J=="string"?W0.default(J):J).replaceWith(this.node),this.metrics.inc("domOperations"),this}}var i1={};s0(i1,{handler:()=>{{return T8}},declaration:()=>{{return P8}},_static:()=>{{return E8}}});var P8={name:"if",syntax:!0,tags:{"else-if":{type:"nexted",many:!0,optional:!0},else:{type:"nexted",alts:["else-if"],optional:!0}}},E8={initialized:!1,prevRenderer:null},T8={onInput(J){this.static.initialized&&this.processor(this.input,J)},onSelfRender(){const J=this.processor(this.input,void 0,!0);return this.static.initialized=!0,J},processor(J,Z,X=!1){if(!J.renderer)return;if(J.by){this.static.prevRenderer?.cleanup();const H=J.renderer.mesh({},Z);if(this.static.prevRenderer=J.renderer,!H?.length)return;if(X)return H;J.renderer.fill(H)}else{this.static.prevRenderer?.cleanup();let H=!1,q;if(Array.isArray(J["else-if"])&&J["else-if"].length)for(let W of J["else-if"]){if(!W.by)continue;if(q=W.renderer.mesh({},Z),this.static.prevRenderer=W.renderer,!q?.length)return;if(X)return q;q?.length&&W.renderer.fill(q),H=!0;break}if(!H&&J.else){const W=J.else.renderer.mesh({},Z);if(this.static.prevRenderer=J.else.renderer,!W?.length)return;if(X)return W;J.else.renderer.fill(W)}}}};var c1={};s0(c1,{handler:()=>{{return A8}},declaration:()=>{{return $8}},_static:()=>{{return S8}}});var C0=J1(o0(),1);var $8={name:"for",syntax:!0},S8={lastIn:null,argvlist:null,initialized:!1,prevRenderer:null,processingBatch:!1},A8={onInput(J){this.static.initialized&&this.processor(this.input,J)},onSelfRender(){const J=this.processor(this.input,void 0,!0);return this.static.initialized=!0,J},processor(J,Z,X=!1){if(this.static.processingBatch)return;if(!J.renderer)throw new Error("Undefined mesh renderer");let{in:H,from:q,to:W}=J;if(H===void 0&&q===void 0)throw new Error("Invalid <for> arguments");this.static.processingBatch=!0;try{if(q!==void 0)return this.asFromTo(J.renderer,q,W,Z,X);else if(Array.isArray(H))return this.asArray(J.renderer,H,Z,X);else if(H instanceof Map)return this.asMap(J.renderer,H,Z,X);else if(typeof H=="object")return this.asObject(J.renderer,H,Z,X)}finally{this.static.processingBatch=!1}},addItem(J,Z,X,H){if(!this.static.argvlist)this.static.argvlist=[];const q=`[${H}]`,W=J.mesh(X,Z,q);if(!W)return;const{boundaries:B,$partial:Y}=J.demarcate(W,q);return this.static.prevRenderer=J,this.static.argvlist.push({argvalues:X,boundaries:B}),Y},updateItem(J,Z,X,H){if(!this.static.argvlist?.[H])return;this.static.argvlist[H].argvalues=X,J.update(Object.keys(X),X,Z,this.static.argvlist[H].boundaries,`[${H}]`)},removeItem(J,Z){if(!this.static.argvlist?.[Z])return;J.cleanup(this.static.argvlist[Z].boundaries,`[${Z}]`),this.static.argvlist.splice(Z,1)},asFromTo(J,Z,X,H,q){if(Z=parseFloat(String(Z)),X==null)throw new Error("Expected <from> <to> attributes of the for loop to be defined");X=parseFloat(String(X));const W=Z<X,B=Math.abs(X-Z)+1;if(Array.isArray(this.static.argvlist)){const[K]=J.argv;if(K){let G=Z;if(this.static.argvlist.length===B){for(let O=0;O<this.static.argvlist.length;O++)this.static.argvlist[O].argvalues[K].value!==G&&this.updateItem(J,H,{[K]:{value:G,type:"arg"}},O),G=W?G+1:G-1;return}const D=Math.min(this.static.argvlist.length,B);for(let O=0;O<D;O++)this.updateItem(J,H,{[K]:{value:O,type:"arg"}},O);if(B>this.static.argvlist.length)for(let O=this.static.argvlist.length;O<B;O++){const g={[K]:{value:O,type:"arg"}};this.boundaries&&C0.default(this.boundaries.end).before(this.addItem(J,H,g,O))}else if(B<this.static.argvlist.length)for(let O=this.static.argvlist.length-1;O>=B;O--)this.removeItem(J,O)}return}this.static.prevRenderer?.cleanup(),this.static.argvlist=[];let Y=C0.default();for(let K=Z;W?K<=X:K>=X;W?K++:K--){const G={},[D]=J.argv;if(D)G[D]={value:K,type:"arg"};Y=Y.add(this.addItem(J,H,G,K))}if(!Y?.length)return;if(q)return Y;J.fill(Y)},asArray(J,Z,X,H){if(this.static.argvlist&&this.static.lastIn&&Z===this.static.lastIn)return;if(!Z.length){if(!this.static.lastIn)console.warn("For loop with empty initial rendering <in> attribute array value will not update")}if(this.static.lastIn=Z,Array.isArray(this.static.argvlist)){const[B,Y]=J.argv;if(B){if(this.static.argvlist.length===Z.length){for(let G=0;G<this.static.argvlist.length;G++)!Y0(this.static.argvlist[G].argvalues[B].value,Z[G])&&this.updateItem(J,X,{[B]:{value:Z[G],type:"arg"},[Y]:{value:G,type:"arg"}},G);return}const K=Math.min(this.static.argvlist.length,Z.length);for(let G=0;G<K;G++)this.updateItem(J,X,{[B]:{value:Z[G],type:"arg"},[Y]:{value:G,type:"arg"}},G);if(Z.length>this.static.argvlist.length)for(let G=this.static.argvlist.length;G<Z.length;G++){const D={[B]:{value:Z[G],type:"arg"},[Y]:{value:G,type:"arg"}};this.boundaries&&C0.default(this.boundaries.end).before(this.addItem(J,X,D,G))}else if(Z.length<this.static.argvlist.length)for(let G=this.static.argvlist.length-1;G>=Z.length;G--)this.removeItem(J,G)}return}this.static.prevRenderer?.cleanup(),this.static.argvlist=[];let q=C0.default(),W=0;for(let B of Z){const Y={},[K,G]=J.argv;if(K)Y[K]={value:B,type:"arg"};if(G)Y[G]={value:W,type:"arg"};q=q.add(this.addItem(J,X,Y,W)),W++}if(!q?.length)return;if(H)return q;J.fill(q)},asMap(J,Z,X,H){if(this.static.argvlist&&this.static.lastIn&&Z===this.static.lastIn)return;if(!Z.size){if(!this.static.lastIn)console.warn("For loop with empty initial rendering <in> attribute map value will not update")}if(this.static.lastIn=Z,Array.isArray(this.static.argvlist)){const[B,Y,K]=J.argv,G=Array.from(Z.entries());if(B){if(this.static.argvlist.length===G.length){for(let O=0;O<this.static.argvlist.length;O++)!Y0(this.static.argvlist[O].argvalues[B].value,G[O][0])||!Y0(this.static.argvlist[O].argvalues[Y].value,G[O][1])&&this.updateItem(J,X,{[B]:{value:G[O][0],type:"arg"},[Y]:{value:G[O][1],type:"arg"},[K]:{value:O,type:"arg"}},O);return}const D=Math.min(this.static.argvlist.length,G.length);for(let O=0;O<D;O++)this.updateItem(J,X,{[B]:{value:G[O][0],type:"arg"},[Y]:{value:G[O][1],type:"arg"},[K]:{value:O,type:"arg"}},O);if(G.length>this.static.argvlist.length)for(let O=this.static.argvlist.length;O<G.length;O++){const g={[B]:{value:G[O][0],type:"arg"},[Y]:{value:G[O][1],type:"arg"},[K]:{value:O,type:"arg"}};this.boundaries&&C0.default(this.boundaries.end).before(this.addItem(J,X,g,O))}else if(G.length<this.static.argvlist.length)for(let O=this.static.argvlist.length-1;O>=G.length;O--)this.removeItem(J,O)}return}this.static.prevRenderer?.cleanup(),this.static.argvlist=[];let q=C0.default(),W=0;for(let[B,Y]of Z){const K={},[G,D,O]=J.argv;if(G)K[G]={value:B,type:"arg"};if(D)K[D]={value:Y,type:"arg"};if(O)K[O]={value:W,type:"arg"};q=q.add(this.addItem(J,X,K,W)),W++}if(!q?.length)return;if(H)return q;J.fill(q)},asObject(J,Z,X,H){if(this.static.argvlist&&this.static.lastIn&&Z===this.static.lastIn)return;if(!Object.keys(Z).length){if(!this.static.lastIn)console.warn("For loop with empty initial rendering <in> attribute object value will not update")}if(this.static.lastIn=Z,Array.isArray(this.static.argvlist)){const[B,Y,K]=J.argv,G=Object.entries(Z);if(B){if(this.static.argvlist.length===G.length){for(let O=0;O<this.static.argvlist.length;O++)!Y0(this.static.argvlist[O].argvalues[B].value,G[O][0])||!Y0(this.static.argvlist[O].argvalues[Y].value,G[O][1])&&this.updateItem(J,X,{[B]:{value:G[O][0],type:"arg"},[Y]:{value:G[O][1],type:"arg"},[K]:{value:O,type:"arg"}},O);return}const D=Math.min(this.static.argvlist.length,G.length);for(let O=0;O<D;O++)this.updateItem(J,X,{[B]:{value:G[O][0],type:"arg"},[Y]:{value:G[O][1],type:"arg"},[K]:{value:O,type:"arg"}},O);if(G.length>this.static.argvlist.length){let O=C0.default();for(let g=this.static.argvlist.length;g<G.length;g++){const d={[B]:{value:G[g][0],type:"arg"},[Y]:{value:G[g][1],type:"arg"},[K]:{value:g,type:"arg"}},J0=this.addItem(J,X,d,g);O=O.add(J0)}this.boundaries&&C0.default(this.boundaries.end).before(O)}else if(G.length<this.static.argvlist.length)for(let O=this.static.argvlist.length-1;O>=G.length;O--)this.removeItem(J,O)}return}this.static.prevRenderer?.cleanup(),this.static.argvlist=[];let q=C0.default(),W=0;for(let B in Z){const Y={},[K,G,D]=J.argv;if(K)Y[K]={value:B,type:"arg"};if(G)Y[G]={value:Z[B],type:"arg"};if(D)Y[D]={value:W,type:"arg"};q=q.add(this.addItem(J,X,Y,W)),W++}if(!q?.length)return;if(H)return q;J.fill(q)},onDestroy(){this.static.prevRenderer?.cleanup(void 0,!0),this.static.prevRenderer=null,this.static.argvlist=null,this.static.lastIn=null}};var p1={};s0(p1,{handler:()=>{{return g8}},declaration:()=>{{return b8}},_static:()=>{{return x8}}});var b8={name:"async",syntax:!0,tags:{then:{type:"child"},catch:{type:"child",optional:!0},loading:{type:"child",optional:!0}}},x8={initialized:!1,finalized:!1,prevRenderer:null},g8={onInput(J){this.static.initialized&&this.processor(this.input,J)},onSelfRender(){const J=this.processor(this.input,void 0,!0);return this.static.initialized=!0,J},processor(J,Z,X=!1){if(!J.await)throw new Error("Undefined async <await> attribute");if(!(J.await instanceof Promise))throw new Error("Expected async <await> attribute value to be a function");if(this.static.finalized=!1,J.loading){this.static.prevRenderer?.cleanup();const H=J.loading.renderer.mesh({},Z);if(this.static.prevRenderer=J.loading.renderer,this.execute(J,Z,!0),this.static.finalized)return;if(!H?.length)return;if(X)return H;J.loading.renderer.fill(H)}else this.execute(J,Z)},execute(J,Z,X=!1){J.await.then((H)=>{if(this.static.prevRenderer?.cleanup(),!J.then)return;const[q]=J.then.renderer.argv,W={[q]:{value:H,type:"arg"}},B=J.then.renderer.mesh(W,Z);if(this.static.prevRenderer=J.then.renderer,!B?.length)return;if(!X)return B;J.then.renderer.fill(B)}).catch((H)=>{if(this.static.prevRenderer?.cleanup(),!J.catch)return;const[q]=J.catch.renderer.argv,W={[q]:{value:H,type:"arg"}},B=J.catch.renderer.mesh(W,Z);if(this.static.prevRenderer=J.catch.renderer,!B?.length)return;if(!X)return B;J.catch.renderer.fill(B)}).finally(()=>this.static.finalized=!0)}};var s1={};s0(s1,{handler:()=>{{return f8}},declaration:()=>{{return k8}},_static:()=>{{return h8}}});var k8={name:"switch",syntax:!0,tags:{case:{type:"child",many:!0},default:{type:"child"}}},h8={initialized:!1,prevRenderer:null},f8={onInput(J){this.static.initialized&&this.processor(this.input,J)},onSelfRender(){const J=this.processor(this.input,void 0,!0);return this.static.initialized=!0,J},processor(J,Z,X=!1){let H=[];this.static.prevRenderer?.cleanup();for(let q of J.case)if(q.is==J.by||Array.isArray(q.is)&&q.is.includes(J.by)){Array.isArray(q.is)?H=[...new Set([...H,...q.is])]:H.push(q.is);const W=q.renderer.mesh({},Z);if(this.static.prevRenderer=q.renderer,!W?.length)return;if(X)return W;q.renderer.fill(W)}if(H.includes(J.by))return;if(J.default){const q=J.default.renderer.mesh({},Z);if(this.static.prevRenderer=J.default.renderer,!q?.length)return;if(X)return q;J.default.renderer.fill(q)}else this.static.prevRenderer=null}};var l1={};s0(l1,{state:()=>{{return _8}},handler:()=>{{return m8}},default:()=>{{return d8}},context:()=>{{return v8}},_static:()=>{{return y8}}});var u8=function(J){const Z={};return J.split("&").map((H)=>{const[q,W]=H.split("=");Z[q]=W}),Z},_8={page:null,params:{},query:{}},y8={global:!1,routes:[],defaultPath:null,currentPath:null,currentRoute:null},v8=["navigate"],m8={onInput(){this.processor(this.input)},processor(J){if(!J.routes)return;if(J.global)this.static.global=J.global;if(this.static.routes=J.routes.map(({path:Z,template:X,default:H})=>{if(H)this.static.defaultPath=Z;const q=Z.match(/:[^\/]*(\/|$)/gi)||[],W=Z.replaceAll("/","\\/").replaceAll(/:[^\/]*(\/|$)/gi,"([^\\/]+)(?:\\/|$)");return{path:Z,template:X,default:H,pathVars:q,pathRegex:new RegExp(`${W}\$`,"i")}}),J.global){const Z=window.location.pathname;this.static.defaultPath=this.static.defaultPath&&Z=="/"&&Z!==this.static.defaultPath?this.static.defaultPath:Z?Z+window.location.search:this.static.routes[0].path}},onAttach(){if(this.input.global)window.navigate=this.navigate.bind(this),window.addEventListener("popstate",(J)=>J.state&&this.navigate(J.state.path,!0));this.setContext("navigate",this.navigate.bind(this)),this.static.defaultPath&&this.navigate(this.static.defaultPath)},navigate(J,Z){!Z&&this.static.global&&history.pushState({path:J},"",J);const X=J.split("?");J=X[0];const H=X[1]?u8(X[1]):{};let q=null;if(this.static.currentRoute)q={path:this.static.currentRoute.path,params:this.state.params},this.emit("before",{fromState:q,toState:{path:J,query:H}});const W=this.match(J);if(!W){this.static.currentRoute=null,this.state.params={},this.state.query={},this.emit("not-found",J);return}const{route:B,params:Y}=W;this.emit("after",{fromState:q,toState:{path:B.path,params:Y,query:H}}),this.static.currentPath=J,this.static.currentRoute=B,this.state.params=Y,this.state.query=H,this.state.page=B.template},match(J){const Z={};let X=!1;for(let H of this.static.routes){const{pathVars:q,pathRegex:W}=H,B=J.match(W);if(B!==null&&B.index===0){for(let Y=0;Y+1<B.length&&Y<q.length;Y++)Z[q[Y].replaceAll(/[\/:]/g,"")]=B[Y+1];X=H;break}}return X?{route:X,params:Z}:!1}},d8="<{state.page} params=state.params query=state.query/>";class i5{debug=!1;stylesheets=[];config={};store=new Map;__root;preprocessor;i18n=new B1;watcher;IUC;__setLang;__getLang;__setContext;__getContext;constructor(J){if(this.config=J,this.config?.debug)this.debug=this.config.debug;this.preprocessor=new W1(this.store),this.watcher=new q1,this.IUC=new H1;const[Z,X]=_0(this.i18n.lang),[H,q]=_0(J?.context||{});this.__setLang=X,this.__getLang=Z,this.__setContext=q,this.__getContext=H,this.register("if",i1),this.register("for",c1),this.register("async",p1),this.register("switch",s1),this.register("router",l1)}register(J,Z){return this.store.set(J,Z),this}unregister(J){return this.store.delete(J),this}has(J){return this.store.has(J)}import(J){if(!this.has(J))throw new Error(`<${J}> component not found`);const Z=this.store.get(J);if(!Z?.declaration?.syntax&&!Z?.default)throw new Error(`Invalid <${J}> component`);return Z}render(J,Z,X){const{default:H,...q}=Z,W={debug:this.debug,prepath:"0",lips:this},B=new y0(J,H||"",{...q,input:X},W);return window.addEventListener("beforeunload",()=>{return this.dispose(),B.destroy(),null}),window.addEventListener("pagehide",(Y)=>{!Y.persisted&&this.dispose()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState!=="hidden")return;this.IUC.prepareForPotentialUnload()}),B}root(J,Z){if(this.__root=this.render("__ROOT__",J),this.__root.appendTo(Z),this.config?.stylesheets)this.stylesheets=this.config.stylesheets.map((X)=>new p0("root",{sheet:X,meta:!0}));return this.__root}setLanguage(J){this.i18n.lang=J,this.__setLang(J)}getLanguage(){return this.__getLang()}setContext(J,Z){const X=this.__getContext();if(typeof J==="string"){const H={...X,[J]:Z};G0(X,H)&&this.__setContext(H)}else if(!Array.isArray(J)){const H={...X,...J};G0(X,H)&&this.__setContext(H)}else throw new Error("Invalid context data")}getContext(){return this.__getContext()}useContext(J,Z){if(!J.length)return;a0(()=>{const X=this.__getContext();if(!X)return;const H=Object.fromEntries(J.map((q)=>[q,X[q]]));H&&typeof Z==="function"&&Object.keys(H).length&&Z(H)})}useTranslator(J,Z){a0(()=>{const X=this.__getLang();if(!X)return;(J==="*"||Array.isArray(J)&&J.includes(X))&&typeof Z==="function"&&Z(X)})}dispose(){this.watcher?.dispose(),this.__root?.destroy(),this.stylesheets.forEach((J)=>J.clear())}}export{i5 as default};
|
|
1
|
+
var Jn=["===","!==","...","=>","==","!=","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/=","%=","+","-","*","/","%","<",">","!","?",":",".",",","(",")","[","]","{","}","="];function Yn(t,e){let n=[],r=0,s=(a)=>/[A-Za-z_$]/.test(a),i=(a)=>/[A-Za-z0-9_$]/.test(a);while(r<t.length){let a=t[r];if(/\s/.test(a)){r++;continue}if(/[0-9]/.test(a)||a==="."&&/[0-9]/.test(t[r+1])){let c=r;while(r<t.length&&/[0-9]/.test(t[r]))r++;if(t[r]==="."){r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}if(t[r]==="e"||t[r]==="E"){if(r++,t[r]==="+"||t[r]==="-")r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}n.push({t:"num",value:t.slice(c,r),start:c,end:r});continue}if(a==="'"||a==='"'){let c=r;r++;let p="",l=!1;while(r<t.length){let u=t[r];if(u==="\\"){let f=t[r+1],m={n:`
|
|
2
|
+
`,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(f==="u"){let g=t.slice(r+2,r+6);p+=String.fromCharCode(parseInt(g,16)||0),r+=6}else p+=m[f]??f,r+=2;continue}if(u===a){l=!0,r++;break}p+=u,r++}if(!l)e.push({code:"LIPS-E001",message:"Unterminated string literal",loc:{offset:c,length:r-c}});n.push({t:"str",value:p,start:c,end:r});continue}if(s(a)){let c=r;while(r<t.length&&i(t[r]))r++;n.push({t:"id",value:t.slice(c,r),start:c,end:r});continue}let o=Jn.find((c)=>t.startsWith(c,r));if(o==="?."&&/[0-9]/.test(t[r+2]??""))o="?";if(o){n.push({t:"punct",value:o,start:r,end:r+o.length}),r+=o.length;continue}e.push({code:"LIPS-E002",message:`Unexpected character '${a}'`,loc:{offset:r,length:1}}),r++}return n.push({t:"eof",value:"",start:t.length,end:t.length}),n}class je{tokens;diagnostics;pos=0;constructor(t,e){this.tokens=t;this.diagnostics=e}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}next(){return this.tokens[this.pos++]??this.tokens[this.tokens.length-1]}at(t){let e=this.peek();return e.t==="punct"&&e.value===t}eat(t){if(this.at(t))return this.pos++,!0;return!1}error(t,e,n=this.peek()){return this.diagnostics.push({code:t,message:e,loc:{offset:n.start,length:Math.max(1,n.end-n.start)}}),{t:"error"}}expect(t,e){if(!this.eat(t))this.error(e,`Expected '${t}'`)}parse(){let t=this.assign();if(this.peek().t!=="eof")this.error("LIPS-E003",`Unexpected token '${this.peek().value}' after expression`);return t}isArrowAhead(){let t=this.peek();if(t.t==="id"){let e=this.peek(1);return e.t==="punct"&&e.value==="=>"}if(t.t==="punct"&&t.value==="("){let e=0,n=0;while(!0){let r=this.peek(n);if(r.t==="eof")return!1;if(r.t==="punct"&&r.value==="(")e++;if(r.t==="punct"&&r.value===")"){if(e--,e===0){let s=this.peek(n+1);return s.t==="punct"&&s.value==="=>"}}n++}}return!1}assign(){if(this.isArrowAhead()){let n=[];if(this.peek().t==="id")n.push(this.next().value);else{this.expect("(","LIPS-E004");while(!this.at(")")&&this.peek().t!=="eof"){let r=this.next();if(r.t!=="id")return this.error("LIPS-E005","Invalid arrow parameter",r);if(n.push(r.value),!this.eat(","))break}this.expect(")","LIPS-E004")}return this.expect("=>","LIPS-E004"),{t:"arrow",params:n,body:this.assign()}}let t=this.conditional(),e=this.peek();if(e.t==="punct"&&["=","+=","-=","*=","/=","%="].includes(e.value)){if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid assignment target",e);return this.next(),{t:"assign",op:e.value,target:t,value:this.assign()}}return t}conditional(){let t=this.nullish();if(this.eat("?")){let e=this.assign();return this.expect(":","LIPS-E007"),{t:"cond",test:t,cons:e,alt:this.assign()}}return t}nullish(){let t=this.or();while(this.at("??"))this.next(),t={t:"logic",op:"??",l:t,r:this.or()};return t}or(){let t=this.and();while(this.at("||"))this.next(),t={t:"logic",op:"||",l:t,r:this.and()};return t}and(){let t=this.equality();while(this.at("&&"))this.next(),t={t:"logic",op:"&&",l:t,r:this.equality()};return t}equality(){let t=this.relational();while(["===","!==","==","!="].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.relational()};return t}relational(){let t=this.additive();while(["<=",">=","<",">"].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.additive()};return t}additive(){let t=this.multiplicative();while(this.at("+")||this.at("-"))t={t:"bin",op:this.next().value,l:t,r:this.multiplicative()};return t}multiplicative(){let t=this.unary();while(this.at("*")||this.at("/")||this.at("%"))t={t:"bin",op:this.next().value,l:t,r:this.unary()};return t}unary(){if(this.at("!")||this.at("-")||this.at("+"))return{t:"unary",op:this.next().value,arg:this.unary()};if(this.at("++")||this.at("--")){let t=this.next().value,e=this.unary();if(e.t!=="id"&&e.t!=="member")return this.error("LIPS-E006","Invalid update target");return{t:"update",op:t,arg:e,prefix:!0}}return this.postfix()}postfix(){let t=this.callMember();if(this.at("++")||this.at("--")){let e=this.next().value;if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid update target");t={t:"update",op:e,arg:t,prefix:!1}}return t}callMember(){let t=this.primary();while(!0)if(this.eat(".")){let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!1,at:e.start}}else if(this.eat("?."))if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!0};else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!0,at:e}}else{let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!0,at:e.start}}else if(this.eat("[")){let e=this.peek().start,n=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:n,computed:!0,optional:!1,at:e}}else if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!1};else break;return t}argList(){this.expect("(","LIPS-E010");let t=[];while(!this.at(")")&&this.peek().t!=="eof")if(t.push(this.assign()),!this.eat(","))break;return this.expect(")","LIPS-E010"),t}primary(){let t=this.peek();if(t.t==="num")return this.next(),{t:"lit",v:parseFloat(t.value)};if(t.t==="str")return this.next(),{t:"lit",v:t.value};if(t.t==="id")switch(this.next(),t.value){case"true":return{t:"lit",v:!0};case"false":return{t:"lit",v:!1};case"null":return{t:"lit",v:null};case"undefined":return{t:"lit",v:void 0};case"NaN":return{t:"lit",v:NaN};case"Infinity":return{t:"lit",v:1/0};default:return{t:"id",name:t.value,at:t.start}}if(this.eat("(")){let e=this.assign();return this.expect(")","LIPS-E010"),e}if(this.eat("[")){let e=[];while(!this.at("]")&&this.peek().t!=="eof"){let n=this.eat("...");if(e.push({spread:n||void 0,value:this.assign()}),!this.eat(","))break}return this.expect("]","LIPS-E009"),{t:"arr",items:e}}if(this.eat("{")){let e=[];while(!this.at("}")&&this.peek().t!=="eof"){if(this.eat("..."))e.push({spread:!0,value:this.assign()});else{let n=this.next();if(n.t!=="id"&&n.t!=="str"&&n.t!=="num")return this.error("LIPS-E011","Invalid object key",n);if(this.eat(":"))e.push({key:String(n.value),value:this.assign(),at:n.start});else if(n.t==="id")e.push({key:n.value,value:{t:"id",name:n.value,at:n.start},at:n.start});else return this.error("LIPS-E011","Invalid shorthand property",n)}if(!this.eat(","))break}return this.expect("}","LIPS-E011"),{t:"obj",props:e}}return this.next(),this.error("LIPS-E012",t.t==="eof"?"Unexpected end of expression":`Unexpected token '${t.value}'`,t)}}function X(t){let e=[],n=Yn(t,e);return{ast:new je(n,e).parse(),diagnostics:e}}function oe(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s++){let i=t[s];if(i==="'"||i==='"'||i==="`"){s++;while(s<t.length&&t[s]!==i){if(t[s]==="\\")s++;s++}continue}if(i==="("||i==="["||i==="{")n++;else if(i===")"||i==="]"||i==="}")n--;else if(i===","&&n===0)e.push(t.slice(r,s)),r=s+1}return e.push(t.slice(r)),e.map((s)=>s.trim()).filter(Boolean)}function Ae(t){let e=new Set,n=(r,s)=>{switch(r.t){case"id":!s.has(r.name)&&e.add(r.name);return;case"member":n(r.obj,s),typeof r.prop!=="string"&&n(r.prop,s);return;case"call":n(r.callee,s),r.args.forEach((i)=>n(i,s));return;case"unary":case"update":n(r.arg,s);return;case"bin":case"logic":n(r.l,s),n(r.r,s);return;case"cond":n(r.test,s),n(r.cons,s),n(r.alt,s);return;case"assign":n(r.target,s),n(r.value,s);return;case"arrow":n(r.body,new Set([...s,...r.params]));return;case"arr":r.items.forEach((i)=>n(i.value,s));return;case"obj":r.props.forEach((i)=>n(i.value,s));return}};return n(t,new Set),[...e]}var _e={__proto__:null,static:"__static",arguments:"__args__"};function j(t){switch(t.t){case"lit":if(typeof t.v==="string")return JSON.stringify(t.v);if(t.v===void 0)return"undefined";if(Number.isNaN(t.v))return"NaN";return String(t.v);case"id":return _e[t.name]??t.name;case"member":{let e=j(t.obj);if(t.computed)return`(${e})${t.optional?"?.":""}[${j(t.prop)}]`;return`(${e})${t.optional?"?.":"."}${t.prop}`}case"call":return`(${j(t.callee)})${t.optional?"?.":""}(${t.args.map(j).join(",")})`;case"unary":return`(${t.op}(${j(t.arg)}))`;case"update":return t.prefix?`(${t.op}${ie(t.arg)})`:`(${ie(t.arg)}${t.op})`;case"bin":return`((${j(t.l)})${t.op}(${j(t.r)}))`;case"logic":return`((${j(t.l)})${t.op}(${j(t.r)}))`;case"cond":return`((${j(t.test)})?(${j(t.cons)}):(${j(t.alt)}))`;case"assign":return`(${ie(t.target)}${t.op}(${j(t.value)}))`;case"arrow":return`((${t.params.join(",")})=>(${j(t.body)}))`;case"arr":return`[${t.items.map((e)=>(e.spread?"...":"")+j(e.value)).join(",")}]`;case"obj":return`({${t.props.map((e)=>e.spread?`...${j(e.value)}`:`${JSON.stringify(e.key)}:${j(e.value)}`).join(",")}})`;case"error":return"undefined"}}function ie(t){if(t.t==="id")return _e[t.name]??t.name;if(t.t==="member"){let e=j(t.obj);return t.computed?`${e}[${j(t.prop)}]`:`${e}.${t.prop}`}return j(t)}var Ne=new Map,Qn=["state","input","context","__static","self"];function ae(t,e=[]){let n=`${e.join(",")}\x00${t}`,r=Ne.get(n);if(r)return r;let{ast:s,diagnostics:i}=X(t);if(i.length)console.warn(`[lips-ir] expression diagnostics for "${t}":`,i);let a=`return (${j(s)});`,o=[...Qn,"__args__",...e],c=Function(...o,a),p={source:t,run(l){let u=l.scope||{};return c(l.state,l.input,l.context,l.static,l.self,l.arguments,...e.map((f)=>u[f]))}};return Ne.set(n,p),p}var $e={__proto__:null,Math,JSON,Object,Array,String,Number,Boolean,Date,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,console};function ce(t,e){let n=e.scope||Object.create(null),r=(o,c)=>{for(let p of c)if(o in p)return p[o];if(o in n)return n[o];switch(o){case"state":return e.state;case"input":return e.input;case"context":return e.context;case"static":return e.static;case"self":return e.self;case"arguments":return e.arguments}if(o in $e)return $e[o];return},s=(o,c,p)=>{for(let l of p)if(o in l)return l[o]=c,c;return n[o]=c,c},i=(o,c)=>{switch(o.t){case"lit":return o.v;case"id":return r(o.name,c);case"member":{let p=i(o.obj,c);if(o.optional&&p==null)return;let l=o.computed?i(o.prop,c):o.prop;return p?.[l]}case"call":{if(o.callee.t==="member"){let l=i(o.callee.obj,c);if((o.callee.optional||o.optional)&&l==null)return;let u=o.callee.computed?i(o.callee.prop,c):o.callee.prop,f=l?.[u];if(o.optional&&f==null)return;return f.apply(l,o.args.map((m)=>i(m,c)))}let p=i(o.callee,c);if(o.optional&&p==null)return;return p(...o.args.map((l)=>i(l,c)))}case"unary":{let p=i(o.arg,c);switch(o.op){case"!":return!p;case"-":return-p;case"+":return+p}}case"update":{let p=i(o.arg,c),l=o.op==="++"?p+1:p-1;return a(o.arg,l,c),o.prefix?l:p}case"bin":{let p=i(o.l,c),l=i(o.r,c);switch(o.op){case"+":return p+l;case"-":return p-l;case"*":return p*l;case"/":return p/l;case"%":return p%l;case"<":return p<l;case">":return p>l;case"<=":return p<=l;case">=":return p>=l;case"==":return p==l;case"!=":return p!=l;case"===":return p===l;case"!==":return p!==l}return}case"logic":{let p=i(o.l,c);switch(o.op){case"&&":return p?i(o.r,c):p;case"||":return p?p:i(o.r,c);case"??":return p!=null?p:i(o.r,c)}}case"cond":return i(o.test,c)?i(o.cons,c):i(o.alt,c);case"assign":{let p=i(o.value,c);if(o.op!=="="){let l=i(o.target,c);switch(o.op){case"+=":p=l+p;break;case"-=":p=l-p;break;case"*=":p=l*p;break;case"/=":p=l/p;break;case"%=":p=l%p;break}}return a(o.target,p,c)}case"arrow":return(...p)=>{let l=Object.create(null);return o.params.forEach((u,f)=>l[u]=p[f]),i(o.body,[l,...c])};case"arr":{let p=[];for(let l of o.items){let u=i(l.value,c);l.spread?p.push(...u):p.push(u)}return p}case"obj":{let p={};for(let l of o.props)if(l.spread)Object.assign(p,i(l.value,c));else p[l.key]=i(l.value,c);return p}case"error":return}},a=(o,c,p)=>{if(o.t==="id")return s(o.name,c,p);if(o.t==="member"){let l=i(o.obj,p),u=o.computed?i(o.prop,p):o.prop;if(l!=null)l[u]=c;return c}return c};return i(t,[])}var J=null,ht=0,Tt=new Set;function Xn(){while(Tt.size){let t=[...Tt];Tt.clear(),ht++;try{for(let e of t)!e.disposed&&e.run()}finally{ht--}}}function pe(t){ht++;try{return t()}finally{ht--,!ht&&Xn()}}function F(t){let e=new Set,n=()=>{if(ht){for(let a of e)Tt.add(a);return}for(let a of[...e])!a.disposed&&a.run()};return[()=>{if(J&&!J.disposed)e.add(J),J.deps.add(e);return t},(a)=>{if(Object.is(a,t))return;t=a,n()},()=>n()]}function A(t){let e={deps:new Set,disposed:!1,run(){if(e.disposed)return;for(let r of e.deps)r.delete(e);e.deps.clear();let n=J;J=e;try{t()}finally{J=n}}};return e.run(),{dispose(){e.disposed=!0;for(let n of e.deps)n.delete(e);e.deps.clear()}}}function V(t){let e=J;J=null;try{return t()}finally{J=e}}var De=Symbol("lips.reactive"),Mt=Symbol("lips.collection"),Be=new WeakMap,ue=(t)=>t!==null&&typeof t==="object"&&(Array.isArray(t)||Object.getPrototypeOf(t)===Object.prototype),Pt=(t)=>t instanceof Map||t instanceof Set||!!(t&&typeof t==="object"&&t[Mt]),tr=new Set(["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"]),er=new Set(["set","delete","clear","add"]),le=Symbol("lips.keys"),Fe=new WeakMap;function He(t,e){let n=t[Mt];if(n)return n.notify.add(e),t;let r=Be.get(t);if(r)return r[Mt].notify.add(e),r;let s={raw:t,notify:new Set([e])},i=()=>s.notify.forEach((o)=>o()),a=new Proxy(t,{get(o,c){if(c===Mt)return s;let p=o[c];if(typeof p!=="function")return p;if(typeof c==="string"&&er.has(c))return(...f)=>{let m=p.apply(o,f);return i(),m};let l=(f)=>ue(f)?fe(f,i):Pt(f)?He(f,i):f,u=o instanceof Map;if(c==="get")return(f)=>l(o.get(f));if(c==="forEach")return(f,m)=>o.forEach((g,b)=>f.call(m,l(g),b,a));if(c==="values"||!u&&(c==="keys"||c===Symbol.iterator))return function*(){for(let f of o.values())yield l(f)};if(c==="entries"||u&&c===Symbol.iterator)return u?function*(){for(let[f,m]of o.entries())yield[f,l(m)]}:function*(){for(let f of o.values())yield[l(f),l(f)]};return p.bind(o)}});return Be.set(t,a),a}function nr(t){let e=Fe.get(t);if(e)return e;let n=new Map,r=(l)=>{let u=n.get(l);if(!u)u=F(0),n.set(l,u);u[0]()},s=(l)=>n.get(l)?.[2](),i=new Map,a=(l)=>{let u=i.get(l);if(!u)u=()=>s(l),i.set(l,u);return u},o=()=>pe(()=>{for(let l of n.values())l[2]()}),c=!1,p=new Proxy(t,{get(l,u){let f=l[u];if(typeof u==="symbol")return f;if(Array.isArray(l)&&tr.has(u)&&typeof f==="function")return(...m)=>{c=!0;try{return f.apply(l,m)}finally{c=!1,o()}};if(typeof f==="function")return f;return r(u),ue(f)||Pt(f)?fe(f,a(u)):f},set(l,u,f){let m=u in l,g=l[u];if(l[u]=f,c)return!0;if(!Object.is(g,f))s(u);if(!m)s(le),Array.isArray(l)&&s("length");return!0},deleteProperty(l,u){let f=u in l;if(delete l[u],!c&&f)s(u),s(le);return!0},has(l,u){return typeof u!=="symbol"&&r(u),u in l},ownKeys(l){return r(le),Reflect.ownKeys(l)}});return Fe.set(t,p),p}function fe(t,e){if(Pt(t))return He(t,e);if(!ue(t))return t;return nr(t)}function Z(t,e=!1){if(t[De])return t;let n=new Map,r=(s,i)=>{let a=n.get(s);if(!a)a=F(i),n.set(s,a);return a};return new Proxy(t,{get(s,i){if(i===De)return!0;if(typeof i==="string"){let a=r(i,s[i]);return e?fe(a[0](),a[2]):a[0]()}return s[i]},set(s,i,a){let o=s[i];if(s[i]=a,typeof i!=="string")return!0;let c=r(i,a);return Object.is(o,a)&&Pt(a)?c[2]():c[1](a),!0},has(s,i){return i in s},deleteProperty(s,i){return delete s[i],typeof i==="string"&&n.get(i)?.[1](void 0),!0}})}var Ve=new WeakMap,he={clone(t){let e=Ve.get(t);if(!e)e=document.createElement("template"),e.innerHTML=t.html,Ve.set(t,e);return e.content.cloneNode(!0)},fragment:()=>document.createDocumentFragment(),element:(t)=>document.createElement(t),text:(t)=>document.createTextNode(t),marker:(t)=>document.createComment(t),child:(t,e)=>t.childNodes[e],next:(t)=>t.nextSibling,range(t,e){let n=[];for(let r=t;r;r=r.nextSibling)if(n.push(r),r===e)break;return n},insert:(t,e,n)=>{t.insertBefore(e,n)},insertAfter(t,e){let n=t.parentNode;if(!n)return;let r=t;for(let s of e)n.insertBefore(s,r.nextSibling),r=s},remove:(t)=>t.remove(),isElement:(t)=>t.nodeType===1,connected:(t)=>t.isConnected,precedes:(t,e)=>!!(t.compareDocumentPosition(e)&4),attr:(t,e,n)=>n===null?t.removeAttribute(e):t.setAttribute(e,n),setText:(t,e)=>{t.data=e},content:(t,e)=>{t.textContent=e},html:(t,e)=>{t.innerHTML=e},styleVar:(t,e,n)=>n===null?t.style.removeProperty(e):t.style.setProperty(e,n),scope:(t,e)=>{t.hasAttribute("rel")||t.setAttribute("rel",e)},listen(t,e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)},keepFocus(){let t=document.activeElement;return()=>{t&&t.isConnected&&t!==document.activeElement&&t.focus()}}};function yt(t){let e=t.split("-"),n=[];while(e.length)n.push(e.join("-")),e.pop(),e[e.length-1]?.length===1&&e.pop();return n}function Ot(t,e){let n=new Map(Object.entries(t.names).map(([r,s])=>[r.toLowerCase(),s]));for(let r of yt(e.toLowerCase()))if(n.has(r))return n.get(r);return t.names[t.default]??""}var tt=(t,e)=>t==null?t:("e"in t)?{$:e[t.e]}:t,ge=(t,e)=>({...t,e:e[t.e]});function Lt(t,e){switch(t.t){case"macro":return{t:t.t,name:t.name,args:t.args,sets:t.sets.map((n)=>("spread"in n)?{spread:e[n.spread]}:{name:n.name,ci:tt(n.ci,e)}),block:et(t.block,e)};case"if":return{t:t.t,branches:t.branches.map((n)=>({when:n.when==null?null:e[n.when],block:et(n.block,e)}))};case"for":return{t:t.t,args:t.args,of:t.of===void 0?void 0:e[t.of],from:tt(t.from,e),to:tt(t.to,e),by:tt(t.by,e),block:et(t.block,e)};case"switch":return{t:t.t,on:e[t.on],cases:t.cases.map((n)=>({is:n.is===null?null:tt(n.is,e),block:et(n.block,e)}))};case"async":return{t:t.t,awaitE:e[t.awaitE],then:t.then&&{args:t.then.args,block:et(t.then.block,e)},catch:t.catch&&{args:t.catch.args,block:et(t.catch.block,e)},loading:t.loading&&et(t.loading,e)};case"let":return{t:t.t,const:t.const,vars:Object.fromEntries(Object.entries(t.vars).map(([n,r])=>[n,tt(r,e)]))};case"log":return{t:t.t,e:e[t.e]};case"provide":return{t:t.t,vars:Object.fromEntries(Object.entries(t.vars).map(([n,r])=>[n,tt(r,e)])),lang:tt(t.lang,e),block:et(t.block,e)};case"comp":case"dynamic":return{t:t.t,name:t.t==="comp"?t.name:void 0,tag:t.t==="dynamic"?e[t.tag]:void 0,inputs:Object.fromEntries(Object.entries(t.inputs).map(([n,r])=>[n,tt(r,e)])),spreads:t.spreads.map((n)=>e[n]),events:t.events.map((n)=>({name:n.name,e:e[n.e]})),contents:t.contents&&{args:t.contents.args,block:et(t.contents.block,e)}}}}var et=(t,e)=>({html:t.html,scope:t.scope,binds:t.binds.map((n)=>ge(n,e)),blocks:t.blocks.map((n)=>Lt(n,e))}),Ue=(t,e,n,r)=>t.t===n.t&&JSON.stringify(Lt(t,e))===JSON.stringify(Lt(n,r)),We=(t,e,n,r)=>JSON.stringify(t.map((s)=>ge(s,e)))===JSON.stringify(n.map((s)=>ge(s,r))),qe=(t,e,n,r)=>{let s=(i,a)=>JSON.stringify(i.blocks.filter((o)=>o.t==="let").map((o)=>Lt(o,a)));return s(t,e)===s(n,r)};var Je=Symbol("lips.slot"),rr=(t)=>!!t&&typeof t==="object"&&t[Je]===!0;function Ye(t){let e=!1,n=!1,r=(s)=>typeof t.onError==="function"?t.onError(s):console.error("[lips:ir]",s);return{onError:r,ready(){n=!0},notifyUpdate(){if(!n||e)return;e=!0,Promise.resolve().then(()=>{e=!1;try{typeof t.onUpdate==="function"&&t.onUpdate(),typeof t.onRender==="function"&&t.onRender()}catch(s){r(s)}})}}}var $t=[];function Qe(){let t=!0;while(t){t=!1;for(let e of[...$t].reverse()){if(!e.live())continue;let n=$t.indexOf(e);if(n<0)continue;$t.splice(n,1),e.fn(),t=!0}}}var Ke=new Map;function sr(t){let e=Ke.get(t);if(!e)e=X(t).ast,Ke.set(t,e);return e}var bt=(t)=>t.join(",");function Ze(t,e,n){let r=e;for(let s of n)r=t.child(r,s);return r}var at=(t,e)=>t.range(e.start,e.end),Ge=(t,e,n,r)=>r===e||t.precedes(e,r)&&t.precedes(r,n);function ze(t,e){e.gen++;for(let r of e.wiring)r();e.wiring=[];let n=t.fragment();for(let r of at(t,e.inst))t.insert(n,r,null)}function Y(t,e,n){return t.insertAfter(e,at(t,n)),n}var me=(t,e)=>at(t,e).filter((n)=>t.isElement(n));function Xe(t,e,n){for(let r of me(t,e))t.scope(r,n)}function ir(t,e,n,r,s=""){for(let i of e)t.styleVar(i,n,r===null||r===void 0||r===!1?null:r+s)}function tn(t,e,n,r,s){Xe(t,n,r);let i=s.css?e.createStylesheet?.(r,s.css):void 0;return i?()=>i.clear():void 0}function or(t){for(let e of t.bindHandles)e.dispose();for(let e of t.childHandles)e.dispose()}function U(t,e){if(!e)return;or(e);for(let n of at(t,e))t.remove(n,!0)}var Nt=(t,e,n,r)=>t.attr(e,n,r===!1||r==null?null:r===!0?"":String(r)),ot=(t,e,n)=>Object.defineProperty(t,e,{get:n,enumerable:!0,configurable:!0}),ar=Symbol.for("lips.self"),en=Symbol("lips.ctx.layer");function cr(t,e,n,r){for(let s=t;s;s=Object.getPrototypeOf(s)){let a=s[en]?.get(e);if(a){a(n);return}}r?.(e,n)}function nn(t,e){let n=new Map,r=(c,...p)=>n.get(c)?.forEach((l)=>l(...p)),s,i=()=>null;return{proto:{[ar]:!0,get node(){let c=i();return c?me(t,c):[]},get lang(){return e()},pick:(c)=>Ot(c,e()),emit:r,emitLocal:r,on(c,p){return n.set(c,[...n.get(c)||[],p]),s},once(c,p){let l=(...u)=>{s.off(c,l),p(...u)};return s.on(c,l)},off(c,p){if(!p)n.delete(c);else{let l=(n.get(c)||[]).filter((u)=>u!==p);l.length?n.set(c,l):n.delete(c)}return s}},bind:(c,p)=>(s=c,i=p,c)}}class jt{ir;options;hooks;live;constructor(t,e,n,r=[]){this.ir=t;this.options=e;this.hooks=n;this.live=r;this.h=e.host||he}h;pool=null;salvaged=[];withSalvage(t,e){let n=this.pool;this.pool=t;try{return e()}finally{this.pool=n;for(let r of t)!r.claimed&&r.teardown()}}claim(t,e){let n=this.pool?.find((r)=>!r.claimed&&r.name===t&&r.key===e);if(!n)return;return n.claimed=!0,this.salvaged.push(t),n}keyOf(t,e,n){let r=t.key;return r===void 0?void 0:("lit"in r)?r.lit:V(()=>this.runner(r.e,n)(e))}guarded(t){let e=!0;return A(()=>{try{t()}catch(n){this.hooks?this.hooks.onError(n):console.error("[lips:ir]",n)}e?e=!1:this.hooks?.notifyUpdate()})}bindStyle(t,e,n){if(!t.binds.length)return()=>{};let r=me(this.h,e),s=t.binds.map((i)=>{let a=this.srcRunner(t.exprs[i.e],[]);return this.guarded(()=>ir(this.h,r,i.prop,a(n),i.u))});return()=>{for(let i of s)i.dispose()}}runner(t,e){return this.srcRunner(this.ir.exprs[t],e)}srcRunner(t,e){if(this.options.guard)return this.options.guard.run(t);if(this.options.mode==="interpreted"){let r=sr(t);return(s)=>ce(r,s)}let n=ae(t,e);return(r)=>n.run(r)}renderBlock(t,e){let n=this.h,r=n.clone(t),s=new Map,i=t.binds.map((f)=>{let m=Ze(n,r,f.p);return s.set(bt(f.p),m),m}),a=t.blocks.map((f)=>{let m=Ze(n,r,f.p);return s.set(bt(f.p),m),m}),o=n.marker("^"),c=n.marker("$");n.insert(r,c,null),n.insert(r,o,n.child(r,0));let p=Object.create(e.scope??null),l={...e,scope:p},u={start:o,end:c,block:t,exprs:this.ir.exprs,penv:e,benv:l,pathNodes:s,bindHandles:[],childHandles:[]};return t.blocks.forEach((f,m)=>{if(f.t!=="let")return;let g=[];for(let[b,k]of Object.entries(f.vars))if("lit"in k){let[h]=F(k.lit);ot(p,b,h)}else{let[h,x]=F(void 0);ot(p,b,h);let R=this.runner(k.e,t.scope);g.push(A(()=>x(R(l))).dispose)}u.childHandles[m]={child:f,exprs:this.ir.exprs,anchor:a[m],dispose:()=>g.forEach((b)=>b())}}),u.bindHandles=t.binds.map((f,m)=>this.bindOne(f,i[m],l,t.scope)),t.blocks.forEach((f,m)=>{if(f.t==="let")return;u.childHandles[m]={child:f,exprs:this.ir.exprs,anchor:a[m],dispose:this.execBlock(f,a[m],l,t.scope)}}),u}bindOne(t,e,n,r,s){let i=this.h;switch(t.t){case"text":{let a=s??i.text("");!s&&i.insertAfter(e,[a]);let o=this.runner(t.e,r),c=t.i18n?this.options.i18n:void 0,p=this.guarded(()=>{let l=o(n),u=l==null?"":String(l);i.setText(a,c?c.translate(u,t.ik,n.lang?.()):u)});return{bind:t,node:e,textNode:a,dispose:p.dispose}}case"attr":{let a=this.runner(t.e,r),o=t.i18n?this.options.i18n:void 0,c=this.guarded(()=>{let p=a(n);Nt(i,e,t.name,o&&p!=null?o.translate(String(p),t.ik,n.lang?.()):p)});return{bind:t,node:e,dispose:c.dispose}}case"prop":{let a=this.runner(t.e,r);if(t.name==="format"){let c=t.ref||"",p=this.guarded(()=>{let l=a(n),u=this.options.i18n?.format(c,l,n.lang?.());i.content(e,u==null?"":String(u))});return{bind:t,node:e,dispose:p.dispose}}let o=this.guarded(()=>{let c=a(n),p=c==null?"":String(c);t.name==="html"&&i.html?i.html(e,p):i.content(e,p)});return{bind:t,node:e,dispose:o.dispose}}case"event":{let a=this.eventDispatcher(this.ir.exprs[t.e],r,n);return{bind:t,node:e,dispose:i.listen(e,t.name,a)}}case"spread":{let a=this.runner(t.e,r),o=new Set,c=this.guarded(()=>{let p=a(n)||{},l=new Set(Object.keys(p));for(let u of o)!l.has(u)&&i.attr(e,u,null);for(let u of l)Nt(i,e,u,p[u]);o=l});return{bind:t,node:e,dispose:c.dispose}}}}swapBlock(t,e,n,r){if(t.block.html!==e.html||JSON.stringify(t.block.scope)!==JSON.stringify(e.scope)||!qe(t.block,t.exprs,e,this.ir.exprs))return this.rebuild(t,e,n,r);if(!We(t.block.binds,t.exprs,e.binds,this.ir.exprs)){let s=e.binds.map((o)=>t.pathNodes.get(bt(o.p)));if(s.some((o)=>!o))return this.rebuild(t,e,n,r);let i=new Map;t.bindHandles.forEach((o)=>o.textNode&&i.set(bt(o.bind.p),o.textNode)),t.bindHandles.forEach((o)=>o.dispose());let a=new Set;t.bindHandles=e.binds.map((o,c)=>{let p=bt(o.p),l=o.t==="text"?i.get(p):void 0;return l&&a.add(p),this.bindOne(o,s[c],t.benv,e.scope,l)}),i.forEach((o,c)=>!a.has(c)&&this.h.remove(o,!0)),n.push({kind:"binds",path:r})}for(let s=0;s<e.blocks.length;s++){let i=e.blocks[s],a=t.childHandles[s];if(i.t==="let")continue;if(a&&Ue(a.child,a.exprs,i,this.ir.exprs))continue;let o=this.live.filter((c)=>Ge(this.h,a.anchor,t.childHandles[s+1]?.anchor??t.end,c.anchor));for(let c of o)ze(this.h,c);a?.dispose(),t.childHandles[s]={child:i,exprs:this.ir.exprs,anchor:a.anchor,dispose:this.withSalvage(o,()=>this.execBlock(i,a.anchor,t.benv,e.scope))},n.push({kind:"block",path:`${r}/${s}`})}return t.block=e,t.exprs=this.ir.exprs,t}rebuild(t,e,n,r){let s=this.live.filter((a)=>Ge(this.h,t.start,t.end,a.anchor));for(let a of s)ze(this.h,a);let i=this.withSalvage(s,()=>this.renderBlock(e,t.penv));return Y(this.h,t.end,i),U(this.h,t),n.push({kind:"skeleton",path:r}),i}execBlock(t,e,n,r){let s=this.h,i=[];switch(t.t){case"if":{let a=t.branches.map((l)=>l.when!=null?this.runner(l.when,r):null),o=null,c=-2,p=A(()=>{let l=-1;for(let u=0;u<t.branches.length;u++){let f=a[u];if(!f||f(n)){l=u;break}}if(l===c)return;c=l,V(()=>{if(U(s,o),o=null,l>=0)o=Y(s,e,this.renderBlock(t.branches[l].block,n))})});i.push(()=>{p.dispose(),U(s,o)});break}case"switch":{let a=this.runner(t.on,r),o=t.cases.map((u)=>u.is&&("e"in u.is)?this.runner(u.is.e,r):null),c=null,p=-2,l=A(()=>{let u=a(n),f=-1,m=-1;for(let g=0;g<t.cases.length;g++){let b=t.cases[g];if(b.is===null){m=g;continue}let k="lit"in b.is?b.is.lit:o[g](n);if(Array.isArray(k)?k.includes(u):k===u){f=g;break}}if(f===-1)f=m;if(f===p)return;p=f,V(()=>{if(U(s,c),c=null,f>=0)c=Y(s,e,this.renderBlock(t.cases[f].block,n))})});i.push(()=>{l.dispose(),U(s,c)});break}case"macro":{let a=Object.create(n.scope??null),o=Z({}),c={};for(let f of t.args)c[f]=F(void 0),ot(a,f,c[f][0]);let p=t.sets.map((f)=>{if("spread"in f)return{kind:"spread",run:this.runner(f.spread,r)};if("lit"in f.ci){let g=f.ci.lit;return{kind:"value",name:f.name,value:()=>g}}let m=this.runner(f.ci.e,r);return{kind:"value",name:f.name,value:()=>m(n)}}),l=new Set;i.push(A(()=>{let f={};for(let m of p)if(m.kind==="spread"){let g=m.run(n);if(g&&typeof g==="object")for(let[b,k]of g instanceof Map?g:Object.entries(g))f[b]=k}else f[m.name]=m.value();V(()=>{for(let g of t.args)c[g][1](f[g]);let m=new Set(Object.keys(f));for(let g of l)!m.has(g)&&delete o[g];for(let g of m)o[g]=f[g];l=m})}).dispose);let u=Y(s,e,this.renderBlock(t.block,{...n,arguments:o,scope:a}));i.push(()=>U(s,u));break}case"for":this.execFor(t,e,n,r,i);break;case"async":{let a=this.runner(t.awaitE,r),o=null,c=0,p=(u,f)=>{if(U(s,o),o=null,!u)return;let m="block"in u,g=Object.create(n.scope??null);if(m&&u.args[0]!==void 0){let[b]=F(f);ot(g,u.args[0],b)}o=Y(s,e,this.renderBlock(m?u.block:u,{...n,scope:g}))},l=A(()=>{let u=a(n),f=++c;V(()=>{t.loading?p(t.loading):p(void 0),Promise.resolve(u).then((m)=>f===c&&V(()=>p(t.then,m)),(m)=>f===c&&V(()=>p(t.catch,m)))})});i.push(()=>{c++,l.dispose(),U(s,o)});break}case"provide":{let a=Object.create(n.context??null),o=new Map;Object.defineProperty(a,en,{value:o});for(let[l,u]of Object.entries(t.vars)){let[f,m]=F("lit"in u?u.lit:void 0);if(ot(a,l,f),o.set(l,m),"lit"in u)continue;let g=this.runner(u.e,r);i.push(A(()=>m(g(n))).dispose)}let c=n.lang;if(t.lang)if("lit"in t.lang){let l=String(t.lang.lit);c=()=>l}else{let[l,u]=F(void 0),f=this.runner(t.lang.e,r);i.push(A(()=>u(f(n))).dispose),c=()=>l()??n.lang?.()}let p=Y(s,e,this.renderBlock(t.block,{...n,context:a,lang:c}));i.push(()=>U(s,p));break}case"log":{let a=oe(this.ir.exprs[t.e]).map((o)=>this.srcRunner(o,r));i.push(A(()=>console.log(...a.map((o)=>o(n)))).dispose);break}case"comp":{let a=this.options.components?.[t.name];a?this.execComponent(a,t,e,n,r,i,t.name):this.execElement(t,e,n,r,i);break}case"dynamic":{let a=this.runner(t.tag,r),o=[],c=Symbol("init"),p=A(()=>{let l=a(n);if(l===c)return;c=l,V(()=>{for(let f of o)f();if(o=[],l==null)return;if(rr(l)){let f={};for(let[g,b]of Object.entries(t.inputs))f[g]="lit"in b?b.lit:this.runner(b.e,r)(n);let m=Y(s,e,l.render(f));o.push(()=>U(s,m));return}let u=typeof l==="string"?this.options.components?.[l]:l&&typeof l==="object"?l.ir?l:this.options.resolveTemplate?.(l):void 0;if(u)this.execComponent(u,t,e,n,r,o,typeof l==="string"?l:"#dynamic");else if(typeof l==="string")this.execElement({...t,name:l},e,n,r,o)})});i.push(()=>{p.dispose();for(let l of o)l()});break}}return()=>i.forEach((a)=>a())}execFor(t,e,n,r,s){let i=this.h,a=t.of!==void 0?this.runner(t.of,r):null,o=t.by&&"e"in t.by?this.runner(t.by.e,r):null,c=t.by&&"lit"in t.by?String(t.by.lit).split("."):null,p=(b,k)=>b===void 0?void 0:("lit"in b)?b.lit:this.runner(b.e,r)(k),l=[],u=0,f=new Map,m=()=>{if(a===null){let h=Number(p(t.from,n)??0),x=Number(p(t.to,n)??h),R=h<=x,C=[];for(let v=h;R?v<=x:v>=x;R?v++:v--)C.push({key:v,values:[v]});return C}let b=a(n),k=(h,x,R)=>{if(o){let C=o(n);return typeof C==="function"?C(h,R):x}if(c)return c.reduce((C,v)=>C?.[v],h);return x};if(Array.isArray(b))return b.map((h,x)=>({key:k(h,x,x),values:[h,x]}));if(b instanceof Map)return[...b.entries()].map(([h,x],R)=>({key:h,values:[h,x,R]}));if(b instanceof Set)return[...b].map((h,x)=>({key:k(h,h,x),values:[h,x]}));if(b&&typeof b==="object")return Object.entries(b).map(([h,x],R)=>({key:h,values:[h,x,R]}));return[]},g=A(()=>{let b=m();V(()=>{let k=new Set,h=[],x=++u;for(let C of b){let v=C.key;if(k.has(v))console.warn(`<for> duplicate key '${String(v)}' — falling back to positional identity`),v=`#dup:${h.length}`;k.add(v);let d=f.get(v);if(d)d.sigs.forEach(([E,M,z],P)=>{let D=C.values[P];Object.is(E(),D)&&typeof D==="object"&&D!==null?z():M(D)}),d.pass=x,h.push(d);else{let E=Object.create(n.scope??null),M=C.values.map((D)=>F(D));t.args.forEach((D,B)=>M[B]&&ot(E,D,M[B][0]));let z=this.renderBlock(t.block,{...n,scope:E}),P={key:v,sigs:M,inst:z,pass:x};f.set(v,P),h.push(P)}}for(let C of l)if(C.pass!==x)f.delete(C.key),U(i,C.inst);let R=e;for(let C of h){if(i.next(R)!==C.inst.start)Y(i,R,C.inst);R=C.inst.end}l=h})});s.push(()=>{g.dispose();for(let b of l)U(i,b.inst);l=[],f.clear()})}wireInputs(t,e,n,r,s,i){for(let[a,o]of Object.entries(t.inputs))if(i?.add(a),"lit"in o)r[a]=o.lit;else{let c=this.runner(o.e,n);s.push(A(()=>r[a]=c(e)).dispose)}for(let a of t.spreads){let o=this.runner(a,n);s.push(A(()=>{let c=o(e)||{};V(()=>Object.entries(c).forEach(([p,l])=>{i?.add(p),r[p]=l}))}).dispose)}}wireEvents(t,e,n,r,s){t?.forEach((i)=>{let a=this.eventDispatcher(this.ir.exprs[i.e],n,e);r.on(i.name,a),s.push(()=>r.off(i.name,a))})}slotRenderer(t,e){let n=this;return{[Je]:!0,args:t.args,render(r){let s=Object.create(e.scope??null);return t.args.forEach((i)=>{let[a]=F(r?.[i]);ot(s,i,a)}),n.renderBlock(t.block,{...e,scope:s})}}}adoptComponent(t,e,n,r,s,i){let a=[],o=new Set;if(this.wireInputs(e,r,s,t.input,a,o),e.contents)t.input.renderer=this.slotRenderer(e.contents,r),o.add("renderer");for(let p of Object.keys(t.input))!o.has(p)&&delete t.input[p];this.wireEvents(e.events,r,s,t.self,a),t.wiring=a,t.anchor=n;let c=t.gen;Y(this.h,n,t.inst),i.push(()=>{if(c!==t.gen)return;for(let p of t.wiring)p();t.wiring=[],t.teardown()})}execComponent(t,e,n,r,s,i,a){let o=this.pool?.length?this.claim(a,this.keyOf(e.inputs,r,s)):void 0;if(o)return this.adoptComponent(o,e,n,r,s,i);let c=Z({}),p=[];if(this.wireInputs(e,r,s,c,p),e.contents)c.renderer=this.slotRenderer(e.contents,r);let l=Z({...t.state||{}},t.deep??!1),u=null,f=this,m=nn(this.h,()=>r.lang?.()??f.options.i18n?.lang()??""),g=m.bind(Object.assign(Object.create(m.proto),{...this.options.expose||{},state:l,input:c,static:t.statics,context:r.context,setContext(P,D){let B=(dt,pt)=>cr(r.context,dt,pt,f.options.expose?.setContext);typeof P==="string"?B(P,D):Object.entries(P||{}).forEach(([dt,pt])=>B(dt,pt))}}),()=>u);t.handlers&&Object.entries(t.handlers).forEach(([P,D])=>g[P]=D.bind(g)),this.wireEvents(e.events,r,s,g,p);let b=Ye(g);try{typeof g.onCreate==="function"&&g.onCreate()}catch(P){b.onError(P)}try{Object.keys(c).length&&typeof g.onInput==="function"&&g.onInput(c)}catch(P){b.onError(P)}let k={state:l,input:c,context:r.context,lang:r.lang,static:t.statics,self:g,scope:void 0},h=new jt(t.ir,this.options,b),x=h.renderBlock(t.ir.root,k);u=x;let R=t.stylesheet?tn(this.h,this.options,x,t.stylesheet.nsp||t.nsp||"lips",t.stylesheet):void 0,C=t.stylesheet?h.bindStyle(t.stylesheet,x,k):void 0;Y(this.h,n,x),b.ready();try{typeof g.onMount==="function"&&g.onMount(),typeof g.onRender==="function"&&g.onRender(),g.emit("component:mount")}catch(P){b.onError(P)}let v;if(t.context?.length&&typeof g.onContext==="function"){let P=!0,{dispose:D}=A(()=>{for(let B of t.context)k.context?.[B];if(P){P=!1;return}V(()=>{try{g.onContext()}catch(B){b.onError(B)}})});v=D}let d=!1;$t.push({live:()=>this.h.connected(x.start),fn:()=>{d=!0;try{typeof g.onAttach==="function"&&g.onAttach(),g.emit("component:attached")}catch(P){b.onError(P)}}}),this.h.connected(x.start)&&Qe();let E=!1,M={name:a,key:c.key,self:g,input:c,inst:x,anchor:n,wiring:p,gen:0,claimed:!1,teardown:()=>{if(E)return;E=!0;let P=this.live.indexOf(M);P>-1&&this.live.splice(P,1),v?.(),C?.(),R?.(),U(this.h,x);try{if(d)typeof g.onDetach==="function"&&g.onDetach(),g.emit("component:detached");typeof g.onDestroy==="function"&&g.onDestroy(),g.emit("component:destroy")}catch(D){b.onError(D)}}};this.live.push(M);let z=M.gen;i.push(()=>{if(z!==M.gen)return;for(let P of M.wiring)P();M.wiring=[],M.teardown()})}execElement(t,e,n,r,s){let i=this.h,a=i.element(t.name);for(let[o,c]of Object.entries(t.inputs))if("lit"in c)Nt(i,a,o,c.lit);else{let p=this.runner(c.e,r);s.push(A(()=>Nt(i,a,o,p(n))).dispose)}for(let o of t.events)s.push(i.listen(a,o.name,this.eventDispatcher(this.ir.exprs[o.e],r,n)));if(t.contents){let o=this.renderBlock(t.contents.block,n);for(let c of at(i,o))i.insert(a,c,null);s.push(()=>U(i,o))}i.insertAfter(e,[a]),s.push(()=>i.remove(a,!0))}eventDispatcher(t,e,n){let r=oe(t);return(...s)=>V(()=>{let i=(c)=>{let p;try{p=this.srcRunner(c,e)(n)}catch(l){p=void 0}if(typeof p!=="function"&&n.self&&!this.options.guard?.self(c)&&typeof n.self[c]==="function")p=n.self[c];return p};if(!r.length)return;let a=i(r[0]);if(typeof a!=="function")return;let o=r.slice(1).map((c)=>this.srcRunner(c,e)(n));a(...o,...s)})}}function At(t,e={},n={}){let r=n.host||he,s=Z(e.state||{},e.deep??!1),i=e.input?Z(e.input,e.deep??!1):void 0,a=null,o=nn(r,()=>n.i18n?.lang()??""),c=o.bind(Object.assign(Object.create(o.proto),{state:s,input:i,static:e.static,...n.expose||{},...e.expose||{}}),()=>a);e.handlers&&Object.entries(e.handlers).forEach(([h,x])=>c[h]=x.bind(c));let p={state:s,input:i,context:e.context,static:e.static,self:c,scope:void 0},l=Ye(c);try{typeof c.onCreate==="function"&&c.onCreate()}catch(h){l.onError(h)}try{i&&Object.keys(i).length&&typeof c.onInput==="function"&&c.onInput(i)}catch(h){l.onError(h)}let u=new jt(t,n,l),f=u.renderBlock(t.root,p);a=f,l.ready();let m=e.stylesheet?tn(r,n,f,e.stylesheet.nsp||e.nsp||"lips",e.stylesheet):void 0,g=e.stylesheet?u.bindStyle(e.stylesheet,f,p):void 0;try{typeof c.onMount==="function"&&c.onMount(),typeof c.onRender==="function"&&c.onRender()}catch(h){l.onError(h)}let b=!1,k=()=>{if(b)return;b=!0;try{typeof c.onAttach==="function"&&c.onAttach(),c.emit("component:attached")}catch(h){l.onError(h)}};return{state:s,self:c,get nodes(){return at(r,f)},mount(h){for(let x of at(r,f))r.insert(h,x,null);if(r.connected(f.start))k(),Qe()},swap(h){let x=[],R=r.keepFocus?.();if(u=new jt(h,n,l,u.live),f=u.swapBlock(f,h.root,x,"root"),a=f,e.stylesheet)Xe(r,f,e.stylesheet.nsp||e.nsp||"lips"),g?.(),g=u.bindStyle(e.stylesheet,f,p);return R?.(),{changes:x,salvaged:u.salvaged}},dispose(){g?.(),m?.(),U(r,f);try{if(b)typeof c.onDetach==="function"&&c.onDetach(),c.emit("component:detached");typeof c.onDestroy==="function"&&c.onDestroy()}catch(h){l.onError(h)}}}}class _t{options={emit:!0};__events={};__once_events={};constructor(t){if(t)this.options=t}on(t,e){if(!Array.isArray(this.__events[t]))this.__events[t]=[];return this.__events[t].push(e),this}once(t,e){if(!Array.isArray(this.__once_events[t]))this.__once_events[t]=[];return this.__once_events[t].push(e),this}off(t,e){if(e){if(Array.isArray(this.__events[t]))this.__events[t]=this.__events[t].filter((n)=>n!==e),!this.__events[t].length&&delete this.__events[t];if(Array.isArray(this.__once_events[t]))this.__once_events[t]=this.__once_events[t].filter((n)=>n!==e),!this.__once_events[t].length&&delete this.__once_events[t]}else delete this.__events[t],delete this.__once_events[t];return this}emit(t,...e){if(!this.options.emit)return;let n=(s)=>{if(!s||typeof s!=="object")return s;if(typeof s.toJSON==="function")return s.toJSON();if(Array.isArray(s))return s.map(n);if(s.constructor===Object||s.constructor===void 0){let i={};for(let a in s)i[a]=n(s[a]);return i}return s},r=e.map(n);this.__events[t]?.forEach((s)=>s(...r)),this.__once_events[t]?.forEach((s)=>s(...r)),delete this.__once_events[t]}}class Dt{nsp;settings;constructor(t,e){if(typeof t!=="string"||!t)throw Error("Undefined or invalid stylesheet namespace");this.nsp=t,this.settings=e||{},this.settings.sheet&&this.load(this.settings)}get rel(){return`${this.settings.meta?"@":""}${this.nsp}`}get styleElement(){return document.head.querySelector(`style[rel="${this.rel.replace(/["\\]/g,"\\$&")}"]`)}load(t){if(this.settings=t,!t.sheet)return;let e=this.styleElement;if(e)return e.setAttribute("dindex",String(Number(e.getAttribute("dindex")||0)+1)),e;let n=document.createElement("style");return n.setAttribute("rel",this.rel),n.setAttribute("dindex","0"),n.textContent=t.sheet,t.meta?document.head.prepend(n):document.head.appendChild(n),n}clear(){let t=this.styleElement;if(!t)return;let e=Number(t.getAttribute("dindex")||0);e<=0?t.remove():t.setAttribute("dindex",String(e-1))}}var lr="en-US";class Bt{engine;currentLang;DICTIONARIES={};functions;onMissing;onError;onChange;loader;loading=new Map;formatters=new Map;constructor(t,e){this.engine=e;this.currentLang=t||typeof navigator<"u"&&navigator.language||lr,this.functions={...e?.functions}}set lang(t){if(this.currentLang===t)return;this.currentLang=t}get lang(){return this.currentLang}setDictionary(t,e){if(!this.engine)throw Error(`[lips:i18n] <${t}> dictionary without a MessageFormat engine — pass \`messageFormat\` from '@lipsjs/lips/i18n' to new Lips()`);this.DICTIONARIES[t.toLowerCase()]=e,this.formatters.clear(),this.onChange?.()}has(t){return yt(t.toLowerCase()).some((e)=>!!this.DICTIONARIES[e])}setLoader(t){return this.loader=t,this}load(t){return Promise.all(yt(t).map((e)=>{let n=e.toLowerCase();if(this.DICTIONARIES[n]||!this.loader)return;let r=this.loading.get(n);if(!r)r=this.loader(e).then((s)=>{s&&this.setDictionary(e,s)}).catch((s)=>console.warn(`[lips:i18n] <${e}> dictionary failed to load —`,s)),this.loading.set(n,r);return r})).then(()=>{})}message(t,e){let n=`${e}
|
|
3
|
+
${t}`;if(this.formatters.has(n))return this.formatters.get(n);let r;for(let s of yt(e.toLowerCase())){let i=this.DICTIONARIES[s];if(!i||!Object.prototype.hasOwnProperty.call(i,t))continue;try{r=new this.engine.MessageFormat(e,i[t],{functions:this.functions})}catch(a){this.onError?.(a,t,e),r=null}break}return r!==void 0&&this.formatters.set(n,r),r}translate(t,e,n){let r=e||this.currentLang,s=n||t,i=this.message(s,r);if(i)t=i.format(void 0,(a)=>this.onError?.(a,s,r));else if(i===void 0&&n)this.onMissing?.(n,r);return{text:t,lang:r}}format(t,e,n){let r=n||this.currentLang,s=this.message(t,r);if(s)return s.format(e,(i)=>this.onError?.(i,t,r));s===void 0&&this.onMissing?.(t,r)}pick(t,e){return Ot(t,e||this.currentLang)}}var Ft=null;function rn(t){Ft=t}var Ht=null;function sn(t){Ht=t}var on;function an(t){on=t}var cn={};function ln(t,e){cn[t]=e}var pr=new Set(["state","input","static","context","emit","on","once","off","node","lang","setContext","setLanguage","destroy","appendTo","prependTo","replaceWith","render","swap"]);function pn(t){if(!t)return;for(let e of Object.keys(t))if(pr.has(e))throw Error(`Handler <${e}> is a reserved component member name`);return t}class un extends _t{lips;template;state;instance;contextWatcher;destroyed=!1;constructor(t,e,n,r,s,i){super();this.lips=t;this.template=n;let a=pn(n.handler);this.state=Z({...n.state||{}},!0);let o=r?Z({...r},!0):void 0,c=(l,...u)=>super.emit(l,...u);this.instance=At(s,{state:this.state,input:o,context:t.getContext(),static:n.static??n._static,handlers:a,deep:!0,stylesheet:t.styleFor(e,n),nsp:e,expose:{emit(l,...u){this.emitLocal?.(l,...u),c(l,...u)},context:t.getContext()}},i);let p=n.watchContext??n.context;if(p?.length&&typeof a?.onContext==="function")this.contextWatcher=t.watchContext(p,()=>{try{a.onContext.call(this.instance.self)}catch(l){console.error("[lips:ir]",l)}});this.emit("component:mount")}emit(t,...e){return this.instance?.self?.emitLocal?.(t,...e),super.emit(t,...e)}get node(){return this.instance.nodes.filter((t)=>t.nodeType===1)}appendTo(t){let e=typeof t==="string"?document.querySelector(t):t;return e&&this.instance.mount(e),this}swap(t){return this.instance.swap(t)}destroy(){if(this.destroyed)return;this.destroyed=!0,this.contextWatcher?.(),this.instance.dispose(),this.emit("component:destroy")}}class de{config;debug;store=new Map;irCache=new WeakMap;defCache=new WeakMap;styleCache=new WeakMap;context;__root;u;i18n;getLang;setLang;getRev;componentsProxy;constructor(t){this.config=t;if(this.u=t?.untrusted,this.debug=!!t?.debug,this.context=Z({...t?.context||{}},!0),this.i18n=new Bt(t?.lang,t?.messageFormat??on),this.debug)this.i18n.onMissing=(a,o)=>console.warn(`[lips:i18n] no <${o}> entry for key "${a}"`),this.i18n.onError=(a,o,c)=>console.warn(`[lips:i18n] <${c}> message "${o}" —`,a);let[e,n]=F(this.i18n.lang);this.getLang=e,this.setLang=n;let[r,s]=F(0);this.getRev=r,this.i18n.onChange=()=>s(r()+1),Ft&&Object.entries(cn).forEach(([a,o])=>this.register(a,o));let i=this;this.componentsProxy=new Proxy({},{get(a,o){let c=i.store.get(o);return c?i.defFor(o,c):void 0},has(a,o){return i.store.has(o)}})}register(t,e){return this.store.set(t,e),this}unregister(t){return this.store.delete(t),this}has(t){return this.store.has(t)}compile(t){if(t.ir)return t.ir;let e=this.irCache.get(t);if(!e){if(!Ft)throw Error("This build has no template compiler — templates must be precompiled to `ir` "+'(import from "@lipsjs/lips" instead of "@lipsjs/lips/runtime")');let n=Ft(t.default||"",{macros:t.macros,check:this.u?.check});n.diagnostics.length&&console.warn("[lips:ir] template diagnostics —",n.diagnostics),e=n.ir,this.irCache.set(t,e)}return e}styleFor(t,e){if(e.style)return e.style;if(!e.stylesheet)return;if(!Ht){console.warn(`[lips:ir] <${t}> stylesheet skipped — this build has no style compiler. `+'Precompile it to StyleIR, or import "@lipsjs/lips" instead of "@lipsjs/lips/runtime".');return}let n=this.styleCache.get(e);if(!n){let r=(this.u?this.u.style(Ht):Ht)(e.stylesheet,{nsp:t,layer:this.config?.styleLayer,preprocess:this.config?.stylePreprocessor});r.diagnostics.length&&console.warn("[lips:ir] style diagnostics —",r.diagnostics),n=r.ir,this.styleCache.set(e,n)}return n}defFor(t,e){let n=this.defCache.get(e);if(!n)n={ir:this.compile(e),state:e.state,statics:e.static??e._static,context:e.watchContext??e.context,stylesheet:this.styleFor(t,e),nsp:t,handlers:pn(e.handler),deep:!0},this.defCache.set(e,n);return n}render(t,e,n){let r={mode:this.config?.mode,components:this.componentsProxy,resolveTemplate:(s)=>s&&(typeof s.default==="string"||s.ir)?this.defFor(s.name||"dynamic",s):void 0,expose:{setContext:(s,i)=>this.setContext(s,i),setLanguage:(s)=>this.setLanguage(s)},createStylesheet:(s,i)=>{let a=new Dt(s,{sheet:i});return{clear:()=>a.clear()}},i18n:{translate:(s,i,a)=>{let o=this.getLang();return this.getRev(),this.i18n.translate(s,a||o,i).text},format:(s,i,a)=>{let o=this.getLang();return this.getRev(),this.i18n.format(s,i,a||o)??""},lang:()=>this.getLang()}};return new un(this,t,e,n,this.compile(e),this.u?this.u.runtime(r):r)}root(t,e){return this.__root=this.render("__ROOT__",t),this.__root.appendTo(e),this.__root}setLanguage(t){return this.i18n.lang=t,this.setLang(t),this.i18n.load(t),this}getLanguage(){return this.getLang()}useTranslator(t,e){let n=!0,{dispose:r}=A(()=>{let s=this.getLang();if(n){n=!1;return}(t==="*"||Array.isArray(t)&&t.includes(s))&&e(s)});return r}get ctx(){return this.context}getContext(){return this.context}setContext(t,e){typeof t==="string"?this.ctx[t]=e:Object.entries(t).forEach(([n,r])=>this.ctx[n]=r)}watchContext(t,e){let n=!0,{dispose:r}=A(()=>{t.forEach((s)=>this.ctx[s]),n?n=!1:e()});return r}useContext(t,e){return this.watchContext(t,()=>e(Object.fromEntries(t.map((n)=>[n,this.ctx[n]]))))}dispose(){this.__root?.destroy()}}var ur=globalThis,Vt=ur.Intl??={},fn=(t)=>(Array.isArray(t)?t:t?[t]:[]).map(String),ye=(t)=>class{options;constructor(e,n){this.options={...n,locale:fn(e)[0]??"und"}}static supportedLocalesOf(e){return fn(e)}resolvedOptions(){return this.options}format(e){return t(e)}formatToParts(e){return[{type:"literal",value:t(e)}]}select(){return"other"}};Vt.Locale??=class{baseName;language;constructor(t){this.baseName=String(t),this.language=this.baseName.split("-")[0]}maximize(){return this}toString(){return this.baseName}};Vt.NumberFormat??=ye(String);Vt.PluralRules??=ye(String);Vt.DateTimeFormat??=ye((t)=>{let e=new Date(t);return isNaN(e.getTime())?String(t):e.toISOString()});var hn=/^[\u061c\u200e\u200f\u2066-\u2069]+/,gn=/^[-.+0-9A-Z_a-z\u{a1}-\u{61b}\u{61d}-\u{167f}\u{1681}-\u{1fff}\u{200b}-\u{200d}\u{2010}-\u{2027}\u{2030}-\u{205e}\u{2060}-\u{2065}\u{206a}-\u{2fff}\u{3001}-\u{d7ff}\u{e000}-\u{fdcf}\u{fdf0}-\u{fffd}\u{10000}-\u{1fffd}\u{20000}-\u{2fffd}\u{30000}-\u{3fffd}\u{40000}-\u{4fffd}\u{50000}-\u{5fffd}\u{60000}-\u{6fffd}\u{70000}-\u{7fffd}\u{80000}-\u{8fffd}\u{90000}-\u{9fffd}\u{a0000}-\u{afffd}\u{b0000}-\u{bfffd}\u{c0000}-\u{cfffd}\u{d0000}-\u{dfffd}\u{e0000}-\u{efffd}\u{f0000}-\u{ffffd}\u{100000}-\u{10fffd}]+/u,fr=/^[-.0-9]/;function mn(t,e){let n=e,r=t.slice(n).match(hn);if(r)n+=r[0].length;let s=t.slice(n).match(gn);if(!s)return null;let i=s[0];if(fr.test(i))return null;n+=i.length;let a=t.slice(n).match(hn);if(a)n+=a[0].length;return{value:i.normalize(),end:n}}var dn=(t,e)=>t.slice(e).match(gn)?.[0]??"";var yn=Symbol.for("CST");class nt extends Error{type;constructor(t,e){super(e);this.type=t}}class ct extends nt{start;end;constructor(t,e,n,r){let s=r?`Missing ${r}`:t;if(e>=0)s+=` at ${e}`;super(t,s);this.start=e,this.end=n??e+1}}class Ut extends ct{constructor(t,e){let{start:n,end:r}=e[yn]??{start:-1,end:-1};super(t,n,r)}}class G extends nt{source;cause;constructor(t,e,n,r){super(t,e);if(this.source=n,r!==void 0)this.cause=r}}class L extends nt{source;cause;constructor(t,e){super(t,e);this.source="�"}}var bn=new Set(""),xn=new Set(`
|
|
4
|
+
\r `),y,w,xt=(t,e)=>new ct("missing-syntax",t,t+e.length,e),W=(...t)=>new ct(...t);function gt(t,e){if(w.startsWith(t,y)){if(e)y+=t.length}else throw xt(y,t)}function be(t){y=0,w=t;let e=mr();if(w.startsWith(".match",y))return hr(e);let n=e.length>0||w.startsWith("{{",y);if(!n&&y>0)y=0;let r=kn(n);if(n){if(_(),y<w.length)throw W("extra-content",y,w.length)}return{type:"message",declarations:e,pattern:r}}function hr(t){y+=6,_(!0);let e=[];while(w[y]==="$")e.push(En()),_(!0);if(e.length===0)throw W("empty-token",y);let n=[];while(y<w.length)n.push(gr()),_();return{type:"select",declarations:t,selectors:e,variants:n}}function gr(){let t=[];while(y<w.length){_(t.length?"{":!1);let e=w[y];if(e==="{")break;if(e==="*")t.push({type:"*"}),y+=1;else{let n=ve(!0);n.value=n.value.normalize(),t.push(n)}}return{keys:t,value:kn(!0)}}function kn(t){if(t)if(w.startsWith("{{",y))y+=2;else throw xt(y,"{{");let e=[];t:while(y<w.length)switch(w[y]){case"{":{e.push(xe(!0));break}case"}":if(!t)throw W("parse-error",y);break t;default:e.push(xr())}if(t)if(w.startsWith("}}",y))y+=2;else throw xt(y,"}}");return e}function mr(){let t=[];_();t:while(w[y]==="."){switch(w.substr(y,6)){case".input":t.push(dr());break;case".local":t.push(yr());break;case".match":break t;default:throw W("parse-error",y)}_()}return t}function dr(){y+=6,_(),gt("{",!1);let t=y,e=xe(!1);if(e.type==="expression"&&e.arg?.type==="variable")return{type:"input",name:e.arg.name,value:e};throw W("bad-input-expression",t,y)}function yr(){y+=6,_(!0),gt("$",!0);let t=qt();_(),gt("=",!0),_(),gt("{",!1);let e=xe(!1);return{type:"local",name:t,value:e}}function xe(t){let e=y;y+=1,_();let n=Sn(!1);if(n)_("}");let r=w[y],s,i;switch(r){case"@":case"}":break;case":":{y+=1,s={type:"function",name:Wt()};let o=vn();if(o)s.options=o;break}case"#":case"/":{if(n||!t)throw W("parse-error",y);y+=1,i={type:"markup",kind:r==="#"?"open":"close",name:Wt()};let c=vn();if(c)i.options=c;break}default:throw W("parse-error",y)}let a=br();if(i?.kind==="open"&&w[y]==="/")i.kind="standalone",y+=1;if(gt("}",!0),s){let o=n?{type:"expression",arg:n,functionRef:s}:{type:"expression",functionRef:s};if(a)o.attributes=a;return o}if(i){if(a)i.attributes=a;return i}if(!n)throw W("empty-token",e,y);return a?{type:"expression",arg:n,attributes:a}:{type:"expression",arg:n}}function vn(){_("/}");let t={},e=!0;while(y<w.length){let n=w[y];if(n==="@"||n==="/"||n==="}")break;let r=y,s=Wt();if(Object.hasOwn(t,s))throw W("duplicate-option-name",r,y);_(),gt("=",!0),_(),t[s]=Sn(!0),e=!1,_("/}")}return e?null:t}function br(){let t={},e=!0;while(w[y]==="@"){let n=y;y+=1;let r=Wt();if(Object.hasOwn(t,r))throw W("duplicate-attribute",n,y);if(_("=/}"),w[y]==="=")y+=1,_(),t[r]=ve(!0),_("/}");else t[r]=!0;e=!1}return e?null:t}function xr(){let t="",e=y;t:for(;e<w.length;++e)switch(w[e]){case"\\":{let n=w[e+1];if(!"\\{|}".includes(n))throw W("bad-escape",e,e+2);t+=w.substring(y,e)+n,e+=1,y=e+1;break}case"{":case"}":break t}return t+=w.substring(y,e),y=e,t}function Sn(t){return w[y]==="$"?En():ve(t)}function En(){return y+=1,{type:"variable",name:qt()}}function ve(t){if(w[y]==="|")return vr();let e=dn(w,y);if(!e)if(t)throw W("empty-token",y);else return;return y+=e.length,{type:"literal",value:e}}function vr(){y+=1;let t="";for(let e=y;e<w.length;++e)switch(w[e]){case"\\":{let n=w[e+1];if(!"\\{|}".includes(n))throw W("bad-escape",e,e+2);t+=w.substring(y,e)+n,e+=1,y=e+1;break}case"|":return t+=w.substring(y,e),y=e+1,{type:"literal",value:t}}throw xt(w.length,"|")}function Wt(){let t=qt();if(w[y]===":")return y+=1,t+":"+qt();return t}function qt(){let t=mn(w,y);if(!t)throw W("empty-token",y);return y=t.end,t.value}function _(t=!1){let e=w[y],n=!1;if(t){while(bn.has(e))e=w[++y];while(xn.has(e))e=w[++y],n=!0}while(bn.has(e)||xn.has(e))e=w[++y];if(t&&!n&&(t===!0||!t.includes(w[y])))throw xt(y,"' '")}function ke(t,e){let{node:n,pattern:r}=e,{functionRef:s=n,attributes:i=null,declaration:a=n,expression:o=n,key:c=n,markup:p=n,options:l=null,value:u=n,variant:f=n}=e,m=(h,x)=>{if(h){let R=l?.(h,x);if(u)for(let C of Object.values(h))u(C,x,"option");R?.()}},g=(h,x)=>{if(h){let R=i?.(h,x);if(u){for(let C of Object.values(h))if(C!==!0)u(C,x,"attribute")}R?.()}},b=(h,x)=>{if(typeof h==="object"){let R;switch(h.type){case"expression":{if(R=o?.(h,x),h.arg)u?.(h.arg,x,"arg");if(h.functionRef){let C=s?.(h.functionRef,x,h.arg);m(h.functionRef.options,x),C?.()}g(h.attributes,x);break}case"markup":{R=p?.(h,x),m(h.options,x),g(h.attributes,x);break}}R?.()}},k=(h)=>{let x=r?.(h);for(let R of h)b(R,"placeholder");x?.()};for(let h of t.declarations){let x=a?.(h);if(h.value)b(h.value,"declaration");x?.()}if(t.type==="message")k(t.pattern);else{if(u)for(let h of t.selectors)u(h,"selector","arg");for(let h of t.variants){let x=f?.(h);if(c)h.keys.forEach(c);k(h.value),x?.()}}}function Se(t,e=(n,r)=>{throw new Ut(n,r)}){let n=0,r=null,s=new Set,i=new Set,a=new Set,o=new Set,c=new Set,p=new Set,l=!0;if(ke(t,{declaration(u){if(!u.name)return;if(u.value.functionRef||u.type==="local"&&u.value.arg?.type==="variable"&&s.has(u.value.arg.name))s.add(u.name);if(u.type==="local")o.add(u.name);return l=u.type==="local",()=>{if(i.has(u.name))e("duplicate-declaration",u);else i.add(u.name)}},expression({functionRef:u}){if(u)a.add(u.name)},value(u,f,m){if(u.type!=="variable")return;switch(c.add(u.name),f){case"declaration":if(m!=="arg"||l)i.add(u.name);break;case"selector":if(n+=1,r=u,!s.has(u.name))e("missing-selector-annotation",u)}},variant(u){let{keys:f}=u;if(f.length!==n)e("key-mismatch",u);let m=JSON.stringify(f.map((g)=>g.type==="literal"?g.value:0));if(p.has(m))e("duplicate-variant",u);else p.add(m);r&&=f.every((g)=>g.type==="*")?null:u}}),r)e("missing-fallback",r);for(let u of o)c.delete(u);return{functions:a,variables:c}}var Ee="",we="",vt="",kt="";function rt(t){if(t)try{if(typeof t==="string")t=new Intl.Locale(t);let e=t.getTextInfo?.()??t.textInfo;if(e?.direction)return e.direction;let n=t.maximize().script;if(n)return"Adlm,Arab,Hebr,Mand,Nkoo,Rohg,Syrc,Thaa".includes(n)?"rtl":"ltr"}catch{}return"auto"}function Ie(t){if(t&&typeof t==="object")t=t.valueOf();if(typeof t==="boolean")return t;if(t&&typeof t==="object")t=String(t);if(t==="true")return!0;if(t==="false")return!1;throw RangeError("Not a boolean")}function q(t){if(t&&typeof t==="object")t=t.valueOf();if(t&&typeof t==="object")t=String(t);if(typeof t==="string"&&/^(0|[1-9][0-9]*)$/.test(t))t=Number(t);if(typeof t==="number"&&t>=0&&Number.isInteger(t))return t;throw RangeError("Not a positive integer")}function H(t){if(t&&typeof t==="object")t=t.valueOf();if(typeof t==="string")return t;if(t&&typeof t==="object")return String(t);throw RangeError("Not a string")}function Q(t){let e=void 0;if(typeof t==="object"){let n=t?.valueOf;if(typeof n==="function")e=t.options,t=n.call(t)}if(typeof t==="string")try{t=JSON.parse(t)}catch{}if(typeof t!=="bigint"&&typeof t!=="number")throw new L("bad-operand","Input is not numeric");return{value:t,options:e}}function st(t,e,n,r){let{dir:s,locales:i}=t;if(n.useGrouping==="never")n.useGrouping=!1;if(r&&"select"in n&&!t.literalOptionKeys.has("select"))t.onError("bad-option","The option select may only be set by a literal value"),r=!1;let a,o,c,p;return{type:"number",get dir(){if(s==null)a??=Intl.NumberFormat.supportedLocalesOf(i,n)[0],s=rt(a);return s},get options(){return{...n}},selectKey:r?(l)=>{let u=e;if(n.style==="percent")if(typeof u==="bigint")u*=100n;else u*=100;let f=String(u);if(l.has(f))return f;if(n.select==="exact")return null;let m=n.select?{...n,select:void 0,type:n.select}:n;return c??=new Intl.PluralRules(i,m).select(Number(u)),l.has(c)?c:null}:void 0,toParts(){o??=new Intl.NumberFormat(i,n);let l=o.formatToParts(e);return a??=o.resolvedOptions().locale,s??=rt(a),s==="ltr"||s==="rtl"?[{type:"number",dir:s,locale:a,parts:l}]:[{type:"number",locale:a,parts:l}]},toString(){return o??=new Intl.NumberFormat(i,n),p??=o.format(e),p},valueOf:()=>e}}function Kt(t,e,n){let r=Q(n),s=r.value,i=Object.assign({},r.options,{localeMatcher:t.localeMatcher,style:"decimal"});for(let[a,o]of Object.entries(e)){if(o===void 0)continue;try{switch(a){case"minimumIntegerDigits":case"minimumFractionDigits":case"maximumFractionDigits":case"minimumSignificantDigits":case"maximumSignificantDigits":case"roundingIncrement":i[a]=q(o);break;case"roundingMode":case"roundingPriority":case"select":case"signDisplay":case"trailingZeroDisplay":case"useGrouping":i[a]=H(o)}}catch{t.onError("bad-option",`Value ${o} is not valid for :number option ${a}`)}}return st(t,s,i,!0)}function wn(t,e,n){let r=Q(n),s=Number.isFinite(r.value)?Math.round(r.value):r.value,i=Object.assign({},r.options,{maximumFractionDigits:0,minimumFractionDigits:void 0,minimumSignificantDigits:void 0,style:"decimal"});for(let[a,o]of Object.entries(e)){if(o===void 0)continue;try{switch(a){case"minimumIntegerDigits":case"maximumSignificantDigits":i[a]=q(o);break;case"select":case"signDisplay":case"useGrouping":i[a]=H(o)}}catch{t.onError("bad-option",`Value ${o} is not valid for :integer option ${a}`)}}return st(t,s,i,!0)}function In(t,e,n){let r=Q(n),s=Object.assign({},r.options,{localeMatcher:t.localeMatcher,style:"currency"});for(let[i,a]of Object.entries(e)){if(a===void 0)continue;try{switch(i){case"currency":case"currencySign":case"roundingMode":case"roundingPriority":case"trailingZeroDisplay":case"useGrouping":s[i]=H(a);break;case"minimumIntegerDigits":case"minimumSignificantDigits":case"maximumSignificantDigits":case"roundingIncrement":s[i]=q(a);break;case"currencyDisplay":{let o=H(a);if(o==="never")t.onError("unsupported-operation",'Currency display "never" is not yet supported');else s[i]=o;break}case"fractionDigits":{let o=H(a);if(o==="auto")s.minimumFractionDigits=void 0,s.maximumFractionDigits=void 0;else{let c=q(o);s.minimumFractionDigits=c,s.maximumFractionDigits=c}break}}}catch{t.onError("bad-option",`Value ${a} is not valid for :currency option ${i}`)}}if(!s.currency)throw new L("bad-operand","A currency code is required for :currency");return st(t,r.value,s,!1)}var Ir=new Set(["weekday","day-weekday","month-day","month-day-weekday","year-month-day","year-month-day-weekday"]),Rr=new Set(["long","medium","short"]),Cr=new Set(["hour","minute","second"]),Tr=new Set(["long","short"]),Rn=(t,e,n)=>Re("datetime",t,e,n),Cn=(t,e,n)=>Re("date",t,e,n),Tn=(t,e,n)=>Re("time",t,e,n);function Re(t,e,n,r){let s={localeMatcher:e.localeMatcher},i=r;if(typeof i==="object"&&i!==null){let l=i.options;if(l){if(s.calendar=l.calendar,t!=="date")s.hour12=l.hour12;s.timeZone=l.timeZone}if(typeof i.valueOf==="function")i=i.valueOf()}switch(typeof i){case"number":case"string":i=new Date(i)}if(!(i instanceof Date)||isNaN(i.getTime()))throw new L("bad-operand","Input is not a valid date");if(n.calendar!==void 0)try{s.calendar=H(n.calendar)}catch{e.onError("bad-option",`Invalid :${t} calendar option value`)}if(n.hour12!==void 0&&t!=="date")try{s.hour12=Ie(n.hour12)}catch{e.onError("bad-option",`Invalid :${t} hour12 option value`)}if(n.timeZone!==void 0){let l;try{l=H(n.timeZone)}catch{e.onError("bad-option",`Invalid :${t} timeZone option value`)}if(l==="input"){if(s.timeZone===void 0)e.onError("bad-operand",`Missing input timeZone value for :${t}`)}else if(l!==void 0){if(s.timeZone!==void 0&&l!==s.timeZone)throw new L("bad-option","Time zone conversion is not supported");s.timeZone=l}}if(t!=="time"){let l=t==="date"?"fields":"dateFields",u=t==="date"?"length":"dateLength",f=Zt(e,n,l,Ir)??"year-month-day",m=Zt(e,n,u,Rr),g=new Set(f.split("-"));if(g.has("year"))s.year="numeric";if(g.has("month"))s.month=m==="long"?"long":m==="short"?"numeric":"short";if(g.has("day"))s.day="numeric";if(g.has("weekday"))s.weekday=m==="long"?"long":"short"}if(t!=="date"){switch(Zt(e,n,t==="time"?"precision":"timePrecision",Cr)){case"hour":s.hour="numeric";break;case"second":s.hour="numeric",s.minute="numeric",s.second="numeric";break;default:s.hour="numeric",s.minute="numeric"}s.timeZoneName=Zt(e,n,"timeZoneStyle",Tr)}let a=new Intl.DateTimeFormat(e.locales,s),o=e.dir,c,p;return{type:"datetime",get dir(){if(o==null)c??=a.resolvedOptions().locale,o=rt(c);return o},get options(){return{...s}},toParts(){let l=a.formatToParts(i);return c??=a.resolvedOptions().locale,o??=rt(c),o==="ltr"||o==="rtl"?[{type:"datetime",dir:o,locale:c,parts:l}]:[{type:"datetime",locale:c,parts:l}]},toString(){return p??=a.format(i),p},valueOf:()=>i}}function Zt(t,e,n,r){let s=e[n];if(s!==void 0)try{let i=H(s);if(r&&!r.has(i))throw Error();return i}catch{t.onError("bad-option",`Invalid value for ${n} option`)}return}function Mn(t,e,n){let{value:r,options:s}=Q(n),i;try{i="add"in e?q(e.add):-1}catch{throw new L("bad-option",`Value ${e.add} is not valid for :offset option add`)}let a;try{a="subtract"in e?q(e.subtract):-1}catch{throw new L("bad-option",`Value ${e.subtract} is not valid for :offset option subtract`)}if(i<0===a<0)throw new L("bad-option",'Exactly one of "add" or "subtract" is required as an :offset option');let o=i<0?-a:i;if(typeof r==="number")r+=o;else r+=BigInt(o);return Kt(t,{},{valueOf:()=>r,options:s})}function Pn(t,e,n){let r=Q(n),s=Object.assign({},r.options,{localeMatcher:t.localeMatcher,style:"percent"});for(let[i,a]of Object.entries(e)){if(a===void 0)continue;try{switch(i){case"roundingMode":case"roundingPriority":case"signDisplay":case"trailingZeroDisplay":case"useGrouping":s[i]=H(a);break;case"minimumFractionDigits":case"maximumFractionDigits":case"minimumSignificantDigits":case"maximumSignificantDigits":s[i]=q(a);break}}catch{t.onError("bad-option",`Value ${a} is not valid for :percent option ${i}`)}}return st(t,r.value,s,!0)}function Gt(t,e,n){let r=n===void 0?"":String(n),s=r.normalize();return{type:"string",dir:t.dir??"auto",selectKey:(i)=>i.has(s)?s:null,toParts(){let{dir:i}=t,a=t.locales[0];return i==="ltr"||i==="rtl"?[{type:"string",dir:i,locale:a,value:r}]:[{type:"string",locale:a,value:r}]},toString:()=>r,valueOf:()=>r}}function On(t,e,n){let r=Q(n),s=Object.assign({},r.options,{localeMatcher:t.localeMatcher,style:"unit"});for(let[i,a]of Object.entries(e)){if(a===void 0)continue;try{switch(i){case"signDisplay":case"roundingMode":case"roundingPriority":case"trailingZeroDisplay":case"unit":case"unitDisplay":case"useGrouping":s[i]=H(a);break;case"minimumIntegerDigits":case"minimumFractionDigits":case"maximumFractionDigits":case"minimumSignificantDigits":case"maximumSignificantDigits":case"roundingIncrement":s[i]=q(a);break}}catch(o){if(o instanceof nt)t.onError(o);else t.onError("bad-option",`Value ${a} is not valid for :currency option ${i}`)}}if(!s.unit)throw new L("bad-operand","A unit identifier is required for :unit");return st(t,r.value,s,!1)}var St={currency:In,integer:wn,number:Kt,offset:Mn,percent:Pn,string:Gt};St=Object.freeze(Object.assign(Object.create(null),St));var zt={date:Cn,datetime:Rn,time:Tn,unit:On};zt=Object.freeze(Object.assign(Object.create(null),zt));var Et=Symbol("bidi-isolate");var wt=(t="�")=>({type:"fallback",source:t,toParts:()=>[{type:"fallback",source:t}],toString:()=>`{${t}}`});var Ln=(t,e)=>({type:"unknown",source:t,dir:"auto",toParts:()=>[{type:"unknown",value:e}],toString:()=>String(e),valueOf:()=>e});class lt{#t;#e;#n;dir;id;constructor(t,e,n){this.#t=t,this.#n=e,this.dir=void 0;let r=n&&Object.hasOwn(n,"u:dir")?n["u:dir"]:void 0;if(r){let i=String(it(t,r));if(i==="ltr"||i==="rtl"||i==="auto")this.dir=i;else if(i!=="inherit"){let a=new L("bad-option","Unsupported value for u:dir option");a.source=mt(r),t.onError(a)}}let s=n&&Object.hasOwn(n,"u:id")?n["u:id"]:void 0;if(this.id=s?String(it(t,s)):void 0,n){this.#e=new Set;for(let[i,a]of Object.entries(n))if(a.type==="literal")this.#e.add(i)}}get literalOptionKeys(){return new Set(this.#e)}get localeMatcher(){return this.#t.localeMatcher}get locales(){return this.#t.locales.map(String)}onError(t,e){let n;if(t instanceof L)n=t;else if(typeof t==="string"&&typeof e==="string")n=new L(t,e);else n=new L("function-error",String(t)),n.cause=t;n.source=this.#n,this.#t.onError(n)}}function Nn(t,e,{name:n,options:r}){let s=`:${n}`,i=mt(e)??s;try{let a=e?[it(t,e)]:[],o=t.functions[n];if(!o)throw new G("unknown-function",`Unknown function ${s}`,i);let c=new lt(t,i,r),p=Mr(t,r),l=o(c,p,...a);if(l===null||typeof l!=="object"||typeof l.type!=="string")throw new G("bad-function-result",`Function ${s} did not return a MessageValue`,i);let u={source:i};if(c.dir)u.dir=c.dir,u[Et]=!0;if(c.id&&typeof l.toParts==="function")u.toParts=()=>{let f=l.toParts();for(let m of f)m.id=c.id;return f};return{...l,...u}}catch(a){return t.onError(a instanceof nt?a:new G("bad-function-result",String(a),i,a)),wt(i)}}function Mr(t,e){let n=Object.create(null);if(e){for(let[r,s]of Object.entries(e))if(!r.startsWith("u:"))n[r]=it(t,s)}return n}function It(t,{arg:e,functionRef:n}){if(n)return Nn(t,e,n);switch(e?.type){case"literal":{let r=`|${e.value}|`,s=new lt(t,r),i=Gt(s,{},e.value);return i.source=r,i}case"variable":return Jt(t,e);default:throw Error(`Unsupported expression: ${e?.type}`)}}class Yt{expression;scope;constructor(t,e){this.expression=t,this.scope=e}}var Pr=(t)=>t!==null&&(typeof t==="object"||typeof t==="function");function $n(t,e){if(Pr(t)){if(e in t)return t[e];let n=e.split(".");for(let r=n.length-1;r>0;--r){let s=n.slice(0,r).join(".");if(s in t){let i=n.slice(r).join(".");return $n(t[s],i)}}for(let[r,s]of Object.entries(t))if(r.normalize()===e)return s}return}function Ce(t,{name:e}){let n=$n(t.scope,e);if(n===void 0){let r="$"+e,s=`Variable not available: ${r}`;t.onError(new G("unresolved-variable",s,r))}else if(n instanceof Yt){let r=It(n.scope?{...t,scope:n.scope}:t,n.expression);return t.scope[e]=r,t.localVars.add(r),r}return n}function Jt(t,e){let n="$"+e.name,r=Ce(t,e);if(r===void 0)return wt(n);let s=typeof r;if(s==="object"){let c=r;if(c.type==="fallback")return wt(n);if(t.localVars.has(c))return c.source=n,c;if(r instanceof Number)s="number";else if(r instanceof String)s="string"}let i;switch(s){case"bigint":case"number":i=t.functions.number;break;case"string":i=t.functions.string;break;default:return Ln(n,r)}let a=new lt(t,n),o=i(a,{},r);return o.source=n,o}function it(t,e){switch(e.type){case"literal":return e.value;case"variable":return Ce(t,e);default:throw Error(`Unsupported value: ${e.type}`)}}function mt(t){switch(t?.type){case"literal":return"|"+t.value.replaceAll("\\","\\\\").replaceAll("|","\\|")+"|";case"variable":return"$"+t.name;default:return}}function Te(t,{kind:e,name:n,options:r}){let s={type:"markup",kind:e,name:n},i=r?Object.entries(r):null;if(i?.length){s.options={};for(let[a,o]of i)if(a==="u:dir"){let c=new L("bad-option",`The option ${a} is not valid for markup`);c.source=mt(o),t.onError(c)}else{let c=it(t,o);if(typeof c==="object"&&typeof c?.valueOf==="function")c=c.valueOf();if(a==="u:id")s.id=String(c);else s.options[a]=c}}return s}function Me(t,e){if(e.type==="message")return e.pattern;let n=e.selectors.map((i)=>{let a=Jt(t,i),o;if(typeof a.selectKey==="function")o=a.selectKey.bind(a);else t.onError(new G("bad-selector","Selector does not support selection",a.source)),o=()=>null;return{selectKey:o,source:a.source,best:null,keys:null}}),r=e.variants;t:for(let i=0;i<n.length;++i){let a=n[i];if(!a.keys){a.keys=new Set;for(let{keys:o}of r){let c=o[i];if(!c)break t;if(c.type!=="*")a.keys.add(c.value)}}try{a.best=a.keys.size?a.selectKey(a.keys):null}catch(o){t.onError(new G("bad-selector","Selection failed",a.source,o)),a.selectKey=()=>null,a.best=null}if(r=r.filter((o)=>{let c=o.keys[i];if(c.type==="*")return a.best==null;return a.best===c.value}),r.length===0){if(i===0)break;let o=n[i-1];if(o.best==null)o.keys?.clear();else o.keys?.delete(o.best);for(let c=i;c<n.length;++c)n[c].keys=null;r=e.variants,i=-1}}let s=r[0];if(!s)return t.onError(new G("no-match","No variant was selected!?",".match")),[];return s.value}class Qt{#t;#e;#n;#s;#r;#i;constructor(t,e,n){this.#t=n?.bidiIsolation!=="none",this.#n=n?.localeMatcher??"best fit",this.#s=Array.isArray(t)?t.map((r)=>new Intl.Locale(r)):t?[new Intl.Locale(t)]:[],this.#e=n?.dir??rt(this.#s[0]),this.#r=typeof e==="string"?be(e):e,Se(this.#r),this.#i=n?.functions?Object.assign(Object.create(null),St,n.functions):St}format(t,e){let n=this.#o(t,e),r="";for(let s of Me(n,this.#r))if(typeof s==="string")r+=s;else if(s.type==="markup")Te(n,s);else{let i;try{if(i=It(n,s),typeof i.toString==="function")if(this.#t&&(this.#e!=="ltr"||i.dir!=="ltr"||i[Et])){let a=i.dir==="ltr"?Ee:i.dir==="rtl"?we:vt;r+=a+i.toString()+kt}else r+=i.toString();else{let a=new L("not-formattable","Message part is not formattable");throw a.source=i.source,a}}catch(a){n.onError(a);let o=`{${i?.source??"�"}}`;r+=this.#t?vt+o+kt:o}}return r}formatToParts(t,e){let n=this.#o(t,e),r=[];for(let s of Me(n,this.#r))if(typeof s==="string")r.push({type:"text",value:s});else if(s.type==="markup")r.push(Te(n,s));else{let i;try{if(i=It(n,s),typeof i.toParts==="function"){let a=i.toParts();if(this.#t&&(this.#e!=="ltr"||i.dir!=="ltr"||i[Et])){let o=i.dir==="ltr"?Ee:i.dir==="rtl"?we:vt;r.push({type:"bidiIsolation",value:o},...a,{type:"bidiIsolation",value:kt})}else r.push(...a)}else{let a=new L("not-formattable","Message part is not formattable");throw a.source=i.source,a}}catch(a){n.onError(a);let o={type:"fallback",source:i?.source??"�"};if(this.#t)r.push({type:"bidiIsolation",value:vt},o,{type:"bidiIsolation",value:kt});else r.push(o)}}return r}#o(t,e=(n)=>{try{process.emitWarning(n)}catch{console.warn(n)}}){let n={...t};for(let s of this.#r.declarations)n[s.name]=new Yt(s.value,s.type==="input"?t??{}:void 0);return{onError:e,localeMatcher:this.#n,locales:this.#s,localVars:new WeakSet,functions:this.#i,scope:n}}}var jn={MessageFormat:Qt,functions:zt};var Or=null;var Lr=/^[-\w]+$/,Fn=/^(%|[a-zA-Z]+)/,An=["<number>","0"];function te(t,e){let n=t[e];e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===n)return e+1;e++}return e}function Hn(t,e){let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function Nr(t,e){let n=t.indexOf(`
|
|
5
|
+
`,e+2);return n<0?t.length:n}var $r=(t)=>t.replace(/["\\]/g,"\\$&");function Xt(t,e,n){let r=1,s=-1;for(let i=0;i<e;i++)if(t[i]===`
|
|
6
|
+
`)r++,s=i;return{line:r,col:e-s,offset:e,length:n}}function Pe(t,e){let n=e+1,r=0,s=!1,i=!1;while(n<t.length){let o=t[n];if(o==='"'||o==="'"){n=te(t,n);continue}if(o==="{"||o===";")return null;if(o==="}")break;if(o==="("||o==="[")r++;else if(o===")"||o==="]")r--;else if(r===0){if(o==="?")s=!0;else if(o===":"&&!s)i=!0}n++}if(n>=t.length||i)return null;let a=t.slice(e+1,n).trim();return a?{end:n,expr:a}:null}var jr=new Set(["state","input","static","context","self"]);function Ar(t,e,n,r){let s=[],i=e,a=e,o=0;while(i<t.length){let c=t[i];if(c==='"'||c==="'"){i=te(t,i);continue}if(c==="/"&&t[i+1]==="*"){let p=Hn(t,i);if(!n)s.push(t.slice(a,i)," "),a=p;i=p;continue}if(c==="("){o++,i++;continue}if(c===")"){o--,i++;continue}if(o===0&&(c===";"||c==="}"))return s.push(t.slice(a,i)),{end:i,parts:s};if(c==="{"){let p=Pe(t,i);if(!p)return t.indexOf("}",i+1)<0&&r?.(i),null;s.push(t.slice(a,i));let l=Fn.exec(t.slice(p.end+1)),u=l?l[1]:"";s.push({expr:p.expr,unit:u,at:i}),i=p.end+1+u.length,a=i;continue}i++}return s.some((c)=>typeof c!=="string")&&r?.(e),null}var _r=/^@(-\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\b/i,_n=/^@(import|charset|namespace)\b/i,Dr=/^@(media|supports|container|layer|scope|starting-style|document)\b/i,Br=/^([a-zA-Z_*\\]|[^\x00-\x7f])/,Fr=/^(?:[-\w*|]|[^\x00-\x7f]|\\[\s\S])+/,Hr=/&[-_]/,Vn=/\s/,Dn=/[{};]/,Bn=/[-\w]/,Un=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,Vr=new RegExp(`(${Un.source})|\\s+`,"g"),Ur=/\/\*[\s\S]*?\*\//g,Wr=/^@layer\b/i,qr=(t)=>t.replace(Vr,(e,n)=>n||" ");function Kr(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s++){let i=t[s];if(i==="\\"){s++;continue}if(i==='"'||i==="'"){s=te(t,s)-1;continue}if(i==="("||i==="[")r++;else if(i===")"||i==="]")r--;else if(i===","&&!r)e.push(t.slice(n,s)),n=s+1}return e.push(t.slice(n)),e.map((s)=>{let i=s.trimStart(),a=i.length;while(a&&Vn.test(i[a-1])&&i[a-2]!=="\\")a--;if(i=i.slice(0,a),!Br.test(i))return i;return i.includes("&")?i.replace(Fr,":is($&)"):`& ${i}`}).join(",")}function Zr(t,e,n,r){let s=[],i=[],a=[],o=`--${e.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}`,c=(S,O,I,T,N)=>r.push({code:S,severity:"error",message:O,hint:N,loc:Xt(t,I,T)}),p=(S,O,I,T,N)=>r.push({code:S,severity:"warning",message:O,hint:N,loc:Xt(t,I,T)}),l=(S,O,I,T)=>e.lint?.(S,T)?.forEach((N)=>r.push({...N,loc:Xt(t,O,I-O)})),u=(S)=>{let O=s.indexOf(S);if(O<0)O=s.push(S)-1;return O},f=(S)=>{let{ast:O,diagnostics:I}=X(S.expr),T=S.expr.length+2;if(I.length){c("LIPS-S004",`Invalid expression: ${I[0].message}`,S.at,T);return}for(let N of Ae(O))if(!jr.has(N)&&!(N in globalThis))c("LIPS-S003",`'${N}' is not readable from a stylesheet`,S.at,T,"Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, "+"which are local to a template position.");S.unit&&O.t==="lit"&&typeof O.v==="string"&&p("LIPS-S005",`Unit '${S.unit}' after a string value`,S.at,T,`A unit suffix multiplies a number: drop the unit, or return ${S.unit==="%"?"50":"8"} instead of a string.`)},m="",g="",b="",k=!1,h=(S)=>{if(!S)return;if(k&&b&&!Dn.test(b)&&!Dn.test(S[0]))g+=" ";k=!1,g+=S,b=S[S.length-1]},x=(S)=>{m+=g+S,g="",b=S,k=!1},R=()=>{let S=g;return g=b="",k=!1,S},C=(S)=>":"+(qr(S).trim()||" "),v=0,d=0,E=0,M="",z="",P="",D=!1,B=[{ctx:e.meta?"top":"style"}],dt=()=>{let S=B[B.length-1],O=g,I;if(S.ctx==="opaque"||l(O,E,v),O[0]==="@")if(S.ctx!=="opaque"&&_r.test(O))I={ctx:"opaque",hoist:m.length};else if(Dr.test(O))I={ctx:S.ctx,group:O,at:m.length};else I={ctx:"opaque"};else{if(S.ctx==="style"){if(n)Hr.test(O.replace(Un,""))&&p("LIPS-S008",`'${O}' joins '&' to a name`,E,v-E,"Native nesting cannot: write the full selector, or use stylisPreprocessor."),g=Kr(O)}I={ctx:S.ctx==="opaque"?"opaque":"style"}}B.push(I),x("{"),I.group&&(I.body=m.length)},pt=()=>{let S=B.pop();if(S.group&&!g&&m.length===S.body&&!Wr.test(S.group)){m=m.slice(0,S.at),b="",k=!1;return}if(x("}"),S.hoist===void 0)return;let O=m.slice(S.hoist),I=B.filter((ut)=>ut.group),T=I.map((ut)=>ut.group).join("{"),N="}".repeat(I.length);m=m.slice(0,S.hoist),b="",z=T&&T===P?z.slice(0,z.length-N.length)+O+N:z+I.map((ut)=>ut.group+"{").join("")+O+N,P=T};while(v<t.length){let S=t[v];if(S==="\\"){h(t.slice(v,v+2)),v+=2;continue}let O=S==="/"&&!t.slice(E,v).trim();if(S==="/"&&(t[v+1]==="*"||t[v+1]==="/"&&O)){let I=t[v+1]==="/",T=I?Nr(t,v):Hn(t,v);if(!I&&!n)g?h(t.slice(v,T)):m+=t.slice(v,T);else Bn.test(b)&&Bn.test(t[T]||"")&&(k=!0);O&&(E=T),v=T;continue}if(S==='"'||S==="'"){let I=te(t,v);h(t.slice(v,I)),v=I;continue}if(Vn.test(S)){E===v&&E++,k=!0,v++;continue}if(S==="(")d++;else if(S===")")d--;if(S===":"&&d===0){let I=t.slice(E,v).replace(Ur,"").trim();if(Lr.test(I)){let T=Ar(t,v+1,!n,(N)=>{D=!0,c("LIPS-S004","Unterminated interpolation",N,t.length-N,"Close the expression with `}`.")});if(T){let N=T.parts.filter((K)=>typeof K!=="string");for(let K of N)f(K);if(k=!1,I.startsWith("--")&&N.length===1&&!N[0].unit&&T.parts.every((K)=>typeof K!=="string"||!K.trim())){i.push({prop:I,e:u(N[0].expr)}),R(),v=T.end+(t[T.end]===";"?1:0),E=v;continue}let Ct="";for(let K of T.parts){if(typeof K==="string"){Ct+=K;continue}let Le=u(K.expr),ft=`${o}-${Le}`;if(!i.some((se)=>se.prop===ft)){if(i.push({prop:ft,e:Le}),K.unit&&!a.some((se)=>se.name===ft))a.push({name:ft,syntax:An[0],inherits:!0,initial:An[1]})}Ct+=K.unit?`calc(var(${ft}) * 1${K.unit})`:`var(${ft})`}l(I,E,T.end,Ct),h(C(Ct)),v=T.end;continue}}}if(S==="{"){if(d>0){let I=Pe(t,v);if(I){c("LIPS-S002","Interpolation in an at-rule condition",v,I.end-v+1,"Media and container conditions cannot read custom properties. Keep the condition static.");let T=Fn.exec(t.slice(I.end+1));v=I.end+1+(T?T[1].length:0);continue}}if(!t.slice(E,v).trim()){let I=Pe(t,v);if(I){c("LIPS-S001","Interpolation in a selector",v,I.end-v+1,"Selectors are static in Layer 1. Bind a value inside the rule instead."),v=I.end+1,E=v;continue}}dt(),E=++v;continue}if(S==="}"){if(B.length>1)pt();else p("LIPS-S007","Unmatched `}` dropped",v,1),g&&x(";");E=++v;continue}if(S===";"){if(g[0]==="@"&&l(g,E,v),B.length===1&&_n.test(g))M+=R()+";";else x(";");E=++v;continue}h(S),v++}if(B.length>1){D||p("LIPS-S007","Unclosed `{` closed at the end",t.length,0);while(B.length>1)pt()}return _n.test(g)&&(M+=R()+";"),x(""),{css:m,statements:M,hoisted:z,exprs:s,binds:i,props:a}}function ee(t,e){let n=[],r=e.preprocess||Or,{css:s,statements:i,hoisted:a,exprs:o,binds:c,props:p}=Zr(t,e,!r,n),l={v:1,nsp:e.nsp,css:"",exprs:[],binds:[]},u=e.meta||!s?s:`${e.scope||`[rel="${$r(e.nsp)}"]`}{${s}}`,f=a+u,m=e.layer?`@layer ${e.layer}{${f}}`:f,g;try{g=r?r(m):m}catch(h){return n.push({code:"LIPS-S006",severity:"error",message:`Style compilation failed: ${h.message}`,loc:Xt(t,0,t.length)}),{ir:l,diagnostics:n}}let b=p.map((h)=>`@property ${h.name}{syntax:"${h.syntax}";inherits:${h.inherits};initial-value:${h.initial}}`).join(""),k={v:1,nsp:e.nsp,css:i+b+g,exprs:o,binds:c};if(p.length)k.props=p;return{ir:k,diagnostics:n}}var Gr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),zr=new Set(["pre","textarea"]),Wn=new Set(["if","else-if","switch","log"]),Jr={"&":"&","<":"<",">":">",""":'"',"'":"'"," ":" "};function ne(t){return t.replace(/&(?:amp|lt|gt|quot|#39|nbsp);/g,(e)=>Jr[e])}class Oe{src;pos=0;lineStarts=null;diagnostics=[];constructor(t){this.src=t}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let r=0;r<this.src.length;r++)if(this.src[r]===`
|
|
7
|
+
`)this.lineStarts.push(r+1)}let e=0,n=this.lineStarts.length-1;while(e<n){let r=e+n+1>>1;this.lineStarts[r]<=t?e=r:n=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,n,r,s=1,i){let{line:a,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:n,hint:i,loc:{line:a,col:o,offset:r,length:s}})}eof(){return this.pos>=this.src.length}peek(t=0){return this.src[this.pos+t]}startsWith(t){return this.src.startsWith(t,this.pos)}skipSpace(){while(!this.eof()&&/\s/.test(this.src[this.pos]))this.pos++}scanBalanced(t,e){let n=this.pos,r=0;while(!this.eof()){let s=this.src[this.pos];if(s==="'"||s==='"'||s==="`"){this.pos++;while(!this.eof()&&this.src[this.pos]!==s){if(this.src[this.pos]==="\\")this.pos++;this.pos++}this.pos++;continue}if(r===0&&s===t){let i=this.src.slice(n,this.pos);return this.pos++,{content:i,loc:{offset:n,length:i.length}}}if(s==="("||s==="["||s==="{")r++;else if(s===")"||s==="]"||s==="}"){if(r===0&&s!==t){this.report(e,"error",`Unbalanced '${s}'`,this.pos),this.pos++;continue}r--}this.pos++}return this.report(e,"error",`Unterminated — expected '${t}'`,n,this.pos-n),null}parse(){let t=[];while(!this.eof())if(t.push(...this.parseNodes([])),this.startsWith("</")){let e=this.pos;this.pos+=2;while(!this.eof()&&this.peek()!==">")this.pos++;!this.eof()&&this.pos++,this.report("LIPS-P005","error",`Stray closing tag ${this.src.slice(e,this.pos)}`,e,this.pos-e)}return{root:{t:"fragment",children:t,loc:{offset:0,length:this.src.length}},diagnostics:this.diagnostics}}parseNodes(t){let e=[];while(!this.eof()){if(this.startsWith("</"))break;let n=this.pos;if(this.peek()==="<"&&this.peek(1)!==void 0){let r=this.parseTag(t);r&&e.push(r)}else{let r=this.parseText(t);r&&e.push(r)}if(this.pos===n)this.pos++}return e}parseText(t){let e=this.pos,n=[],r="";while(!this.eof()&&this.peek()!=="<"){if(this.peek()==="{"){this.pos++;let o=this.scanBalanced("}","LIPS-P007");if(o)r&&n.push(r),r="",n.push({expr:o.content.trim(),loc:o.loc});continue}r+=this.peek(),this.pos++}r&&n.push(r);let s={offset:e,length:this.pos-e};if(n.some((o)=>typeof o!=="string"))return{t:"interp",parts:n.map((o)=>typeof o==="string"?ne(o):o),loc:s};let i=n.length?n[0]:"",a=t.some((o)=>zr.has(o));if(!i||!a&&!i.trim())return null;return{t:"text",value:ne(i),loc:s}}parseTag(t){let e=this.pos;if(this.startsWith("<!--")){let i=this.src.indexOf("-->",this.pos+4);if(i===-1)return this.report("LIPS-P003","error","Unterminated comment",e,this.src.length-e),this.pos=this.src.length,null;let a=this.src.slice(this.pos+4,i);return this.pos=i+3,{t:"comment",value:a,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<>")){this.pos+=2;let i=[];while(!0)if(i.push(...this.parseNodes([...t,"#fragment"])),this.closeStatus("#fragment",e,t)!=="stray")break;return{t:"fragment",children:i,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<{")){this.pos+=2;let i=this.scanBalanced("}","LIPS-P008");if(!i)return null;let a={t:"element",tag:"#dynamic",dynamicTag:{expr:i.content.trim(),loc:i.loc},attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};return this.finishTag(a,t,e),a}this.pos++;let n=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let r=this.src.slice(n,this.pos);if(!r||!/^[A-Za-z]/.test(r))return this.report("LIPS-P002","error","Invalid tag name",e,this.pos-e+1),{t:"text",value:"<",loc:{offset:e,length:1}};let s={t:"element",tag:r.toLowerCase(),attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};if(this.peek()==="(")if(Wn.has(s.tag)){this.pos++;let i=this.scanBalanced(")","LIPS-P012");i&&(s.head={expr:i.content.trim(),loc:i.loc})}else this.report("LIPS-P011","error",`Head expression is not allowed on <${s.tag}>`,this.pos,1,`Only ${[...Wn].map((i)=>`<${i}(…)>`).join(", ")} take a head`);return this.finishTag(s,t,e),s}finishTag(t,e,n){if(this.parseAttrs(t),t.selfClosed||Gr.has(t.tag)){t.selfClosed=!0,t.loc={offset:n,length:this.pos-n};return}let r=t.tag==="#dynamic"?"#dynamic":t.tag;t.children=[];while(!0)if(t.children.push(...this.parseNodes([...e,r])),this.closeStatus(r,n,e)!=="stray")break;t.loc={offset:n,length:this.pos-n}}closeStatus(t,e,n){if(this.eof())return this.report("LIPS-P006","error",`Unclosed <${t==="#fragment"?"":t}> — reached end of template`,e,1,`Add </${t==="#fragment"||t==="#dynamic"?"":t}>`),"eof";if(!this.startsWith("</"))return"closed";let r=this.pos;if(this.pos+=2,this.peek()===">"){if(this.pos++,t!=="#fragment"&&t!=="#dynamic")this.report("LIPS-P004","warning",`Generic '</>' closes <${t}>`,r,3,`Prefer </${t}>`);return"closed"}let s=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let i=this.src.slice(s,this.pos).toLowerCase();if(this.skipSpace(),this.peek()===">"?this.pos++:this.report("LIPS-P001","error","Malformed closing tag",r,this.pos-r),i===t)return"closed";if(n.includes(i))return this.report("LIPS-P004","warning",`</${i}> auto-closes <${t}>`,r,this.pos-r,`Add the missing </${t}> before </${i}>`),this.pos=r,"ancestor";return this.report("LIPS-P005","error",`Stray closing tag </${i}> — <${t}> is open`,r,this.pos-r),"stray"}parseAttrs(t){while(!0){if(this.skipSpace(),this.eof()){this.report("LIPS-P001","error","Unexpected end of template inside tag",t.loc.offset);return}if(this.startsWith("/>")){this.pos+=2,t.selfClosed=!0;return}if(this.peek()===">"){this.pos++;return}let e=this.pos;if(this.startsWith("...")){this.pos+=3;let i=this.readUnquotedValue();t.attrs.push({k:"spread",source:i,loc:{offset:e,length:this.pos-e}});continue}if(this.peek()==="["){this.pos++;let i=this.scanBalanced("]","LIPS-P009");if(i){let a=i.content.split(",").map((o)=>o.trim()).filter(Boolean);t.attrs.push({k:"args",names:a,loc:{offset:e,length:this.pos-e}})}continue}let n=!1;if(this.peek()==="!")n=!0,this.pos++;let r=this.pos;while(!this.eof()&&/[^\s=/>()]/.test(this.peek()))this.pos++;let s=this.src.slice(r,this.pos);if(!s){this.report("LIPS-P009","error",`Invalid attribute syntax at '${this.peek()}'`,this.pos),this.pos++;continue}if(this.peek()==="("){this.pos++;let i=this.scanBalanced(")","LIPS-P010"),a=i?i.content.trim():"",o={offset:e,length:this.pos-e};s.startsWith("on-")?t.attrs.push({k:"event",name:s.slice(3),source:a,loc:o}):t.attrs.push({k:"fn",name:s,source:a,loc:o});continue}if(this.peek()==="="){this.pos++,this.parseAttrValue(t,s,e);continue}t.attrs.push({k:"bool",name:s,value:!n,loc:{offset:e,length:this.pos-e}})}}parseAttrValue(t,e,n){let r=this.peek();if(r==='"'||r==="'"){this.pos++;let i=this.pos,a=[],o="";while(!this.eof()&&this.peek()!==r){if(this.peek()==="{"){this.pos++;let p=this.scanBalanced("}","LIPS-P007");if(p)o&&a.push(o),o="",a.push({expr:p.content.trim(),loc:p.loc});continue}o+=this.peek(),this.pos++}o&&a.push(o),this.eof()?this.report("LIPS-P010","error",`Unterminated value for '${e}'`,i,this.pos-i):this.pos++;let c={offset:n,length:this.pos-n};a.some((p)=>typeof p!=="string")?t.attrs.push({k:"interp",name:e,parts:a.map((p)=>typeof p==="string"?ne(p):p),loc:c}):t.attrs.push({k:"literal",name:e,value:ne(a[0]??""),loc:c});return}if(r==="{"){this.pos++;let i=this.scanBalanced("}","LIPS-P007");t.attrs.push({k:"expr",name:e,source:i?i.content.trim():"",loc:{offset:n,length:this.pos-n}});return}let s=this.readUnquotedValue();s?t.attrs.push({k:"expr",name:e,source:s,loc:{offset:n,length:this.pos-n}}):this.report("LIPS-P010","error",`Missing value for attribute '${e}'`,n)}readUnquotedValue(){let t=this.pos,e=0;while(!this.eof()){let n=this.peek();if(n==="'"||n==='"'||n==="`"){this.pos++;while(!this.eof()&&this.peek()!==n){if(this.peek()==="\\")this.pos++;this.pos++}this.pos++;continue}if(e===0){if(/\s/.test(n)||n===">")break;if(n==="/"&&this.peek(1)===">")break}if(n==="("||n==="["||n==="{")e++;else if(n===")"||n==="]"||n==="}")e--;this.pos++}return this.src.slice(t,this.pos).trim()}}function Rt(t){return new Oe(t||"").parse()}function qn(t){let e=Yr(t||""),n=(t||"").slice(0,e).trimEnd(),r=(t||"").slice(e),s=new Oe(r).parse(),i=n?n.split(`
|
|
8
|
+
`).length+(/\n\s*\n$/.test(t.slice(0,e))?1:0):0;return s.diagnostics.forEach((a)=>{a.loc.line+=n?t.slice(0,e).split(`
|
|
9
|
+
`).length-1:0,a.loc.offset+=e}),{script:n,...s}}function Yr(t){let e=0,n=!0;for(let r=0;r<t.length;r++){let s=t[r];if(s==="'"||s==='"'||s==="`"){let i=s;r++;while(r<t.length&&t[r]!==i){if(t[r]==="\\")r++;r++}n=!1;continue}if(s==="/"&&t[r+1]==="/"){while(r<t.length&&t[r]!==`
|
|
10
|
+
`)r++;n=!0;continue}if(s==="/"&&t[r+1]==="*"){let i=t.indexOf("*/",r+2);r=i===-1?t.length:i+1;continue}if(s===`
|
|
11
|
+
`){n=!0;continue}if(n&&e===0&&s==="<"&&/[A-Za-z{>!]/.test(t[r+1]||""))return r;if(s==="("||s==="["||s==="{")e++;else if(s===")"||s==="]"||s==="}")e=Math.max(0,e-1);if(!/\s/.test(s))n=!1}return 0}var Qr="<!--$-->",Xr=new Set(["if","else-if","else","for","switch","async","let","const","log","context","i18n"]),ts=new Set(["case","default","then","catch","loading"]),es=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","marker","mask","path","pattern","polygon","polyline","radialgradient","rect","stop","symbol","text","tspan","use"]),ns=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),rs=(t)=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),ss=(t)=>t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),Kn=(t)=>t!==""&&!isNaN(Number(t)),Zn=(t)=>{let e=t.trim(),n=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="'"||s==='"'||s==="`"){r++;while(r<e.length&&e[r]!==s){if(e[r]==="\\")r++;r++}continue}if(s==="("||s==="["||s==="{")n++;else if(s===")"||s==="]"||s==="}"){if(n--,n===0&&e[0]==="{"&&r===e.length-1)return Zn(e.slice(1,-1))}else if(n===0){if(s==="?")return!1;if(s===":")return!0}}return!1},is=(t)=>{if(t.k==="expr")return t.source;if(t.k!=="interp")return"";let e=t.parts.filter((n)=>typeof n!=="string");return e.length===1&&t.parts.every((n)=>typeof n!=="string"||!n.trim())?e[0].expr:""};class Gn{src;macros;tree;exprs=[];exprIndex=new Map;lineStarts=null;macroStack=[];diagnostics=[];constructor(t,e=new Map,n=!1){this.src=t;this.macros=e;this.tree=n}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let r=0;r<this.src.length;r++)if(this.src[r]===`
|
|
12
|
+
`)this.lineStarts.push(r+1)}let e=0,n=this.lineStarts.length-1;while(e<n){let r=e+n+1>>1;this.lineStarts[r]<=t?e=r:n=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,n,r,s=1,i){let{line:a,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:n,hint:i,loc:{line:a,col:o,offset:r,length:s}})}expr(t,e){let n=this.exprIndex.get(t);if(n!==void 0)return n;let{diagnostics:r}=X(t);for(let i of r){let a=(e?.offset??0)+i.loc.offset;this.report(i.code,"error",i.message,a,i.loc.length)}let s=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,s),s}synth(t){let e=this.exprIndex.get(t);if(e!==void 0)return e;let n=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,n),n}concat(t){t.filter((n)=>typeof n!=="string").forEach((n)=>{let{diagnostics:r}=X(n.expr);for(let s of r)this.report(s.code,"error",s.message,n.loc.offset+s.loc.offset,s.loc.length)});let e=t.map((n)=>typeof n==="string"?JSON.stringify(n):`((${n.expr})??"")`).join("+");return this.synth(e)}compInput(t){switch(t.k){case"literal":return{lit:t.value};case"bool":return{lit:t.value};case"expr":return{e:this.expr(t.source,t.loc)};case"interp":return{e:this.concat(t.parts)}}}compile(t){return{v:1,exprs:this.exprs,root:this.block(t,[])}}block(t,e){let n={html:"",scope:[...e],binds:[],blocks:[]},r=[],s=this.tree,i=[],a=(o,c,p,l=!1,u)=>{let f=0,m=!1,g=()=>(r.push(Qr),s&&p.push(0),m=!1,[...c,f++]);for(let b=0;b<o.length;b++){let k=o[b];switch(k.t){case"text":{if(l){let h={t:"text",p:g(),e:this.synth(JSON.stringify(k.value)),i18n:1};if(u)h.ik=u;n.binds.push(h);break}if(r.push(rs(k.value)),s&&(m?p[p.length-1]+=k.value:p.push(k.value)),!m)f++;m=!0;break}case"comment":{if(s)break;let h=k.value.replace(/--/g,"- -");r.push(`<!--${/^-?>/.test(h)?" "+h:h}-->`),m=!1,f++;break}case"interp":{let h={t:"text",p:g(),e:this.concat(k.parts)};if(l)h.i18n=1;if(l&&u)h.ik=u;n.binds.push(h);break}case"fragment":{o=[...o.slice(0,b),...k.children,...o.slice(b+1)],b--;break}case"element":{if(Xr.has(k.tag)){if(this.controlBlock(k,o,b,g(),n,e),k.tag==="if"){let h=b+1;while(h<o.length){let x=o[h];if(x.t==="element"&&(x.tag==="else-if"||x.tag==="else"))h++;else break}o=[...o.slice(0,b+1),...o.slice(h)]}break}if(ts.has(k.tag)){this.report("LIPS-C002","error",`<${k.tag}> is only valid inside its parent construct`,k.loc.offset,k.loc.length);break}if(k.tag==="#dynamic"){n.blocks.push(this.compLike(k,g(),e,"dynamic"));break}if(this.macros.has(k.tag)){let h=this.macroCall(k,g(),e);h&&n.blocks.push(h);break}if(!es.has(k.tag)){n.blocks.push(this.compLike(k,g(),e,"comp"));break}this.emitElement(k,c,f++,r,n,a,p),m=!1;break}}}};if(a(t,[],i),n.html=r.join(""),s)n.nodes=i;return n}emitElement(t,e,n,r,s,i,a){let o=[...e,n],c=`<${t.tag}`,p=[t.tag],l={},u=(d,E)=>{Object.prototype.hasOwnProperty.call(l,d)||(l[d]=E)};this.tree&&a.push(p);let f=t.attrs.filter((d)=>("name"in d)),m=f.some((d)=>d.name==="i18n"&&(d.k==="bool"&&d.value||d.k==="literal")),g=(d)=>m&&(d==="title"||d==="placeholder"),b=(d)=>{let E=f.find((M)=>M.name===d&&M.k==="literal");return E&&"value"in E&&E.value?String(E.value):void 0},k=b("i18n"),h=(d)=>b(`i18n-${d}`);!m&&f.some((d)=>d.name.startsWith("i18n-"))&&this.report("LIPS-C014","warning",`i18n-* key on <${t.tag}> without the 'i18n' marker — the attribute will not be translated`,t.loc.offset,t.loc.length);for(let d of t.attrs){if(this.tree&&"name"in d&&d.name==="@html"){this.report("LIPS-C021","error",`@html on <${t.tag}>: the 'tree' target has no HTML parser`,d.loc.offset,d.loc.length,"Write the markup in the template, or use @text");continue}if("name"in d&&d.name==="style"){let E=is(d);if(E&&Zn(E)){this.report("LIPS-C019","error",`style= on <${t.tag}> takes CSS text, not an object literal`,d.loc.offset,d.loc.length,'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — '+`and interpolate values into it where they vary: style="margin: {state.gap}rem". Styles that need pseudo-classes, media queries or keyframes belong in the component's stylesheet.`);continue}}if(this.quotedEvent(t.tag,d))continue;switch(d.k){case"literal":if(d.name==="@format"){s.binds.push(this.formatBind(o,d));break}if(d.name.startsWith("@")){s.binds.push({t:"prop",p:o,name:d.name.slice(1),e:this.synth(JSON.stringify(d.value))});break}if(d.name==="i18n"||d.name.startsWith("i18n-"))break;if(g(d.name)){let E={t:"attr",p:o,name:d.name,e:this.synth(JSON.stringify(d.value)),i18n:1},M=h(d.name);if(M)E.ik=M;s.binds.push(E);break}c+=` ${d.name}="${ss(d.value)}"`,u(d.name,d.value);break;case"bool":if(d.name!=="i18n"&&d.value)c+=` ${d.name}`,u(d.name,"");break;case"expr":{if(d.name==="@format"){s.binds.push(this.formatBind(o,d));break}if(d.name.startsWith("@")){s.binds.push({t:"prop",p:o,name:d.name.slice(1),e:this.expr(d.source,d.loc)});break}let E={t:"attr",p:o,name:d.name,e:this.expr(d.source,d.loc)};if(g(d.name)){E.i18n=1;let M=h(d.name);if(M)E.ik=M}s.binds.push(E);break}case"interp":{if(d.name==="@format"){s.binds.push(this.formatBind(o,d));break}if(d.name.startsWith("@")){s.binds.push({t:"prop",p:o,name:d.name.slice(1),e:this.concat(d.parts)});break}let E={t:"attr",p:o,name:d.name,e:this.concat(d.parts)};if(g(d.name)){E.i18n=1;let M=h(d.name);if(M)E.ik=M}s.binds.push(E);break}case"event":s.binds.push({t:"event",p:o,name:d.name,e:this.synth(d.source)});break;case"spread":s.binds.push({t:"spread",p:o,e:this.expr(d.source,d.loc)});break;case"fn":this.report("LIPS-C007","warning",`Callable attribute '${d.name}(…)' has no meaning on <${t.tag}>`,d.loc.offset,d.loc.length);break;case"args":this.report("LIPS-C008","warning",`Iterator arguments are not applicable to <${t.tag}>`,d.loc.offset,d.loc.length);break}}if(Object.keys(l).length&&(p[1]=l),ns.has(t.tag)){r.push(c+">");return}r.push(c+">");let R=k,C=t.children.filter((d)=>d.t==="text"||d.t==="interp");if(R&&(C.length>1||C.some((d)=>d.t==="interp")))this.report("LIPS-C015","error",`<${t.tag} i18n="${R}"> keys text that is not a single fixed string. Use @format="${R}, { … }" for interpolated text.`,t.loc.offset,t.loc.length),R=void 0;let v=[];if(t.children.length&&i(t.children,o,v,m,R),v.length)p[1]=l,p[2]=v;r.push(`</${t.tag}>`)}formatBind(t,e){let n=e.k==="literal"?e.value:e.k==="expr"?e.source:e.parts.map((a)=>typeof a==="string"?a:`{${a.expr}}`).join(""),r=n.indexOf(",");if(r===-1)return this.report("LIPS-C012","error",'@format expects "reference, { params }"',e.loc.offset,e.loc.length),{t:"prop",p:t,name:"format",e:this.synth("({})"),ref:n.trim()};let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(i,e.loc),ref:s}}attrsOf(t){let e=new Map,n=[];for(let r of t.attrs)if(r.k==="args")n.push(...r.names);else if("name"in r)e.set(r.name,r);return{byName:e,args:n}}controlBlock(t,e,n,r,s,i){switch(t.tag){case"if":{let a=[{when:t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),block:this.block(t.children,i)}];for(let o=n+1;o<e.length;o++){let c=e[o];if(c.t!=="element")break;if(c.tag==="else-if")a.push({when:c.head?this.expr(c.head.expr,c.head.loc):this.missingHead(c),block:this.block(c.children,i)});else if(c.tag==="else"){a.push({when:null,block:this.block(c.children,i)});break}else break}s.blocks.push({t:"if",p:r,branches:a});break}case"else-if":case"else":this.report("LIPS-C001","error",`<${t.tag}> without a preceding <if>`,t.loc.offset,t.loc.length);break;case"for":{let{byName:a,args:o}=this.attrsOf(t),c=a.get("in"),p=a.get("from"),l=a.get("to"),u=a.get("by");if(!c&&!p){this.report("LIPS-C004","error","<for> requires 'in' or 'from'/'to'",t.loc.offset,t.loc.length);break}let f={t:"for",p:r,args:o,block:this.block(t.children,[...i,...o])};if(c&&c.k==="expr")f.of=this.expr(c.source,c.loc);if(p)f.from=this.numInput(p);if(l)f.to=this.numInput(l);if(u&&(u.k==="literal"||u.k==="expr"))f.by=u.k==="literal"?{lit:u.value}:{e:this.expr(u.source,u.loc)};s.blocks.push(f);break}case"switch":{let a=t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),o=[];for(let c of t.children){if(c.t!=="element")continue;if(c.tag==="case"){let{byName:p}=this.attrsOf(c),l=p.get("is");if(!l||l.k!=="literal"&&l.k!=="expr"){this.report("LIPS-C004","error","<case> requires an 'is' attribute",c.loc.offset,c.loc.length);continue}o.push({is:l.k==="literal"?{lit:l.value}:{e:this.expr(l.source,l.loc)},block:this.block(c.children,i)})}else if(c.tag==="default")o.push({is:null,block:this.block(c.children,i)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",c.loc.offset,c.loc.length)}s.blocks.push({t:"switch",p:r,on:a,cases:o});break}case"async":{let a=t.attrs.find((c)=>c.k==="fn"&&c.name==="await");if(!a){this.report("LIPS-C004","error","<async> requires await(…)",t.loc.offset,t.loc.length);break}let o={t:"async",p:r,awaitE:this.expr(a.source,a.loc)};for(let c of t.children){if(c.t!=="element")continue;let{args:p}=this.attrsOf(c);if(c.tag==="then")o.then={args:p,block:this.block(c.children,[...i,...p])};else if(c.tag==="catch")o.catch={args:p,block:this.block(c.children,[...i,...p])};else if(c.tag==="loading")o.loading=this.block(c.children,i);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",c.loc.offset,c.loc.length)}s.blocks.push(o);break}case"let":case"const":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C013","error",`Spread is not supported on <${t.tag}> — scope names must be known at compile time`,o.loc.offset,o.loc.length,`Assign it to one variable: <${t.tag} obj={ ${o.source} }/> and read obj.<key>`);continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o),!s.scope.includes(o.name)&&s.scope.push(o.name),!i.includes(o.name)&&i.push(o.name)}s.blocks.push({t:"let",p:r,const:t.tag==="const",vars:a});break}case"log":s.blocks.push({t:"log",p:r,e:t.head?this.synth(t.head.expr):this.missingHead(t)});break;case"context":{let a={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C016","error","Spread is not supported on <context> — provided keys must be known at compile time",o.loc.offset,o.loc.length,"Provide them one by one: <context a=obj.a b=obj.b>");continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")a[o.name]=this.compInput(o)}if(!Object.keys(a).length)this.report("LIPS-C017","warning","<context> provides nothing — it renders its children unchanged",t.loc.offset,t.loc.length);s.blocks.push({t:"provide",p:r,vars:a,block:this.block(t.children,i)});break}case"i18n":{let{byName:a}=this.attrsOf(t),o=a.get("lang");if(!o){this.report("LIPS-C018","error","<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>",t.loc.offset,t.loc.length);break}s.blocks.push({t:"provide",p:r,vars:{},lang:this.compInput(o),block:this.block(t.children,i)});break}}}missingHead(t){return this.report("LIPS-C004","error",`<${t.tag}> requires a head expression: <${t.tag}( … )>`,t.loc.offset,t.loc.length),this.synth("undefined")}numInput(t){if(t.k==="literal")return{lit:Kn(t.value)?Number(t.value):t.value};if(t.k==="expr")return Kn(t.source)?{lit:Number(t.source)}:{e:this.expr(t.source,t.loc)};return{lit:void 0}}macroCall(t,e,n){let r=this.macros.get(t.tag);if(this.macroStack.includes(r.name))return this.report("LIPS-C009","error",`Recursive macro <${r.name}> (${[...this.macroStack,r.name].join(" → ")})`,t.loc.offset,t.loc.length),null;let s=[];for(let a of t.attrs)if(a.k==="literal"||a.k==="expr"||a.k==="interp"||a.k==="bool")s.push({name:a.name,ci:this.compInput(a)});else if(a.k==="spread")s.push({spread:this.expr(a.source,a.loc)});this.macroStack.push(r.name);let i=this.block(r.children,[...n,...r.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:r.name,sets:s,args:r.argv,block:i}}quotedEvent(t,e){if(!("name"in e)||!e.name.startsWith("on-"))return!1;return this.report("LIPS-C020","error",`${e.name}="…" on <${t}> wires no listener`,e.loc.offset,e.loc.length,`Handlers use the instruction form: ${e.name}( … ). `+"Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM."),!0}compLike(t,e,n,r){let s={},i=[],a=[],o=[];for(let p of t.attrs){if(p.k!=="event"&&this.quotedEvent(t.tag,p))continue;switch(p.k){case"literal":case"bool":case"expr":case"interp":s[p.name]=this.compInput(p);break;case"event":a.push({name:p.name,e:this.synth(p.source)});break;case"spread":i.push(this.expr(p.source,p.loc));break;case"args":o=[...o,...p.names];break;case"fn":s[p.name]={e:this.expr(p.source,p.loc)};break}}let c=t.children.length?{args:o,block:this.block(t.children,[...n,...o])}:void 0;return r==="comp"?{t:"comp",p:e,name:t.tag,inputs:s,spreads:i,events:a,contents:c}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:s,spreads:i,events:a,contents:c}}}function os(t,e,n){let r=new Map;if(!t?.trim())return r;let s=Rt(t);e.push(...s.diagnostics),n?.(s.root.children,e,t);for(let i of s.root.children){if(i.t!=="element")continue;if(i.tag!=="macro"){e.push({code:"LIPS-C010",severity:"warning",message:`Only <macro> definitions are allowed in the macros source — ignoring <${i.tag}>`,loc:{line:1,col:1,offset:i.loc.offset,length:i.loc.length}});continue}let a="",o=[];for(let c of i.attrs)if(c.k==="args")o.push(...c.names);else if(c.k==="literal"&&c.name==="name")a=c.value;if(!a){e.push({code:"LIPS-C011",severity:"error",message:"<macro> requires a name attribute",loc:{line:1,col:1,offset:i.loc.offset,length:i.loc.length}});continue}r.set(a.toLowerCase(),{name:a,argv:o,children:i.children})}return r}function re(t,e){let n=[],r=os(e?.macros||"",n,e?.check),s=Rt(t);e?.check?.(s.root.children,n,t),e?.transform?.(s.root.children,n);let i=new Gn(t,r,e?.target==="tree");return{ir:i.compile(s.root.children),diagnostics:[...n,...s.diagnostics,...i.diagnostics]}}function as(t){try{return decodeURIComponent(t)}catch(e){return t}}var cs=(t)=>Object.fromEntries(new URLSearchParams(t)),zn={state:{page:null,params:{},query:{}},handler:{onCreate(){this.__routes=[],this.__defaultPath=null,this.__currentRoute=null,this.__global=!1},onInput(){this.processor(this.input)},processor(t){if(!t?.routes)return;if(t.global)this.__global=!0;if(this.__routes=t.routes.map(({path:e,template:n,default:r})=>{if(r)this.__defaultPath=e;let s=e.match(/:[^\/]*(\/|$)/gi)||[],i=e.replaceAll("/","\\/").replaceAll(/:[^\/]*(\/|$)/gi,"([^\\/]+)(?:\\/|$)");return{path:e,template:n,default:r,pathVars:s,pathRegex:new RegExp(`${i}$`,"i")}}),t.global){let e=window.location.pathname;this.__defaultPath=this.__defaultPath&&e==="/"&&e!==this.__defaultPath?this.__defaultPath:e?e+window.location.search:this.__routes[0]?.path}},onAttach(){if(this.input?.global)window.navigate=this.navigate.bind(this),window.addEventListener("popstate",(t)=>t.state&&this.navigate(t.state.path,!0));typeof this.setContext==="function"&&this.setContext("navigate",this.navigate.bind(this)),this.__defaultPath&&this.navigate(this.__defaultPath)},navigate(t,e){!e&&this.__global&&history.pushState({path:t},"",t);let n=String(t).split("?");t=n[0];let r=n[1]?cs(n[1]):{},s=null;if(this.__currentRoute)s={path:this.__currentRoute.path,params:this.state.params},this.emit("before",{fromState:s,toState:{path:t,query:r}});let i=this.match(t);if(!i){this.__currentRoute=null,this.state.params={},this.state.query={},this.state.page=null,this.emit("not-found",t);return}let{route:a,params:o}=i;this.emit("after",{fromState:s,toState:{path:a.path,params:o,query:r}}),this.__currentRoute=a,this.state.params=o,this.state.query=r,this.state.page=a.template},match(t){let e={};for(let n of this.__routes){let r=t.match(n.pathRegex);if(r===null||r.index!==0)continue;for(let s=0;s+1<r.length&&s<n.pathVars.length;s++)e[n.pathVars[s].replaceAll(/[\/:]/g,"")]=as(r[s+1]);return{route:n,params:e}}return!1}},default:"<{state.page} params=state.params query=state.query/>"};rn(re);sn(ee);an(jn);ln("router",zn);var pa=de;export{pe as batch,ee as compileStyle,re as compileTemplate,pa as default,A as effect,qn as parseSFC,Rt as parseTemplate,Z as reactive,At as renderIR,F as signal,V as untrack};
|
|
2
13
|
|
|
3
|
-
//# debugId=
|
|
14
|
+
//# debugId=B396D5F1D77B979464756E2164756E21
|