yvee 0.0.8 → 0.0.9
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/dist/index.d.ts +724 -480
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Pr=Object.defineProperty;var Lr=(t,r)=>{for(var n in r)Pr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(o)=>r[n]=()=>o})};var At={};Lr(At,{isWindow:()=>q,isUndefined:()=>Ir,isStr:()=>v,isPromise:()=>Zr,isPlainObject:()=>H,isObject:()=>Fr,isObj:()=>E,isNumber:()=>Z,isNum:()=>St,isNull:()=>lt,isNotWindow:()=>p,isNotNull:()=>qr,isInt:()=>Rt,isFN:()=>w,isDefined:()=>Ur,isClassOrId:()=>Xr,isBool:()=>k,isAsync:()=>Cr,isArraybuff:()=>Br,isArr:()=>g});var w=(t)=>typeof t==="function",Cr=(t)=>t.constructor.name==="AsyncFunction",Zr=(t)=>!!t&&typeof t.then==="function",Z=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},Fr=(t)=>{return t&&typeof t==="object"&&!Array.isArray(t)},H=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},Br=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Xr=(t)=>{return t.startsWith(".")||t.startsWith("#")},k=(t)=>typeof t==="boolean",v=(t)=>typeof t==="string",g=(t)=>Array.isArray(t),E=(t)=>typeof t==="object",St=(t)=>typeof t==="number",lt=(t)=>t===null,qr=(t)=>t===null,Ir=(t)=>typeof t==="undefined",Ur=(t)=>typeof t!=="undefined",Rt=(t)=>{return Number.isInteger(Number(t))},q=typeof window!=="undefined",p=typeof window==="undefined";function ct(t,r){l(r).forEach(([n,o])=>{Ot(t,n,{value:o,writable:!1,configurable:!1,enumerable:!0})})}var Dt=(t)=>{return g(t)?t:[t]};class ${static set i(t){console.info(...Dt(t))}static set e(t){console.error(...Dt(t))}static set w(t){console.warn(...Dt(t))}}class D{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??x(5),t?.includes("-")){let[r,n]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=r,this._c=Z(n)?parseInt(n):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Jr=(t)=>Array.from({length:t},(r,n)=>n),kt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vt="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),tr=(t)=>{return JSON.parse(t)};var M=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(t)=>{let r=kt+vt,n=Jr(10).join("");return Array.from({length:t},(o,i)=>r+(i?n:"")).reduce((o,i)=>{return o+=i.charAt(Math.floor(Math.random()*i.length))},"")},Wr=(t=6,r)=>{if(!r)return Math.floor(Math.random()*t);return Math.round(Math.random()*(r-t)+t)},rr=()=>{let t=[...kt,...vt],r=Wr(0,t.length);return t[r]};var nr=(t,r)=>{let n=r==="/"?"":r;if(r.startsWith("#"))return t+r;return r.startsWith("/")?t+n:r};class a extends Map{obj(t){t&&l(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof a)this.set(n,r);else if(g(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if(E(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});d(this.get(t),r)}lacks(t){return!this.has(t)}init(t,r){return this.has(t)?this.get(t):this.set(t,r).get(t)}}var{values:A,keys:W,entries:l}=Object;var{defineProperty:Ot,assign:d}=Object,or=(t,r)=>Object.hasOwn(t,r),R=(t)=>{return Object.keys(t).length},dt=(t,r)=>{if(!r.has(t))r.set(t,new a);return r.get(t)},tt=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Ht=(t,r)=>{let n={added:{},removed:{},modified:{}},o=W(t),i=W(r);for(let e of i){let f=t[e],s=r[e];if(!(e in t))n.added[e]=s;else if(g(f)&&g(s)){if(S(f)!==S(s))n.modified[e]={old:f,new:s}}else if(E(f)&&E(s)&&!lt(f)&&!lt(s)){let u=Ht(f,s);if(R(u.added)||R(u.removed)||R(u.modified))n.modified[e]={old:f,new:s}}else if(f!==s)n.modified[e]={old:f,new:s}}for(let e of o)if(!(e in r))n.removed[e]=t[e];return n};function ir(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var er=(t)=>{return A(t).some((r)=>{return R(r)})};var I=(t,r)=>{return{name:t,content:r}},Gr=(t,r)=>{return{property:t,content:r}},Qr=(t,r)=>{return{"http-equiv":t,content:r}};class rt{metas=[];constructor(t){t&&this.metas.push(I("description",t))}author(t){return this.meta=I("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=I("keywords",t.join(", ")),this}viewport(t){let r=l(t).map(([n,o])=>[M(n),String(o)].join("="));return this.meta=I("viewport",r.join(", ")),this}httpEquiv(t){return l(t).forEach(([r,n])=>{this.meta=Qr(M(r),String(n))}),this}robots(...t){return this.meta=I("robots",t.join(", ")),this}themeColor(t){return this.meta=I("theme-color",t),this}openGraph(t){return l(t).forEach(([r,n])=>{this.meta=Gr("og:"+r,String(n))}),this}twitter(t){return l(t).forEach(([r,n])=>{this.meta=I("twitter:"+r,String(n))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class Mt{title;description;base;meta;link;script;css}var Kr=["charset","name","property","http-equiv"],sr=(t,r)=>{r.forEach((n)=>{for(let o of Kr)if(o in n){let i=n[o];t[`${o}_${o==="charset"?"":i}`]=n}})},zr=(t,r)=>{r.forEach((n)=>{if("href"in n){let o=n.href;t[`${o}`]=n}})};class G{_head;idm;constructor(t){this._head=new a(t)}set head(t){l(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof rt)return sr(this._head.init("meta",{}),n.metas);if(!g(n))return;switch(r){case"meta":return sr(this._head.init("meta",{}),n);case"link":return zr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let o=n.map((i)=>{if(!i.yid&&this.idm)i.yid="sc"+this.idm.mid;return i});this._head.get(r).push(...o)}return}})}get head(){return this._head}set id(t){this.idm=new D(t)}}var nt=(t)=>{return l(t??{}).reduce((r,[n,o])=>{return r.push(k(o)&&o?n:`${n}="${o}"`),r},[""]).join(" ")},fr=(t)=>{let r=new Set;if(!t)return"";let n=[...t].reduce((o,[i,e])=>{if(i==="meta"||i==="link")e=A(e);if(v(e)){if(i==="title")r.add(`<${i}>${e}</${i}>`);else o.add(`<${i}>${e}</${i}>`);return o}if(!g(e))return o;if(i==="base"){let s=e.slice(-1);if(s)return r.add(`<${i}${nt(s[0])}>`),o}return e.map((s)=>{if(i==="script"){let u={...s},h="";if("importmap"in u)u.type="importmap",h=JSON.stringify(u.importmap),delete u.importmap;else if("body"in u)h=u.body,delete u.body;return`<${i}${nt(u)}>${h}</${i}>`}return`<${i}${nt(s)}>`}).forEach((s)=>{if(s.includes('type="module"'))r.add(s);else if(s.includes("<meta"))r.add(s);else o.add(s)}),o},new Set);return[...r,...n].join("")};class ot{lang="en";htmlHead;head;constructor(){this.htmlHead=new a,this.head=(t={})=>{let r=new G(this.htmlHead),{css:n,description:o,...i}=t;if(o)r.head={meta:[{name:"description",content:o}]};if(n){let f=(g(n)?n:[n]).map((s)=>({rel:"preload stylesheet",href:s,as:"style"}));r.head={link:[...f]}}r.head=i,this.htmlHead=r.head}}}var jt=(t)=>{if(p)return;return new Promise((r,n)=>{let o=null;if(t.href)o=document.querySelector(`link[href="${t.href}"]`);if(o){r(o);return}let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";l(t).forEach(([e,f])=>{i.setAttribute(e,f)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},ur=(t)=>{if(p)return;return new Promise((r,n)=>{let o=document.createElement("script"),i="";if("importmap"in t)t.type="importmap",i=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)i=t.body,delete t.body;if(i)o.textContent=i;l(t).forEach(([e,f])=>{o.setAttribute(e,f)}),o.onload=()=>r(o),o.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(o),requestAnimationFrame(()=>r("Script executed"))})},Nr=()=>{let r=document.querySelector("#d-css")?.sheet;if(r)return r;let n=document.createElement("style");return n.id="d-css",document.head.appendChild(n),n.sheet},Vr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},_r=(t)=>Object.entries(t).map(([r,n])=>`${M(r)}: ${n};`).join(" ");function Or(t,r={}){if(p)return;let n=Nr();if(!n)return;if(!Vr(n,t))n.insertRule(`${t} { ${_r(r)} }`,n.cssRules.length)}var Yt=(t,r=!1)=>{if(Z(t))return[+t,Rt(t)?"int":"float"];if(r&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},Q=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[o,i]=n.reduce(([e,f],s)=>{if(s.includes("<")){let u=s.match(/(?<=<)[^/].*?(?=>|$)/g);if(u?.length){let[h,m]=u[0].split(":");if(h)e.push(h),f.push(m||"_")}}else e.push(s===">"?"/":s);return[e,f]},[[],[]]);if(r.endsWith("/")&&r.length>1)o.push("/");return{parsed:o,args:i}};class pt{storage;constructor(){this.storage=new a}cache(t,r){if(this.storage.lacks(t))this.storage.set(t,r());return this.storage.get(t)}}var hr=["int","float","file","uuid","string"],Tt=(t,r)=>{let n={},o=[],{parsed:i}=Q(t),{parsed:e,args:f}=Q(r);if(i.length===e.length)e.map((s,u)=>{let h=Yt(i[u],i.length-1===u);if(s===h[0])return h[0];if(hr.includes(h[1]))return o.push(h[0]),h[1];return s}),f.forEach((s,u)=>{n[s]=o[u]});return n};class K{_storage;CC;constructor(){this._storage=new a,this.CC=new pt}set(t){let{parsed:r,path:n}=t,o=S(r);if(!this._storage.get(o))this._storage.set(o,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=this.CC.cache(t,()=>Q(t)),n={},o=this._storage.get(S(r));if(!o&&t!=="/")for(let i of this._storage.keys()){let e=[],f=tr(i);if(r.length===f.length){let s=f.map((m,b)=>{let T=Yt(r[b],r.length-1===b);if(m===T[0])return T[0];if(hr.includes(T[1]))return e.push(T[0]),T[1];return m}),u=S(s);if(this._storage.has(u)){o=this._storage.get(u),o?.args.forEach((m,b)=>{n[m]=e[b]});break}}}return[o,n]}}class it{path="";parsed=[];args=[];constructor(t){ct(this,{path:t,...Q(t)})}}class Pt{date;constructor(t){this.date=t?new Date(t):new Date}delta(t=null,r=!1){let n=Pt.delta(this.date.getTime(),t);return r?new Date(n):n}timed(t){if(!t)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((n,[o,i])=>{let e=t[o];return e?new Date(n[`set${i}`](n[`get${i}`]()+e)):n},new Date(this.date))}static delta(t,r=null){return r?r-t:t-Date.now()}static local(t){return new Date(t).toLocaleString()}static get now(){return Date.now()}}class Lt{static rand(t=6,r){if(r)return Math.floor(Math.random()*(r-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,r=null){return Array(t).fill(r)}static new({dom:t,id:r,inner:n}){let o=document.createElement(t);if(r)o.id=r;if(n)o.innerHTML=n;return o}static randFrom(t){if(Array.isArray(t)){let r=t.length,n=this.rand(0,r-1);return t[n]}else if(typeof t=="object"){let r=W(t),n=r.length,o=this.rand(0,n-1);return r[o]}}static randArray(t=[],r=1,n=!1){let o=[],i=n?new Set:null;while((n?i.size:o.length)<r){let e=t[Lt.rand(0,t.length-1)];n?i.add(e):o.push(e)}return n?[...i]:o}static randomAZ=rr;static makeID=x;static class(t,...r){let n=r;if(t?.class)n.push(...g(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:A,keys:W,items:l,has:or,ass:d,len:(t={})=>W(t).length}}static get is(){return At}static get return(){return ar}static sleep=(t=1000)=>new Promise((r)=>setTimeout(r,t));static get screen(){let{innerWidth:t}=window,r={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},n=l(r).reverse();for(let o=0;o<n.length;o++){let[i,e]=n[o];if(e)return i}return}bytes(t){if(t===0)return"0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,o)).toFixed(2))+" "+n[o]}static format(t){return new mr(t)}}class ar{static arr(t){return t?g(t)?t:[t]:[]}static num(t,r=0){let n=parseFloat(t);return isNaN(n)?r:n}static str(t){return String(t)}static arr2obj(t,r=!1){return t.reduce((n,o,i)=>{if(r)n[o]=i;else n[i]=o;return n},{})}}class mr{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}var Ct={},U={};class gr{stream;url;constructor(t,r){if(this.url=t,t in Ct)this.stream=Ct[t];else this.stream=new EventSource(t,{withCredentials:r}),Ct[t]=this.stream,U[this.url]={}}on(t){let r=this.stream;return l(t).forEach(([n,o])=>{if(n in U[this.url])U[this.url][n].forEach((i)=>{this.stream.removeEventListener(n,i)}),U[this.url][n]=[];if(r.addEventListener(n,o),!(n in U[this.url]))U[this.url][n]=[];U[this.url][n].push(o)}),this}}function lr(t,r=!0){return new gr(t,r)}class cr{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(Z(this.value))return parseInt(this.value);else return null}get float(){if(Z(this.value))return parseFloat(this.value);else return null}get bool(){if(this.value==="true")return!0;else if(this.value=="false")return!1;else return null}get json(){if(this.value)return JSON.parse(this.value);return null}}class z{key;state;storage;constructor(t,r="local",n){if(this.storage=r=="local"?localStorage:sessionStorage,typeof t=="object"){let[o,i]=l(t)[0];if(this.key=o,this.state=i,n){let e=this.as[n];this.state.value=e}N((e)=>{this.set=e},[this.state],{id:this.key})}else this.key=t,this.state=null}get as(){return new cr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}set set(t){let r=E(t)?S(t):String(t);this.storage.setItem(this.key,r)}get remove(){this.storage.removeItem(this.key);return}}var dr={get:(t)=>new z(t,"local"),init:(t,r)=>new z(t,"local",r)};var pr={get:(t)=>new z(t,"session")};class bt extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Tr extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Zt extends ot{storage=new K;errorStorage=new K;wssStorage=new K;route;error;wss;base;constructor(t=""){super();this.base=t?t.startsWith("/")?t:`/${t}`:"",this.route=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.storage.set(new bt(n,x(5),o)),o}},this.wss=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.wssStorage.set(new Tr(n,x(5),o)),o}},this.error=(...r)=>{return(n)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new bt(o.toString(),x(5),n))});else this.errorStorage.set(new bt("404",x(5),n));return n}}}_base(t){return nr(this.base,t)}async getPath(t){return this.storage.get(t)}async loadError(t){return this.errorStorage.get(t.toString())}async loadWSS(t){return this.wssStorage.get(t)}}var et=new a,V=(t)=>{if(p)return;let r=et.get(t);if(r?.isConnected)return r;et.delete(t);let n=document.getElementById(t);if(!n)return;return et.set(t,n),n};function br(){let t=[];return et.forEach((r,n)=>{if(!r.isConnected)t.push(n),et.delete(n)}),t}function N(t,r,{id:n="stateHook",init:o}={}){if(p)return()=>{};let i=[],e=()=>r.map((s)=>s.value),f=()=>{t(...e())};if(r.forEach((s)=>{i.push(s.hook(f)(n))}),o)f();return()=>{i.forEach((s)=>s())}}var yr=(t)=>{t.forEach((r)=>r())};var kr=(t,r)=>{for(let[n,o]of t){let i=V(n);if(!i){t.delete(n);continue}o.forEach((e)=>{e.call(i,r)})}};class j extends EventTarget{options;deep;verify;hooks=new a;states=new a;_value;listening=!1;end;constructor(t,r={},n=!0,o=!0){super();this.options=r;this.deep=n;this.verify=o;this._value=t}get value(){return this._value}set value(t){if(!this.verify){this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(H(this._value)||g(this._value)){let r=Ht(this._value,t);if(!er(r))return}else if(this._value instanceof Set){if(!ir(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(r)=>{if(yr(this.hooks),kr(this.states,r.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,r){return(n)=>{if(dt(n,this.states).set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(n))this.states.get(n)?.delete(r)}}}hook(t){return(r)=>{if(this.hooks.set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function Y(t,r={}){return new j(t,r,!0)}function vr(t,r=!1){return new j(t,{},!1,r)}var _=(t)=>{if(g(t))return t.filter((r)=>r!==void 0).join(" ");else if(E(t)){if(H(t))return S(t)}else if(w(t))return _(t());else if(t!==void 0&&t!==null)return k(t)?t?"":"false":String(t);return""};function tn(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class Ft{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let o=(i,e)=>{if(g(e))t.attr_push(i,_(e));else if(e instanceof j){let f=n?`${n}_${i}`:i;t.states.push(e.call(tn(i,n),f)),o(i,e.value)}else if(E(e)){if(H(e)&&!n)this.get(t,e,i)}else t.attr_push(i,_(e),n)};l(r).forEach(([i,e])=>{if(i==="ref"){if(e instanceof st)t.events.obj({element(){e.element=this}})}else if(["on"].includes(i))E(r.on)&&t.events.obj(r.on);else o(i,e)})}unload(t){let r=void 0;if(t in this.attr)r=this.attr[t],delete this.attr[t];return r}}class F{xid;IDM;map=new a;states=[];events=new a;OZ;constructor(t,r=new D,n){this.xid=t;this.IDM=r;this.OZ=n??new yt}attr_push(t,r,n){let o=n??t;if(!this.map.has(o))this.map.set(o,[]);let i=n?`${M(t)}:${r};`:r;this.map.get(o).push(i)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let o=r.join("");t.push(o?`${n}="${o}"`:n)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}var rn=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},ft={};class yt{events=new a;states=new a;winStates=new a;windowEvents=new a;resetST=new a;resetEV=new a;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:r,events:n,states:o}=t;if(r){if(n.size)this.events.set(r,n);if(o.length)this.states.set(r,o)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((o,i)=>{dt(n,this.events).set(i,o)})}),t.states.forEach((r,n)=>{tt(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=V(r);if(!n){this.events.delete(r);return}t.forEach((o,i)=>{switch(i){case"ready":case"element":o.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=i.replace(/^win/,"");this.windowEvents.init(e,new a).set(r,o);break;case"state":let[f,s,u]=o.apply(n,[n]),h=g(s)?s:[s];if(!h.length)break;let m=()=>h.map((T)=>T.value),b=()=>f(...m());if(u)b();h.forEach((T)=>tt(r,this.resetST).push(T.call(b,r+"_state")(r)));break;default:tt(r,this.resetEV).push(rn(n,i,o))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{tt(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let o=0,i=!1,e=(s)=>{if(o=window.scrollY,!i)window.requestAnimationFrame(()=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)}),i=!1}),i=!0},f=(s)=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)})};return window.addEventListener(r,r==="scroll"?e:f),()=>{window.removeEventListener(r,r==="scroll"?e:f)}};return this.windowEvents.forEach((r,n)=>{if(r.size){if(!ft[n])ft[n]=t(n,r)}else if(ft[n])ft[n](),delete ft[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,o)=>{if(n.has(r))n.delete(r)}),this.resetEV.get(r)?.forEach((n)=>{n()}),this.resetST.get(r)?.forEach((n)=>{n()}),this.resetST.delete(r),this.resetEV.delete(r)}),this}RPS(t){if(t){let r=br();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var P=new yt;var nn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],on=(t)=>nn.includes(t);function en(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var xt=(t,r)=>{if(g(t))return t.map((n)=>xt(n,r)).join("");else if(t instanceof ht){let n=t.__(r.IDM),{ctx:o,oz:i}=n;return r.OZ.push(i),o}else if(E(t))return S(t);else if(w(t))return xt(t(),r);else if(t!==void 0&&t!==null)return en(t);return""},wt=(t,r)=>{let n=new D(r),o=new F(n.id,n);return{ctx:xt(t,o),catt:o}};function sn(t){let r=this.id;if(r){let{ctx:n,catt:o}=wt(t,r);if(this.innerHTML!==n)this.innerHTML=n,P.RPS(o.OZ)}}var ut=(t,r,n,o=[])=>{if(g(t))t.forEach((i)=>{ut(i,t.length,n,o)});else if(t instanceof j)if(r>1)ut(B("div",{},t),r,n,o);else{let i=t.value,e=i instanceof ht?"dom":"ctx",{ctx:f,catt:s}=wt(i,n.xid+"-0");n.xid=s.xid,o.push(f),n.OZ.push(s.OZ),n.states.push(t.call(sn,e))}else o.push(xt(t,n))};class Bt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=on(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((o)=>{ut(o,r.length,t,n)}),n.join("")}get(t){let r=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${r}${this.closing}`}}class ht{tag;constructor(t,r={},...n){this.tag=t;ct(this,{attr:new Ft(r),ctx:new Bt(t,n)})}__(t=new D){let r=t.mid,n=new F(r,t);return this.attr.get(n),{ctx:this.ctx.get(n),oz:n.OZ.set(n),id:n.id}}}function B(t,r={},...n){if(w(t))return $.i=t,t(r??{},...n);return new ht(t,r??{},n)}var fn=(t,...r)=>r;class Xt{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,r={}){return this.e.animate(t,r)}get slide(){let t=({x:r=0,y:n=0},o={})=>{d(this.opt,o);let i=[[r,n],[0,0]].map(([e,f])=>({transform:`translateX(${e}rem) translateY(${f}rem)`}));return this.e.animate(i,this.opt),this};return{left:(r={})=>{return t({x:-2},r)},right:(r={})=>{return t({x:2},r)},up:(r={})=>{return t({y:2},r)},down:(r={})=>{return t({y:-2},r)}}}fade(t={}){d(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){d(this.opt,r);let n=[0,5,-5,5,0].map((o)=>({transform:`translate${t}(${o}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({color:o})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({backgroundColor:o})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){d(this.opt,r);let n=[0.5,t,1].map((o)=>({transform:`scale(${o})`}));return this.e.animate(n),this}}class Ut{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new Xt(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((r)=>r)}return[]}get attr(){let t=this.e;return{has:(r)=>{return t.hasAttribute(r)},get:(r)=>{return t.getAttribute(r)},del:(r)=>{return t.removeAttribute(r),this},set:(r)=>{for(let n in r){let o=r[n];if(r[n]!==void 0)t.setAttribute(n,_(o))}return this}}}get children(){return Array.from(this.e.children).map((t)=>c(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new L(t);return}get parent(){let t=this.e.parentElement;if(t)return new L(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,r=this;return{set:(n,o=0)=>{let i=t,e=()=>{l(n).forEach(([f,s])=>{if(f in i){if(i[f]!==s)i[f]=s}else if(s!==null)t.setProperty(f,String(s))})};if(w(o))r.on("transitionend",o);if(St(o))setTimeout(e,o);else e();return r},get:(n)=>{let o=M(String(n));return t.getPropertyValue(o)},del:(...n)=>{n.forEach((o)=>{let i=M(String(o));t.removeProperty(i)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("beforeend",r),P.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("afterbegin",r),P.RPS(n)}set inner(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.innerHTML=r,P.RPS(n)}set disabled(t){let r=this.e;if("disabled"in r)r.disabled=t}set id(t){this.e.id=t}set value(t){let r=this.e;r.value=t}}var qt=(t,r)=>{let{ctx:n,catt:o}=wt(t,r);return{ctx:n,oz:o.OZ}},It=(t)=>t?`${t}-0`:t;class L extends Ut{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,"")))}}remove(...t){return this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,""))),this}toggle(t,r){let n=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(n,r)}hasNode(t){return this.e.contains(t)}has(...t){let r=this.e.classList;return t.every((n)=>r.contains(n))}insert(t){return{HTML:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentHTML(t,n)}),this},element:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentElement(t,n)}),this},text:function(...r){return r.forEach((n)=>{this.e.insertAdjacentText(t,n)}),this}}}is(t){let r=this.e.classList,n=this.e.tagName.toLocaleLowerCase(),o=!0,i=!0;if(t.dom)i=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{o=o?r.contains(e):!1});else o=o?r.contains(t.class):!1;return o&&i}on(t,r,n=!1){let o=!1;if(t.indexOf("touch")>-1)o=!0;return this.e.addEventListener(t,r,{capture:n,passive:o}),this}remove_on(t,r,n=!1){return this.e.removeEventListener(t,r,n),this}timed(t,r=250){return setTimeout(()=>t(this),r),this}animate(t,r,n){let o={duration:300,easing:"ease",fill:"forwards"};if(w(r))n=r;else d(o,r);let i=this.e.animate(t,o);if(n)i.finished.then(n);return this}}function c(t,r){let n=r?r:document;if(v(t)){let o=n.querySelector(t);if(o)return new L(o,t);return}else if(H(t)){let[[o,i]]=l(t),f=`${o==="id"?"#":"."}${i}`,s=n.querySelector(f);if(s)return new L(s,f);return}else return new L(t)}class st{state=new j(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new L(t);else this.state.value=void 0}get $(){return this.state.value}}var un=()=>{return new st};class Jt{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=fr(r)}body(t,r,n){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${r??x(5)}"${n?" "+n:""}>${t}</body>`,"</html>"].join("")}}class $t extends Mt{path;args;id;status;lang;import;_data={};static route="/";constructor(t,r={},n,o=200){super();this.path=t;this.args=r;this.id=n;this.status=o}async loader(){if(this.import)try{let t=await this.import;if(t.default)this.import=await t.default({...this.args,...this.data});else this.import=void 0}catch(t){return $.e=["import",{error:"loader"}],this.import=void 0,[]}if(this.body){let t=await this.body();return g(t)?t:[t]}if(this.import){let t=this.import;return g(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new G;if(R(t))n.head=t;n.id=this.id;let o=n.head;return r.forEach((i)=>{o.map(i)}),hn(n,this),o}set data(t){d(this._data,t)}get data(){return this._data}}class Wt extends $t{head(){this.title=`error ${this.status}`}body(){return B("div",{},this.path+" not found...")}}function hn(t,r){let{link:n,script:o,meta:i,title:e,base:f,description:s,css:u}=r;if(t.head={title:e,base:f,meta:i,link:n,script:o},s)t.head={meta:[{name:"description",content:s}]};if(u){let m=(g(u)?u:[u]).map((b)=>({rel:"preload stylesheet",href:b,as:"style"}));t.head={link:[...m]}}}function xr(t){let r=[];if(t?.length){let{href:n,target:o}=t[0],i=c("base");if(i){if(i.attr.get("href")!==n)i.attr.set({href:n,target:o})}else{let e=c(document.createElement("base"));e.attr.set({href:n,target:o}),document.head.append(e.e)}}return r}var wr=new a;async function $r(t,r={},n=!1){let o=at.value,i={};if(c("link")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("href");if(s){let u=f.attr.get("rt");if(n){let h=wr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r&&R(r))for(let e of A(r)){let f=e.href;if(!(f in i))try{let s=void 0;if(!n){if(s=c(`link[href='${f}']`),s)s.attr.set({rt:t});e.rt=t;let u=wr.init(o,new Set);if(!u.has(f))u.add(f)}if(!s)await jt(e)}catch(s){$.e=["link error",{error:"yvee @ link"}]}else delete i[f]}return A(i)}var an=["charset","name","property","http-equiv"];function Er(t){let r={};if(c("meta")?.all.forEach((n)=>{let o=n.attributes;for(let i of an)if(i in o){let e=o[i].value;r[`${i}_${i==="charset"?"":e}`]=n}}),t)l(t).forEach(([n,o])=>{if(n in r)c(r[n]).attr.set(o),delete r[n];else{let i=c(document.createElement("meta"));i.attr.set(o),document.head.append(i.e)}});return A(r).map((n)=>c(n).unload)}var Sr=new a;async function Rr(t,r,n=!1){let o=at.value,i={};if(c("script[yid]")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("yid");if(s){let u=f.attr.get("rt");if(n){let h=Sr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in i)delete i[e.yid];else try{if(!n){e.rt=t;let f=e.yid,s=Sr.init(o,new Set);if(!s.has(f))s.add(f)}await ur(e)}catch(f){$.e=["script error",{error:"yvee @ script"}]}}return A(i)}async function Ar(t,r){let n=[];if(p)return[];let o=t.get("title")??"",{pushState:i}=this.config;if(i){let e=this.path.value,f=this.lastPath.value;if(f!==e)if(!f.startsWith(e))X(e,o);else if(e===this.base)X(e,o);else X(e,o)}if(o&&(document.title=o),this.isYvee)document.documentElement.lang=r,n.push(...xr(t.get("base"))),n.push(...Er(t.get("meta")));return n.push(...await $r(this.id,t.get("link"),this.isYvee)),n.push(...await Rr(this.id,t.get("script"),this.isYvee)),n}function X(t,r){if(p)return;let{pathname:n,hash:o}=window.location,i=n+o;if(t&&i!==t)history.pushState({},r??"",t)}class Gt{path;args;static route="/";isConnected=Y(!1);data={};constructor(t,r={}){this.path=t;this.args=r;this.data=r}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var O=new a;class Qt{yvee;constructor(t){this.yvee=t}async load(t){if(p)return;if(!O.has(t)){let[n,o]=await this.yvee.loadWSS(t);if(!n)return;let{cls:i,path:e,id:f}=n,s=new i(e,o).connect;return O.set(t,s),s}let r=O.get(t);return r.reconnect,r}unload(t){if(p)return;if(O.has(t)){let r=O.get(t);if(!r)return;r.disconnect,O.delete(t)}}}var Kt=new a;function mn(t,r,n,o){let{on:i,top:e,topRef:f,...s}=t,u={...i??{},click(h){h.preventDefault();let m=c(this),b=m.path;o.value=n.value,n.value=b;let T=m.hash;if(T){let J=c(T),y=window.scrollY;if(J)y+=J.rect.top;if(f)y-=f?.value?.e.offsetHeight||0;if(e)if(typeof e==="number")y-=e;else y-=e();window.scrollTo({top:y,behavior:"smooth"}),X(b+T)}else if(o.value===n.value)window.scrollTo({top:m.rect.top||0,behavior:"smooth"}),X(window.location.pathname)}};return B("a",{...s,on:{...u}},...r)}function gn(t,r,n){let{classes:o}=t.config,{on:i,...e}=r,f={...r.on??{},...n&&{popstate(s){let h=s.target.location.pathname;t.path.value=h}},...{element(s){t.mainElement=this}}};return B("div",{...e,...o&&{class:o},on:f},t.root)}async function ln(t,r){let[n,o]=await this.loadError(r??0);if(n){let{cls:i,id:e}=n;return new i(t,o,e,r)}else{let i=new Wt(t,o,x(5));return i.title=`error ${r}`,i}}function zt(){if(q)return parseInt(c('meta[name="error"]')?.attr.get("content")??"200");return 200}class mt extends Zt{config;hook;root=Y([]);socket;id=x(4);path=Y("");lastPath=Y("");loading=Y(!1);mainElement;A;Main;load;matchPath;isYvee=!1;constructor(t={},r={}){super(t.base??"");this.config=t;if(this.socket=new Qt(this),t.id)this.id=t.id;this.A=(n,...o)=>{if(this.base){if(!n.href.startsWith(this.base))n.href=this._base(n.href)}return mn(n,o,this.path,this.lastPath)},this.Main=(n)=>{if(R(r))if(!n.on)n.on=r;else d(n.on,r);return gn(this,n,this.isYvee)},this.load=async(n,o={})=>{if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Pager loader"}]}}return this},this.matchPath=(n)=>{let o=this._base(n),i=this.path.value,e=this.base;if(i===o)return!0;else{let f=i.replace(e,""),s=o.replace(e,"");if(s){if(f.startsWith(s))return!0}else if(!i)return!0}return!1}}hooker(){let t={},r={},n=this.path.value;if(this.hook)this.hook();this.hook=N(async(o)=>{if(r[n]=window.scrollY,t[n]=this.mainElement?.scrollTop??0,(await this.render(o,404)).done){let i=r[o]??0;if(i)window.scrollTo({top:i,behavior:"instant"});let e=t[o]??0;if(e)this.mainElement?.scrollTo({top:e,behavior:"instant"});n=o}},[this.path],{id:"router"})}async class(t,r,n=!1){let[o,i]=await this.getPath(t);if(o&&!n){let{cls:e,id:f}=o;return new e(t,i,f)}else return await ln.call(this,t,404)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(H(r)&&R(r))t.data=r}}catch(r){$.e=["class fetch",{error:"fetch"}]}}async processHead(t,r={}){return t?await this.processClassHead(t,r):await this.processDefaultHead(r)}async processClassHead(t,r){if(t.head)await t.head();return t.getHeadAttr(r,this.htmlHead)}async processDefaultHead(t){let r=new G;if(R(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},o={},i=!0,e=!1){let f=await this.class(t,r??zt(),e);f.data=n,await this.fetch(f);let s=await this.processHead(f,o);if(p)Kt.set(this.id,s);if(!f)return{lang:this.lang,heads:s,done:!1};let u=[];if(this.loading.value=!0,this.isYvee)u=await f.loader();let h=[];if(i)h=await Ar.call(this,s,f?.lang||this.lang);if(!this.isYvee)u=await f.loader(),h.forEach((m)=>m());if(this.isYvee)h.forEach((m)=>m());if(u.length)this.root.value=u;else await this.render(t,r,n,o,i,!0);return this.loading.value=!1,{heads:s,lang:f.lang??this.lang,done:!0}}}var at=Y("");class Et extends mt{config;isYvee=!0;unload=!0;constructor(t={},r={}){super(t,r);this.config=t;this.path=at,this.load=async(n,o={})=>{if(q)n=dn()||this._base(n??"/");if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Yvee loader"}]}}return this}}}var cn=(t)=>{return(r)=>{t(r)}};function dn(){if(q)return c('meta[name="yvee"]')?.attr.get("content")??"/";return""}var Dr=(t,r,n,o=!1)=>{let i=[];if(i.push({charset:"utf-8"}),i.push({name:"viewport",content:"width=device-width, initial-scale=1.0"}),n)switch(n){case 404:i.push({name:"error",content:n.toString()});break;default:break}if(o)i.push({name:"yvee",content:r});if(t.meta)if(g(t.meta))t.meta.unshift(...i);else t.meta.push(i);else t.meta=i},Hr=async(t,r,n={},o=[])=>{let i=await r(n),e=g(i)?i:[i],f=new F(t,new D(t));return e.forEach((s)=>{ut(s,e.length,f,o)}),f.OZ.set(f),f.OZ};async function pn(t,r,n={}){let{bodyattr:o={},id:i,route:e,base:f="",index:s,data:u}=n;if(q){let h={},m=window.location.pathname,b=document.body.id;if(r)if(r instanceof Et)await r.load();else{if(u)if(w(u))h=await u();else h=u;if(e){if(e.length>1&&e.slice(-1)!=="/")m=m.replace(/^\/|\/$/g,"");d(h,Tt(m,e))}d(h,{path:m,status:zt()})}let T=await Hr(b,t,h);P.push(T),requestAnimationFrame(()=>{P.stage})}return async({path:h,data:m={},status:b=200})=>{let T=x(4),J=new a,y={};if(i)T=i;if(o.id)T=o.id.toString();let Nt="en";if(r instanceof Et){let{base:C,path:gt,id:Mr,lang:jr}=r;if(y.base=[{href:C==="/"?C:`${C}/`,target:"_blank"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];gt.value=h,Dr(y,h,b,!0);let{heads:_t}=await r.render(h,b,m,y,!1);Kt.values().forEach((Yr)=>{d(_t.init("link",{}),Yr.get("link")??{})}),T=Mr,J=_t,Nt=jr}else{let C=h==="/"?h:`${h}/`;if(s)C=`${s}/`;if(f)C=`${f}${C}`;if(y.base=[{href:C,target:"_self"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];if(e)d(m,Tt(h,e));d(m,{status:b,path:h,base:f}),d(y,w(r)?await r(m):r),Dr(y,h,b);let gt=new ot;gt.head(y),J=gt.htmlHead}let Vt=[];return await Hr(T,t,m,Vt),new Jt(Nt,J).body(Vt.join(""),T,nt(o))}}var Us=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`},Js=(t)=>{if(p)return;return t()};export{Gt as websocket,un as useRef,pr as session,Us as resolvePath,X as pushHistory,$ as log,dr as local,fn as frag,lr as eventStream,B as dom,$t as doc,jt as cssLoader,Or as addCSS,Lt as __,Et as Yvee,Pt as Time,j as Stateful,N as StateHook,Y as State,cn as Routes,pn as Render,st as Ref,vr as QState,mt as Pager,rt as Meta,Js as IfClient,c as $};
|
|
1
|
+
var Sn=Object.defineProperty;var Mn=(t,n)=>{for(var r in n)Sn(t,r,{get:n[r],enumerable:!0,configurable:!0,set:(o)=>n[r]=()=>o})};var L=function(t,n,r,o){var i=arguments.length,f=i<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,r):o,u;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")f=Reflect.decorate(t,n,r,o);else for(var m=t.length-1;m>=0;m--)if(u=t[m])f=(i<3?u(f):i>3?u(n,r,f):u(n,r))||f;return i>3&&f&&Object.defineProperty(n,r,f),f};var g=(t,n)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(t,n)};var Et={};Mn(Et,{isWindow:()=>$t,isUndefined:()=>Un,isStr:()=>V,isPromise:()=>Rn,isPlainObject:()=>X,isObject:()=>qn,isObj:()=>Y,isNumber:()=>K,isNum:()=>yt,isNull:()=>ot,isNotWindow:()=>$,isNotNull:()=>Qn,isModule:()=>et,isInt:()=>Ht,isFN:()=>E,isDefined:()=>Xn,isClassOrId:()=>Fn,isBool:()=>P,isAsync:()=>Zn,isArraybuff:()=>An,isArr:()=>x});var E=(t)=>typeof t==="function",Zn=(t)=>t.constructor.name==="AsyncFunction",Rn=(t)=>!!t&&typeof t.then==="function",K=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},qn=(t)=>{return t&&typeof t==="object"&&!Array.isArray(t)},X=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},et=(t)=>{return t&&typeof t==="object"&&t[Symbol.toStringTag]==="Module"},An=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Fn=(t)=>{return t.startsWith(".")||t.startsWith("#")},P=(t)=>typeof t==="boolean",V=(t)=>typeof t==="string",x=(t)=>Array.isArray(t),Y=(t)=>typeof t==="object",yt=(t)=>typeof t==="number",ot=(t)=>t===null,Qn=(t)=>t===null,Un=(t)=>typeof t==="undefined",Xn=(t)=>typeof t!=="undefined",Ht=(t)=>{return Number.isInteger(Number(t))},$t=typeof window!=="undefined",$=typeof window==="undefined";var Bn=(t)=>{if($)return;return t()};function Pt(t,n){b(n).forEach(([r,o])=>{Vt(t,r,{value:o,writable:!1,configurable:!1,enumerable:!0})})}var lt=(t)=>{return x(t)?t:[t]};class J{static set i(t){console.info(...lt(t))}static set e(t){console.error(...lt(t))}static set w(t){console.warn(...lt(t))}}class D{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??B(5),t?.includes("-")){let[n,r]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=n,this._c=K(r)?parseInt(r):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Cn=(t)=>Array.from({length:t},(n,r)=>r),dt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ot="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),Nt=(t)=>{return JSON.parse(t)};var q=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},B=(t)=>{let n=dt+Ot,r=Cn(10).join("");return Array.from({length:t},(o,i)=>n+(i?r:"")).reduce((o,i)=>{return o+=i.charAt(Math.floor(Math.random()*i.length))},"")},wn=(t=6,n)=>{if(!n)return Math.floor(Math.random()*t);return Math.round(Math.random()*(n-t)+t)},_t=()=>{let t=[...dt,...Ot],n=wn(0,t.length);return t[n]};class T extends Map{obj(t){t&&b(t).forEach(([n,r])=>this.set(n,r))}map(t){t.forEach((n,r)=>{if(n instanceof T)this.set(r,n);else if(x(n)){if(this.lacks(r))this.set(r,[]);this.get(r).push(...n)}else if(Y(n))this.ass(r,n);else this.set(r,n)})}ass(t,n){if(!this.has(t))this.set(t,{});h(this.get(t),n)}lacks(t){return!this.has(t)}init(t,n){return this.has(t)?this.get(t):this.set(t,n).get(t)}}var{values:M,keys:j,entries:b}=Object;var{defineProperty:Vt,assign:h}=Object,at=(t,n)=>Object.hasOwn(t,n),C=(t)=>{return Object.keys(t).length},it=(t,n)=>{if(!n.has(t))n.set(t,new T);return n.get(t)},d=(t,n)=>{if(!n.has(t))n.set(t,[]);return n.get(t)},Dt=(t,n)=>{let r={added:{},removed:{},modified:{}},o=j(t),i=j(n);for(let f of i){let u=t[f],m=n[f];if(!(f in t))r.added[f]=m;else if(x(u)&&x(m)){if(S(u)!==S(m))r.modified[f]={old:u,new:m}}else if(Y(u)&&Y(m)&&!ot(u)&&!ot(m)){let s=Dt(u,m);if(C(s.added)||C(s.removed)||C(s.modified))r.modified[f]={old:u,new:m}}else if(u!==m)r.modified[f]={old:u,new:m}}for(let f of o)if(!(f in n))r.removed[f]=t[f];return r};function kt(t,n){if(t.size!==n.size)return!1;for(let r of t)if(!n.has(r))return!1;return!0}var vt=(t)=>{return M(t).some((n)=>{return C(n)})};var Z=(t,n,r)=>{let o=r.value;return{configurable:!0,get(){if(this===t.constructor.prototype)return o;let i=o.bind(this);return Object.defineProperty(this,n,{value:i,configurable:!0,writable:!0}),i}}};var G=(t,n)=>{return{name:t,content:n}},Gn=(t,n)=>{return{property:t,content:n}},Jn=(t,n)=>{return{"http-equiv":t,content:n}};class O{metas=[];constructor(t){t&&this.metas.push(G("description",t))}author(t){return this.meta=G("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=G("keywords",t.join(", ")),this}viewport(t){let n=b(t).map(([r,o])=>[q(r),String(o)].join("="));return this.meta=G("viewport",n.join(", ")),this}httpEquiv(t){return b(t).forEach(([n,r])=>{this.meta=Jn(q(n),String(r))}),this}robots(...t){return this.meta=G("robots",t.join(", ")),this}themeColor(t){return this.meta=G("theme-color",t),this}openGraph(t){return b(t).forEach(([n,r])=>{this.meta=Gn("og:"+n,String(r))}),this}twitter(t){return b(t).forEach(([n,r])=>{this.meta=G("twitter:"+n,String(r))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class Yt{}var jn=["charset","name","property","http-equiv"],tn=(t,n,r=!1,o={})=>{n.forEach((i)=>{for(let f of jn)if(f in i){let u=i[f];if(r)h(i,{x:!0});else if(!("x"in i))h(i,o);t[`${f}_${f==="charset"?"":u}`]=i}})},zn=(t,n,r=!1,o={})=>{n.forEach((i)=>{if("href"in i){let f=i.href;if(r)h(i,{x:!0});else if(!("x"in i))h(i,o);t[`${f}`]=i}})};class nn{_head;idm;mark;push;constructor({initial:t,mark:n,push:r}={}){this._head=new T(t),this.mark=n||!1,this.push=r||{}}set head(t){b(t).forEach(([n,r])=>{if(n==="title"||n==="base"){if(r!==void 0){if(n=="base"){if(this.mark)h(r[0]||{},{x:!0})}this._head.set(n,r)}return}if(r instanceof O)return tn(this._head.init("meta",{}),r.metas,this.mark,this.push);if(!x(r))return;switch(n){case"meta":return tn(this._head.init("meta",{}),r,this.mark,this.push);case"link":return zn(this._head.init("link",{}),r,this.mark,this.push);case"script":if(r.length){this._head.init(n,[]);let o=r.map((i)=>{if(!i.yid&&this.idm)i.yid="sc"+this.idm.mid;if(this.mark)h(i,{x:!0});else if(!("x"in i))h(i,this.push);return i});this._head.get(n).push(...o)}return}})}get head(){return this._head}set id(t){this.idm=new D(t)}}var Lt=(t)=>{return b(t??{}).reduce((n,[r,o])=>{return n.push(P(o)&&o?r:`${r}="${o}"`),n},[""]).join(" ")},rn=(t)=>{let n=new Set;if(!t)return"";let r=[...t].reduce((o,[i,f])=>{if(i==="meta"||i==="link")f=M(f);if(V(f)){if(i==="title")n.add(`<${i}>${f}</${i}>`);else o.add(`<${i}>${f}</${i}>`);return o}if(!x(f))return o;if(i==="base"){let m=f.slice(-1);if(m)return n.add(`<${i}${Lt(m[0])}>`),o}return f.map((m)=>{if(i==="script"){let s={...m},e="";if("importmap"in s)s.type="importmap",e=JSON.stringify(s.importmap),delete s.importmap;else if("body"in s)e=s.body,delete s.body;return`<${i}${Lt(s)}>${e}</${i}>`}return`<${i}${Lt(m)}>`}).forEach((m)=>{if(m.includes('type="module"'))n.add(m);else if(m.includes("<meta"))n.add(m);else o.add(m)}),o},new Set);return[...n,...r].join("")};class N{lang="en";htmlHead;head;constructor({mark:t,push:n}={}){this.htmlHead=new T,this.head=(r={})=>{let o=new nn({initial:this.htmlHead,mark:t,push:n}),{link:i,script:f,meta:u,title:m,description:s,css:e,js:y}=r;if(s)o.head={meta:[{name:"description",content:s}]};if(pn(o,{css:e,js:y}),"base"in r)o.head={base:r.base};o.head={script:f,title:m,meta:u,link:i},this.htmlHead=o.head}}}var pn=(t,n)=>{let{css:r,js:o}=n;if(r){let f=(x(r)?r:[r]).map((u)=>({rel:"preload stylesheet",href:u,as:"style"}));t.head={link:[...f]}}if(o){let f=(x(o)?o:[o]).map((u)=>({src:u}));t.head={script:[...f]}}};var St=async(t)=>{if($)return;return new Promise((n,r)=>{let o=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";b(t).forEach(([i,f])=>{o.setAttribute(i,f)}),o.onload=()=>n(o),o.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(o)})};var on=(t)=>{if($)return;return new Promise((n,r)=>{let o=document.createElement("script"),i="";if("importmap"in t)t.type="importmap",i=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)i=t.body,delete t.body;if(i)o.textContent=i;b(t).forEach(([f,u])=>{o.setAttribute(f,u)}),o.onload=()=>n(o),o.onerror=()=>r(new Error("Failed to load Script")),document.head.appendChild(o),requestAnimationFrame(()=>n("Script executed"))})},Wn=()=>{let n=document.querySelector("#d-css")?.sheet;if(n)return n;let r=document.createElement("style");return r.id="d-css",document.head.appendChild(r),r.sheet},cn=(t,n)=>{for(let r=0;r<t.cssRules.length;r++)if(t.cssRules[r].selectorText===n)return!0;return!1},In=(t)=>Object.entries(t).map(([n,r])=>`${q(n)}: ${r};`).join(" ");function Kn(t,n={}){if($)return;let r=Wn();if(!r)return;if(!cn(r,t))r.insertRule(`${t} { ${In(n)} }`,r.cssRules.length)}var fn=(t,n=!1)=>{if(K(t))return[+t,Ht(t)?"int":"float"];if(n&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},ft=(t)=>{let n=t.startsWith("/")?t:"/"+t,r=n.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[o,i]=r.reduce(([f,u],m)=>{if(m.includes("<")){let s=m.match(/(?<=<)[^/].*?(?=>|$)/g);if(s?.length){let[e,y]=s[0].split(":");if(e)f.push(e),u.push(y||"_")}}else f.push(m===">"?"/":m);return[f,u]},[[],[]]);if(n.endsWith("/")&&n.length>1)o.push("/");return{parsed:o,args:i}};class ut{storage;constructor(){this.storage=new T}cache(t,n){if(this.storage.lacks(t))this.storage.set(t,n());return this.storage.get(t)}}var Pn=["int","float","file","uuid","string"];class z{_storage;CC;constructor(){this._storage=new T,this.CC=new ut}set(t){let{parsed:n,path:r}=t,o=S(n);if(!this._storage.get(o))this._storage.set(o,t);else throw`path: ${r} already used.`}get(t){let{parsed:n}=this.CC.cache(t,()=>ft(t)),r={},o=this._storage.get(S(n));if(!o&&t!=="/")for(let i of this._storage.keys()){let f=[],u=Nt(i);if(n.length===u.length){let m=u.map((y,w)=>{let F=fn(n[w],n.length-1===w);if(y===F[0])return F[0];if(Pn.includes(F[1]))return f.push(F[0]),F[1];return y}),s=S(m);if(this._storage.has(s)){o=this._storage.get(s),o?.args.forEach((y,w)=>{r[y]=f[w]});break}}}return[o,r]}keys(){return this._storage.keys()}}class mt{path="";parsed=[];args=[];constructor(t){Pt(this,{path:t,...ft(t)})}}class Mt{date;constructor(t){this.date=t?new Date(t):new Date}delta(t=null,n=!1){let r=Mt.delta(this.date.getTime(),t);return n?new Date(r):r}timed(t){if(!t)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((r,[o,i])=>{let f=t[o];return f?new Date(r[`set${i}`](r[`get${i}`]()+f)):r},new Date(this.date))}static delta(t,n=null){return n?n-t:t-Date.now()}static local(t){return new Date(t).toLocaleString()}static get now(){return Date.now()}}class Zt{static rand(t=6,n){if(n)return Math.floor(Math.random()*(n-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,n=null){return Array(t).fill(n)}static new({dom:t,id:n,inner:r}){let o=document.createElement(t);if(n)o.id=n;if(r)o.innerHTML=r;return o}static randFrom(t){if(Array.isArray(t)){let n=t.length,r=this.rand(0,n-1);return t[r]}else if(typeof t=="object"){let n=j(t),r=n.length,o=this.rand(0,r-1);return n[o]}}static randArray(t=[],n=1,r=!1){let o=[],i=r?new Set:null;while((r?i.size:o.length)<n){let f=t[Zt.rand(0,t.length-1)];r?i.add(f):o.push(f)}return r?[...i]:o}static randomAZ=_t;static makeID=B;static class(t,...n){let r=n;if(t?.class)r.push(...x(t.class)?t.class:[t.class]);t.class=n}static get O(){return{vals:M,keys:j,items:b,has:at,ass:h,len:(t={})=>j(t).length}}static get is(){return Et}static get return(){return un}static sleep=(t=1000)=>new Promise((n)=>setTimeout(n,t));static get screen(){let{innerWidth:t}=window,n={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},r=b(n).reverse();for(let o=0;o<r.length;o++){let[i,f]=r[o];if(f)return i}return}bytes(t){if(t===0)return"0 Bytes";let n=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(n));return parseFloat((t/Math.pow(n,o)).toFixed(2))+" "+r[o]}static format(t){return new mn(t)}}class un{static arr(t){return t?x(t)?t:[t]:[]}static num(t,n=0){let r=parseFloat(t);return isNaN(r)?n:r}static str(t){return String(t)}static arr2obj(t,n=!1){return t.reduce((r,o,i)=>{if(n)r[o]=i;else r[i]=o;return r},{})}}class mn{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}async function p(t,n,{id:r="stateHook",init:o}={}){let i=[],f=()=>n.map((m)=>m.value),u=async()=>{await t(...f())};if(n.forEach((m)=>{i.push(m.hook(u)(r))}),o)await u();return()=>{i.forEach((m)=>m())}}var sn=(t)=>{t.forEach((n)=>n())};var Vn=(t,n)=>{for(let[r,o]of t){let i=W(r);if(!i){t.delete(r);continue}o.forEach((f)=>{f.call(i,n)})}};class A extends EventTarget{options;deep;verify;hooks=new T;states=new T;_value;listening=!1;end;constructor(t,n={},r=!0,o=!0){super();this.options=n;this.deep=r;this.verify=o;this._value=t}get value(){return this._value}set value(t){if(!this.verify){this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(X(this._value)||x(this._value)){let n=Dt(this._value,t);if(!vt(n))return}else if(this._value instanceof Set){if(!kt(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(n)=>{if(sn(this.hooks),Vn(this.states,n.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,n){return(r)=>{if(it(r,this.states).set(n,t),!$&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(r))this.states.get(r)?.delete(n)}}}hook(t){return(n)=>{if(this.hooks.set(n,t),!$&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(n))this.hooks.delete(n)}}}}function R(t,n={}){return new A(t,n,!0)}function dn(t,n=!1){return new A(t,{},!1,n)}class Rt{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,n={}){return this.e.animate(t,n)}get slide(){let t=({x:n=0,y:r=0},o={})=>{h(this.opt,o);let i=[[n,r],[0,0]].map(([f,u])=>({transform:`translateX(${f}rem) translateY(${u}rem)`}));return this.e.animate(i,this.opt),this};return{left:(n={})=>{return t({x:-2},n)},right:(n={})=>{return t({x:2},n)},up:(n={})=>{return t({y:2},n)},down:(n={})=>{return t({y:-2},n)}}}fade(t={}){h(this.opt,t);let n=[0,1].map((r)=>({opacity:r}));return this.e.animate(n,this.opt),this}shake(t="Y",n={}){h(this.opt,n);let r=[0,5,-5,5,0].map((o)=>({transform:`translate${t}(${o}px)`}));return this.e.animate(r,this.opt),this}color(t=[],n={}){h(this.opt,n);let r=Array.isArray(t)?t.map((o)=>({color:o})):{color:t};return this.e.animate(r,this.opt),this}bg(t=[],n={}){h(this.opt,n);let r=Array.isArray(t)?t.map((o)=>({backgroundColor:o})):{backgroundColor:t};return this.e.animate(r,this.opt),this}bounce(t=1,n={}){h(this.opt,n);let r=[0.5,t,1].map((o)=>({transform:`scale(${o})`}));return this.e.animate(r),this}}var _=(t)=>{if(x(t))return t.filter((n)=>n!==void 0).join(" ");else if(Y(t)){if(X(t))return S(t)}else if(E(t))return _(t());else if(t!==void 0&&t!==null)return P(t)?t?"":"false":String(t);return""};function On(t,n){switch(n??t){case"style":return function(r){this.style.setProperty(t,r)};default:return function(r){this.setAttribute(t,r)}}}class qt{attr;constructor(t={}){this.attr=t}get(t,n=this.attr,r){let o=(i,f)=>{if(x(f))t.attr_push(i,_(f),r);else if(f instanceof A){let u=r?`${r}_${i}`:i;t.states.push(f.call(On(i,r),u)),o(i,f.value)}else if(Y(f)){if(X(f)&&!r)this.get(t,f,i)}else t.attr_push(i,_(f),r)};b(n).forEach(([i,f])=>{if(i==="ref"){if(f instanceof a)t.events.obj({element(){f.element=this}})}else if(["on"].includes(i))Y(n.on)&&t.events.obj(n.on);else{if(f===void 0)return;o(i,f)}})}unload(t){let n=void 0;if(t in this.attr)n=this.attr[t],delete this.attr[t];return n}}var Nn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],_n=(t)=>Nn.includes(t);function an(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var st=(t,n)=>{if(x(t))return t.map((r)=>st(r,n)).join("");else if(t instanceof c){let{ctx:r,oz:o}=Qt(t,n.IDM);return n.OZ.push(o),r}else if(Y(t))return S(t);else if(E(t))return st(t(),n);else if(t!==void 0&&t!==null)return an(t);return""},ht=(t,n)=>{let r=new D(n),o=new k(r.id,r);return{ctx:st(t,o),catt:o}};function kn(t){let n=this.id;if(n){let{ctx:r,catt:o}=ht(t,n);if(this.innerHTML!==r)this.innerHTML=r,Q.RPS(o.OZ)}}var At=(t,n,r,o=[])=>{if(x(t))t.forEach((i)=>{At(i,t.length,r,o)});else if(t instanceof A)if(n>1)At(l("div",{},t),n,r,o);else{let i=t.value,f=i instanceof c?"dom":"ctx",{ctx:u,catt:m}=ht(i,r.xid+"-0");r.xid=m.xid,o.push(u),r.OZ.push(m.OZ),r.states.push(t.call(kn,f))}else o.push(st(t,r))};class Ft{tag;ctx;closing;constructor(t="",n){this.tag=t;this.ctx=n;let r=_n(t);this.closing=r?"":`</${t}>`}process(t,n=this.ctx,r=[]){return n.forEach((o)=>{At(o,n.length,t,r)}),r.join("")}get(t){let n=this.process(t);if(!this.tag)return n;if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${n}${this.closing}`}}class Bt{e;query;constructor(t,n){this.e=t;this.query=n}get a(){return new Rt(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((n)=>n)}return[]}get attr(){let t=this.e;return{has:(n)=>{return t.hasAttribute(n)},get:(n)=>{return t.getAttribute(n)},del:(n)=>{return t.removeAttribute(n),this},set:(n)=>{for(let r in n){let o=n[r];if(n[r]!==void 0)t.setAttribute(r,_(o))}return this}}}get children(){return Array.from(this.e.children).map((t)=>H(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new U(t);return}get parent(){let t=this.e.parentElement;if(t)return new U(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,n=this;return{set:(r,o=0)=>{let i=t,f=()=>{b(r).forEach(([u,m])=>{if(u in i){if(i[u]!==m)i[u]=m}else if(m!==null)t.setProperty(u,String(m))})};if(E(o))n.on("transitionend",o);if(yt(o))setTimeout(f,o);else f();return n},get:(r)=>{let o=q(String(r));return t.getPropertyValue(o)},del:(...r)=>{r.forEach((o)=>{let i=q(String(o));t.removeProperty(i)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:n,oz:r}=Ut(t,Xt(this.id));this.e.insertAdjacentHTML("beforeend",n),Q.RPS(r)}set appendfirst(t){let{ctx:n,oz:r}=Ut(t,Xt(this.id));this.e.insertAdjacentHTML("afterbegin",n),Q.RPS(r)}set inner(t){let{ctx:n,oz:r}=Ut(t,Xt(this.id));this.e.innerHTML=n,Q.RPS(r)}set disabled(t){let n=this.e;if("disabled"in n)n.disabled=t}set id(t){this.e.id=t}set value(t){let n=this.e;n.value=t}}var Ut=(t,n)=>{let{ctx:r,catt:o}=ht(t,n);return{ctx:r,oz:o.OZ}},Xt=(t)=>t?`${t}-0`:t;class U extends Bt{constructor(t,n){super(t,n)}add(...t){return this.e.classList.add(...t.map((n)=>n.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...t.map((n)=>n.replace(/[^\w-]/,"")))}}remove(...t){return this.e.classList.remove(...t.map((n)=>n.replace(/[^\w-]/,""))),this}toggle(t,n){let r=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(r,n)}hasNode(t){return this.e.contains(t)}has(...t){let n=this.e.classList;return t.every((r)=>n.contains(r))}insert(t){return{HTML:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentHTML(t,r)}),this},element:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentElement(t,r)}),this},text:function(...n){return n.forEach((r)=>{this.e.insertAdjacentText(t,r)}),this}}}is(t){let n=this.e.classList,r=this.e.tagName.toLocaleLowerCase(),o=!0,i=!0;if(t.dom)i=t.dom==r?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((f)=>{o=o?n.contains(f):!1});else o=o?n.contains(t.class):!1;return o&&i}on(t,n,r=!1){let o=!1;if(t.indexOf("touch")>-1)o=!0;return this.e.addEventListener(t,n,{capture:r,passive:o}),this}remove_on(t,n,r=!1){return this.e.removeEventListener(t,n,r),this}timed(t,n=250){return setTimeout(()=>t(this),n),this}animate(t,n,r){let o={duration:300,easing:"ease",fill:"forwards"};if(E(n))r=n;else h(o,n);let i=this.e.animate(t,o);if(r)i.finished.then(r);return this}}var v=new T,W=(t)=>{if($)return;let n=v.get(t);if(n?.isConnected)return n;v.delete(t);let r=document.getElementById(t);if(!r)return;return v.set(t,r),r};function hn(){let t=[];for(let[n,r]of v)if(!r.isConnected)t.push(n),v.delete(n);return t}function H(t,n){let r=n?n:document;if(V(t)){let o=r.querySelector(t);if(o)return new U(o,t);return}else if(X(t)){let[[o,i]]=b(t),u=`${o==="id"?"#":"."}${i}`,m=r.querySelector(u);if(m)return new U(m,u);return}else return new U(t)}class a{state=new A(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new U(t);else this.state.value=void 0}get $(){return this.state.value}}var vn=()=>{return new a};var tr=(t,n,r)=>{return t.addEventListener(n,r),()=>{t.removeEventListener(n,r)}},tt={};class gt{events=new T;states=new T;windowEvents=new T;resetST=new T;resetEV=new T;get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:n,events:r,states:o}=t;if(n){if(r.size)this.events.set(n,r);if(o.length)this.states.set(n,o)}return this}push(t){return t.events.forEach((n,r)=>{n.forEach((o,i)=>{it(r,this.events).set(i,o)})}),t.states.forEach((n,r)=>{d(r,this.states).push(...n)}),this}get stage(){return this.events.forEach((t,n)=>{this.events.delete(n);let r=W(n);if(!r){this.events.delete(n);return}t.forEach((o,i)=>{switch(i){case"ready":case"element":o.apply(r,[r]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let f=i.replace(/^win/,"");this.windowEvents.init(f,new T).set(n,o);break;case"state":let[u,m,s]=o.apply(r,[r]),e=x(m)?m:[m];if(!e.length)break;let y=()=>e.map((F)=>F.value),w=()=>u(...y());if(s)w();e.forEach((F)=>d(n,this.resetST).push(F.call(w,n+"_state")(n)));break;default:d(n,this.resetEV).push(tr(r,i,o))}})}),this.processWindowEvents,this.states.forEach((t,n)=>{this.states.delete(n),t.forEach((r)=>{d(n,this.resetST).push(r(n))})}),this}get processWindowEvents(){let t=(n,r)=>{let o=0,i=!1,f=(m)=>{if(o=window.scrollY,!i)window.requestAnimationFrame(()=>{r.forEach((s,e)=>{let y=W(e);if(y)s.call(y,m);else this.windowEvents.get(n)?.delete(e)}),i=!1}),i=!0},u=(m)=>{r.forEach((s,e)=>{let y=W(e);if(y)s.call(y,m);else this.windowEvents.get(n)?.delete(e)})};return window.addEventListener(n,n==="scroll"?f:u),()=>{window.removeEventListener(n,n==="scroll"?f:u)}};return this.windowEvents.forEach((n,r)=>{if(n.size){if(!tt[r])tt[r]=t(r,n)}else if(tt[r])tt[r](),delete tt[r]}),this}reset(t){return t.forEach((n)=>{this.windowEvents.forEach((r,o)=>{if(r.has(n))r.delete(n)}),this.resetEV.get(n)?.forEach((r)=>{r()}),this.resetST.get(n)?.forEach((r)=>{r()}),this.resetST.delete(n),this.resetEV.delete(n)}),this}RPS(t){if(t){let n=hn();this.reset(n);let r=t.keys;if(r.length)this.reset(r).push(t).stage}return this}}var Q=new gt;class k{xid;IDM;map=new T;states=[];events=new T;OZ;constructor(t,n=new D,r){this.xid=t;this.IDM=n;this.OZ=r??new gt}attr_push(t,n,r){let o=r??t;if(!this.map.has(o))this.map.set(o,[]);let i=r?`${q(t)}:${n};`:n;this.map.get(o).push(i)}get attr(){let t=[""];return this.map.forEach((n,r)=>{let o=n.join("");t.push(o?`${r}="${o}"`:r)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}async function gn(t,n,r){let o=new D(n),i=l("main",{class:r},t);return Qt(i,o)}function Qt(t,n=new D){let{tag:r,attr:o,ctx:i}=t,f=n instanceof D?n:new D(n),u=f.mid,m=new k(u,f),s=new qt(o),e=new Ft(r,i);return s.get(m),{ctx:e.get(m),oz:m.OZ.set(m),id:m.id}}class c{tag;attr;ctx;constructor(t,n,r){this.tag=t;this.attr=n;this.ctx=r}}function l(t,n={},...r){if(E(t))return t(n??{},...r);return new c(t,n??{},r)}var nr=(t,...n)=>new c("",{},n);async function xn(t={},n){let r=H("link[rt]")?.all.map((o)=>()=>o.remove())||[];if(t&&C(t))for(let o of M(t)){if(o.x)continue;try{await St(o)}catch(i){J.e=["link error",{error:"Huntr @ link"}]}}return r}var rr=["charset","name","property","http-equiv"];async function Tn(t){let n={};if(H("meta")?.all.forEach((r)=>{let o=r.attributes;for(let i of rr)if(i in o){let f=o[i].value;n[`${i}_${i==="charset"?"":f}`]=r}}),t)b(t).forEach(([r,o])=>{if(r in n)H(n[r]).attr.set(o),delete n[r];else{let i=H(document.createElement("meta"));i.attr.set(o),document.head.append(i.e)}});return M(n).map((r)=>H(r).unload)}async function bn(t,n=!1){let r=H("script[rt]")?.all.map((o)=>()=>o.remove())||[];if(t&&C(t))for(let o of M(t)){if(o.x)continue;try{await on(o)}catch(i){J.e=["script error",{error:"Huntr @ script"}]}}return r}class nt extends Yt{path="";data={};args={};importArgs=[]}async function en(t,n=!1){if(!n&&t.fetch)h(t.data,await t.fetch());return await t.head?.(),[wt(await t.body?.(),t.importArgs),or.call(this,t)]}function wt(t,n=[]){let r=t||"";if(et(t)){let o=t.default;r=E(o)?o.apply({},n):o}return x(r)?r:[r]}function or(t){let n=new N({push:{rt:this.id}});return n.htmlHead=structuredClone(this.htmlHead),n.head(t),n.htmlHead}async function yn(t,n){document.title=t.get("title")||"",Ct(await xn(t.get("link"),n)),Ct(await bn(t.get("script")));let r=await Tn(t.get("meta"));Ct(r)}var Ct=(t)=>{t.forEach((n)=>n())};class xt{onChange;popListener;constructor(t=R(""),n){this.assertClient(),this.onChange=n,this.onChange?.(this.path(),history.state??{path:this.path()}),this.popListener=(r)=>{let o=r.state??{path:this.path()};t.value=o?.path||t.value,this.onChange?.(this.path(),o)},window.addEventListener("popstate",this.popListener)}path(){this.assertClient();let{pathname:t,search:n,hash:r}=window.location;return`${t}${n}${r}`}state(){return this.assertClient(),window.history.state??{path:this.path()}}navigate(t,n,r=""){this.assertClient();let o=this.resolve(t),i=this.path();if(this.samePath(i,o))return;let f={...n,path:o};window.history.pushState(f,r,o),this.onChange?.(this.path(),f)}replace(t,n,r=""){this.assertClient();let o=this.resolve(t),i=this.path();if(this.samePath(i,o))return;let f={...n,path:o};window.history.replaceState(f,r,o),this.onChange?.(this.path(),f)}back(){this.assertClient(),window.history.back()}forward(){this.assertClient(),window.history.forward()}destroy(){if(this.popListener)window.removeEventListener("popstate",this.popListener),this.popListener=void 0}resolve(t){let n=new URL(t,window.location.origin);return`${n.pathname}${n.search}${n.hash}`}samePath(t,n){return t===n}assertClient(){if(typeof window==="undefined"||typeof window.history==="undefined")throw new Error("BrowserPathHistory must be used in a client/browser environment.")}}class Gt{lang;head="";constructor(t,n){if(this.lang=t,n)this.head=rn(n)}body(t,n,r){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${n}"${r?" "+r:""}>${t}</body>`,"</html>"].join("")}}class rt{path="";data={};args={}}class Jt extends mt{cls;constructor(t,n){super(t);this.cls=n}}class Tt extends Jt{}class jt{storage=new z;error=new z}class zt extends jt{wss=new z;setRoute(t,n){this.storage.set(new Tt(t,n))}getRoute(t,n){let[r,o]=this.storage.get(t);if(!r){let[f=new Tt(t,Hn)]=this.getError(n),u=new f.cls;return u.args=o,h(u,{args:o})}let i=new r.cls;return h(i,{args:o})}setWss(t){}getWss(t){return this.wss.get(t)}setError(t,n){this.error.set(new Tt(t.toString(),n))}getError(t=404){return this.error.get(t.toString())}}class bt extends Jt{}class pt extends jt{setRoute(t,n){this.storage.set(new bt(t,n))}getRoute(t,n){let[r,o]=this.storage.get(t);if(!r){let[f=new bt(t,$n)]=this.getError(n),u=new f.cls;return u.args=o,h(u,{args:o})}let i=new r.cls;return h(i,{args:o})}setWss(t){}getWss(t){}setError(t,n){this.error.set(new bt(t.toString(),n))}getError(t=404){return this.error.get(t.toString())}}class Hn extends nt{body(){return l("div",{},this.path+" not found...")}}class $n extends rt{body(){return l("div",{},`${this.path} not found...`)}}class Wt extends N{storage=new zt;base;constructor(t="/",n=""){super({mark:!0});this.base=t?t.startsWith("/")?t:`/${t}`:"";let r=this.base;this.head({script:[{type:"module",src:"./index.js"}],...{base:[{href:r==="/"?r:`${r}/`,target:"_blank"}]},meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]})}route(t){return(n)=>{return this.storage.setRoute(t,n),n}}}L([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],Wt.prototype,"route",null);class En{id=B(5);path=R("");_root=R([]);Main(t){return l("main",{},this._root)}Button(t,...n){let r=this.path,{on:o,...i}=t,f={...o||{},click(u){u.preventDefault();let s=H(this).attr.get("tab");if(!s)return;r.value=s}};return l("button",{on:f,...i},...n)}}L([Z,g("design:type",Function),g("design:paramtypes",[typeof attr==="undefined"?Object:attr]),g("design:returntype",void 0)],En.prototype,"Main",null),L([Z,g("design:type",Function),g("design:paramtypes",[Object,Object]),g("design:returntype",void 0)],En.prototype,"Button",null);class ct extends En{storage=new pt;constructor(){super()}tab(t){return(n)=>{return this.storage.setRoute(t,n),n}}async load(t,n={}){this.path.value=this.path.value||t,await p(async(r)=>{this._root.value=await ir.call(this,r,n)},[this.path],{id:this.id,init:!0})}}L([Z,g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",void 0)],ct.prototype,"tab",null),L([Z,g("design:type",Function),g("design:paramtypes",[String,typeof obj==="undefined"?Object:obj]),g("design:returntype",Promise)],ct.prototype,"load",null);async function ir(t,n={},r=!1,o){let i=this.storage.getRoute(t,o);return h(i,{path:t,data:n}),wt(await i.body?.())}class It{path;args;route="/";isConnected=R(!1);data={};constructor(t,n={}){this.path=t;this.args=n;this.data=n}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var I=new T;class Kt{yvee;constructor(t){this.yvee=t}async load(t){if($)return;if(!I.has(t)){let[r,o]=this.yvee.storage.getWss(t);if(!r)return;let{cls:i,path:f}=r,u=new i(f,o).connect;return I.set(t,u),u}let n=I.get(t);return n.reconnect,n}unload(t){if($)return;if(I.has(t)){let n=I.get(t);if(!n)return;n.disconnect,I.delete(t)}}}class Dn extends Wt{pushHistory;id;data;path;_root;constructor(t="/",n="",r=!1){super(t,n);this.pushHistory=r;this.id=B(6),this.path=R("/"),this._root=R([]),this.data={}}Main(t){return l("main",{},this._root)}A(t,...n){let{on:r,...o}=t,i=this.path,f={...r||{},click(u){u.preventDefault();let m=H(this).path;i.value=m}};return l("a",{on:f,...o},...n)}}L([Z,g("design:type",Function),g("design:paramtypes",[typeof attr==="undefined"?Object:attr]),g("design:returntype",void 0)],Dn.prototype,"Main",null),L([Z,g("design:type",Function),g("design:paramtypes",[typeof aAttr==="undefined"?Object:aAttr,Object]),g("design:returntype",void 0)],Dn.prototype,"A",null);class Ln extends Dn{constructor({base:t,history:n,index:r}={}){super(t,r,n);let o=this;h(this,{get yvee(){return o}})}async render(t={}){let{id:n,data:r,class:o,isDev:i=!1}=t;if($t){let f=window.location.pathname;if(i)f=f.replace(/\/+$/g,"");this.path.value=f;let u=document.body.id;this.id=u;let[m,s]=await ln.call(this,this.path.value,o);return Q.push(s.oz),requestAnimationFrame(()=>{Q.stage,this.init(r)}),()=>{}}return async({path:f,data:u={},error:m=0})=>{if(n)this.id=n;this.path.value=f;let[s,e]=await ln.call(this,this.path.value,o,m,u,!0);return new Gt(this.lang,s).body(e.ctx,this.id)}}async init(t={}){let n=this.id,r=new xt(this.path);p(async(o)=>{let[i,f]=await Yn.call(this,o,t);await yn(f,n),this._root.value=i,this.pushHistory&&r.navigate(o)},[this.path],{id:n})}}L([Z,g("design:type",Function),g("design:paramtypes",[typeof renderConfig==="undefined"?Object:renderConfig]),g("design:returntype",Promise)],Ln.prototype,"render",null);async function Yn(t,n={},r=!1,o){let i=this.storage.getRoute(t,o);return h(i,{path:t,data:n}),await en.call(this,i,r)}async function ln(t,n,r,o={},i=!1){let[f,u]=await Yn.call(this,t,o,i,r);this._root.value=f;let m=await gn(this._root,this.id,n);return[u,m]}var fr=(t)=>{return(n)=>{t(n)}};export{It as websocket,vn as useRef,Kt as socket,J as log,nr as frag,l as dom,nt as doc,St as cssLoader,rt as content,Kn as addCSS,Zt as __,Ln as Yvee,Mt as Time,ct as Tabs,A as Stateful,p as StateHook,R as State,fr as Routes,a as Ref,dn as QState,xt as PathHistory,O as Meta,Bn as IfClient,H as $};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yvee",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Yvee JS framework",
|
|
5
5
|
"author": "Marky <markjotep@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"homepage": "https://github.com/MARKjotep/yvee#readme",
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"rollup": "^4.
|
|
31
|
-
"rollup-plugin-dts": "^6.2.
|
|
30
|
+
"rollup": "^4.47.1",
|
|
31
|
+
"rollup-plugin-dts": "^6.2.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"typescript": "^5.7.3"
|