From a992af35c2033fcbb4355a57de387fe308d4d5d9 Mon Sep 17 00:00:00 2001 From: defaultkavy Date: Mon, 7 Oct 2024 22:03:10 +0800 Subject: [PATCH] v0.3.5 new: danbooru account login with api is available now. new: class Client User adjust: [css] route element padding inline. new: [css] color variable. new: interface APIError. new: [page] /login route. new: [$nav] menu button and account button. new: class $Drawer, with user account basic detail, and login/logout button. new: function numberFormat. optimize: [$IconButton] $icon default is hiding, method icon will set $icon visible. new: [$IconButton] method link, set 'click' listener with open link. --- dist/assets/index-BkbpsU_v.css | 1 + dist/assets/index-DaDrA_5o.js | 1 - dist/assets/index-DeBFHjT4.css | 1 - dist/assets/index-La3x4wRW.js | 1 + dist/index.html | 4 +- index.scss | 6 +- package.json | 2 +- src/component/Drawer/$Drawer.ts | 91 +++++++++++++++++++++++++ src/component/Drawer/_$Drawer.scss | 75 ++++++++++++++++++++ src/component/IconButton/$IconButton.ts | 9 ++- src/component/Searchbar/$Searchbar.ts | 8 +-- src/index.d.ts | 9 ++- src/main.ts | 30 +++++++- src/modules.ts | 4 ++ src/route/login/$login_route.ts | 30 ++++++++ src/route/login/_$login_route.scss | 27 ++++++++ src/route/post/$post_route.ts | 3 +- src/structure/Booru.ts | 33 ++++++++- src/structure/ClientUser.ts | 71 +++++++++++++++++++ src/structure/Post.ts | 1 + src/structure/Tag.ts | 3 +- src/structure/User.ts | 81 ++++++++-------------- 22 files changed, 415 insertions(+), 76 deletions(-) create mode 100644 dist/assets/index-BkbpsU_v.css delete mode 100644 dist/assets/index-DaDrA_5o.js delete mode 100644 dist/assets/index-DeBFHjT4.css create mode 100644 dist/assets/index-La3x4wRW.js create mode 100644 src/component/Drawer/$Drawer.ts create mode 100644 src/component/Drawer/_$Drawer.scss create mode 100644 src/modules.ts create mode 100644 src/route/login/$login_route.ts create mode 100644 src/route/login/_$login_route.scss create mode 100644 src/structure/ClientUser.ts diff --git a/dist/assets/index-BkbpsU_v.css b/dist/assets/index-BkbpsU_v.css new file mode 100644 index 0000000..beb82f7 --- /dev/null +++ b/dist/assets/index-BkbpsU_v.css @@ -0,0 +1 @@ +layout.post-grid{margin-top:.4rem}post-tile{display:block;transition:.3s all ease;position:relative;transition:all .3s ease;border-radius:var(--border-radius-medium);overflow:hidden;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}@media (hover: hover){post-tile:hover{transform:scale(1.02);z-index:1;box-shadow:0 0 10px color-mix(in srgb,var(--background-color) 50%,transparent)}}post-tile.loading{transition:none}post-tile:active{transform:scale(.95)}post-tile div.video-detail,post-tile div.gif-detail{position:absolute;background-color:var(--background-color-lighter);color:var(--primary-color);bottom:.3rem;right:.3rem;padding:.2em .4em;height:1rem;border-radius:var(--border-radius-small);font-size:12px;display:flex;align-items:center;gap:.2rem;z-index:2}post-tile div.video-detail ion-icon,post-tile div.gif-detail ion-icon{font-size:1.4rem}post-tile div.video-detail ion-icon[name=images-outline],post-tile div.gif-detail ion-icon[name=images-outline]{padding:.1rem;font-size:1rem}post-tile div.video-detail span.duration,post-tile div.gif-detail span.duration{text-transform:uppercase;z-index:2}post-tile img{height:100%;width:100%;vertical-align:top;background-color:var(--background-color)}post-tile video{height:100%;width:100%;object-fit:cover;position:absolute;z-index:1}searchbar{display:flex;align-items:center;flex-direction:column;width:100%;z-index:200;position:fixed;height:100%}searchbar div.input-container{margin-top:.4rem;background-color:color-mix(in srgb,var(--background-color-light) 100%,transparent);border-radius:var(--border-radius-small);font-size:1rem;width:500px;padding:.4rem;max-width:calc(100% - 2rem);box-sizing:border-box;z-index:201;display:flex;align-items:center;border:1px solid var(--secondary-color-darker)}searchbar div.input-container:focus-within{outline:none}searchbar div.input-container tag-input{display:flex;gap:.4rem;width:100%;overflow:hidden;padding-inline:.4rem;box-sizing:border-box;cursor:text}searchbar div.input-container tag-input tag{display:inline-block;padding:.2rem .4rem;background-color:var(--secondary-color-darker);color:var(--secondary-color);border-radius:var(--border-radius-small);cursor:pointer}searchbar div.input-container ion-icon{font-size:20px;color:var(--secondary-color-darker);cursor:pointer}searchbar div.input-container ion-icon:hover{color:var(--secondary-color)}searchbar div.selection-list-container{overflow:hidden;border-radius:var(--border-radius-small);background-color:var(--background-color);z-index:201;max-width:calc(100% - 2rem);width:500px}searchbar div.selection-list-container selection-list{display:block;max-height:40vh;overflow-y:scroll;overflow-x:hidden;position:relative}searchbar div.selection-list-container selection-list::-webkit-scrollbar{width:4px}searchbar div.selection-list-container selection-list selection{display:flex;justify-content:space-between;align-items:center;padding:.4rem 1rem;cursor:pointer;gap:1rem}searchbar div.selection-list-container selection-list selection:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}searchbar div.selection-list-container selection-list selection.active{background-color:var(--background-color-lighter)}searchbar div.selection-list-container selection-list selection div.selection-label{display:flex;flex-wrap:wrap;gap:.5rem}searchbar div.selection-list-container selection-list selection div.selection-label .label-container{display:flex;gap:.5rem;align-items:center}searchbar div.selection-list-container selection-list selection div.selection-label .label-container ion-icon{font-size:1rem}searchbar div.selection-list-container selection-list selection div.tag-detail{display:flex;align-items:center;gap:.5rem}searchbar div.selection-list-container selection-list selection div.tag-detail .tag-post-count{font-size:.8rem}searchbar div.selection-list-container selection-list selection .tag-category,searchbar div.selection-list-container selection-list selection .user-level{padding:.1rem .4rem;border-radius:var(--border-radius-small);font-size:.9rem;background-color:var(--secondary-color-darker);color:var(--secondary-color)}searchbar div.filter{background-color:var(--background-color);opacity:.5;position:fixed;top:0;height:100%;width:100%;z-index:199}.input-wrapper{color:var(--primary-color);border:1px solid var(--secondary-color);border-radius:var(--border-radius-small);position:relative;box-sizing:border-box;line-height:1em;font-size:14px;padding:4px 8px;display:inline-block;max-width:100%;text-overflow:ellipsis}.input-wrapper span.sizer{font-family:inherit;white-space:pre;height:1em;display:inline-block;font-size:inherit;line-height:inherit;box-sizing:border-box;position:relative;opacity:0;min-width:2px;-webkit-user-select:none;user-select:none;vertical-align:top}.input-wrapper input{height:100%;text-overflow:ellipsis;font-family:inherit;background:none;color:inherit;top:0;left:0;font-size:inherit;line-height:inherit;padding:inherit;position:absolute;box-sizing:border-box;width:100%;border:none;outline:none}button.icon{display:flex;justify-content:center;align-items:center;gap:.4rem;padding:.8rem 1.2rem}button.icon ion-icon{font-size:1.4rem;color:inherit}button.icon.vertical{flex-direction:column}drawer{position:fixed;top:0;left:0;display:flex;z-index:300;height:100%;width:100%;box-sizing:border-box;justify-content:end;align-items:center;padding:1rem}drawer div.drawer-container{width:300px;max-width:70%;height:100%;background-color:var(--background-color);border-radius:var(--border-radius-large);z-index:1;overflow:hidden}drawer div.drawer-container div.user-info{background-color:var(--background-color-light);padding:2rem}drawer div.drawer-container div.user-info .username{margin:0;color:var(--secondary-color);cursor:pointer}drawer div.drawer-container div.user-info div.user-detail{display:flex;gap:.5rem;margin-top:.2rem}drawer div.drawer-container div.user-info div.user-detail span{font-size:.8rem;color:var(--primary-color-dark);display:block;cursor:pointer}drawer div.drawer-container div.user-info div.user-nav{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}drawer div.drawer-container div.nav{padding:2rem;display:flex;gap:1rem;flex-direction:column}drawer div.filter{position:absolute;top:0;left:0;height:100%;width:100%;background:linear-gradient(90deg,color-mix(in srgb,var(--background-color-dark) 50%,transparent),color-mix(in srgb,var(--background-color-darker) 70%,transparent))}#post{padding:0;padding-top:var(--nav-height)}#post section{background-color:#2f2f45;border-radius:var(--border-radius-large);padding:20px}#post div.viewer{height:calc(100vh - 2rem - var(--nav-height));display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:var(--border-radius-large);overflow:hidden;width:calc(100vw - 300px - 4rem);margin:1rem}@media (max-width: 800px){#post div.viewer{width:100%;height:calc(100vh - var(--nav-height));border-radius:0;margin:0}}#post div.viewer img{max-width:100%;max-height:100%}#post div.viewer video{max-width:100%;max-height:100%;-webkit-user-drag:none;transition:all .3s ease}#post div.content{width:calc(100vw - 300px - 2rem);display:flex;flex-direction:column;padding:1rem;box-sizing:border-box}@media (max-width: 800px){#post div.content{width:100%}}#post div.content::-webkit-scrollbar{background-color:#000;width:4px}#post div.content::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}#post div.content>h3{padding-left:1rem;margin-block:1rem}#post div.content section.commentary *{text-wrap:wrap;word-break:break-word}#post div.sidebar{--padding: 1rem;position:fixed;top:calc(var(--nav-height) + var(--padding));right:var(--padding);display:flex;flex-direction:column;gap:.4rem;width:300px;overflow:scroll;overflow-x:hidden;height:calc(100vh - 2rem - var(--nav-height));border-radius:var(--border-radius-large)}@media (max-width: 800px){#post div.sidebar{position:static;width:100%;overflow:visible;height:100%;padding:1rem;box-sizing:border-box}}#post div.sidebar::-webkit-scrollbar{background-color:#000;width:0px}#post div.sidebar::-webkit-scrollbar-thumb{background-color:#aeaeec}#post div.sidebar h3{padding-left:1rem;margin-block:.6rem}#post div.sidebar .post-info{background-color:#2f2f45;border-radius:var(--border-radius-large);padding:20px;display:flex;flex-direction:column;gap:.4rem}#post div.sidebar .post-info .buttons{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}#post div.sidebar div.property{display:flex;gap:.6rem;align-items:center;width:100%}#post div.sidebar div.property span.property-name{flex-shrink:0}#post div.sidebar div.property div.property-values{display:flex;gap:.4rem;width:100%;overflow:hidden}#post div.sidebar div.property div.property-values span.property-value{padding:2px 4px;background-color:var(--secondary-color-darker);color:var(--secondary-color);border-radius:var(--border-radius-small);justify-content:space-between;flex-shrink:1}#post div.sidebar div.property div.property-values span.property-value:has(*){overflow:hidden;padding:0}#post div.sidebar div.property div.property-values span.property-value:has(ion-icon){flex-shrink:0}#post div.sidebar div.property div.property-values span.property-value *{display:block;padding:2px 4px;overflow:hidden;text-wrap:nowrap;text-overflow:ellipsis;flex-shrink:1}#post div.sidebar div.property div.property-values span.property-value ion-icon{font-size:1rem;padding:4px;box-sizing:border-box}#post div.sidebar div.inline{display:flex;gap:1rem}#post div.sidebar div.post-tags{display:flex;flex-direction:column;gap:.2rem}#post div.sidebar div.post-tags div.tag{align-items:center}#post div.sidebar div.post-tags div.tag a.tag-name{word-break:break-word;color:#d1d1ee;text-decoration:none}#post div.sidebar div.post-tags div.tag span.tag-post-count{background-color:var(--secondary-color-darker);color:var(--secondary-color);padding:0 4px;border-radius:var(--border-radius-small);font-size:12px;margin-left:.4rem}route#login{display:flex;justify-content:center;align-items:center;margin-top:5rem}route#login .login-container{padding:2rem;border:1px solid var(--secondary-color);border-radius:var(--border-radius-large);display:flex;flex-direction:column;justify-content:center;gap:1rem}route#login .login-container h1{margin:0}route#login .login-container .input-container{display:flex;flex-direction:column;gap:.5rem}route#login .login-container .input-container input{width:300px}:root{--background-color: #1e1e2c;--background-color-lighter: #3b3b66;--background-color-light: #24243b;--background-color-dark: #12121f;--background-color-darker: #07070c;--primary-color: #d1d1ee;--primary-color-dark: #9696b3;--primary-color-darker: #72728d;--secondary-color: #aeaeec;--secondary-color-dark: #6d6da1;--secondary-color-darker: #424268;--shadow-color: #09090e50;--border-radius-small: .4rem;--border-radius-medium: .8rem;--border-radius-large: 1.2rem;--nav-height: 50px}html{overflow-x:hidden;font-size:14px}html ::-webkit-scrollbar{background-color:var(--background-color);width:8px}html ::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}body{overflow-x:hidden;background-color:var(--background-color);color:var(--primary-color);margin:0;font-family:Microsoft Yahei}nav{display:flex;width:100%;height:var(--nav-height);position:fixed;top:0;z-index:100;background-color:color-mix(in srgb,var(--background-color) 70%,transparent);justify-content:space-between;align-items:center;padding-inline:1rem;box-sizing:border-box;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}nav a.title{display:flex;align-items:center;gap:.4rem;text-decoration:none}nav a.title .booru-name{color:var(--secondary-color);margin:0}nav a.title .app{display:flex;align-items:center;border-radius:var(--border-radius-small);margin:0;gap:.4rem}nav a.title .app .version{color:var(--background-color);background-color:var(--secondary-color);padding:.2em .4em;border-radius:var(--border-radius-small);font-size:.8rem;font-weight:700}nav a.title .app .app-name{display:none;font-size:1rem;color:var(--secondary-color)}nav div.searchbar{padding:.4rem 10%;max-width:500px;background-color:color-mix(in srgb,var(--background-color-light) 30%,transparent);border:1px solid var(--primary-color-darker);border-radius:var(--border-radius-small);color:var(--primary-color-dark);transition:.3s all ease;cursor:pointer}nav div.searchbar:hover{color:var(--primary-color)}nav div.buttons{display:flex;align-items:center;gap:1rem}nav div.buttons ion-icon{transition:all .3s ease;border-radius:1rem;padding:.4rem}nav div.buttons ion-icon:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}nav div.buttons ion-icon.search{display:none}nav div.buttons div.account{height:2rem;width:2rem;display:flex;justify-content:center;align-items:center;border-radius:2rem;font-weight:bolder;color:var(--secondary-color);background-color:var(--secondary-color-darker);-webkit-user-select:none;user-select:none;cursor:pointer}@media (max-width: 800px){nav div.searchbar{display:none}nav div.buttons ion-icon.search{display:inline-block}}router{display:block;position:relative}router route{display:block;position:relative;padding-inline:1rem;padding-top:var(--nav-height)}button{background-color:var(--secondary-color-darker);color:var(--secondary-color);padding:.8rem 1.2rem;border-radius:1rem;border:none;cursor:pointer}button:hover{background-color:var(--secondary-color-dark);color:var(--primary-color)}ion-icon{font-size:24px;color:var(--primary-color);cursor:pointer}ion-icon:hover{color:var(--secondary-color)}a{color:var(--secondary-color);text-decoration:none}input{background-color:var(--background-color-light);border-radius:var(--border-radius-small);border:1px solid var(--background-color-lighter);font-size:.9rem;padding:.8rem 1.2rem;color:var(--primary-color);outline:none}input:focus{border-color:var(--secondary-color)} diff --git a/dist/assets/index-DaDrA_5o.js b/dist/assets/index-DaDrA_5o.js deleted file mode 100644 index b76c7d4..0000000 --- a/dist/assets/index-DaDrA_5o.js +++ /dev/null @@ -1 +0,0 @@ -var Et=Object.defineProperty;var ft=r=>{throw TypeError(r)};var Lt=(r,t,e)=>t in r?Et(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var h=(r,t,e)=>Lt(r,typeof t!="symbol"?t+"":t,e),pt=(r,t,e)=>t.has(r)||ft("Cannot "+e);var x=(r,t,e)=>(pt(r,t,"read from private field"),e?e.call(r):t.get(r)),B=(r,t,e)=>t.has(r)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),K=(r,t,e,s)=>(pt(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(i){if(i.ep)return;i.ep=!0;const n=e(i);fetch(i.href,n)}})();class G{constructor(){h(this,"__hidden",!1);h(this,"domEvents",{});h(this,"parent");h(this,"events",new et)}on(t,e,s){t=v.orArrayResolve(t);for(const i of t){this.domEvents[i]||(this.domEvents[i]=new Map);const n=a=>{e(a,this)};this.domEvents[i].set(e,n),this.events.on(i,e),this.dom.addEventListener(i,n,s)}return this}off(t,e,s){var n;const i=(n=this.domEvents[t])==null?void 0:n.get(e);return i&&this.dom.removeEventListener(t,i,s),this.events.off(t,e),this}once(t,e,s){const i=n=>{this.dom.removeEventListener(t,i,s),e(n,this)};return this.dom.addEventListener(t,i,s),this.events.once(t,e),this}hide(t,e=!0){return v.fluent(this,arguments,()=>this.__hidden,()=>{var s;if(t!==void 0)return t instanceof S?(this.__hidden=t.value,t.use(this,"hide")):this.__hidden=t,e&&((s=this.parent)==null||s.children.render()),this})}remove(){var t;return(t=this.parent)==null||t.children.remove(this).render(),this}replace(t){var e;return(e=this.parent)==null||e.children.replace(this,t).render(),this}contains(t){return t?t instanceof G?this.dom.contains(t.dom):t instanceof EventTarget?this.dom.contains(v(t).dom):this.dom.contains(t):!1}self(t){return t(this),this}inDOM(){return document.contains(this.dom)}isElement(){return this instanceof C}get element(){return this instanceof C?this:null}}class C extends G{constructor(e,s){super();h(this,"dom");h(this,"static_classes",new Set);this.dom=this.createDom(e,s),this.dom.$=this,this.setOptions(s)}createDom(e,s){return s!=null&&s.dom?s.dom:e==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement((s==null?void 0:s.tagname)??e)}setOptions(e){return this.id(e==null?void 0:e.id),e&&e.class&&this.class(...e.class),this}id(e){return $.fluent(this,arguments,()=>this.dom.id,()=>$.set(this.dom,"id",e))}class(...e){return $.fluent(this,arguments,()=>this.dom.classList,()=>{this.dom.classList.forEach(s=>this.static_classes.has(s)??this.dom.classList.remove(s)),this.dom.classList.add(...e.detype())})}addClass(...e){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.add(...e.detype())})}removeClass(...e){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.remove(...e.detype())})}staticClass(...e){return $.fluent(this,arguments,()=>this.static_classes,()=>{this.removeClass(...this.static_classes),this.static_classes.clear(),this.addStaticClass(...e)})}addStaticClass(...e){return $.fluent(this,arguments,()=>this,()=>{e.detype().forEach(s=>this.static_classes.add(s)),this.addClass(...e)})}removeStaticClass(...e){return $.fluent(this,arguments,()=>this,()=>{e.detype().forEach(s=>this.static_classes.delete(s)),this.removeClass(...e)})}css(e){return $.fluent(this,arguments,()=>this.dom.style,()=>{Object.assign(this.dom.style,e)})}attribute(e,s){return arguments.length?arguments.length===1?e===void 0?null:this.dom.getAttribute(e):arguments.length===2?e?(s===null?this.dom.removeAttribute(e):s!==void 0&&this.dom.setAttribute(e,`${s}`),this):this:this:null}tabIndex(e){return $.fluent(this,arguments,()=>this.dom.tabIndex,()=>$.set(this.dom,"tabIndex",e))}focus(){return this.dom.focus(),this}blur(){return this.dom.blur(),this}animate(e,s,i){const n=this.dom.animate(e,s);return i&&(n.onfinish=()=>i(n)),n}getAnimations(e){return this.dom.getAnimations(e)}get dataset(){return this.dom.dataset}domRect(e){const s=this.dom.getBoundingClientRect();if(!e)return s;const i=e instanceof C?e.dom.getBoundingClientRect():e;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}}class J extends G{constructor(e){super();h(this,"dom");this.dom=e,this.dom.$=this}domRect(e){const s={bottom:innerHeight,height:innerHeight,left:0,right:innerWidth,top:0,width:innerWidth,x:0,y:0};if(!e)return s;const i=e instanceof C?e.dom.getBoundingClientRect():e;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}static from(e){return e.$ instanceof J?e.$:new J(e)}}const At="modulepreload",Pt=function(r){return"/"+r},gt={},Mt=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(e.map(u=>{if(u=Pt(u),u in gt)return;gt[u]=!0;const c=u.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${d}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":At,c||(m.as="script"),m.crossOrigin="",m.href=u,o&&m.setAttribute("nonce",o),document.head.appendChild(m),c)return new Promise((b,l)=>{m.addEventListener("load",b),m.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${u}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};class Ct{constructor(t){h(this,"$container");h(this,"childList",new Set);this.$container=t}add(t,e=-1){if(e===-1||this.childList.size-1===e)this.childList.add(t);else{const s=[...this.childList];s.splice(e,0,t),this.childList.clear(),s.forEach(i=>this.childList.add(i))}t.parent=this.$container}remove(t){return this.childList.has(t)?(this.childList.delete(t),t.parent=void 0,this):this}removeAll(t=!0){this.childList.forEach(e=>this.remove(e)),t&&this.render()}replace(t,e){const s=this.array;return s.splice(s.indexOf(t),1,e),t.remove(),this.childList.clear(),s.forEach(i=>this.childList.add(i)),e.parent=this.$container,this}render(){const[t,e]=[this.array.map(i=>i.dom),Array.from(this.dom.childNodes)],s=[];for(;e.length||t.length;){const[i,n]=[e.at(0),t.at(0)];n?i?n!==i?(n.$.__hidden||(this.dom.insertBefore(n,i),s.push(n)),t.shift()):(n.$.__hidden&&this.dom.removeChild(n),t.shift(),e.shift()):(n.$.__hidden||this.dom.append(n),t.shift()):(i&&!s.includes(i)&&i.remove(),e.shift())}}indexOf(t){return this.array.indexOf(t)}get array(){return[...this.childList.values()]}get dom(){return this.$container.dom}}class S{constructor(t,e){h(this,"_value");h(this,"attributes",new Map);h(this,"linkStates",new Set);h(this,"options",{});this.set(t),e&&(this.options=e)}set(t){this._value=t,t instanceof S&&t.linkStates.add(this),this.update(),this.linkStates.forEach(e=>e.update())}static toJSON(t){const e={};for(let[s,i]of Object.entries(t))i instanceof S?i=i.toJSON():i instanceof Object&&S.toJSON(i),Object.assign(e,{[s]:i});return e}update(){for(const[t,e]of this.attributes.entries())for(const s of e)t[s]instanceof Function?this.options.format?t[s](this.options.format(this.value)):t[s](this.value):s in t&&(t[s]=this.value)}use(t,e){const s=this.attributes.get(t);s?s.add(e):this.attributes.set(t,new Set().add(e))}convert(t){return new S(this,{format:t})}get value(){return this._value instanceof S?this._value.value:this._value}toString(){return this.options.format?this.options.format(this.value):this.value instanceof Object?JSON.stringify(this.toJSON()):`${this.value}`}toJSON(){return this.value instanceof S?this.value.toJSON():this.value instanceof Object?S.toJSON(this.value):this.toString()}}class z extends G{constructor(e){super();h(this,"dom");this.dom=new Text(e),this.dom.$=this}content(e){return $.fluent(this,arguments,()=>this.dom.textContent,()=>$.set(this.dom,"textContent",e))}}class Q extends C{constructor(t,e){super(t,e)}autocapitalize(t){return $.fluent(this,arguments,()=>this.dom.autocapitalize,()=>$.set(this.dom,"autocapitalize",t))}innerText(t){return $.fluent(this,arguments,()=>this.dom.innerText,()=>$.set(this.dom,"innerText",t))}title(t){return $.fluent(this,arguments,()=>this.dom.title,()=>$.set(this.dom,"title",t))}dir(t){return $.fluent(this,arguments,()=>this.dom.dir,()=>$.set(this.dom,"dir",t))}translate(t){return $.fluent(this,arguments,()=>this.dom.translate,()=>$.set(this.dom,"translate",t))}popover(t){return $.fluent(this,arguments,()=>this.dom.popover,()=>$.set(this.dom,"popover",t))}spellcheck(t){return $.fluent(this,arguments,()=>this.dom.spellcheck,()=>$.set(this.dom,"spellcheck",t))}inert(t){return $.fluent(this,arguments,()=>this.dom.inert,()=>$.set(this.dom,"inert",t))}lang(t){return $.fluent(this,arguments,()=>this.dom.lang,()=>$.set(this.dom,"lang",t))}draggable(t){return $.fluent(this,arguments,()=>this.dom.draggable,()=>$.set(this.dom,"draggable",t))}hidden(t){return $.fluent(this,arguments,()=>this.dom.hidden,()=>$.set(this.dom,"hidden",t))}click(){return this.dom.click(),this}attachInternals(){return this.dom.attachInternals()}hidePopover(){return this.dom.hidePopover(),this}showPopover(){return this.dom.showPopover(),this}togglePopover(){return this.dom.togglePopover(),this}get accessKeyLabel(){return this.dom.accessKeyLabel}get offsetHeight(){return this.dom.offsetHeight}get offsetLeft(){return this.dom.offsetLeft}get offsetParent(){return $(this.dom.offsetParent)}get offsetTop(){return this.dom.offsetTop}get offsetWidth(){return this.dom.offsetWidth}}class f extends Q{constructor(e,s){super(e,s);h(this,"children",new Ct(this));h(this,"__position_cursor",0)}content(e){return $.fluent(this,arguments,()=>this,()=>{this.children.removeAll(!1),this.insert(e)})}insert(e,s=-1){return $.fluent(this,arguments,()=>this,async()=>{if(e instanceof Function){let i=e(this);i instanceof Promise?e=await i:e=i}else e instanceof Promise&&(e=await e);e=$.orArrayResolve(e),this.__position_cursor=s<0?this.children.array.length+s:s;for(const i of e)if(i!=null){if(i instanceof Array)this.insert(i,this.__position_cursor);else if(typeof i=="string")this.children.add(new z(i),s);else if(i instanceof S){const n=new z(i.toString());i.use(n,"content"),this.children.add(n,s)}else if(i instanceof Promise){const n=(await Mt(async()=>{const{$Async:o}=await Promise.resolve().then(()=>Ut);return{$Async:o}},void 0)).$Async,a=new n().await(i);this.children.add(a,s)}else this.children.add(i,s);this.__position_cursor+=1}this.children.render()})}clear(){return this.children.removeAll(),this}$(e){return $(this.dom.querySelector(e))}$all(e){return Array.from(this.dom.querySelectorAll(e)).map(s=>$(s))}get scrollHeight(){return this.dom.scrollHeight}get scrollWidth(){return this.dom.scrollWidth}scrollTop(e){return $.fluent(this,arguments,()=>this.dom.scrollTop,()=>$.set(this.dom,"scrollTop",e))}scrollLeft(e){return $.fluent(this,arguments,()=>this.dom.scrollLeft,()=>$.set(this.dom,"scrollLeft",e))}}class Rt extends f{constructor(t){super("a",t),this.dom.addEventListener("click",e=>{$.anchorHandler&&this.href()&&(e.preventDefault(),$.anchorHandler(this,e))})}href(t){return $.fluent(this,arguments,()=>this.dom.href,()=>$.set(this.dom,"href",t))}target(t){return $.fluent(this,arguments,()=>this.dom.target??void 0,()=>{t&&(this.dom.target=t)})}}class kt extends C{constructor(t,e){super(t,e)}}var I;(r=>{function t(o,u,c,d){return u.length?(d(),o):c()}r.fluent=t;function e(o){return o instanceof Array?o:[o]}r.orArrayResolve=e;function s(o,u){return e(u).forEach(c=>{Object.getOwnPropertyNames(c.prototype).forEach(d=>{d!=="constructor"&&Object.defineProperty(o.prototype,d,Object.getOwnPropertyDescriptor(c.prototype,d)||Object.create(null))})}),o}r.mixin=s;function i(o,u,c){c!==void 0&&(o[u]=c)}r.set=i;function n(o){return new S(o)}r.state=n;function a(o){if(o.$)return o.$;if(o.nodeName.toLowerCase()==="body")return new f("body",{dom:o});if(o.nodeName.toLowerCase()==="#document")return J.from(o);if(o instanceof HTMLElement){const u=$.TagNameElementMap[o.tagName.toLowerCase()],c=u===f?new u(o.tagName,{dom:o}):new u({dom:o});if(c instanceof f)for(const d of Array.from(c.dom.childNodes))c.children.add($(d));return c}else if(o instanceof Text){const u=new z(o.textContent??"");return u.dom=o,u}else if(o instanceof SVGElement&&o.tagName.toLowerCase()==="svg")return new kt("svg",{dom:o});throw`$NODE.FROM: NOT SUPPORT TARGET ELEMENT TYPE (${o.nodeName})`}r.from=a})(I||(I={}));class A{static create(...t){const e=class{};return Object.getOwnPropertyNames(A.prototype).forEach(s=>{s!=="constructor"&&t.includes(s)&&Object.defineProperty(e.prototype,s,Object.getOwnPropertyDescriptor(A.prototype,s)||Object.create(null))}),e}disabled(t){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",t))}checkValidity(){return this.dom.checkValidity()}reportValidity(){return this.dom.reportValidity()}formAction(t){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",t))}formEnctype(t){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",t))}formMethod(t){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",t))}formNoValidate(t){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",t))}formTarget(t){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",t))}autocomplete(t){return $.fluent(this,arguments,()=>this.dom.autocomplete,()=>$.set(this.dom,"autocomplete",t))}name(t){return $.fluent(this,arguments,()=>this.dom.name,()=>$.set(this.dom,"name",t))}maxLength(t){return $.fluent(this,arguments,()=>this.dom.maxLength,()=>$.set(this.dom,"maxLength",t))}minLength(t){return $.fluent(this,arguments,()=>this.dom.minLength,()=>$.set(this.dom,"minLength",t))}required(t){return $.fluent(this,arguments,()=>this.dom.required,()=>$.set(this.dom,"required",t))}label(t){return $.fluent(this,arguments,()=>this.dom.label,()=>$.set(this.dom,"label",t))}get form(){return this.dom.form?$(this.dom.form):null}get validationMessage(){return this.dom.validationMessage}get validity(){return this.dom.validity}get willValidate(){return this.dom.willValidate}}class ht extends f{constructor(t){super("button",t)}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}}I.mixin(ht,A.create("disabled","checkValidity","formAction","formEnctype","formMethod","formNoValidate","formTarget","reportValidity"));class yt extends f{constructor(t){super("form",t)}action(t){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",t))}enctype(t){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",t))}method(t){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",t))}noValidate(t){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",t))}acceptCharset(t){return $.fluent(this,arguments,()=>this.dom.acceptCharset,()=>$.set(this.dom,"acceptCharset",t))}target(t){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",t))}requestSubmit(){return this.dom.requestSubmit(),this}reset(){return this.dom.reset(),this}submit(){return this.dom.submit(),this}get length(){return this.dom.length}get elements(){return Array.from(this.dom.elements).map(t=>$(t))}}I.mixin(yt,A.create("checkValidity","reportValidity","autocomplete"));class k extends Q{constructor(t){super("input",t)}value(t){return $.fluent(this,arguments,()=>this.type()==="number"?Number(this.dom.value):this.dom.value,()=>$.set(this.dom,"value",t,e=>{this.on("input",()=>{e.attributes.has(this.dom)!==!1&&(typeof e.value=="string"&&e.set(`${this.value()}`),typeof e.value=="number"&&e.set(Number(this.value())))})}))}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}capture(t){return $.fluent(this,arguments,()=>this.dom.capture,()=>$.set(this.dom,"capture",t))}alt(t){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}defaultValue(t){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",t))}dirName(t){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",t))}pattern(t){return $.fluent(this,arguments,()=>this.dom.pattern,()=>$.set(this.dom,"pattern",t))}placeholder(t){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",t))}readOnly(t){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",t))}selectionDirection(t){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",t))}selectionEnd(t){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",t))}selectionStart(t){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",t))}size(t){return $.fluent(this,arguments,()=>this.dom.size,()=>$.set(this.dom,"size",t))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}inputMode(t){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",t))}valueAsDate(t){return $.fluent(this,arguments,()=>this.dom.valueAsDate,()=>$.set(this.dom,"valueAsDate",t))}valueAsNumber(t){return $.fluent(this,arguments,()=>this.dom.valueAsNumber,()=>$.set(this.dom,"valueAsNumber",t))}webkitdirectory(t){return $.fluent(this,arguments,()=>this.dom.webkitdirectory,()=>$.set(this.dom,"webkitdirectory",t))}select(){return this.dom.select(),this}setCustomValidity(t){return this.dom.setCustomValidity(t),this}setRangeText(t,e,s,i){return typeof e=="number"&&typeof s=="number"&&this.dom.setRangeText(t,e,s,i),this.dom.setRangeText(t),this}setSelectionRange(t,e,s){return this.dom.setSelectionRange(t,e,s),this}showPicker(){return this.dom.showPicker(),this}get files(){return this.dom.files}get webkitEntries(){return this.dom.webkitEntries}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}I.mixin(k,A.create("checkValidity","reportValidity","autocomplete","name","form","required","validationMessage","validity","willValidate","formAction","formEnctype","formMethod","formNoValidate","formTarget"));class Nt extends k{constructor(t){super(t),this.type("number")}static from(t){return $.mixin(k,this)}stepDown(){return this.dom.stepDown(),this}stepUp(){return this.dom.stepUp(),this}max(t){return $.fluent(this,arguments,()=>this.dom.max===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"max",t==null?void 0:t.toString()))}min(t){return $.fluent(this,arguments,()=>this.dom.min===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"min",t==null?void 0:t.toString()))}step(t){return $.fluent(this,arguments,()=>Number(this.dom.step),()=>$.set(this.dom,"step",t==null?void 0:t.toString()))}}class Ht extends k{constructor(t){super(t),this.type("radio")}static from(t){return $.mixin(k,this)}checked(t){return $.fluent(this,arguments,()=>this.dom.checked,()=>$.set(this.dom,"checked",t))}defaultChecked(t){return $.fluent(this,arguments,()=>this.dom.defaultChecked,()=>$.set(this.dom,"defaultChecked",t))}}class Dt extends k{constructor(t){super(t),this.type("file")}static from(t){return $.mixin(k,this)}multiple(t){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",t))}accept(...t){return $.fluent(this,arguments,()=>this.dom.accept.split(","),()=>this.dom.accept=t.toString())}}I.mixin(k,[Nt,Ht,Dt]);class vt extends f{constructor(t){super("label",t)}for(t){return $.fluent(this,arguments,()=>this.dom.htmlFor,()=>{$.set(this.dom,"htmlFor",t)})}get control(){return this.dom.control}}I.mixin(vt,A.create("form"));class Vt extends Q{constructor(t){super("img",t)}async load(t){return new Promise(e=>{const s=this.once("load",()=>{e(s)});typeof t=="string"?s.src(t):t.then(i=>s.src(i))})}static resize(t,e){return new Promise(s=>{const i=new Image;if(i.addEventListener("load",()=>{const n=document.createElement("canvas"),a=n.getContext("2d");if(!a)throw"$Image.resize: context undefined";const o=i.width/i.height,[u,c,d]=[o>1,o<1,o===1],m=e instanceof Array?e[0]:c?e:e*o,b=e instanceof Array?e[1]:u?e:e/o;n.height=b,n.width=m,a.drawImage(i,0,0,m,b),s(n.toDataURL())},{once:!0}),t instanceof File){const n=new FileReader;n.addEventListener("load",()=>i.src=n.result),n.readAsDataURL(t)}else i.src=t})}alt(t){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",t))}crossOrigin(t){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",t))}decoding(t){return $.fluent(this,arguments,()=>this.dom.decoding,()=>$.set(this.dom,"decoding",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}isMap(t){return $.fluent(this,arguments,()=>this.dom.isMap,()=>$.set(this.dom,"isMap",t))}loading(t){return $.fluent(this,arguments,()=>this.dom.loading,()=>$.set(this.dom,"loading",t))}referrerPolicy(t){return $.fluent(this,arguments,()=>this.dom.referrerPolicy,()=>$.set(this.dom,"referrerPolicy",t))}sizes(t){return $.fluent(this,arguments,()=>this.dom.sizes,()=>$.set(this.dom,"sizes",t))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}srcset(t){return $.fluent(this,arguments,()=>this.dom.srcset,()=>$.set(this.dom,"srcset",t))}useMap(t){return $.fluent(this,arguments,()=>this.dom.useMap,()=>$.set(this.dom,"useMap",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}decode(){return this.dom.decode()}get complete(){return this.dom.complete}get currentSrc(){return this.dom.currentSrc}get naturalHeight(){return this.dom.naturalHeight}get naturalWidth(){return this.dom.naturalWidth}get x(){return this.dom.x}get y(){return this.dom.y}}class jt extends f{constructor(t){super("canvas",t)}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>{$.set(this.dom,"height",t)})}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>{$.set(this.dom,"width",t)})}captureStream(t){return this.dom.captureStream(t)}getContext(t,e){return this.dom.getContext(t)}toBlob(t,e,s){return this.dom.toBlob(t,e,s),this}toDataURL(t,e){return this.dom.toDataURL(t,e)}transferControlToOffscreen(){return this.dom.transferControlToOffscreen()}}class Wt extends f{constructor(t){super("dialog",t)}open(t){return $.fluent(this,arguments,()=>this.dom.open,()=>$.set(this.dom,"open",t))}returnValue(t){return $.fluent(this,arguments,()=>this.dom.returnValue,()=>$.set(this.dom,"returnValue",t))}close(){return this.dom.close(),this}show(){return this.dom.show(),this}showModal(){return this.dom.showModal(),this}}class wt extends f{constructor(t){super("select")}add(t){return this.insert(t),this}item(t){return $(this.dom.item(t))}namedItem(t){return $(this.dom.namedItem(t))}multiple(t){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",t))}get length(){return this.dom.length}get size(){return this.dom.size}get options(){return Array.from(this.dom.options).map(t=>$(t))}get selectedIndex(){return this.dom.selectedIndex}get selectedOptions(){return Array.from(this.dom.selectedOptions).map(t=>$(t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t,e=>{this.on("input",()=>{e.attributes.has(this.dom)!==!1&&(typeof e.value=="string"&&e.set(`${this.value()}`),typeof e.value=="number"&&e.set(Number(this.value())))})}))}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}I.mixin(wt,A.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","validationMessage","validity","willValidate"));class bt extends f{constructor(t){super("option",t)}defaultSelected(t){return $.fluent(this,arguments,()=>this.dom.defaultSelected,()=>$.set(this.dom,"defaultSelected",t))}selected(t){return $.fluent(this,arguments,()=>this.dom.selected,()=>$.set(this.dom,"selected",t))}text(t){return $.fluent(this,arguments,()=>this.dom.text,()=>$.set(this.dom,"text",t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t))}get form(){return this.dom.form?$(this.dom.form):null}get index(){return this.dom.index}}I.mixin(bt,A.create("form","disabled","label"));class Tt extends f{constructor(t){super("optgroup",t)}disabled(t){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",t))}}I.mixin(Tt,A.create("disabled","label"));class _t extends f{constructor(t){super("textarea",t)}cols(t){return $.fluent(this,arguments,()=>this.dom.cols,()=>$.set(this.dom,"cols",t))}wrap(t){return $.fluent(this,arguments,()=>this.dom.wrap,()=>$.set(this.dom,"wrap",t))}value(t){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",t))}defaultValue(t){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",t))}dirName(t){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",t))}placeholder(t){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",t))}readOnly(t){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",t))}selectionDirection(t){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",t))}selectionEnd(t){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",t))}selectionStart(t){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",t))}type(t){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",t))}inputMode(t){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",t))}select(){return this.dom.select(),this}setCustomValidity(t){return this.dom.setCustomValidity(t),this}setRangeText(t,e,s,i){return typeof e=="number"&&typeof s=="number"&&this.dom.setRangeText(t,e,s,i),this.dom.setRangeText(t),this}setSelectionRange(t,e,s){return this.dom.setSelectionRange(t,e,s),this}get labels(){return Array.from(this.dom.labels??[]).map(t=>$(t))}}I.mixin(_t,A.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","minLength","maxLength","validationMessage","validity","willValidate"));var tt;class St extends f{constructor(e){super("async",e);B(this,tt,!1)}await(e){return e instanceof Function?e(this).then(s=>this._loaded(s)):e.then(s=>this._loaded(s)),this}_loaded(e){if(K(this,tt,!0),typeof e=="string")this.replace(new z(e));else if(e instanceof S){const s=new z(e.toString());e.use(s,"content"),this.replace(s)}else e==null?this.replace(new z(String(e))):this.replace(e);this.dom.dispatchEvent(new Event("load"))}get loaded(){return x(this,tt)}}tt=new WeakMap;const Ut=Object.freeze(Object.defineProperty({__proto__:null,$Async:St},Symbol.toStringTag,{value:"Module"}));class Ft extends C{constructor(t,e){super(t,e)}autoplay(t){return $.fluent(this,arguments,()=>this.dom.autoplay,()=>$.set(this.dom,"autoplay",t))}get buffered(){return this.dom.buffered}controls(t){return $.fluent(this,arguments,()=>this.dom.controls,()=>$.set(this.dom,"controls",t))}crossOrigin(t){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",t))}get currentSrc(){return this.dom.currentSrc}currentTime(t){return $.fluent(this,arguments,()=>this.dom.currentTime,()=>$.set(this.dom,"currentTime",t))}defaultMuted(t){return $.fluent(this,arguments,()=>this.dom.defaultMuted,()=>$.set(this.dom,"defaultMuted",t))}defaultPlaybackRate(t){return $.fluent(this,arguments,()=>this.dom.defaultPlaybackRate,()=>$.set(this.dom,"defaultPlaybackRate",t))}disableRemotePlayback(t){return $.fluent(this,arguments,()=>this.dom.disableRemotePlayback,()=>$.set(this.dom,"disableRemotePlayback",t))}get duration(){return this.dom.duration}get ended(){return this.dom.ended}get error(){return this.dom.error}loop(t){return $.fluent(this,arguments,()=>this.dom.loop,()=>$.set(this.dom,"loop",t))}mediaKeys(t){return $.fluent(this,arguments,()=>this.dom.mediaKeys,()=>$.set(this.dom,"setMediaKeys",[t]))}muted(t){return $.fluent(this,arguments,()=>this.dom.muted,()=>$.set(this.dom,"muted",t))}get networkState(){return this.dom.networkState}get paused(){return this.dom.paused}playbackRate(t){return $.fluent(this,arguments,()=>this.dom.playbackRate,()=>$.set(this.dom,"playbackRate",t))}get played(){return this.dom.played}preload(t){return $.fluent(this,arguments,()=>this.dom.preload,()=>$.set(this.dom,"preload",t))}preservesPitch(t){return $.fluent(this,arguments,()=>this.dom.preservesPitch,()=>$.set(this.dom,"preservesPitch",t))}get readyState(){return this.dom.readyState}get remote(){return this.dom.remote}get seekable(){return this.dom.seekable}get seeking(){return this.dom.seeking}sinkId(t){return $.fluent(this,arguments,()=>this.dom.sinkId,()=>$.set(this.dom,"setSinkId",[t]))}src(t){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",t))}srcObject(t){return $.fluent(this,arguments,()=>this.dom.srcObject,()=>$.set(this.dom,"srcObject",t))}get textTracks(){return this.dom.textTracks}volume(t){return $.fluent(this,arguments,()=>this.dom.volume,()=>$.set(this.dom,"volume",t))}addTextTrack(t,e,s){return this.dom.addTextTrack(t,e,s)}canPlayType(t){return this.dom.canPlayType(t)}fastSeek(t){return this.dom.fastSeek(t),this}load(){return this.dom.load(),this}pause(){return this.dom.pause(),this}async play(){return await this.dom.play(),this}get isPlaying(){return this.currentTime()>0&&!this.paused&&!this.ended&&this.readyState>2}}class Gt extends Ft{constructor(t){super("video",t)}disablePictureInPicture(t){return $.fluent(this,arguments,()=>this.dom.disablePictureInPicture,()=>$.set(this.dom,"disablePictureInPicture",t))}height(t){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",t))}width(t){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",t))}playsInline(t){return $.fluent(this,arguments,()=>this.dom.playsInline,()=>$.set(this.dom,"playsInline",t))}poster(t){return $.fluent(this,arguments,()=>this.dom.poster,()=>$.set(this.dom,"poster",t))}get videoHeight(){return this.dom.videoHeight}get videoWidth(){return this.dom.videoWidth}cancelVideoFrameCallback(t){return this.dom.cancelVideoFrameCallback(t),this}getVideoPlaybackQuality(){return this.dom.getVideoPlaybackQuality()}requestPictureInPicture(){return this.dom.requestPictureInPicture()}requestVideoFrameCallback(t){return this.dom.requestVideoFrameCallback(t)}}function v(r){if(typeof r>"u"||r===null||r instanceof G)return r;if(typeof r=="string"){if(r.startsWith("::"))return Array.from(document.querySelectorAll(r.replace(/^::/,""))).map(t=>v(t));if(r.startsWith(":"))return v(document.querySelector(r.replace(/^:/,"")));if(r in v.TagNameElementMap){const t=v.TagNameElementMap[r];return t===Q?new Q(r):t===f?new f(r):new t}else return new f(r)}if(r instanceof Node)return r.$?r.$:I.from(r);throw`$: NOT SUPPORT TARGET ELEMENT TYPE ('${r}')`}(r=>{r.anchorHandler=null,r.TagNameElementMap={html:f,head:f,document:J,body:f,a:Rt,p:f,pre:f,code:f,blockquote:f,strong:f,h1:f,h2:f,h3:f,h4:f,h5:f,h6:f,div:f,ol:f,ul:f,dl:f,li:f,input:k,label:vt,button:ht,form:yt,img:Vt,dialog:Wt,canvas:jt,select:wt,option:bt,optgroup:Tt,textarea:_t,video:Gt,async:St};function t(l,p,y,_){return p.length?(_(),l):y()}r.fluent=t;function e(l){return l instanceof Array?l:[l]}r.orArrayResolve=e;function s(l,p){return I.mixin(l,p)}r.mixin=s;function i(l,p,y,_){if(y!==void 0){if(y instanceof S){y.use(l,p),l[p]instanceof Function?l[p](...y.value):l[p]=y.value,_&&_(y);return}l[p]instanceof Function?l[p](...y):l[p]=y}}r.set=i;function n(l,p){return new S(l,p)}r.state=n;async function a(l,p){return new Promise(y=>{const _=new FileReader;_.onload=O=>{const T=r("img");if(T.once("load",R=>{const j=r("canvas"),W=j.getContext("2d"),N=T.height()/T.width(),[P,q]=[N>1?p/N:p,N>1?p:p*N];j.height(q).width(P),W==null||W.drawImage(T.dom,0,0,P,q),y(j.toDataURL(l.type))}),!O.target)throw"$.resize(): e.target is null";T.src(O.target.result)},_.readAsDataURL(l)})}r.resize=a;function o(l=1){return parseInt(getComputedStyle(document.documentElement).fontSize)*l}r.rem=o;function u(l){const p=new DOMParser().parseFromString(l,"text/html").body;return Array.from(p.children).map(y=>r(y))}r.html=u;function c(l,p,y){if(typeof p=="number")return Array(p).fill("").map(O=>{const T=_(l)?l[0](...l.slice(1)):r(l);return y&&y(T),T});{const O=[];for(const T of p){const R=l instanceof Function?l(...T):_(l)?l[0](...l.slice(1)):r(l);T instanceof Function?T(R):(T instanceof G||typeof T=="string")&&R.content(T),O.push(R)}return O}function _(O){return O instanceof Array&&O[0]instanceof Function}}r.builder=c;function d(l,p){return Object.assign(r.TagNameElementMap,{[l]:p}),r.TagNameElementMap}r.registerTagName=d;function m(...l){return new et}r.events=m;function b(l){return l()}r.call=b})(v||(v={}));globalThis.$=v;class et{constructor(){h(this,"eventMap",new Map)}fire(t,...e){var s;return(s=this.eventMap.get(t))==null||s.forEach(i=>i(...e)),this}on(t,e){const s=this.eventMap.get(t)??this.eventMap.set(t,new Set).get(t);return s==null||s.add(e),this}off(t,e){var s;return(s=this.eventMap.get(t))==null||s.delete(e),this}once(t,e){const s=(...n)=>{var a;(a=this.eventMap.get(t))==null||a.delete(s),e(...n)},i=this.eventMap.get(t)??this.eventMap.set(t,new Set).get(t);return i==null||i.add(s),this}}Array.prototype.detype=function(...r){return this.filter(t=>{if(r.length)for(const e of r)return typeof t!=typeof e;else return t!==void 0})};Object.defineProperties(Set.prototype,{array:{get:function(){return Array.from(this)}}});Set.prototype.sort=function(r){return this.array.sort(r)};class It extends f{constructor(e){super("layout",e);h(this,"_property",{ROW_MAX_HEIGHT:200,GAP:0,IS_RENDERING:!1,RENDER_REQUEST:!1,COLUNM:1,TYPE:"justified",ROOT:null,ITEM_PROPERTIES:new Map});this.css({display:"block",position:"relative"}),new ResizeObserver(s=>{this.inDOM()&&(this.render(),this.dom.dispatchEvent(new Event("resize")))}).observe(this.dom),document.addEventListener("scroll",s=>{s.target===this.root().dom&&this.scrollCompute()},{passive:!0}),new IntersectionObserver(s=>{this.inDOM()&&this.render()}).observe(this.dom)}type(e){return $.fluent(this,arguments,()=>this._property.TYPE,()=>$.set(this._property,"TYPE",e))}maxHeight(e){return $.fluent(this,arguments,()=>this._property.ROW_MAX_HEIGHT,()=>$.set(this._property,"ROW_MAX_HEIGHT",e))}column(e){return $.fluent(this,arguments,()=>this._property.COLUNM,()=>$.set(this._property,"COLUNM",e))}gap(e){return $.fluent(this,arguments,()=>this._property.GAP,()=>$.set(this._property,"GAP",e))}root(e){return $.fluent(this,arguments,()=>this._property.ROOT??$(document),()=>$.set(this._property,"ROOT",e))}get COL_WIDTH(){return(this.offsetWidth-this._property.GAP*(this._property.COLUNM-1))/this._property.COLUNM}justifiedCompute(){const e=[],s=this.offsetWidth;for(const i of this.children.array){const n=$(i);if(!(n instanceof C))continue;const a=n.attribute("layout-item-ratio"),o=a?parseFloat(a):n.dom.offsetWidth/n.dom.offsetHeight,u={$node:n,ratio:o};let c=e.at(-1);(!c||c.heightd+=l.ratio);const m=d+o,b=(s-this._property.GAP*c.items.length)/m;c.items.push(u),c.ratio=m,c.height=b}return e}waterfallCompute(){const e=[],s=this.COL_WIDTH,i=()=>{if(e.lengthn.height-a.height)[0]};for(const n of this.children.array){const a=$(n);if(!(a instanceof C))continue;const o=a.attribute("layout-item-ratio"),u=o?parseFloat(o):a.dom.offsetWidth/a.dom.offsetHeight,c={$node:a,ratio:u},d=i();let m=0;d.items.forEach(p=>m+=p.ratio);const b=s/(d.height+s/u),l=s/b;d.items.push(c),d.ratio=b,d.height=l}return e}render(){if(!this.inDOM())return this;if(this._property.ITEM_PROPERTIES.clear(),this._property.TYPE==="justified"){const e=this.justifiedCompute();let s=0;for(const i of e){let n=0;i.height>this._property.ROW_MAX_HEIGHT&&(i.height=this._property.ROW_MAX_HEIGHT);for(const a of i.items){const o=a.ratio*i.height;a.$node.css({position:"absolute",height:`${i.height}px`,width:`${o}px`,top:`${s}px`,left:`${n}px`}),a.$node.attribute("layout-item-ratio",a.ratio),this._property.ITEM_PROPERTIES.set(a.$node,{height:i.height,width:o,top:s,left:n,ratio:a.ratio,$node:a.$node}),n+=i.height*a.ratio+this._property.GAP}s+=i.height+this._property.GAP}this.css({height:`${s}px`})}else if(this._property.TYPE="waterfall"){const e=this.waterfallCompute(),s=this.COL_WIDTH;let i=0;for(const n of e){let a=0;for(const o of n.items){const u=s/o.ratio;o.$node.css({position:"absolute",height:`${u}px`,width:`${s}px`,top:`${a}px`,left:`${i}px`}),o.$node.attribute("layout-item-ratio",o.ratio),this._property.ITEM_PROPERTIES.set(o.$node,{height:u,width:s,top:a,left:i,ratio:o.ratio,$node:o.$node}),a+=u+this._property.GAP}i+=s+this._property.GAP}if(e.length){const n=e.sort((a,o)=>o.height-a.height)[0];this.css({height:`${n.height+n.items.length*this._property.GAP}px`})}else this.css({height:""})}return this.scrollCompute(),this}scrollCompute(){if(this.inDOM()===!1)return;const e=document.documentElement.scrollTop-this.dom.offsetTop;this._property.ITEM_PROPERTIES.forEach((s,i)=>{const n=s.top;s.top+s.height>e&&n{this.contentId=e,this.events.fire("rendered",{$view:this,previousContent:i,nextContent:s})},o=()=>{this.events.fire("afterSwitch",{$view:this,previousId:e})};return this.events.fire("beforeSwitch",{$view:this,preventDefault:()=>n=!0,targetId:e,previousContent:i,nextContent:s,switched:o,rendered:a}),n||(this.content(s),a(),o()),this}get currentContent(){if(this.contentId)return this.viewCache.get(this.contentId)}}$.registerTagName("view",Ot);var D;const g=class g extends Ot{constructor(e){super({tagname:"router",...e});B(this,D,"");h(this,"routes",new Map);g.routers.add(this)}base(e){return $.fluent(this,arguments,()=>x(this,D),()=>{K(this,D,e??x(this,D))})}map(e){e=$.orArrayResolve(e);for(const s of e)s instanceof Array?this.map(s):this.routes.set(s.path(),s);return this.resolve(),this}resolve(){return new Promise(e=>{if(!location.pathname.startsWith(x(this,D)))return e(2);const s=location.pathname.replace(x(this,D),"/").replace("//","/"),i=s.split("/").map(p=>`/${p}`),n=location.search,a=new Map(n.replace("?","").split("&").map(p=>p.split("="))),u=(()=>{const p=[];for(const[y,_]of this.routes){const O=$.orArrayResolve(y);for(const T of O){let R=0,j={},W={};const N=T.split("/").map(P=>`/${P}`);if(!(i.lengthObject.assign(W,{[mt]:a.get(mt)})),q.startsWith("/:")){R++,Object.assign(j,{[q.replace("/:","")]:i[P].replace("/","")});continue}else if(T.startsWith("#")&&T===location.hash){R++;continue}else if(q===i[P]){R++;continue}else break}p.push({deep:R,$route:_,params:j,query:W,pathId:Object.keys(W).length!==0?s+n:Object.keys(j).length!==0?s:O[0]})}}}return p.sort((y,_)=>_.deep-y.deep).at(0)})();if(!u)return e(1);const{$route:c,params:d,pathId:m,query:b}=u;if(m===this.contentId)return e(0);this.events.once("rendered",({nextContent:p,previousContent:y})=>{y==null||y.events.fire("afterShift",{$route:y}),p.events.fire("rendered",{$route:p}),e(0)});const l=this.viewCache.get(m)??c.build({params:d,query:b});this.viewCache.has(m)||this.setView(m,l),this.events.once("beforeSwitch",()=>{var p;l.events.fire("beforeShift",{$route:l}),(p=this.currentContent)==null||p.events.fire("beforeShift",{$route:this.currentContent})}),this.events.once("afterSwitch",()=>l.events.fire("afterShift",{$route:l})),this.switchView(m)})}static init(){if(!history.state||!("index"in history.state)){const e={index:g.historyIndex};history.replaceState(e,"")}else g.historyIndex=history.state.index;return g.navigationDirection=0,g.resolve(),window.addEventListener("popstate",()=>g.popstate()),window.addEventListener("scroll",()=>{this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)},{passive:!0}),history.scrollRestoration="manual",this}static open(e,s){return e===void 0?this:(e=this.urlResolver(e),e.href===this.url.href?this:e.origin!==this.url.origin?(window.open(e,s),this):(g.clearForwardScrollHistory(),g.historyIndex++,history.pushState(g.historyState,"",e),g.stateChange(0),g.resolve(),this))}static back(){return this.historyIndex--,history.back(),this.stateChange(1),this}static replace(e){return e===void 0?this:(e=this.urlResolver(e),history.replaceState(g.historyState,"",e),this.stateChange(2),this.setScrollHistory(this.historyIndex,location.href,0),g.resolve(),this)}static urlResolver(e){return e instanceof URL?e:(e.startsWith("/")&&(e=`${location.origin}${e}`),e.startsWith("#")&&(e=`${location.origin}${location.pathname}${e}`),new URL(e))}static popstate(){const e=history.state.index>g.historyIndex?0:history.state.indexe.resolve())),this.scrollRestoration(),this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)}static get historyState(){return{index:g.historyIndex}}static stateChange(e){const s=this.url,i=new URL(location.href);this.url=i,g.events.fire("stateChange",{beforeURL:s,afterURL:i,direction:e}),g.navigationDirection=e}static setScrollHistory(e,s,i){const n=this.getScrollHistory();if(!n)return sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify({[e]:{url:s,value:i}}));n[e]={url:s,value:i},sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(n))}static getScrollHistory(){const e=sessionStorage.getItem(this.scrollHistoryKey);if(e)return JSON.parse(e)}static clearForwardScrollHistory(){const e=this.getScrollHistory();if(e)for(const s in e)Number(s)>this.historyIndex&&delete e[s],sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(e))}static scrollRestoration(){const e=this.getScrollHistory();if(e&&e[this.historyIndex])document.documentElement.scrollTop=e[this.historyIndex].value??0;else if(location.hash.length){const s=$(document.body).$(location.hash);s&&(document.documentElement.scrollTop=s.dom.offsetTop)}else document.documentElement.scrollTop=0}};D=new WeakMap,h(g,"routers",new Set),h(g,"events",new et),h(g,"navigationDirection"),h(g,"historyIndex",0),h(g,"url",new URL(location.href)),h(g,"scrollHistoryKey","$ROUTER_SCROLL_HISTORY");let L=g;var U=(r=>(r[r.Forward=0]="Forward",r[r.Back=1]="Back",r[r.Replace=2]="Replace",r))(U||{});L.init();var X,V;const lt=class lt extends f{constructor(e){super("route",e);B(this,X,"");B(this,V);h(this,"rendered",!1)}path(e){return $.fluent(this,arguments,()=>x(this,X),()=>K(this,X,e??x(this,X)))}builder(e){return K(this,V,e),this}render(e){return x(this,V)&&this.content(x(this,V).call(this,{$route:this,params:e.params,query:e.query})),this.rendered=!0,this}build(e){return new lt({dom:this.dom.cloneNode()}).self(s=>{x(this,V)&&s.builder(x(this,V)).render({params:e.params,query:e.query})})}};X=new WeakMap,V=new WeakMap;let ot=lt;$.registerTagName("router",L);$.registerTagName("route",ot);Object.assign($,{open(r,t){return L.open(r,t)},replace(r){return L.replace(r)},back(){return L.back()}});const H=class H{constructor(t){h(this,"posts",new Map);h(this,"tags",new Map);Object.assign(this,t),this.origin.endsWith("/")&&(this.origin=this.origin.slice(0,-1)),H.manager.set(this.name,this)}static set(t){return this.used=t,this.name$.set(t.name),this.storageAPI=t.name,this.events.fire("set"),this}static get storageAPI(){return localStorage.getItem("booru_api")}static set storageAPI(t){t?localStorage.setItem("booru_api",t):localStorage.removeItem("booru_api")}};h(H,"used"),h(H,"events",new et),h(H,"name$",$.state(H.name)),h(H,"manager",new Map);let w=H;const qt=new Intl.NumberFormat("en",{notation:"compact"});class zt{constructor(t,e){h(this,"post_count$",$.state(0,{format:t=>`${qt.format(t)}`}));h(this,"name$",$.state(""));h(this,"booru");this.booru=t,Object.assign(this,e),this.$update()}static async fetch(t,e){var n;const s=await fetch(`${t.origin}/tags/${e}.json`).then(async a=>await a.json()),i=((n=t.tags.get(s.id))==null?void 0:n.update(s))??new this(t,s);return t.tags.set(i.id,i),i}static async fetchMultiple(t,e,s=1e3){let i="";if(e)for(const[u,c]of Object.entries(e))if(c instanceof Array)i+=`&search[${u}]=${c}`;else if(c instanceof Object)for(const[d,m]of Object.entries(c))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${c}`;return(await(await fetch(`${t.origin}/tags.json?limit=${s}${i}`)).json()).map(u=>{var d;const c=((d=t.tags.get(u.id))==null?void 0:d.update(u))??new this(t,u);return t.tags.set(c.id,c),c})}update(t){return Object.assign(this,t),this.$update(),this}$update(){this.post_count$.set(this.post_count),this.name$.set(this.name)}}var F=(r=>(r[r.General=0]="General",r[r.Artist=1]="Artist",r[r.Copyright=3]="Copyright",r[r.Character=4]="Character",r[r.Meta=5]="Meta",r))(F||{});class Y{constructor(t){h(this,"name$",$.state("loding..."));Object.assign(this,t),this.update$()}static async fetch(t,e){var n;const s=await fetch(`${t.origin}/users/${e}.json`).then(async a=>await a.json()),i=((n=this.manager.get(s.id))==null?void 0:n.update(s))??new this(s);return this.manager.set(i.id,i),i}static async fetchMultiple(t,e,s=200){let i="";if(e)for(const[u,c]of Object.entries(e))if(c instanceof Array)i+=`&search[${u}]=${c}`;else if(c instanceof Object)for(const[d,m]of Object.entries(c))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${c}`;return(await(await fetch(`${t.origin}/users.json?limit=${s}${i}`)).json()).map(u=>{const c=new this(u);return this.manager.set(c.id,c),c})}update(t){return Object.assign(this,t),this.update$(),this}update$(){this.name$.set(this.name)}}h(Y,"manager",new Map);const ct=1e3,it=ct*60,rt=it*60,nt=rt*24,Xt=nt*7,st=new Intl.RelativeTimeFormat("en",{style:"long"});function Bt(r){r=Math.floor(r);const t=r/ct,e=r/it,s=r/rt,i=r/nt,n=r%1e3,a=Math.floor(r%6e4/1e3),o=Math.floor(r%36e5/6e4),u=Math.floor(r%(36e5*24)/36e5),c=a.toString().padStart(2,"0"),d=o.toString().padStart(2,"0"),m=u.toString().padStart(2,"0");return{seconds:t,minutes:e,hours:s,days:i,mil:n,s:a,min:o,h:u,ss:c,mm:d,hh:m}}function Kt(r,t=Date.now()){const e=r-t,s=Math.abs(e);if(sawait s.json());return this.update(e),Y.fetchMultiple(this.booru,{id:[this.uploader_id,this.approver_id].detype(null)}).then(()=>this.update$()),this}static async fetchMultiple(e,s,i=20){let n="";if(s){if(typeof s=="string")n=s;else for(const[d,m]of Object.entries(s))if(m!==void 0){if(d==="tags"){n+=`${m}`;continue}n.at(-1)!=="="&&(n+=" "),n+=`${d}:${m}`}}const o=await(await fetch(`${e.origin}/posts.json?limit=${i}&tags=${n}&_method=get`)).json();if(!(o instanceof Array))return[];const u=o.map(d=>{var b;const m=((b=e.posts.get(d.id))==null?void 0:b.update(d))??new this(e,d.id,d);return e.posts.set(m.id,m),m});if(!u.length)return u;const c=[...new Set(o.map(d=>[d.approver_id,d.uploader_id].detype(null)).flat())];return Y.fetchMultiple(e,{id:c}).then(()=>u.forEach(d=>d.update$())),u}update$(){var e,s,i,n;this.uploader$.set(((e=this.uploader)==null?void 0:e.name$)??((s=this.uploader_id)==null?void 0:s.toString())),this.approver$.set(((i=this.approver)==null?void 0:i.name$)??((n=this.approver_id)==null?void 0:n.toString())??"None"),this.created_date$.set(Kt(+new Date(this.created_at))),this.favorites$.set(this.fav_count),this.score$.set(this.score),this.file_size$.set(Yt(this.file_size)),this.file_ext$.set(this.file_ext),this.file_url$.set(this.file_url),this.source$.set(this.source),this.dimension$.set(`${this.image_width}x${this.image_height}`),this.url$.set(`${this.url}`),this.isUgoria&&this.webm_url$.set(this.large_file_url),this.createdDate=new Date(this.created_at),this.fire("update")}update(e){return Object.assign(this,e),this.update$(),this}async fetchTags(){return await this.ready,await zt.fetchMultiple(this.booru,{name:{_space:this.tag_string}})}get pathname(){return`/posts/${this.id}`}get uploader(){return Y.manager.get(this.uploader_id)}get approver(){return this.approver_id?Y.manager.get(this.approver_id):null}get isVideo(){return this.file_ext==="mp4"||this.file_ext==="webm"||this.file_ext==="zip"}get isGif(){return this.file_ext==="gif"}get isUgoria(){return this.file_ext==="zip"}get hasSound(){return this.tag_string_meta.includes("sound")}get tags(){const e=this.tag_string.split(" ");return[...this.booru.tags.values()].filter(s=>e.includes(s.name))}get previewURL(){var e,s;return((s=(e=this.media_asset.variants)==null?void 0:e.find(i=>i.file_ext==="webp"))==null?void 0:s.url)??this.large_file_url}get url(){return`${this.booru.origin}/posts/${this.id}`}}class xt{constructor(t){Object.assign(this,t)}static async fetch(t,e){const s=await fetch(`${t.origin}/artist_commentaries/${e}.json`);return new this(await s.json())}static async fetchMultiple(t,e,s=200){let i="";if(e)for(const[u,c]of Object.entries(e))if(c instanceof Array)i+=`&search[${u}]=${c}`;else if(c instanceof Object)for(const[d,m]of Object.entries(c))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${c}`;return(await(await fetch(`${t.origin}/artist_commentaries.json?limit=${s}${i}`)).json()).map(u=>{const c=new this(u);return this.manager.set(c.id,c),c})}}h(xt,"manager",new Map);const Jt=$("route").path("/posts/:id").id("post").builder(({$route:r,params:t})=>{if(!Number(t.id))return $("h1").content("404: POST NOT FOUND");const e=Z.get(w.used,+t.id);return[$("div").class("viewer").content(async()=>(await e.ready,e.isVideo?$("video").height(e.image_height).width(e.image_width).src(e.file_ext==="zip"?e.large_file_url:e.file_url).controls(!0).autoplay(!0).loop(!0).disablePictureInPicture(!0):$("img").src(e.large_file_url))),$("div").class("content").content([$("h3").content("Artist's Commentary"),$("section").class("commentary").content(async s=>{const i=(await xt.fetchMultiple(w.used,{post:{_id:e.id}})).at(0);return[i?[i.original_title?$("h3").content(i.original_title):null,$("pre").content(i.original_description)]:"No commentary"]})]),$("div").class("sidebar").self(s=>{let i=0;addEventListener("scroll",()=>{s.inDOM()&&(i=document.documentElement.scrollTop)},{passive:!0}),r.on("beforeShift",()=>{innerWidth>800&&s.css({position:"absolute",top:`calc(${i}px + var(--nav-height) + var(--padding))`})}).on("afterShift",()=>s.css({position:"",top:""}))}).content([$("section").class("post-info").content([new E("id").name("Post").content(`#${t.id}`),new E("uploader").name("Uploader").content(e.uploader$),new E("approver").name("Approver").content(e.approver$),new E("date").name("Date").content(e.created_date$),new E("size").name("Size").content([e.file_size$,e.dimension$]),new E("file-type").name("File Type").content(e.file_ext$),$("div").class("inline").content([new E("favorites").name("Favorites").content(e.favorites$),new E("score").name("Score").content(e.score$)]),new E("file-url").name("File").content($("a").href(e.file_url$).content(e.file_url$.convert(s=>s.replace("https://",""))).target("_blank")),new E("source-url").name("Source").content($("a").href(e.source$).content(e.source$.convert(s=>s.replace("https://",""))).target("_blank")),new E("booru-url").name(w.name$).content($("a").href(e.url$).content(e.url$.convert(s=>s.replace("https://",""))).target("_blank")),new E("booru-url").name("Webm").hide(!0).self(async s=>{await e.ready,e.isUgoria&&s.content($("a").href(e.webm_url$).content(e.webm_url$.convert(i=>i.replace("https://",""))).target("_blank")).hide(!1)})]),$("div").class("post-tags").content(async s=>{const i=await e.fetchTags(),[n,a,o,u,c]=[i.filter(m=>m.category===F.Artist),i.filter(m=>m.category===F.Character),i.filter(m=>m.category===F.General),i.filter(m=>m.category===F.Meta),i.filter(m=>m.category===F.Copyright)];return[d("Artist",n),d("Character",a),d("Copyright",c),d("Meta",u),d("General",o)];function d(m,b){return b.length?[$("h3").content(m),$("section").content([b.map(l=>$("div").class("tag").content([$("a").class("tag-name").content(l.name).href(`/posts?tags=${l.name}`),$("span").class("tag-post-count").content(l.post_count$)]))])]:null}})])]});class E extends f{constructor(e){super("div");h(this,"$name",$("span").class("property-name"));h(this,"$values",$("div").class("property-values"));this.staticClass("property").attribute("property-id",e),super.content([this.$name,this.$values.hide(!0)])}name(e){return this.$name.content(e),this}content(e){this.$values.hide(!1);const s=$.orArrayResolve(e);return this.$values.content(s.map(i=>$("span").staticClass("property-value").content(i))),this}}class Qt extends f{constructor(e){super("post-tile");h(this,"post");h(this,"$video");h(this,"duration$",$.state(""));this.post=e,this.$video=this.post.isVideo?$("video").width(this.post.image_width).height(this.post.image_height).disablePictureInPicture(!0).loop(!0).muted(!0).hide(!0).on("mousedown",s=>s.preventDefault()):null,this.attribute("filetype",this.post.file_ext),this.durationUpdate(),this.build()}build(){var s,i;let e;(s=this.$video)==null||s.on("playing",(n,a)=>{e=setInterval(()=>{this.durationUpdate()},500)}),(i=this.$video)==null||i.on("pause",()=>{clearInterval(e),this.durationUpdate()}),this.class("loading").content([this.post.isVideo?$("div").class("video-detail").content([this.post.hasSound?$("ion-icon").name("volume-medium-outline"):null,this.post.isUgoria?$("ion-icon").name("images-outline"):null,$("span").class("duration").content(this.duration$)]):null,this.post.isGif?$("div").class("gif-detail").content([$("span").content("GIF")]):null,$("a").href(this.post.pathname).content(()=>[this.$video,$("img").draggable(!1).css({opacity:"0"}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading("lazy").on("mousedown",n=>n.preventDefault()).once("load",(n,a)=>{a.src(this.post.previewURL).on(["mouseenter","touchstart"],()=>{this.post.isGif&&a.src(this.post.large_file_url)},{passive:!0}).on(["mouseleave","touchend","touchcancel"],()=>{this.post.isGif&&a.src(this.post.previewURL)},{passive:!0}).animate({opacity:[0,1]},{duration:300,fill:"both"}),this.removeClass("loading")})]).on(["mouseenter","touchstart"],()=>{var n,a;(n=this.$video)!=null&&n.isPlaying||(a=this.$video)==null||a.src(this.post.large_file_url).hide(!1).play().catch(o=>{})},{passive:!0}).on(["mouseleave","touchend","touchcancel"],()=>{var n;(n=this.$video)==null||n.pause().currentTime(0).hide(!0)},{passive:!0})])}durationUpdate(){if(!this.$video)return;const e=Bt(this.post.media_asset.duration*1e3-this.$video.currentTime()*1e3);this.duration$.set(Number(e.hh)>0?`${e.hh}:${e.mm}:${e.ss}`:`${e.mm}:${e.ss}`)}}class $t extends It{constructor(e){super();h(this,"posts",new Set);h(this,"$posts",new Set);h(this,"tags");h(this,"finished",!1);this.tags=e==null?void 0:e.tags,this.addStaticClass("post-grid"),this.type("waterfall").gap(10),this.init()}async init(){setInterval(()=>{this.inDOM()&&document.documentElement.scrollTop===0&&this.updateNewest()},1e4),w.events.on("set",()=>{this.removeAll(),this.finished&&(this.finished=!1,this.loader())}),this.on("resize",()=>this.resize()),this.loader()}async loader(){if(!this.inDOM())return setTimeout(()=>this.loader(),100);for(;this.inDOM()&&document.documentElement.scrollHeight<=innerHeight*2;)if(!(await this.getPosts()).length)return this.finished=!0;if(document.documentElement.scrollTop+innerHeight>document.documentElement.scrollHeight-innerHeight*2&&!(await this.getPosts()).length)return this.finished=!0;setTimeout(()=>this.loader(),100)}resize(){const e=Math.round(this.dom.clientWidth/300);this.column(e>=2?e:2)}addPost(e){e=$.orArrayResolve(e);for(const i of e){if(!i.file_url||this.posts.has(i))continue;const n=new Qt(i);this.$posts.add(n),this.posts.add(i)}const s=[...this.$posts.values()].sort((i,n)=>+n.post.createdDate-+i.post.createdDate);return this.content(s).render(),this}removeAll(){return this.posts.clear(),this.$posts.clear(),this.animate({opacity:[1,0]},{duration:300,easing:"ease"},()=>this.clear().render()),this}async updateNewest(){const e=this.sortedPosts.at(0),s=await Z.fetchMultiple(w.used,{tags:this.tags,id:e?`>${e.id}`:void 0},100);return this.addPost(s),s}async getPosts(){const e=this.sortedPosts.at(-1),s=await Z.fetchMultiple(w.used,{tags:this.tags,id:e?`<${e.id}`:void 0},100);return this.addPost(s),s}get sortedPosts(){return this.posts.array.sort((e,s)=>+s.createdDate-+e.createdDate)}}class Zt{static async fetch(t,e,s=20){return(await fetch(`${t.origin}/autocomplete.json?search[query]=${e}&search[type]=tag_query&version=1&limit=${s}`).then(n=>n.json())).map(n=>new te(n))}}class te{constructor(t){Object.assign(this,t)}isTag(){return this.type==="tag"||this.type==="tag-autocorrect"||this.type==="tag-alias"||this.type==="tag-word"}isTagAutocorrect(){return this.type==="tag-autocorrect"}isTagAntecedent(){return!!this.antecedent}isTagWord(){return this.type==="tag-word"}isUser(){return this.type==="user"}}class ee extends f{constructor(){super("searchbar");h(this,"$tagInput",new re(this));h(this,"$selectionList",new se);h(this,"typingTimer",null);h(this,"$filter",$("div").class("filter"));this.build(),window.addEventListener("keyup",e=>{!this.inDOM()&&e.key==="/"&&this.activate(),this.inDOM()&&e.key==="Escape"&&this.inactivate()})}build(){this.content([$("div").class("input-container").content([this.$tagInput.on("input",()=>this.inputHandler()).on("keydown",e=>this.keyHandler(e)),$("ion-icon").name("close-circle-outline").title("Clear Input").on("click",()=>this.$tagInput.clearAll())]).on("click",e=>{e.target===this.$tagInput.dom&&this.$tagInput.addTag().input()}),$("div").class("selection-list-container").content([this.$selectionList]),this.$filter.on("click",()=>{location.hash==="#search"&&$.back()})])}activate(){return this.hide(!1),this.$filter.animate({opacity:[0,.5]},{duration:300,easing:"ease"}),this.$tagInput.input(),this}inactivate(){return this.animate({opacity:[.5,0]},{duration:300,easing:"ease"},()=>this.hide(!0)),this}keyHandler(e){var n,a;const s=()=>{e.preventDefault(),this.$tagInput.addTag().input()},i=o=>{const u=this.$tagInput.children.indexOf(this.$tagInput.$inputor),c=this.$tagInput.children.array.at(u+1);this.$tagInput.addTag(o.value()),c?this.$tagInput.editTag(c):this.$tagInput.input()};switch(e.key){case"ArrowUp":{e.preventDefault(),this.$selectionList.focusPrevSelection(),this.$tagInput.value((n=this.$selectionList.focused)==null?void 0:n.value());break}case"ArrowDown":{e.preventDefault(),this.$selectionList.focusNextSelection(),this.$tagInput.value((a=this.$selectionList.focused)==null?void 0:a.value());break}case" ":s();break;case"Enter":{e.preventDefault(),this.$selectionList.focused?i(this.$selectionList.focused):(this.$tagInput.addTag(),this.search());break}case"Tab":{e.preventDefault();const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(e.shiftKey){this.$tagInput.editTag(this.$tagInput.children.array.at(o-1));break}if(this.$selectionList.focused)i(this.$selectionList.focused);else{const u=this.$tagInput.children.array.at(o+1);u?this.$tagInput.editTag(u):this.$tagInput.addTag().input()}break}case"Backspace":{const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);o!==0&&!this.$tagInput.$input.value().length&&(e.preventDefault(),this.$tagInput.editTag(this.$tagInput.children.array.at(o-1)));break}}}inputHandler(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.typingTimer=setTimeout(async()=>{this.typingTimer=null,this.getSearchSuggestions()},200)}async getSearchSuggestions(){const e=this.$tagInput.$input.value();if(!e.length)return this.$selectionList.clearSelections();const s=await Zt.fetch(w.used,e,20);this.$selectionList.clearSelections().addSelections(s.map(i=>new ie().value(i.value).content([$("div").class("selection-label").content([i.isTagAntecedent()?$("span").class("tag-antecedent").self(n=>n.dom.innerHTML=i.antecedent.replaceAll(e,`${e}`)):null,$("div").class("label-container").content([i.isTagAntecedent()?$("ion-icon").name("arrow-forward-outline"):null,$("span").class("label").self(n=>n.dom.innerHTML=i.label.replaceAll(e,`${e}`))])]),i.isTag()?$("div").class("tag-detail").content([$("span").class("tag-post-count").content(new Intl.NumberFormat("en",{notation:"compact"}).format(i.post_count)),$("span").class("tag-category").content(F[i.category])]):null,i.isUser()?$("span").class("user-level").content(i.level):null]).on("click",()=>{this.$tagInput.addTag(i.label).input()}))),this.$tagInput.$input.value().length||this.$selectionList.clearSelections()}search(){return $.replace(`/posts?tags=${this.$tagInput.query.replace(":","%3A")}`),this.$tagInput.clearAll(),this.inactivate(),this}checkURL(e,s){e.hash==="#search"&&this.inactivate(),s.hash==="#search"&&this.activate()}}class se extends f{constructor(){super("selection-list");h(this,"focused",null);h(this,"selections",new Set)}addSelections(e){e=$.orArrayResolve(e);for(const s of e)this.selections.add(s);return this.insert(e),this}clearSelections(){return this.focused=null,this.selections.clear(),this.clear(),this}focusSelection(e){return this.blurSelection(),this.focused=e,e.focus(),e.offsetTopthis.scrollTop()+this.offsetHeight&&this.scrollTop(e.offsetTop+e.offsetHeight-this.offsetHeight),this}blurSelection(){var e;return(e=this.focused)==null||e.blur(),this.focused=null,this}focusNextSelection(){const e=this.selections.array,s=e.at(0);if(this.focused){const i=e.at(e.indexOf(this.focused)+1);i?this.focusSelection(i):s&&this.focusSelection(s)}else s&&this.focusSelection(s)}focusPrevSelection(){const e=this.selections.array;if(this.focused){const s=e.at(e.indexOf(this.focused)-1);s&&this.focusSelection(s)}else{const s=e.at(0);s&&this.focusSelection(s)}}}class ie extends f{constructor(){super("selection");h(this,"property",{value:""})}value(e){return $.fluent(this,arguments,()=>this.property.value,()=>$.set(this.property,"value",e))}focus(){return this.addClass("active"),this}blur(){return this.removeClass("active"),this}}class re extends f{constructor(e){super("tag-input");h(this,"$input",$("input").type("text"));h(this,"$sizer",$("span").class("sizer"));h(this,"$inputor",$("div").class("input-wrapper").content([this.$sizer,this.$input.on("input",()=>{this.$sizer.content(this.$input.value())})]));h(this,"tags",new Set);h(this,"$seachbar");this.$seachbar=e}input(){return this.insert(this.$inputor),this.$input.focus(),this.$input.value()?this.$seachbar.getSearchSuggestions():this.$seachbar.$selectionList.clearSelections(),this}addTag(e){if(e=e??this.$input.value(),!e.length)return this;const s=new ne(e);return s.on("click",()=>this.editTag(s)),this.tags.add(s),this.value(""),this.$inputor.replace(s),this}editTag(e){return this.addTag(),this.tags.delete(e),e.replace(this.$inputor),this.value(e.name),this.$input.focus(),this.$seachbar.getSearchSuggestions(),this}clearAll(){return this.value(""),this.tags.clear(),this.clear(),this}value(e){return e===void 0?this:(this.$input.value(e),this.$sizer.content(e),this)}get query(){return this.tags.array.map(e=>e.name).toString().replace(",","+")}}class ne extends f{constructor(e){super("tag");h(this,"name");this.name=e,this.build()}build(){this.content(this.name)}}class oe extends f{constructor(){super("ion-icon")}name(t){return this.attribute("name",t),this}size(t){return this.attribute("size",t),this}}class ae extends ht{constructor(){super();h(this,"$icon",$("ion-icon"));h(this,"$label",$("span"));this.addStaticClass("icon"),this.build()}build(){super.content([this.$icon,this.$label])}content(e){return this.$label.content(e),this}icon(e){return this.$icon.name(e),this}}$.registerTagName("ion-icon",oe);$.registerTagName("icon-button",ae);$.anchorHandler=r=>{$.open(r.href(),r.target())};const[at,he]=[new w({origin:"https://danbooru.donmai.us",name:"Danbooru"}),new w({origin:"https://safebooru.donmai.us",name:"Safebooru"}),new w({origin:"https://testbooru.donmai.us",name:"Testbooru"})];w.set(w.manager.get(w.storageAPI??"")??at);const ut=new ee().hide(!0);location.hash==="#search"&&ut.activate();$(document.body).content([$("nav").content([$("a").class("title").href("/").content([$("h1").class("booru-name").content(w.name$),$("h2").class("app").content([$("span").class("app-name").content("Viewer"),$("span").class("version").content("v0.3.4")])]),$("div").class("searchbar").content(["Search in ",w.name$]).self(r=>L.events.on("stateChange",({beforeURL:t,afterURL:e})=>{t.hash==="#search"&&r.hide(!1),e.hash==="#search"&&r.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("div").class("buttons").content([$("ion-icon").class("search").name("search-outline").title("Search").self(r=>L.events.on("stateChange",({beforeURL:t,afterURL:e})=>{t.hash==="#search"&&r.hide(!1),e.hash==="#search"&&r.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("ion-icon").class("switch").name("swap-horizontal").title("Switch Booru").on("click",()=>{w.used===at?w.set(he):w.set(at)}),$("ion-icon").class("open").name("open-outline").title("Open in Original Site").on("click",()=>$.open(location.href.replace(location.origin,w.used.origin)))])]),ut,$("router").base("/").map([$("route").id("posts").path("/").builder(()=>new $t),$("route").id("posts").path("/posts?tags").builder(({query:r})=>new $t({tags:r.tags})),Jt]).on("beforeSwitch",r=>{r.preventDefault();function s(){var a;const n=$.call(()=>{switch(L.navigationDirection){case U.Forward:return["translateX(2%)","translateX(0%)"];case U.Back:return["translateX(-2%)","translateX(0%)"];case U.Replace:return""}});r.$view.content(r.nextContent),r.rendered(),(a=r.nextContent.element)==null||a.class("animated").animate({opacity:[0,1],transform:n},{duration:300,easing:"ease"},()=>{var o;r.switched(),(o=r.nextContent.element)==null||o.removeClass("animated")})}function i(){var a,o;const n=$.call(()=>{switch(L.navigationDirection){case U.Forward:return["translateX(0%)","translateX(-2%)"];case U.Back:return["translateX(0%)","translateX(2%)"];case U.Replace:return""}});(o=(a=r.previousContent)==null?void 0:a.element)==null||o.class("animated").animate({opacity:[1,0],transform:n},{duration:300,easing:"ease"},()=>{var u,c;(c=(u=r.previousContent)==null?void 0:u.element)==null||c.removeClass("animated"),s()})}r.previousContent?i():s()})]);L.events.on("stateChange",({beforeURL:r,afterURL:t})=>{ut.checkURL(r,t)}); diff --git a/dist/assets/index-DeBFHjT4.css b/dist/assets/index-DeBFHjT4.css deleted file mode 100644 index 5c00c27..0000000 --- a/dist/assets/index-DeBFHjT4.css +++ /dev/null @@ -1 +0,0 @@ -layout.post-grid{margin-top:1rem}post-tile{display:block;transition:.3s all ease;position:relative;transition:all .3s ease;border-radius:10px;overflow:hidden;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}@media (hover: hover){post-tile:hover{transform:scale(1.02);z-index:1;box-shadow:0 0 10px color-mix(in srgb,var(--background-color) 50%,transparent)}}post-tile.loading{transition:none}post-tile:active{transform:scale(.95)}post-tile div.video-detail,post-tile div.gif-detail{position:absolute;background-color:var(--background-color-lighter);color:var(--primary-color);bottom:.3rem;right:.3rem;padding:.2em .4em;height:1rem;border-radius:4px;font-size:12px;display:flex;align-items:center;gap:.2rem;z-index:2}post-tile div.video-detail ion-icon,post-tile div.gif-detail ion-icon{font-size:1.4rem}post-tile div.video-detail ion-icon[name=images-outline],post-tile div.gif-detail ion-icon[name=images-outline]{padding:.1rem;font-size:1rem}post-tile div.video-detail span.duration,post-tile div.gif-detail span.duration{text-transform:uppercase;z-index:2}post-tile img{height:100%;width:100%;vertical-align:top;background-color:var(--background-color)}post-tile video{height:100%;width:100%;object-fit:cover;position:absolute;z-index:1}searchbar{display:flex;align-items:center;flex-direction:column;width:100%;z-index:200;position:fixed;height:100%}searchbar div.input-container{margin-top:.4rem;background-color:color-mix(in srgb,var(--background-color-light) 100%,transparent);border-radius:.4rem;font-size:1rem;width:500px;padding:.4rem;max-width:calc(100% - 2rem);box-sizing:border-box;z-index:201;display:flex;align-items:center;border:1px solid var(--secondary-color-dark)}searchbar div.input-container:focus-within{outline:none}searchbar div.input-container tag-input{display:flex;gap:.4rem;width:100%;overflow:hidden;padding-inline:.4rem;box-sizing:border-box;cursor:text}searchbar div.input-container tag-input tag{display:inline-block;padding:.2rem .4rem;background-color:var(--secondary-color-dark);color:var(--secondary-color);border-radius:.4rem;cursor:pointer}searchbar div.input-container ion-icon{font-size:20px;color:var(--secondary-color-dark);cursor:pointer}searchbar div.input-container ion-icon:hover{color:var(--secondary-color)}searchbar div.selection-list-container{overflow:hidden;border-radius:.4rem;background-color:var(--background-color);z-index:201;max-width:calc(100% - 2rem);width:500px}searchbar div.selection-list-container selection-list{display:block;max-height:40vh;overflow-y:scroll;overflow-x:hidden;position:relative}searchbar div.selection-list-container selection-list::-webkit-scrollbar{width:4px}searchbar div.selection-list-container selection-list selection{display:flex;justify-content:space-between;align-items:center;padding:.4rem 1rem;cursor:pointer;gap:1rem}searchbar div.selection-list-container selection-list selection:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}searchbar div.selection-list-container selection-list selection.active{background-color:var(--background-color-lighter)}searchbar div.selection-list-container selection-list selection div.selection-label{display:flex;flex-wrap:wrap;gap:.5rem}searchbar div.selection-list-container selection-list selection div.selection-label .label-container{display:flex;gap:.5rem;align-items:center}searchbar div.selection-list-container selection-list selection div.selection-label .label-container ion-icon{font-size:1rem}searchbar div.selection-list-container selection-list selection div.tag-detail{display:flex;align-items:center;gap:.5rem}searchbar div.selection-list-container selection-list selection div.tag-detail .tag-post-count{font-size:.8rem}searchbar div.selection-list-container selection-list selection .tag-category,searchbar div.selection-list-container selection-list selection .user-level{padding:.1rem .4rem;border-radius:.4rem;font-size:.9rem;background-color:var(--secondary-color-dark);color:var(--secondary-color)}searchbar div.filter{background-color:var(--background-color);opacity:.5;position:fixed;top:0;height:100%;width:100%;z-index:199}.input-wrapper{color:var(--primary-color);border:1px solid var(--secondary-color);border-radius:.4rem;position:relative;box-sizing:border-box;line-height:1em;font-size:14px;padding:4px 8px;display:inline-block;max-width:100%;text-overflow:ellipsis}.input-wrapper span.sizer{font-family:inherit;white-space:pre;height:1em;display:inline-block;font-size:inherit;line-height:inherit;box-sizing:border-box;position:relative;opacity:0;min-width:2px;-webkit-user-select:none;user-select:none;vertical-align:top}.input-wrapper input{height:100%;text-overflow:ellipsis;font-family:inherit;background:none;color:inherit;top:0;left:0;font-size:inherit;line-height:inherit;padding:inherit;position:absolute;box-sizing:border-box;width:100%;border:none;outline:none}button.icon{display:flex;justify-content:center;align-items:center;gap:.4rem;padding:.4rem;background-color:transparent}button.icon ion-icon{font-size:1.5rem}button.icon:hover{background-color:var(--background-color-light)}button.icon.vertical{flex-direction:column}#post{padding:0;padding-top:var(--nav-height)}#post section{background-color:#2f2f45;border-radius:20px;padding:20px}#post div.viewer{height:calc(100vh - 2rem - var(--nav-height));display:flex;justify-content:center;align-items:center;background-color:#000;border-radius:20px;overflow:hidden;width:calc(100vw - 300px - 4rem);margin:1rem}@media (max-width: 800px){#post div.viewer{width:100%;height:calc(100vh - var(--nav-height));border-radius:0;margin:0}}#post div.viewer img{max-width:100%;max-height:100%}#post div.viewer video{max-width:100%;max-height:100%;-webkit-user-drag:none;transition:all .3s ease}#post div.content{width:calc(100vw - 300px - 2rem);display:flex;flex-direction:column;padding:1rem;box-sizing:border-box}@media (max-width: 800px){#post div.content{width:100%}}#post div.content::-webkit-scrollbar{background-color:#000;width:4px}#post div.content::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}#post div.content>h3{padding-left:1rem;margin-block:1rem}#post div.content section.commentary *{text-wrap:wrap;word-break:break-word}#post div.sidebar{--padding: 1rem;position:fixed;top:calc(var(--nav-height) + var(--padding));right:var(--padding);display:flex;flex-direction:column;gap:.4rem;width:300px;overflow:scroll;overflow-x:hidden;height:calc(100vh - 2rem - var(--nav-height));border-radius:20px}@media (max-width: 800px){#post div.sidebar{position:static;width:100%;overflow:visible;height:100%;padding:1rem;box-sizing:border-box}}#post div.sidebar::-webkit-scrollbar{background-color:#000;width:0px}#post div.sidebar::-webkit-scrollbar-thumb{background-color:#aeaeec}#post div.sidebar h3{padding-left:1rem;margin-block:.6rem}#post div.sidebar .post-info{background-color:#2f2f45;border-radius:20px;padding:20px;display:flex;flex-direction:column;gap:.4rem}#post div.sidebar .post-info .buttons{display:grid;grid-template-columns:1fr 1fr 1fr;gap:1rem;margin-top:1rem}#post div.sidebar div.property{display:flex;gap:.6rem;align-items:center;width:100%}#post div.sidebar div.property span.property-name{flex-shrink:0}#post div.sidebar div.property div.property-values{display:flex;gap:.4rem;overflow:hidden}#post div.sidebar div.property div.property-values span.property-value{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:2px 4px;border-radius:4px;text-overflow:ellipsis;overflow:hidden;text-wrap:nowrap}#post div.sidebar div.inline{display:flex;gap:1rem}#post div.sidebar div.post-tags{display:flex;flex-direction:column;gap:.2rem}#post div.sidebar div.post-tags div.tag{align-items:center}#post div.sidebar div.post-tags div.tag a.tag-name{word-break:break-word;color:#d1d1ee;text-decoration:none}#post div.sidebar div.post-tags div.tag span.tag-post-count{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:0 4px;border-radius:4px;font-size:12px;margin-left:.4rem}page#root layout *{transition:all .3s ease}page#root .loader{text-align:center;padding-block:2rem}:root{--background-color: #1e1e2c;--background-color-lighter: #3b3b66;--background-color-light: #24243b;--primary-color: #d1d1ee;--primary-color-dark: #9696b3;--primary-color-darker: #72728d;--secondary-color: #aeaeec;--secondary-color-dark: #424268;--nav-height: 50px}html{overflow-x:hidden;font-size:14px}html ::-webkit-scrollbar{background-color:var(--background-color);width:8px}html ::-webkit-scrollbar-thumb{background-color:#aeaeec;border-radius:2px}body{overflow-x:hidden;background-color:var(--background-color);color:var(--primary-color);margin:0;font-family:Microsoft Yahei}nav{display:flex;width:100%;height:var(--nav-height);position:fixed;top:0;z-index:100;background-color:color-mix(in srgb,var(--background-color) 70%,transparent);justify-content:space-between;align-items:center;padding-inline:1rem;box-sizing:border-box;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}nav a.title{display:flex;align-items:center;gap:.4rem;text-decoration:none}nav a.title .booru-name{color:var(--secondary-color);margin:0}nav a.title .app{display:flex;align-items:center;border-radius:.4rem;margin:0;gap:.4rem}nav a.title .app .version{color:var(--background-color);background-color:var(--secondary-color);padding:.2em .4em;border-radius:.4rem;font-size:.8rem;font-weight:700}nav a.title .app .app-name{display:none;font-size:1rem;color:var(--secondary-color)}nav div.searchbar{padding:.4rem 10%;max-width:500px;background-color:color-mix(in srgb,var(--background-color-light) 30%,transparent);border:1px solid var(--primary-color-darker);border-radius:.4rem;color:var(--primary-color-dark);transition:.3s all ease;cursor:pointer}nav div.searchbar:hover{color:var(--primary-color)}nav div.buttons{display:flex;align-items:center;gap:1rem}nav div.buttons ion-icon{transition:all .3s ease;border-radius:1rem;padding:.4rem}nav div.buttons ion-icon:hover{background-color:color-mix(in srgb,var(--background-color-lighter) 50%,transparent)}nav div.buttons ion-icon.search{display:none}@media (max-width: 800px){nav div.searchbar{display:none}nav div.buttons ion-icon.search{display:inline-block}}router{display:block;position:relative}router route{display:block;position:relative;padding-inline:10px;padding-top:var(--nav-height)}button{background-color:var(--secondary-color-dark);color:var(--secondary-color);padding:.8rem 1.2rem;border-radius:1rem;border:none;cursor:pointer}ion-icon{font-size:24px;color:var(--primary-color);cursor:pointer}ion-icon:hover{color:var(--secondary-color)}a{color:var(--secondary-color);text-decoration:none} diff --git a/dist/assets/index-La3x4wRW.js b/dist/assets/index-La3x4wRW.js new file mode 100644 index 0000000..906975b --- /dev/null +++ b/dist/assets/index-La3x4wRW.js @@ -0,0 +1 @@ +var kt=Object.defineProperty;var gt=n=>{throw TypeError(n)};var Ct=(n,e,t)=>e in n?kt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var h=(n,e,t)=>Ct(n,typeof e!="symbol"?e+"":e,t),$t=(n,e,t)=>e.has(n)||gt("Cannot "+t);var x=(n,e,t)=>($t(n,e,"read from private field"),t?t.call(n):e.get(n)),K=(n,e,t)=>e.has(n)?gt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),J=(n,e,t,s)=>($t(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();class G{constructor(){h(this,"__hidden",!1);h(this,"domEvents",{});h(this,"parent");h(this,"events",new st)}on(e,t,s){e=w.orArrayResolve(e);for(const i of e){this.domEvents[i]||(this.domEvents[i]=new Map);const r=a=>{t(a,this)};this.domEvents[i].set(t,r),this.events.on(i,t),this.dom.addEventListener(i,r,s)}return this}off(e,t,s){var r;const i=(r=this.domEvents[e])==null?void 0:r.get(t);return i&&this.dom.removeEventListener(e,i,s),this.events.off(e,t),this}once(e,t,s){const i=r=>{this.dom.removeEventListener(e,i,s),t(r,this)};return this.dom.addEventListener(e,i,s),this.events.once(e,t),this}hide(e,t=!0){return w.fluent(this,arguments,()=>this.__hidden,()=>{var s;if(e!==void 0)return e instanceof S?(this.__hidden=e.value,e.use(this,"hide")):this.__hidden=e,t&&((s=this.parent)==null||s.children.render()),this})}remove(){var e;return(e=this.parent)==null||e.children.remove(this).render(),this}replace(e){var t;return(t=this.parent)==null||t.children.replace(this,e).render(),this}contains(e){return e?e instanceof G?this.dom.contains(e.dom):e instanceof EventTarget?this.dom.contains(w(e).dom):this.dom.contains(e):!1}self(e){return e(this),this}inDOM(){return document.contains(this.dom)}isElement(){return this instanceof C}get element(){return this instanceof C?this:null}}class C extends G{constructor(t,s){super();h(this,"dom");h(this,"static_classes",new Set);this.dom=this.createDom(t,s),this.dom.$=this,this.setOptions(s)}createDom(t,s){return s!=null&&s.dom?s.dom:t==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement((s==null?void 0:s.tagname)??t)}setOptions(t){return this.id(t==null?void 0:t.id),t&&t.class&&this.class(...t.class),this}id(t){return $.fluent(this,arguments,()=>this.dom.id,()=>$.set(this.dom,"id",t))}class(...t){return $.fluent(this,arguments,()=>this.dom.classList,()=>{this.dom.classList.forEach(s=>this.static_classes.has(s)??this.dom.classList.remove(s)),this.dom.classList.add(...t.detype())})}addClass(...t){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.add(...t.detype())})}removeClass(...t){return $.fluent(this,arguments,()=>this,()=>{this.dom.classList.remove(...t.detype())})}staticClass(...t){return $.fluent(this,arguments,()=>this.static_classes,()=>{this.removeClass(...this.static_classes),this.static_classes.clear(),this.addStaticClass(...t)})}addStaticClass(...t){return $.fluent(this,arguments,()=>this,()=>{t.detype().forEach(s=>this.static_classes.add(s)),this.addClass(...t)})}removeStaticClass(...t){return $.fluent(this,arguments,()=>this,()=>{t.detype().forEach(s=>this.static_classes.delete(s)),this.removeClass(...t)})}css(t){return $.fluent(this,arguments,()=>this.dom.style,()=>{Object.assign(this.dom.style,t)})}attribute(t,s){return arguments.length?arguments.length===1?t===void 0?null:this.dom.getAttribute(t):arguments.length===2?t?(s===null?this.dom.removeAttribute(t):s!==void 0&&this.dom.setAttribute(t,`${s}`),this):this:this:null}tabIndex(t){return $.fluent(this,arguments,()=>this.dom.tabIndex,()=>$.set(this.dom,"tabIndex",t))}focus(){return this.dom.focus(),this}blur(){return this.dom.blur(),this}animate(t,s,i){const r=this.dom.animate(t,s);return i&&(r.onfinish=()=>i(r)),r}getAnimations(t){return this.dom.getAnimations(t)}get dataset(){return this.dom.dataset}domRect(t){const s=this.dom.getBoundingClientRect();if(!t)return s;const i=t instanceof C?t.dom.getBoundingClientRect():t;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}}class Q extends G{constructor(t){super();h(this,"dom");this.dom=t,this.dom.$=this}domRect(t){const s={bottom:innerHeight,height:innerHeight,left:0,right:innerWidth,top:0,width:innerWidth,x:0,y:0};if(!t)return s;const i=t instanceof C?t.dom.getBoundingClientRect():t;return{...s,top:s.top-i.top,left:s.left-i.left,right:s.right-i.left,bottom:s.bottom-i.top,x:s.x-i.x,y:s.y-i.y}}static from(t){return t.$ instanceof Q?t.$:new Q(t)}}const Rt="modulepreload",Dt=function(n){return"/"+n},yt={},Nt=function(e,t,s){let i=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(t.map(u=>{if(u=Dt(u),u in yt)return;yt[u]=!0;const c=u.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${d}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":Rt,c||(m.as="script"),m.crossOrigin="",m.href=u,o&&m.setAttribute("nonce",o),document.head.appendChild(m),c)return new Promise((b,l)=>{m.addEventListener("load",b),m.addEventListener("error",()=>l(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})};class Ht{constructor(e){h(this,"$container");h(this,"childList",new Set);this.$container=e}add(e,t=-1){if(t===-1||this.childList.size-1===t)this.childList.add(e);else{const s=[...this.childList];s.splice(t,0,e),this.childList.clear(),s.forEach(i=>this.childList.add(i))}e.parent=this.$container}remove(e){return this.childList.has(e)?(this.childList.delete(e),e.parent=void 0,this):this}removeAll(e=!0){this.childList.forEach(t=>this.remove(t)),e&&this.render()}replace(e,t){const s=this.array;return s.splice(s.indexOf(e),1,t),e.remove(),this.childList.clear(),s.forEach(i=>this.childList.add(i)),t.parent=this.$container,this}render(){const[e,t]=[this.array.map(i=>i.dom),Array.from(this.dom.childNodes)],s=[];for(;t.length||e.length;){const[i,r]=[t.at(0),e.at(0)];r?i?r!==i?(r.$.__hidden||(this.dom.insertBefore(r,i),s.push(r)),e.shift()):(r.$.__hidden&&this.dom.removeChild(r),e.shift(),t.shift()):(r.$.__hidden||this.dom.append(r),e.shift()):(i&&!s.includes(i)&&i.remove(),t.shift())}}indexOf(e){return this.array.indexOf(e)}get array(){return[...this.childList.values()]}get dom(){return this.$container.dom}}class S{constructor(e,t){h(this,"_value");h(this,"attributes",new Map);h(this,"linkStates",new Set);h(this,"options",{});this.set(e),t&&(this.options=t)}set(e){this._value=e,e instanceof S&&e.linkStates.add(this),this.update(),this.linkStates.forEach(t=>t.update())}static toJSON(e){const t={};for(let[s,i]of Object.entries(e))i instanceof S?i=i.toJSON():i instanceof Object&&S.toJSON(i),Object.assign(t,{[s]:i});return t}update(){for(const[e,t]of this.attributes.entries())for(const s of t)e[s]instanceof Function?this.options.format?e[s](this.options.format(this.value)):e[s](this.value):s in e&&(e[s]=this.value)}use(e,t){const s=this.attributes.get(e);s?s.add(t):this.attributes.set(e,new Set().add(t))}convert(e){return new S(this,{format:e})}get value(){return this._value instanceof S?this._value.value:this._value}toString(){return this.options.format?this.options.format(this.value):this.value instanceof Object?JSON.stringify(this.toJSON()):`${this.value}`}toJSON(){return this.value instanceof S?this.value.toJSON():this.value instanceof Object?S.toJSON(this.value):this.toString()}}class X extends G{constructor(t){super();h(this,"dom");this.dom=new Text(t),this.dom.$=this}content(t){return $.fluent(this,arguments,()=>this.dom.textContent,()=>$.set(this.dom,"textContent",t))}}class Z extends C{constructor(e,t){super(e,t)}autocapitalize(e){return $.fluent(this,arguments,()=>this.dom.autocapitalize,()=>$.set(this.dom,"autocapitalize",e))}innerText(e){return $.fluent(this,arguments,()=>this.dom.innerText,()=>$.set(this.dom,"innerText",e))}title(e){return $.fluent(this,arguments,()=>this.dom.title,()=>$.set(this.dom,"title",e))}dir(e){return $.fluent(this,arguments,()=>this.dom.dir,()=>$.set(this.dom,"dir",e))}translate(e){return $.fluent(this,arguments,()=>this.dom.translate,()=>$.set(this.dom,"translate",e))}popover(e){return $.fluent(this,arguments,()=>this.dom.popover,()=>$.set(this.dom,"popover",e))}spellcheck(e){return $.fluent(this,arguments,()=>this.dom.spellcheck,()=>$.set(this.dom,"spellcheck",e))}inert(e){return $.fluent(this,arguments,()=>this.dom.inert,()=>$.set(this.dom,"inert",e))}lang(e){return $.fluent(this,arguments,()=>this.dom.lang,()=>$.set(this.dom,"lang",e))}draggable(e){return $.fluent(this,arguments,()=>this.dom.draggable,()=>$.set(this.dom,"draggable",e))}hidden(e){return $.fluent(this,arguments,()=>this.dom.hidden,()=>$.set(this.dom,"hidden",e))}click(){return this.dom.click(),this}attachInternals(){return this.dom.attachInternals()}hidePopover(){return this.dom.hidePopover(),this}showPopover(){return this.dom.showPopover(),this}togglePopover(){return this.dom.togglePopover(),this}get accessKeyLabel(){return this.dom.accessKeyLabel}get offsetHeight(){return this.dom.offsetHeight}get offsetLeft(){return this.dom.offsetLeft}get offsetParent(){return $(this.dom.offsetParent)}get offsetTop(){return this.dom.offsetTop}get offsetWidth(){return this.dom.offsetWidth}}class f extends Z{constructor(t,s){super(t,s);h(this,"children",new Ht(this));h(this,"__position_cursor",0)}content(t){return $.fluent(this,arguments,()=>this,()=>{this.children.removeAll(!1),this.insert(t)})}insert(t,s=-1){return $.fluent(this,arguments,()=>this,async()=>{if(t instanceof Function){let i=t(this);i instanceof Promise?t=await i:t=i}else t instanceof Promise&&(t=await t);t=$.orArrayResolve(t),this.__position_cursor=s<0?this.children.array.length+s:s;for(const i of t)if(i!=null){if(i instanceof Array)this.insert(i,this.__position_cursor);else if(typeof i=="string")this.children.add(new X(i),s);else if(i instanceof S){const r=new X(i.toString());i.use(r,"content"),this.children.add(r,s)}else if(i instanceof Promise){const r=(await Nt(async()=>{const{$Async:o}=await Promise.resolve().then(()=>Xt);return{$Async:o}},void 0)).$Async,a=new r().await(i);this.children.add(a,s)}else this.children.add(i,s);this.__position_cursor+=1}this.children.render()})}clear(){return this.children.removeAll(),this}$(t){return $(this.dom.querySelector(t))}$all(t){return Array.from(this.dom.querySelectorAll(t)).map(s=>$(s))}get scrollHeight(){return this.dom.scrollHeight}get scrollWidth(){return this.dom.scrollWidth}scrollTop(t){return $.fluent(this,arguments,()=>this.dom.scrollTop,()=>$.set(this.dom,"scrollTop",t))}scrollLeft(t){return $.fluent(this,arguments,()=>this.dom.scrollLeft,()=>$.set(this.dom,"scrollLeft",t))}}class Vt extends f{constructor(e){super("a",e),this.dom.addEventListener("click",t=>{$.anchorHandler&&this.href()&&(t.preventDefault(),$.anchorHandler(this,t))})}href(e){return $.fluent(this,arguments,()=>this.dom.href,()=>$.set(this.dom,"href",e))}target(e){return $.fluent(this,arguments,()=>this.dom.target??void 0,()=>{e&&(this.dom.target=e)})}}class jt extends C{constructor(e,t){super(e,t)}}var I;(n=>{function e(o,u,c,d){return u.length?(d(),o):c()}n.fluent=e;function t(o){return o instanceof Array?o:[o]}n.orArrayResolve=t;function s(o,u){return t(u).forEach(c=>{Object.getOwnPropertyNames(c.prototype).forEach(d=>{d!=="constructor"&&Object.defineProperty(o.prototype,d,Object.getOwnPropertyDescriptor(c.prototype,d)||Object.create(null))})}),o}n.mixin=s;function i(o,u,c){c!==void 0&&(o[u]=c)}n.set=i;function r(o){return new S(o)}n.state=r;function a(o){if(o.$)return o.$;if(o.nodeName.toLowerCase()==="body")return new f("body",{dom:o});if(o.nodeName.toLowerCase()==="#document")return Q.from(o);if(o instanceof HTMLElement){const u=$.TagNameElementMap[o.tagName.toLowerCase()],c=u===f?new u(o.tagName,{dom:o}):new u({dom:o});if(c instanceof f)for(const d of Array.from(c.dom.childNodes))c.children.add($(d));return c}else if(o instanceof Text){const u=new X(o.textContent??"");return u.dom=o,u}else if(o instanceof SVGElement&&o.tagName.toLowerCase()==="svg")return new jt("svg",{dom:o});throw`$NODE.FROM: NOT SUPPORT TARGET ELEMENT TYPE (${o.nodeName})`}n.from=a})(I||(I={}));class A{static create(...e){const t=class{};return Object.getOwnPropertyNames(A.prototype).forEach(s=>{s!=="constructor"&&e.includes(s)&&Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(A.prototype,s)||Object.create(null))}),t}disabled(e){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",e))}checkValidity(){return this.dom.checkValidity()}reportValidity(){return this.dom.reportValidity()}formAction(e){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",e))}formEnctype(e){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",e))}formMethod(e){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",e))}formNoValidate(e){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",e))}formTarget(e){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",e))}autocomplete(e){return $.fluent(this,arguments,()=>this.dom.autocomplete,()=>$.set(this.dom,"autocomplete",e))}name(e){return $.fluent(this,arguments,()=>this.dom.name,()=>$.set(this.dom,"name",e))}maxLength(e){return $.fluent(this,arguments,()=>this.dom.maxLength,()=>$.set(this.dom,"maxLength",e))}minLength(e){return $.fluent(this,arguments,()=>this.dom.minLength,()=>$.set(this.dom,"minLength",e))}required(e){return $.fluent(this,arguments,()=>this.dom.required,()=>$.set(this.dom,"required",e))}label(e){return $.fluent(this,arguments,()=>this.dom.label,()=>$.set(this.dom,"label",e))}get form(){return this.dom.form?$(this.dom.form):null}get validationMessage(){return this.dom.validationMessage}get validity(){return this.dom.validity}get willValidate(){return this.dom.willValidate}}class lt extends f{constructor(e){super("button",e)}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}}I.mixin(lt,A.create("disabled","checkValidity","formAction","formEnctype","formMethod","formNoValidate","formTarget","reportValidity"));class wt extends f{constructor(e){super("form",e)}action(e){return $.fluent(this,arguments,()=>this.dom.formAction,()=>$.set(this.dom,"formAction",e))}enctype(e){return $.fluent(this,arguments,()=>this.dom.formEnctype,()=>$.set(this.dom,"formEnctype",e))}method(e){return $.fluent(this,arguments,()=>this.dom.formMethod,()=>$.set(this.dom,"formMethod",e))}noValidate(e){return $.fluent(this,arguments,()=>this.dom.formNoValidate,()=>$.set(this.dom,"formNoValidate",e))}acceptCharset(e){return $.fluent(this,arguments,()=>this.dom.acceptCharset,()=>$.set(this.dom,"acceptCharset",e))}target(e){return $.fluent(this,arguments,()=>this.dom.formTarget,()=>$.set(this.dom,"formTarget",e))}requestSubmit(){return this.dom.requestSubmit(),this}reset(){return this.dom.reset(),this}submit(){return this.dom.submit(),this}get length(){return this.dom.length}get elements(){return Array.from(this.dom.elements).map(e=>$(e))}}I.mixin(wt,A.create("checkValidity","reportValidity","autocomplete"));class D extends Z{constructor(e){super("input",e)}value(e){return $.fluent(this,arguments,()=>this.type()==="number"?Number(this.dom.value):this.dom.value,()=>$.set(this.dom,"value",e,t=>{this.on("input",()=>{t.attributes.has(this.dom)!==!1&&(typeof t.value=="string"&&t.set(`${this.value()}`),typeof t.value=="number"&&t.set(Number(this.value())))})}))}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}capture(e){return $.fluent(this,arguments,()=>this.dom.capture,()=>$.set(this.dom,"capture",e))}alt(e){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}defaultValue(e){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",e))}dirName(e){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",e))}pattern(e){return $.fluent(this,arguments,()=>this.dom.pattern,()=>$.set(this.dom,"pattern",e))}placeholder(e){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",e))}readOnly(e){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",e))}selectionDirection(e){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",e))}selectionEnd(e){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",e))}selectionStart(e){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",e))}size(e){return $.fluent(this,arguments,()=>this.dom.size,()=>$.set(this.dom,"size",e))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}inputMode(e){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",e))}valueAsDate(e){return $.fluent(this,arguments,()=>this.dom.valueAsDate,()=>$.set(this.dom,"valueAsDate",e))}valueAsNumber(e){return $.fluent(this,arguments,()=>this.dom.valueAsNumber,()=>$.set(this.dom,"valueAsNumber",e))}webkitdirectory(e){return $.fluent(this,arguments,()=>this.dom.webkitdirectory,()=>$.set(this.dom,"webkitdirectory",e))}select(){return this.dom.select(),this}setCustomValidity(e){return this.dom.setCustomValidity(e),this}setRangeText(e,t,s,i){return typeof t=="number"&&typeof s=="number"&&this.dom.setRangeText(e,t,s,i),this.dom.setRangeText(e),this}setSelectionRange(e,t,s){return this.dom.setSelectionRange(e,t,s),this}showPicker(){return this.dom.showPicker(),this}get files(){return this.dom.files}get webkitEntries(){return this.dom.webkitEntries}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}I.mixin(D,A.create("checkValidity","reportValidity","autocomplete","name","form","required","validationMessage","validity","willValidate","formAction","formEnctype","formMethod","formNoValidate","formTarget"));class Ut extends D{constructor(e){super(e),this.type("number")}static from(e){return $.mixin(D,this)}stepDown(){return this.dom.stepDown(),this}stepUp(){return this.dom.stepUp(),this}max(e){return $.fluent(this,arguments,()=>this.dom.max===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"max",e==null?void 0:e.toString()))}min(e){return $.fluent(this,arguments,()=>this.dom.min===""?null:parseInt(this.dom.min),()=>$.set(this.dom,"min",e==null?void 0:e.toString()))}step(e){return $.fluent(this,arguments,()=>Number(this.dom.step),()=>$.set(this.dom,"step",e==null?void 0:e.toString()))}}class Ft extends D{constructor(e){super(e),this.type("radio")}static from(e){return $.mixin(D,this)}checked(e){return $.fluent(this,arguments,()=>this.dom.checked,()=>$.set(this.dom,"checked",e))}defaultChecked(e){return $.fluent(this,arguments,()=>this.dom.defaultChecked,()=>$.set(this.dom,"defaultChecked",e))}}class Wt extends D{constructor(e){super(e),this.type("file")}static from(e){return $.mixin(D,this)}multiple(e){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",e))}accept(...e){return $.fluent(this,arguments,()=>this.dom.accept.split(","),()=>this.dom.accept=e.toString())}}I.mixin(D,[Ut,Ft,Wt]);class bt extends f{constructor(e){super("label",e)}for(e){return $.fluent(this,arguments,()=>this.dom.htmlFor,()=>{$.set(this.dom,"htmlFor",e)})}get control(){return this.dom.control}}I.mixin(bt,A.create("form"));class Gt extends Z{constructor(e){super("img",e)}async load(e){return new Promise(t=>{const s=this.once("load",()=>{t(s)});typeof e=="string"?s.src(e):e.then(i=>s.src(i))})}static resize(e,t){return new Promise(s=>{const i=new Image;if(i.addEventListener("load",()=>{const r=document.createElement("canvas"),a=r.getContext("2d");if(!a)throw"$Image.resize: context undefined";const o=i.width/i.height,[u,c,d]=[o>1,o<1,o===1],m=t instanceof Array?t[0]:c?t:t*o,b=t instanceof Array?t[1]:u?t:t/o;r.height=b,r.width=m,a.drawImage(i,0,0,m,b),s(r.toDataURL())},{once:!0}),e instanceof File){const r=new FileReader;r.addEventListener("load",()=>i.src=r.result),r.readAsDataURL(e)}else i.src=e})}alt(e){return $.fluent(this,arguments,()=>this.dom.alt,()=>$.set(this.dom,"alt",e))}crossOrigin(e){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",e))}decoding(e){return $.fluent(this,arguments,()=>this.dom.decoding,()=>$.set(this.dom,"decoding",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}isMap(e){return $.fluent(this,arguments,()=>this.dom.isMap,()=>$.set(this.dom,"isMap",e))}loading(e){return $.fluent(this,arguments,()=>this.dom.loading,()=>$.set(this.dom,"loading",e))}referrerPolicy(e){return $.fluent(this,arguments,()=>this.dom.referrerPolicy,()=>$.set(this.dom,"referrerPolicy",e))}sizes(e){return $.fluent(this,arguments,()=>this.dom.sizes,()=>$.set(this.dom,"sizes",e))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}srcset(e){return $.fluent(this,arguments,()=>this.dom.srcset,()=>$.set(this.dom,"srcset",e))}useMap(e){return $.fluent(this,arguments,()=>this.dom.useMap,()=>$.set(this.dom,"useMap",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}decode(){return this.dom.decode()}get complete(){return this.dom.complete}get currentSrc(){return this.dom.currentSrc}get naturalHeight(){return this.dom.naturalHeight}get naturalWidth(){return this.dom.naturalWidth}get x(){return this.dom.x}get y(){return this.dom.y}}class qt extends f{constructor(e){super("canvas",e)}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>{$.set(this.dom,"height",e)})}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>{$.set(this.dom,"width",e)})}captureStream(e){return this.dom.captureStream(e)}getContext(e,t){return this.dom.getContext(e)}toBlob(e,t,s){return this.dom.toBlob(e,t,s),this}toDataURL(e,t){return this.dom.toDataURL(e,t)}transferControlToOffscreen(){return this.dom.transferControlToOffscreen()}}class zt extends f{constructor(e){super("dialog",e)}open(e){return $.fluent(this,arguments,()=>this.dom.open,()=>$.set(this.dom,"open",e))}returnValue(e){return $.fluent(this,arguments,()=>this.dom.returnValue,()=>$.set(this.dom,"returnValue",e))}close(){return this.dom.close(),this}show(){return this.dom.show(),this}showModal(){return this.dom.showModal(),this}}class _t extends f{constructor(e){super("select")}add(e){return this.insert(e),this}item(e){return $(this.dom.item(e))}namedItem(e){return $(this.dom.namedItem(e))}multiple(e){return $.fluent(this,arguments,()=>this.dom.multiple,()=>$.set(this.dom,"multiple",e))}get length(){return this.dom.length}get size(){return this.dom.size}get options(){return Array.from(this.dom.options).map(e=>$(e))}get selectedIndex(){return this.dom.selectedIndex}get selectedOptions(){return Array.from(this.dom.selectedOptions).map(e=>$(e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e,t=>{this.on("input",()=>{t.attributes.has(this.dom)!==!1&&(typeof t.value=="string"&&t.set(`${this.value()}`),typeof t.value=="number"&&t.set(Number(this.value())))})}))}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}I.mixin(_t,A.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","validationMessage","validity","willValidate"));class Tt extends f{constructor(e){super("option",e)}defaultSelected(e){return $.fluent(this,arguments,()=>this.dom.defaultSelected,()=>$.set(this.dom,"defaultSelected",e))}selected(e){return $.fluent(this,arguments,()=>this.dom.selected,()=>$.set(this.dom,"selected",e))}text(e){return $.fluent(this,arguments,()=>this.dom.text,()=>$.set(this.dom,"text",e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e))}get form(){return this.dom.form?$(this.dom.form):null}get index(){return this.dom.index}}I.mixin(Tt,A.create("form","disabled","label"));class St extends f{constructor(e){super("optgroup",e)}disabled(e){return $.fluent(this,arguments,()=>this.dom.disabled,()=>$.set(this.dom,"disabled",e))}}I.mixin(St,A.create("disabled","label"));class It extends f{constructor(e){super("textarea",e)}cols(e){return $.fluent(this,arguments,()=>this.dom.cols,()=>$.set(this.dom,"cols",e))}wrap(e){return $.fluent(this,arguments,()=>this.dom.wrap,()=>$.set(this.dom,"wrap",e))}value(e){return $.fluent(this,arguments,()=>this.dom.value,()=>$.set(this.dom,"value",e))}defaultValue(e){return $.fluent(this,arguments,()=>this.dom.defaultValue,()=>$.set(this.dom,"defaultValue",e))}dirName(e){return $.fluent(this,arguments,()=>this.dom.dirName,()=>$.set(this.dom,"dirName",e))}placeholder(e){return $.fluent(this,arguments,()=>this.dom.placeholder,()=>$.set(this.dom,"placeholder",e))}readOnly(e){return $.fluent(this,arguments,()=>this.dom.readOnly,()=>$.set(this.dom,"readOnly",e))}selectionDirection(e){return $.fluent(this,arguments,()=>this.dom.selectionDirection,()=>$.set(this.dom,"selectionDirection",e))}selectionEnd(e){return $.fluent(this,arguments,()=>this.dom.selectionEnd,()=>$.set(this.dom,"selectionEnd",e))}selectionStart(e){return $.fluent(this,arguments,()=>this.dom.selectionStart,()=>$.set(this.dom,"selectionStart",e))}type(e){return $.fluent(this,arguments,()=>this.dom.type,()=>$.set(this.dom,"type",e))}inputMode(e){return $.fluent(this,arguments,()=>this.dom.inputMode,()=>$.set(this.dom,"inputMode",e))}select(){return this.dom.select(),this}setCustomValidity(e){return this.dom.setCustomValidity(e),this}setRangeText(e,t,s,i){return typeof t=="number"&&typeof s=="number"&&this.dom.setRangeText(e,t,s,i),this.dom.setRangeText(e),this}setSelectionRange(e,t,s){return this.dom.setSelectionRange(e,t,s),this}get labels(){return Array.from(this.dom.labels??[]).map(e=>$(e))}}I.mixin(It,A.create("checkValidity","reportValidity","autocomplete","name","form","required","disabled","minLength","maxLength","validationMessage","validity","willValidate"));var et;class Ot extends f{constructor(t){super("async",t);K(this,et,!1)}await(t){return t instanceof Function?t(this).then(s=>this._loaded(s)):t.then(s=>this._loaded(s)),this}_loaded(t){if(J(this,et,!0),typeof t=="string")this.replace(new X(t));else if(t instanceof S){const s=new X(t.toString());t.use(s,"content"),this.replace(s)}else t==null?this.replace(new X(String(t))):this.replace(t);this.dom.dispatchEvent(new Event("load"))}get loaded(){return x(this,et)}}et=new WeakMap;const Xt=Object.freeze(Object.defineProperty({__proto__:null,$Async:Ot},Symbol.toStringTag,{value:"Module"}));class Bt extends C{constructor(e,t){super(e,t)}autoplay(e){return $.fluent(this,arguments,()=>this.dom.autoplay,()=>$.set(this.dom,"autoplay",e))}get buffered(){return this.dom.buffered}controls(e){return $.fluent(this,arguments,()=>this.dom.controls,()=>$.set(this.dom,"controls",e))}crossOrigin(e){return $.fluent(this,arguments,()=>this.dom.crossOrigin,()=>$.set(this.dom,"crossOrigin",e))}get currentSrc(){return this.dom.currentSrc}currentTime(e){return $.fluent(this,arguments,()=>this.dom.currentTime,()=>$.set(this.dom,"currentTime",e))}defaultMuted(e){return $.fluent(this,arguments,()=>this.dom.defaultMuted,()=>$.set(this.dom,"defaultMuted",e))}defaultPlaybackRate(e){return $.fluent(this,arguments,()=>this.dom.defaultPlaybackRate,()=>$.set(this.dom,"defaultPlaybackRate",e))}disableRemotePlayback(e){return $.fluent(this,arguments,()=>this.dom.disableRemotePlayback,()=>$.set(this.dom,"disableRemotePlayback",e))}get duration(){return this.dom.duration}get ended(){return this.dom.ended}get error(){return this.dom.error}loop(e){return $.fluent(this,arguments,()=>this.dom.loop,()=>$.set(this.dom,"loop",e))}mediaKeys(e){return $.fluent(this,arguments,()=>this.dom.mediaKeys,()=>$.set(this.dom,"setMediaKeys",[e]))}muted(e){return $.fluent(this,arguments,()=>this.dom.muted,()=>$.set(this.dom,"muted",e))}get networkState(){return this.dom.networkState}get paused(){return this.dom.paused}playbackRate(e){return $.fluent(this,arguments,()=>this.dom.playbackRate,()=>$.set(this.dom,"playbackRate",e))}get played(){return this.dom.played}preload(e){return $.fluent(this,arguments,()=>this.dom.preload,()=>$.set(this.dom,"preload",e))}preservesPitch(e){return $.fluent(this,arguments,()=>this.dom.preservesPitch,()=>$.set(this.dom,"preservesPitch",e))}get readyState(){return this.dom.readyState}get remote(){return this.dom.remote}get seekable(){return this.dom.seekable}get seeking(){return this.dom.seeking}sinkId(e){return $.fluent(this,arguments,()=>this.dom.sinkId,()=>$.set(this.dom,"setSinkId",[e]))}src(e){return $.fluent(this,arguments,()=>this.dom.src,()=>$.set(this.dom,"src",e))}srcObject(e){return $.fluent(this,arguments,()=>this.dom.srcObject,()=>$.set(this.dom,"srcObject",e))}get textTracks(){return this.dom.textTracks}volume(e){return $.fluent(this,arguments,()=>this.dom.volume,()=>$.set(this.dom,"volume",e))}addTextTrack(e,t,s){return this.dom.addTextTrack(e,t,s)}canPlayType(e){return this.dom.canPlayType(e)}fastSeek(e){return this.dom.fastSeek(e),this}load(){return this.dom.load(),this}pause(){return this.dom.pause(),this}async play(){return await this.dom.play(),this}get isPlaying(){return this.currentTime()>0&&!this.paused&&!this.ended&&this.readyState>2}}class Kt extends Bt{constructor(e){super("video",e)}disablePictureInPicture(e){return $.fluent(this,arguments,()=>this.dom.disablePictureInPicture,()=>$.set(this.dom,"disablePictureInPicture",e))}height(e){return $.fluent(this,arguments,()=>this.dom.height,()=>$.set(this.dom,"height",e))}width(e){return $.fluent(this,arguments,()=>this.dom.width,()=>$.set(this.dom,"width",e))}playsInline(e){return $.fluent(this,arguments,()=>this.dom.playsInline,()=>$.set(this.dom,"playsInline",e))}poster(e){return $.fluent(this,arguments,()=>this.dom.poster,()=>$.set(this.dom,"poster",e))}get videoHeight(){return this.dom.videoHeight}get videoWidth(){return this.dom.videoWidth}cancelVideoFrameCallback(e){return this.dom.cancelVideoFrameCallback(e),this}getVideoPlaybackQuality(){return this.dom.getVideoPlaybackQuality()}requestPictureInPicture(){return this.dom.requestPictureInPicture()}requestVideoFrameCallback(e){return this.dom.requestVideoFrameCallback(e)}}function w(n){if(typeof n>"u"||n===null||n instanceof G)return n;if(typeof n=="string"){if(n.startsWith("::"))return Array.from(document.querySelectorAll(n.replace(/^::/,""))).map(e=>w(e));if(n.startsWith(":"))return w(document.querySelector(n.replace(/^:/,"")));if(n in w.TagNameElementMap){const e=w.TagNameElementMap[n];return e===Z?new Z(n):e===f?new f(n):new e}else return new f(n)}if(n instanceof Node)return n.$?n.$:I.from(n);throw`$: NOT SUPPORT TARGET ELEMENT TYPE ('${n}')`}(n=>{n.anchorHandler=null,n.TagNameElementMap={html:f,head:f,document:Q,body:f,a:Vt,p:f,pre:f,code:f,blockquote:f,strong:f,h1:f,h2:f,h3:f,h4:f,h5:f,h6:f,div:f,ol:f,ul:f,dl:f,li:f,input:D,label:bt,button:lt,form:wt,img:Gt,dialog:zt,canvas:qt,select:_t,option:Tt,optgroup:St,textarea:It,video:Kt,async:Ot};function e(l,p,v,T){return p.length?(T(),l):v()}n.fluent=e;function t(l){return l instanceof Array?l:[l]}n.orArrayResolve=t;function s(l,p){return I.mixin(l,p)}n.mixin=s;function i(l,p,v,T){if(v!==void 0){if(v instanceof S){v.use(l,p),l[p]instanceof Function?l[p](...v.value):l[p]=v.value,T&&T(v);return}l[p]instanceof Function?l[p](...v):l[p]=v}}n.set=i;function r(l,p){return new S(l,p)}n.state=r;async function a(l,p){return new Promise(v=>{const T=new FileReader;T.onload=O=>{const _=n("img");if(_.once("load",R=>{const j=n("canvas"),U=j.getContext("2d"),N=_.height()/_.width(),[M,q]=[N>1?p/N:p,N>1?p:p*N];j.height(q).width(M),U==null||U.drawImage(_.dom,0,0,M,q),v(j.toDataURL(l.type))}),!O.target)throw"$.resize(): e.target is null";_.src(O.target.result)},T.readAsDataURL(l)})}n.resize=a;function o(l=1){return parseInt(getComputedStyle(document.documentElement).fontSize)*l}n.rem=o;function u(l){const p=new DOMParser().parseFromString(l,"text/html").body;return Array.from(p.children).map(v=>n(v))}n.html=u;function c(l,p,v){if(typeof p=="number")return Array(p).fill("").map(O=>{const _=T(l)?l[0](...l.slice(1)):n(l);return v&&v(_),_});{const O=[];for(const _ of p){const R=l instanceof Function?l(..._):T(l)?l[0](...l.slice(1)):n(l);_ instanceof Function?_(R):(_ instanceof G||typeof _=="string")&&R.content(_),O.push(R)}return O}function T(O){return O instanceof Array&&O[0]instanceof Function}}n.builder=c;function d(l,p){return Object.assign(n.TagNameElementMap,{[l]:p}),n.TagNameElementMap}n.registerTagName=d;function m(...l){return new st}n.events=m;function b(l){return l()}n.call=b})(w||(w={}));globalThis.$=w;class st{constructor(){h(this,"eventMap",new Map)}fire(e,...t){var s;return(s=this.eventMap.get(e))==null||s.forEach(i=>i(...t)),this}on(e,t){const s=this.eventMap.get(e)??this.eventMap.set(e,new Set).get(e);return s==null||s.add(t),this}off(e,t){var s;return(s=this.eventMap.get(e))==null||s.delete(t),this}once(e,t){const s=(...r)=>{var a;(a=this.eventMap.get(e))==null||a.delete(s),t(...r)},i=this.eventMap.get(e)??this.eventMap.set(e,new Set).get(e);return i==null||i.add(s),this}}Array.prototype.detype=function(...n){return this.filter(e=>{if(n.length)for(const t of n)return typeof e!=typeof t;else return e!==void 0})};Object.defineProperties(Set.prototype,{array:{get:function(){return Array.from(this)}}});Set.prototype.sort=function(n){return this.array.sort(n)};class xt extends f{constructor(t){super("layout",t);h(this,"_property",{ROW_MAX_HEIGHT:200,GAP:0,IS_RENDERING:!1,RENDER_REQUEST:!1,COLUNM:1,TYPE:"justified",ROOT:null,ITEM_PROPERTIES:new Map});this.css({display:"block",position:"relative"}),new ResizeObserver(s=>{this.inDOM()&&(this.render(),this.dom.dispatchEvent(new Event("resize")))}).observe(this.dom),document.addEventListener("scroll",s=>{s.target===this.root().dom&&this.scrollCompute()},{passive:!0}),new IntersectionObserver(s=>{this.inDOM()&&this.render()}).observe(this.dom)}type(t){return $.fluent(this,arguments,()=>this._property.TYPE,()=>$.set(this._property,"TYPE",t))}maxHeight(t){return $.fluent(this,arguments,()=>this._property.ROW_MAX_HEIGHT,()=>$.set(this._property,"ROW_MAX_HEIGHT",t))}column(t){return $.fluent(this,arguments,()=>this._property.COLUNM,()=>$.set(this._property,"COLUNM",t))}gap(t){return $.fluent(this,arguments,()=>this._property.GAP,()=>$.set(this._property,"GAP",t))}root(t){return $.fluent(this,arguments,()=>this._property.ROOT??$(document),()=>$.set(this._property,"ROOT",t))}get COL_WIDTH(){return(this.offsetWidth-this._property.GAP*(this._property.COLUNM-1))/this._property.COLUNM}justifiedCompute(){const t=[],s=this.offsetWidth;for(const i of this.children.array){const r=$(i);if(!(r instanceof C))continue;const a=r.attribute("layout-item-ratio"),o=a?parseFloat(a):r.dom.offsetWidth/r.dom.offsetHeight,u={$node:r,ratio:o};let c=t.at(-1);(!c||c.heightd+=l.ratio);const m=d+o,b=(s-this._property.GAP*c.items.length)/m;c.items.push(u),c.ratio=m,c.height=b}return t}waterfallCompute(){const t=[],s=this.COL_WIDTH,i=()=>{if(t.lengthr.height-a.height)[0]};for(const r of this.children.array){const a=$(r);if(!(a instanceof C))continue;const o=a.attribute("layout-item-ratio"),u=o?parseFloat(o):a.dom.offsetWidth/a.dom.offsetHeight,c={$node:a,ratio:u},d=i();let m=0;d.items.forEach(p=>m+=p.ratio);const b=s/(d.height+s/u),l=s/b;d.items.push(c),d.ratio=b,d.height=l}return t}render(){if(!this.inDOM())return this;if(this._property.ITEM_PROPERTIES.clear(),this._property.TYPE==="justified"){const t=this.justifiedCompute();let s=0;for(const i of t){let r=0;i.height>this._property.ROW_MAX_HEIGHT&&(i.height=this._property.ROW_MAX_HEIGHT);for(const a of i.items){const o=a.ratio*i.height;a.$node.css({position:"absolute",height:`${i.height}px`,width:`${o}px`,top:`${s}px`,left:`${r}px`}),a.$node.attribute("layout-item-ratio",a.ratio),this._property.ITEM_PROPERTIES.set(a.$node,{height:i.height,width:o,top:s,left:r,ratio:a.ratio,$node:a.$node}),r+=i.height*a.ratio+this._property.GAP}s+=i.height+this._property.GAP}this.css({height:`${s}px`})}else if(this._property.TYPE="waterfall"){const t=this.waterfallCompute(),s=this.COL_WIDTH;let i=0;for(const r of t){let a=0;for(const o of r.items){const u=s/o.ratio;o.$node.css({position:"absolute",height:`${u}px`,width:`${s}px`,top:`${a}px`,left:`${i}px`}),o.$node.attribute("layout-item-ratio",o.ratio),this._property.ITEM_PROPERTIES.set(o.$node,{height:u,width:s,top:a,left:i,ratio:o.ratio,$node:o.$node}),a+=u+this._property.GAP}i+=s+this._property.GAP}if(t.length){const r=t.sort((a,o)=>o.height-a.height)[0];this.css({height:`${r.height+r.items.length*this._property.GAP}px`})}else this.css({height:""})}return this.scrollCompute(),this}scrollCompute(){if(this.inDOM()===!1)return;const t=document.documentElement.scrollTop-this.dom.offsetTop;this._property.ITEM_PROPERTIES.forEach((s,i)=>{const r=s.top;s.top+s.height>t&&r{this.contentId=t,this.events.fire("rendered",{$view:this,previousContent:i,nextContent:s})},o=()=>{this.events.fire("afterSwitch",{$view:this,previousId:t})};return this.events.fire("beforeSwitch",{$view:this,preventDefault:()=>r=!0,targetId:t,previousContent:i,nextContent:s,switched:o,rendered:a}),r||(this.content(s),a(),o()),this}get currentContent(){if(this.contentId)return this.viewCache.get(this.contentId)}}$.registerTagName("view",Et);var H;const g=class g extends Et{constructor(t){super({tagname:"router",...t});K(this,H,"");h(this,"routes",new Map);g.routers.add(this)}base(t){return $.fluent(this,arguments,()=>x(this,H),()=>{J(this,H,t??x(this,H))})}map(t){t=$.orArrayResolve(t);for(const s of t)s instanceof Array?this.map(s):this.routes.set(s.path(),s);return this.resolve(),this}resolve(){return new Promise(t=>{if(!location.pathname.startsWith(x(this,H)))return t(2);const s=location.pathname.replace(x(this,H),"/").replace("//","/"),i=s.split("/").map(p=>`/${p}`),r=location.search,a=new Map(r.replace("?","").split("&").map(p=>p.split("="))),u=(()=>{const p=[];for(const[v,T]of this.routes){const O=$.orArrayResolve(v);for(const _ of O){let R=0,j={},U={};const N=_.split("/").map(M=>`/${M}`);if(!(i.lengthObject.assign(U,{[pt]:a.get(pt)})),q.startsWith("/:")){R++,Object.assign(j,{[q.replace("/:","")]:i[M].replace("/","")});continue}else if(_.startsWith("#")&&_===location.hash){R++;continue}else if(q===i[M]){R++;continue}else break}p.push({deep:R,$route:T,params:j,query:U,pathId:Object.keys(U).length!==0?s+r:Object.keys(j).length!==0?s:O[0]})}}}return p.sort((v,T)=>T.deep-v.deep).at(0)})();if(!u)return t(1);const{$route:c,params:d,pathId:m,query:b}=u;if(m===this.contentId)return t(0);this.events.once("rendered",({nextContent:p,previousContent:v})=>{v==null||v.events.fire("afterShift",{$route:v}),p.events.fire("rendered",{$route:p}),t(0)});const l=this.viewCache.get(m)??c.build({params:d,query:b});this.viewCache.has(m)||this.setView(m,l),this.events.once("beforeSwitch",()=>{var p;l.events.fire("beforeShift",{$route:l}),(p=this.currentContent)==null||p.events.fire("beforeShift",{$route:this.currentContent})}),this.events.once("afterSwitch",()=>l.events.fire("afterShift",{$route:l})),this.switchView(m)})}static init(){if(!history.state||!("index"in history.state)){const t={index:g.historyIndex};history.replaceState(t,"")}else g.historyIndex=history.state.index;return g.navigationDirection=0,g.resolve(),window.addEventListener("popstate",()=>g.popstate()),window.addEventListener("scroll",()=>{this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)},{passive:!0}),history.scrollRestoration="manual",this}static open(t,s){return t===void 0?this:(t=this.urlResolver(t),t.href===this.url.href?this:t.origin!==this.url.origin?(window.open(t,s),this):(g.clearForwardScrollHistory(),g.historyIndex++,history.pushState(g.historyState,"",t),g.stateChange(0),g.resolve(),this))}static back(){return this.historyIndex--,history.back(),this}static replace(t){return t===void 0?this:(t=this.urlResolver(t),history.replaceState(g.historyState,"",t),this.stateChange(2),this.setScrollHistory(this.historyIndex,location.href,0),g.resolve(),this)}static urlResolver(t){return t instanceof URL?t:(t.startsWith("/")&&(t=`${location.origin}${t}`),t.startsWith("#")&&(t=`${location.origin}${location.pathname}${t}`),new URL(t))}static popstate(){const t=history.state.index>g.historyIndex?0:history.state.indext.resolve())),this.scrollRestoration(),this.setScrollHistory(this.historyIndex,location.href,document.documentElement.scrollTop)}static get historyState(){return{index:g.historyIndex}}static stateChange(t){const s=this.url,i=new URL(location.href);this.url=i,g.events.fire("stateChange",{beforeURL:s,afterURL:i,direction:t}),g.navigationDirection=t}static setScrollHistory(t,s,i){const r=this.getScrollHistory();if(!r)return sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify({[t]:{url:s,value:i}}));r[t]={url:s,value:i},sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(r))}static getScrollHistory(){const t=sessionStorage.getItem(this.scrollHistoryKey);if(t)return JSON.parse(t)}static clearForwardScrollHistory(){const t=this.getScrollHistory();if(t)for(const s in t)Number(s)>this.historyIndex&&delete t[s],sessionStorage.setItem(this.scrollHistoryKey,JSON.stringify(t))}static scrollRestoration(){const t=this.getScrollHistory();if(t&&t[this.historyIndex])document.documentElement.scrollTop=t[this.historyIndex].value??0;else if(location.hash.length){const s=$(document.body).$(location.hash);s&&(document.documentElement.scrollTop=s.dom.offsetTop)}else document.documentElement.scrollTop=0}};H=new WeakMap,h(g,"routers",new Set),h(g,"events",new st),h(g,"navigationDirection"),h(g,"historyIndex",0),h(g,"url",new URL(location.href)),h(g,"scrollHistoryKey","$ROUTER_SCROLL_HISTORY");let L=g;var F=(n=>(n[n.Forward=0]="Forward",n[n.Back=1]="Back",n[n.Replace=2]="Replace",n))(F||{});L.init();var B,V;const mt=class mt extends f{constructor(t){super("route",t);K(this,B,"");K(this,V);h(this,"rendered",!1)}path(t){return $.fluent(this,arguments,()=>x(this,B),()=>J(this,B,t??x(this,B)))}builder(t){return J(this,V,t),this}render(t){return x(this,V)&&this.content(x(this,V).call(this,{$route:this,params:t.params,query:t.query})),this.rendered=!0,this}build(t){return new mt({dom:this.dom.cloneNode()}).self(s=>{x(this,V)&&s.builder(x(this,V)).render({params:t.params,query:t.query})})}};B=new WeakMap,V=new WeakMap;let ct=mt;$.registerTagName("router",L);$.registerTagName("route",ct);Object.assign($,{open(n,e){return L.open(n,e)},replace(n){return L.replace(n)},back(){return L.back()}});class z{constructor(e,t,s=!0){h(this,"name$",$.state("..."));h(this,"post_upload_count$",$.state(0));h(this,"level$",$.state(10));h(this,"level_string$",$.state("..."));h(this,"booru");this.booru=e,Object.assign(this,t),s&&this.update$()}static async fetch(e,t){var r;const s=await fetch(`${e.origin}/users/${t}.json`).then(async a=>await a.json()),i=((r=this.manager.get(s.id))==null?void 0:r.update(s))??new this(e,s);return this.manager.set(i.id,i),i}static async fetchMultiple(e,t,s=200){let i="";if(t)for(const[u,c]of Object.entries(t))if(c instanceof Array)i+=`&search[${u}]=${c}`;else if(c instanceof Object)for(const[d,m]of Object.entries(c))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${c}`;return(await(await fetch(`${e.origin}/users.json?limit=${s}${i}`)).json()).map(u=>{const c=new this(e,u);return this.manager.set(c.id,c),c})}update(e){return Object.assign(this,e),this.update$(),this}update$(){this.name$.set(this.name),this.post_upload_count$.set(this.post_upload_count),this.level$.set(this.level),this.level_string$.set(this.level_string)}get booruURL(){return`${this.booru.origin}/users/${this.id}`}get url(){return`/users/${this.id}`}}h(z,"manager",new Map);class nt extends z{constructor(t,s,i){super(t,i,!1);h(this,"apiKey");h(this,"favorite_count$",$.state(0));h(this,"forum_post_count$",$.state(0));this.apiKey=s,this.update$()}update$(){var t,s;super.update$(),(t=this.forum_post_count$)==null||t.set(this.forum_post_count),(s=this.favorite_count$)==null||s.set(this.favorite_count)}static get storageUserData(){const t=localStorage.getItem("user_data");return t?JSON.parse(t):null}static set storageUserData(t){localStorage.setItem("user_data",JSON.stringify(t))}}const k=class k{constructor(e){h(this,"user");h(this,"posts",new Map);h(this,"tags",new Map);Object.assign(this,e),this.origin.endsWith("/")&&(this.origin=this.origin.slice(0,-1)),k.manager.set(this.name,this)}static set(e){this.used=e,this.name$.set(e.name),this.storageAPI=e.name;const t=nt.storageUserData;return t&&e.login(t.username,t.apiKey),this.events.fire("set"),this}static get storageAPI(){return localStorage.getItem("booru_api")}static set storageAPI(e){e?localStorage.setItem("booru_api",e):localStorage.removeItem("booru_api")}async fetch(e){const t=await fetch(`${this.origin}${e}`).then(s=>s.json());if(t.success===!1)throw t.message;return t}async login(e,t){const s=await this.fetch(`/profile.json?login=${e}&api_key=${t}`);return this.user=new nt(this,t,s),k.events.fire("login",this.user),this.user}logout(){return this.user=void 0,nt.storageUserData=null,k.events.fire("logout"),this}};h(k,"used"),h(k,"events",new st),h(k,"name$",$.state(k.name)),h(k,"manager",new Map);let y=k;class Jt{constructor(e,t){h(this,"post_count$",$.state(0));h(this,"name$",$.state(""));h(this,"booru");this.booru=e,Object.assign(this,t),this.$update()}static async fetch(e,t){var r;const s=await fetch(`${e.origin}/tags/${t}.json`).then(async a=>await a.json()),i=((r=e.tags.get(s.id))==null?void 0:r.update(s))??new this(e,s);return e.tags.set(i.id,i),i}static async fetchMultiple(e,t,s=1e3){let i="";if(t)for(const[u,c]of Object.entries(t))if(c instanceof Array)i+=`&search[${u}]=${c}`;else if(c instanceof Object)for(const[d,m]of Object.entries(c))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${c}`;return(await(await fetch(`${e.origin}/tags.json?limit=${s}${i}`)).json()).map(u=>{var d;const c=((d=e.tags.get(u.id))==null?void 0:d.update(u))??new this(e,u);return e.tags.set(c.id,c),c})}update(e){return Object.assign(this,e),this.$update(),this}$update(){this.post_count$.set(this.post_count),this.name$.set(this.name)}}var W=(n=>(n[n.General=0]="General",n[n.Artist=1]="Artist",n[n.Copyright=3]="Copyright",n[n.Character=4]="Character",n[n.Meta=5]="Meta",n))(W||{});const dt=1e3,rt=dt*60,ot=rt*60,at=ot*24,Yt=at*7,it=new Intl.RelativeTimeFormat("en",{style:"long"});function Qt(n){n=Math.floor(n);const e=n/dt,t=n/rt,s=n/ot,i=n/at,r=n%1e3,a=Math.floor(n%6e4/1e3),o=Math.floor(n%36e5/6e4),u=Math.floor(n%(36e5*24)/36e5),c=a.toString().padStart(2,"0"),d=o.toString().padStart(2,"0"),m=u.toString().padStart(2,"0");return{seconds:e,minutes:t,hours:s,days:i,mil:r,s:a,min:o,h:u,ss:c,mm:d,hh:m}}function Zt(n,e=Date.now()){const t=n-e,s=Math.abs(t);if(sawait s.json());return this.update(t),z.fetchMultiple(this.booru,{id:[this.uploader_id,this.approver_id].detype(null)}).then(()=>this.update$()),this}static async fetchMultiple(t,s,i=20){let r="";if(s){if(typeof s=="string")r=s;else for(const[d,m]of Object.entries(s))if(m!==void 0){if(d==="tags"){r+=`${m}`;continue}r.at(-1)!=="="&&(r+=" "),r+=`${d}:${m}`}}const o=await(await fetch(`${t.origin}/posts.json?limit=${i}&tags=${r}&_method=get`)).json();if(!(o instanceof Array))return[];const u=o.map(d=>{var b;const m=((b=t.posts.get(d.id))==null?void 0:b.update(d))??new this(t,d.id,d);return t.posts.set(m.id,m),m});if(!u.length)return u;const c=[...new Set(o.map(d=>[d.approver_id,d.uploader_id].detype(null)).flat())];return z.fetchMultiple(t,{id:c}).then(()=>u.forEach(d=>d.update$())),u}update$(){var t,s,i,r;this.uploader$.set(((t=this.uploader)==null?void 0:t.name$)??((s=this.uploader_id)==null?void 0:s.toString())),this.approver$.set(((i=this.approver)==null?void 0:i.name$)??((r=this.approver_id)==null?void 0:r.toString())??"None"),this.created_date$.set(Zt(+new Date(this.created_at))),this.favorites$.set(this.fav_count),this.score$.set(this.score),this.file_size$.set(te(this.file_size)),this.file_ext$.set(this.file_ext),this.file_url$.set(this.file_url),this.source$.set(this.source),this.dimension$.set(`${this.image_width}x${this.image_height}`),this.url$.set(`${this.url}`),this.isUgoria&&this.webm_url$.set(this.large_file_url),this.createdDate=new Date(this.created_at),this.fire("update")}update(t){return Object.assign(this,t),this.update$(),this}async fetchTags(){return await this.ready,await Jt.fetchMultiple(this.booru,{name:{_space:this.tag_string}})}get pathname(){return`/posts/${this.id}`}get uploader(){return z.manager.get(this.uploader_id)}get approver(){return this.approver_id?z.manager.get(this.approver_id):null}get isVideo(){return this.file_ext==="mp4"||this.file_ext==="webm"||this.file_ext==="zip"}get isGif(){return this.file_ext==="gif"}get isUgoria(){return this.file_ext==="zip"}get hasSound(){return this.tag_string_meta.includes("sound")}get tags(){const t=this.tag_string.split(" ");return[...this.booru.tags.values()].filter(s=>t.includes(s.name))}get previewURL(){var t,s;return((s=(t=this.media_asset.variants)==null?void 0:t.find(i=>i.file_ext==="webp"))==null?void 0:s.url)??this.large_file_url}get url(){return`${this.booru.origin}/posts/${this.id}`}get isFileSource(){return this.source.startsWith("file://")}}class Lt{constructor(e){Object.assign(this,e)}static async fetch(e,t){const s=await fetch(`${e.origin}/artist_commentaries/${t}.json`);return new this(await s.json())}static async fetchMultiple(e,t,s=200){let i="";if(t)for(const[u,c]of Object.entries(t))if(c instanceof Array)i+=`&search[${u}]=${c}`;else if(c instanceof Object)for(const[d,m]of Object.entries(c))i+=`&search[${u}${d}]=${m}`;else i+=`&search[${u}]=${c}`;return(await(await fetch(`${e.origin}/artist_commentaries.json?limit=${s}${i}`)).json()).map(u=>{const c=new this(u);return this.manager.set(c.id,c),c})}}h(Lt,"manager",new Map);const ee=new Intl.NumberFormat("en",{notation:"compact"});function Y(n){return ee.format(n)}const se=$("route").path("/posts/:id").id("post").builder(({$route:n,params:e})=>{if(!Number(e.id))return $("h1").content("404: POST NOT FOUND");const t=tt.get(y.used,+e.id);return[$("div").class("viewer").content(async()=>(await t.ready,t.isVideo?$("video").height(t.image_height).width(t.image_width).src(t.file_ext==="zip"?t.large_file_url:t.file_url).controls(!0).autoplay(!0).loop(!0).disablePictureInPicture(!0):$("img").src(t.large_file_url))),$("div").class("content").content([$("h3").content("Artist's Commentary"),$("section").class("commentary").content(async s=>{const i=(await Lt.fetchMultiple(y.used,{post:{_id:t.id}})).at(0);return[i?[i.original_title?$("h3").content(i.original_title):null,$("pre").content(i.original_description)]:"No commentary"]})]),$("div").class("sidebar").self(s=>{let i=0;addEventListener("scroll",()=>{s.inDOM()&&(i=document.documentElement.scrollTop)},{passive:!0}),n.on("beforeShift",()=>{innerWidth>800&&s.css({position:"absolute",top:`calc(${i}px + var(--nav-height) + var(--padding))`})}).on("afterShift",()=>s.css({position:"",top:""}))}).content([$("section").class("post-info").content([new E("id").name("Post").content(`#${e.id}`),new E("uploader").name("Uploader").content(t.uploader$),new E("approver").name("Approver").content(t.approver$),new E("date").name("Date").content(t.created_date$),new E("size").name("Size").content([t.file_size$,t.dimension$]),new E("file-type").name("File Type").content(t.file_ext$),$("div").class("inline").content([new E("favorites").name("Favorites").content(t.favorites$),new E("score").name("Score").content(t.score$)]),new E("file-url").name("File").content([$("a").href(t.file_url$).content(t.file_url$.convert(s=>s.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(s,i)=>ht(i,t.source))]),new E("source-url").name("Source").content([$("a").href(t.source$).content(t.source$.convert(s=>s.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(s,i)=>ht(i,t.source))]),new E("booru-url").name(y.name$).content([$("a").href(t.url$).content(t.url$.convert(s=>s.replace("https://",""))).target("_blank"),$("ion-icon").name("clipboard").on("click",(s,i)=>ht(i,t.source))]),new E("booru-url").name("Webm").hide(!0).self(async s=>{await t.ready,t.isUgoria&&s.content($("a").href(t.webm_url$).content(t.webm_url$.convert(i=>i.replace("https://",""))).target("_blank")).hide(!1)})]),$("div").class("post-tags").content(async s=>{const i=await t.fetchTags(),[r,a,o,u,c]=[i.filter(m=>m.category===W.Artist),i.filter(m=>m.category===W.Character),i.filter(m=>m.category===W.General),i.filter(m=>m.category===W.Meta),i.filter(m=>m.category===W.Copyright)];return[d("Artist",r),d("Character",a),d("Copyright",c),d("Meta",u),d("General",o)];function d(m,b){return b.length?[$("h3").content(m),$("section").content([b.map(l=>$("div").class("tag").content([$("a").class("tag-name").content(l.name).href(`/posts?tags=${l.name}`),$("span").class("tag-post-count").content(l.post_count$.convert(Y))]))])]:null}})])]});function ht(n,e){n.name("checkmark"),navigator.clipboard.writeText(e),setTimeout(()=>n.name("clipboard"),3e3)}class E extends f{constructor(t){super("div");h(this,"$name",$("span").class("property-name"));h(this,"$values",$("div").class("property-values"));this.staticClass("property").attribute("property-id",t),super.content([this.$name,this.$values.hide(!0)])}name(t){return this.$name.content(t),this}content(t){this.$values.hide(!1);const s=$.orArrayResolve(t);return this.$values.content(s.map(i=>$("span").staticClass("property-value").content(i))),this}}class ie extends f{constructor(t){super("post-tile");h(this,"post");h(this,"$video");h(this,"duration$",$.state(""));this.post=t,this.$video=this.post.isVideo?$("video").width(this.post.image_width).height(this.post.image_height).disablePictureInPicture(!0).loop(!0).muted(!0).hide(!0).on("mousedown",s=>s.preventDefault()):null,this.attribute("filetype",this.post.file_ext),this.durationUpdate(),this.build()}build(){var s,i;let t;(s=this.$video)==null||s.on("playing",(r,a)=>{t=setInterval(()=>{this.durationUpdate()},500)}),(i=this.$video)==null||i.on("pause",()=>{clearInterval(t),this.durationUpdate()}),this.class("loading").content([this.post.isVideo?$("div").class("video-detail").content([this.post.hasSound?$("ion-icon").name("volume-medium-outline"):null,this.post.isUgoria?$("ion-icon").name("images-outline"):null,$("span").class("duration").content(this.duration$)]):null,this.post.isGif?$("div").class("gif-detail").content([$("span").content("GIF")]):null,$("a").href(this.post.pathname).content(()=>[this.$video,$("img").draggable(!1).css({opacity:"0"}).width(this.post.image_width).height(this.post.image_height).src(this.post.previewURL).loading("lazy").on("mousedown",r=>r.preventDefault()).once("load",(r,a)=>{a.src(this.post.previewURL).on(["mouseenter","touchstart"],()=>{this.post.isGif&&a.src(this.post.large_file_url)},{passive:!0}).on(["mouseleave","touchend","touchcancel"],()=>{this.post.isGif&&a.src(this.post.previewURL)},{passive:!0}).animate({opacity:[0,1]},{duration:300,fill:"both"}),this.removeClass("loading")})]).on(["mouseenter","touchstart"],()=>{var r,a;(r=this.$video)!=null&&r.isPlaying||(a=this.$video)==null||a.src(this.post.large_file_url).hide(!1).play().catch(o=>{})},{passive:!0}).on(["mouseleave","touchend","touchcancel"],()=>{var r;(r=this.$video)==null||r.pause().currentTime(0).hide(!0)},{passive:!0})])}durationUpdate(){if(!this.$video)return;const t=Qt(this.post.media_asset.duration*1e3-this.$video.currentTime()*1e3);this.duration$.set(Number(t.hh)>0?`${t.hh}:${t.mm}:${t.ss}`:`${t.mm}:${t.ss}`)}}class vt extends xt{constructor(t){super();h(this,"posts",new Set);h(this,"$posts",new Set);h(this,"tags");h(this,"finished",!1);this.tags=t==null?void 0:t.tags,this.addStaticClass("post-grid"),this.type("waterfall").gap(10),this.init()}async init(){setInterval(()=>{this.inDOM()&&document.documentElement.scrollTop===0&&this.updateNewest()},1e4),y.events.on("set",()=>{this.removeAll(),this.finished&&(this.finished=!1,this.loader())}),this.on("resize",()=>this.resize()),this.loader()}async loader(){if(!this.inDOM())return setTimeout(()=>this.loader(),100);for(;this.inDOM()&&document.documentElement.scrollHeight<=innerHeight*2;)if(!(await this.getPosts()).length)return this.finished=!0;if(document.documentElement.scrollTop+innerHeight>document.documentElement.scrollHeight-innerHeight*2&&!(await this.getPosts()).length)return this.finished=!0;setTimeout(()=>this.loader(),100)}resize(){const t=Math.round(this.dom.clientWidth/300);this.column(t>=2?t:2)}addPost(t){t=$.orArrayResolve(t);for(const i of t){if(!i.file_url||this.posts.has(i))continue;const r=new ie(i);this.$posts.add(r),this.posts.add(i)}const s=[...this.$posts.values()].sort((i,r)=>+r.post.createdDate-+i.post.createdDate);return this.content(s).render(),this}removeAll(){return this.posts.clear(),this.$posts.clear(),this.animate({opacity:[1,0]},{duration:300,easing:"ease"},()=>this.clear().render()),this}async updateNewest(){const t=this.sortedPosts.at(0),s=await tt.fetchMultiple(y.used,{tags:this.tags,id:t?`>${t.id}`:void 0},100);return this.addPost(s),s}async getPosts(){const t=this.sortedPosts.at(-1),s=await tt.fetchMultiple(y.used,{tags:this.tags,id:t?`<${t.id}`:void 0},100);return this.addPost(s),s}get sortedPosts(){return this.posts.array.sort((t,s)=>+s.createdDate-+t.createdDate)}}class ne{static async fetch(e,t,s=20){return(await fetch(`${e.origin}/autocomplete.json?search[query]=${t}&search[type]=tag_query&version=1&limit=${s}`).then(r=>r.json())).map(r=>new re(r))}}class re{constructor(e){Object.assign(this,e)}isTag(){return this.type==="tag"||this.type==="tag-autocorrect"||this.type==="tag-alias"||this.type==="tag-word"}isTagAutocorrect(){return this.type==="tag-autocorrect"}isTagAntecedent(){return!!this.antecedent}isTagWord(){return this.type==="tag-word"}isUser(){return this.type==="user"}}class oe extends f{constructor(){super("searchbar");h(this,"$tagInput",new ce(this));h(this,"$selectionList",new ae);h(this,"typingTimer",null);h(this,"$filter",$("div").class("filter"));this.build(),window.addEventListener("keyup",t=>{!this.inDOM()&&t.key==="/"&&this.activate(),this.inDOM()&&t.key==="Escape"&&this.inactivate()})}build(){this.content([$("div").class("input-container").content([this.$tagInput.on("input",()=>this.inputHandler()).on("keydown",t=>this.keyHandler(t)),$("ion-icon").name("close-circle-outline").title("Clear Input").on("click",()=>this.$tagInput.clearAll())]).on("click",t=>{t.target===this.$tagInput.dom&&this.$tagInput.addTag().input()}),$("div").class("selection-list-container").content([this.$selectionList]),this.$filter.on("click",()=>{location.hash==="#search"&&$.back()})])}activate(){return this.hide(!1),this.$filter.animate({opacity:[0,.5]},{duration:300,easing:"ease"}),this.$tagInput.input(),this}inactivate(){return this.animate({opacity:[.5,0]},{duration:300,easing:"ease"},()=>this.hide(!0)),this}keyHandler(t){var r,a;const s=()=>{t.preventDefault(),this.$tagInput.addTag().input()},i=o=>{const u=this.$tagInput.children.indexOf(this.$tagInput.$inputor),c=this.$tagInput.children.array.at(u+1);this.$tagInput.addTag(o.value()),c?this.$tagInput.editTag(c):this.$tagInput.input()};switch(t.key){case"ArrowUp":{t.preventDefault(),this.$selectionList.focusPrevSelection(),this.$tagInput.value((r=this.$selectionList.focused)==null?void 0:r.value());break}case"ArrowDown":{t.preventDefault(),this.$selectionList.focusNextSelection(),this.$tagInput.value((a=this.$selectionList.focused)==null?void 0:a.value());break}case" ":s();break;case"Enter":{t.preventDefault(),this.$selectionList.focused?i(this.$selectionList.focused):(this.$tagInput.addTag(),this.search());break}case"Tab":{t.preventDefault();const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);if(t.shiftKey){this.$tagInput.editTag(this.$tagInput.children.array.at(o-1));break}if(this.$selectionList.focused)i(this.$selectionList.focused);else{const u=this.$tagInput.children.array.at(o+1);u?this.$tagInput.editTag(u):this.$tagInput.addTag().input()}break}case"Backspace":{const o=this.$tagInput.children.indexOf(this.$tagInput.$inputor);o!==0&&!this.$tagInput.$input.value().length&&(t.preventDefault(),this.$tagInput.editTag(this.$tagInput.children.array.at(o-1)));break}}}inputHandler(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.typingTimer=setTimeout(async()=>{this.typingTimer=null,this.getSearchSuggestions()},200)}async getSearchSuggestions(){const t=this.$tagInput.$input.value();if(!t.length)return this.$selectionList.clearSelections();const s=await ne.fetch(y.used,t,20);this.$selectionList.clearSelections().addSelections(s.map(i=>new he().value(i.value).content([$("div").class("selection-label").content([i.isTagAntecedent()?$("span").class("tag-antecedent").self(r=>r.dom.innerHTML=i.antecedent.replaceAll(t,`${t}`)):null,$("div").class("label-container").content([i.isTagAntecedent()?$("ion-icon").name("arrow-forward-outline"):null,$("span").class("label").self(r=>r.dom.innerHTML=i.label.replaceAll(t,`${t}`))])]),i.isTag()?$("div").class("tag-detail").content([$("span").class("tag-post-count").content(Y(i.post_count)),$("span").class("tag-category").content(W[i.category])]):null,i.isUser()?$("span").class("user-level").content(i.level):null]).on("click",()=>{this.$tagInput.addTag(i.label).input()}))),this.$tagInput.$input.value().length||this.$selectionList.clearSelections()}search(){return $.replace(`/posts?tags=${this.$tagInput.query.replace(":","%3A")}`),this.$tagInput.clearAll(),this.inactivate(),this}checkURL(t,s){(t==null?void 0:t.hash)==="#search"&&this.inactivate(),s.hash==="#search"&&this.activate()}}class ae extends f{constructor(){super("selection-list");h(this,"focused",null);h(this,"selections",new Set)}addSelections(t){t=$.orArrayResolve(t);for(const s of t)this.selections.add(s);return this.insert(t),this}clearSelections(){return this.focused=null,this.selections.clear(),this.clear(),this}focusSelection(t){return this.blurSelection(),this.focused=t,t.focus(),t.offsetTopthis.scrollTop()+this.offsetHeight&&this.scrollTop(t.offsetTop+t.offsetHeight-this.offsetHeight),this}blurSelection(){var t;return(t=this.focused)==null||t.blur(),this.focused=null,this}focusNextSelection(){const t=this.selections.array,s=t.at(0);if(this.focused){const i=t.at(t.indexOf(this.focused)+1);i?this.focusSelection(i):s&&this.focusSelection(s)}else s&&this.focusSelection(s)}focusPrevSelection(){const t=this.selections.array;if(this.focused){const s=t.at(t.indexOf(this.focused)-1);s&&this.focusSelection(s)}else{const s=t.at(0);s&&this.focusSelection(s)}}}class he extends f{constructor(){super("selection");h(this,"property",{value:""})}value(t){return $.fluent(this,arguments,()=>this.property.value,()=>$.set(this.property,"value",t))}focus(){return this.addClass("active"),this}blur(){return this.removeClass("active"),this}}class ce extends f{constructor(t){super("tag-input");h(this,"$input",$("input").type("text"));h(this,"$sizer",$("span").class("sizer"));h(this,"$inputor",$("div").class("input-wrapper").content([this.$sizer,this.$input.on("input",()=>{this.$sizer.content(this.$input.value())})]));h(this,"tags",new Set);h(this,"$seachbar");this.$seachbar=t}input(){return this.insert(this.$inputor),this.$input.focus(),this.$input.value()?this.$seachbar.getSearchSuggestions():this.$seachbar.$selectionList.clearSelections(),this}addTag(t){if(t=t??this.$input.value(),!t.length)return this;const s=new ue(t);return s.on("click",()=>this.editTag(s)),this.tags.add(s),this.value(""),this.$inputor.replace(s),this}editTag(t){return this.addTag(),this.tags.delete(t),t.replace(this.$inputor),this.value(t.name),this.$input.focus(),this.$seachbar.getSearchSuggestions(),this}clearAll(){return this.value(""),this.tags.clear(),this.clear(),this}value(t){return t===void 0?this:(this.$input.value(t),this.$sizer.content(t),this)}get query(){return this.tags.array.map(t=>t.name).toString().replace(",","+")}}class ue extends f{constructor(t){super("tag");h(this,"name");this.name=t,this.build()}build(){this.content(this.name)}}class le extends f{constructor(){super("ion-icon")}name(e){return this.attribute("name",e),this}size(e){return this.attribute("size",e),this}}class de extends lt{constructor(){super();h(this,"$icon",$("ion-icon"));h(this,"$label",$("span"));this.addStaticClass("icon"),this.build()}build(){super.content([this.$icon.hide(!0),this.$label])}content(t){return this.$label.content(t),this}icon(t){return this.$icon.name(t).hide(!1),this}link(t,s=!1){return this.on("click",()=>s?$.replace(t):$.open(t)),this}}const me=$("route").id("login").path("/login").builder(()=>{const[n,e]=[$.state(""),$.state("")];return[$("div").class("login-container").content([$("h1").content("Login"),$("div").class("username","input-container").content([$("label").for("username").content("Username"),$("input").type("text").id("username").value(n)]),$("div").class("api-key","input-container").content([$("label").for("api-key").content("API Key"),$("input").type("password").id("api-key").value(e)]),$("icon-button").content("Login").on("click",async()=>{await y.used.login(n.value,e.value),y.used.user&&(nt.storageUserData={apiKey:e.value,username:n.value},n.set(""),e.set(""),$.replace("/"))}),$("icon-button").content("Create Account").icon("open-outline").on("click",()=>$.open("https://danbooru.donmai.us/users/new","_blank"))])]});class fe extends f{constructor(){super("drawer");h(this,"$filter",$("div").class("filter"));h(this,"$container",$("div").class("drawer-container"));this.hide(!0),this.build()}build(){this.content([this.$container.content([$("div").class("user-info").hide(!0).self(t=>[y.events.on("login",s=>{t.content([$("div").content([$("h3").class("username").content(s.name$),$("div").class("user-detail").content([$("span").class("userid").content(`ID: ${s.id}`),$("span").class("level").content(["Level: ",s.level_string$])])]),$("div").class("user-nav").content([$("icon-button").title("Uploaded Posts").icon("image").content(s.post_upload_count$.convert(Y)).link(`/posts?tags=user:${s.name}`,!0),$("icon-button").title("Favorites").icon("heart").content(s.favorite_count$.convert(Y)).link(`/posts?tags=ordfav:${s.name}`,!0),$("icon-button").title("Forum Posts").icon("document-text").content(s.forum_post_count$.convert(Y)).hide(!0)])]).hide(!1)}).on("logout",()=>{t.clear().hide(!0)})]),$("div").class("nav").content([$("div").class("login").content([$("icon-button").icon("log-in-outline").content("Login").link("/login",!0)]).self(t=>y.events.on("login",()=>t.hide(!0)).on("logout",()=>t.hide(!1))),$("div").class("logout").hide(!0).content([$("icon-button").icon("log-in-outline").content("Logout").on("dblclick",()=>y.used.logout())]).self(t=>y.events.on("login",()=>t.hide(!1)).on("logout",()=>t.hide(!0)))])]),this.$filter.on("click",()=>$.back())])}open(){this.hide(!1),this.$container.animate({transform:["translateX(100%)","translateX(0%)"]},{fill:"both",duration:300,easing:"ease"}),this.$filter.animate({opacity:[0,1]},{fill:"both",duration:300,easing:"ease"})}close(){this.$container.animate({transform:["translateX(0%)","translateX(100%)"]},{fill:"both",duration:300,easing:"ease"},()=>this.hide(!0)),this.$filter.animate({opacity:[1,0]},{fill:"both",duration:300,easing:"ease"})}checkURL(t,s){(t==null?void 0:t.hash)==="#drawer"&&this.close(),s.hash==="#drawer"&&this.open()}}$.registerTagName("ion-icon",le);$.registerTagName("icon-button",de);$.anchorHandler=n=>{$.open(n.href(),n.target())};const[ut,pe]=[new y({origin:"https://danbooru.donmai.us",name:"Danbooru"}),new y({origin:"https://safebooru.donmai.us",name:"Safebooru"}),new y({origin:"https://testbooru.donmai.us",name:"Testbooru"})];y.set(y.manager.get(y.storageAPI??"")??ut);const At=new oe().hide(!0),Mt=new fe;$(document.body).content([$("nav").content([$("a").class("title").href("/").content([$("h1").class("booru-name").content(y.name$),$("h2").class("app").content([$("span").class("app-name").content("Viewer"),$("span").class("version").content("v0.3.5")])]),$("div").class("searchbar").content(["Search in ",y.name$]).self(n=>L.events.on("stateChange",({beforeURL:e,afterURL:t})=>{e.hash==="#search"&&n.hide(!1),t.hash==="#search"&&n.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("div").class("buttons").content([$("ion-icon").class("search").name("search-outline").title("Search").self(n=>L.events.on("stateChange",({beforeURL:e,afterURL:t})=>{e.hash==="#search"&&n.hide(!1),t.hash==="#search"&&n.hide(!0)})).on("click",()=>$.open(location.href+"#search")),$("ion-icon").class("switch").name("swap-horizontal").title("Switch Booru").on("click",()=>{y.used===ut?y.set(pe):y.set(ut)}),$("ion-icon").class("open").name("open-outline").title("Open in Original Site").on("click",()=>$.open(location.href.replace(location.origin,y.used.origin))),$("ion-icon").class("menu").name("menu-outline").title("Menu").hide(!1).self(n=>{y.events.on("login",()=>n.hide(!0)).on("logout",()=>n.hide(!1))}).on("click",()=>$.open(location.href+"#drawer")),$("div").class("account").hide(!0).title("Menu").self(n=>{y.events.on("login",e=>{n.content(e.name$.convert(t=>{var s;return((s=t.at(0))==null?void 0:s.toUpperCase())??""})).hide(!1)}).on("logout",()=>n.hide(!0))}).on("click",()=>$.open(location.href+"#drawer"))])]),At,Mt,$("router").base("/").map([$("route").id("posts").path("/").builder(()=>new vt),$("route").id("posts").path("/posts?tags").builder(({query:n})=>new vt({tags:n.tags})),se,me]).on("beforeSwitch",n=>{n.preventDefault();function s(){var a;const r=$.call(()=>{switch(L.navigationDirection){case F.Forward:return["translateX(2%)","translateX(0%)"];case F.Back:return["translateX(-2%)","translateX(0%)"];case F.Replace:return""}});n.$view.content(n.nextContent),n.rendered(),(a=n.nextContent.element)==null||a.class("animated").animate({opacity:[0,1],transform:r},{duration:300,easing:"ease"},()=>{var o;n.switched(),(o=n.nextContent.element)==null||o.removeClass("animated")})}function i(){var a,o;const r=$.call(()=>{switch(L.navigationDirection){case F.Forward:return["translateX(0%)","translateX(-2%)"];case F.Back:return["translateX(0%)","translateX(2%)"];case F.Replace:return""}});(o=(a=n.previousContent)==null?void 0:a.element)==null||o.class("animated").animate({opacity:[1,0],transform:r},{duration:300,easing:"ease"},()=>{var u,c;(c=(u=n.previousContent)==null?void 0:u.element)==null||c.removeClass("animated"),s()})}n.previousContent?i():s()})]);L.events.on("stateChange",({beforeURL:n,afterURL:e})=>Pt(n,e));Pt(void 0,new URL(location.href));function Pt(n,e){At.checkURL(n,e),Mt.checkURL(n,e)} diff --git a/dist/index.html b/dist/index.html index 28ae191..27e48af 100644 --- a/dist/index.html +++ b/dist/index.html @@ -7,8 +7,8 @@ Danbooru Viewer v0.2.5 - - + + diff --git a/index.scss b/index.scss index 2fe6c36..a1f7af1 100644 --- a/index.scss +++ b/index.scss @@ -3,6 +3,7 @@ @import '/src/component/PostTile/$PostTile'; @import '/src/component/Searchbar/$Searchbar'; @import '/src/component/IconButton/$IconButton'; +@import '/src/component/Drawer/$Drawer'; // routes @import '/src/route/post/$post_route'; @import '/src/route/login/$login_route'; @@ -11,12 +12,15 @@ --background-color: #1e1e2c; --background-color-lighter: #3b3b66; --background-color-light: #24243b; + --background-color-dark: #12121f; + --background-color-darker: #07070c; --primary-color: #d1d1ee; --primary-color-dark: #9696b3; --primary-color-darker: #72728d; --secondary-color: #aeaeec; --secondary-color-dark: #6d6da1; --secondary-color-darker: #424268; + --shadow-color: #09090e50; --border-radius-small: 0.4rem; --border-radius-medium: 0.8rem; @@ -154,7 +158,7 @@ router { route { display: block; position: relative; - padding-inline: 10px; + padding-inline: 1rem; padding-top: var(--nav-height); } } diff --git a/package.json b/package.json index 99494a3..e69f6ee 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "danbooru-viewer", "module": "index.ts", "type": "module", - "version": "0.3.4", + "version": "0.3.5", "devDependencies": { "@types/bun": "latest", "vite": "^5.4.8" diff --git a/src/component/Drawer/$Drawer.ts b/src/component/Drawer/$Drawer.ts new file mode 100644 index 0000000..c495f0a --- /dev/null +++ b/src/component/Drawer/$Drawer.ts @@ -0,0 +1,91 @@ +import { $Container } from "elexis"; +import { Booru } from "../../structure/Booru"; +import { numberFormat } from "../../modules"; + +export class $Drawer extends $Container { + $filter = $('div').class('filter'); + $container = $('div').class('drawer-container') + constructor() { + super('drawer'); + this.hide(true); + this.build(); + } + + private build() { + this.content([ + this.$container.content([ + $('div').class('user-info').hide(true).self(($div) => [ + Booru.events + .on('login', (user) => { + $div.content([ + $('div').content([ + $('h3').class('username').content(user.name$), + $('div').class('user-detail').content([ + $('span').class('userid').content(`ID: ${user.id}`), + $('span').class('level').content(['Level: ', user.level_string$]) + ]) + ]),//.on('click', () => $.replace(user.url)), + $('div').class('user-nav').content([ + $('icon-button').title('Uploaded Posts').icon('image').content(user.post_upload_count$.convert(numberFormat)).link(`/posts?tags=user:${user.name}`, true), + $('icon-button').title('Favorites').icon('heart').content(user.favorite_count$.convert(numberFormat)).link(`/posts?tags=ordfav:${user.name}`, true), + $('icon-button').title('Forum Posts').icon('document-text').content(user.forum_post_count$.convert(numberFormat)).hide(true), + ]) + ]).hide(false); + }) + .on('logout', () => { + $div.clear().hide(true); + }) + ]), + $('div').class('nav').content([ + $('div').class('login') + .content([ $('icon-button').icon('log-in-outline').content('Login').link('/login', true) ]) + .self(($div => Booru.events.on('login', () => $div.hide(true)).on('logout', () => $div.hide(false)))), + $('div').class('logout').hide(true) + .content([ $('icon-button').icon('log-in-outline').content('Logout').on('dblclick', () => Booru.used.logout()) ]) + .self(($div => Booru.events.on('login', () => $div.hide(false)).on('logout', () => $div.hide(true)))), + ]) + ]), + this.$filter.on('click', () => $.back()) + ]) + } + + open() { + this.hide(false); + this.$container.animate({ + transform: [`translateX(100%)`, `translateX(0%)`] + }, { + fill: 'both', + duration: 300, + easing: 'ease' + }) + this.$filter.animate({ + opacity: [0, 1] + }, { + fill: 'both', + duration: 300, + easing: 'ease' + }) + } + + close() { + this.$container.animate({ + transform: [`translateX(0%)`, `translateX(100%)`] + }, { + fill: 'both', + duration: 300, + easing: 'ease' + }, () => this.hide(true)) + this.$filter.animate({ + opacity: [1, 0] + }, { + fill: 'both', + duration: 300, + easing: 'ease' + }) + } + + checkURL(beforeURL: URL | undefined, afterURL: URL) { + if (beforeURL?.hash === '#drawer') this.close(); + if (afterURL.hash === '#drawer') this.open(); + } +} \ No newline at end of file diff --git a/src/component/Drawer/_$Drawer.scss b/src/component/Drawer/_$Drawer.scss new file mode 100644 index 0000000..73c18ac --- /dev/null +++ b/src/component/Drawer/_$Drawer.scss @@ -0,0 +1,75 @@ +drawer { + position: fixed; + top: 0; + left: 0; + display: flex; + z-index: 300; + height: 100%; + width: 100%; + box-sizing: border-box; + justify-content: end; + align-items: center; + padding: 1rem; + + div.drawer-container { + width: 300px; + max-width: 70%; + height: 100%; + background-color: var(--background-color); + border-radius: var(--border-radius-large); + z-index: 1; + overflow: hidden; + + div.user-info { + background-color: var(--background-color-light); + padding: 2rem; + + .username { + margin: 0; + color: var(--secondary-color); + cursor: pointer; + } + + div.user-detail { + display: flex; + gap: 0.5rem; + margin-top: 0.2rem; + span { + font-size: 0.8rem; + color: var(--primary-color-dark); + display: block; + cursor: pointer; + } + } + + div.user-nav { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + gap: 1rem; + margin-top: 1rem; + } + } + + div.nav { + padding: 2rem; + display: flex; + gap: 1rem; + flex-direction: column; + button.icon { + + } + } + } + + div.filter { + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + background: linear-gradient(90deg, + color-mix(in srgb, var(--background-color-dark) 50%, transparent) 0%, + color-mix(in srgb, var(--background-color-darker) 70%, transparent) 100% + ); + } +} \ No newline at end of file diff --git a/src/component/IconButton/$IconButton.ts b/src/component/IconButton/$IconButton.ts index 3a4a93a..41651f1 100644 --- a/src/component/IconButton/$IconButton.ts +++ b/src/component/IconButton/$IconButton.ts @@ -11,7 +11,7 @@ export class $IconButton extends $Button { private build() { super.content([ - this.$icon, + this.$icon.hide(true), this.$label ]) } @@ -22,7 +22,12 @@ export class $IconButton extends $Button { } icon(name: string) { - this.$icon.name(name); + this.$icon.name(name).hide(false); + return this; + } + + link(url: string, replace = false) { + this.on('click', () => replace ? $.replace(url) : $.open(url)); return this; } } \ No newline at end of file diff --git a/src/component/Searchbar/$Searchbar.ts b/src/component/Searchbar/$Searchbar.ts index b9e0148..547ee22 100644 --- a/src/component/Searchbar/$Searchbar.ts +++ b/src/component/Searchbar/$Searchbar.ts @@ -1,8 +1,8 @@ import { $Container } from "elexis"; import { Tag, TagCategory } from "../../structure/Tag"; import { Booru } from "../../structure/Booru"; -import { User } from "../../structure/User"; import { Autocomplete } from "../../structure/Autocomplete"; +import { numberFormat } from "../../modules"; export class $Searchbar extends $Container { $tagInput = new $TagInput(this); @@ -143,7 +143,7 @@ export class $Searchbar extends $Container { ]) ]), data.isTag() ? $('div').class('tag-detail').content([ - $('span').class('tag-post-count').content(new Intl.NumberFormat('en', {notation: 'compact'}).format(data.post_count)), + $('span').class('tag-post-count').content(numberFormat(data.post_count)), $('span').class('tag-category').content(TagCategory[data.category]) ]) : null, data.isUser() ? $('span').class('user-level').content(data.level) : null @@ -160,8 +160,8 @@ export class $Searchbar extends $Container { return this; } - checkURL(beforeURL: URL, afterURL: URL) { - if (beforeURL.hash === '#search') this.inactivate(); + checkURL(beforeURL: URL | undefined, afterURL: URL) { + if (beforeURL?.hash === '#search') this.inactivate(); if (afterURL.hash === '#search') this.activate(); } } diff --git a/src/index.d.ts b/src/index.d.ts index 0579a10..b6edd5a 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -45,7 +45,10 @@ type TextSyntaxComparisons = { _lower_space: string } type UserSyntax = { _id: id } | { _name: username }; - type ChainingSyntax = {_id: id} | {has_: boolean}; - -type PostSyntax = {_id: id} | {_tags_match: string}; \ No newline at end of file +type PostSyntax = {_id: id} | {_tags_match: string}; +interface APIError { + success: false; + error: string; + message: string; +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index b81c397..38ae208 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,8 @@ import { $Router, $RouterNavigationDirection } from '@elexis/router'; import { $Searchbar } from './component/Searchbar/$Searchbar'; import { $IonIcon } from './component/IonIcon/$IonIcon'; import { $IconButton } from './component/IconButton/$IconButton'; +import { $login_route } from './route/login/$login_route'; +import { $Drawer } from './component/Drawer/$Drawer'; // declare elexis module declare module 'elexis' { export namespace $ { @@ -28,7 +30,8 @@ export const [danbooru, safebooru]: Booru[] = [ ] Booru.set(Booru.manager.get(Booru.storageAPI ?? '') ?? danbooru); const $searchbar = new $Searchbar().hide(true); -if (location.hash === '#search') $searchbar.activate(); +const $drawer = new $Drawer(); + // render $(document.body).content([ // Navigation Bar @@ -60,10 +63,24 @@ $(document.body).content([ // Open Booru $('ion-icon').class('open').name('open-outline').title('Open in Original Site') .on('click', () => $.open(location.href.replace(location.origin, Booru.used.origin))), + // Menu Button + $('ion-icon').class('menu').name('menu-outline').title('Menu').hide(false) + .self(($icon) => { Booru.events.on('login', () => $icon.hide(true)).on('logout', () => $icon.hide(false)) }) + .on('click', () => $.open(location.href + '#drawer')), + // Account Menu + $('div').class('account').hide(true).title('Menu') + .self(($account) => { + Booru.events + .on('login', user => { $account.content(user.name$.convert(value => value.at(0)?.toUpperCase() ?? '')).hide(false); }) + .on('logout', () => $account.hide(true)) + }) + .on('click', () => $.open(location.href + '#drawer')) ]) ]), // Searchbar $searchbar, + // Drawer + $drawer, // Base Router $('router').base('/').map([ // Home Page @@ -71,7 +88,9 @@ $(document.body).content([ // Posts Page $('route').id('posts').path('/posts?tags').builder(({query}) => new $PostGrid({tags: query.tags})), // Post Page - post_route + post_route, + // Login Page + $login_route ]).on('beforeSwitch', (e) => { const DURATION = 300; const TX = 2; @@ -123,4 +142,9 @@ $(document.body).content([ }) ]) -$Router.events.on('stateChange', ({beforeURL, afterURL}) => { $searchbar.checkURL(beforeURL, afterURL) }) \ No newline at end of file +$Router.events.on('stateChange', ({beforeURL, afterURL}) => componentState(beforeURL, afterURL)) +componentState(undefined, new URL(location.href)) + +function componentState(beforeURL: URL | undefined, afterURL: URL) { + $searchbar.checkURL(beforeURL, afterURL); $drawer.checkURL(beforeURL, afterURL) +} \ No newline at end of file diff --git a/src/modules.ts b/src/modules.ts new file mode 100644 index 0000000..77f44b7 --- /dev/null +++ b/src/modules.ts @@ -0,0 +1,4 @@ +const NUMBER_FORMAT = new Intl.NumberFormat('en', {notation: 'compact'}) +export function numberFormat(number: number) { + return NUMBER_FORMAT.format(number) +} \ No newline at end of file diff --git a/src/route/login/$login_route.ts b/src/route/login/$login_route.ts new file mode 100644 index 0000000..4d2861d --- /dev/null +++ b/src/route/login/$login_route.ts @@ -0,0 +1,30 @@ +import { Booru } from "../../structure/Booru" +import { ClientUser } from "../../structure/ClientUser"; + +export const $login_route = $('route').id('login').path('/login').builder(() => { + const [username$, apiKey$] = [$.state(''), $.state('')] + return [ + $('div').class('login-container').content([ + $('h1').content('Login'), + $('div').class('username', 'input-container').content([ + $('label').for('username').content('Username'), + $('input').type('text').id('username').value(username$) + ]), + $('div').class('api-key', 'input-container').content([ + $('label').for('api-key').content('API Key'), + $('input').type('password').id('api-key').value(apiKey$) + ]), + $('icon-button').content('Login').on('click', async () => { + await Booru.used.login(username$.value, apiKey$.value); + if (Booru.used.user) { + ClientUser.storageUserData = { apiKey: apiKey$.value, username: username$.value } + // Clear input + username$.set(''); + apiKey$.set(''); + $.replace('/'); + }; + }), + $('icon-button').content('Create Account').icon('open-outline').on('click', () => $.open('https://danbooru.donmai.us/users/new', '_blank')), + ]) + ] +}) \ No newline at end of file diff --git a/src/route/login/_$login_route.scss b/src/route/login/_$login_route.scss new file mode 100644 index 0000000..50d2135 --- /dev/null +++ b/src/route/login/_$login_route.scss @@ -0,0 +1,27 @@ +route#login { + display: flex; + justify-content: center; + align-items: center; + margin-top: 5rem; + + .login-container { + padding: 2rem; + border: 1px solid var(--secondary-color); + border-radius: var(--border-radius-large); + display: flex; + flex-direction: column; + justify-content: center; + gap: 1rem; + h1 { + margin: 0; + } + .input-container { + display: flex; + flex-direction: column; + gap: 0.5rem; + input { + width: 300px; + } + } + } +} \ No newline at end of file diff --git a/src/route/post/$post_route.ts b/src/route/post/$post_route.ts index 8a031d0..394ddec 100644 --- a/src/route/post/$post_route.ts +++ b/src/route/post/$post_route.ts @@ -4,6 +4,7 @@ import { Tag, TagCategory } from "../../structure/Tag"; import { ArtistCommentary } from "../../structure/Commentary"; import { Booru } from "../../structure/Booru"; import type { $IonIcon } from "../../component/IonIcon/$IonIcon"; +import { numberFormat } from "../../modules"; export const post_route = $('route').path('/posts/:id').id('post').builder(({$route, params}) => { if (!Number(params.id)) return $('h1').content('404: POST NOT FOUND'); @@ -87,7 +88,7 @@ export const post_route = $('route').path('/posts/:id').id('post').builder(({$ro $('section').content([ tags.map(tag => $('div').class('tag').content([ $('a').class('tag-name').content(tag.name).href(`/posts?tags=${tag.name}`), - $('span').class('tag-post-count').content(tag.post_count$) + $('span').class('tag-post-count').content(tag.post_count$.convert(numberFormat)) ])) ]) ] : null diff --git a/src/structure/Booru.ts b/src/structure/Booru.ts index 6e74510..dd46189 100644 --- a/src/structure/Booru.ts +++ b/src/structure/Booru.ts @@ -1,6 +1,7 @@ import { $EventManager, type $EventMap } from "elexis"; import type { Post } from "./Post"; import type { Tag } from "./Tag"; +import { ClientUser, type ClientUserData } from "./ClientUser"; export interface BooruOptions { origin: string; @@ -9,9 +10,10 @@ export interface BooruOptions { export interface Booru extends BooruOptions {} export class Booru { static used: Booru; - static events = new $EventManager(); + static events = new $EventManager(); static name$ = $.state(this.name); static manager = new Map() + user?: ClientUser; posts = new Map(); tags = new Map(); constructor(options: BooruOptions) { @@ -24,6 +26,8 @@ export class Booru { this.used = booru; this.name$.set(booru.name); this.storageAPI = booru.name; + const userdata = ClientUser.storageUserData; + if (userdata) booru.login(userdata.username, userdata.apiKey); this.events.fire('set'); return this; } @@ -31,8 +35,33 @@ export class Booru { static get storageAPI() { return localStorage.getItem('booru_api'); } static set storageAPI(name: string | null) { if (name) localStorage.setItem('booru_api', name); else localStorage.removeItem('booru_api') } + async fetch(endpoint: string) { + const data = await fetch(`${this.origin}${endpoint}`).then(res => res.json()) as any; + if (data.success === false) throw data.message; + return data as T; + } + + async login(username: string, apiKey: string) { + const data = await this.fetch(`/profile.json?login=${username}&api_key=${apiKey}`); + this.user = new ClientUser(this, apiKey, data); + Booru.events.fire('login', this.user); + return this.user; + } + + logout() { + this.user = undefined; + ClientUser.storageUserData = null; + Booru.events.fire('logout'); + return this + } + +} + +interface BooruStaticEventMap extends $EventMap { + set: []; + login: [user: ClientUser]; + logout: []; } interface BooruEventMap extends $EventMap { - set: [] } \ No newline at end of file diff --git a/src/structure/ClientUser.ts b/src/structure/ClientUser.ts new file mode 100644 index 0000000..5050c96 --- /dev/null +++ b/src/structure/ClientUser.ts @@ -0,0 +1,71 @@ +import type { Booru } from "./Booru"; +import { User, type UserData } from "./User"; + +export interface ClientUser extends ClientUserData {} +export class ClientUser extends User { + apiKey: string; + favorite_count$ = $.state(0); + forum_post_count$ = $.state(0); + constructor(booru: Booru, apiKey: string, data: ClientUserData) { + super(booru, data, false); + this.apiKey = apiKey; + this.update$(); + } + + update$() { + super.update$(); + this.forum_post_count$?.set(this.forum_post_count); + this.favorite_count$?.set(this.favorite_count); + } + + static get storageUserData() { const data = localStorage.getItem('user_data'); return data ? JSON.parse(data) as ClientUserStoreData : null } + static set storageUserData(data: ClientUserStoreData | null) { localStorage.setItem('user_data', JSON.stringify(data)) } +} +export interface ClientUserData extends UserData { + "last_logged_in_at": ISOString, + "last_forum_read_at": ISOString, + "comment_threshold": number, + "updated_at": ISOString, + "default_image_size": "large" | "original", + "favorite_tags": null | string, + "blacklisted_tags": string, + "time_zone": string, + "favorite_count": number, + "per_page": number, + "custom_style": string, + "theme": "auto" | "light" | "dark", + "receive_email_notifications": boolean, + "new_post_navigation_layout": boolean, + "enable_private_favorites": boolean, + "show_deleted_children": boolean, + "disable_categorized_saved_searches": boolean, + "disable_tagged_filenames": boolean, + "disable_mobile_gestures": boolean, + "enable_safe_mode": boolean, + "enable_desktop_mode": boolean, + "disable_post_tooltips": boolean, + "requires_verification": boolean, + "is_verified": boolean, + "show_deleted_posts": boolean, + "statement_timeout": number, + "favorite_group_limit": 10 | 100, + "tag_query_limit": 2 | 6, + "max_saved_searches": 250, + "wiki_page_version_count": number, + "artist_version_count": number, + "artist_commentary_version_count": number, + "pool_version_count": number | null, + "forum_post_count": number, + "comment_count": number, + "favorite_group_count": number, + "appeal_count": number, + "flag_count": number, + "positive_feedback_count": number, + "neutral_feedback_count": number, + "negative_feedback_count": number +} + +export interface ClientUserStoreData { + username: string; + apiKey: string; +} \ No newline at end of file diff --git a/src/structure/Post.ts b/src/structure/Post.ts index cd2804e..7b8e7a7 100644 --- a/src/structure/Post.ts +++ b/src/structure/Post.ts @@ -113,6 +113,7 @@ export class Post extends $EventManager<{update: []}> { } get previewURL() { return this.media_asset.variants?.find(variant => variant.file_ext === 'webp')?.url ?? this.large_file_url } get url() { return `${this.booru.origin}/posts/${this.id}` } + get isFileSource() { return this.source.startsWith('file://') } } export interface PostData extends PostOptions { diff --git a/src/structure/Tag.ts b/src/structure/Tag.ts index 3e59db7..43852b4 100644 --- a/src/structure/Tag.ts +++ b/src/structure/Tag.ts @@ -1,10 +1,9 @@ import type { Booru } from "./Booru"; -const INTL_number = new Intl.NumberFormat('en', {notation: 'compact'}) export interface TagOptions {} export interface Tag extends TagData {} export class Tag { - post_count$ = $.state(0, {format: (value) => `${INTL_number.format(value)}`}); + post_count$ = $.state(0); name$ = $.state(''); booru: Booru; constructor(booru: Booru, data: TagData) { diff --git a/src/structure/User.ts b/src/structure/User.ts index e65f6b0..f341f9f 100644 --- a/src/structure/User.ts +++ b/src/structure/User.ts @@ -4,15 +4,20 @@ export class UserOptions {} export interface User extends UserOptions, UserData {} export class User { static manager = new Map(); - name$ = $.state('loding...'); - constructor(data: UserData) { + name$ = $.state('...'); + post_upload_count$ = $.state(0); + level$ = $.state(10); + level_string$ = $.state('...'); + booru: Booru; + constructor(booru: Booru, data: UserData, update$: boolean = true) { + this.booru = booru; Object.assign(this, data); - this.update$(); + if (update$) this.update$(); } static async fetch(booru: Booru, id: id) { const data = await fetch(`${booru.origin}/users/${id}.json`).then(async data => await data.json()) as UserData; - const instance = this.manager.get(data.id)?.update(data) ?? new this(data); + const instance = this.manager.get(data.id)?.update(data) ?? new this(booru, data); this.manager.set(instance.id, instance); return instance; } @@ -33,7 +38,7 @@ export class User { const req = await fetch(`${booru.origin}/users.json?limit=${limit}${searchQuery}`); const dataArray: UserData[] = await req.json(); const list = dataArray.map(data => { - const instance = new this(data); + const instance = new this(booru, data); this.manager.set(instance.id, instance); return instance; }); @@ -48,9 +53,26 @@ export class User { update$() { this.name$.set(this.name); + this.post_upload_count$.set(this.post_upload_count); + this.level$.set(this.level); + this.level_string$.set(this.level_string); } + + get booruURL() { return `${this.booru.origin}/users/${this.id}`} + get url() { return `/users/${this.id}`} } +export enum UserLevel { + Restricted = 10, + Member = 20, + Gold = 30, + Platinum = 31, + Builder = 32, + Contributor = 35, + Approver = 37, + Moderater = 40, + Admin = 50 +} export interface UserData { "id": id, "name": username, @@ -61,57 +83,10 @@ export interface UserData { "note_update_count": number, "post_upload_count": number, "is_deleted": boolean, - "level_string": UserLevelString, + "level_string": keyof UserLevel, "is_banned": boolean, } -export type UserLevel = 10 | 20 | 30 | 31 | 32 | 40 | 50; -export type UserLevelString = "Member" | "Gold" | "Platinum" | "Admin" | "Contributor" | "Builder" | "Approver"; - -export interface UserProfileData extends UserData { - "last_logged_in_at": ISOString, - "last_forum_read_at": ISOString, - "comment_threshold": number, - "updated_at": ISOString, - "default_image_size": "large" | "original", - "favorite_tags": null | string, - "blacklisted_tags": string, - "time_zone": string, - "favorite_count": number, - "per_page": number, - "custom_style": string, - "theme": "auto" | "light" | "dark", - "receive_email_notifications": boolean, - "new_post_navigation_layout": boolean, - "enable_private_favorites": boolean, - "show_deleted_children": boolean, - "disable_categorized_saved_searches": boolean, - "disable_tagged_filenames": boolean, - "disable_mobile_gestures": boolean, - "enable_safe_mode": boolean, - "enable_desktop_mode": boolean, - "disable_post_tooltips": boolean, - "requires_verification": boolean, - "is_verified": boolean, - "show_deleted_posts": boolean, - "statement_timeout": number, - "favorite_group_limit": 10 | 100, - "tag_query_limit": 2 | 6, - "max_saved_searches": 250, - "wiki_page_version_count": number, - "artist_version_count": number, - "artist_commentary_version_count": number, - "pool_version_count": number | null, - "forum_post_count": number, - "comment_count": number, - "favorite_group_count": number, - "appeal_count": number, - "flag_count": number, - "positive_feedback_count": number, - "neutral_feedback_count": number, - "negative_feedback_count": number -} - export interface UserSearchParam { id: NumericSyntax; level: NumericSyntax;