lu2
Version:
Simple and flexible UI component library based on native HTML and JavaScript
1 lines • 121 kB
JavaScript
(async()=>{CSS.supports("overflow-anchor:auto")&&CSS.supports("offset:none")||await import("./safari-polyfill.js");class t extends HTMLButtonElement{static get observedAttributes(){return["color","height","radius","width"]}constructor(){super(),this.render()}get color(){return this.getAttribute("color")}set color(t){this.setAttribute("color",t)}get radius(){let t=this.getAttribute("radius");return isNaN(t)||isNaN(parseFloat(t))||(t+="px"),t}set radius(t){this.setAttribute("radius",t)}get height(){let t=this.getAttribute("height");return isNaN(t)||isNaN(parseFloat(t))||(t+="px"),t}set height(t){this.setAttribute("height",t)}get width(){let t=this.getAttribute("width");return isNaN(t)||isNaN(parseFloat(t))||(t+="px"),t}set width(t){this.setAttribute("width",t)}renderAttribute(t,e){"string"==typeof this[t]?this.style.setProperty("--ui-button-"+t,this[t]):e||this.style.removeProperty("--ui-button-"+t)}render(){t.observedAttributes.forEach((t=>{this.renderAttribute(t,!0)}))}attributeChangedCallback(t){this.render(t)}connectedCallback(){this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-button"}})),this.isConnectedCallback=!0}}customElements.get("ui-button")||customElements.define("ui-button",t,{extends:"button"});class e extends HTMLInputElement{static get observedAttributes(){return["extends","checked","disabled"]}get extends(){return this.hasAttribute("extends")}set extends(t){this.toggleAttribute("extends",t)}render(){this.extends&&[...this.labels].forEach((t=>{t.classList[this.checked?"add":"remove"]("active"),t.classList[this.disabled?"add":"remove"]("disabled"),t.setAttribute("role","button")}))}attributeChangedCallback(){this.render()}constructor(){super(),this.addEventListener("change",(()=>{this.render()})),this.render();const t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"checked");Object.defineProperty(e.prototype,"checked",{...t,set(e){t.set.call(this,e),this.render()}})}connectedCallback(){this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-checkbox"}})),this.isConnectedCallback=!0}}customElements.get("ui-checkbox")||customElements.define("ui-checkbox",e,{extends:"input"});const i={toString:()=>"ui-datetime"};["date","day","year","month","hour","minute","time","second"].forEach((t=>{i[t]=(...e)=>["ui",t,...e].join("-")}));const s=/-|\//g;String.prototype.toDate=function(){let t,e,i;const n=this.replace(/年|月|日/g,"-").split(s);return t=1*n[0],e=n[1]||1,i=n[2]||1,t?new Date(t,e-1,i):new Date},String.prototype.toTime=function(){let t=this.trim().split(":").map(((t,e)=>!t||/\D/.test(t)?"":t<0?"00":(0===e?t>23&&(t="23"):t>59&&(t="59"),t.padStart(2,"0")))).filter((t=>t)).slice(0,3);return 1==t.length&&t.push("00"),t},Date.prototype.toArray=function(){let t=this.getFullYear(),e=this.getMonth()+1,i=this.getDate();return e<10&&(e=`0${e}`),i<10&&(i=`0${i}`),[t,e,i]};class n extends HTMLInputElement{constructor(){super(),this.element=this.element||{};let t=document.createElement("div");t.className=i.date("container"),this.element.container=t}get min(){let t=this.getAttribute("min")||"";return t?this.minMaxConvert(t).toString():t}set min(t){t?this.setAttribute("min",this.minMaxConvert(t)):this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return t?this.minMaxConvert(t).toString():t}set max(t){t?this.setAttribute("max",this.minMaxConvert(t)):this.removeAttribute("max")}get step(){let t=this.getAttribute("step"),e=this.params.type,i=Number(t);return t&&/^\d+$/.test(t)?("time"==e?t>60?(t%60!=0||t/60>30)&&(i=1):i>30&&(i=1):"hour"==e?i>12&&(i=1):"minute"==e&&i>30&&(i=1),i):""}set step(t){t?this.setAttribute("step",t):this.removeAttribute("step")}minMaxConvert(t){"number"==typeof t&&Number.isInteger(t)&&(t>1e7?t=new Date(t):t<9999&&(t=String(t)));let e=[];t.toArray?e=t.toArray():"string"==typeof t&&(e=t.toDate().toArray());let i=this.getAttribute("type")||"date";if("date"==i||"date-range"==i)t=e.join("-");else if("year"==i)t=e[0];else if("month"==i||"month-range"==i)t=e.slice(0,2).join("-");else{t.toArray&&(t=t.getHours()+":"+t.getMinutes());let e=t.toTime();if(!e[0])return"";t=e.join(":")}return t}setError(){let t=this.element.container;t.toggleAttribute("is-error",t.querySelector("[disabled][selected]"))}setStatus(){let t=this.min,e=this.max;if(!t&&!e)return;let i=t.split(/\D/),s=e.split(/\D/),n=this.element.container,r="[disabled][selected]",o=this.selected,a=this.params.type;if("time"==a||"hour"==a||"minute"==a){let i=t||"00:00:00",s=e||"23:59:59",a=Number(i.split(":")[0])||0,l=Number(i.split(":")[1])||0,h=Number(i.split(":")[2])||0,d=Number(s.split(":")[0]);isNaN(d)&&(d=23);let c=Number(s.split(":")[1]),u=Number(s.split(":")[2]);isNaN(c)&&(c=59),isNaN(u)&&(u=59);let p=n.querySelector('ui-scroll-snap[list="minute"]'),m=n.querySelector('ui-scroll-snap[list="second"]');return p?(o[0]<a||o[0]>d?[...p.children].forEach((t=>{t.disabled=!0})):o[0]==a?[...p.children].forEach((t=>{let e=parseInt(t.textContent);t.disabled=e<l})):o[0]==d?[...p.children].forEach((t=>{let e=parseInt(t.textContent);t.disabled=e>c})):[...p.children].forEach((t=>{t.disabled=!1})),m?(p.querySelector(r)?[...m.children].forEach((t=>{t.disabled=!0})):o[0]==a&&Number(o[1])==Number(l)?[...m.children].forEach((t=>{t.disabled=parseInt(t.textContent)<h})):o[0]==d&&Number(o[1])==Number(c)?[...m.children].forEach((t=>{t.disabled=parseInt(t.textContent)>u})):[...m.children].forEach((t=>{t.disabled=!1})),void this.setError()):void this.setError()):void this.setError()}let l=i[0]||0,h=s[0]||9999,d=i[1]||1,c=s[1]||12,u=i[2]||1,p=s[2]||31,m=n.querySelector('[list="month"]'),g=n.querySelector('[list="day"]');m?(o[0]<l||o[1]>h?[...m.children].forEach((t=>{t.disabled=!0})):o[0]==l?[...m.children].forEach((t=>{let e=parseInt(t.textContent);t.disabled=e<d})):o[0]==h?[...m.children].forEach((t=>{let e=parseInt(t.textContent);t.disabled=e>c})):[...m.children].forEach((t=>{t.disabled=!1})),g?(m.querySelector(r)?[...g.children].forEach((t=>{t.disabled=!0})):o[0]==l&&Number(o[1])==Number(d)?[...g.children].forEach((t=>{let e=parseInt(t.textContent);t.disabled=e<u})):o[0]==h&&Number(o[1])==Number(c)?[...g.children].forEach((t=>{let e=parseInt(t.textContent);t.disabled=e>p})):[...g.children].forEach((t=>{t.disabled=!1})),this.setError()):this.setError()):this.setError()}events(){return this.addEventListener("click",(function(){let t=this.element.popup,e=this.params.type;t?t.show():(t=new Popup({content:this.element.container}),t.addEventListener("show",(()=>{this[e]&&this[e](),this.show()})),t.addEventListener("hide",(()=>{this.hide()})),this.element.popup=t)})),this}setValue(){const t=this.selected,e=this.value;switch(this.params.type){case"date":this.value=t.join("-");break;case"month":this.value=t.slice(0,2).join("-");break;case"year":this.value=t[0];break;case"time":case"minute":this.value=t.join(":");break;case"hour":this.value=`${t[0]}:${t[1]||"00"}`}return this.value!=e&&this.dispatchEvent(new CustomEvent("change",{bubbles:!0})),this.value}getYearData(t){let e=(new Date).getFullYear();t&&t[0]&&(e=t[0]||e);let i="";for(let t=e-5;t<=e+5;t++)i+=`<ui-scroll-snap-item${t===e?" selected":""}>${t}年</ui-scroll-snap-item>`;return i}getMonthData(t){let e=0;return t&&t[1]&&(e=t[1]-1||e),Array(12).fill().map(((t,i)=>`<ui-scroll-snap-item${i===e?" selected":""}>${String(i+1).padStart(2,"0")}月</ui-scroll-snap-item>`)).join("")}getMonthDay(t){let e=t;"object"==typeof t||t.map||(e=t.toArray());const i=[31,28,31,30,31,30,31,31,30,31,30,31];return(e[0]%4==0&&e[0]%100!=0||e[0]%400==0)&&(i[1]=29),i}getDayData(t){let e=new Date;t&&(e=t.join("-").toDate());let i=e.getMonth(),s=this.getMonthDay(e)[i],n=e.getDate();return Array(s).fill().map(((t,e)=>`<ui-scroll-snap-item${e+1===n?" selected":""}>${String(e+1).padStart(2,"0")}日</ui-scroll-snap-item>`)).join("")}getHourData(t){let e=(new Date).getHours();t&&(e=Number(t[0]));let i=24;"ah:mm"==this.datetimeformat&&(i=12,e>12&&(e-=12));let s=this.min||"00:00:00",n=this.max||"23:59:59",r=Number(s.split(":")[0])||0,o=Number(n.split(":")[0]);return isNaN(o)&&(o=23),Array(i).fill().map(((t,i)=>`<ui-scroll-snap-item${i===e?" selected":""}${i<r||i>o?" disabled":""}>${String(i).padStart(2,"0")}时</ui-scroll-snap-item>`)).join("")}getMinuteData(t){let e=this.selected[0],i=this.selected[1];i||0===i||(i=(new Date).getMinutes());let s=1*this.step||1;s>60&&(s=Math.floor(s/60)),t||60!=s||(t="00");const n="<ui-scroll-snap-item></ui-scroll-snap-item>";if(void 0!==t)return`<ui-scroll-snap-item></ui-scroll-snap-item><ui-scroll-snap-item selected>${String(t).padStart(2,"0")}分</ui-scroll-snap-item>`;let r=Math.floor(60/s),o=this.min,a=this.max;(!o||o.split(":").length<2)&&(o="00:00:00"),(!a||a.split(":").length<2)&&(o="23:59:59");let l=o.split(":"),h=a.split(":"),d=Array(r).fill().map(((t,n)=>{let r=s*n,o="";return(Number(e)==Number(l[0])&&n<l[1]||Number(e)==Number(h[0])&&n>h[1])&&(o=" disabled"),`<ui-scroll-snap-item${r===i?" selected":""}${o}>${String(r).padStart(2,"0")}分</ui-scroll-snap-item>`})).join("");return r<6&&(d=n+d+n,this.element.minute&&this.element.minute.removeAttribute("loop")),d}getSecondData(){let t=this.selected[2];t||0===t||(t=(new Date).getSeconds());let e=1*this.step||1;e>60&&(e=Math.floor(e/60));const i="<ui-scroll-snap-item></ui-scroll-snap-item>";let s=Math.floor(60/e);t=Math.floor(t/e)*e;let n=Array(s).fill().map(((i,s)=>{let n=e*s;return`<ui-scroll-snap-item${n===t?" selected":""}>${String(n).padStart(2,"0")}秒</ui-scroll-snap-item>`})).join("");return s<6&&(n=i+n+i,this.element.second&&this.element.second.removeAttribute("loop")),n}getAmpmData(){let t=1;return 1*this.selected[0]<12&&(t=0),`<ui-scroll-snap-item></ui-scroll-snap-item><ui-scroll-snap-item${0===t?" selected":""}>上午</ui-scroll-snap-item><ui-scroll-snap-item${1===t?" selected":""}>下午</ui-scroll-snap-item><ui-scroll-snap-item></ui-scroll-snap-item>`}date(){return this.month(),this.day(),this}month(){this.year();let t=this.element.month,e=this.selected;if(!t){t=document.createElement("ui-scroll-snap"),t.setAttribute("type","y"),t.setAttribute("loop",""),t.setAttribute("list","month"),t.addEventListener("scrollEnd",(t=>{let i=t.detail;i.item&&(e[1]=i.item.textContent.replace(/\D/g,""),this.selected=e,this.setValue(),this.setStatus())})),t.innerHTML=this.getMonthData();let s=document.createElement("div");s.className=i.month("container"),s.append(t),this.element.year.parentElement.after(s),this.element.month=t}let s=t.querySelector(":scope > [selected]");s&&s.removeAttribute("selected"),[...t.children].some((t=>{t.textContent.replace(/\D/g,"")==String(e[1])&&(t.selected=!0,t.position())}))}day(){let t=this.element.day,e=this.element.container,s=this.selected;if(!t){t=document.createElement("ui-scroll-snap"),t.setAttribute("type","y"),t.setAttribute("loop",""),t.setAttribute("list","day"),t.addEventListener("scrollEnd",(t=>{let e=t.detail;e.item&&(s[2]=e.item.textContent.replace(/\D/g,""),this.selected=s,this.setValue(),this.setStatus())})),t.innerHTML=this.getDayData();let n=document.createElement("div");n.className=i.day("container"),n.append(t),e.append(n),this.element.day=t}let n=t.querySelector(":scope > [selected]");return n&&n.removeAttribute("selected"),[...t.children].some((t=>{t.textContent.replace(/\D/g,"")==String(s[2])&&(t.selected=!0,t.position())})),this}year(){let t=this.element.year,e=this.element.container,s=this.selected,n=this.min,r=this.max,o=n.split(/\D/)[0]||0,a=r.split(/\D/)[0]||9999;if(!t){t=document.createElement("ui-scroll-snap"),t.setAttribute("type","y"),t.setAttribute("loop",""),t.setAttribute("list","year"),t.addEventListener("scrollEnd",(t=>{let e=t.detail;e.item&&(s[0]=e.item.textContent.replace(/\D/g,""),this.selected=s,this.setValue(),this.setStatus())})),t.innerHTML=this.getYearData();let n=document.createElement("div");n.className=i.year("container"),n.append(t),t.onScrollInited=function(t,e){let i=parseInt(e[0].textContent),s=e.length;t.forEach(((t,e)=>{let n=i-s+e;t.textContent=n+"年",t.disabled=n<o||n>a}))},t.onScrollStart=function(t,e){let i=parseInt(t[0].textContent),s=e.length;t.forEach(((t,e)=>{if(e<s){let n=i-s+e;t.textContent=n+"年",t.disabled=n<o||n>a}})),e.forEach(((t,e)=>{let s=i+e;t.textContent=s+"年",t.disabled=s<o||s>a}))},t.onScrollEnd=function(t,e,i){let s=parseInt(t[t.length-1].textContent),n=e.length;[...t].reverse().forEach((function(t,e){let i=s+n-e;t.textContent=i+"年",t.disabled=i<o||i>a}))},e.prepend(n),this.element.year=t}let l=t.querySelector(":scope > [selected]");l&&l.removeAttribute("selected"),[...t.children].some((t=>{t.textContent.replace(/\D/g,"")==String(s[0])&&(t.selected=!0,t.position())}))}hour(){let t=this.element.hour,e=this.element.container,s=this.selected;if(!t){t=document.createElement("ui-scroll-snap"),t.setAttribute("type","y"),t.setAttribute("loop",""),t.setAttribute("list","hour"),t.addEventListener("scrollEnd",(t=>{let e=t.detail;if(e.item){s[0]=e.item.textContent.replace(/\D/g,"");let t=this.element.ampm,i=t&&t.querySelector("[selected]");i&&"下午"==i.textContent&&(s[0]=1*s[0]+12),this.selected=s,this.setValue(),this.setStatus()}})),t.innerHTML=this.getHourData(s);let n=document.createElement("div");n.className=i.hour("container"),n.append(t),e.append(n),this.element.hour=t}let n=t.querySelector(":scope > [selected]");return n&&n.removeAttribute("selected"),[...t.children].some((t=>{t.textContent.replace(/\D/g,"")==String(s[0])&&(t.selected=!0,t.position())})),"hour"==this.params.type&&this.minute(s[1]),this}time(){const t=this.element.container,e=this.selected;if("H:mm"!=this.datetimeformat){let s=this.element.ampm;s||(s=document.createElement("ui-scroll-snap"),s.setAttribute("type","y"),s.setAttribute("list","ampm")),s.addEventListener("scrollEnd",(t=>{let i=t.detail;i.item&&("上午"==i.item.textContent?e[0]>=12&&(e[0]-=12):e[0]<12&&(e[0]=1*e[0]+12),e[0]=String(e[0]).padStart(2,"0"),this.selected=e,this.setValue(),this.setStatus())})),s.innerHTML=this.getAmpmData();let n=document.createElement("div");n.className=i.hour("container"),n.append(s),t.prepend(n),this.element.ampm=s}this.hour().minute(),3==e.length&&this.second()}minute(t){"minute"==this.params.type&&this.hour();let e=this.element.minute,s=this.element.container,n=this.selected;if(!e){e=document.createElement("ui-scroll-snap"),e.setAttribute("type","y"),void 0===t&&e.setAttribute("loop",""),e.setAttribute("list","minute"),this.element.minute=e,e.addEventListener("scrollEnd",(t=>{let e=t.detail;e.item&&(n[1]=e.item.textContent.replace(/\D/g,""),this.selected=n,this.setValue(),this.setStatus())})),e.innerHTML=this.getMinuteData(t);let r=document.createElement("div");r.className=i.minute("container"),r.append(e),s.append(r)}let r=e.querySelector(":scope > [selected]");return r&&r.removeAttribute("selected"),[...e.children].some((t=>{if(t.textContent.replace(/\D/g,"")==String(n[1]))return t.selected=!0,t.position(),!0})),this}second(){let t=this.element.second,e=this.element.container,s=this.selected;if(!t){t=document.createElement("ui-scroll-snap"),t.setAttribute("type","y"),t.setAttribute("loop",""),t.setAttribute("list","second"),this.element.minute=t,t.addEventListener("scrollEnd",(t=>{let e=t.detail;e.item&&(s[2]=e.item.textContent.replace(/\D/g,""),this.selected=s,this.setValue(),this.setStatus())})),t.innerHTML=this.getSecondData();let n=document.createElement("div");n.className=i.second("container"),n.append(t),e.append(n)}let n=t.querySelector(":scope > [selected]");return n&&n.removeAttribute("selected"),[...t.children].some((t=>{if(t.textContent.replace(/\D/g,"")==String(s[2]))return t.selected=!0,t.position(),!0})),this}show(){return this.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-datetime"}})),this}hide(){return this.display=!1,this.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-datetime"}})),this}connectedCallback(){let t=this.getAttribute("type");0==["date","year","month","time","hour","minute"].includes(t)&&(t="date",t&&this.removeAttribute("type")),this.params=this.params||{},this.params.type=t,this.setAttribute("readonly","readonly"),this.toggleAttribute("required",!0);let e=this.getAttribute("value")||this.value;switch(t){case"date":case"year":case"month":{const i=e.toDate().toArray();"date"==t?this.value=i.join("-"):"year"==t?this.value=i[0]:"month"==t&&(this.value=i.slice(0,2).join("-")),this.selected=i;break}case"time":{const i=e.toTime();let s=new Date,n=s.getHours(),r=s.getMinutes(),o=s.getSeconds(),a=String(i[0]||n).padStart(2,"0"),l=String(i[1]||r).padStart(2,"0"),h=String(i[2]||o).padStart(2,"0"),d=this.step;"time"==t&&(!d&&i[2]||d>0&&d<=30)?(this.value=[a,l,h].join(":"),this.selected=[a,l,h]):(this.value=[a,l].join(":"),this.selected=[a,l]);break}case"hour":case"minute":{const t=e.toTime();let i=new Date,s=i.getHours(),n=i.getMinutes(),r=String(t[0]||s).padStart(2,"0"),o=String(t[1]||n).padStart(2,"0");this.value=[r,o].join(":"),this.selected=[r,o];break}}if(/time/.test(t)){this.datetimeformat="H:mm";let t=document.createElement("input");if(t.setAttribute("type","time"),t.value="00:00",document.body.append(t),t.style.position="absolute",t.style.left="-999px",t.style.fontFamily="revert","time"==t.type){t.style.fontSize="20px";let e=t.clientWidth;t.style.fontSize="30px";let i=t.clientWidth-e;Math.ceil(i/10)>=5&&(this.datetimeformat="ah:mm"),t.remove()}}this.events(),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-datetime"}})),this.isConnectedCallback=!0}}customElements.get("ui-datetime")||customElements.define("ui-datetime",n,{extends:"input"});const r=(()=>{const t="dialog",e={add:(...t)=>`ui-dialog-${t.join("-")}`,toString:e=>`ui-${e||t}`};let i=function(t){this.element={dialog:t},t.hasAttribute("role")||t.setAttribute("role","dialog"),t.show=this.show.bind(this),t.showModal=this.showModal.bind(this),t.close=this.close.bind(this),t.zIndex=this.zIndex.bind(this),Object.defineProperty(t,"open",{set:this.setOpen.bind(this),get:t.hasAttribute.bind(t,"open")})};i.prototype={get dialog(){return this.element.dialog},show(){this.setOpen(!0),this.zIndex()},showModal(){this.setOpen(!0)},close(){this.setOpen(!1),this.dialog.dispatchEvent(new CustomEvent("close",{bubbles:!1,cancelable:!1}))},setOpen(t){t?this.dialog.setAttribute("open",""):this.dialog.removeAttribute("open")},zIndex(){var t=this.dialog;const e=window.getComputedStyle(t).zIndex;let i=19;document.body.childNodes.forEach((function(e){if(1!==e.nodeType)return;const s=window.getComputedStyle(e),n=1*s.zIndex;n&&t!==e&&"none"!==s.display&&(i=Math.max(n+1,i))})),i!==e&&(t.style.zIndex=i)}};let s=function(s){if(!s.hide||!s.button){if("open"in document.createElement("dialog")==0&&new i(s),"ui-dialog"==s.getAttribute("is")){Object.defineProperties(s,{setParams:{value:function(t){return Object.assign(this.params,t||{}),this.params}},button:{value:function(){const t=this.params,e=this.element;e.footer.innerHTML="";for(const t in e)/^button/.test(t)&&delete e[t];const i=1===t.buttons.length;let s=["取消","确定"],n=1;return 2===t.buttons.length&&t.buttons[0].events&&!t.buttons[1].events&&(s=s.reverse(),n=0),t.buttons.forEach((function(t,r){let o=(t=t||{}).type,a=t.value;o||!i&&r!==n||(o="primary"),a||(a=i?"确定":s[r]);let l=document.createElement("button");if(t.for?(l=document.createElement("label"),l.setAttribute("for",t.for)):t.form&&(l.setAttribute("form",t.form),l.type="reset"==o?o:"submit"),t.className&&(l.className=t.className),l.setAttribute("is","ui-button"),l.setAttribute("blank",""),o){let t=l.hasAttribute("form")?"data-type":"type";l.setAttribute(t,o)}if(l.disabled=Boolean(t.disabled),l.innerHTML=a,r){let t=document.createElement("hr");t.setAttribute("v",""),e.footer.append(t)}e.footer.appendChild(l),e["button"+r]=l})),t.buttons.forEach(((t,i)=>{t=t||{};const s=e["button"+i];if(!s||t.for||t.form)return;let n=t.events||{click:()=>{this[this.closeMode]()}};"function"==typeof n&&(n={click:n});for(const t in n)s.addEventListener(t,(e=>{e.dialog=this,n[t](e)}))})),e.close&&void 0===t.close&&(e.close.style.display=t.buttons.length?"none":""),this}},events:{value:function(){const i=this.element;this.addEventListener("animationend",(function(i){i.target.tagName.toLowerCase()===t&&this.classList.remove(e.add("animation"))}));const s=i.close;return s&&s.addEventListener("click",(()=>{this[this.closeMode]()})),this.dispatchEvent(new CustomEvent("DOMContentLoaded")),this}},alert:{value:function(t,i){if(!t)return;let s=t;const n={title:"",type:"remind",buttons:[{}],close:!1},r={...n,...i};"fail"===r.type&&(r.type="danger"),r.buttons.length&&(r.buttons[0].type||(r.buttons[0].type=r.type,!1===/^(?:remind|primary|success|safe|warn|warning|danger|error)$/.test(r.type)&&(r.buttons[0].type=n.type)),r.buttons[0].value||(r.buttons[0].value="确定"));let o=(new DOMParser).parseFromString(s,"text/html").body.childNodes;return 1==o.length?3===o[0].nodeType&&(s='<p class="'+e.add("wrap")+'">'+s+"</p>"):s='<div class="'+e.add("wrap")+'">'+s+"</div>",s='<div class="'+e.add(r.type)+" "+e.add("alert")+'">'+s+"</div>",this.setParams({width:"auto",title:r.title,buttons:r.buttons,content:s}),this.type="alert",this.show(),this}},confirm:{value:function(t,i){if(!t)return;let s=t;const n={title:"",type:"danger",buttons:[{},{}],close:!1},r={...n,...i};"error"!==r.type&&"fail"!==r.type||(r.type="danger"),"primary"===r.type&&(r.type="remind"),2===r.buttons.length&&(r.buttons[0].events&&!r.buttons[1].events&&(r.buttons=r.buttons.reverse()),r.buttons[1].type||(r.buttons[1].type=r.type,!1===/^(?:remind|primary|success|safe|warn|warning|danger|error)$/.test(r.type)&&(r.buttons[1].type=n.type)));let o=(new DOMParser).parseFromString(s,"text/html").body.childNodes;return 1==o.length?o[0].nodeType===Node.TEXT_NODE&&(s='<p class="'+e.add("wrap")+'">'+s+"</p>"):s='<div class="'+e.add("wrap")+'">'+s+"</div>",s='<div class="'+e.add(r.type)+" "+e.add("confirm")+'">'+s+"</div>",this.setParams({width:"auto",title:r.title,buttons:r.buttons,content:s}),this.type="confirm",this.show(),this}},loading:{value:function(){const t=this.element.dialog;return this.params.content='<ui-loading rows="10" size="3"></ui-loading>',t.classList.add(e.add("loading")),setTimeout((()=>{/loading/.test(t.className)&&t.addEventListener("click",(()=>{/loading/.test(t.className)&&this.remove()}))}),1e4),this.show(),this}},content:{get(){return this.params.content},set(t){if(t!=this.params.content)return void(this.params.content=t);let i=this.element.body;if(this.element.dialog.classList.remove(e.add("loading")),"function"==typeof t)t=t();else if("string"==typeof t&&/^#?\w+(?:[-_]\w+)*$/i.test(t)){let e=document.querySelector(t);e&&(t=e.matches("textarea")?e.value:e.matches("script")?e.innerHTML:e)}if(this.closeMode="string"==typeof t?"remove":"hide","hide"==this.closeMode&&i.innerHTML){let t=document.createElement("div");t.setAttribute("hidden",""),i.childNodes.forEach((e=>{t.appendChild(e)})),document.body.appendChild(t)}if(i.innerHTML="","remove"==this.closeMode)i.innerHTML=t;else{let e=t.parentElement,s=e&&e.matches("div[hidden]");i.appendChild(t),s&&""===e.innerHTML.trim()&&e.remove(),1===t.nodeType&&"none"==getComputedStyle(t).display&&(t.removeAttribute("hidden"),t.style.display="","none"==getComputedStyle(t).display&&(t.style.display="revert"))}}},scrollbar:{value:function(){const t=document.querySelectorAll('dialog[is="ui-dialog"]'),e=[].slice.call(t).some((function(t){return"none"!==window.getComputedStyle(t).display}));document.documentElement.style.overflow="",document.body.style.borderRight="";let i=window.innerWidth-document.documentElement.clientWidth;return e&&(document.documentElement.style.overflow="hidden",document.body.style.borderRight=i+"px solid transparent"),this}},tabindex:{value:function(){var t=this.element.dialog,e=this.lastActiveElement;if(1==this.open){var i=document.activeElement;"alert"==this.type||"confirm"==this.type?(this.element.button0!=i&&(this.lastActiveElement=i),this.element.button0.focus()):t&&(t!=i&&(this.lastActiveElement=i),t.focus())}else e&&"body"!=e.tagName.toLowerCase()&&(e.focus(),e.blur(),this.lastActiveElement=null);return this}},show:{value:function(){return!0!==this.open&&this.classList.add(e.add("animation")),this.open=!0,this.zIndex&&this.zIndex(),this.element.close&&void 0!==this.params.close&&(this.element.close.style.display=this.params.close?"":"none"),this.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-dialog"}})),this}},hide:{value:function(){return this.close(),this.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-dialog"}})),this}},remove:{value:function(){return this.open=!1,this.parentElement.removeChild(this),this.dispatchEvent(new CustomEvent("remove",{detail:{type:"ui-dialog"}})),this}}}),s.params=new Proxy(s.params||{},{get:(t,e)=>t[e],set(t,i,n){if(!s.element)return!1;if(t[i]=n,"title"==i&&s.element.title)s.element.title.innerHTML=n;else if("content"==i)s.content=n;else if("buttons"==i)s.button();else if(s.element.dialog&&("width"==i||"height"==i)){let t=s.element.dialog;t.classList.remove(e.add("stretch")),""!==n&&Number(n)==n?t.style[i]=n+"px":"height"==i&&"stretch"==n?t.classList.add(e.add(n)):("auto"==n&&(n=""),t.style[i]=n)}return!0}});const i=document.createElement("div");i.classList.add(e),i.setAttribute("tabindex","-1");const n=document.createElement("h4");n.classList.add(e.add("title")),n.innerHTML=s.title,s.removeAttribute("title");const r=document.createElement("button");r.textContent="关闭",r.classList.add(e.add("close"));const o=document.createElement("div");o.classList.add(e.add("body"));const a=document.createElement("div");a.classList.add(e.add("footer")),s.element=Object.assign(s.element||{},{dialog:i,close:r,title:n,body:o,footer:a});let l=[...s.childNodes];l.length&&l.forEach((t=>{o.append(t)})),i.append(r,n,o,a),s.append(i),new MutationObserver((function(t){t.forEach((t=>{let e=t.target;"attributes"==t.type&&(e.scrollbar(),e.tabindex())}))})).observe(s,{attributes:!0,attributeFilter:["open"]}),s.closeMode="hide",s.events()}s.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-dialog"}})),s.setAttribute("defined",""),s.isConnectedCallback=!0}},n=function(){document.querySelectorAll("dialog").forEach((t=>{s(t)})),new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){t.matches&&t.matches("dialog")?s(t):t.querySelector&&t.querySelectorAll("dialog").forEach((t=>{s(t)}))}))}))})).observe(document.body,{childList:!0,subtree:!0})};return"loading"!=document.readyState?n():window.addEventListener("DOMContentLoaded",n),class{constructor(e={}){const i={title:"",content:"",width:"auto",height:"auto",buttons:[],onShow:function(){},onHide:function(){},onRemove:function(){},...e};i.buttons.length&&void 0===i.close&&(i.close=!1);const n=document.createElement(t);n.setAttribute("is","ui-dialog"),n.addEventListener("DOMContentLoaded",(()=>{'"{}"'!=JSON.stringify(e)&&(n.setParams({title:i.title,width:i.width,height:i.height,content:i.content,buttons:i.buttons,close:i.close}),"function"==typeof e.onShow&&n.addEventListener("show",(function(t){e.onShow.call(n,t)})),"function"==typeof e.onHide&&n.addEventListener("hide",(function(t){e.onHide.call(n,t)})),"function"==typeof e.onRemove&&n.addEventListener("remove",(function(t){e.onRemove.call(n,t)}))),n.show()}));const r=document.querySelector("body > dialog");return r?r.insertAdjacentElement("beforebegin",n):document.body.appendChild(n),s(n),n}}})();window.Dialog=r;class o extends HTMLElement{static get observedAttributes(){return["open","target"]}static get defaults(){return{eventtype:"click",position:"7-5"}}constructor(t,e,i){super(),i=i||{},this.params=this.params||{},this.params=new Proxy(this.params,{get:(t,e)=>{if(!e)return;let i=t[e=e.toLowerCase()],s=this.element.trigger;return void 0===i&&(i=s.getAttribute(e)||s.dataset[e],"width"==e&&(i=s!==this?s.dataset[e]:s.getAttribute(e)),void 0===i&&o.defaults[e]&&(i=o.defaults[e])),i},set:(t,e,i)=>(t[e.toLowerCase()]=i,!0)});let s=this.element||{};this.element=new Proxy(s,{get:(t,e)=>{if("target"==e){let i=this.getAttribute("target"),s=t[e];return!s&&i&&(s=document.getElementById(i)),s}return"trigger"==e?t[e]||this:t[e]},set:(t,e,i)=>{if("string"==typeof i&&(i=document.getElementById(i)||document.querySelector(i)),i&&"number"!=typeof i.nodeType)return!1;if(t[e]=i,"target"==e&&i){let t=i,e=t.id;e||(e=("lulu_"+Math.random()).replace("0.",""),t.id=e);let s=this.element.trigger;if(s==this)this.target!=e&&(this.target=e);else if(s){let t=s.dataset.target;t&&document.querySelector('datalist[id="'+t+'"]')?s.setAttribute("data-target2",e):s.setAttribute("data-target",e)}}return!0}}),[...arguments].forEach((function(t){"object"==typeof t&&t&&!t.tagName&&(i=t)})),t&&(this.element.trigger=t),(t=this.element.trigger)&&(e&&e!==i?this.element.target=e:!e&&t.dataset&&t.dataset.target&&(this.element.target=t.dataset.target)),this.setParams(i),this.open&&("loading"!=document.readyState?this.show():window.addEventListener("DOMContentLoaded",(()=>{this.show()}))),t!==this&&(this.addEventListener("connected",(function(){this.remove()})),t["ui-drop"]=this,document.body.append(this))}get htmlFor(){return this.getAttribute("for")}set htmlFor(t){this.setAttribute("for",t)}get target(){return this.getAttribute("target")}set target(t){this.setAttribute("target",t)}get open(){return this.hasAttribute("open")}set open(t){this.toggleAttribute("open",t)}setParams(t){let e=(t=t||{}).onShow,i=t.onHide;"function"==typeof e&&(this.addEventListener("show",(function(t){e.call(this,t)})),delete t.onShow),"function"==typeof i&&(this.addEventListener("hide",(function(t){i.call(this,t)})),delete t.onHide),Object.assign(this.params,t||{})}events(t){let e=this.element.trigger,i=this.element.target;if(!i&&!t)return;if(i&&i.matches("datalist"))return;const s=this.params;switch(s.eventType){case"null":default:break;case"click":e.isBindDropEvents&&e.isBindDropEvents===s.eventType||e.addEventListener(s.eventType,(t=>{t.preventDefault();const i=(t=>{if(!s.selector)return null;const i=t.closest(s.selector);return 0==e.contains(i)?null:i})(t.target);if(i&&(this.element.trigger=i),!s.selector||i){if("contextmenu"==s.eventType)return s.position=[t.pageX,t.pageY],void this.show();this.open?this.hide():this.show()}}))}"null"==s.eventType||e.isBindDocMouseUp||(document.addEventListener("mouseup",(t=>{let e=t&&t.target;if(!e||!this.open)return;let i=this.element.trigger,s=this.element.target;0!=i.contains(e)||s&&0!=s.contains(e)||this.hide()})),e.isBindDocMouseUp=!0),e.isBindDropEvents=s.eventType||!0,window.addEventListener("resize",(()=>{this.position()})),this.dispatchEvent(new CustomEvent("DOMContentLoaded")),e!=this&&e.dispatchEvent(new CustomEvent("DOMContentLoaded"))}position(){let t=this.element.trigger,e=this.element.target;return this.open&&e&&"none"!=window.getComputedStyle(t).display&&t.follow(e,{offsets:this.params.offsets,position:this.params.position,edgeAdjust:this.params.edgeAdjust}),this}show(){let t=this.element.trigger,e=this.element.target;return e&&0==document.body.contains(e)&&document.body.appendChild(e),e&&(e.style.position="absolute",e.style.display="inline",e.style.outline="none",e.tabIndex=-1,e.focus({preventScroll:!0}),e.element=e.element||{},e.element.trigger=this),t.setAttribute("aria-expanded","true"),this.open||(this.open=!0),this.position(),this.dispatchEvent(new CustomEvent("show")),t!=this&&t.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-drop"}})),this}hide(){let t=this.element.trigger,e=this.element.target;return e&&(e.style.display="none",e.classList.remove("ESC"),e.element&&delete e.element.trigger),t.setAttribute("aria-expanded","false"),window.isKeyEvent&&t.focus(),this.open&&(this.open=!1),this.dispatchEvent(new CustomEvent("hide")),t!=this&&t.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-drop"}})),this}connectedCallback(){let t=this.element.target,e=this.element.trigger;e.open?e.setAttribute("aria-expanded","true"):e.setAttribute("aria-expanded","false"),t?t.matches("datalist")?setTimeout((()=>{this.list&&this.list(t)}),1):this.events():this.events(e===this),this.querySelector("a, button")||this.closest("a, button")||(this.tabIndex=0,this.role="button"),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-drop"}})),e!=this&&e.hasAttribute("is-drop")&&(e.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-drop"}})),e.setAttribute("defined","")),this.isConnectedCallback=!0}attributeChangedCallback(t,e,i){if("target"==t){let t=document.getElementById(i);t&&(this.element.target=t)}else if("open"==t){let t=this.element.trigger.getAttribute("aria-expanded");this.open&&"false"==t?this.show():this.open||"true"!=t||this.hide()}}}window.Drop=o,customElements.get("ui-drop")||customElements.define("ui-drop",o),HTMLElement.prototype.drop=function(t,e){return this.matches("ui-drop, [is-drop]")||this["ui-drop"]||(this["ui-drop"]=new o(this,t,e)),this};const a=t=>{(t||document.querySelectorAll("[is-drop]")).forEach((t=>{let e=t.getAttribute("is-drop");e&&!t.dataset.target&&(t.dataset.target=e),e=t.dataset.target;let i=e&&document.getElementById(e);i&&(t["ui-drop"]=new o(t,i))}))},l=()=>{a();new MutationObserver((t=>{t.forEach((t=>{t.addedNodes&&t.addedNodes.forEach((t=>{t.tagName&&(t.hasAttribute("is-drop")?a([t]):a(t.querySelectorAll("[is-drop]")))}))}))})).observe(document.body,{childList:!0,subtree:!0})};"loading"!=document.readyState?l():window.addEventListener("DOMContentLoaded",l),o.prototype.list=function(t,e,i){const s=function(t){let e={id:t.id||t.value,value:t.innerHTML||t.value,className:t.className,disabled:t.disabled,label:t.label,accessKey:t.accessKey},i=t.closest("optgroup");return i&&i.disabled&&(e.disabled=!0),t.hasAttribute("href")&&(e.href=t.getAttribute("href")),e};if([...arguments].forEach((n=>{const r=typeof n;"string"===r?t=document.getElementById(n)||document.querySelector(n):"function"===r?e=n:"object"===r&&("number"==typeof n.nodeType?n.matches("datalist")?(e=function(){let t=n.querySelectorAll("optgroup"),e=!!n.querySelector("optgroup[label]");if(t.length){let i=[];return t.forEach((t=>{e?i.push({id:"-1",value:t.label,disabled:t.disabled,className:t.className,heading:!0}):i.push({}),t.querySelectorAll("option").forEach((t=>{i.push(s(t))}))})),i}return[...n.querySelectorAll("option")].map(((t,e)=>{let i=s(t);return i.value?(i.id||(i.id=e),i):{}}))},t==n&&(t=null)):t=n:n.map?e=n:i=n)})),t&&"number"!=typeof t.nodeType&&(t=null),!(t=t||this.element.trigger))return this;e||(e=[]);const n={eventType:"click",offsets:{x:0,y:0},position:"4-1",selector:"",width:"",onShow:()=>{},onHide:()=>{},onSelect:()=>{}},r={};i=i||{},Object.keys(n).forEach((t=>{r[t]=i[t]||this.params[t]||n[t]}));const o="selected",a="disabled",l={add:function(){return["ui-droplist"].concat([].slice.call(arguments)).join("-")},toString:()=>"ui-droplist"};let h="innerHTML";t.matches("input")&&(h="value");let d=document.createElement("div");d.setAttribute("role","listbox"),d.setAttribute("tabindex","-1"),/^\d+$/.test(r.width)?d.style.width=r.width+"px":d.style.width=r.width,d.className=l.add("x"),this.data=e;let c=e,u=e=>{let i="-1",s=!1,n=(e,r)=>{e&&e.length&&e.forEach(((e,l)=>{const d=r.concat(l);e&&e.data?n(e.data,d):(e&&e[o]&&!e[a]&&e.value&&(t[h]=e.value,i=d.join("-")),e&&e[o]&&(s=!0))}))};n(e,[]);const r=(t[h]||"").trim();return 0==s&&r&&(n=(t,e)=>{t&&t.length&&t.forEach(((t,s)=>{const a=e.concat(s);t&&t.data?n(t.data,a):"string"==typeof t.value&&t.value.trim()==r&&(i=a.join("-"),t[o]=!0)}))},n(e,[])),i},p=-1;"function"!=typeof e&&e.length&&e.map&&(p=u(c));const m=(t,e)=>{"function"==typeof e&&(e=e(),p=u(e));let i=(e=e&&e.length?e.map((t=>"string"==typeof t&&"-"!==t?{value:t}:t)):[{value:"没有数据",disabled:!0}]).some((t=>t&&t[o]));t.innerHTML=(()=>{let t="";const s=(t,e)=>{let n="";return t.forEach(((t,r)=>{if("-"==t||null===t||"{}"==JSON.stringify(t))return void(n+='<hr class="'+l.add("hr")+'">');const h=e.concat(r);let d=t.href;"string"!=typeof d?d="javascript:":d||(d=location.href.split("#")[0]);let c="";t.target&&(c=' target="'+t.target+'"');let u="";t.data&&(u=" data-sublist");let m="";t.label&&(m=' aria-label="'+t.label+'"');let g="";t.accessKey&&(g=` accesskey="${t.accessKey}"`),0==i&&p==h.join("-")&&(t[o]=!0);let b=l.add("li")+" "+t.className;if(t[o]&&(b=b+" "+o),b=b.trim(),1==t.heading)return t.disabled&&(b+=" disabled"),void(n+='<div class="'+b+'"'+m+' role="heading">'+t.value+"</div>");1!=t[a]?(n+='<a href="'+d+'"'+c+m+g+' class="'+b+'" data-index="'+h.join("-")+'" role="option" aria-selected="'+(t[o]||"false")+'" '+u+">"+t.value+"</a>",t.data&&(n+='<div class="'+l.add("xx")+'"><div class="'+l.add("x")+'" role="listbox">'+s(t.data,h)+"</div></div>")):n+='<span class="'+b+'"'+m+g+">"+t.value+"</span>"})),n};return t+=s(e,[]),t})(),t.listData=e};return this.setParams({eventType:r.eventType,offsets:r.offsets,selector:r.selector,position:r.position,onShow:function(){m.call(this,d,this.data),r.onShow.apply(this,arguments)},onHide:r.onHide}),this.element.trigger=t,this.element.target=d,this.events(),d.addEventListener("click",(e=>{if(1!=e.target.nodeType||!e.target.closest)return;const i=e.target.closest("a");if(!i)return;const s=d.listData,n=i.getAttribute("data-index");if(!n)return;let a=null;if(n.split("-").forEach((t=>{a=null===a?s[t]:a.data?a.data[t]:a[t]})),a){if("string"==typeof i.getAttribute("data-sublist")){i.classList.add(o);const t=i.nextElementSibling.querySelector("."+l.add("x"));if(!t)return;t.style.transform="",t.classList.remove("reverse");const e=t.getBoundingClientRect();e.right>document.documentElement.clientWidth&&t.classList.add("reverse");let s=0;return e.bottom>window.innerHeight&&(s=window.innerHeight-e.bottom),void(t.style.transform="translateY("+s+"px)")}if(n!=p){let t=null;"-1"!=p&&(p.split("-").forEach((e=>{t=null===t?s[e]:t.data?t.data[e]:t[e]})),t&&delete t[o]),a[o]=!0,p=n}(this.params.onSelect||r.onSelect).call(this,a,i),this.dispatchEvent(new CustomEvent("select",{detail:{data:a,target:i}})),t!=this&&t.dispatchEvent(new CustomEvent("select",{detail:{type:"ui-drop",data:a,target:i}})),"contextmenu"==r.eventType||""!=r.selector||a.href||(t[h]=a.value),this.hide()}})),d.addEventListener("mouseover",(t=>{if(1!=t.target.nodeType||!t.target.closest)return;const e=t.target.closest("a");if(!e)return;const i=e.parentElement.querySelector("."+o+"[data-sublist]");i&&i!=e&&i.classList.remove(o),0==e.classList.contains(o)&&"string"==typeof e.getAttribute("data-sublist")&&e.click()})),this};class h{static allHide(t){h.collectionErrorTip.forEach((e=>{t!=e&&e.hide()}))}constructor(t,e,i){const s={unique:!0,onShow:()=>{},onHide:()=>{},...i};let n=e;if("function"==typeof n&&(n=n()),"string"!=typeof n)return this;const r=t;let o,a=r.data&&r.data.errorTip;if(a)return a.content=n,a.callback={show:s.onShow,hide:s.onHide},a.element.tips.trigger=r,a.show(),this;let l=h.collectionErrorTip;const d=l[l.length-1];o=1==s.unique&&d?d.element.tips:0==s.unique&&r.data&&r.data.errorTip?r.data.errorTip.element.tips:this.create(),1==s.unique&&0==l.includes(this)&&l.push(this),o.trigger=r,this.element={trigger:r,tips:o},this.callback={show:s.onShow,hide:s.onHide},this.params={unique:s.unique},this.content=n,r.data||(r.data={}),r.data.errorTip=this,this.show()}create(){let t=document.createElement("div");return t.className="ui-tips-x ui-tips-error",document.body.appendChild(t),this.events(t),t}events(t){document.addEventListener("keydown",(t=>{/Control|Shift/i.test(t.code)||(h.allHide(this),this.hide())})),document.addEventListener("mousedown",(e=>{const i=document.activeElement,s=t.trigger,n=e.target;i&&s&&i==n&&i==s&&!s.getAttribute("data-focus")||(h.allHide(this),this.hide())})),window.addEventListener("resize",(()=>{h.allHide(this),this.hide()}))}show(){const t=this.element,e=t.tips,i=t.trigger;e.innerHTML=this.content,e.style.display="",i.follow(e,{position:"5-7",edgeAdjust:!1}),i.setAttribute("aria-label","错误提示:"+this.content),i.toggleAttribute("is-error",!0),i.classList.add("valided"),this.display=!0,this.callback&&this.callback.show&&this.callback.show.call(this,i,e),i.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-errortip",content:this.content}}))}hide(){if(!this.display)return;const t=this.element.tips,e=this.element.trigger;e.removeAttribute("aria-label"),e.removeAttribute("is-error"),t.style.display="none",this.display=!1,this.callback&&this.callback.hide&&this.callback.hide.call(this,e,t),e.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-errortip"}}))}}h.collectionErrorTip=[],window.ErrorTip=h,HTMLElement.prototype.errorTip=function(t,e={}){return new h(this,t,e),this},HTMLElement.prototype.follow=function(t,e){let i={offsets:{x:0,y:0},safeArea:[0,0,0,0],position:"4-1",edgeAdjust:!0};for(var s in t&&"[object Object]"===Object.prototype.toString.call(t)&&(e=t,t=null),e||(e={}))void 0===e[s]&&delete e[s];let n=Object.assign({},i,e);if(!t){let e=this.getAttribute("is-follow")||this.dataset.target;if(!e)return;if(!(t=document.getElementById(e)||document.querySelector("."+e)||document.querySelector(e)))return}let r=["4-1","1-4","5-7","2-3","2-1","6-8","3-4","4-3","8-6","1-2","7-5","3-2"],o=this.dataset.offsets,a=[];n.offsets.map&&n.offsets.length?a=n.offsets:"string"==typeof n.offsets&&(a=n.offsets.trim().split(/,\s*|\s+/)),o&&!e.offsets&&(a=o.trim().split(/,\s*|\s+/)),a.length&&(n.offsets={},n.offsets.x=a[0],n.offsets.y=a[1]||a[0]);let l=this.dataset.offsetX,h=this.dataset.offsetY;l&&(n.offsets.x=l),h&&(n.offsets.y=h),n.offsets.x*=1,n.offsets.y*=1;let d=this.dataset.position,c=this.dataset.align,u=r.some((t=>t===c));!d&&c&&u&&(d=c),!d||e&&e.position||(n.position=d);let p=this.dataset.edgeAdjust||n.edgeAdjust,m=!("0"===p||"none"===p||"false"===p||!1===p);"string"==typeof p&&"boolean"!=typeof n.edgeAdjust&&(n.edgeAdjust=m);let g=t.style.position;"absolute"!=g&&(t.style.position="absolute");let b=this.getBoundingClientRect(),f=t.getBoundingClientRect();if(f.width*f.height==0)return t.style.position=g||"",void window.console.warn((t.id?"id为"+t.id+"的":"")+"目前元素尺寸为0,无法定位");let y=window.pageYOffset,v=window.pageXOffset,E=window.innerWidth,A=window.innerHeight;(b.left<0&&b.right<0||b.top<0&&b.bottom<0||b.left>E&&b.right>E||b.top>A&&b.bottom>A)&&(n.edgeAdjust=m=!1);let w=t.offsetParent,x=w.getBoundingClientRect();const C={follow:t};this.element=this.element?Object.assign(this.element,C):C,this.params=this.params?Object.assign(this.params,n):n;let L=n.offsets,S=x.top+y,M=x.left+v;w===document.body&&"static"===window.getComputedStyle(w).position&&(S=0,M=0);let N,T,k=n.position,P=function(){let e=window.getComputedStyle(t),i=Number(e.zIndex),s=19;w.childNodes.forEach((e=>{if(1!==e.nodeType)return;let i=window.getComputedStyle(e),n=1*i.zIndex;n&&t!==e&&"none"!==i.display&&(s=Math.max(n+1,s))})),s!==i&&(t.style.zIndex=s)};if("string"!=typeof k&&2===k.length){let e=k;return N=e[0]+L.x,T=e[1]+L.y,!0===n.edgeAdjust&&(N+f.width>E+v&&(N=E+v-f.width-L.x),T+f.height>A+y&&(T=A+y-f.height-L.y)),t.style.left=`${N}px`,t.style.top=`${T}px`,t.dataset.align="3-1",void P()}!1===r.some((t=>t===k))&&(k=i.position);let H=this.dataset.safeArea||getComputedStyle(t).getPropertyValue("--safe-area")||n.safeArea;"string"==typeof H&&(H=H.trim().split(/(?:,\s*|\s+)/)),H=H.map((function(t){return parseFloat(t)||0})),1==H.length?H=H.concat(H[0],H[0],H[0]):2==H.length?(H.push(H[0]),H.push(H[1])):3==H.length&&H.push(H[1]);const I=f.width+L.x+H[3]>b.left,O=b.top-(f.height+L.y+H[0])<0,j=b.right+f.width+L.x+H[1]>E,$=b.bottom+f.height+L.y+H[2]>A;f.width,L.x,H[3],b.right,b.left,f.width,L.x,H[1],f.height,L.y,H[0],b.bottom,b.top,f.height,L.y,H[2];let q="bottom";var D=()=>{switch(k){case"1-4":case"5-7":case"2-3":T=b.top-f.height,N="1-4"===k?b.left:"5-7"===k?b.left-(f.width-b.width)/2:b.left-(f.width-b.width),q="top",m&&O&&($?I&&j||(k={"1-4":"2-1","5-7":"6-8","2-3":"3-4"}[k],D()):(k={"1-4":"4-1","5-7":"7-5","2-3":"3-2"}[k],D()));break;case"2-1":case"6-8":case"3-4":N=b.right,T="2-1"===k?b.top:"6-8"===k?b.top-(f.height-b.height)/2:b.top-(f.height-b.height),q="right",m&&j&&(I?O&&$||(k={"2-1":"1-4","6-8":"5-7","3-4":"2-3"}[k],D()):(k={"2-1":"1-2","6-8":"8-6","3-4":"4-3"}[k],D()));break;case"4-1":case"7-5":case"3-2":T=b.bottom,N="4-1"===k?b.left:"7-5"===k?b.left-(f.width-b.width)/2:b.left-(f.width-b.width),q="bottom",m&&$&&(O?I&&j||(k={"4-1":"2-1","7-5":"6-8","3-2":"3-4"}[k],D()):(k={"4-1":"1-4","7-5":"5-7","3-2":"2-3"}[k],D()));break;case"1-2":case"8-6":case"4-3":N=b.left-f.width,T="1-2"===k?b.top:"8-6"===k?b.top-(f.height-b.height)/2:b.top-(f.height-b.height),q="left",m&&I&&(j?O&&$||(k={"1-2":"1-4","8-6":"5-7","4-3":"2-3"}[k],D()):(k={"1-2":"2-1","8-6":"6-8","4-3":"3-4"}[k],D()))}};D(),N=N+L.x-M,T=T+L.y-S,m&&("top"==q?T-=H[2]:"bottom"==q?T+=H[0]:"left"==q?N-=H[1]:N+=H[3]),T+=y,N+=v,t.style.left=`${Math.round(N)}px`,t.style.top=`${Math.round(T)}px`,f=t.getBoundingClientRect(),m&&("top"==q||"bottom"==q?f.left<H[3]?N+=H[3]-f.left:f.right+H[1]>E&&(N-=f.right+H[1]-E):f.top<H[0]?T+=H[0]-f.top:f.bottom+H[2]>A&&(T-=f.bottom+H[2]-A),t.style.left=`${Math.round(N)}px`,t.style.top=`${Math.round(T)}px`),t.dataset.align=k,t.dataset.direction=q,P(),t.zIndex||(t.zIndex=P)},[NodeList.prototype,HTMLCollection.prototype].forEach((t=>{t.follow=function(){[...this].forEach((t=>{1===t.nodeType&&t.follow.apply(t,this.arguments)}))}}));class d extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),arguments.length&&d.custom.apply(this,arguments)}get type(){return this.getAttribute("type")}get time(){let t=this.getAttribute("time");return isNaN(t)||isNaN(parseFloat(t))?3e3:Number(t)}set type(t){this.setAttribute("type",t)}set time(t){this.setAttribute("time",t)}get open(){return this.hasAttribute("open")}set open(t){this.toggleAttribute("open",t)}connectedCallback(){this.closeMode||(this.closeMode="hide"),this.addEventListener("click",(()=>{this[this.closeMode]()})),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-float"}})),this.isConnectedCallback=!0}attributeChangedCallback(t,e,i){"open"==t&&typeof e!=typeof i&&"string"==typeof i&&(clearTimeout(this.timer),this.time&&(this.timer=setTimeout((()=>{this[this.closeMode](),this.position()}),this.time)),this.setAttribute("data-tid",this.timer),this.zIndex(),this.position())}zIndex(){var t=19;this.parentElement&&[...this.parentElement.childNodes].forEach((function(e){if(1==e.nodeType){var i=window.getComputedStyle(e),s=1*i.zIndex;s&&"none"!=i.display&&(t=Math.max(s+1,t))}})),this.style.zIndex=t}position(){}static custom(t="",e,i){if(!this.matches||!this.matches("ui-float"))return d.custom.apply(document.createElement("ui-float"),arguments);if("object"==typeof t&&(e=t,t=""),"string"!=typeof t)return this;if(this.closeMode="remove",e&&"object"==typeof e)d.custom.call(this,t,e.type,e.time);else{if("number"!=typeof e)return(i||0===i)&&(this.time=i),e&&(this.type=e),this.innerHTML=t,this.parentElement||(document.body.appendChild(this),this.dispatchEvent(new CustomEvent("DOMContentLoaded"))),this.show(),this;d.custom.call(this,t,i,e)}}remove(){this.parentElement&&this.parentElement.removeChild(this),this.open=!1}show(){this.time>0&&(this.open=!0)}hide(){this.open=!1}}customElements.get("ui-float")||customElements.define("ui-float",d),window.UiFloat=d,window.FollowText=function(t,e,i){const s=document.createElement("ui-float");var n,r;[e,i].forEach((function(t){"string"==typeof t?n=t:"object"==typeof t&&(r=t)})),r||(r={x:-100,y:-100}),n=[n||r.type||"","text"].join(" ");var o=r.pageX||r.x,a=r.pageY||r.y;return"number"!=typeof o&&(o=window.innerWidth/2),"number"!=typeof a&&(a=window.pageYOffset+window.innerHeight/2),s.innerHTML=t||"",s.type=n,s.open=!0,document.body.append(s),s.addEventListener("animationend",(function(){document.body.removeChild(s)})),s.style.left=o-s.clientWidth/2+"px",s.style.top=a-s.clientHeight+"px",s},FollowText.success=function(t,e){return this.custom(t,"success",e)},FollowText.error=function(t,e){return this.custom(t,"error",e)},FollowText.warning=function(t,e){return this.custom(t,"warning",e)},FollowText.custom=function(){return FollowText(...arguments)};class c extends HTMLFormElement{constructor(){return super(),this.element=this.element||{},this.params=this.params||{},this.callback=this.callback||{},Object.defineProperty(this.params,"validate",{set(t){this.validate&&this.validate.setCustomValidity(t)}}),this}ajax(){let t=this.callback;t=t||function(){},"function"==typeof t&&(t={success:t});let e=null,i=this.element.submit;e=i.id&&document.querySelector("label[for="+i.id+"]"),e||(e=i),this.element.button=e;let s=this.action.split("#")[0]||location.href.split("#")[0],n=this.method||"POST",r=this.enctype;e.loading=!0,i.setAttribute("disabled","disabled");let o=new FormData(this);this.params.data&&Object.keys(this.params.data).forEach((t=>{o.append(t,this.params.data[t])}));let a=new URLSearchParams(o).toString();"get"==n.toLowerCase()&&(s=s.split("?").length>1?s+"&"+a:s+"?"+a);let l=new XMLHttpRequest;l.open(n,s),t.beforeSend&&t.beforeSend.call(this,l,o),l.onload=()=>{let e={};try{e=JSON.parse(l.responseText)}catch(e){return new LightTip("返回数据解析出错。","error"),t.error&&t.error.call(this,e),void this.dispatchEvent(new CustomEvent("error",{detail:{data:{code:-1,msg:"解析出错"}}}))}!e||0!==e.code&&0!==e.error?(new LightTip(e&&e.msg||"返回数据格式不符合要求。","error"),t.error&&t.error.call(this,e),this.dispatchEvent(new CustomEvent("error",{detail:{data:e}}))):(t.success?t.success.call(this,e):(new LightTip(e.msg||"操作成功。","success"),this.reset()),this.dispatchEvent(new CustomEvent("success",{detail:{data:e}})))},l.onerror=()=>{new LightTip("网络异常,刚才的操作没有成功,您可以稍后重试。","error"),t.error&&t.error.apply(this,arguments),this.dispatchEvent(new CustomEvent("error",{detail:{code:-1,msg:"网络异常"}}))},l.onloadend=()=>{e.loading=!1,i.removeAttribute("disabled"),t.complete&&t.complete.apply(this,arguments),this.dispatchEvent(new CustomEvent("complete"))},r&&"application/x-www-form-urlencoded"===r.toLowerCase()?l.send(a):l.send(o)}connectedCallback(){let t=[...this.elements].filter((function(t){return t.type&&/^(?:submit|image)$/i.test(t.type)}))[0]||this.querySelector("button:nth-last-of-type(1)");t||(t=(()=>{let t=document.createElemen