jmini 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +1 -1
- package/declare/core.d.ts +2 -0
- package/esm/core.js +1 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty,_=Object.defineProperties,z=Object.getOwnPropertyDescriptor,X=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var B=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var F=Math.pow,Y=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))J.call(t,n)&&Y(e,n,t[n]);if(P)for(var n of P(t))U.call(t,n)&&Y(e,n,t[n]);return e},A=(e,t)=>_(e,X(t));var j=(e,t)=>{var n={};for(var i in e)J.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&P)for(var i of P(e))t.indexOf(i)<0&&U.call(e,i)&&(n[i]=e[i]);return n};var Q=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},Z=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!J.call(e,r)&&r!==n&&k(e,r,{get:()=>t[r],enumerable:!(i=z(t,r))||i.enumerable});return e};var ee=e=>Z(k({},"__esModule",{value:!0}),e);var d=(e,t,n)=>new Promise((i,r)=>{var s=l=>{try{u(n.next(l))}catch(h){r(h)}},o=l=>{try{u(n.throw(l))}catch(h){r(h)}},u=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,o);u((n=n.apply(e,t)).next())}),O=function(e,t){this[0]=e,this[1]=t},V=(e,t,n)=>{var i=(o,u,l,h)=>{try{var p=n[o](u),g=(u=p.value)instanceof O,T=p.done;Promise.resolve(g?u[0]:u).then(m=>g?i(o==="return"?o:"next",u[1]?{done:m.done,value:m.value}:m,l,h):l({value:m,done:T})).catch(m=>i("throw",m,l,h))}catch(m){h(m)}},r=o=>s[o]=u=>new Promise((l,h)=>i(o,u,l,h)),s={};return n=n.apply(e,t),s[B("asyncIterator")]=()=>s,r("next"),r("throw"),r("return"),s};var $=(e,t,n)=>(t=e[B("asyncIterator")])?t.call(e):(e=e[B("iterator")](),t={},n=(i,r)=>(r=e[i])&&(t[i]=s=>new Promise((o,u,l)=>(s=r.call(e,s),l=s.done,Promise.resolve(s.value).then(h=>o({value:h,done:l}),u)))),n("next"),n("return"),t);var pe={};Q(pe,{Fetcher:()=>c,Filer:()=>b,Server:()=>L,Time:()=>f,UUID:()=>x,default:()=>ce,useStore:()=>I});module.exports=ee(pe);typeof HTMLElement!="undefined"&&(HTMLElement.prototype.position=function(){return this.getBoundingClientRect()});typeof String!="undefined"&&(String.prototype.compress=function(){return this.trim().replace(/(\s|\n|\t)/ig,"")},String.prototype.encode=function(){return encodeURIComponent(this)},String.prototype.decode=function(){return decodeURIComponent(this)},String.prototype.toUpper=function(){return this.toLocaleUpperCase()},String.prototype.toLower=function(){return this.toLocaleLowerCase()},String.prototype.toCapital=function(){let e=this;return e&&(e=e.replace(/^./,this[0].toUpper()).replace(/(\s|_|-)[a-z]{1}/ig,t=>t[1].toUpper())),e},String.prototype.clip=function(e,t){return this.slice(e,t)},String.prototype.partReplace=function(e,t){return this.slice(0,e)+t+this.slice(e+t.length)},String.prototype.toBlob=function(e){let t=atob(this.replace(/^.*,/,"")),n=new Uint8Array(t.length);for(var i=0;i<t.length;i++)n[i]=t.charCodeAt(i);try{var r=new Blob([n.buffer],{type:e})}catch(s){return!1}return r},String.prototype.toNumber=function(){return Number(this.removeLetters())},String.prototype.removeLetters=function(){return this.replace(/[\D]/ig,"")},String.prototype.removeSpecifics=function(){return this.replace(/[^\w\s\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]|_/uig,"")},String.prototype.removeJP=function(){return this.replace(/[\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]+/uig,"")},String.prototype.zen2hanNumber=function(){return this.replace(/[0-9]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)}).replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,"-").replace(/¥/,"\xA5").replace(/、/,",").replace(/(/,"(").replace(/)/,")").replace(/+/,"+")});typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){return String(this).padStart(e||2,"0")},Number.prototype.ratio=function(e,t=2){let n=F(10,t);return Math.round(this/e*n*100)/n},Number.prototype.rate=function(e,t=2){let n=F(10,t);return Math.round(this/e*n)/n},Number.prototype.rank=function(e=1){let t=F(10,e),n=Number(this),i=n.toLocaleString().replace(/\d/ig,"").length;return Math.round(n/F(1e3,i)*t)/t+("KMGTPEZY"[i-1]||"")},Number.prototype.rankJp=function(){let e=Number(this),t="";return e>=1e12?t=`${e/1e12}\u5146`:e>=1e8?t=`${e/1e8}\u5104`:e>=1e4?t=`${e/1e4}\u4E07`:e>=1e3?t=`${e/1e3}\u5343`:t=`${e.toLocaleString()}`,t},Number.prototype.toDate=function(e="/"){let t=String(this),n=t.slice(0,4),i=t.slice(4,6),r=t.slice(6,8),s=[];return n.length!=4||s.push(n),i.length!=2||s.push(i),r.length!=2||s.push(r),s.join(e)});if(typeof Array!="undefined"){let e=(t,n)=>{var r;let i=t;for(let s of n){if(!s)break;i=(r=(i||{})[s||""])!=null?r:null}return i};Array.prototype.toASC=function(...t){return(!t||!(t!=null&&t.length))&&(t=[""]),this.sort((n,i)=>{for(let r of t){r=r||"";let s=this.every(l=>{let h=Number(e(l,r.split(".")));return typeof h=="number"&&!isNaN(h)}),o=e(n,r.split(".")),u=e(i,r.split("."));if(s){if(o=Number(o),u=Number(u),o>u)return 1;if(o<u)return-1}else{if(o=String(o).replace(/(\d+)/g,l=>l.padStart(18,"0")),u=String(u).replace(/(\d+)/g,l=>l.padStart(18,"0")),o>u)return 1;if(o<u)return-1}}return 0})},Array.prototype.toDESC=function(...t){return this.toASC(...t).reverse()}}typeof File!="undefined"&&(File.prototype.convert=function(e){return e=e||"dataURL",new Promise((t,n)=>{let i=new FileReader;i.onload=s=>t(s),i.onerror=s=>n(s);let r="readAs"+(e==null?void 0:e.toCapital());i[r](this)})});var te=(e=24)=>Array.from({length:e}).map((t,n)=>{let i=n==0?25:35,r=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*i)][r?"toUpper":"toLower"]()}).join(""),x=te;x.gen128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");x.gen32Hex=(e="Formatted",t="-")=>{let n=Array.from({length:32}).map((i,r)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(n=[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20,32)].join(t)),n};x.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();var re=e=>new a.prototype.jmini(e),a=re;a.prototype={};a.extend=function(e,t=a){for(var[n,i]of Object.entries(e))t.prototype[n]=i};a.expando="__jmini_"+x();var y=(e,t)=>(e.queue.push(t),N(e),e),N=e=>d(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let t=e.queue.shift();t&&(yield t()),e.queueProcess=!1,N(e)}}),R=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=null;for(let[n,i]of Object.entries(t))n.match(/queue/)||(e[n]=i);return e},ne=(e,t)=>{if(t.length){for(var n=0;n<t.length;n++){let i=t[n];i&&(i[a.expando]||(a.is.element(i)||a.is.shadowRoot(i))&&(i[a.expando]={events:{}})),e[n]=i}e.length=t.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,N(e),e};a.extend({constructor:a,jmini:function(e){return this.src=e,this.srcType=a.is.what(e),this.queueProcess=!0,this.queue=[],ne(this,a.is.jmini(e)?e.get():a.is.element(e)?[e]:a.is.elements(e)?e:a.is.shadowRoot(e)?[e]:a.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}});a.prototype[String(Symbol.iterator)]=[][Symbol.iterator];a.prototype.jmini.prototype=a.prototype;{let e=function(r,s,o){let u=[];for(let l=0;l<(r.length||0);l++)u.push(s(r[l],l));return o&&(u=u.filter(l=>l!=null)),u},t=r=>(r.for((s,o)=>{if(!(a.is.element(s)||a.is.shadowRoot(s)))return;let u=s.cloneNode(),l=s.parentNode;l&&l.replaceChild(u,s),r[o]=u}),r),n=(r,s)=>(a(s).for(o=>{if(r&&(a.is.element(o)||a.is.shadowRoot(o)))if(a.is.string(r)||a.is.number(r))r=String(r),o.insertAdjacentHTML("beforeend",String(r));else if(a.is.element(r))o.appendChild(r);else{a.is.jmini(r)?r=r.get():a.is.element(r)?r=[r]:a.is.keyValueDictionary(r)&&(r=[a(r)]);for(var u=0;u<r.length;u++)n(r[u],o)}}),s),i=(r,s,...o)=>{let{p:u,s:l}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[s]||{p:"",s:""};return r.for(h=>{if(a.is.string(o[0]))h.insertAdjacentHTML(u,o[0]);else{if(!h.parentNode)return;a(o[0]).for(g=>{o[1]&&(g=g.cloneNode(!0)),h.parentNode.insertBefore(g,h[l]||h)})}}),r};a.extend({get:function(r){return r?this[0]:e(this,s=>s)},for:function(r,s=1){let o=e(this,(u,l)=>r(u,l),1);return s?o:[]},await:function(r){return y(this,()=>new Promise((s,o)=>{setTimeout(()=>{s(this)},r)}))},abort:function(){return y(this,()=>d(this,null,function*(){return this.queue=[],this}))},callback:function(r){return y(this,()=>d(this,null,function*(){return yield r(this),this}))},click:function(){return y(this,()=>{for(var r=0;r<this.length;r++){let s=this[r];a.is.element(s)&&s.click()}return this})},focus:function(){return y(this,()=>{for(var r=0;r<this.length;r++){let s=this[r];a.is.element(s)&&s.focus()}return this})},addEvent:function(r){return y(this,()=>{let{eventType:s,eventID:o=x(),target:u,callback:l,options:h}=r;return h=M({passive:!0,capture:!1},h),this.for(p=>{if(!(a.is.element(p)||a.is.shadowRoot(p)))return;let{events:g}=p[a.expando];if(u){let T=l;l=m=>{if(m.target){if(a.is.string(u)){let S=m.target.closest(u);S&&(!S||T.call(S,m))}else if(a.is.elements(u)){for(let v of u)if(m.target==v)return T.call(v,m)}}}}if(g[o]){let T=g[o];p.removeEventListener(T.eventType,T.callback,T.options)}g[o]={eventType:s,callback:l,options:h},p.addEventListener(s,l,h)}),this})},removeEvent:function(r){return y(this,()=>{let s=a.is.array(r)?r:[r];return this.for(o=>{let{events:u}=o[a.expando];for(let l of s){let h=u[l];h&&o.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(r){return y(this,()=>R(this,n(r,t(this))))},empty:function(){return y(this,()=>R(this,t(this)))},append:function(r){return y(this,()=>{n(r,this)})},remove:function(){return y(this,()=>(this.for((r,s)=>{r&&a.is.element(r)&&(r.remove(),delete this[s])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...r){return y(this,()=>R(this,i(this,"before",...r)))},after:function(...r){return y(this,()=>R(this,i(this,"after",...r)))},find:function(r){return y(this,()=>{let s=[],o=this[0];o||R(this,a()),(a.is.element(o)||a.is.shadowRoot(o))&&(a.is.string(r)?s=o.querySelectorAll(r):a.is.element(o)&&a(r).for(u=>{let l=o.childNodes;for(let h of l)if(h===u){s.push(h);break}else h.childNodes.length&&(s=[...s,...a(h).find(u).for(p=>p)])})),R(this,a(s))})},parent:function(r){return y(this,()=>{var o,u;let s=a(r?(o=this[0])==null?void 0:o.closest(r):(u=this[0])==null?void 0:u.parentNode);R(this,s)})},children:function(r){return y(this,()=>{let s=this[0].children;a.is.exist(r)&&(r=String(r).replace(/^ : /,""),s=r=="first"?s[0]:r=="last"?s[s.length-1]:s[Number(r)]);let o=a(s);return R(this,o)})},addClass:function(r){return y(this,()=>(r&&this.for(s=>{let o=a.is.string(r)?r.split(" "):r;s&&a.is.element(s)&&s.classList.add(...o)}),this))},removeClass:function(r){return y(this,()=>(r&&this.for(s=>{let o=a.is.string(r)?r.split(" "):r;s&&a.is.element(s)&&s.classList.remove(...o)}),this))},toggleClass:function(r){return y(this,()=>(r&&this.for(s=>{s.classList.toggle(r)}),this))},hasClass:function(r=""){if(this[0])return this[0].classList.contains(r.replace(/^\./,""))},findClass:function(r){let s=[];return this[0]&&(s=[...this[0].classList].filter(o=>o.match(r))),s},css:function(r){return y(this,()=>(this.for(s=>{if(a.is.element(s))for(let[o,u]of Object.entries(r)){if(a.is.number(u)&&o.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){s.style[o]=u+"px";continue}s.style[o]=String(u)}}),this))},getAttribute:function(r){return this[0].getAttribute(String(r))},setAttribute:function(r,s){return y(this,()=>(this.for(o=>o.setAttribute(r,s)),this))},getStyleProperty:function(r){let s=this[0];return s&&a.is.element(s)?getComputedStyle(s).getPropertyValue(r):""},setStyleProperty:function(r,s){let o=this[0];return o&&a.is.element(o)&&o.style.setProperty(r,s),this},val:function(){var s;let r=this[0];return(r==null?void 0:r.value)||((s=r==null?void 0:r.dataset)==null?void 0:s.value)},position:function(){return a.is.element(this[0])?this[0].getBoundingClientRect():{}}})}a.flatArray=(e,t)=>{if(!a.is.array(e))return[e];let n=[];for(let i of e)n.push(...t=="-R"?a.flatArray(i,"-R"):[i]);return n};a.Stringify=JSON.stringify;a.Objectify=(e,t)=>{try{return JSON.parse(e)}catch(n){return t!=null?t:null}};a.randomNumber=(e=0,t=100,n)=>{if(e>t)return NaN;let i=[],r=e;for(;r<=t;){if(n&&n.length&&n.includes(r)){r++;continue}i.push(r),r++}let s=Math.round(Math.random()*(i.length-1))+0;return i[s]};a.try=e=>{try{return[e(),!0]}catch(t){return[t,!1]}};a.trySync=e=>d(void 0,null,function*(){try{return[yield e(),!0]}catch(t){return[t,!1]}});a.scope=e=>e();a.scopeSync=e=>d(void 0,null,function*(){return yield e()});a.createElement=function(e){var g;let{tag:t,className:n="",id:i,html:r,attr:s,style:o,parent:u}=e,l=document.createElement(t||"div");if(n&&l.classList.add(...n.split(" ")),i&&(l.id=i),s)for(let T of Object.entries(s)){let m=T[0],v=(g=T[1])!=null?g:"";if(m=="data"&&a.is.keyValueDictionary(v))for(let[S,E]of Object.entries(v))l.dataset[S]=E;else m=="for"?m="htmlFor":m=="tabindex"?m="tabIndex":m=="aria-label"&&(m="ariaLabel"),l[m]=v}if(r&&a(l).append(r),o)for(var[h,p]of Object.entries(o))l.style[h]=p;return u&&a(u).append(l),l};a.setCookie=e=>{let{hostname:t}=new URL(location.toString()),{name:n,value:i="",age:r=60*60*24*365,path:s="/",domain:o=t,secure:u=!1}=e,l=`${n}=${i}max-age=${r}path=${s}domain=${o}`;u&&(l+=" Secure"),document.cookie=l};a.getCookie=e=>{let t=document.cookie.match(new RegExp(e+"=[^]*"));return t?t[0].replace(new RegExp(e+"="),""):""};a.localStrage={set:(e,t)=>{localStorage.setItem(e,a.Stringify(t))},get:e=>{let t=localStorage.getItem(e);return a.Objectify(t,t)}};a.deleteCookie=e=>{document.cookie=e+"=max-age=0"};a.getScreenSize=()=>{let{innerHeight:e,innerWidth:t,scrollY:n,scrollX:i,pageXOffset:r,pageYOffset:s}=window,o=Number(a(document.body).getStyleProperty("--sat").removeLetters()),u=Number(a(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:t,pageHeight:e-o-u,scrollY:n,scrollX:i,pageXOffset:r,pageYOffset:s,safeAreaTop:o,safeAreaBottom:u}};a.getCursor=e=>{var i,r,s,o,u,l,h,p;let t=(o=e.pageX)!=null?o:(s=(i=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:i.pageX)!=null?s:(((r=e==null?void 0:e.originalEvent)==null?void 0:r.touches)||[])[0].pageX,n=(p=e.pageY)!=null?p:(h=(u=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:u.pageY)!=null?h:(((l=e==null?void 0:e.originalEvent)==null?void 0:l.touches)||[])[0].pageY;return{x:t,y:n}};a.pending=(e,t)=>new Promise((n,i)=>{e(n),t&&setTimeout(()=>{n(!0)},t)});a.deepMerge=(e,...t)=>{if(!t.length)return e;let n=t.shift();if(a.is.keyValueDictionary(e)&&a.is.keyValueDictionary(n))for(let i in n)a.is.keyValueDictionary(n[i])?(e[i]||Object.assign(e,{[i]:{}}),a.deepMerge(e[i],n[i])):Object.assign(e,{[i]:n[i]});return a.deepMerge(e,...t)};a.deepCopy=e=>{if(a.is.array(e))return e.map(t=>a.deepCopy(t));if(a.is.keyValueDictionary(e)){let t={};return Object.entries(e).forEach(([n,i])=>{t[n]=a.deepCopy(i)}),t}return e};a.queryParams={get:e=>{let t=new URL(e||location.href),n={};return t.searchParams.forEach((i,r)=>n[r]=i),n},set:(e,t)=>{let n=new URL(t||location.href);return Object.entries(e).forEach(([i,r])=>{n.searchParams.set(i,String(r))}),t||history.replaceState({},"",n.pathname+n.search),n.toString()},delete:(e,t)=>{let n=new URL(t||location.href);return e.forEach(i=>{n.searchParams.delete(i)}),t||history.replaceState({},"",n.pathname+n.search),n.toString()}};a.ellipsisText=(e,t)=>{let n=String(e);return n.length>t&&(n=n.slice(0,t)+" ..."),n};a.is={equal:function(e,t,n){return n==null||n?a.Stringify(e)===a.Stringify(t):e===t},what:function(e){let t="other";return this.jmini(e)?t="jmini":this.element(e)?t="element":this.elements(e)?t="elements":this.shadowRoot(e)?t="shadowRoot":this.string(e)?t="string":this.number(e)?t="number":this.array(e)?t="array":this.function(e)?t="function":this.date(e)?t="date":typeof e=="undefined"?t="undefined":this.keyValueDictionary(e)?t="keyValueDictionary":e==null?t="null":isNaN(e)&&(t="NaN"),t},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini:function(e){return(e||{}).constructor===a},string:function(e){return typeof e=="string"},boolean:function(e){return typeof e=="boolean"},number:function(e){return!isNaN(e)&&typeof e=="number"},array:function(e){let t={}.toString.call(e);return e instanceof Array||t=="[object NodeList]"||t=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jmini(e)},element:function(e){return e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e))},elements:function(e){let t={}.toString.call(e),n=Number(!!e&&typeof e!="string"&&this.array(e)&&t!=="[object Text]");if(n&&t!=="[object NodeList]")for(var i of e)n&=Number(this.element(i));return!!n},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};var ie=e=>new f.prototype.Time(e),f=ie;f.prototype={};var se=function(e){f.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return this.set(t)};a.extend({value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,constructor:f,Time:se,clone:function(){return f(this)},set:function(e){this.value=e;let t=a.is.date(e);if(this.validate=t,!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;this.ms=e.getTime(),this.weekday=e.getDay(),this.year=e.getFullYear(),this.month=e.getMonth()+1,this.date=e.getDate();{let n=new Date(this.year,0,1),i=new Date(n.valueOf());i.setDate(i.getDate()-(n.getDay()+1));let r=e.getTime()-i.getTime(),s=Math.ceil(r/(1e3*60*60*24));this.weekInYear=Math.ceil(s/7)}{let n=new Date(this.year,this.month-1,1),i=new Date(n.valueOf());i.setDate(i.getDate()-(n.getDay()+1));let r=e.getTime()-i.getTime(),s=Math.ceil(r/(1e3*60*60*24)),o=Math.ceil(s/7);this.weekInMonth=o}{let n=new Date(this.year,this.month,0),i=n.getDay(),r=new Date(new Date(n).setDate(n.getDate()-i));this.isLastWeekInMonth=this.date>=r.getDate()}return this.hours=e.getHours(),this.minutes=e.getMinutes(),this.seconds=e.getSeconds(),this},isSameYear:function(e){let t=f(e);return this.year==t.year},isSameMonth:function(e){let t=f(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=f(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=f(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+e)},addMonth:function(e){return this.setMonth(this.month+e)},addWeek:function(e){return this.addDate(7*e)},addDate:function(e){return this.setDate(this.date+e)},addHours:function(e){return this.setHours(this.hours+e)},addMinutes:function(e){return this.setMinutes(this.minutes+e)},addSeconds:function(e){return this.setSeconds(this.seconds+e)},toFormat:function(e){return this.validate?e.replace(/\%y/ig,this.year.zeroEmbed(4)).replace(/\%m/ig,this.month.zeroEmbed(2)).replace(/\%d/ig,this.date.zeroEmbed(2)).replace(/\%w/ig,this.weekInYear.zeroEmbed(2)).replace(/\%h/ig,this.hours.zeroEmbed(2)).replace(/\%i/ig,this.minutes.zeroEmbed(2)).replace(/\%s/ig,this.seconds.zeroEmbed(2)):""},toFormatYMD:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5"):this.toFormat("%Y/%M/%D"):""},toFormatYM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708"):this.toFormat("%Y/%M"):""},toFormatMD:function(e){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5"):this.toFormat("%M/%D"):""},toFormatHM:function(e){return this.validate?e=="JP"?this.toFormat("%h\u6642%m\u5206"):this.toFormat("%h:%i"):""},toFormatYMDHM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206"):this.toFormat("%Y/%M/%D %h:%i"):""},toFormatYMDHMS:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2"):this.toFormat("%Y/%M/%D %h:%i:%s"):""},setFirstOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},getFirstDayOfTheYear:function(){return f(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return f(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return f(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return f(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=f(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=f(this.value);return e.addDate(6-e.weekday)},diff:function(e){let t=this.ms-e.ms;return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:Math.floor(t/(60*60*24*1e3)),hours:Math.floor(t/(60*60*1e3)),minutes:Math.floor(t/(60*1e3)),seconds:Math.floor(t/1e3)}},getAge:function(e){let t=e||f(),n=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&n--,n}},f);f.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===f};f.getFromNumberYYYYMMDD=e=>{let t=String(e).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return f(t+" 00:00")};f.getShortYMDs=(e,t)=>{let n="",i="";return e.year==t.year&&e.year==f().year?n=e.toFormatMD():n=e.toFormatYMD(),e.year!=t.year?i=t.toFormatYMD():i=t.toFormatMD(),[n,i]};f.getPeriodArray=(e,t,n)=>{let i=[],r=t;if(!t.validate||!n.validate)return i;for(;r.toFormatYMDHMS().toNumber()<=n.toFormatYMDHMS().toNumber();)i.push(r),e=="year"?r=f(r).addYear(1):e=="month"?r=f(r).addMonth(1):e=="week"?r=f(r).addWeek(1):e=="day"?r=f(r).addDate(1):e=="hours"?r=f(r).addHours(1):e=="minutes"?r=f(r).addMinutes(1):e=="seconds"&&(r=f(r).addSeconds(1));return i};f.prototype.Time.prototype=f.prototype;var D={},I={set:(e,t)=>{let n=!0;return Object.entries(e).forEach(([i,r])=>{let s=D[i]||{};s&&s.privateKey&&s.privateKey!=t&&(n=!1),D[i]={privateKey:t,value:r}}),n},update:(e,t)=>{let n=!0;return Object.entries(e).forEach(([i,r])=>{var o;let s=D[i]||{};s&&s.privateKey&&s.privateKey!=t&&(n=!1),D[i]=A(M({},D[i]),{value:M(M({},(o=D[i])==null?void 0:o.value),r)})}),n},get:(e,t)=>{let n=D[e];if(!(n&&n.privateKey&&n.privateKey!=t))return n==null?void 0:n.value},delete:(e,t)=>{let n=D[e];return n&&n.privateKey&&n.privateKey!=t?!1:(delete D[e],!0)}};var ae=(...[e,t,n])=>new C.prototype.Interval(e,t,n),C=ae;C.prototype={};var oe=function(...[e,t,n]){return this.fn=e,this.ms=t,this.key=n,C.abort(this.key),this.store(),this};a.extend({key:"",ms:0,timeoutIndex:-1,fn:null,Interval:oe,store:function(){I.set({["Interval_"+this.key]:this})},once:function(){return this.fn&&(this.timeoutIndex=setTimeout(this.fn,this.ms)),this.store(),this},start:function(){return this.fn&&(this.timeoutIndex=setInterval(this.fn,this.ms)),this.store(),this},abort:function(){return C.abort(this.timeoutIndex),this},set_ms:function(e){return this.ms=e,this.store(),this},set_fn:function(e){return this.fn=e,this.store(),this}},C);C.abort=e=>{if(a.is.number(e))return clearInterval(e);let t=I.get("Interval_"+e);t&&clearInterval(t.timeoutIndex)};C.get=e=>I.get("Interval_"+e);C.once=(e,t,n)=>C(e,t,n).once();C.start=(e,t,n)=>C(e,t,n).start();C.prototype.Interval.prototype=C.prototype;var ue=(e,t)=>new c.prototype.Fetcher(e,t),c=ue;c.prototype={};c.waitList=[];c.setDefaultTrafficControl=0;c.setDefaultTimeout=1e3*60*10;c.isReadableStream=e=>e instanceof ReadableStream;c.isReadableStreamReader=e=>e instanceof ReadableStreamDefaultReader;c.streamToContext=(e,t)=>d(void 0,null,function*(){try{let n=(t==null?void 0:t.reader)||e.getReader();if(!c.isReadableStreamReader(n))return{ok:!1,done:!0,data:null};if(!n)return{ok:!1,done:!0,data:null};let i=(t==null?void 0:t.decoder)||new TextDecoder("utf-8"),r=yield n.read();return{ok:!0,done:r.done,data:i.decode(r.value)}}catch(n){return{ok:!1,done:!0,data:n}}});var le=function(e,t){var r;t=t||{};let n=t.body;t.body&&!a.is.string(t.body)&&((r=t.bodyStringify)==null||r)&&(n=a.Stringify(t.body||{}));let i=e;return a.is.string(e)&&!e.match(/https?:/)&&(i=location.origin+"/"+e.replace(/^\//,"")),this.url=i,this.method=t.method||"get",this.streamStatus="open",this.params=A(M({key:x(),response_format:"json",timeout:c.setDefaultTimeout,trafficControl:c.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:M(M({"Content-Type":"application/json"},c.setDefaultHeaders&&c.setDefaultHeaders()),t.headers),body:n}),this};a.extend({Fetcher:le,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:()=>{},onCompleteCB:()=>{},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(e){return this.onStartCB=e,this},onStream:function(e){return this.onStreamCB=e,this},onResult:function(e){return this.onResultCB=e,this},onComplete:function(e){return this.onCompleteCB=e,this},onError:function(e){return this.onErrorCB=e,this},onStreamProcess:function(e){return d(this,null,function*(){let{response:t,errorCB:n,streamCB:i,reader:r,decoder:s}=e,o=t.body,u=this,l=function(){return V(this,null,function*(){if(!t.ok){a.scope(()=>d(this,null,function*(){let{ok:v,done:S,data:E}=yield c.streamToContext(o,{reader:r,decoder:s});v&&n(E)}));return}let m=!1;for(;!m;){let{ok:v,done:S,data:E}=yield new O(c.streamToContext(o,{reader:r,decoder:s}));u.streamStatus=="abort"?(u.streamStatus="closed",r.cancel(),S=!0):u.streamStatus=="closed"&&(S=!0),S&&(m=S,r.releaseLock()),i(E,S)}})};try{for(var h=$(l()),p,g,T;p=!(g=yield h.next()).done;p=!1){let m=g.value;;}}catch(g){T=[g]}finally{try{p&&(g=h.return)&&(yield g.call(h))}finally{if(T)throw T[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return d(this,null,function*(){var T;let e=this.params,t=performance.now(),n=0,i=new AbortController,r=setTimeout(()=>{i.abort()},e.timeout);e.signal=i.signal;let s=!1,o=500,u="InternalServerError",l={},h=null;try{c.setDefaultOnStart&&c.setDefaultOnStart(e),this.onStartCB&&this.onStartCB(e);let g=e,{key:m,response_format:v,trafficControl:S,preventMultiRequest:E,timeout:de,queries:K}=g,H=j(g,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);H.method=this.method;let q=c.waitList.includes(m);if(E&&q)throw o=429,new Error("TooManyRequests");c.waitList=[...c.waitList,m];let W=a.queryParams.set(M({},K),String(this.url));l=yield fetch(W,H).then(w=>d(this,null,function*(){return s=w.ok,o=w.status,u=w.statusText,h=w,v=="none"||v=="stream"?w:w[v]()})).catch(w=>{throw new Error(w)})}catch(m){o==200&&(o=500,s=!1),o==429&&(u="TooManyRequests"),i.signal.aborted&&(o=408,u="Timeout"),o==500&&(u=String(m)||u),l={errorCode:String(m)}}finally{clearTimeout(r),n=performance.now()-t}e.trafficControl&&(yield a.pending(()=>{},e.trafficControl)),c.waitList.splice(c.waitList.findIndex(m=>m==e.key),1);let p={ok:s,status:o,statusText:u,body:l,requestTime:n,rawData:h};if(!s&&this.onErrorCB&&this.onErrorCB(p.body),s&&this.onStreamCB&&e.response_format=="stream"){let m=(T=h.body)==null?void 0:T.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:p,reader:m,decoder:new TextDecoder("utf-8")})}return s&&this.onCompleteCB&&this.onCompleteCB(p.body),this.onResultCB&&this.onResultCB(p,e),c.setDefaultOnEnd&&c.setDefaultOnEnd(p,e),p})},abortStream:function(){this.streamStatus="abort"}},c);c.prototype.Fetcher.prototype=c.prototype;var he=e=>new b.prototype.Filer(e),b=he;b.prototype={};var me=function(e){this.ok=!0;try{let[t,n]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=n,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this};a.extend({ok:!1,extension:"",type:"",file:{},fileName:"",Filer:me,isValid:function(){return this.ok},toBlob:function(){return d(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("dataURL")).target)==null?void 0:t.result})},toAarrayBuffer:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("arrayBuffer")).target)==null?void 0:t.result})},toObjectURL:function(){return d(this,null,function*(){return URL.createObjectURL(this.file)})},updateFileName:function(e){let t=new File([this.file],e+"."+this.extension);return this.file=t,this.fileName=e,this},updateMimeType:function(e){return this.file=new File([this.file],this.fileName+"."+this.extension,{type:e}),this.type=e,this},updateExtension:function(e){let t=new File([this.file],this.fileName+"."+e);return this.file=t,this.extension=e,this}},b);b.fromFile=e=>d(void 0,null,function*(){return b(e)});b.fromBlob=(e,t)=>d(void 0,null,function*(){let n=(t==null?void 0:t.fileName)||"file",i=(t==null?void 0:t.extension)||"",r=new File([e],n+"."+i,{type:t==null?void 0:t.mimeType});return b(r)});b.fromArrayBuffer=(e,t)=>d(void 0,null,function*(){return b.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t)});b.fromObjectURL=(e,t)=>d(void 0,null,function*(){let n=yield c(e,{response_format:"blob"}).get();return n.ok?b.fromBlob(n.body,t):b({})});b.fromDataURL=(e,t)=>d(void 0,null,function*(){let n=yield e.toBlob((t==null?void 0:t.mimeType)||"");return n?b.fromBlob(n,t):b({})});b.prototype.Filer.prototype=b.prototype;var fe=function(e){let t=e,n=null;return t.use((i,r,s)=>{let o=r;o.return=u=>{let{status:l=200,body:h={},bodyStringify:p=!0}=u||{},g=h;return p&&!a.is.string(h)&&(g=a.Stringify(h)),r.status(l).end(g)},s()}),t.onPathRouter=function(i){return n=i,this},t.pathRouter=function(i){if(!n)return;let r=n(i);return r.route(i),t.use(i,r),r},t.exception=function(i){return t.use(i),this},t},L=fe;L.getLocalIP=e=>{let t="";return a.scope(()=>{if(!e)return;let n=e.networkInterfaces();for(let[i,r]of Object.entries(n))r.forEach(s=>{!s.internal&&s.family==="IPv4"&&!s.address.match(/^(169|127)/)&&(t=s.address)})}),t};L.getIP=function(e){var i;return(((e==null?void 0:e.headers["x-forwarded-for"])||((i=e==null?void 0:e.socket)==null?void 0:i.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};a.copyToClipboard=e=>d(void 0,null,function*(){let t="";a.is.string(e)?t=e:a.is.function(e)&&(t=e());let n={ok:!1,body:"NotSupported"};return yield d(void 0,null,function*(){let i;if(navigator.clipboard){if(i=yield navigator.clipboard.writeText(t).then(()=>!0,()=>!1),!i)return}else{let r=document.createElement("input");if(a(document.body).append(r),r.value=t,r.select(),i=document.execCommand("copy"),document.body.removeChild(r),!i)return}n={ok:!0,body:""}}),n});a.ImageLoader=(e,t)=>new Promise((n,i)=>{let r=t||new Image;r.onload=()=>n(r),r.onerror=s=>i(s),r.src=e});a.formatCharacter={postal:{JP:e=>{let t="--";return e=String(e).replace(/\D/ig,""),e.length==7&&(t=e.replace(/^(\d{3})(.*)/,"$1-$2")),t}},tel:{_:e=>{let t=e;return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t},mobile:e=>{let t="--";return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),t},fixed:e=>{let t="--";return e=String(e).removeLetters(),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t}}};a.transformer={weekday:{JP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]+"\u66DC\u65E5",shortJP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]},wareki:e=>{let t=[],n=[],i=!1;return[{From:1868,To:1912,name:"\u660E\u6CBB"},{From:1912,To:1926,name:"\u5927\u6B63"},{From:1926,To:1989,name:"\u662D\u548C"},{From:1989,To:2019,name:"\u5E73\u6210"},{From:2019,To:1e5,name:"\u4EE4\u548C"}].forEach(s=>{let{From:o,To:u,name:l}=s;if(o<=e&&e<=u){let h=e-o+1;h==1&&(i=!0,h="\u5143"),n.push(l+h+"\u5E74"),t.push(l)}}),{era:t,value:n,gap:i}}};a.interval=C;c.setDefaultHeaders=()=>({});var ce=a;0&&(module.exports={Fetcher,Filer,Server,Time,UUID,useStore});
|
|
1
|
+
"use strict";var k=Object.defineProperty,_=Object.defineProperties,z=Object.getOwnPropertyDescriptor,X=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var B=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var F=Math.pow,Y=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))J.call(t,n)&&Y(e,n,t[n]);if(P)for(var n of P(t))j.call(t,n)&&Y(e,n,t[n]);return e},A=(e,t)=>_(e,X(t));var U=(e,t)=>{var n={};for(var i in e)J.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&P)for(var i of P(e))t.indexOf(i)<0&&j.call(e,i)&&(n[i]=e[i]);return n};var Q=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},Z=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!J.call(e,r)&&r!==n&&k(e,r,{get:()=>t[r],enumerable:!(i=z(t,r))||i.enumerable});return e};var ee=e=>Z(k({},"__esModule",{value:!0}),e);var d=(e,t,n)=>new Promise((i,r)=>{var s=l=>{try{u(n.next(l))}catch(h){r(h)}},o=l=>{try{u(n.throw(l))}catch(h){r(h)}},u=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,o);u((n=n.apply(e,t)).next())}),O=function(e,t){this[0]=e,this[1]=t},V=(e,t,n)=>{var i=(o,u,l,h)=>{try{var p=n[o](u),g=(u=p.value)instanceof O,T=p.done;Promise.resolve(g?u[0]:u).then(m=>g?i(o==="return"?o:"next",u[1]?{done:m.done,value:m.value}:m,l,h):l({value:m,done:T})).catch(m=>i("throw",m,l,h))}catch(m){h(m)}},r=o=>s[o]=u=>new Promise((l,h)=>i(o,u,l,h)),s={};return n=n.apply(e,t),s[B("asyncIterator")]=()=>s,r("next"),r("throw"),r("return"),s};var K=(e,t,n)=>(t=e[B("asyncIterator")])?t.call(e):(e=e[B("iterator")](),t={},n=(i,r)=>(r=e[i])&&(t[i]=s=>new Promise((o,u,l)=>(s=r.call(e,s),l=s.done,Promise.resolve(s.value).then(h=>o({value:h,done:l}),u)))),n("next"),n("return"),t);var pe={};Q(pe,{Fetcher:()=>c,Filer:()=>b,Server:()=>L,Time:()=>f,UUID:()=>x,default:()=>ce,useStore:()=>I});module.exports=ee(pe);typeof HTMLElement!="undefined"&&(HTMLElement.prototype.position=function(){return this.getBoundingClientRect()});typeof String!="undefined"&&(String.prototype.compress=function(){return this.trim().replace(/(\s|\n|\t)/ig,"")},String.prototype.encode=function(){return encodeURIComponent(this)},String.prototype.decode=function(){return decodeURIComponent(this)},String.prototype.toUpper=function(){return this.toLocaleUpperCase()},String.prototype.toLower=function(){return this.toLocaleLowerCase()},String.prototype.toCapital=function(){let e=this;return e&&(e=e.replace(/^./,this[0].toUpper()).replace(/(\s|_|-)[a-z]{1}/ig,t=>t[1].toUpper())),e},String.prototype.clip=function(e,t){return this.slice(e,t)},String.prototype.partReplace=function(e,t){return this.slice(0,e)+t+this.slice(e+t.length)},String.prototype.toBlob=function(e){let t=atob(this.replace(/^.*,/,"")),n=new Uint8Array(t.length);for(var i=0;i<t.length;i++)n[i]=t.charCodeAt(i);try{var r=new Blob([n.buffer],{type:e})}catch(s){return!1}return r},String.prototype.toNumber=function(){return Number(this.removeLetters())},String.prototype.removeLetters=function(){return this.replace(/[\D]/ig,"")},String.prototype.removeSpecifics=function(){return this.replace(/[^\w\s\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]|_/uig,"")},String.prototype.removeJP=function(){return this.replace(/[\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Han}]+/uig,"")},String.prototype.zen2hanNumber=function(){return this.replace(/[0-9]/g,function(e){return String.fromCharCode(e.charCodeAt(0)-65248)}).replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g,"-").replace(/¥/,"\xA5").replace(/、/,",").replace(/(/,"(").replace(/)/,")").replace(/+/,"+")});typeof Number!="undefined"&&(Number.prototype.zeroEmbed=function(e){return String(this).padStart(e||2,"0")},Number.prototype.ratio=function(e,t=2){let n=F(10,t);return Math.round(this/e*n*100)/n},Number.prototype.rate=function(e,t=2){let n=F(10,t);return Math.round(this/e*n)/n},Number.prototype.rank=function(e=1){let t=F(10,e),n=Number(this),i=n.toLocaleString().replace(/\d/ig,"").length;return Math.round(n/F(1e3,i)*t)/t+("KMGTPEZY"[i-1]||"")},Number.prototype.rankJp=function(){let e=Number(this),t="";return e>=1e12?t=`${e/1e12}\u5146`:e>=1e8?t=`${e/1e8}\u5104`:e>=1e4?t=`${e/1e4}\u4E07`:e>=1e3?t=`${e/1e3}\u5343`:t=`${e.toLocaleString()}`,t},Number.prototype.toDate=function(e="/"){let t=String(this),n=t.slice(0,4),i=t.slice(4,6),r=t.slice(6,8),s=[];return n.length!=4||s.push(n),i.length!=2||s.push(i),r.length!=2||s.push(r),s.join(e)});if(typeof Array!="undefined"){let e=(t,n)=>{var r;let i=t;for(let s of n){if(!s)break;i=(r=(i||{})[s||""])!=null?r:null}return i};Array.prototype.toASC=function(...t){return(!t||!(t!=null&&t.length))&&(t=[""]),this.sort((n,i)=>{for(let r of t){r=r||"";let s=this.every(l=>{let h=Number(e(l,r.split(".")));return typeof h=="number"&&!isNaN(h)}),o=e(n,r.split(".")),u=e(i,r.split("."));if(s){if(o=Number(o),u=Number(u),o>u)return 1;if(o<u)return-1}else{if(o=String(o).replace(/(\d+)/g,l=>l.padStart(18,"0")),u=String(u).replace(/(\d+)/g,l=>l.padStart(18,"0")),o>u)return 1;if(o<u)return-1}}return 0})},Array.prototype.toDESC=function(...t){return this.toASC(...t).reverse()}}typeof File!="undefined"&&(File.prototype.convert=function(e){return e=e||"dataURL",new Promise((t,n)=>{let i=new FileReader;i.onload=s=>t(s),i.onerror=s=>n(s);let r="readAs"+(e==null?void 0:e.toCapital());i[r](this)})});var te=(e=24)=>Array.from({length:e}).map((t,n)=>{let i=n==0?25:35,r=Math.round(Math.random());return"abcdefghijkrmnopqrstuvwxyz0123456789"[Math.round(Math.random()*i)][r?"toUpper":"toLower"]()}).join(""),x=te;x.gen128Binary=()=>Array.from({length:128}).map((e,t)=>"01"[Math.round(Math.random()*1)]).join("");x.gen32Hex=(e="Formatted",t="-")=>{let n=Array.from({length:32}).map((i,r)=>"0123456789abcdef"[Math.round(Math.random()*15)]).join("").toUpper();return e=="Formatted"&&(n=[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20,32)].join(t)),n};x.to32Format=e=>[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-").toUpper();var re=e=>new a.prototype.jmini(e),a=re;a.prototype={};a.extend=function(e,t=a){for(var[n,i]of Object.entries(e))t.prototype[n]=i};a.expando="__jmini_"+x();var y=(e,t)=>(e.queue.push(t),N(e),e),N=e=>d(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let t=e.queue.shift();t&&(yield t()),e.queueProcess=!1,N(e)}}),E=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=null;for(let[n,i]of Object.entries(t))n.match(/queue/)||(e[n]=i);return e},ne=(e,t)=>{if(t.length){for(var n=0;n<t.length;n++){let i=t[n];i&&(i[a.expando]||(a.is.element(i)||a.is.shadowRoot(i))&&(i[a.expando]={events:{}})),e[n]=i}e.length=t.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,N(e),e};a.extend({constructor:a,jmini:function(e){return this.src=e,this.srcType=a.is.what(e),this.queueProcess=!0,this.queue=[],ne(this,a.is.jmini(e)?e.get():a.is.element(e)?[e]:a.is.elements(e)?e:a.is.shadowRoot(e)?[e]:a.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}});a.prototype[String(Symbol.iterator)]=[][Symbol.iterator];a.prototype.jmini.prototype=a.prototype;{let e=function(r,s,o){let u=[];for(let l=0;l<(r.length||0);l++)u.push(s(r[l],l));return o&&(u=u.filter(l=>l!=null)),u},t=r=>(r.for((s,o)=>{if(!(a.is.element(s)||a.is.shadowRoot(s)))return;let u=s.cloneNode(),l=s.parentNode;l&&l.replaceChild(u,s),r[o]=u}),r),n=(r,s)=>(a(s).for(o=>{if(r&&(a.is.element(o)||a.is.shadowRoot(o)))if(a.is.string(r)||a.is.number(r))r=String(r),o.insertAdjacentHTML("beforeend",String(r));else if(a.is.element(r))o.appendChild(r);else{a.is.jmini(r)?r=r.get():a.is.element(r)?r=[r]:a.is.keyValueDictionary(r)&&(r=[a(r)]);for(var u=0;u<r.length;u++)n(r[u],o)}}),s),i=(r,s,...o)=>{let{p:u,s:l}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[s]||{p:"",s:""};return r.for(h=>{if(a.is.string(o[0]))h.insertAdjacentHTML(u,o[0]);else{if(!h.parentNode)return;a(o[0]).for(g=>{o[1]&&(g=g.cloneNode(!0)),h.parentNode.insertBefore(g,h[l]||h)})}}),r};a.extend({get:function(r){return r?this[0]:e(this,s=>s)},for:function(r,s=1){let o=e(this,(u,l)=>r(u,l),1);return s?o:[]},await:function(r){return y(this,()=>new Promise((s,o)=>{setTimeout(()=>{s(this)},r)}))},abort:function(){return y(this,()=>d(this,null,function*(){return this.queue=[],this}))},callback:function(r){return y(this,()=>d(this,null,function*(){return yield r(this),this}))},click:function(){return y(this,()=>{for(var r=0;r<this.length;r++){let s=this[r];a.is.element(s)&&s.click()}return this})},focus:function(){return y(this,()=>{for(var r=0;r<this.length;r++){let s=this[r];a.is.element(s)&&s.focus()}return this})},addEvent:function(r){return y(this,()=>{let{eventType:s,eventID:o=x(),target:u,callback:l,options:h}=r;return h=M({passive:!0,capture:!1},h),this.for(p=>{if(!(a.is.element(p)||a.is.shadowRoot(p)))return;let{events:g}=p[a.expando];if(u){let T=l;l=m=>{if(m.target){if(a.is.string(u)){let S=m.target.closest(u);S&&(!S||T.call(S,m))}else if(a.is.elements(u)){for(let v of u)if(m.target==v)return T.call(v,m)}}}}if(g[o]){let T=g[o];p.removeEventListener(T.eventType,T.callback,T.options)}g[o]={eventType:s,callback:l,options:h},p.addEventListener(s,l,h)}),this})},removeEvent:function(r){return y(this,()=>{let s=a.is.array(r)?r:[r];return this.for(o=>{let{events:u}=o[a.expando];for(let l of s){let h=u[l];h&&o.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(r){return y(this,()=>E(this,n(r,t(this))))},empty:function(){return y(this,()=>E(this,t(this)))},append:function(r){return y(this,()=>{n(r,this)})},remove:function(){return y(this,()=>(this.for((r,s)=>{r&&a.is.element(r)&&(r.remove(),delete this[s])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...r){return y(this,()=>E(this,i(this,"before",...r)))},after:function(...r){return y(this,()=>E(this,i(this,"after",...r)))},find:function(r){return y(this,()=>{let s=[],o=this[0];o||E(this,a()),(a.is.element(o)||a.is.shadowRoot(o))&&(a.is.string(r)?s=o.querySelectorAll(r):a.is.element(o)&&a(r).for(u=>{let l=o.childNodes;for(let h of l)if(h===u){s.push(h);break}else h.childNodes.length&&(s=[...s,...a(h).find(u).for(p=>p)])})),E(this,a(s))})},parent:function(r){return y(this,()=>{var o,u;let s=a(r?(o=this[0])==null?void 0:o.closest(r):(u=this[0])==null?void 0:u.parentNode);E(this,s)})},children:function(r){return y(this,()=>{let s=this[0].children;a.is.exist(r)&&(r=String(r).replace(/^ : /,""),s=r=="first"?s[0]:r=="last"?s[s.length-1]:s[Number(r)]);let o=a(s);return E(this,o)})},addClass:function(r){return y(this,()=>(r&&this.for(s=>{let o=a.is.string(r)?r.split(" "):r;s&&a.is.element(s)&&s.classList.add(...o)}),this))},removeClass:function(r){return y(this,()=>(r&&this.for(s=>{let o=a.is.string(r)?r.split(" "):r;s&&a.is.element(s)&&s.classList.remove(...o)}),this))},toggleClass:function(r){return y(this,()=>(r&&this.for(s=>{s.classList.toggle(r)}),this))},hasClass:function(r=""){if(this[0])return this[0].classList.contains(r.replace(/^\./,""))},findClass:function(r){let s=[];return this[0]&&(s=[...this[0].classList].filter(o=>o.match(r))),s},css:function(r){return y(this,()=>(this.for(s=>{if(a.is.element(s))for(let[o,u]of Object.entries(r)){if(a.is.number(u)&&o.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){s.style[o]=u+"px";continue}s.style[o]=String(u)}}),this))},getAttribute:function(r){return this[0].getAttribute(String(r))},setAttribute:function(r,s){return y(this,()=>(this.for(o=>o.setAttribute(r,s)),this))},getStyleProperty:function(r){let s=this[0];return s&&a.is.element(s)?getComputedStyle(s).getPropertyValue(r):""},setStyleProperty:function(r,s){let o=this[0];return o&&a.is.element(o)&&o.style.setProperty(r,s),this},val:function(){var s;let r=this[0];return(r==null?void 0:r.value)||((s=r==null?void 0:r.dataset)==null?void 0:s.value)},position:function(){return a.is.element(this[0])?this[0].getBoundingClientRect():{}}})}a.flatArray=(e,t)=>{if(!a.is.array(e))return[e];let n=[];for(let i of e)n.push(...t=="-R"?a.flatArray(i,"-R"):[i]);return n};a.uniqueArray=(e,t)=>{let n=e;return t?n=Array.from(new Map(e.map(i=>[a.getKeyValue(i,t||"0"),i])).values()):n=Array.from(new Set(e)),n};a.getKeyValue=(e,t)=>{let n={},i=e;return t.split(".").forEach(r=>{i=i==null?void 0:i[r],n=i}),n};a.Stringify=JSON.stringify;a.Objectify=(e,t)=>{try{return JSON.parse(e)}catch(n){return t!=null?t:null}};a.randomNumber=(e=0,t=100,n)=>{if(e>t)return NaN;let i=[],r=e;for(;r<=t;){if(n&&n.length&&n.includes(r)){r++;continue}i.push(r),r++}let s=Math.round(Math.random()*(i.length-1))+0;return i[s]};a.try=e=>{try{return[e(),!0]}catch(t){return[t,!1]}};a.trySync=e=>d(void 0,null,function*(){try{return[yield e(),!0]}catch(t){return[t,!1]}});a.scope=e=>e();a.scopeSync=e=>d(void 0,null,function*(){return yield e()});a.createElement=function(e){var g;let{tag:t,className:n="",id:i,html:r,attr:s,style:o,parent:u}=e,l=document.createElement(t||"div");if(n&&l.classList.add(...n.split(" ")),i&&(l.id=i),s)for(let T of Object.entries(s)){let m=T[0],v=(g=T[1])!=null?g:"";if(m=="data"&&a.is.keyValueDictionary(v))for(let[S,R]of Object.entries(v))l.dataset[S]=R;else m=="for"?m="htmlFor":m=="tabindex"?m="tabIndex":m=="aria-label"&&(m="ariaLabel"),l[m]=v}if(r&&a(l).append(r),o)for(var[h,p]of Object.entries(o))l.style[h]=p;return u&&a(u).append(l),l};a.setCookie=e=>{let{hostname:t}=new URL(location.toString()),{name:n,value:i="",age:r=60*60*24*365,path:s="/",domain:o=t,secure:u=!1}=e,l=`${n}=${i}max-age=${r}path=${s}domain=${o}`;u&&(l+=" Secure"),document.cookie=l};a.getCookie=e=>{let t=document.cookie.match(new RegExp(e+"=[^]*"));return t?t[0].replace(new RegExp(e+"="),""):""};a.localStrage={set:(e,t)=>{localStorage.setItem(e,a.Stringify(t))},get:e=>{let t=localStorage.getItem(e);return a.Objectify(t,t)}};a.deleteCookie=e=>{document.cookie=e+"=max-age=0"};a.getScreenSize=()=>{let{innerHeight:e,innerWidth:t,scrollY:n,scrollX:i,pageXOffset:r,pageYOffset:s}=window,o=Number(a(document.body).getStyleProperty("--sat").removeLetters()),u=Number(a(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:t,pageHeight:e-o-u,scrollY:n,scrollX:i,pageXOffset:r,pageYOffset:s,safeAreaTop:o,safeAreaBottom:u}};a.getCursor=e=>{var i,r,s,o,u,l,h,p;let t=(o=e.pageX)!=null?o:(s=(i=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:i.pageX)!=null?s:(((r=e==null?void 0:e.originalEvent)==null?void 0:r.touches)||[])[0].pageX,n=(p=e.pageY)!=null?p:(h=(u=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:u.pageY)!=null?h:(((l=e==null?void 0:e.originalEvent)==null?void 0:l.touches)||[])[0].pageY;return{x:t,y:n}};a.pending=(e,t)=>new Promise((n,i)=>{e(n),t&&setTimeout(()=>{n(!0)},t)});a.deepMerge=(e,...t)=>{if(!t.length)return e;let n=t.shift();if(a.is.keyValueDictionary(e)&&a.is.keyValueDictionary(n))for(let i in n)a.is.keyValueDictionary(n[i])?(e[i]||Object.assign(e,{[i]:{}}),a.deepMerge(e[i],n[i])):Object.assign(e,{[i]:n[i]});return a.deepMerge(e,...t)};a.deepCopy=e=>{if(a.is.array(e))return e.map(t=>a.deepCopy(t));if(a.is.keyValueDictionary(e)){let t={};return Object.entries(e).forEach(([n,i])=>{t[n]=a.deepCopy(i)}),t}return e};a.queryParams={get:e=>{let t=new URL(e||location.href),n={};return t.searchParams.forEach((i,r)=>n[r]=i),n},set:(e,t)=>{let n=new URL(t||location.href);return Object.entries(e).forEach(([i,r])=>{n.searchParams.set(i,String(r))}),t||history.replaceState({},"",n.pathname+n.search),n.toString()},delete:(e,t)=>{let n=new URL(t||location.href);return e.forEach(i=>{n.searchParams.delete(i)}),t||history.replaceState({},"",n.pathname+n.search),n.toString()}};a.ellipsisText=(e,t)=>{let n=String(e);return n.length>t&&(n=n.slice(0,t)+" ..."),n};a.is={equal:function(e,t,n){return n==null||n?a.Stringify(e)===a.Stringify(t):e===t},what:function(e){let t="other";return this.jmini(e)?t="jmini":this.element(e)?t="element":this.elements(e)?t="elements":this.shadowRoot(e)?t="shadowRoot":this.string(e)?t="string":this.number(e)?t="number":this.array(e)?t="array":this.function(e)?t="function":this.date(e)?t="date":typeof e=="undefined"?t="undefined":this.keyValueDictionary(e)?t="keyValueDictionary":e==null?t="null":isNaN(e)&&(t="NaN"),t},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini:function(e){return(e||{}).constructor===a},string:function(e){return typeof e=="string"},boolean:function(e){return typeof e=="boolean"},number:function(e){return!isNaN(e)&&typeof e=="number"},array:function(e){let t={}.toString.call(e);return e instanceof Array||t=="[object NodeList]"||t=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jmini(e)},element:function(e){return e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e))},elements:function(e){let t={}.toString.call(e),n=Number(!!e&&typeof e!="string"&&this.array(e)&&t!=="[object Text]");if(n&&t!=="[object NodeList]")for(var i of e)n&=Number(this.element(i));return!!n},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};var ie=e=>new f.prototype.Time(e),f=ie;f.prototype={};var se=function(e){f.isTimeObject(e)&&(e=e.value),e||(e===null?e=void 0:e===void 0&&(e=new Date));let t=new Date(e);return this.set(t)};a.extend({value:new Date,validate:!1,ms:-1,weekday:-1,weekInMonth:-1,weekInYear:-1,isLastWeekInMonth:!1,year:-1,month:-1,date:-1,hours:-1,minutes:-1,seconds:-1,constructor:f,Time:se,clone:function(){return f(this)},set:function(e){this.value=e;let t=a.is.date(e);if(this.validate=t,!t)return this.ms=-1,this.year=-1,this.month=-1,this.weekday=-1,this.weekInYear=-1,this.date=-1,this.hours=-1,this.minutes=-1,this.seconds=-1,this;this.ms=e.getTime(),this.weekday=e.getDay(),this.year=e.getFullYear(),this.month=e.getMonth()+1,this.date=e.getDate();{let n=new Date(this.year,0,1),i=new Date(n.valueOf());i.setDate(i.getDate()-(n.getDay()+1));let r=e.getTime()-i.getTime(),s=Math.ceil(r/(1e3*60*60*24));this.weekInYear=Math.ceil(s/7)}{let n=new Date(this.year,this.month-1,1),i=new Date(n.valueOf());i.setDate(i.getDate()-(n.getDay()+1));let r=e.getTime()-i.getTime(),s=Math.ceil(r/(1e3*60*60*24)),o=Math.ceil(s/7);this.weekInMonth=o}{let n=new Date(this.year,this.month,0),i=n.getDay(),r=new Date(new Date(n).setDate(n.getDate()-i));this.isLastWeekInMonth=this.date>=r.getDate()}return this.hours=e.getHours(),this.minutes=e.getMinutes(),this.seconds=e.getSeconds(),this},isSameYear:function(e){let t=f(e);return this.year==t.year},isSameMonth:function(e){let t=f(e);return this.year==t.year&&this.month==t.month},isSameWeek:function(e){let t=f(e);return this.year==t.year&&this.weekInYear==t.weekInYear},isSameDate:function(e){let t=f(e);return this.year==t.year&&this.month==t.month&&this.date==t.date},setYear:function(e){let t=new Date(this.value.valueOf());return t.setFullYear(e),this.set(t)},setMonth:function(e){let t=new Date(this.value.valueOf());return t.setMonth(e-1),this.set(t)},setDate:function(e){let t=new Date(this.value.valueOf());return t.setDate(e),this.set(t)},setHours:function(e){let t=new Date(this.value.valueOf());return t.setHours(e),this.set(t)},setMinutes:function(e){let t=new Date(this.value.valueOf());return t.setMinutes(e),this.set(t)},setSeconds:function(e){let t=new Date(this.value.valueOf());return t.setSeconds(e),this.set(t)},setMilliseconds:function(e){let t=new Date(this.value.valueOf());return t.setMilliseconds(e),this.set(t)},addYear:function(e){return this.setYear(this.year+e)},addMonth:function(e){return this.setMonth(this.month+e)},addWeek:function(e){return this.addDate(7*e)},addDate:function(e){return this.setDate(this.date+e)},addHours:function(e){return this.setHours(this.hours+e)},addMinutes:function(e){return this.setMinutes(this.minutes+e)},addSeconds:function(e){return this.setSeconds(this.seconds+e)},toFormat:function(e){return this.validate?e.replace(/\%y/ig,this.year.zeroEmbed(4)).replace(/\%m/ig,this.month.zeroEmbed(2)).replace(/\%d/ig,this.date.zeroEmbed(2)).replace(/\%w/ig,this.weekInYear.zeroEmbed(2)).replace(/\%h/ig,this.hours.zeroEmbed(2)).replace(/\%i/ig,this.minutes.zeroEmbed(2)).replace(/\%s/ig,this.seconds.zeroEmbed(2)):""},toFormatYMD:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5"):this.toFormat("%Y/%M/%D"):""},toFormatYM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708"):this.toFormat("%Y/%M"):""},toFormatMD:function(e){return this.validate?e=="JP"?this.toFormat("%M\u6708%D\u65E5"):this.toFormat("%M/%D"):""},toFormatHM:function(e){return this.validate?e=="JP"?this.toFormat("%h\u6642%m\u5206"):this.toFormat("%h:%i"):""},toFormatYMDHM:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206"):this.toFormat("%Y/%M/%D %h:%i"):""},toFormatYMDHMS:function(e){return this.validate?e=="JP"?this.toFormat("%Y\u5E74%M\u6708%D\u65E5%h\u6642%m\u5206%s\u79D2"):this.toFormat("%Y/%M/%D %h:%i:%s"):""},setFirstOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),this.set(e)},setLastOfTheDay:function(){let e=new Date(this.value.valueOf());return e.setHours(23),e.setMinutes(59),e.setSeconds(59),e.setMilliseconds(999),this.set(e)},getFirstDayOfTheYear:function(){return f(new Date(this.value.getFullYear(),0,1))},getLastDayOfTheYear:function(){return f(new Date(this.value.getFullYear()+1,0,0))},getFirstDayOfTheMonth:function(){return f(new Date(this.value.getFullYear(),this.month-1,1))},getLastDayOfTheMonth:function(){return f(new Date(this.value.getFullYear(),this.month,0))},getFirstDayOfTheWeek:function(){let e=f(this.value);return e.addDate(-e.weekday)},getLastDayOfTheWeek:function(){let e=f(this.value);return e.addDate(6-e.weekday)},diff:function(e){let t=this.ms-e.ms;return{years:this.year-e.year,months:(this.year-e.year)*12+(this.month-e.month),dates:Math.floor(t/(60*60*24*1e3)),hours:Math.floor(t/(60*60*1e3)),minutes:Math.floor(t/(60*1e3)),seconds:Math.floor(t/1e3)}},getAge:function(e){let t=e||f(),n=t.year-this.year;return(this.month>t.month||this.month==t.month&&t.date<this.date)&&n--,n}},f);f.isTimeObject=e=>{var t;return((t=e||{})==null?void 0:t.constructor)===f};f.getFromNumberYYYYMMDD=e=>{let t=String(e).replace(/(\d{4})(\d{2})(\d{2})/,"$1/$2/$3");return f(t+" 00:00")};f.getShortYMDs=(e,t)=>{let n="",i="";return e.year==t.year&&e.year==f().year?n=e.toFormatMD():n=e.toFormatYMD(),e.year!=t.year?i=t.toFormatYMD():i=t.toFormatMD(),[n,i]};f.getPeriodArray=(e,t,n)=>{let i=[],r=t;if(!t.validate||!n.validate)return i;for(;r.toFormatYMDHMS().toNumber()<=n.toFormatYMDHMS().toNumber();)i.push(r),e=="year"?r=f(r).addYear(1):e=="month"?r=f(r).addMonth(1):e=="week"?r=f(r).addWeek(1):e=="day"?r=f(r).addDate(1):e=="hours"?r=f(r).addHours(1):e=="minutes"?r=f(r).addMinutes(1):e=="seconds"&&(r=f(r).addSeconds(1));return i};f.prototype.Time.prototype=f.prototype;var D={},I={set:(e,t)=>{let n=!0;return Object.entries(e).forEach(([i,r])=>{let s=D[i]||{};s&&s.privateKey&&s.privateKey!=t&&(n=!1),D[i]={privateKey:t,value:r}}),n},update:(e,t)=>{let n=!0;return Object.entries(e).forEach(([i,r])=>{var o;let s=D[i]||{};s&&s.privateKey&&s.privateKey!=t&&(n=!1),D[i]=A(M({},D[i]),{value:M(M({},(o=D[i])==null?void 0:o.value),r)})}),n},get:(e,t)=>{let n=D[e];if(!(n&&n.privateKey&&n.privateKey!=t))return n==null?void 0:n.value},delete:(e,t)=>{let n=D[e];return n&&n.privateKey&&n.privateKey!=t?!1:(delete D[e],!0)}};var ae=(...[e,t,n])=>new C.prototype.Interval(e,t,n),C=ae;C.prototype={};var oe=function(...[e,t,n]){return this.fn=e,this.ms=t,this.key=n,C.abort(this.key),this.store(),this};a.extend({key:"",ms:0,timeoutIndex:-1,fn:null,Interval:oe,store:function(){I.set({["Interval_"+this.key]:this})},once:function(){return this.fn&&(this.timeoutIndex=setTimeout(this.fn,this.ms)),this.store(),this},start:function(){return this.fn&&(this.timeoutIndex=setInterval(this.fn,this.ms)),this.store(),this},abort:function(){return C.abort(this.timeoutIndex),this},set_ms:function(e){return this.ms=e,this.store(),this},set_fn:function(e){return this.fn=e,this.store(),this}},C);C.abort=e=>{if(a.is.number(e))return clearInterval(e);let t=I.get("Interval_"+e);t&&clearInterval(t.timeoutIndex)};C.get=e=>I.get("Interval_"+e);C.once=(e,t,n)=>C(e,t,n).once();C.start=(e,t,n)=>C(e,t,n).start();C.prototype.Interval.prototype=C.prototype;var ue=(e,t)=>new c.prototype.Fetcher(e,t),c=ue;c.prototype={};c.waitList=[];c.setDefaultTrafficControl=0;c.setDefaultTimeout=1e3*60*10;c.isReadableStream=e=>e instanceof ReadableStream;c.isReadableStreamReader=e=>e instanceof ReadableStreamDefaultReader;c.streamToContext=(e,t)=>d(void 0,null,function*(){try{let n=(t==null?void 0:t.reader)||e.getReader();if(!c.isReadableStreamReader(n))return{ok:!1,done:!0,data:null};if(!n)return{ok:!1,done:!0,data:null};let i=(t==null?void 0:t.decoder)||new TextDecoder("utf-8"),r=yield n.read();return{ok:!0,done:r.done,data:i.decode(r.value)}}catch(n){return{ok:!1,done:!0,data:n}}});var le=function(e,t){var r;t=t||{};let n=t.body;t.body&&!a.is.string(t.body)&&((r=t.bodyStringify)==null||r)&&(n=a.Stringify(t.body||{}));let i=e;return a.is.string(e)&&!e.match(/https?:/)&&(i=location.origin+"/"+e.replace(/^\//,"")),this.url=i,this.method=t.method||"get",this.streamStatus="open",this.params=A(M({key:x(),response_format:"json",timeout:c.setDefaultTimeout,trafficControl:c.setDefaultTrafficControl,preventMultiRequest:!0},t),{headers:M(M({"Content-Type":"application/json"},c.setDefaultHeaders&&c.setDefaultHeaders()),t.headers),body:n}),this};a.extend({Fetcher:le,params:{},url:"",method:"GET",streamStatus:"closed",onStartCB:()=>{},onCompleteCB:()=>{},onErrorCB:()=>{},onResultCB:()=>{},onStreamCB:()=>{},onStart:function(e){return this.onStartCB=e,this},onStream:function(e){return this.onStreamCB=e,this},onResult:function(e){return this.onResultCB=e,this},onComplete:function(e){return this.onCompleteCB=e,this},onError:function(e){return this.onErrorCB=e,this},onStreamProcess:function(e){return d(this,null,function*(){let{response:t,errorCB:n,streamCB:i,reader:r,decoder:s}=e,o=t.body,u=this,l=function(){return V(this,null,function*(){if(!t.ok){a.scope(()=>d(this,null,function*(){let{ok:v,done:S,data:R}=yield c.streamToContext(o,{reader:r,decoder:s});v&&n(R)}));return}let m=!1;for(;!m;){let{ok:v,done:S,data:R}=yield new O(c.streamToContext(o,{reader:r,decoder:s}));u.streamStatus=="abort"?(u.streamStatus="closed",r.cancel(),S=!0):u.streamStatus=="closed"&&(S=!0),S&&(m=S,r.releaseLock()),i(R,S)}})};try{for(var h=K(l()),p,g,T;p=!(g=yield h.next()).done;p=!1){let m=g.value;;}}catch(g){T=[g]}finally{try{p&&(g=h.return)&&(yield g.call(h))}finally{if(T)throw T[0]}}})},get:function(){return this.method="GET",this.send()},head:function(){return this.method="HEAD",this.send()},post:function(){return this.method="POST",this.send()},put:function(){return this.method="PUT",this.send()},delete:function(){return this.method="DELETE",this.send()},patch:function(){return this.method="PATCH",this.send()},options:function(){return this.method="OPTIONS",this.send()},send:function(){return d(this,null,function*(){var T;let e=this.params,t=performance.now(),n=0,i=new AbortController,r=setTimeout(()=>{i.abort()},e.timeout);e.signal=i.signal;let s=!1,o=500,u="InternalServerError",l={},h=null;try{c.setDefaultOnStart&&c.setDefaultOnStart(e),this.onStartCB&&this.onStartCB(e);let g=e,{key:m,response_format:v,trafficControl:S,preventMultiRequest:R,timeout:de,queries:$}=g,H=U(g,["key","response_format","trafficControl","preventMultiRequest","timeout","queries"]);H.method=this.method;let q=c.waitList.includes(m);if(R&&q)throw o=429,new Error("TooManyRequests");c.waitList=[...c.waitList,m];let W=a.queryParams.set(M({},$),String(this.url));l=yield fetch(W,H).then(w=>d(this,null,function*(){return s=w.ok,o=w.status,u=w.statusText,h=w,v=="none"||v=="stream"?w:w[v]()})).catch(w=>{throw new Error(w)})}catch(m){o==200&&(o=500,s=!1),o==429&&(u="TooManyRequests"),i.signal.aborted&&(o=408,u="Timeout"),o==500&&(u=String(m)||u),l={errorCode:String(m)}}finally{clearTimeout(r),n=performance.now()-t}e.trafficControl&&(yield a.pending(()=>{},e.trafficControl)),c.waitList.splice(c.waitList.findIndex(m=>m==e.key),1);let p={ok:s,status:o,statusText:u,body:l,requestTime:n,rawData:h};if(!s&&this.onErrorCB&&this.onErrorCB(p.body),s&&this.onStreamCB&&e.response_format=="stream"){let m=(T=h.body)==null?void 0:T.getReader();this.onStreamProcess({errorCB:this.onErrorCB,streamCB:this.onStreamCB,response:p,reader:m,decoder:new TextDecoder("utf-8")})}return s&&this.onCompleteCB&&this.onCompleteCB(p.body),this.onResultCB&&this.onResultCB(p,e),c.setDefaultOnEnd&&c.setDefaultOnEnd(p,e),p})},abortStream:function(){this.streamStatus="abort"}},c);c.prototype.Fetcher.prototype=c.prototype;var he=e=>new b.prototype.Filer(e),b=he;b.prototype={};var me=function(e){this.ok=!0;try{let[t,n]=e.name.replace(/\s/,"").replace(/(.*)\.(.*)$/,"$1 $2").split(" ");this.file=e,this.extension=n,this.fileName=t,this.type=e.type}catch(t){console.log(t),this.ok=!1}return this};a.extend({ok:!1,extension:"",type:"",file:{},fileName:"",Filer:me,isValid:function(){return this.ok},toBlob:function(){return d(this,null,function*(){return new Blob([this.file,{type:this.type}])})},toDataURL:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("dataURL")).target)==null?void 0:t.result})},toAarrayBuffer:function(){return d(this,null,function*(){var t;return(t=(yield this.file.convert("arrayBuffer")).target)==null?void 0:t.result})},toObjectURL:function(){return d(this,null,function*(){return URL.createObjectURL(this.file)})},updateFileName:function(e){let t=new File([this.file],e+"."+this.extension);return this.file=t,this.fileName=e,this},updateMimeType:function(e){return this.file=new File([this.file],this.fileName+"."+this.extension,{type:e}),this.type=e,this},updateExtension:function(e){let t=new File([this.file],this.fileName+"."+e);return this.file=t,this.extension=e,this}},b);b.fromFile=e=>d(void 0,null,function*(){return b(e)});b.fromBlob=(e,t)=>d(void 0,null,function*(){let n=(t==null?void 0:t.fileName)||"file",i=(t==null?void 0:t.extension)||"",r=new File([e],n+"."+i,{type:t==null?void 0:t.mimeType});return b(r)});b.fromArrayBuffer=(e,t)=>d(void 0,null,function*(){return b.fromBlob(new Blob([e],{type:(t==null?void 0:t.mimeType)||""}),t)});b.fromObjectURL=(e,t)=>d(void 0,null,function*(){let n=yield c(e,{response_format:"blob"}).get();return n.ok?b.fromBlob(n.body,t):b({})});b.fromDataURL=(e,t)=>d(void 0,null,function*(){let n=yield e.toBlob((t==null?void 0:t.mimeType)||"");return n?b.fromBlob(n,t):b({})});b.prototype.Filer.prototype=b.prototype;var fe=function(e){let t=e,n=null;return t.use((i,r,s)=>{let o=r;o.return=u=>{let{status:l=200,body:h={},bodyStringify:p=!0}=u||{},g=h;return p&&!a.is.string(h)&&(g=a.Stringify(h)),r.status(l).end(g)},s()}),t.onPathRouter=function(i){return n=i,this},t.pathRouter=function(i){if(!n)return;let r=n(i);return r.route(i),t.use(i,r),r},t.exception=function(i){return t.use(i),this},t},L=fe;L.getLocalIP=e=>{let t="";return a.scope(()=>{if(!e)return;let n=e.networkInterfaces();for(let[i,r]of Object.entries(n))r.forEach(s=>{!s.internal&&s.family==="IPv4"&&!s.address.match(/^(169|127)/)&&(t=s.address)})}),t};L.getIP=function(e){var i;return(((e==null?void 0:e.headers["x-forwarded-for"])||((i=e==null?void 0:e.socket)==null?void 0:i.remoteAddress)||"").toString().match(new RegExp(/(::ffff:)?(\d+\.\d+.\d+\.\d+(:\d+)?)/))||[])[2]||"UNKNOWN IP"};a.copyToClipboard=e=>d(void 0,null,function*(){let t="";a.is.string(e)?t=e:a.is.function(e)&&(t=e());let n={ok:!1,body:"NotSupported"};return yield d(void 0,null,function*(){let i;if(navigator.clipboard){if(i=yield navigator.clipboard.writeText(t).then(()=>!0,()=>!1),!i)return}else{let r=document.createElement("input");if(a(document.body).append(r),r.value=t,r.select(),i=document.execCommand("copy"),document.body.removeChild(r),!i)return}n={ok:!0,body:""}}),n});a.ImageLoader=(e,t)=>new Promise((n,i)=>{let r=t||new Image;r.onload=()=>n(r),r.onerror=s=>i(s),r.src=e});a.formatCharacter={postal:{JP:e=>{let t="--";return e=String(e).replace(/\D/ig,""),e.length==7&&(t=e.replace(/^(\d{3})(.*)/,"$1-$2")),t}},tel:{_:e=>{let t=e;return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t},mobile:e=>{let t="--";return e=String(e).removeLetters(),e.length==11&&(t=e.replace(/^(\d{3})(\d{4})(\d{4})/,"$1-$2-$3")),t},fixed:e=>{let t="--";return e=String(e).removeLetters(),e.length==10&&(t=e.replace(/^(\d{2})(\d{4})(\d{4})/,"$1-$2-$3")),t}}};a.transformer={weekday:{JP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]+"\u66DC\u65E5",shortJP:e=>["\u65E5","\u6708","\u706B","\u6C34","\u6728","\u91D1","\u571F"][e]},wareki:e=>{let t=[],n=[],i=!1;return[{From:1868,To:1912,name:"\u660E\u6CBB"},{From:1912,To:1926,name:"\u5927\u6B63"},{From:1926,To:1989,name:"\u662D\u548C"},{From:1989,To:2019,name:"\u5E73\u6210"},{From:2019,To:1e5,name:"\u4EE4\u548C"}].forEach(s=>{let{From:o,To:u,name:l}=s;if(o<=e&&e<=u){let h=e-o+1;h==1&&(i=!0,h="\u5143"),n.push(l+h+"\u5E74"),t.push(l)}}),{era:t,value:n,gap:i}}};a.interval=C;c.setDefaultHeaders=()=>({});var ce=a;0&&(module.exports={Fetcher,Filer,Server,Time,UUID,useStore});
|
package/declare/core.d.ts
CHANGED
|
@@ -149,6 +149,8 @@ declare namespace Jmini {
|
|
|
149
149
|
};
|
|
150
150
|
ellipsisText(value: string, length: number): string;
|
|
151
151
|
flatArray<T = any>(v: any, regression?: '-R'): T[];
|
|
152
|
+
uniqueArray<T = any>(v: T[], key?: string): T[];
|
|
153
|
+
getKeyValue<T = any>(object: KeyValueDict, keys: string): T;
|
|
152
154
|
deepMerge<T = any>(target: T, ...args: T[]): T;
|
|
153
155
|
deepCopy<T = any>(target: T): T;
|
|
154
156
|
randomNumber(min?: number, max?: number, notIn?: number[]): number;
|
package/esm/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as T,e as b}from"./chunk-ABA72NWU.js";import{UUID as J}from"./uuid";import"./primitiveExtension";const v=e=>new n.prototype.jmini(e),n=v;n.prototype={},n.extend=function(e,i=n){for(var[s,o]of Object.entries(e))i.prototype[s]=o},n.expando="__jmini_"+J();const m=(e,i)=>(e.queue.push(i),E(e),e),E=e=>b(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let i=e.queue.shift();i&&(yield i()),e.queueProcess=!1,E(e)}}),p=(e,i)=>{for(let s=0;s<e.length;s++)e[s]=null;for(let[s,o]of Object.entries(i))s.match(/queue/)||(e[s]=o);return e},w=(e,i)=>{if(i.length){for(var s=0;s<i.length;s++){let o=i[s];o&&(o[n.expando]||(n.is.element(o)||n.is.shadowRoot(o))&&(o[n.expando]={events:{}})),e[s]=o}e.length=i.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,E(e),e};n.extend({constructor:n,jmini:function(e){return this.src=e,this.srcType=n.is.what(e),this.queueProcess=!0,this.queue=[],w(this,n.is.jmini(e)?e.get():n.is.element(e)?[e]:n.is.elements(e)?e:n.is.shadowRoot(e)?[e]:n.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}}),n.prototype[String(Symbol.iterator)]=[][Symbol.iterator],n.prototype.jmini.prototype=n.prototype;{const e=function(t,r,a){let l=[];for(let u=0;u<(t.length||0);u++)l.push(r(t[u],u));return a&&(l=l.filter(u=>u!=null)),l},i=t=>(t.for((r,a)=>{if(!(n.is.element(r)||n.is.shadowRoot(r)))return;let l=r.cloneNode(),u=r.parentNode;u&&u.replaceChild(l,r),t[a]=l}),t),s=(t,r)=>(n(r).for(a=>{if(t&&(n.is.element(a)||n.is.shadowRoot(a)))if(n.is.string(t)||n.is.number(t))t=String(t),a.insertAdjacentHTML("beforeend",String(t));else if(n.is.element(t))a.appendChild(t);else{n.is.jmini(t)?t=t.get():n.is.element(t)?t=[t]:n.is.keyValueDictionary(t)&&(t=[n(t)]);for(var l=0;l<t.length;l++)s(t[l],a)}}),r),o=(t,r,...a)=>{let{p:l,s:u}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[r]||{p:"",s:""};return t.for(h=>{if(n.is.string(a[0]))h.insertAdjacentHTML(l,a[0]);else{if(!h.parentNode)return;n(a[0]).for(y=>{a[1]&&(y=y.cloneNode(!0)),h.parentNode.insertBefore(y,h[u]||h)})}}),t};n.extend({get:function(t){return t?this[0]:e(this,r=>r)},for:function(t,r=1){let a=e(this,(l,u)=>t(l,u),1);return r?a:[]},await:function(t){return m(this,()=>new Promise((r,a)=>{setTimeout(()=>{r(this)},t)}))},abort:function(){return m(this,()=>b(this,null,function*(){return this.queue=[],this}))},callback:function(t){return m(this,()=>b(this,null,function*(){return yield t(this),this}))},click:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let r=this[t];n.is.element(r)&&r.click()}return this})},focus:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let r=this[t];n.is.element(r)&&r.focus()}return this})},addEvent:function(t){return m(this,()=>{let{eventType:r,eventID:a=J(),target:l,callback:u,options:h}=t;return h=T({passive:!0,capture:!1},h),this.for(f=>{if(!(n.is.element(f)||n.is.shadowRoot(f)))return;let{events:y}=f[n.expando];if(l){let g=u;u=c=>{if(c.target){if(n.is.string(l)){let C=c.target.closest(l);C&&(!C||g.call(C,c))}else if(n.is.elements(l)){for(let d of l)if(c.target==d)return g.call(d,c)}}}}if(y[a]){let g=y[a];f.removeEventListener(g.eventType,g.callback,g.options)}y[a]={eventType:r,callback:u,options:h},f.addEventListener(r,u,h)}),this})},removeEvent:function(t){return m(this,()=>{let r=n.is.array(t)?t:[t];return this.for(a=>{let{events:l}=a[n.expando];for(let u of r){let h=l[u];h&&a.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(t){return m(this,()=>p(this,s(t,i(this))))},empty:function(){return m(this,()=>p(this,i(this)))},append:function(t){return m(this,()=>{s(t,this)})},remove:function(){return m(this,()=>(this.for((t,r)=>{t&&n.is.element(t)&&(t.remove(),delete this[r])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...t){return m(this,()=>p(this,o(this,"before",...t)))},after:function(...t){return m(this,()=>p(this,o(this,"after",...t)))},find:function(t){return m(this,()=>{let r=[],a=this[0];a||p(this,n()),(n.is.element(a)||n.is.shadowRoot(a))&&(n.is.string(t)?r=a.querySelectorAll(t):n.is.element(a)&&n(t).for(l=>{let u=a.childNodes;for(let h of u)if(h===l){r.push(h);break}else h.childNodes.length&&(r=[...r,...n(h).find(l).for(f=>f)])})),p(this,n(r))})},parent:function(t){return m(this,()=>{var a,l;let r=n(t?(a=this[0])==null?void 0:a.closest(t):(l=this[0])==null?void 0:l.parentNode);p(this,r)})},children:function(t){return m(this,()=>{let r=this[0].children;n.is.exist(t)&&(t=String(t).replace(/^ : /,""),r=t=="first"?r[0]:t=="last"?r[r.length-1]:r[Number(t)]);let a=n(r);return p(this,a)})},addClass:function(t){return m(this,()=>(t&&this.for(r=>{let a=n.is.string(t)?t.split(" "):t;r&&n.is.element(r)&&r.classList.add(...a)}),this))},removeClass:function(t){return m(this,()=>(t&&this.for(r=>{let a=n.is.string(t)?t.split(" "):t;r&&n.is.element(r)&&r.classList.remove(...a)}),this))},toggleClass:function(t){return m(this,()=>(t&&this.for(r=>{r.classList.toggle(t)}),this))},hasClass:function(t=""){if(this[0])return this[0].classList.contains(t.replace(/^\./,""))},findClass:function(t){let r=[];return this[0]&&(r=[...this[0].classList].filter(a=>a.match(t))),r},css:function(t){return m(this,()=>(this.for(r=>{if(n.is.element(r))for(let[a,l]of Object.entries(t)){if(n.is.number(l)&&a.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){r.style[a]=l+"px";continue}r.style[a]=String(l)}}),this))},getAttribute:function(t){return this[0].getAttribute(String(t))},setAttribute:function(t,r){return m(this,()=>(this.for(a=>a.setAttribute(t,r)),this))},getStyleProperty:function(t){let r=this[0];return r&&n.is.element(r)?getComputedStyle(r).getPropertyValue(t):""},setStyleProperty:function(t,r){let a=this[0];return a&&n.is.element(a)&&a.style.setProperty(t,r),this},val:function(){var r;let t=this[0];return(t==null?void 0:t.value)||((r=t==null?void 0:t.dataset)==null?void 0:r.value)},position:function(){return n.is.element(this[0])?this[0].getBoundingClientRect():{}}})}n.flatArray=(e,i)=>{if(!n.is.array(e))return[e];let s=[];for(let o of e)s.push(...i=="-R"?n.flatArray(o,"-R"):[o]);return s},n.Stringify=JSON.stringify,n.Objectify=(e,i)=>{try{return JSON.parse(e)}catch(s){return i!=null?i:null}},n.randomNumber=(e=0,i=100,s)=>{if(e>i)return NaN;let o=[],t=e;for(;t<=i;){if(s&&s.length&&s.includes(t)){t++;continue}o.push(t),t++}let r=Math.round(Math.random()*(o.length-1))+0;return o[r]},n.try=e=>{try{return[e(),!0]}catch(i){return[i,!1]}},n.trySync=e=>b(void 0,null,function*(){try{return[yield e(),!0]}catch(i){return[i,!1]}}),n.scope=e=>e(),n.scopeSync=e=>b(void 0,null,function*(){return yield e()}),n.createElement=function(e){var y;let{tag:i,className:s="",id:o,html:t,attr:r,style:a,parent:l}=e,u=document.createElement(i||"div");if(s&&u.classList.add(...s.split(" ")),o&&(u.id=o),r)for(let g of Object.entries(r)){let c=g[0],d=(y=g[1])!=null?y:"";if(c=="data"&&n.is.keyValueDictionary(d))for(let[C,S]of Object.entries(d))u.dataset[C]=S;else c=="for"?c="htmlFor":c=="tabindex"?c="tabIndex":c=="aria-label"&&(c="ariaLabel"),u[c]=d}if(t&&n(u).append(t),a)for(var[h,f]of Object.entries(a))u.style[h]=f;return l&&n(l).append(u),u},n.setCookie=e=>{let{hostname:i}=new URL(location.toString()),{name:s,value:o="",age:t=60*60*24*365,path:r="/",domain:a=i,secure:l=!1}=e,u=`${s}=${o}max-age=${t}path=${r}domain=${a}`;l&&(u+=" Secure"),document.cookie=u},n.getCookie=e=>{let i=document.cookie.match(new RegExp(e+"=[^]*"));return i?i[0].replace(new RegExp(e+"="),""):""},n.localStrage={set:(e,i)=>{localStorage.setItem(e,n.Stringify(i))},get:e=>{let i=localStorage.getItem(e);return n.Objectify(i,i)}},n.deleteCookie=e=>{document.cookie=e+"=max-age=0"},n.getScreenSize=()=>{let{innerHeight:e,innerWidth:i,scrollY:s,scrollX:o,pageXOffset:t,pageYOffset:r}=window,a=Number(n(document.body).getStyleProperty("--sat").removeLetters()),l=Number(n(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:i,pageHeight:e-a-l,scrollY:s,scrollX:o,pageXOffset:t,pageYOffset:r,safeAreaTop:a,safeAreaBottom:l}},n.getCursor=e=>{var o,t,r,a,l,u,h,f;let i=(a=e.pageX)!=null?a:(r=(o=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:o.pageX)!=null?r:(((t=e==null?void 0:e.originalEvent)==null?void 0:t.touches)||[])[0].pageX,s=(f=e.pageY)!=null?f:(h=(l=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:l.pageY)!=null?h:(((u=e==null?void 0:e.originalEvent)==null?void 0:u.touches)||[])[0].pageY;return{x:i,y:s}},n.pending=(e,i)=>new Promise((s,o)=>{e(s),i&&setTimeout(()=>{s(!0)},i)}),n.deepMerge=(e,...i)=>{if(!i.length)return e;const s=i.shift();if(n.is.keyValueDictionary(e)&&n.is.keyValueDictionary(s))for(const o in s)n.is.keyValueDictionary(s[o])?(e[o]||Object.assign(e,{[o]:{}}),n.deepMerge(e[o],s[o])):Object.assign(e,{[o]:s[o]});return n.deepMerge(e,...i)},n.deepCopy=e=>{if(n.is.array(e))return e.map(i=>n.deepCopy(i));if(n.is.keyValueDictionary(e)){let i={};return Object.entries(e).forEach(([s,o])=>{i[s]=n.deepCopy(o)}),i}return e},n.queryParams={get:e=>{let i=new URL(e||location.href),s={};return i.searchParams.forEach((o,t)=>s[t]=o),s},set:(e,i)=>{const s=new URL(i||location.href);return Object.entries(e).forEach(([o,t])=>{s.searchParams.set(o,String(t))}),i||history.replaceState({},"",s.pathname+s.search),s.toString()},delete:(e,i)=>{const s=new URL(i||location.href);return e.forEach(o=>{s.searchParams.delete(o)}),i||history.replaceState({},"",s.pathname+s.search),s.toString()}},n.ellipsisText=(e,i)=>{let s=String(e);return s.length>i&&(s=s.slice(0,i)+" ..."),s},n.is={equal:function(e,i,s){return s==null||s?n.Stringify(e)===n.Stringify(i):e===i},what:function(e){let i="other";return this.jmini(e)?i="jmini":this.element(e)?i="element":this.elements(e)?i="elements":this.shadowRoot(e)?i="shadowRoot":this.string(e)?i="string":this.number(e)?i="number":this.array(e)?i="array":this.function(e)?i="function":this.date(e)?i="date":typeof e=="undefined"?i="undefined":this.keyValueDictionary(e)?i="keyValueDictionary":e==null?i="null":isNaN(e)&&(i="NaN"),i},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini:function(e){return(e||{}).constructor===n},string:function(e){return typeof e=="string"},boolean:function(e){return typeof e=="boolean"},number:function(e){return!isNaN(e)&&typeof e=="number"},array:function(e){let i={}.toString.call(e);return e instanceof Array||i=="[object NodeList]"||i=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jmini(e)},element:function(e){return e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e))},elements:function(e){let i={}.toString.call(e),s=Number(!!e&&typeof e!="string"&&this.array(e)&&i!=="[object Text]");if(s&&i!=="[object NodeList]")for(var o of e)s&=Number(this.element(o));return!!s},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};export{n as Jmini,n as default};
|
|
1
|
+
import{b as T,e as b}from"./chunk-ABA72NWU.js";import{UUID as J}from"./uuid";import"./primitiveExtension";const v=e=>new n.prototype.jmini(e),n=v;n.prototype={},n.extend=function(e,i=n){for(var[s,o]of Object.entries(e))i.prototype[s]=o},n.expando="__jmini_"+J();const m=(e,i)=>(e.queue.push(i),E(e),e),E=e=>b(void 0,null,function*(){if(!e.queueProcess&&e.queue.length){e.queueProcess=!0;let i=e.queue.shift();i&&(yield i()),e.queueProcess=!1,E(e)}}),p=(e,i)=>{for(let s=0;s<e.length;s++)e[s]=null;for(let[s,o]of Object.entries(i))s.match(/queue/)||(e[s]=o);return e},w=(e,i)=>{if(i.length){for(var s=0;s<i.length;s++){let o=i[s];o&&(o[n.expando]||(n.is.element(o)||n.is.shadowRoot(o))&&(o[n.expando]={events:{}})),e[s]=o}e.length=i.length}else e.warn="No Argument(s).",e.length=0;return e.queueProcess=!1,E(e),e};n.extend({constructor:n,jmini:function(e){return this.src=e,this.srcType=n.is.what(e),this.queueProcess=!0,this.queue=[],w(this,n.is.jmini(e)?e.get():n.is.element(e)?[e]:n.is.elements(e)?e:n.is.shadowRoot(e)?[e]:n.is.string(e)?e.match(/^#[^\.\s]*$/)?[document.getElementById(e.replace(/#/,""))]:document.querySelectorAll(e):[])}}),n.prototype[String(Symbol.iterator)]=[][Symbol.iterator],n.prototype.jmini.prototype=n.prototype;{const e=function(t,r,a){let l=[];for(let u=0;u<(t.length||0);u++)l.push(r(t[u],u));return a&&(l=l.filter(u=>u!=null)),l},i=t=>(t.for((r,a)=>{if(!(n.is.element(r)||n.is.shadowRoot(r)))return;let l=r.cloneNode(),u=r.parentNode;u&&u.replaceChild(l,r),t[a]=l}),t),s=(t,r)=>(n(r).for(a=>{if(t&&(n.is.element(a)||n.is.shadowRoot(a)))if(n.is.string(t)||n.is.number(t))t=String(t),a.insertAdjacentHTML("beforeend",String(t));else if(n.is.element(t))a.appendChild(t);else{n.is.jmini(t)?t=t.get():n.is.element(t)?t=[t]:n.is.keyValueDictionary(t)&&(t=[n(t)]);for(var l=0;l<t.length;l++)s(t[l],a)}}),r),o=(t,r,...a)=>{let{p:l,s:u}={before:{p:"beforebegin",s:""},after:{p:"afterend",s:"nextSibling"}}[r]||{p:"",s:""};return t.for(h=>{if(n.is.string(a[0]))h.insertAdjacentHTML(l,a[0]);else{if(!h.parentNode)return;n(a[0]).for(y=>{a[1]&&(y=y.cloneNode(!0)),h.parentNode.insertBefore(y,h[u]||h)})}}),t};n.extend({get:function(t){return t?this[0]:e(this,r=>r)},for:function(t,r=1){let a=e(this,(l,u)=>t(l,u),1);return r?a:[]},await:function(t){return m(this,()=>new Promise((r,a)=>{setTimeout(()=>{r(this)},t)}))},abort:function(){return m(this,()=>b(this,null,function*(){return this.queue=[],this}))},callback:function(t){return m(this,()=>b(this,null,function*(){return yield t(this),this}))},click:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let r=this[t];n.is.element(r)&&r.click()}return this})},focus:function(){return m(this,()=>{for(var t=0;t<this.length;t++){let r=this[t];n.is.element(r)&&r.focus()}return this})},addEvent:function(t){return m(this,()=>{let{eventType:r,eventID:a=J(),target:l,callback:u,options:h}=t;return h=T({passive:!0,capture:!1},h),this.for(f=>{if(!(n.is.element(f)||n.is.shadowRoot(f)))return;let{events:y}=f[n.expando];if(l){let g=u;u=c=>{if(c.target){if(n.is.string(l)){let C=c.target.closest(l);C&&(!C||g.call(C,c))}else if(n.is.elements(l)){for(let d of l)if(c.target==d)return g.call(d,c)}}}}if(y[a]){let g=y[a];f.removeEventListener(g.eventType,g.callback,g.options)}y[a]={eventType:r,callback:u,options:h},f.addEventListener(r,u,h)}),this})},removeEvent:function(t){return m(this,()=>{let r=n.is.array(t)?t:[t];return this.for(a=>{let{events:l}=a[n.expando];for(let u of r){let h=l[u];h&&a.removeEventListener(h.eventType,h.callback,h.options)}}),this})},html:function(t){return m(this,()=>p(this,s(t,i(this))))},empty:function(){return m(this,()=>p(this,i(this)))},append:function(t){return m(this,()=>{s(t,this)})},remove:function(){return m(this,()=>(this.for((t,r)=>{t&&n.is.element(t)&&(t.remove(),delete this[r])}),this.length=0,this.warn="Object(s?) were all removed.",this))},before:function(...t){return m(this,()=>p(this,o(this,"before",...t)))},after:function(...t){return m(this,()=>p(this,o(this,"after",...t)))},find:function(t){return m(this,()=>{let r=[],a=this[0];a||p(this,n()),(n.is.element(a)||n.is.shadowRoot(a))&&(n.is.string(t)?r=a.querySelectorAll(t):n.is.element(a)&&n(t).for(l=>{let u=a.childNodes;for(let h of u)if(h===l){r.push(h);break}else h.childNodes.length&&(r=[...r,...n(h).find(l).for(f=>f)])})),p(this,n(r))})},parent:function(t){return m(this,()=>{var a,l;let r=n(t?(a=this[0])==null?void 0:a.closest(t):(l=this[0])==null?void 0:l.parentNode);p(this,r)})},children:function(t){return m(this,()=>{let r=this[0].children;n.is.exist(t)&&(t=String(t).replace(/^ : /,""),r=t=="first"?r[0]:t=="last"?r[r.length-1]:r[Number(t)]);let a=n(r);return p(this,a)})},addClass:function(t){return m(this,()=>(t&&this.for(r=>{let a=n.is.string(t)?t.split(" "):t;r&&n.is.element(r)&&r.classList.add(...a)}),this))},removeClass:function(t){return m(this,()=>(t&&this.for(r=>{let a=n.is.string(t)?t.split(" "):t;r&&n.is.element(r)&&r.classList.remove(...a)}),this))},toggleClass:function(t){return m(this,()=>(t&&this.for(r=>{r.classList.toggle(t)}),this))},hasClass:function(t=""){if(this[0])return this[0].classList.contains(t.replace(/^\./,""))},findClass:function(t){let r=[];return this[0]&&(r=[...this[0].classList].filter(a=>a.match(t))),r},css:function(t){return m(this,()=>(this.for(r=>{if(n.is.element(r))for(let[a,l]of Object.entries(t)){if(n.is.number(l)&&a.match(/width|height|top|right|bottom|left|padding|margin|gap|border-.*radius/)){r.style[a]=l+"px";continue}r.style[a]=String(l)}}),this))},getAttribute:function(t){return this[0].getAttribute(String(t))},setAttribute:function(t,r){return m(this,()=>(this.for(a=>a.setAttribute(t,r)),this))},getStyleProperty:function(t){let r=this[0];return r&&n.is.element(r)?getComputedStyle(r).getPropertyValue(t):""},setStyleProperty:function(t,r){let a=this[0];return a&&n.is.element(a)&&a.style.setProperty(t,r),this},val:function(){var r;let t=this[0];return(t==null?void 0:t.value)||((r=t==null?void 0:t.dataset)==null?void 0:r.value)},position:function(){return n.is.element(this[0])?this[0].getBoundingClientRect():{}}})}n.flatArray=(e,i)=>{if(!n.is.array(e))return[e];let s=[];for(let o of e)s.push(...i=="-R"?n.flatArray(o,"-R"):[o]);return s},n.uniqueArray=(e,i)=>{let s=e;return i?s=Array.from(new Map(e.map(o=>[n.getKeyValue(o,i||"0"),o])).values()):s=Array.from(new Set(e)),s},n.getKeyValue=(e,i)=>{let s={},o=e;return i.split(".").forEach(t=>{o=o==null?void 0:o[t],s=o}),s},n.Stringify=JSON.stringify,n.Objectify=(e,i)=>{try{return JSON.parse(e)}catch(s){return i!=null?i:null}},n.randomNumber=(e=0,i=100,s)=>{if(e>i)return NaN;let o=[],t=e;for(;t<=i;){if(s&&s.length&&s.includes(t)){t++;continue}o.push(t),t++}let r=Math.round(Math.random()*(o.length-1))+0;return o[r]},n.try=e=>{try{return[e(),!0]}catch(i){return[i,!1]}},n.trySync=e=>b(void 0,null,function*(){try{return[yield e(),!0]}catch(i){return[i,!1]}}),n.scope=e=>e(),n.scopeSync=e=>b(void 0,null,function*(){return yield e()}),n.createElement=function(e){var y;let{tag:i,className:s="",id:o,html:t,attr:r,style:a,parent:l}=e,u=document.createElement(i||"div");if(s&&u.classList.add(...s.split(" ")),o&&(u.id=o),r)for(let g of Object.entries(r)){let c=g[0],d=(y=g[1])!=null?y:"";if(c=="data"&&n.is.keyValueDictionary(d))for(let[C,S]of Object.entries(d))u.dataset[C]=S;else c=="for"?c="htmlFor":c=="tabindex"?c="tabIndex":c=="aria-label"&&(c="ariaLabel"),u[c]=d}if(t&&n(u).append(t),a)for(var[h,f]of Object.entries(a))u.style[h]=f;return l&&n(l).append(u),u},n.setCookie=e=>{let{hostname:i}=new URL(location.toString()),{name:s,value:o="",age:t=60*60*24*365,path:r="/",domain:a=i,secure:l=!1}=e,u=`${s}=${o}max-age=${t}path=${r}domain=${a}`;l&&(u+=" Secure"),document.cookie=u},n.getCookie=e=>{let i=document.cookie.match(new RegExp(e+"=[^]*"));return i?i[0].replace(new RegExp(e+"="),""):""},n.localStrage={set:(e,i)=>{localStorage.setItem(e,n.Stringify(i))},get:e=>{let i=localStorage.getItem(e);return n.Objectify(i,i)}},n.deleteCookie=e=>{document.cookie=e+"=max-age=0"},n.getScreenSize=()=>{let{innerHeight:e,innerWidth:i,scrollY:s,scrollX:o,pageXOffset:t,pageYOffset:r}=window,a=Number(n(document.body).getStyleProperty("--sat").removeLetters()),l=Number(n(document.body).getStyleProperty("--sab").removeLetters());return{height:e,width:i,pageHeight:e-a-l,scrollY:s,scrollX:o,pageXOffset:t,pageYOffset:r,safeAreaTop:a,safeAreaBottom:l}},n.getCursor=e=>{var o,t,r,a,l,u,h,f;let i=(a=e.pageX)!=null?a:(r=(o=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:o.pageX)!=null?r:(((t=e==null?void 0:e.originalEvent)==null?void 0:t.touches)||[])[0].pageX,s=(f=e.pageY)!=null?f:(h=(l=((e==null?void 0:e.changedTouches)||[])[0])==null?void 0:l.pageY)!=null?h:(((u=e==null?void 0:e.originalEvent)==null?void 0:u.touches)||[])[0].pageY;return{x:i,y:s}},n.pending=(e,i)=>new Promise((s,o)=>{e(s),i&&setTimeout(()=>{s(!0)},i)}),n.deepMerge=(e,...i)=>{if(!i.length)return e;const s=i.shift();if(n.is.keyValueDictionary(e)&&n.is.keyValueDictionary(s))for(const o in s)n.is.keyValueDictionary(s[o])?(e[o]||Object.assign(e,{[o]:{}}),n.deepMerge(e[o],s[o])):Object.assign(e,{[o]:s[o]});return n.deepMerge(e,...i)},n.deepCopy=e=>{if(n.is.array(e))return e.map(i=>n.deepCopy(i));if(n.is.keyValueDictionary(e)){let i={};return Object.entries(e).forEach(([s,o])=>{i[s]=n.deepCopy(o)}),i}return e},n.queryParams={get:e=>{let i=new URL(e||location.href),s={};return i.searchParams.forEach((o,t)=>s[t]=o),s},set:(e,i)=>{const s=new URL(i||location.href);return Object.entries(e).forEach(([o,t])=>{s.searchParams.set(o,String(t))}),i||history.replaceState({},"",s.pathname+s.search),s.toString()},delete:(e,i)=>{const s=new URL(i||location.href);return e.forEach(o=>{s.searchParams.delete(o)}),i||history.replaceState({},"",s.pathname+s.search),s.toString()}},n.ellipsisText=(e,i)=>{let s=String(e);return s.length>i&&(s=s.slice(0,i)+" ..."),s},n.is={equal:function(e,i,s){return s==null||s?n.Stringify(e)===n.Stringify(i):e===i},what:function(e){let i="other";return this.jmini(e)?i="jmini":this.element(e)?i="element":this.elements(e)?i="elements":this.shadowRoot(e)?i="shadowRoot":this.string(e)?i="string":this.number(e)?i="number":this.array(e)?i="array":this.function(e)?i="function":this.date(e)?i="date":typeof e=="undefined"?i="undefined":this.keyValueDictionary(e)?i="keyValueDictionary":e==null?i="null":isNaN(e)&&(i="NaN"),i},exist:function(e){return e===(e!=null?e:!e)},nullish:function(e){return!this.exist(e)},jmini:function(e){return(e||{}).constructor===n},string:function(e){return typeof e=="string"},boolean:function(e){return typeof e=="boolean"},number:function(e){return!isNaN(e)&&typeof e=="number"},array:function(e){let i={}.toString.call(e);return e instanceof Array||i=="[object NodeList]"||i=="[object HTMLCollection]"},function:function(e){return typeof e=="function"},keyValueDictionary:function(e){return{}.toString.call(e)==="[object Object]"&&!this.jmini(e)},element:function(e){return e&&(e.nodeType==1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"||[window,document].includes(e))},elements:function(e){let i={}.toString.call(e),s=Number(!!e&&typeof e!="string"&&this.array(e)&&i!=="[object Text]");if(s&&i!=="[object NodeList]")for(var o of e)s&=Number(this.element(o));return!!s},shadowRoot:function(e){return e instanceof ShadowRoot},date:function(e){return this.number(new Date(e).getTime())}};export{n as Jmini,n as default};
|