yvee 0.0.7 → 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 +756 -453
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Yr=Object.defineProperty;var Lr=(t,r)=>{for(var n in r)Yr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(i)=>r[n]=()=>i})};var At={};Lr(At,{isWindow:()=>B,isUndefined:()=>qr,isStr:()=>tt,isPromise:()=>Cr,isPlainObject:()=>D,isObj:()=>$,isNumber:()=>Z,isNum:()=>St,isNull:()=>gt,isNotWindow:()=>T,isNotNull:()=>Xr,isInt:()=>Rt,isFN:()=>w,isDefined:()=>Br,isClassOrId:()=>Fr,isBool:()=>v,isAsync:()=>Pr,isArraybuff:()=>Zr,isArr:()=>m});var w=(t)=>typeof t==="function",Pr=(t)=>t.constructor.name==="AsyncFunction",Cr=(t)=>!!t&&typeof t.then==="function",Z=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},D=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},Zr=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Fr=(t)=>{return t.startsWith(".")||t.startsWith("#")},v=(t)=>typeof t==="boolean",tt=(t)=>typeof t==="string",m=(t)=>Array.isArray(t),$=(t)=>typeof t==="object",St=(t)=>typeof t==="number",gt=(t)=>t===null,Xr=(t)=>t===null,qr=(t)=>typeof t==="undefined",Br=(t)=>typeof t!=="undefined",Rt=(t)=>{return Number.isInteger(Number(t))},B=typeof window!=="undefined",T=typeof window==="undefined";function ct(t,r){g(r).forEach(([n,i])=>{Nt(t,n,{value:i,writable:!1,configurable:!1,enumerable:!0})})}var Ht=(t)=>{return m(t)?t:[t]};class E{static set i(t){console.info(...Ht(t))}static set e(t){console.error(...Ht(t))}static set w(t){console.info(...Ht(t))}}class H{_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 Ir=(t)=>Array.from({length:t},(r,n)=>n),_t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ot="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),kt=(t)=>{return JSON.parse(t)};var j=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(t)=>{let r=_t+Ot,n=Ir(10).join("");return Array.from({length:t},(i,o)=>r+(o?n:"")).reduce((i,o)=>{return i+=o.charAt(Math.floor(Math.random()*o.length))},"")},Ur=(t=6,r)=>{if(!r)return Math.floor(Math.random()*t);return Math.round(Math.random()*(r-t)+t)},vt=()=>{let t=[..._t,...Ot],r=Ur(0,t.length);return t[r]};var tr=(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&&g(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof a)this.set(n,r);else if(m(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if($(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});p(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:g}=Object;var{defineProperty:Nt,assign:p}=Object,rr=(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)},rt=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Dt=(t,r)=>{let n={added:{},removed:{},modified:{}},i=W(t),o=W(r);for(let e of o){let f=t[e],s=r[e];if(!(e in t))n.added[e]=s;else if(m(f)&&m(s)){if(S(f)!==S(s))n.modified[e]={old:f,new:s}}else if($(f)&&$(s)&&!gt(f)&&!gt(s)){let u=Dt(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 i)if(!(e in r))n.removed[e]=t[e];return n};function nr(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var ir=(t)=>{return A(t).some((r)=>{return R(r)})};var I=(t,r)=>{return{name:t,content:r}},Jr=(t,r)=>{return{property:t,content:r}},Wr=(t,r)=>{return{"http-equiv":t,content:r}};class nt{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=g(t).map(([n,i])=>[j(n),String(i)].join("="));return this.meta=I("viewport",r.join(", ")),this}httpEquiv(t){return g(t).forEach(([r,n])=>{this.meta=Wr(j(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 g(t).forEach(([r,n])=>{this.meta=Jr("og:"+r,String(n))}),this}twitter(t){return g(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 jt{title;description;base;meta;link;script;css}var Qr=["charset","name","property","http-equiv"],or=(t,r)=>{r.forEach((n)=>{for(let i of Qr)if(i in n){let o=n[i];t[`${i}_${i==="charset"?"":o}`]=n}})},Gr=(t,r)=>{r.forEach((n)=>{if("href"in n){let i=n.href;t[`${i}`]=n}})};class Q{_head;idm;constructor(t){this._head=new a(t)}set head(t){g(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof nt)return or(this._head.init("meta",{}),n.metas);if(!m(n))return;switch(r){case"meta":return or(this._head.init("meta",{}),n);case"link":return Gr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let i=n.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(r).push(...i)}return}})}get head(){return this._head}set id(t){this.idm=new H(t)}}var it=(t)=>{return g(t??{}).reduce((r,[n,i])=>{return r.push(v(i)&&i?n:`${n}="${i}"`),r},[""]).join(" ")},er=(t)=>{let r=new Set;if(!t)return"";let n=[...t].reduce((i,[o,e])=>{if(o==="meta"||o==="link")e=A(e);if(tt(e)){if(o==="title")r.add(`<${o}>${e}</${o}>`);else i.add(`<${o}>${e}</${o}>`);return i}if(!m(e))return i;if(o==="base"){let s=e.slice(-1);if(s)return r.add(`<${o}${it(s[0])}>`),i}return e.map((s)=>{if(o==="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`<${o}${it(u)}>${h}</${o}>`}return`<${o}${it(s)}>`}).forEach((s)=>{if(s.includes('type="module"'))r.add(s);else if(s.includes("<meta"))r.add(s);else i.add(s)}),i},new Set);return[...r,...n].join("")};class ot{lang="en";htmlHead;head;constructor(){this.htmlHead=new a,this.head=(t={})=>{let r=new Q(this.htmlHead),{css:n,description:i,...o}=t;if(i)r.head={meta:[{name:"description",content:i}]};if(n){let f=(m(n)?n:[n]).map((s)=>({rel:"preload stylesheet",href:s,as:"style"}));r.head={link:[...f]}}r.head=o,this.htmlHead=r.head}}}var Mt=(t)=>{if(T)return;return new Promise((r,n)=>{let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";g(t).forEach(([o,e])=>{i.setAttribute(o,e)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},sr=(t)=>{if(T)return;return new Promise((r,n)=>{let i=document.createElement("script"),o="";if("importmap"in t)t.type="importmap",o=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)o=t.body,delete t.body;if(o)i.textContent=o;g(t).forEach(([e,f])=>{i.setAttribute(e,f)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(i),requestAnimationFrame(()=>r("Script executed"))})},Kr=()=>{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},zr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},Vr=(t)=>Object.entries(t).map(([r,n])=>`${j(r)}: ${n};`).join(" ");function Nr(t,r={}){if(T)return;let n=Kr();if(!n)return;if(!zr(n,t))n.insertRule(`${t} { ${Vr(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"]},G=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=n.reduce(([e,f],s)=>{if(s.includes("<")){let u=s.match(/(?<=<)[^/].*?(?=>|$)/g);if(u?.length){let[h,l]=u[0].split(":");if(h&&l)e.push(h),f.push(l)}}else e.push(s===">"?"/":s);return[e,f]},[[],[]]);if(r.endsWith("/")&&r.length>1)i.push("/");return{parsed:i,args:o}};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 fr=["int","float","file","uuid","string"],Tt=(t,r)=>{let n={},i=[],{parsed:o}=G(t),{parsed:e,args:f}=G(r);if(o.length===e.length)e.map((s,u)=>{let h=Yt(o[u],o.length-1===u);if(s===h[0])return h[0];if(fr.includes(h[1]))return i.push(h[0]),h[1];return s}),f.forEach((s,u)=>{n[s]=i[u]});return n};class K{_storage;CC;constructor(){this._storage=new a,this.CC=new pt}set(t){let{parsed:r,path:n}=t,i=S(r);if(!this._storage.get(i))this._storage.set(i,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=this.CC.cache(t,()=>G(t)),n={},i=this._storage.get(S(r));if(!i&&t!=="/")for(let o of this._storage.keys()){let e=[],f=kt(o);if(r.length===f.length){let s=f.map((l,b)=>{let c=Yt(r[b],r.length-1===b);if(l===c[0])return c[0];if(fr.includes(c[1]))return e.push(c[0]),c[1];return l}),u=S(s);if(this._storage.has(u)){i=this._storage.get(u),i?.args.forEach((l,b)=>{n[l]=e[b]});break}}}return[i,n]}}class et{path="";parsed=[];args=[];constructor(t){ct(this,{path:t,...G(t)})}}class ur{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 i=document.createElement(t);if(r)i.id=r;if(n)i.innerHTML=n;return i}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,i=this.rand(0,n-1);return r[i]}}static randomAZ=vt;static makeID=x;static class(t,r){let n=r;if(t?.class)n.push(...m(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:A,keys:W,items:g,has:rr,ass:p,len:(t={})=>W(t).length}}static get is(){return At}static get return(){return hr}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=g(r).reverse();for(let i=0;i<n.length;i++){let[o,e]=n[i];if(e)return o}return}bytes(t){if(t===0)return"0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,i)).toFixed(2))+" "+n[i]}static format(t){return new ar(t)}}class hr{static arr(t){return m(t)?t:[t]}static num(t,r=0){let n=parseFloat(t);return isNaN(n)?r:n}}class ar{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}var Lt={},U={};class lr{stream;url;constructor(t,r){if(this.url=t,t in Lt)this.stream=Lt[t];else this.stream=new EventSource(t,{withCredentials:r}),Lt[t]=this.stream,U[this.url]={}}on(t){let r=this.stream;return g(t).forEach(([n,i])=>{if(n in U[this.url])U[this.url][n].forEach((o)=>{this.stream.removeEventListener(n,o)}),U[this.url][n]=[];if(r.addEventListener(n,i),!(n in U[this.url]))U[this.url][n]=[];U[this.url][n].push(i)}),this}}function mr(t,r=!0){return new lr(t,r)}class gr{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[i,o]=g(t)[0];if(this.key=i,this.state=o,n){let e=this.as[n];this.state.value=e}V((e)=>{this.set=e},[this.state],{id:this.key})}else this.key=t,this.state=null}get as(){return new gr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}set set(t){let r=$(t)?S(t):String(t);this.storage.setItem(this.key,r)}get remove(){this.storage.removeItem(this.key);return}}var cr={get:(t)=>new z(t,"local"),init:(t,r)=>new z(t,"local",r)};var dr={get:(t)=>new z(t,"session")};class bt extends et{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class pr extends et{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Pt 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(i)=>{return i.route=n,this.storage.set(new bt(n,x(5),i)),i}},this.wss=(r)=>{let n=this._base(r);return(i)=>{return i.route=n,this.wssStorage.set(new pr(n,x(5),i)),i}},this.error=(...r)=>{return(n)=>{if(r.length)r.forEach((i)=>{this.errorStorage.set(new bt(i.toString(),x(5),n))});else this.errorStorage.set(new bt("404",x(5),n));return n}}}_base(t){return tr(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 st=new a,N=(t)=>{if(T)return;let r=st.get(t);if(r?.isConnected)return r;st.delete(t);let n=document.getElementById(t);if(!n)return;return st.set(t,n),n};function Tr(){let t=[];return st.forEach((r,n)=>{if(!r.isConnected)t.push(n),st.delete(n)}),t}function V(t,r,{id:n="stateHook",init:i}={}){if(T)return()=>{};let o=[],e=()=>r.map((s)=>s.value),f=()=>{t(...e())};if(r.forEach((s)=>{o.push(s.hook(f)(n))}),i)f();return()=>{o.forEach((s)=>s())}}var br=(t)=>{t.forEach((r)=>r())};var _r=(t,r)=>{for(let[n,i]of t){let o=N(n);if(!o){t.delete(n);continue}i.forEach((e)=>{e.call(o,r)})}};class Y extends EventTarget{options;hooks=new a;states=new a;_value;listening=!1;end;constructor(t,r){super();this.options=r;this._value=t}get value(){return this._value}set value(t){if(D(this._value)||m(this._value)){let r=Dt(this._value,t);if(!ir(r))return}else if(this._value instanceof Set){if(!nr(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(br(this.hooks),_r(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),!T&&!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),!T&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function M(t,r){return new Y(t,r)}var _=(t)=>{if(m(t))return t.filter((r)=>r!==void 0).join(" ");else if($(t)){if(D(t))return S(t)}else if(w(t))return _(t());else if(t!==void 0&&t!==null)return v(t)?t?"":"false":String(t);return""};function Or(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class Ct{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let i=(o,e)=>{if(m(e))t.attr_push(o,_(e));else if(e instanceof Y){let f=n?`${n}_${o}`:o;t.states.push(e.call(Or(o,n),f)),i(o,e.value)}else if($(e)){if(D(e)&&!n)this.get(t,e,o)}else t.attr_push(o,_(e),n)};g(r).forEach(([o,e])=>{if(o==="ref"){if(e instanceof ft)t.events.obj({element(){e.element=this}})}else if(["on"].includes(o))$(r.on)&&t.events.obj(r.on);else i(o,e)})}}class F{xid;IDM;map=new a;states=[];events=new a;OZ;constructor(t,r=new H,n){this.xid=t;this.IDM=r;this.OZ=n??new yt}attr_push(t,r,n){let i=n??t;if(!this.map.has(i))this.map.set(i,[]);let o=n?`${j(t)}:${r};`:r;this.map.get(i).push(o)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let i=r.join("");t.push(i?`${n}="${i}"`: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 kr=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},ut={};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:i}=t;if(r){if(n.size)this.events.set(r,n);if(i.length)this.states.set(r,i)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((i,o)=>{dt(n,this.events).set(o,i)})}),t.states.forEach((r,n)=>{rt(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=N(r);if(!n){this.events.delete(r);return}t.forEach((i,o)=>{switch(o){case"ready":case"element":i.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=o.replace(/^win/,"");this.windowEvents.init(e,new a).set(r,i);break;case"state":let[f,s,u]=i.apply(n,[n]),h=m(s)?s:[s],l=()=>h.map((c)=>c.value),b=()=>f(...l());if(u)b();h.forEach((c)=>rt(r,this.resetST).push(c.call(b,r+"_state")(r)));break;default:rt(r,this.resetEV).push(kr(n,o,i))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{rt(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let i=0,o=!1,e=(s)=>{if(i=window.scrollY,!o)window.requestAnimationFrame(()=>{n.forEach((u,h)=>{let l=N(h);if(l)u.call(l,s);else this.windowEvents.get(r)?.delete(h)}),o=!1}),o=!0},f=(s)=>{n.forEach((u,h)=>{let l=N(h);if(l)u.call(l,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(!ut[n])ut[n]=t(n,r)}else if(ut[n])ut[n](),delete ut[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,i)=>{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=Tr();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var L=new yt;var vr=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],tn=(t)=>vr.includes(t);function rn(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var xt=(t,r)=>{if(m(t))return t.map((n)=>xt(n,r)).join("");else if(t instanceof O){let n=t.__(r.IDM),{ctx:i,oz:o}=n;return r.OZ.push(o),i}else if($(t))return S(t);else if(w(t))return xt(t(),r);else if(t!==void 0&&t!==null)return rn(t);return""},wt=(t,r)=>{let n=new H(r),i=new F(n.id,n);return{ctx:xt(t,i),catt:i}};function nn(t){let r=this.id;if(r){let{ctx:n,catt:i}=wt(t,r);if(this.innerHTML!==n)this.innerHTML=n,L.RPS(i.OZ)}}var ht=(t,r,n,i=[])=>{if(m(t))t.forEach((o)=>{ht(o,t.length,n,i)});else if(t instanceof Y)if(r>1)ht(X("div",{},t),r,n,i);else{let o=t.value,e=o instanceof O?"dom":"ctx",{ctx:f,catt:s}=wt(o,n.xid+"-0");n.xid=s.xid,i.push(f),n.OZ.push(s.OZ),n.states.push(t.call(nn,e))}else i.push(xt(t,n))};class Zt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=tn(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((i)=>{ht(i,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 O{tag;constructor(t,r={},...n){this.tag=t;ct(this,{attr:new Ct(r),ctx:new Zt(t,n)})}__(t=new H){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 X(t,r={},...n){if(w(t))return t(r??{},...n);return new O(t,r??{},n)}var on=(t,...r)=>r;class Ft{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},i={})=>{p(this.opt,i);let o=[[r,n],[0,0]].map(([e,f])=>({transform:`translateX(${e}rem) translateY(${f}rem)`}));return this.e.animate(o,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={}){p(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){p(this.opt,r);let n=[0,5,-5,5,0].map((i)=>({transform:`translate${t}(${i}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){p(this.opt,r);let n=Array.isArray(t)?t.map((i)=>({color:i})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){p(this.opt,r);let n=Array.isArray(t)?t.map((i)=>({backgroundColor:i})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){p(this.opt,r);let n=[0.5,t,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(n),this}}class Bt{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new Ft(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 i=r[n];if(r[n]!==void 0)t.setAttribute(n,_(i))}return this}}}get children(){return Array.from(this.e.children).map((t)=>d(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 P(t);return}get parent(){let t=this.e.parentElement;if(t)return new P(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,i=0)=>{let o=t,e=()=>{g(n).forEach(([f,s])=>{if(f in o){if(o[f]!==s)o[f]=s}else if(s!==null)t.setProperty(f,String(s))})};if(w(i))r.on("transitionend",i);if(St(i))setTimeout(e,i);else e();return r},get:(n)=>{let i=j(String(n));return t.getPropertyValue(i)},del:(...n)=>{n.forEach((i)=>{let o=j(String(i));t.removeProperty(o)})}}}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}=Xt(t,qt(this.id));this.e.insertAdjacentHTML("beforeend",r),L.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=Xt(t,qt(this.id));this.e.insertAdjacentHTML("afterbegin",r),L.RPS(n)}set inner(t){let{ctx:r,oz:n}=Xt(t,qt(this.id));this.e.innerHTML=r,L.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 Xt=(t,r)=>{let{ctx:n,catt:i}=wt(t,r);return{ctx:n,oz:i.OZ}},qt=(t)=>t?`${t}-0`:t;class P extends Bt{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),this}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,i=this.e.classList;return n.split(" ").forEach((o)=>{i.toggle(o,r)}),this}has(t){return this.e.contains(t)}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.value.split(" "),n=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(t.dom)o=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{i=i?r.includes(e):!1});else i=i?r.includes(t.class):!1;return i&&o}on(t,r,n=!1){let i=!1;if(t.indexOf("touch")>-1)i=!0;return this.e.addEventListener(t,r,{capture:n,passive:i}),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 i={duration:300,easing:"ease",fill:"forwards"};if(w(r))n=r;else p(i,r);let o=this.e.animate(t,i);if(n)o.finished.then(n);return this}}function d(t){if(tt(t)){let r=document.querySelector(t);if(r)return new P(r,t);return}else if(D(t)){let[[r,n]]=g(t),o=`${r==="id"?"#":"."}${n}`,e=document.querySelector(o);if(e)return new P(e,o);return}else return new P(t)}class ft{state=new Y(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new P(t);else this.state.value=void 0}get $(){return this.state.value}}var en=()=>{return new ft};class It{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=er(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 jt{path;args;id;status;lang;import;_data={};static route="/";constructor(t,r={},n,i=200){super();this.path=t;this.args=r;this.id=n;this.status=i}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.e=["import",{error:"loader"}],this.import=void 0,[]}if(this.body){let t=await this.body();return m(t)?t:[t]}if(this.import){let t=this.import;return m(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new Q;if(R(t))n.head=t;n.id=this.id;let i=n.head;return r.forEach((o)=>{i.map(o)}),sn(n,this),i}set data(t){p(this._data,t)}get data(){return this._data}}class Ut extends $t{head(){this.title=`error ${this.status}`}body(){return X("div",{},this.path+" not found...")}}function sn(t,r){let{link:n,script:i,meta:o,title:e,base:f,description:s,css:u}=r;if(t.head={title:e,base:f,meta:o,link:n,script:i},s)t.head={meta:[{name:"description",content:s}]};if(u){let l=(m(u)?u:[u]).map((b)=>({rel:"preload stylesheet",href:b,as:"style"}));t.head={link:[...l]}}}function yr(t){let r=[];if(t?.length){let{href:n,target:i}=t[0],o=d("base");if(o){if(o.attr.get("href")!==n)o.attr.set({href:n,target:i})}else{let e=d(document.createElement("base"));e.attr.set({href:n,target:i}),document.head.append(e.e)}}return r}var xr=new a;async function wr(t,r={},n=!1){let i=at.value,o={};if(d("link")?.all.forEach((e)=>{let f=d(e),s=f.attr.get("href");if(s){let u=f.attr.get("rt");if(n){let h=xr.get(i);if(h){if(!h.has(s))o[s]=f.unload}else o[s]=f.unload}else if(u){if(u===t)o[s]=f.unload}}}),r&&R(r))for(let e of A(r)){let f=e.href;if(!(f in o))try{let s=void 0;if(!n){if(s=d(`link[href='${f}']`),s)s.attr.set({rt:t});e.rt=t;let u=xr.init(i,new Set);if(!u.has(f))u.add(f)}if(!s)await Mt(e)}catch(s){E.e=["link error",{error:"yvee @ link"}]}else delete o[f]}return A(o)}var fn=["charset","name","property","http-equiv"];function $r(t){let r={};if(d("meta")?.all.forEach((n)=>{let i=n.attributes;for(let o of fn)if(o in i){let e=i[o].value;r[`${o}_${o==="charset"?"":e}`]=n}}),t)g(t).forEach(([n,i])=>{if(n in r)d(r[n]).attr.set(i),delete r[n];else{let o=d(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return A(r).map((n)=>d(n).unload)}var Er=new a;async function Sr(t,r,n=!1){let i=at.value,o={};if(d("script[yid]")?.all.forEach((e)=>{let f=d(e),s=f.attr.get("yid");if(s){let u=f.attr.get("rt");if(n){let h=Er.get(i);if(h){if(!h.has(s))o[s]=f.unload}else o[s]=f.unload}else if(u){if(u===t)o[s]=f.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in o)delete o[e.yid];else try{if(!n){e.rt=t;let f=e.yid,s=Er.init(i,new Set);if(!s.has(f))s.add(f)}await sr(e)}catch(f){E.e=["script error",{error:"yvee @ script"}]}}return A(o)}async function Rr(t,r){let n=[];if(T)return[];let i=t.get("title")??"",{pushState:o}=this.config;if(o){let e=this.path.value,f=this.lastPath.value;if(f!==e)if(!f.startsWith(e))q(e,i);else if(e===this.base)q(e,i);else q(e,i)}if(this.isYvee)document.documentElement.lang=r,document.title=i,n.push(...yr(t.get("base"))),n.push(...$r(t.get("meta")));return n.push(...await wr(this.id,t.get("link"),this.isYvee)),n.push(...await Sr(this.id,t.get("script"),this.isYvee)),n}function q(t,r){if(T)return;let{pathname:n,hash:i}=window.location,o=n+i;if(t&&o!==t)history.pushState({},r??"",t)}class Jt{path;args;static route="/";isConnected=M(!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 k=new a;class Wt{yvee;constructor(t){this.yvee=t}async load(t){if(T)return;if(!k.has(t)){let[n,i]=await this.yvee.loadWSS(t);if(!n)return;let{cls:o,path:e,id:f}=n,s=new o(e,i).connect;return k.set(t,s),s}let r=k.get(t);return r.reconnect,r}unload(t){if(T)return;if(k.has(t)){let r=k.get(t);if(!r)return;r.disconnect,k.delete(t)}}}var Qt=new a;function un(t,r,n,i){let{on:o,top:e,topRef:f,...s}=t,u={...o??{},click(h){h.preventDefault();let l=d(this),b=l.path;i.value=n.value,n.value=b;let c=l.hash;if(c){let J=d(c),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"}),q(b+c)}else if(i.value===n.value)window.scrollTo({top:l.rect.top||0,behavior:"smooth"}),q(window.location.pathname)}};return X("a",{...s,on:{...u}},...r)}function hn(t,r,n){let{classes:i}=t.config,{on:o,...e}=r,f={...r.on??{},...n&&{popstate(s){let h=s.target.location.pathname;t.path.value=h}},...{element(s){t.mainElement=this}}};return X("div",{...e,...i&&{class:i},on:f},t.root)}async function an(t,r){let[n,i]=await this.loadError(r??0);if(n){let{cls:o,id:e}=n;return new o(t,i,e,r)}else{let o=new Ut(t,i,x(5));return o.title=`error ${r}`,o}}function Gt(){if(B)return parseInt(d('meta[name="error"]')?.attr.get("content")??"200");return 200}class lt extends Pt{config;hook;root=M([]);socket;id=x(4);path=M("");lastPath=M("");loading=M(!1);mainElement;A;Main;load;matchPath;isYvee=!1;constructor(t={},r={}){super(t.base??"");this.config=t;if(this.socket=new Wt(this),t.id)this.id=t.id;this.A=(n,...i)=>{if(this.base){if(!n.href.startsWith(this.base))n.href=this._base(n.href)}return un(n,i,this.path,this.lastPath)},this.Main=(n)=>{if(R(r))if(!n.on)n.on=r;else p(n.on,r);return hn(this,n,this.isYvee)},this.load=async(n,i={})=>{if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,i),this.hooker()}catch(o){E.e=["render error",{error:"Pager loader"}]}}return this},this.matchPath=(n)=>{let i=this._base(n),o=this.path.value,e=this.base;if(o===i)return!0;else{let f=o.replace(e,""),s=i.replace(e,"");if(s){if(f.startsWith(s))return!0}else if(!o)return!0}return!1}}hooker(){let t={},r={},n=this.path.value;if(this.hook)this.hook();this.hook=V(async(i)=>{if(r[n]=window.scrollY,t[n]=this.mainElement?.scrollTop??0,(await this.render(i,404)).done){let o=r[i]??0;if(o)window.scrollTo({top:o,behavior:"instant"});let e=t[i]??0;if(e)this.mainElement?.scrollTo({top:e,behavior:"instant"});n=i}},[this.path],{id:"router"})}async class(t,r,n=!1){let[i,o]=await this.getPath(t);if(i&&!n){let{cls:e,id:f}=i;return new e(t,o,f)}else return await an.call(this,t,404)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(D(r)&&R(r))t.data=r}}catch(r){E.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 Q;if(R(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},i={},o=!0,e=!1){let f=await this.class(t,r??Gt(),e);f.data=n,await this.fetch(f);let s=await this.processHead(f,i);if(T)Qt.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(o)h=await Rr.call(this,s,f?.lang||this.lang);if(!this.isYvee)u=await f.loader(),h.forEach((l)=>l());if(this.isYvee)h.forEach((l)=>l());if(u.length)this.root.value=u;else await this.render(t,r,n,i,o,!0);return this.loading.value=!1,{heads:s,lang:f.lang??this.lang,done:!0}}}var at=M("");class Et extends lt{config;isYvee=!0;unload=!0;constructor(t={},r={}){super(t,r);this.config=t;this.path=at,this.load=async(n,i={})=>{if(B)n=mn()||this._base(n??"/");if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,i),this.hooker()}catch(o){E.e=["render error",{error:"Yvee loader"}]}}return this}}}var ln=(t)=>{return(r)=>{t(r)}};function mn(){if(B)return d('meta[name="yvee"]')?.attr.get("content")??"/";return""}var Ar=(t,r,n,i=!1)=>{let o=[];if(o.push({charset:"utf-8"}),o.push({name:"viewport",content:"width=device-width, initial-scale=1.0"}),n)switch(n){case 404:o.push({name:"error",content:n.toString()});break;default:break}if(i)o.push({name:"yvee",content:r});if(t.meta)if(m(t.meta))t.meta.unshift(...o);else t.meta.push(o);else t.meta=o},Hr=async(t,r,n={},i=[])=>{let o=await r(n),e=m(o)?o:[o],f=new F(t,new H(t));return e.forEach((s)=>{ht(s,e.length,f,i)}),f.OZ.set(f),f.OZ};async function gn(t,r,n={}){let{bodyattr:i={},id:o,route:e,base:f="",index:s,data:u}=n;if(B){let h={},l=document.body.id;if(r)if(r instanceof Et)await r.load();else{if(u)if(w(u))h=await u();else h=u;let c=window.location.pathname;if(p(h,{path:c,status:Gt()}),e){if(e.length>1&&e.slice(-1)!=="/")c=c.replace(/^\/|\/$/g,"");p(h,Tt(c,e))}}let b=await Hr(l,t,h);L.push(b),requestAnimationFrame(()=>{L.stage})}return async({path:h,data:l={},status:b=200})=>{let c=x(4),J=new a,y={};if(o)c=o;if(i.id)c=i.id.toString();let Kt="en";if(r instanceof Et){let{base:C,path:mt,id:Dr,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"}];mt.value=h,Ar(y,h,b,!0);let{heads:Vt}=await r.render(h,b,l,y,!1);Qt.values().forEach((Mr)=>{p(Vt.init("link",{}),Mr.get("link")??{})}),c=Dr,J=Vt,Kt=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)p(l,Tt(h,e));p(l,{status:b,path:h,base:f}),p(y,w(r)?await r(l):r),Ar(y,h,b);let mt=new ot;mt.head(y),J=mt.htmlHead}let zt=[];return await Hr(c,t,l,zt),new It(Kt,J).body(zt.join(""),c,it(i))}}var Fs=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`},Xs=(t)=>{if(T)return;return t()};export{Jt as websocket,en as useRef,dr as session,Fs as resolvePath,q as pushHistory,E as log,cr as local,on as frag,mr as eventStream,X as dom,$t as doc,Mt as cssLoader,Nr as addCSS,ur as __,Et as Yvee,Y as Stateful,V as StateHook,M as State,ln as Routes,gn as Render,ft as Ref,lt as Pager,nt as Meta,Xs as IfClient,O as Dom,d 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.
|
|
30
|
+
"rollup": "^4.47.1",
|
|
31
|
+
"rollup-plugin-dts": "^6.2.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"typescript": "^5.7.3"
|