selective-ui 1.2.6 → 1.2.7
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/README.md +0 -7
- package/dist/selective-ui.esm.js +11 -8
- package/dist/selective-ui.esm.js.map +1 -1
- package/dist/selective-ui.esm.min.js +2 -2
- package/dist/selective-ui.esm.min.js.br +0 -0
- package/dist/selective-ui.min.js +2 -2
- package/dist/selective-ui.min.js.br +0 -0
- package/dist/selective-ui.umd.js +12 -9
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +11 -2
- package/src/ts/adapter/mixed-adapter.ts +1 -0
- package/src/ts/core/search-controller.ts +2 -1
- package/src/ts/global.ts +2 -2
- package/src/ts/index.ts +2 -2
- package/src/ts/models/group-model.ts +1 -2
- package/src/ts/services/ea-observer.ts +7 -5
- package/src/ts/types/core/base/mixed-adapter.type.ts +9 -5
- package/src/ts/types/core/search-controller.type.ts +69 -35
- package/src/ts/types/services/select-observer.type.ts +9 -5
package/dist/selective-ui.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Selective UI v1.2.
|
|
2
|
-
var t,s;t=this,s=function(t){"use strict";function s(t){return new m(t??null)}class i{constructor(){this.t={accessoryVisible:!0,virtualScroll:!0,accessoryStyle:"top",multiple:!1,minWidth:"50px",width:"0px",offsetWidth:null,minHeight:"30px",height:"30px",panelHeight:"220px",panelMinHeight:"100px",disabled:!1,readonly:!1,selectall:!0,keepSelected:!0,placeholder:"Select value",altMask:"",autoclose:!1,autoscroll:!0,autofocus:!0,searchable:!0,loadingfield:!0,visible:!0,skipError:!1,customDelimiter:",",textLoading:"Processing...",textNoData:"No data available",textNotFound:"Not found",textSelectAll:"Select all",textDeselectAll:"Deselect all",textAccessoryDeselect:"Deselect: ",animationtime:200,delaysearchtime:200,allowHtml:!1,maxSelected:0,labelHalign:"left",labelValign:"center",imageMode:!1,imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",imagePosition:"right",ajax:null,on:{load:[],beforeShow:[],show:[],beforeChange:[],change:[],beforeClose:[],close:[]}},this.i=new Map,this.h=new Map,this.o=[]}}class e{static get l(){return this.u||(this.u=new i),this.u}static p(t){if(null===t||"object"!=typeof t)return t;const s=Array.isArray(t)?[]:{};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=this.p(t[i]));return s}static m(t=6){let s="";for(let i=0;i<t;i++)s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return s}static v(t){if(!t)return[];if("string"==typeof t){const s=document.querySelectorAll(t);return Array.from(s)}return t instanceof HTMLElement?[t]:t instanceof NodeList||Array.isArray(t)?Array.from(t):[]}static M(t={}){return this.T(document.createElement(t.node??"div"),t,!0)}static T(t=document.documentElement,s=null,i=!1){const e={...s??{}},h=i?t:t.cloneNode(!0),n=e.classList;return"string"==typeof n?h.classList.add(n):Array.isArray(n)&&h.classList.add(...n),delete e.classList,["style","dataset"].forEach(t=>{const s=e[t];s&&"object"==typeof s&&Object.assign(h[t],s),delete e[t]}),e.role&&(h.setAttribute("role",e.role+""),delete e.role),e.ariaLive&&(h.setAttribute("aria-live",e.ariaLive+""),delete e.ariaLive),e.O&&(h.setAttribute("aria-labelledby",e.O+""),delete e.O),e.A&&(h.setAttribute("aria-controls",e.A+""),delete e.A),e.H&&(h.setAttribute("aria-haspopup",e.H+""),delete e.H),e.S&&(h.setAttribute("aria-multiselectable",e.S+""),delete e.S),e.P&&(h.setAttribute("aria-autocomplete",e.P+""),delete e.P),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,s])=>{h.addEventListener(t,s)}),delete e.event),Object.entries(e).forEach(([t,s])=>{null===s?h.removeAttribute(t):h[t]=s}),h}static C(t,s=null,i=!1,e=!1,h={}){let n=null;for(const o in t){const r=t[o],l=r?.tag?.tagName?r.tag:this.M(r.tag);h[o]=l,r?.L&&this.C(r.L,l,!1,!1,h),s?i?s.prepend(l):s.append(l):e||n||(n=l)}return e||(h.id=this.m(7),s||(h={tags:h,view:n})),h}static I(t,s){const i=this.p(s);for(const e in i){const s=t[e];s?i[e]="boolean"==typeof i[e]?this.F(s):s:void 0!==t?.dataset?.[e]&&(i[e]="boolean"==typeof i[e]?this.F(t.dataset[e]):t.dataset[e])}return i}static j(...t){if(0===t.length)return{};if(1===t.length)return this.p(t[0]);const s=this.p(t[0]);for(let i=1;i<t.length;i++){const e=t[i];for(const t in e)if("on"===t){const i=e[t];for(const e in i)s[t][e].push(i[e])}else s[t]=e[t]}return s}static F(t){if("boolean"==typeof t)return t;if("string"!=typeof t)return!!t;switch(t.trim().toLowerCase()){case"true":case"1":case"yes":case"on":return!0;default:return!1}}static $(t){return this.l.i.delete(t)}static V(t){return this.l.i.get(t)}static k(t,s){this.l.i.set(t,s)}static R(t){return this.l.h.delete(t)}static D(t){return this.l.h.get(t)}static _(t,s){this.l.h.set(t,s)}static B(){return this.l.t}static U(){return this.l.o}static N(t){if(null==t)return"";let s=(t+"").replace(/<`/g,"<").replace(/`>/g,">").replace(/\<\`/g,"<").replace(/\`\>/g,">").trim();const i=globalThis?.document;if(!i||"function"!=typeof i.createElement)return s=s.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<iframe\b[^>]*>[\s\S]*?<\/iframe>/gi,"").replace(/<(object|embed|link)\b[^>]*>[\s\S]*?<\/\1>/gi,""),s=s.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,""),s=s.replace(/\s([a-z-:]+)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,""),s;const e=i.createElement("div");return e.innerHTML=s,e.querySelectorAll("script, style, iframe, object, embed, link").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const s in t.attributes){const i=t.attributes[s],e=i.name??"",h=i.value??"";if(/^on/i.test(e))return void t.removeAttribute(e);/^(href|src|xlink:href)$/i.test(e)&&/^javascript:/i.test(h)&&t.removeAttribute(e)}}),(e.innerHTML??"").trim()}static G(t){const s=document.createElement("DIV");s.innerHTML=t;const i=s.textContent??s.innerText??"";return s.remove(),i.trim()}static W(t){return null==t?"":(t+"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"d")}static q(t){const s=[];return Array.from(t.children).forEach(t=>{if("OPTGROUP"===t.tagName){const i=t;s.push(i),Array.from(i.children).forEach(t=>{t.__parentGroup=i,s.push(t)})}else"OPTION"===t.tagName&&s.push(t)}),s}static K(){const t=navigator.userAgent;return/iP(hone|ad|od)/.test(t)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1}static Y(t){const s=(t+"").trim();if(s.endsWith("px"))return s;if(s.endsWith("vh"))return window.innerHeight*parseFloat(s)/100+"px";if(s.endsWith("vw"))return window.innerWidth*parseFloat(s)/100+"px";const i=parseFloat(getComputedStyle(document.documentElement).fontSize);if(s.endsWith("rem"))return i*parseFloat(s)+"px";const e=this.M({node:"div",style:{height:s,opacity:"0"}});document.body.appendChild(e);const h=e.offsetHeight+"px";return e.remove(),h}}e.u=null,e.J=new class{constructor(){this.X=new Map,this.Z=new Map}on(t,s,i={}){const e=i.tt??50,h=i.once??!1;this.X.has(t)||this.X.set(t,[]),this.X.get(t).push({st:s,timeout:e,once:h})}off(t){const s=this.Z.get(t);if(s){for(const t of s.values())clearTimeout(t);s.clear(),this.Z.delete(t)}this.X.delete(t)}run(t,...s){const i=this.X.get(t);if(!i||0===i.length)return Promise.resolve();this.Z.has(t)||this.Z.set(t,new Map);const e=this.Z.get(t),h=[];for(let n=0;n<i.length;n++){const t=i[n];if(!t)continue;const o=e.get(n);o&&clearTimeout(o);const r=new Promise(h=>{const o=setTimeout(async()=>{try{const i=t.st(s.length>0?s:null);i instanceof Promise&&await i}catch{}finally{if(t.once){i[n]=void 0;const t=e.get(n);t&&clearTimeout(t),e.delete(n)}h()}},t.timeout);e.set(n,o)});h.push(r)}return Promise.all(h).then(()=>{})}clear(t){if(void 0===t)for(const s of Array.from(this.X.keys()))this.off(s);else this.off(t)}};class h{static it(){const t={isContinue:!0,isCancel:!1};return{token:{get isContinue(){return t.isContinue},get isCancel(){return t.isCancel}},st:{stopPropagation(){t.isContinue=!1},cancel(){t.isCancel=!0,t.isContinue=!1}}}}static et(t,...s){const{token:i,st:e}=this.it();for(let h=0;h<s.length;h++){const n=s[h];if("function"==typeof n&&(t&&Array.isArray(t)?n(e,...t):n(e),i.isCancel||!i.isContinue))break}return i}static ht(t,s,i={bubbles:!0,cancelable:!0}){const e=new Event(s,i);return t.dispatchEvent(e),e}static nt(t,...s){if(Array.isArray(t))for(const i of t)"function"==typeof i&&i(...s)}}class n{static ot(t,s){const i=e.V(t);if(!i?.options)return;const h=i.options,n=h.minWidth,o=h.minHeight,r=Number.parseInt(h.width,10),l=Number.parseInt(h.height,10);let a=t.offsetWidth+"px",u=t.offsetHeight+"px";const c=getComputedStyle(t);"0px"===a&&"auto"!==c.width&&(a=c.width),"0px"===u&&"auto"!==c.height&&(u=c.height),r>0&&(a=h.width),l>0&&(u=h.height),Object.assign(s.style,{width:a,height:u,minWidth:n,minHeight:o})}}var o;(t=>{t.NEW="new",t.INITIALIZED="initialized",t.MOUNTED="mounted",t.UPDATED="updated",t.DESTROYED="destroyed"})(o||(o={}));class r{constructor(){this.state=o.NEW,this.rt=new Map,this.rt.set("onInit",new Set),this.rt.set("onMount",new Set),this.rt.set("onUpdate",new Set),this.rt.set("onDestroy",new Set)}on(t,s){return this.rt.get(t).add(s),this}off(t,s){return this.rt.get(t).delete(s),this}emit(t,s){const i={state:this.state,lt:s};for(const h of this.rt.get(t))try{h(i)}catch(e){this.ut(e,t)}}ut(t,s){console.error(`[Lifecycle:${s}]`,t)}init(){if(this.state!==o.NEW)return;const t=this.state;this.state=o.INITIALIZED,this.emit("onInit",t)}mount(){if(this.state!==o.INITIALIZED)return;const t=this.state;this.state=o.MOUNTED,this.emit("onMount",t)}update(){if(this.state!==o.MOUNTED&&this.state!==o.UPDATED)return;const t=this.state;this.state=o.UPDATED,this.emit("onUpdate",t)}destroy(){if(this.state===o.DESTROYED)return;const t=this.state;this.state=o.DESTROYED,this.emit("onDestroy",t),this.ct()}getState(){return this.state}is(t){return this.state===t}ct(){for(const t of this.rt.values())t.clear()}}class l extends r{constructor(t){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.node=e.M({node:"div",classList:"seui-placeholder",innerHTML:t.placeholder}),this.options=t,this.init()}get(){return this.options?.placeholder??""}set(t,s=!0){if(!this.node||!this.options)return;s&&(this.options.placeholder=t);const i=e.N(t);this.node.innerHTML=this.options.allowHtml?i:e.G(i)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.node=null,this.options=null,super.destroy())}}class a extends r{constructor(){super(),this.init()}init(){this.node=e.M({node:"div",classList:"seui-directive",role:"button",ariaLabel:"Toggle dropdown"}),super.init(),this.mount()}dt(t){this.node.classList.toggle("drop-down",!!t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.node=null,super.destroy())}}class u extends r{constructor(t=null){super(),this.gt=null,this.node=null,this.options=null,this.ft=[],this.bt=[],t&&this.initialize(t)}initialize(t){this.gt=e.C({yt:{tag:{node:"div",classList:["seui-option-handle","hide"]},L:{wt:{tag:{node:"a",classList:"seui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.nt(this.ft)}}},vt:{tag:{node:"a",classList:"seui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.nt(this.bt)}}}}}}),this.node=this.gt.view,this.options=t,this.init()}available(){return!!this.options&&e.F(this.options.multiple)&&e.F(this.options.selectall)}update(){this.node&&(this.available()?this.show():this.hide()),super.update()}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}xt(t=null){"function"==typeof t&&this.ft.push(t)}Mt(t=null){"function"==typeof t&&this.bt.push(t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.options=null,this.ft=null,this.bt=null,this.node=null,super.destroy())}}class c extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.M({node:"div",classList:["seui-empty-state","hide"],role:"status",ariaLive:"polite"}),this.init()}show(t="nodata"){this.node&&this.options&&(this.node.textContent="notfound"===t?this.options.textNotFound:this.options.textNoData,this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}destroy(){this.is(o.DESTROYED)||(this.options=null,this.node?.remove(),this.node=null,super.destroy())}}class d extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.M({node:"div",classList:["seui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"}),this.init()}show(t){this.node&&this.options&&(this.node.textContent=this.options.textLoading,this.node.classList.toggle("small",!!t),this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}destroy(){this.is(o.DESTROYED)||(this.options=null,this.node?.remove(),this.node=null,super.destroy())}}class p{constructor(){this.Tt=!1,this.element=null,this.Ot=null,this.At=null,this.Tt=!0,this.Ht=this.St.bind(this)}Pt(t){}St(){const t=this.element;if(!t||"function"!=typeof t.getBoundingClientRect)return void this.Pt({width:0,height:0,top:0,left:0,padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}});const s=t.getBoundingClientRect(),i="undefined"!=typeof window&&"function"==typeof window.getComputedStyle?window.getComputedStyle(t):null;this.Pt({width:s?.width??0,height:s?.height??0,top:s?.top??0,left:s?.left??0,padding:{top:parseFloat(i?.paddingTop??"0"),right:parseFloat(i?.paddingRight??"0"),bottom:parseFloat(i?.paddingBottom??"0"),left:parseFloat(i?.paddingLeft??"0")},border:{top:parseFloat(i?.borderTopWidth??"0"),right:parseFloat(i?.borderRightWidth??"0"),bottom:parseFloat(i?.borderBottomWidth??"0"),left:parseFloat(i?.borderLeftWidth??"0")},margin:{top:parseFloat(i?.marginTop??"0"),right:parseFloat(i?.marginRight??"0"),bottom:parseFloat(i?.marginBottom??"0"),left:parseFloat(i?.marginLeft??"0")}})}ht(){this.St()}connect(t){if(!(t instanceof HTMLElement))throw Error("Invalid element");this.element=t,this.Ot=new ResizeObserver(this.Ht),this.Ot.observe(t),this.At=new MutationObserver(this.Ht),this.At.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.Ht,!0),window.addEventListener("resize",this.Ht),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.Ht),window.visualViewport.addEventListener("scroll",this.Ht))}disconnect(){this.Ot?.disconnect(),this.At?.disconnect(),this.Pt=()=>{},window.removeEventListener("scroll",this.Ht,!0),window.removeEventListener("resize",this.Ht),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.Ht),window.visualViewport.removeEventListener("scroll",this.Ht)),this.Ot=null,this.At=null,this.element=null}}class g extends r{constructor(t=null,s=null,i=null){super(),this.options=null,this.Ct=!1,this.Lt=null,this.node=null,this.It=null,this.Ft=null,this.parent=null,this.jt=null,this.Et=null,this.$t=null,this.Vt=null,this.kt=null,this.Rt=null,this.Dt=null,this.zt={_t:36,Bt:8,Ut:!0},this.Nt=i,t&&s&&this.initialize(t,s)}initialize(t,s){if(!this.Nt)throw Error("Popup requires a ModelManager instance.");this.jt=new u(s),this.Et=new c(s),this.$t=new d(s);const i=e.C({Gt:{tag:{node:"div",classList:"seui-popup",style:{maxHeight:s.panelHeight}},L:{yt:{tag:this.jt.node},Wt:{tag:{id:s.qt,node:"div",classList:"seui-options-container",role:"listbox"}},Kt:{tag:this.$t.node},Qt:{tag:this.Et.node}}}},null);this.node=i.view,this.kt=i.tags.Wt,this.parent=e.V(t),this.options=s,this.init(),this.Nt.load(this.kt,{isMultiple:s.multiple},s.virtualScroll?{Yt:this.node,_t:this.zt._t,Bt:this.zt.Bt,Ut:this.zt.Ut}:{});const h=this.Nt.Jt();this.Lt=h.Xt,this.Vt=h.Vt,this.jt.xt(()=>{h.Xt.Zt(!0)}),this.jt.Mt(()=>{h.Xt.Zt(!1)}),this.ts(),this.mount()}async ss(){this.options&&this.$t&&this.jt&&this.Lt&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Nt.es(!0),!1!==e.F(this.options.loadingfield)&&(this.Et.hide(),this.$t.show(this.Lt.ns().hs),this.rs()))}async ls(){this.options&&this.$t&&this.Lt&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Dt=setTimeout(()=>{this.Nt?.es(!1),this.$t?.hide();const t=this.Lt?.ns();this.us(t??void 0),this.rs()},this.options.animationtime))}ts(){this.Lt&&(this.Lt.cs(t=>{this.us(t)}),this.Lt.ds("items",()=>{const t=this.Lt.ns();this.us(t),this.rs()}))}us(t){if(!(this.Lt&&this.Et&&this.jt&&this.kt))return;const s=t??this.Lt.ns();s.isEmpty?(this.Et.show("nodata"),this.kt.classList.add("hide"),this.jt.hide()):s.hs?(this.Et.hide(),this.kt.classList.remove("hide"),this.jt.update()):(this.Et.show("notfound"),this.kt.classList.add("hide"),this.jt.hide())}ps(t,s){this.Lt?.gs(t,s)}fs(t,s){this.Lt?.ds(t,s)}bs(t){this.It=t}open(t=null,s){if(!(this.node&&this.options&&this.jt&&this.parent&&this.It))return;this.Ct||(document.body.appendChild(this.node),this.Ct=!0,this.Ft=new p,this.It.ys(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.jt.update(),s&&this.us();const i=this.ws(),{position:e,top:h,maxHeight:n,vs:o}=this.xs(i);this.It.expand({duration:this.options.animationtime,display:"flex",width:i.width,left:i.left,top:h,maxHeight:n,vs:o,position:e,Ms:()=>{if(!this.Ft||!this.parent)return;this.Ft.Pt=()=>{const t=this.ws();this.Ts(t)},this.Ft.connect(this.parent.container.tags.Os),t?.();const s=this.Vt;s?.resume?.()}})}close(t=null){if(!(this.Ct&&this.options&&this.Ft&&this.It))return;const s=this.Vt;s?.suspend?.(),this.Ft.disconnect(),this.It.collapse({duration:this.options.animationtime,Ms:t??void 0})}rs(){this.Ct&&this.Ft?.ht()}As(t,s){this.node&&(this.Rt=async()=>{const s=t.Hs();if(!s.Ss)return;const i=this.node;if(i.scrollHeight-i.scrollTop-i.clientHeight<100&&!s.Ps&&s.hasMore){const s=await t.Cs();!s.Ls&&s.message&&console.log("Load more:",s.message)}},this.node.addEventListener("scroll",this.Rt))}destroy(){if(!this.is(o.DESTROYED)){if(clearTimeout(this.Dt),this.Dt=null,this.node&&this.Rt&&(this.node.removeEventListener("scroll",this.Rt),this.Rt=null),this.Et.destroy(),this.$t.destroy(),this.jt.destroy(),this.Ft?.disconnect?.(),this.It?.ys?.(null),this.Nt?.es?.(!1),this.Vt?.clear?.(),this.node?.remove?.(),this.node)try{const t=e.T(this.node);this.node.replaceWith(t),t.remove()}catch(t){this.node.remove()}this.node=null,this.kt=null,this.Nt=null,this.jt=null,this.Et=null,this.$t=null,this.parent=null,this.options=null,this.Ct=!1,this.It=null,this.Ft=null,this.Vt=null,this.Lt=null,super.destroy()}}ws(){const t=this.parent.container.tags.Os,s=t.getBoundingClientRect(),i=window.getComputedStyle(t);return{width:s.width,height:s.height,top:s.top,left:s.left,padding:{top:parseFloat(i.paddingTop),right:parseFloat(i.paddingRight),bottom:parseFloat(i.paddingBottom),left:parseFloat(i.paddingLeft)},border:{top:parseFloat(i.borderTopWidth),right:parseFloat(i.borderRightWidth),bottom:parseFloat(i.borderBottomWidth),left:parseFloat(i.borderLeftWidth)}}}xs(t){const s=window.visualViewport,i=e.K(),h=s?.height??window.innerHeight,n=this.It.Is("flex").scrollHeight,o=parseFloat(this.options?.panelHeight??"220")||220,r=parseFloat(this.options?.panelMinHeight??"100")||100,l=h-(t.top+t.height)-3,a=t.top-3;let u="bottom",c=o,d=Math.min(n,c);const p=l-15;(d>=r?p>=r:p>=d)?(u="bottom",c=Math.min(l-15,o)):a>=Math.max(d,r)?(u="top",c=Math.min(a-15,o)):l>=a?(u="bottom",c=Math.max(l-15,r)):(u="top",c=Math.max(a-15,r)),d=Math.min(n,c);const g=s&&i?s.offsetTop:0;return{position:u,top:"bottom"===u?t.top+t.height+3+g:t.top-d-3+g,maxHeight:c,vs:d,Fs:n}}Ts(t){if(!this.options||!this.It)return;const{position:s,top:i,maxHeight:e,vs:h}=this.xs(t);this.It.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:i,maxHeight:e,vs:h,position:s,animate:!0})}}class f extends r{constructor(t=null){super(),this.gt=null,this.node=null,this.js=null,this.Es=null,this.options=null,this.$s=null,this.Vs=null,this.ks=null,this.options=t,t&&this.initialize(t)}initialize(t){this.gt=e.C({Rs:{tag:{node:"div",classList:["seui-searchbox","hide"]},L:{js:{tag:{id:e.m(),node:"input",type:"search",classList:["seui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",A:t.qt,P:"list"}}}}}),this.node=this.gt.view,this.js=this.gt.tags.js;let s=!1;const i=this.gt.tags.js;i.addEventListener("mousedown",t=>{t.stopPropagation()}),i.addEventListener("mouseup",t=>{t.stopPropagation()}),i.addEventListener("keydown",t=>{s=!1,"ArrowDown"===t.key||"Tab"===t.key?(t.preventDefault(),t.stopPropagation(),s=!0,this.$s?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),s=!0,this.$s?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),s=!0,this.Vs?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),s=!0,this.ks?.()),t.stopPropagation()}),i.addEventListener("input",()=>{s||this.Es?.(i.value,!0)}),this.init()}show(){this.node&&this.js&&this.options&&(this.node.classList.remove("hide"),this.js.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.js?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.gt&&(this.gt.tags.js.value="",this.Es?.("",t))}Ds(t){this.js&&(this.js.placeholder=e.G(t))}zs(t){this.js&&this.js.setAttribute("aria-activedescendant",t)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.gt=null,this.node=null,this.js=null,this.Es=null,this.options=null,this.$s=null,this.Vs=null,this.ks=null,super.destroy())}}class m{constructor(t=null){this._s=null,this.Bs=null,this.Us=!1,t&&this.ys(t)}ys(t){if("string"==typeof t){const s=document.querySelector(t);return void(s instanceof HTMLElement&&(this.element=s))}this.element=t}cancel(){return this._s&&(clearTimeout(this._s),this._s=null),this.Bs&&(clearTimeout(this.Bs),this.Bs=null),this.Us=!1,this}Is(t="flex"){if(!this.element)return{width:0,height:0,scrollHeight:0};const s={display:this.element.style.display,visibility:this.element.style.visibility,position:this.element.style.position,height:this.element.style.height,width:this.element.style.width};Object.assign(this.element.style,{display:t,visibility:"hidden",position:"fixed",height:"fit-content",width:"fit-content"});const i=window.getComputedStyle(this.element),e=parseFloat(i.borderTopWidth),h=parseFloat(i.borderBottomWidth),n=this.element.scrollHeight+e+h,o=this.element.getBoundingClientRect(),r={width:o.width,height:o.height+e+h,scrollHeight:n};return Object.assign(this.element.style,s),r}expand(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,display:i="flex",width:e,left:h,top:n,maxHeight:o,vs:r,position:l="bottom",Ms:a}=t;return Object.assign(this.element.style,{display:i,width:e+"px",left:h+"px",top:("bottom"===l?n:n+r)+"px",maxHeight:o+"px",height:"0px",opacity:"0",overflow:"hidden",transition:"none"}),this.element.classList.toggle("position-top","top"===l),this.element.classList.toggle("position-bottom","bottom"===l),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`top ${s}ms, height ${s}ms, opacity ${s}ms`,top:n+"px",height:r+"px",opacity:"1",overflow:r>=o?"auto":"hidden"}),this._s=setTimeout(()=>{this.element.style.transition="none",this.Us=!1,a?.()},s)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,Ms:i}=t,e=this.element.offsetHeight,h=this.element.offsetTop,n=this.element.classList.contains("position-top")?"top":"bottom",o=this.element.scrollHeight-this.element.offsetHeight>0,r="top"===n?h+e:h;return requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`height ${s}ms, top ${s}ms, opacity ${s}ms`,height:"0px",top:r+"px",opacity:"0",overflow:o?"auto":"hidden"}),this._s=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Us=!1,i?.()},s)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,display:i="block",Ms:e}=t;Object.assign(this.element.style,{transition:"none",display:i,width:"fit-content"});const h=this.Is(i).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${s}ms`,width:h+"px",overflow:"hidden"})}),this._s=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Us=!1,e?.()},s),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,Ms:i}=t,e=this.Is().width;return Object.assign(this.element.style,{transition:"none",width:e+"px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${s}ms`,width:"0px",overflow:"hidden"})}),this._s=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Us=!1,i?.()},s),this}resize(t){if(!this.element)return this;this.cancel();const{duration:s=200,width:i,left:e,top:h,maxHeight:n,vs:o,position:r="bottom",animate:l=!0,Ms:a}=t,u=(this.element.classList.contains("position-top")?"top":"bottom")!==r,c=this.element.scrollHeight>n;return this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),u&&(this.element.style.transition=`top ${s}ms ease-out, height ${s}ms ease-out, max-height ${s}ms ease-out;`),requestAnimationFrame(()=>{const t={width:i+"px",left:e+"px",top:h+"px",maxHeight:n+"px",height:o+"px",overflowY:c?"auto":"hidden"},r=Math.abs(this.element.offsetHeight-o);l&&(u||r>5)?t.transition=`height ${s}ms, top ${s}ms`:this.Bs=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},s),Object.assign(this.element.style,t),l&&(u||r>1)?this.Bs=setTimeout(()=>{this.element.style.transition=null,u&&delete this.element.style.transition,a?.()},s):(u&&delete this.element.style.transition,a?.())}),this}get Ns(){return this.Us}}class b extends r{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,s=null,i=null){super(),this.targetElement=null,this.view=null,this.position=-1,this.Tt=!1,this.Gs=!1,this.options=t,this.targetElement=s,this.view=i,this.init()}Ws(t){this.targetElement=t,this.update()}destroy(){this.is(o.DESTROYED)||(this.targetElement=null,this.view?.destroy(),this.view=null,this.Gs=!0,super.destroy())}}class y extends b{constructor(t,s){super(t,s??null,null),this.label="",this.items=[],this.collapsed=!1,this.qs=[],this.label=this.targetElement.label}init(){this.collapsed=e.F(this.targetElement.dataset?.collapsed),super.init(),this.mount()}get value(){return this.items.map(t=>t.value)}get Ks(){return this.items.filter(t=>t.selected)}get Qs(){return this.items.filter(t=>t.visible)}get Ys(){return this.Qs.length>0}Ws(t){this.label=t.label,this.view?.Js(this.label),this.update()}update(){this.view&&(this.view.Js(this.label),this.view.Xs(this.collapsed)),super.update()}destroy(){this.is(o.DESTROYED)||(this.items.forEach(t=>{t.destroy()}),this.items=[],super.destroy())}Zs(t){this.qs.push(t)}ti(){this.collapsed=!this.collapsed,this.view?.Xs(this.collapsed),h.et([this,this.collapsed],...this.qs)}si(t){this.items.push(t),t.group=this}removeItem(t){const s=this.items.indexOf(t);s>-1&&(this.items.splice(s,1),t.group=null)}ii(){this.view?.ii()}}class w extends b{constructor(t,s=null,i=null){super(t,s,i),this.ei=[],this.hi=[],this.ni=[],this.oi=!0,this.ri=!1,this.group=null}init(){this.li=e.W(this.textContent.toLowerCase()),super.init(),this.mount()}get ai(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ai}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.ui=t,h.et([this,t],...this.ei)}get visible(){return this.oi}set visible(t){if(this.oi===t)return;this.oi=t;const s=this.view?.ci?.();s&&s.classList.toggle("hide",!t),h.et([this,t],...this.ni)}get ui(){return this.selected}set ui(t){const s=this.view?.view?.tags?.di,i=this.view?.ci?.();s&&(s.checked=t),i&&this.targetElement&&(i.classList.toggle("checked",!!t),i.setAttribute("aria-selected",t?"true":"false"),this.targetElement.toggleAttribute("selected",!!t)),this.targetElement&&(this.targetElement.selected=t),h.et([this,t],...this.hi)}get text(){const t=e.N(this.dataset?.mask??this.targetElement?.text??"");return this.options.allowHtml?t:e.G(t)}get textContent(){return this.options.allowHtml?e.G(this.text).trim():this.text.trim()}get dataset(){return this.targetElement?.dataset??{}}get pi(){return this.ri}set pi(t){const s=!!t,i=this.view?.ci?.();this.ri!==s&&(this.ri=s),i&&i.classList.toggle("highlight",s)}gi(t){this.ei.push(t)}fi(t){this.hi.push(t)}cs(t){this.ni.push(t)}update(){if(this.li=e.W(this.textContent.toLowerCase()),!this.view)return void super.update();const t=this.view.view.tags.mi;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const s=this.view.view.tags.bi;s&&this.hasImage&&(s.src!=this.ai&&(s.src=this.ai),s.alt!=this.text&&(s.alt=this.text)),this.targetElement&&(this.ui=this.targetElement.selected),super.update()}destroy(){this.is(o.DESTROYED)||(this.ei=[],this.hi=[],this.ni=[],this.group=null,this.li=null,super.destroy())}}class v extends r{constructor(t){super(),this.yi=[],this.wi=null,this.xi=null,this.options=null,this.Mi=0,this.options=t,this.init()}Ti(t){this.Oi=t}Ai(t){this.Hi=t}Si(t){this.is(o.INITIALIZED)&&this.mount(),this.yi=[];let s=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)s=new y(this.options,t),this.yi.push(s);else if("OPTION"===t.tagName){const i=new w(this.options,t),e=t.__parentGroup;e&&s&&e===s.targetElement?(s.si(i),i.group=s):(this.yi.push(i),s=null)}}),this.yi}async replace(t){this.Si(t),this.wi&&await this.wi.Pi(this.yi),this.refresh(!1)}notify(){this.wi&&this.refresh(!1)}load(t,s={},i={}){this.wi=new this.Oi(this.yi),Object.assign(this.wi,s),this.xi=new this.Hi(t),Object.assign(this.xi,i),this.xi.Ci(this.wi)}Li(t){const s=this.yi,i=[],e=new Map,h=new Map;s.forEach(t=>{t instanceof y?e.set(t.label,t):t instanceof w&&h.set(`${t.value}::${t.textContent}`,t)});let n=null,o=0;t.forEach(t=>{if("OPTGROUP"===t.tagName){const s=t,h=e.get(s.label);h?(h.label!==s.label&&h.Ws(s),h.position=o,h.items=[],n=h,i.push(h),e.delete(s.label)):(n=new y(this.options,s),n.position=o,i.push(n)),o++}else if("OPTION"===t.tagName){const s=t,e=`${s.value}::${s.text}`,r=h.get(e);if(r)r.Ws(s),r.position=o,s.__parentGroup&&n?(n.si(r),r.group=n):(r.group=null,i.push(r)),h.delete(e);else{const t=new w(this.options,s);t.position=o,s.__parentGroup&&n?(n.si(t),t.group=n):i.push(t)}o++}});let r=!0;0==this.Mi&&(r=!1),this.Mi=o,e.forEach(t=>{r=!1,t.destroy()}),h.forEach(t=>{r=!1,t.destroy()}),this.yi=i,this.wi&&this.wi.Ii(this.yi),this.refresh(r)}es(t){this.wi&&(this.wi.Fi=t)}refresh(t){this.xi&&(this.xi.refresh(t),this.update())}destroy(){this.is(o.DESTROYED)||(this.wi.destroy(),this.xi.destroy(),this.yi=[],this.Oi=null,this.wi=null,this.Hi=null,this.xi=null,this.options=null,this.Mi=0,super.destroy())}Jt(){return{ji:this.yi,Xt:this.wi,Vt:this.xi}}Ei(t){return this.wi?.$i(t)}Vi(t){return this.wi?.ki(t)}}class x extends r{constructor(t=null){super(),this.Ri=null,this.Xt=null,this.Ri=t,this.init()}Ci(t){this.Xt=t,t.gs("items",()=>{this.clear()}),t.ds("items",()=>{this.Di()}),t.mount(),this.mount(),this.Di()}clear(){this.Ri&&this.Ri.replaceChildren()}Di(){this.Xt&&this.Ri&&(this.Xt.zi(this.Ri),this.update())}refresh(t){this.Di()}destroy(){this.is(o.DESTROYED)||(this.Ri=null,this.Xt=null,super.destroy())}}class M extends r{constructor(t=null){super(),this.gt=null,this.node=null,this.options=null,this._i=null,this.Bi=null,this.Nt=null,this.Ui=[],t&&this.initialize(t)}initialize(t){this.options=t,this.init()}init(){this.state===o.NEW&&(this.gt=e.C({Ni:{tag:{node:"div",classList:["seui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.gt.view,super.init())}Gi(t){this._i=t,this.Bi=t.parentElement,this.Wi(),this.mount()}mount(){this.is(o.INITIALIZED)&&super.mount()}Wi(){this.Bi&&this.node&&this._i&&this.options&&this.Bi.insertBefore(this.node,"top"===this.options.accessoryStyle?this._i:this._i.nextSibling)}qi(t){this.Nt=t}Ki(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?t.forEach(t=>{e.C({Qi:{tag:{node:"div",classList:["accessory-item"]},L:{Yi:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:async s=>{s.preventDefault(),await(this.Nt?.Ei?.("select")),t.selected=!1}}},Ji:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)}):t=[],this.Ui=t,this.Xi(),this.update(),h.ht(window,"resize"))}update(){this.state===o.MOUNTED&&super.update()}Xi(){this.options?.accessoryVisible&&this.Ui.length>0&&this.options.multiple?this.show():this.hide()}show(){this.node?.classList.remove("hide")}hide(){this.node?.classList.add("hide")}destroy(){this.state!==o.DESTROYED&&(this.node?.remove(),this.gt=null,this.node=null,this.options=null,this._i=null,this.Bi=null,this.Nt=null,this.Ui=[],super.destroy())}}class T extends r{constructor(t,s,i){super(),this.Zi=null,this.te=null,this.se=null,this.ie=null,this.ee={currentPage:0,totalPages:1,hasMore:!1,Ps:!1,he:"",Ss:!1},this.initialize(t,s,i)}initialize(t,s,i){this.select=t,this.Nt=s,this.ie=i,this.init()}ne(){return!!this.Zi}async oe(t){if(!this.Zi)return{Ls:!1,items:[],message:"Ajax not configured"};const s=Array.isArray(t)?t:[t];if(0===s.length)return{Ls:!0,items:[]};try{const t=this.Zi;let i,e;if(i="function"==typeof t.re?t.re(s):{values:s.join(","),le:"1",..."function"==typeof t.data?t.data.bind(this.ie.ae.find(this.ie.container.targetElement))("",0):t.data??{}},"POST"===(t.method??"GET")){const s=new URLSearchParams;Object.keys(i).forEach(t=>s.append(t,i[t]+"")),e=await fetch(t.url,{method:"POST",body:s,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{const s=""+new URLSearchParams(i);e=await fetch(`${t.url}?${s}`)}if(!e.ok)throw Error("HTTP error! status: "+e.status);const h=await e.json(),n=this.ue(h);return this.update(),{Ls:!0,items:n.items}}catch(i){return console.error("Load by values error:",i),{Ls:!1,message:i?.message,items:[]}}}ce(t){const s=Array.from(this.select.options).map(t=>t.value);return{de:t.filter(t=>s.includes(t)),pe:t.filter(t=>!s.includes(t))}}ge(t){this.Zi=t}setPopup(t){this.se=t}Hs(){return{...this.ee}}fe(){this.ee={currentPage:0,totalPages:1,hasMore:!1,Ps:!1,he:"",Ss:this.ee.Ss}}clear(){this.ee.he="";const{ji:t}=this.Nt.Jt(),s=[];for(const i of t)i instanceof w?s.push(i):i instanceof y&&Array.isArray(i.items)&&s.push(...i.items);s.forEach(t=>{t.visible=!0})}async search(t,s=!1){return this.Zi?this.me(t,s):this.be(t)}async Cs(){return this.Zi?this.ee.Ps?{Ls:!1,message:"Already loading"}:this.ee.Ss?this.ee.hasMore?(this.ee.currentPage++,this.me(this.ee.he,!0)):{Ls:!1,message:"No more data"}:{Ls:!1,message:"Pagination not enabled"}:{Ls:!1,message:"Ajax not enabled"}}async be(t){this.ye(t)&&(this.ee.he=t);const s=((t??"")+"").toLowerCase(),i=e.W(s),{ji:h}=this.Nt.Jt(),n=[];for(const e of h)e instanceof w?n.push(e):e instanceof y&&Array.isArray(e.items)&&n.push(...e.items);let o=!1;return n.forEach(t=>{const e=""===s||t.li.includes(i);t.visible=e,e&&(o=!0)}),this.update(),{Ls:!0,we:o,isEmpty:0===n.length}}ye(t){return t!==this.ee.he}async me(t,s=!1){const i=this.Zi;this.ye(t)&&(this.fe(),this.ee.he=t,s=!1),this.ee.Ps=!0,this.se?.ss(),this.te?.abort(),this.te=new AbortController;const e=this.ee.currentPage,h=Array.from(this.select.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof i.data?(n=i.data.bind(this.ie.ae.find(this.ie.container.targetElement))(t,e),n&&void 0===n.selectedValue&&(n.selectedValue=h)):n={search:t,page:e,selectedValue:h,...i.data??{}};try{let t;if("POST"===(i.method??"GET")){const s=new URLSearchParams;Object.keys(n).forEach(t=>s.append(t,n[t]+"")),t=await fetch(i.url,{method:"POST",body:s,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.te.signal})}else{const s=""+new URLSearchParams(n);t=await fetch(`${i.url}?${s}`,{signal:this.te.signal})}const e=await t.json(),h=this.ue(e);return h.ve?(this.ee.Ss=!0,this.ee.currentPage=h.page,this.ee.totalPages=h.totalPages,this.ee.hasMore=h.hasMore):this.ee.Ss=!1,this.xe(h.items,!!i.keepSelected,s),this.ee.Ps=!1,this.se?.ls(),this.update(),{Ls:!0,we:h.items.length>0,isEmpty:0===h.items.length,ve:h.ve,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.ee.Ps=!1,this.se?.ls(),"AbortError"===o?.name?{Ls:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Ls:!1,message:o?.message})}}ue(t){let s=[],i=!1,e=0,h=1,n=!1;return t.object&&Array.isArray(t.object)?(s=t.object,void 0!==t.page&&(i=!0,e=parseInt(t.page??0,10),h=parseInt(t.totalPages??t.total_page??1,10),n=e<h-1)):t.data&&Array.isArray(t.data)?(s=t.data,void 0!==t.page&&(i=!0,e=parseInt(t.page??0,10),h=parseInt(t.totalPages??t.total_page??1,10),n=t.hasMore??e<h-1)):Array.isArray(t)?s=t:t.items&&Array.isArray(t.items)&&(s=t.items,t.pagination&&(i=!0,e=parseInt(t.pagination.page??0,10),h=parseInt(t.pagination.totalPages??t.pagination.total_page??1,10),n=t.pagination.hasMore??e<h-1)),{items:s.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.Me||t.group||t.label)return{type:"optgroup",label:t.label??t.name??t.title??"",data:t.data??{},options:(t.options??t.items??[]).map(t=>({value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:t.data??(t.imgsrc?{imgsrc:t.imgsrc}:{})}))};const s=t.data??{};return t?.imgsrc&&(s.imgsrc=t.imgsrc),{type:"option",value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:s}}),ve:i,page:e,totalPages:h,hasMore:n}}xe(t,s,i=!1){const e=this.select;let h=[];s&&(h=Array.from(e.selectedOptions).map(t=>t.value)),i||(e.innerHTML=""),t.forEach(t=>{if("option"!==t.type&&t.type||""!==t.value||""!==t.text)if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)e.appendChild(t);else if("optgroup"===t.type){const i=document.createElement("optgroup");i.label=t.label,t.data&&Object.keys(t.data).forEach(s=>{i.dataset[s]=t.data[s]+""}),Array.isArray(t.options)&&t.options.forEach(t=>{const e=document.createElement("option");e.value=t.value,e.text=t.text,t.data&&Object.keys(t.data).forEach(s=>{e.dataset[s]=t.data[s]+""}),(t.selected||s&&h.includes(e.value))&&(e.selected=!0),i.appendChild(e)}),e.appendChild(i)}else{const i=document.createElement("option");i.value=t.value,i.text=t.text,t.data&&Object.keys(t.data).forEach(s=>{i.dataset[s]=t.data[s]+""}),(t.selected||s&&h.includes(i.value))&&(i.selected=!0),e.appendChild(i)}})}destroy(){this.is(o.DESTROYED)||(this.select=null,this.Nt=null,this.Zi=null,this.te=null,this.se=null,this.ie=null,super.destroy())}}class O{constructor(t){this.Te=null,this.Oe=50,this.select=t,this.Ae=new MutationObserver(()=>{clearTimeout(this.Te),this.Te=setTimeout(()=>{this.He()},this.Oe)})}He(){this.Pt(this.select)}connect(){this.Ae.observe(this.select,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.Te&&clearTimeout(this.Te),this.Te=null,this.Ae.disconnect()}}class A{constructor(t){this.Te=null,this.element=t,this.Ae=new MutationObserver(t=>{let s=!1;for(const i of t)if("attributes"===i.type&&i.attributeName?.startsWith("data-")){s=!0;break}s&&(this.Te&&clearTimeout(this.Te),this.Te=setTimeout(()=>{this.Pt({...this.element.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.element.dataset})})}connect(){this.Ae.observe(this.element,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.Te&&clearTimeout(this.Te),this.Te=null,this.Ae.disconnect()}}class H extends r{constructor(t=[]){super(),this.items=[],this.Se=e.m(12),this.Fi=!1,this.items=t,this.init()}Pe(t,s,i){const e=s;t.Tt?e?.update?.():e?.mount?.()}gs(t,s){e.J.on(`${t}ing_${this.Se}`,s,{tt:0})}ds(t,s){e.J.on(`${t}_${this.Se}`,s,{tt:0})}ki(t,...s){return e.J.run(`${t}_${this.Se}`,...s)}$i(t,...s){return e.J.run(`${t}ing_${this.Se}`,...s)}Ce(t,s){return null}Le(){return this.items.length}async Ie(t){await this.$i("items",t),this.items=t,await this.ki("items",t),this.update()}async Pi(t){await this.Ie(t)}zi(t){for(let s=0;s<this.Le();s++){const i=this.items[s];let e=i.view;i.Tt||(e=this.Ce(t,i),i.view=e),this.Pe(i,e,s),i.Tt=!0}}Ii(t){}destroy(){this.is(o.DESTROYED)||(this.Vt=null,this.items.forEach(t=>{t?.destroy?.()}),this.items=[])}}class S extends r{constructor(t){super(),this.parent=null,this.view=null,this.parent=t,this.init()}ci(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}destroy(){this.is(o.DESTROYED)||(this.ci()?.remove?.(),this.parent=null,this.view=null,super.destroy())}}class P extends S{constructor(){super(...arguments),this.view=null}mount(){const t=e.m(7);this.view=e.C({Fe:{tag:{node:"div",classList:["seui-group"],role:"group",O:`seui-${t}-header`,id:`seui-${t}-group`},L:{je:{tag:{node:"div",classList:["seui-group-header"],role:"presentation",id:`seui-${t}-header`}},Ee:{tag:{node:"div",classList:["seui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view),super.mount()}update(){this.Js(),super.update()}Js(t=null){this.view&&null!==t&&(this.view.tags.je.textContent=t)}$e(){if(!this.view)throw Error("GroupView has not been rendered.");return this.view.tags.Ee}ii(){if(!this.view)return;const t=Array.from(this.view.tags.Ee.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",0===t.length)}Xs(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.je.setAttribute("aria-expanded",t?"false":"true"))}}class C extends S{constructor(t){super(t),this.view=null,this.config=null,this.Ve=null,this.ke=!1,this.initialize()}initialize(){const t=this;this.config={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.Ve=new Proxy(this.config,{set(s,i,e){if("string"!=typeof i)return!0;const h=i,n=s[h];return n!==e&&(s[h]=e,t.ke&&t.Re(h,e,n)),!0}}),this.init()}get isMultiple(){return this.config.isMultiple}set isMultiple(t){this.Ve.isMultiple=!!t}get hasImage(){return this.config.hasImage}set hasImage(t){this.Ve.hasImage=!!t}get De(){return this.Ve}set De(t){if(!t||!this.Ve||!this.config)return;const s={};void 0!==t.imageWidth&&t.imageWidth!==this.config.imageWidth&&(s.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.config.imageHeight&&(s.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.config.imageBorderRadius&&(s.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.config.imagePosition&&(s.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.config.labelValign&&(s.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.config.labelHalign&&(s.labelHalign=t.labelHalign),Object.keys(s).length>0&&Object.assign(this.Ve,s)}mount(){const t=["seui-option-view"],s=e.m(7),i="option_"+s;this.config.isMultiple&&t.push("multiple"),this.config.hasImage&&t.push("has-image","image-"+this.config.imagePosition);const h={di:{tag:{node:"input",type:this.config.isMultiple?"checkbox":"radio",classList:"allow-choice",id:i}},...this.config.hasImage&&{bi:{tag:{node:"img",classList:"option-image",style:{width:this.config.imageWidth,height:this.config.imageHeight,borderRadius:this.config.imageBorderRadius}}}},ze:{tag:{node:"label",htmlFor:i,classList:["align-vertical-"+this.config.labelValign,"align-horizontal-"+this.config.labelHalign]},L:{mi:{tag:{node:"div"}}}}};this.view=e.C({_e:{tag:{node:"div",id:`seui-${s}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},L:h}}),this.parent.appendChild(this.view.view),this.ke=!0,super.mount()}Re(t,s,i){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.di,o=e.tags?.ze;switch(t){case"isMultiple":{const t=!!s;h.classList.toggle("multiple",t),n&&n.type!==(t?"checkbox":"radio")&&(n.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!s;if(h.classList.toggle("has-image",t),t)h.classList.add("image-"+this.config.imagePosition),this.Be();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.bi;t?.remove(),e.tags.bi=null}break}case"imagePosition":this.config.hasImage&&(h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim(),h.classList.add("image-"+s));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const i=e.tags?.bi;i&&(i.style["imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius"]=s+"");break}case"labelValign":case"labelHalign":o&&(o.className=`align-vertical-${this.config.labelValign} align-horizontal-`+this.config.labelHalign)}}Be(){const t=this.view;if(!t||!t.view)return;if(t.tags?.bi)return;const s=t.view,i=t.tags?.ze,e=document.createElement("img");e.className="option-image",e.style.width=this.config.imageWidth,e.style.height=this.config.imageHeight,e.style.borderRadius=this.config.imageBorderRadius,i?.parentElement?s.insertBefore(e,i):s.appendChild(e),t.tags.bi=e}}class L extends H{constructor(t=[]){super(t),this.isMultiple=!1,this.Ue=[],this.Ne=-1,this.Ge=null,this.groups=[],this.We=[],this.qe()}init(){e.J.on("sche_vis_"+this.Se,()=>{const t=this.We.filter(t=>t.visible).length,s=this.We.length;this.Ue.forEach(i=>{i({Ke:t,Qe:s,hs:t>0,isEmpty:0===s})}),e.J.run("sche_vis_proxy_"+this.Se)},{tt:10}),super.init(),this.mount()}qe(){this.We=[],this.groups=[],this.items.forEach(t=>{t instanceof y?(this.groups.push(t),this.We.push(...t.items)):t instanceof w&&this.We.push(t)})}Ce(t,s){return s instanceof y?new P(t):new C(t)}Pe(t,s,i){t.position=i,t instanceof y?this.Ye(t,s,i):t instanceof w&&this.Je(t,s,i),t.Tt=!0}Ye(t,s,i){super.Pe(t,s,i),t.view=s;const e=s.view.tags.je;e.textContent=t.label,t.Tt||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.ti()}),t.Zs((t,s,i)=>{s.items.forEach(t=>{const s=t.view?.ci?.();s&&(s.style.display=i?"none":"")}),this.Xe(s,i)}));const h=s.$e();t.items.forEach((t,s)=>{let i=t.view;t.Tt&&i||(i=new C(h)),this.Je(t,i,s),t.Tt=!0}),s.Xs(t.collapsed),s.ii()}Je(t,s,i){if(s.isMultiple=this.isMultiple,s.hasImage=t.hasImage,s.De={imageWidth:t.options.imageWidth,imageHeight:t.options.imageHeight,imageBorderRadius:t.options.imageBorderRadius,imagePosition:t.options.imagePosition,labelValign:t.options.labelValign,labelHalign:t.options.labelHalign},t.Tt||super.Pe(t,s,i),t.view=s,t.hasImage){const i=s.view.tags.bi;i&&(i.src!==t.ai&&(i.src=t.ai),i.alt!==t.text&&(i.alt=t.text))}s.view.tags.mi.innerHTML=t.text,t.Tt||(s.view.tags._e.addEventListener("click",async s=>{s.stopPropagation(),s.preventDefault(),this.Fi||(this.isMultiple?(await this.$i("select"),t.selected=!t.selected):!0!==t.selected&&(await this.$i("select"),this.Ge&&(this.Ge.selected=!1),t.selected=!0))}),s.view.tags._e.title=t.textContent,s.view.tags._e.addEventListener("mouseenter",()=>{this.Fi||this.Ze(this.We.indexOf(t),!1)}),t.gi(()=>{this.ki("selected")}),t.fi((s,i,e)=>{e&&(this.Ge=t),this.ki("selected_internal")}),t.cs((t,s)=>{s.group?.ii(),this.th()})),t.selected&&(this.Ge=t,t.ui=!0)}async Ie(t){await this.$i("items",t),this.items=t,this.qe(),await this.ki("items",t),this.update()}async Pi(t){await this.Ie(t)}Ii(t){this.items=t,this.qe(),this.update()}destroy(){this.is(o.DESTROYED)||(e.J.clear("sche_vis_"+this.Se),this.groups.forEach(t=>{t.destroy()}),this.Ue=[],this.Ne=-1,this.Ge=null,this.groups=[],this.We=[],super.destroy())}sh(){return this.We.filter(t=>t.selected)}ih(){return this.We.find(t=>t.selected)}Zt(t){this.isMultiple&&this.We.forEach(s=>{s.selected=t})}cs(t){this.Ue.push(t)}th(){e.J.run("sche_vis_"+this.Se)}ns(){const t=this.We.filter(t=>t.visible).length,s=this.We.length;return{Ke:t,Qe:s,hs:t>0,isEmpty:0===s}}eh(){this.Ze(0)}navigate(t,s=!0){const i=this.We.filter(t=>t.visible);if(0===i.length)return;let e=i.findIndex(t=>t===this.We[this.Ne]);-1===e&&(e=-1);let h=e+t;h>=i.length&&(h=0),h<0&&(h=i.length-1);const n=this.We.indexOf(i[h]);this.Ze(n,s)}hh(){if(this.Ne>-1&&this.We[this.Ne]){const t=this.We[this.Ne];if(t.visible){const s=t.view?.ci?.();s&&s.click()}}}Ze(t,s=!0){let i=0;if("number"==typeof t)i=t;else if(t instanceof w){const s=this.We.indexOf(t);i=s>-1?s:0}else i=0;this.Ne>-1&&this.We[this.Ne]&&(this.We[this.Ne].pi=!1);for(let e=i;e<this.We.length;e++){const t=this.We[e];if(t?.visible){if(t.pi=!0,this.Ne=e,s){const s=t.view?.ci?.();s?s.scrollIntoView({block:"center",behavior:"smooth"}):this.Vt?.nh?.(e,{scrollIntoView:!0})}return void this.oh(e,t.view?.ci?.()?.id)}}}oh(t,s){}Xe(t,s){}}class I extends r{constructor(t=0){super(),this.rh=[],this.ah=0,this.initialize(t)}initialize(t){this.init(),this.reset(t)}reset(t){this.ah=t,this.rh=Array(t+1).fill(0)}add(t,s){for(let i=t;i<=this.ah;i+=i&-i)this.rh[i]+=s}uh(t){let s=0;for(let i=t;i>0;i-=i&-i)s+=this.rh[i];return s}dh(t,s){return s<t?0:this.uh(s)-this.uh(t-1)}ph(t){this.reset(t.length),t.forEach((t,s)=>this.add(s+1,t))}gh(t){let s=0,i=1;for(;i<<1<=this.ah;)i<<=1;let e=0;for(let h=i;0!==h;h>>=1){const i=s+h;i<=this.ah&&e+this.rh[i]<=t&&(s=i,e+=this.rh[i])}return s}}class F extends x{constructor(t=null){super(t),this.fh={Yt:void 0,_t:36,Bt:8,Ut:!0,mh:!0},this.bh=[],this.yh=new I(0),this.wh=new Map,this.xh=!1,this.start=0,this.end=-1,this.Mh=null,this.Th=null,this.updating=!1,this.Oh=!1,this.Ah=0,this.Hh=!1,this.Sh=!1,this.Ph=0,this.Ch=0,this.Lh=0,this.Ih=0}configure(t){this.fh={...this.fh,...t}}Ci(t){if(this.Xt&&this.dispose(),super.Ci(t),t.Vt=this,!this.Ri)return;this.Ri.replaceChildren();const s=e.C({Fh:{tag:{node:"div",classList:"seui-virtual-pad-top"}},jh:{tag:{node:"div",classList:"seui-virtual-items"}},Eh:{tag:{node:"div",classList:"seui-virtual-pad-bottom"}}},this.Ri);if(this.Fh=s.Fh,this.jh=s.jh,this.Eh=s.Eh,this.Yt=this.fh.Yt??this.Ri.closest(".seui-popup")??this.Ri.parentElement,!this.Yt)throw Error("VirtualRecyclerView: scrollEl not found");this.$h=this.Vh.bind(this),this.Yt.addEventListener("scroll",this.$h,{passive:!0}),this.refresh(!1),this.kh(),t?.cs?.(()=>this.Rh())}suspend(){this.Hh=!0,this.Dh(),this.Yt&&this.$h&&this.Yt.removeEventListener("scroll",this.$h),this.zh&&(this.zh.disconnect(),this.Sh=!0)}resume(){this.Hh=!1,this.Yt&&this.$h&&this.Yt.addEventListener("scroll",this.$h,{passive:!0}),this.Sh&&(this.kh(),this.Sh=!1),this._h()}refresh(t){if(!this.Xt||!this.Ri)return;t||this.Rh();const s=this.Xt.Le();if(this.Ah=s,0===s)return this.Bh(),void this.update();this.bh.length=s,this.xh||(this.Uh(),this.xh=!0),this.Nh(s),this._h(),this.update()}nh(t,s){this.Gh(t,t),s?.scrollIntoView&&this.Wh(t)}Wh(t){if((this.Xt?.Le?.()??0)<=0)return;const s=this.qh(t),i=this.Kh()+s,e=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight);this.Yt.scrollTop=Math.min(Math.max(0,i),e)}dispose(){this.Dh(),this.Yt&&this.$h&&this.Yt.removeEventListener("scroll",this.$h),this.zh?.disconnect(),this.wh.forEach(t=>t.remove()),this.wh.clear()}destroy(){this.is(o.DESTROYED)||(this.Bh(),this.dispose(),this.Fh.remove(),this.jh.remove(),this.Eh.remove(),this.Fh=null,this.jh=null,this.Eh=null,super.destroy())}Rh(){if(!this.Xt)return;const t=this.Xt.Le();t<=0||(this.suspend(),this.Bh(),this.Qh(),this.Yh(t),this.Nh(t),this.start=0,this.end=-1,this.resume())}Dh(){null!=this.Mh&&(cancelAnimationFrame(this.Mh),this.Mh=null),null!=this.Th&&(cancelAnimationFrame(this.Th),this.Th=null)}Bh(){this.wh.forEach(t=>t.remove()),this.wh.clear(),this.bh=[],this.yh.reset(0),this.Fh.style.height="0px",this.Eh.style.height="0px",this.xh=!1,this.Lh=0,this.Ih=0}Uh(){this.Jh(0);const t=this.wh.get(0);if(!t)return;const s=this.Xh(t);if(isNaN(s)||(this.fh._t=s),!this.fh.Ut){t.remove(),this.wh.delete(0);const s=this.Xt.items[0];s&&(s.Tt=!1,s.view=null)}}Zh(t){const s=this.Xt?.items?.[t];return s?.visible??!0}tn(t,s){for(let i=Math.max(0,t);i<s;i++)if(this.Zh(i))return i;return-1}Yh(t){this.Lh=0,this.Ih=0;for(let s=0;s<t;s++){if(!this.Zh(s))continue;const t=this.bh[s];null!=t&&(this.Lh+=t,this.Ih++)}}Kh(){const t=this.Ri.getBoundingClientRect(),s=this.Yt.getBoundingClientRect();return Math.max(0,t.top-s.top+this.Yt.scrollTop)}sn(){const t=performance.now();if(t-this.Ph<16)return this.Ch;const s=this.Yt.querySelector(".seui-option-handle:not(.hide)");return this.Ch=s?.offsetHeight??0,this.Ph=t,this.Ch}_h(){null!=this.Mh||this.Hh||(this.Mh=requestAnimationFrame(()=>{this.Mh=null,this.en()}))}Xh(t){const s=t.getBoundingClientRect(),i=getComputedStyle(t);return Math.max(1,s.height+(parseFloat(i.marginTop)||0)+(parseFloat(i.marginBottom)||0))}hn(){return this.fh.mh&&this.Ih>0?Math.max(1,this.Lh/this.Ih):this.fh._t}Nh(t){const s=this.hn(),i=Array.from({length:t},(t,i)=>this.Zh(i)?this.bh[i]??s:0);this.yh.ph(i)}nn(t,s){if(!this.Zh(t))return!1;const i=this.hn(),e=this.bh[t]??i;if(Math.abs(s-e)<=F.rn)return!1;const h=this.bh[t];return null==h?(this.Lh+=s,this.Ih++):this.Lh+=s-h,this.bh[t]=s,this.yh.add(t+1,s-e),!0}ln(t,s){const i=this.yh.gh(Math.max(0,t)),e=Math.min(s-1,i),h=this.tn(e,s);return-1===h?Math.max(0,e):h}an(t,s){s.setAttribute(F.un,t+"");const i=this.wh.get(t-1);if(i?.parentElement===this.jh)return void i.after(s);const e=this.wh.get(t+1);if(e?.parentElement===this.jh)return void this.jh.insertBefore(s,e);const h=Array.from(this.jh.children);for(const n of h){const i=n.getAttribute(F.un);if(i&&+i>t)return void this.jh.insertBefore(s,n)}this.jh.appendChild(s)}cn(t,s){if(s.parentElement!==this.jh)return void this.an(t,s);s.setAttribute(F.un,t+"");const i=s.previousElementSibling,e=s.nextElementSibling;(i&&+i.getAttribute(F.un)>t||e&&+e.getAttribute(F.un)<t)&&(s.remove(),this.an(t,s))}kh(){this.zh||(this.zh=new ResizeObserver(()=>{this.Oh||this.Hh||!this.Xt||null!=this.Th||(this.Th=requestAnimationFrame(()=>{this.Th=null,this.dn()}))}),this.zh.observe(this.jh))}dn(){if(!this.Xt)return;const t=this.Xt.Le();if(t<=0)return;let s=!1;for(let i=this.start;i<=this.end;i++){if(!this.Zh(i))continue;const t=this.Xt.items[i],e=t?.view?.ci?.();if(!e)continue;const h=this.Xh(e);this.nn(i,h)&&(s=!0)}s&&(this.fh.mh&&this.Nh(t),this._h())}Vh(){this._h()}en(){if(!this.updating&&!this.Hh){this.updating=!0;try{if(!this.Xt)return;const t=this.Xt.Le();if(t<=0)return;this.Ah!==t&&(this.Ah=t,this.bh.length=t,this.Nh(t));const s=this.Kh(),i=Math.max(0,this.Yt.scrollTop-s),e=this.sn(),h=Math.max(0,this.Yt.clientHeight-e),n=this.ln(i,t),o=this.qh(n),r=s+o-this.Yt.scrollTop,l=this.ln(i,t);if(-1===l)return void this.Bh();const a=this.hn(),u=this.fh.Bt*a;let c=this.tn(Math.min(t-1,this.yh.gh(Math.max(0,i-u))),t)??l,d=Math.min(t-1,this.yh.gh(i+h+u));if(c===this.start&&d===this.end)return;this.start=c,this.end=d,this.Oh=!0;try{this.Gh(this.start,this.end),this.pn(this.start,this.end),this.fh.Ut&&this.dn();const s=this.qh(this.start),i=this.gn(this.start,this.end),e=this.fn(t),h=Math.max(0,e-s-i);this.Fh.style.height=s+"px",this.Eh.style.height=h+"px"}finally{this.Oh=!1}const p=this.qh(n),g=this.Kh()+p-r,f=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight),m=Math.min(Math.max(0,g),f),b=Math.abs(p-o)>1,y=Math.abs(this.Yt.scrollTop-m);b&&y>.5&&y<100&&(this.Yt.scrollTop=m)}finally{this.updating=!1}}}Gh(t,s){for(let i=t;i<=s;i++)this.Jh(i)}Jh(t){if(!this.Zh(t)){const s=this.wh.get(t);return s?.parentElement===this.jh&&s.remove(),void this.wh.delete(t)}const s=this.Xt.items[t];if(!s)return;const i=this.wh.get(t);if(i)return void(s?.view?(this.cn(t,i),this.Xt.Pe(s,s.view,t)):(i.remove(),this.wh.delete(t)));if(s.Tt)s.view&&this.Xt.Pe(s,s.view,t);else{const i=this.Xt.Ce(this.jh,s);s.view=i,this.Xt.Pe(s,i,t),s.Tt=!0}const e=s.view?.ci?.();e&&(this.cn(t,e),this.wh.set(t,e))}pn(t,s){this.wh.forEach((i,e)=>{(e<t||e>s)&&(i.parentElement===this.jh&&i.remove(),this.wh.delete(e))})}Qh(){this.wh.forEach((t,s)=>{this.Zh(s)||(t.parentElement===this.jh&&t.remove(),this.wh.delete(s))})}qh(t){return this.yh.uh(t)}gn(t,s){return this.yh.dh(t+1,s+1)}fn(t){return this.yh.uh(t)}}F.rn=.5,F.un="data-vindex";class j extends r{constructor(t,s){super(),this.container={},this.oldValue=null,this.node=null,this.options=null,this.mn=null,this.isOpen=!1,this.bn=!1,this.yn=!1,this.wn=!1,this.ae=null,this.plugins=[],this.vn=null,t&&s&&this.initialize(t,s)}get isDisabled(){return!!this.options?.disabled}set isDisabled(t){this.options&&this.node&&(this.options.disabled=t,this.node.classList.toggle("disabled",t),this.node.setAttribute("aria-disabled",t+""),this.container.tags?.Os?.setAttribute("aria-disabled",t+""))}get xn(){return!!this.options?.readonly}set xn(t){this.options&&this.node&&(this.options.readonly=t,this.node.classList.toggle("readonly",t))}get isVisible(){return!!this.options?.visible}set isVisible(t){this.options&&this.node&&(this.options.visible=t,this.node.classList.toggle("invisible",!t))}initialize(t,s){const i=e.V(t);this.options=i.options,this.ae=s,this.init(t)}init(t){if(this.state!==o.NEW)return;if(!t||!this.options)return;const i=this.options,h=new l(i),n=new a,r=new f(i),effector=s(),u=new v(i),c=new M(i),d=new T(t,u,this),p=new O(t),m=new A(t);h.node&&(h.node.id=(i.Mn??"")+"");const b=e.C({Tn:{tag:{node:"div",classList:"seui-MAIN"},L:{Os:{tag:{node:"div",classList:"seui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.On()?.open())}},L:{An:{tag:h.node},Hn:{tag:n.node},Rs:{tag:r.node}}}}}},null);if(this.container=b,this.node=b.view,b.Sn=d,b.placeholder=h,b.Pn=n,b.Cn=r,b.effector=effector,b.targetElement=t,b.Ln=c,b.In=p,b.Fn=m,u.Ti(L),u.Ai(i.virtualScroll?F:x),u.Si(e.q(t)),u.on("onUpdate",()=>{b.se?.rs?.()}),this.mn=u,b.se=new g(t,i,u),b.se.bs(effector),b.se.As(d,i),b.se.fs("selected",()=>{this.On()?.change(null,!0)}),b.se.fs("selected_internal",()=>{this.On()?.change(null,!1)}),b.se.ps("select",()=>{this.oldValue=this.On()?.value??""}),c.Gi(b.tags.Os),c.qi(u),this.jn(t,b,i,d,r),this.En(p,m,t,u),this.plugins=this.ae?.$n?.()??[],this.plugins.length){const t=u.Jt(),s={ie:this,options:i,Xt:t.Xt,Vn:t.Vt,kn:b.tags,actions:this.On()};this.vn=s,this.Rn("init",t=>t.init?.(s))}this.isDisabled=e.F(i.disabled),this.xn=e.F(i.readonly),super.init()}mount(){if(this.state!==o.INITIALIZED)return;if(!this.node||!this.container.targetElement)return;const t=this.container.targetElement,s=this.container;t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,s.tags.Os),s.tags.Os.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.ot(t,s.tags.Os),t.classList.add("init"),this.On()?.change(null,!1),super.mount()}update(){this.state===o.MOUNTED&&(this.container.se?.rs?.(),super.update())}jn(t,s,i,h,n){const o=s.se.Lt;let r=null;const l=(t,n)=>{n||""!==t?(""!==t&&(this.yn=!0),h.search(t).then(t=>{clearTimeout(r),e.J.clear("sche_vis_proxy_"+o.Se),e.J.on("sche_vis_proxy_"+o.Se,()=>{s.se?.rs?.(),t?.we&&(r=setTimeout(()=>{o.eh(),s.se?.rs?.()},i.animationtime??0))},{tt:10})}).catch(t=>{console.error("Search error:",t)})):h.clear()};let a=null;n.Es=(t,e)=>{h.ye(t)&&(a&&clearTimeout(a),h.ne()?(s.se?.ss?.(),a=setTimeout(()=>{l(t,e)},i.delaysearchtime??0)):a=setTimeout(()=>{l(t,e)},10))},h.setPopup(s.se),n.$s=t=>{o.navigate(t)},n.Vs=()=>{o.hh()},n.ks=()=>{this.On()?.close(),s.tags.Os.focus()},o.oh=(t,s)=>{s&&n.zs(s)},o.Xe=()=>{s.se?.rs?.()},i.ajax&&(null==i.ajax?.keepSelected&&(i.ajax.keepSelected=i.keepSelected),h.ge(i.ajax))}En(t,s,i,h){t.connect(),t.Pt=t=>{h.Li(e.q(t)),this.On()?.refreshMask()},s.connect(),s.Pt=t=>{e.F(t.disabled)!==this.isDisabled&&(this.isDisabled=e.F(t.disabled)),e.F(t.readonly)!==this.xn&&(this.xn=e.F(t.readonly)),e.F(t.visible)!==this.isVisible&&(this.isVisible=e.F(t.visible??"1"))}}Dn(){if(this.wn)return;const t=this.container??{},{In:s,Fn:i}=t;this.plugins.length&&this.Rn("destroy",t=>t.destroy?.()),this.plugins=[],this.vn=null,s?.disconnect&&s.disconnect(),i?.disconnect&&i.disconnect(),this.wn=!0}destroy(){if(this.is(o.DESTROYED))return;this.Dn();const t=this.container;t.Sn.destroy(),t.Pn.destroy(),t.se.destroy(),t.Ln.destroy(),t.placeholder.destroy(),t.Cn.destroy(),this.mn.destroy(),this.node?.remove(),this.container={},this.node=null,this.options=null,this.mn=null,this.ae=null,this.oldValue=null,this.isOpen=!1,this.bn=!1,this.yn=!1,super.destroy()}On(){const t=this.container,s=this,i=()=>this.ae.find(t.targetElement),n=e.V(t.targetElement);if(!n)return null;const r=n.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(s){t.placeholder?.set(s),t.Cn?.Ds(s)},get oldValue(){return s.oldValue},set value(t){this.setValue(null,t,!0)},get value(){const t=this.valueArray,s=t.length;return s>1?t:0===s?"":t[0]},get valueArray(){const t=[];return s.zn().forEach(s=>{s.selected&&t.push(s.value)}),t},get valueString(){return this.valueArray.join(r.customDelimiter)},get valueOptions(){const t=[];return s.zn(!0).forEach(s=>{t.push(s)}),t},get mask(){const t=[];return s.zn(!0).forEach(s=>{t.push(s.text)}),t},get valueText(){const t=[];s.zn(!0).forEach(s=>{t.push(s.text)});const i=t.length;return i>1?t:0===i?"":t[0]},get isOpen(){return s.isOpen},getParent:()=>t.view.parentElement,valueDataset(t,i=null,e=!1){var h=[];if(s.zn(!0).forEach(t=>{h.push(i?t.dataset[i]:t.dataset)}),!e){if(0==h.length)return"";if(1==h.length)return h[0]}return h},selectAll(t,e=!0){if(!(r.multiple&&r.maxSelected>0&&s.zn().length>r.maxSelected)&&!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.et([i()],...r.on.beforeChange).isCancel)return;s.oldValue=this.value}s.zn().forEach(t=>{t.ui=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.et([i()],...r.on.beforeChange).isCancel)return;s.oldValue=this.value}s.zn().forEach(t=>{t.ui=!1}),this.change(!1,e)}},setValue(e=null,n,o=!0,l=!1){if(Array.isArray(n)||(n=[n]),0===(n=n.filter(t=>""!==t&&null!=t)).length)return s.zn().forEach(t=>t.ui=!1),void this.change(!1,o);if(r.multiple&&r.maxSelected>0&&n.length>r.maxSelected)console.warn(`Cannot select more than ${r.maxSelected} items`);else if(l||!this.disabled&&!this.readonly){if(t.Sn?.ne?.()){const{pe:i}=t.Sn.ce(n);if(i.length>0)return void(async()=>{r.loadingfield&&t.se?.ss?.();try{t.Sn.fe();const e=await t.Sn.oe(i);e.Ls&&e.items.length>0?(e.items.forEach(t=>{i.includes(t.value)&&(t.selected=!0)}),t.Sn.xe?.(e.items,!0,!0),setTimeout(()=>{s.zn().forEach(t=>{t.ui=n.some(s=>s==t.value)}),this.change(!1,!1)},100)):i.length>0&&console.warn(`Could not load ${i.length} values:`,i)}catch(e){console.error("Error loading missing values:",e)}finally{r.loadingfield&&t.se?.ls?.()}})()}if(o){if(h.et([i()],...r.on.beforeChange).isCancel)return;s.oldValue=this.value}s.zn().forEach(t=>{t.ui=n.some(s=>s==t.value)}),!r.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,o)}},open(){if(s.isOpen)return;const e=s.ae?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(h.et([i()],...r.on.beforeShow).isCancel)return;s.isOpen=!0,t.Pn.dt(!0);const n=t.se.Lt,o=n.ih();o?n.Ze(o,!1):n.eh(),s.bn&&!s.yn||!r?.ajax?t.se.open(null,!0):(t.Sn.fe(),t.se.ss(),s.bn=!0,s.yn=!1,setTimeout(()=>{t.se&&t.Sn&&t.Sn.search("").then(()=>t.se?.rs?.()).catch(t=>console.error("Initial ajax load error:",t))},r.animationtime),t.se.open(null,!1)),t.Cn.show();const l=t.tags.Os;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",r.qt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",r.Mn),r.multiple&&l.setAttribute("aria-multiselectable","true"),h.et([i()],...r.on.show),s.vn&&s.Rn("onOpen",t=>t._n?.(s.vn))},close(){s.isOpen&&(h.et([i()],...r.on.beforeClose).isCancel||(s.isOpen=!1,t.Pn.dt(!1),t.se.close(()=>{t.Cn.clear(!1)}),t.Cn.hide(),t.tags.Os.setAttribute("aria-expanded","false"),h.et([i()],...r.on.close),s.vn&&s.Rn("onClose",t=>t.Bn?.(s.vn))))},toggle(){s.isOpen?this.close():this.open()},change(e=null,n=!0){if(n){if(r.multiple&&r.maxSelected>0&&this.valueArray.length>r.maxSelected&&this.setValue(null,this.oldValue,!1,!0),this.disabled||this.readonly)return void this.setValue(null,this.oldValue,!1,!0);if(h.et([i(),this.value],...r.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}if(this.refreshMask(),t.Ln.Ki(this.valueOptions),n&&(t.targetElement&&h.ht(t.targetElement,"change"),h.et([i(),this.value],...r.on.change),s.options?.autoclose&&this.close()),s.is(o.MOUNTED)&&s.update(),s.vn&&s.mn){const t=s.mn.Jt();s.Rn("onChange",i=>i.Un?.(this.value,t.ji,t.Xt,s.vn))}},refreshMask(){let i=r.placeholder;!r.multiple&&s.zn().length>0&&(i=this.mask[0]),i??(i=r.placeholder),t.placeholder.set(i,!1),t.Cn.Ds(i)},on(t,s,i){r.on[s]||(r.on[s]=[]),r.on[s].push(i)},ajax(i,e){null==e.keepSelected&&(e.keepSelected=s.options.keepSelected),t.Sn.ge(e)},loadAjax:()=>new Promise((e,h)=>{t.se.ss(),t.Sn.fe(),s.bn=!0,s.yn=!1,t.se&&t.Sn?t.Sn.search("").then(()=>{t.se?.rs?.(),e(i())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(i())})};return this.Nn(l,"disabled","isDisabled"),this.Nn(l,"readonly","isReadOnly"),this.Nn(l,"visible","isVisible"),l}Nn(t,s,i){const e=this;Object.defineProperty(t,s,{get:()=>e[i],set(t){e[i]=!!t,e.container?.targetElement?.dataset&&(e.container.targetElement.dataset[s]=!!t+"")},enumerable:!0,configurable:!0})}zn(t=null){if(!this.mn)return[];const{ji:s}=this.mn.Jt(),i=[];for(const e of s)e instanceof w?i.push(e):e instanceof y&&Array.isArray(e.items)&&e.items.length&&i.push(...e.items);return"boolean"==typeof t?i.filter(s=>s.selected===t):i}Rn(t,s){this.plugins.length&&this.plugins.forEach(i=>{try{s(i)}catch(e){console.error(`Plugin "${i.id}" ${t} error:`,e)}})}}class E{constructor(){this.isActive=!1,this.Ae=null,this.actions=[]}Gn(t){this.actions.push(t)}Wn(){this.actions=[]}connect(t){if(this.isActive)return;this.isActive=!0;const s=t.toUpperCase(),i=t.toLowerCase();this.Ae=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===s&&this.qn(e),e.querySelectorAll(i).forEach(t=>this.qn(t))})}),this.Ae.observe(document.body,{childList:!0,subtree:!0})}disconnect(){this.isActive&&(this.isActive=!1,this.Ae?.disconnect(),this.Ae=null)}qn(t){this.actions.forEach(s=>s(t))}}class $ extends r{constructor(){super(),this.Kn=new Map,this.plugins=new Map,this.init()}init(){this.is(o.NEW)&&(this.Kn=new Map,this.plugins=new Map,super.init())}bind(t,s){this.is(o.NEW)&&this.init();const i=e.j(e.B(),s);i.on=i.on??{},i.on.load=i.on.load??[],this.Kn.set(t,i);const n=e.m();e.J.on(n,()=>{h.et([this.find(t)],...i.on.load),e.J.clear(n),i.on.load=[]});const r=e.v(t);let l=!1;r.forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e.R(t),this.Qn(t,i)&&(l=!0,e.J.run(n)))})()}),e.U().includes(t)||e.U().push(t),this.is(o.INITIALIZED)&&l&&this.mount(),this.is(o.MOUNTED)&&this.update()}mount(){this.state===o.INITIALIZED&&super.mount()}update(){this.state===o.MOUNTED&&super.update()}find(t="*"){const s={isEmpty:!0};if("*"===t&&""===(t=e.U().join(", ")))return s;const i=e.v(t);if(0===i.length)return s;const h=e.V(i[0]);if(!h||!h.action)return s;const n={};for(const e in h.action)n[e]=this.Yn(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.Jn(o,t.name,i);break;case"func":this.Xn(o,t.name,i)}}return o}$n(){return Array.from(this.plugins.values())}Zn(){this.so||(this.so=new E,this.so.Gn(t=>{this.Kn.forEach((s,i)=>{try{t.matches(i)&&(this.Qn(t,s),this.is(o.MOUNTED)&&this.update())}catch(e){console.warn("Invalid selector: "+i,e)}})})),this.so.connect("select")}destroy(t=null){null===t?this.io():"string"==typeof t?this.eo(t):t instanceof HTMLSelectElement&&this.ho(t),null!==t&&this.is(o.MOUNTED)&&this.update()}registerPlugin(t){t?.id&&this.plugins.set(t.id,t)}unregisterPlugin(t){t&&this.plugins.delete(t)}no(t){if(t)return this.plugins.get(t)}io(){this.state!==o.DESTROYED&&(e.U().forEach(t=>this.eo(t)),this.Kn.clear(),e.U().length=0,this.plugins.forEach(t=>{t.destroy?.(),t.oo?.()}),this.plugins.clear(),this.so?.disconnect(),this.plugins.clear(),super.destroy())}eo(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.ho(t)}),this.Kn.delete(t);const s=e.U(),i=s.indexOf(t);i>-1&&s.splice(i,1)}ho(t){const s=e.V(t);if(!s)return;const i=s.self;e._(t,s);const h=!!this.so;h&&this.so?.disconnect(),s.self?.Dn?.();const n=s.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.ro,n&&n.parentNode?n.parentNode.replaceChild(t,n):t.appendChild(t),e.$(t),h&&this.Kn.size>0&&this.so?.connect("select"),i?.destroy?.()}rebind(t,s){this.eo(t),this.bind(t,s),this.is(o.MOUNTED)&&this.update()}Qn(t,s){if(e.V(t)||e.D(t))return!1;const i=e.m(8),h=e.I(t,s);h.lo=i,h.qt=`seui-${i}-optionlist`,h.Mn=`seui-${i}-placeholder`;const n={options:h};e.k(t,n);const o=new j(t,this);return o.on("onMount",()=>{o.container.view&&o.container.view.addEventListener("mouseup",()=>{n.action?.toggle?.()})}),o.mount(),n.container=o.container,n.action=o.On(),n.self=o,!0}Yn(t,s){const i=Object.getOwnPropertyDescriptor(s,t);let e="variable";return i?.get||i?.set&&"function"!=typeof s[t]?e="get-set":"function"==typeof s[t]&&(e="func"),{type:e,name:t}}Jn(t,s,i){Object.defineProperty(t,s,{get(){const t=e.V(i[0]);return t.action?.[s]},set(t){i.forEach(i=>{const h=e.V(i);h?.action&&(h.action[s]=t)})},enumerable:!0,configurable:!0})}Xn(t,s,i){t[s]=(...n)=>{let o=null;for(let t=0;t<i.length;t++){const r=e.V(i[t]);if(!r?.action)continue;const l=h.it();if(o??(o=r.action[s](l.st,...n)),!l.token.isContinue)break}return o??t}}}if(void 0===globalThis.GLOBAL_SEUI){const k=new $;globalThis.GLOBAL_SEUI={version:"1.2.6",name:"SelectiveUI",bind:k.bind.bind(k),find:k.find.bind(k),destroy:k.destroy.bind(k),effector:s.bind(s),rebind:k.rebind.bind(k),registerPlugin:k.registerPlugin.bind(k),unregisterPlugin:k.unregisterPlugin.bind(k)};let R=!1;function init(){R||(R=!0,document.addEventListener("mousedown",()=>{const t=e.U();if(t.length>0){const s=k.find(t.join(", "));s.isEmpty||s.close()}}),k.Zn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",init):init()),console.log("[SelectiveUI] v1.2.6 loaded successfully")}else console.warn(`[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). Using existing instance. Please remove duplicate <script> tags.`);const version=globalThis.GLOBAL_SEUI.version,V=globalThis.GLOBAL_SEUI.name;t.bind=(t,s={})=>{globalThis.GLOBAL_SEUI.bind(t,s)},t.destroy=(t=null)=>{globalThis.GLOBAL_SEUI.destroy(t)},t.effector=t=>globalThis.GLOBAL_SEUI.effector(t),t.find=t=>globalThis.GLOBAL_SEUI.find(t),t.name=V,t.rebind=(t,s={})=>{globalThis.GLOBAL_SEUI.rebind(t,s)},t.registerPlugin=t=>{globalThis.GLOBAL_SEUI.registerPlugin(t)},t.unregisterPlugin=t=>{globalThis.GLOBAL_SEUI.unregisterPlugin(t)},t.version=version},"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).SelectiveUI={});
|
|
1
|
+
/*! Selective UI v1.2.7 | MIT License */
|
|
2
|
+
var t,s;t=this,s=function(t){"use strict";function s(t){return new m(t??null)}class i{constructor(){this.t={accessoryVisible:!0,virtualScroll:!0,accessoryStyle:"top",multiple:!1,minWidth:"50px",width:"0px",offsetWidth:null,minHeight:"30px",height:"30px",panelHeight:"220px",panelMinHeight:"100px",disabled:!1,readonly:!1,selectall:!0,keepSelected:!0,placeholder:"Select value",altMask:"",autoclose:!1,autoscroll:!0,autofocus:!0,searchable:!0,loadingfield:!0,visible:!0,skipError:!1,customDelimiter:",",textLoading:"Processing...",textNoData:"No data available",textNotFound:"Not found",textSelectAll:"Select all",textDeselectAll:"Deselect all",textAccessoryDeselect:"Deselect: ",animationtime:200,delaysearchtime:200,allowHtml:!1,maxSelected:0,labelHalign:"left",labelValign:"center",imageMode:!1,imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",imagePosition:"right",ajax:null,on:{load:[],beforeShow:[],show:[],beforeChange:[],change:[],beforeClose:[],close:[]}},this.i=new Map,this.h=new Map,this.o=[]}}class e{static get l(){return this.u||(this.u=new i),this.u}static p(t){if(null===t||"object"!=typeof t)return t;const s=Array.isArray(t)?[]:{};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=this.p(t[i]));return s}static m(t=6){let s="";for(let i=0;i<t;i++)s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return s}static v(t){if(!t)return[];if("string"==typeof t){const s=document.querySelectorAll(t);return Array.from(s)}return t instanceof HTMLElement?[t]:t instanceof NodeList||Array.isArray(t)?Array.from(t):[]}static M(t={}){return this.T(document.createElement(t.node??"div"),t,!0)}static T(t=document.documentElement,s=null,i=!1){const e={...s??{}},h=i?t:t.cloneNode(!0),n=e.classList;return"string"==typeof n?h.classList.add(n):Array.isArray(n)&&h.classList.add(...n),delete e.classList,["style","dataset"].forEach(t=>{const s=e[t];s&&"object"==typeof s&&Object.assign(h[t],s),delete e[t]}),e.role&&(h.setAttribute("role",e.role+""),delete e.role),e.ariaLive&&(h.setAttribute("aria-live",e.ariaLive+""),delete e.ariaLive),e.O&&(h.setAttribute("aria-labelledby",e.O+""),delete e.O),e.A&&(h.setAttribute("aria-controls",e.A+""),delete e.A),e.H&&(h.setAttribute("aria-haspopup",e.H+""),delete e.H),e.S&&(h.setAttribute("aria-multiselectable",e.S+""),delete e.S),e.P&&(h.setAttribute("aria-autocomplete",e.P+""),delete e.P),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,s])=>{h.addEventListener(t,s)}),delete e.event),Object.entries(e).forEach(([t,s])=>{null===s?h.removeAttribute(t):h[t]=s}),h}static C(t,s=null,i=!1,e=!1,h={}){let n=null;for(const o in t){const r=t[o],l=r?.tag?.tagName?r.tag:this.M(r.tag);h[o]=l,r?.L&&this.C(r.L,l,!1,!1,h),s?i?s.prepend(l):s.append(l):e||n||(n=l)}return e||(h.id=this.m(7),s||(h={tags:h,view:n})),h}static I(t,s){const i=this.p(s);for(const e in i){const s=t[e];s?i[e]="boolean"==typeof i[e]?this.F(s):s:void 0!==t?.dataset?.[e]&&(i[e]="boolean"==typeof i[e]?this.F(t.dataset[e]):t.dataset[e])}return i}static j(...t){if(0===t.length)return{};if(1===t.length)return this.p(t[0]);const s=this.p(t[0]);for(let i=1;i<t.length;i++){const e=t[i];for(const t in e)if("on"===t){const i=e[t];for(const e in i)s[t][e].push(i[e])}else s[t]=e[t]}return s}static F(t){if("boolean"==typeof t)return t;if("string"!=typeof t)return!!t;switch(t.trim().toLowerCase()){case"true":case"1":case"yes":case"on":return!0;default:return!1}}static $(t){return this.l.i.delete(t)}static V(t){return this.l.i.get(t)}static k(t,s){this.l.i.set(t,s)}static R(t){return this.l.h.delete(t)}static D(t){return this.l.h.get(t)}static _(t,s){this.l.h.set(t,s)}static B(){return this.l.t}static U(){return this.l.o}static N(t){if(null==t)return"";let s=(t+"").replace(/<`/g,"<").replace(/`>/g,">").replace(/\<\`/g,"<").replace(/\`\>/g,">").trim();const i=globalThis?.document;if(!i||"function"!=typeof i.createElement)return s=s.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<iframe\b[^>]*>[\s\S]*?<\/iframe>/gi,"").replace(/<(object|embed|link)\b[^>]*>[\s\S]*?<\/\1>/gi,""),s=s.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,""),s=s.replace(/\s([a-z-:]+)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,""),s;const e=i.createElement("div");return e.innerHTML=s,e.querySelectorAll("script, style, iframe, object, embed, link").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const s in t.attributes){const i=t.attributes[s],e=i.name??"",h=i.value??"";if(/^on/i.test(e))return void t.removeAttribute(e);/^(href|src|xlink:href)$/i.test(e)&&/^javascript:/i.test(h)&&t.removeAttribute(e)}}),(e.innerHTML??"").trim()}static G(t){const s=document.createElement("DIV");s.innerHTML=t;const i=s.textContent??s.innerText??"";return s.remove(),i.trim()}static W(t){return null==t?"":(t+"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"d")}static q(t){const s=[];return Array.from(t.children).forEach(t=>{if("OPTGROUP"===t.tagName){const i=t;s.push(i),Array.from(i.children).forEach(t=>{t.__parentGroup=i,s.push(t)})}else"OPTION"===t.tagName&&s.push(t)}),s}static K(){const t=navigator.userAgent;return/iP(hone|ad|od)/.test(t)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1}static Y(t){const s=(t+"").trim();if(s.endsWith("px"))return s;if(s.endsWith("vh"))return window.innerHeight*parseFloat(s)/100+"px";if(s.endsWith("vw"))return window.innerWidth*parseFloat(s)/100+"px";const i=parseFloat(getComputedStyle(document.documentElement).fontSize);if(s.endsWith("rem"))return i*parseFloat(s)+"px";const e=this.M({node:"div",style:{height:s,opacity:"0"}});document.body.appendChild(e);const h=e.offsetHeight+"px";return e.remove(),h}}e.u=null,e.J=new class{constructor(){this.X=new Map,this.Z=new Map}on(t,s,i={}){const e=i.tt??50,h=i.once??!1;this.X.has(t)||this.X.set(t,[]),this.X.get(t).push({st:s,timeout:e,once:h})}off(t){const s=this.Z.get(t);if(s){for(const t of s.values())clearTimeout(t);s.clear(),this.Z.delete(t)}this.X.delete(t)}run(t,...s){const i=this.X.get(t);if(!i||0===i.length)return Promise.resolve();this.Z.has(t)||this.Z.set(t,new Map);const e=this.Z.get(t),h=[];for(let n=0;n<i.length;n++){const t=i[n];if(!t)continue;const o=e.get(n);o&&clearTimeout(o);const r=new Promise(h=>{const o=setTimeout(async()=>{try{const i=t.st(s.length>0?s:null);i instanceof Promise&&await i}catch{}finally{if(t.once){i[n]=void 0;const t=e.get(n);t&&clearTimeout(t),e.delete(n)}h()}},t.timeout);e.set(n,o)});h.push(r)}return Promise.all(h).then(()=>{})}clear(t){if(void 0===t)for(const s of Array.from(this.X.keys()))this.off(s);else this.off(t)}};class h{static it(){const t={isContinue:!0,isCancel:!1};return{token:{get isContinue(){return t.isContinue},get isCancel(){return t.isCancel}},st:{stopPropagation(){t.isContinue=!1},cancel(){t.isCancel=!0,t.isContinue=!1}}}}static et(t,...s){const{token:i,st:e}=this.it();for(let h=0;h<s.length;h++){const n=s[h];if("function"==typeof n&&(t&&Array.isArray(t)?n(e,...t):n(e),i.isCancel||!i.isContinue))break}return i}static ht(t,s,i={bubbles:!0,cancelable:!0}){const e=new Event(s,i);return t.dispatchEvent(e),e}static nt(t,...s){if(Array.isArray(t))for(const i of t)"function"==typeof i&&i(...s)}}class n{static ot(t,s){const i=e.V(t);if(!i?.options)return;const h=i.options,n=h.minWidth,o=h.minHeight,r=Number.parseInt(h.width,10),l=Number.parseInt(h.height,10);let a=t.offsetWidth+"px",u=t.offsetHeight+"px";const c=getComputedStyle(t);"0px"===a&&"auto"!==c.width&&(a=c.width),"0px"===u&&"auto"!==c.height&&(u=c.height),r>0&&(a=h.width),l>0&&(u=h.height),Object.assign(s.style,{width:a,height:u,minWidth:n,minHeight:o})}}var o;(t=>{t.NEW="new",t.INITIALIZED="initialized",t.MOUNTED="mounted",t.UPDATED="updated",t.DESTROYED="destroyed"})(o||(o={}));class r{constructor(){this.state=o.NEW,this.rt=new Map,this.rt.set("onInit",new Set),this.rt.set("onMount",new Set),this.rt.set("onUpdate",new Set),this.rt.set("onDestroy",new Set)}on(t,s){return this.rt.get(t).add(s),this}off(t,s){return this.rt.get(t).delete(s),this}emit(t,s){const i={state:this.state,lt:s};for(const h of this.rt.get(t))try{h(i)}catch(e){this.ut(e,t)}}ut(t,s){console.error(`[Lifecycle:${s}]`,t)}init(){if(this.state!==o.NEW)return;const t=this.state;this.state=o.INITIALIZED,this.emit("onInit",t)}mount(){if(this.state!==o.INITIALIZED)return;const t=this.state;this.state=o.MOUNTED,this.emit("onMount",t)}update(){if(this.state!==o.MOUNTED&&this.state!==o.UPDATED)return;const t=this.state;this.state=o.UPDATED,this.emit("onUpdate",t)}destroy(){if(this.state===o.DESTROYED)return;const t=this.state;this.state=o.DESTROYED,this.emit("onDestroy",t),this.ct()}getState(){return this.state}is(t){return this.state===t}ct(){for(const t of this.rt.values())t.clear()}}class l extends r{constructor(t){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.node=e.M({node:"div",classList:"seui-placeholder",innerHTML:t.placeholder}),this.options=t,this.init()}get(){return this.options?.placeholder??""}set(t,s=!0){if(!this.node||!this.options)return;s&&(this.options.placeholder=t);const i=e.N(t);this.node.innerHTML=this.options.allowHtml?i:e.G(i)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.node=null,this.options=null,super.destroy())}}class a extends r{constructor(){super(),this.init()}init(){this.node=e.M({node:"div",classList:"seui-directive",role:"button",ariaLabel:"Toggle dropdown"}),super.init(),this.mount()}dt(t){this.node.classList.toggle("drop-down",!!t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.node=null,super.destroy())}}class u extends r{constructor(t=null){super(),this.gt=null,this.node=null,this.options=null,this.ft=[],this.bt=[],t&&this.initialize(t)}initialize(t){this.gt=e.C({yt:{tag:{node:"div",classList:["seui-option-handle","hide"]},L:{wt:{tag:{node:"a",classList:"seui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.nt(this.ft)}}},vt:{tag:{node:"a",classList:"seui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.nt(this.bt)}}}}}}),this.node=this.gt.view,this.options=t,this.init()}available(){return!!this.options&&e.F(this.options.multiple)&&e.F(this.options.selectall)}update(){this.node&&(this.available()?this.show():this.hide()),super.update()}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}xt(t=null){"function"==typeof t&&this.ft.push(t)}Mt(t=null){"function"==typeof t&&this.bt.push(t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.options=null,this.ft=null,this.bt=null,this.node=null,super.destroy())}}class c extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.M({node:"div",classList:["seui-empty-state","hide"],role:"status",ariaLive:"polite"}),this.init()}show(t="nodata"){this.node&&this.options&&(this.node.textContent="notfound"===t?this.options.textNotFound:this.options.textNoData,this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}destroy(){this.is(o.DESTROYED)||(this.options=null,this.node?.remove(),this.node=null,super.destroy())}}class d extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.M({node:"div",classList:["seui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"}),this.init()}show(t){this.node&&this.options&&(this.node.textContent=this.options.textLoading,this.node.classList.toggle("small",!!t),this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}destroy(){this.is(o.DESTROYED)||(this.options=null,this.node?.remove(),this.node=null,super.destroy())}}class p{constructor(){this.Tt=!1,this.element=null,this.Ot=null,this.At=null,this.Tt=!0,this.Ht=this.St.bind(this)}Pt(t){}St(){const t=this.element;if(!t||"function"!=typeof t.getBoundingClientRect)return void this.Pt({width:0,height:0,top:0,left:0,padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}});const s=t.getBoundingClientRect(),i="undefined"!=typeof window&&"function"==typeof window.getComputedStyle?window.getComputedStyle(t):null;this.Pt({width:s?.width??0,height:s?.height??0,top:s?.top??0,left:s?.left??0,padding:{top:parseFloat(i?.paddingTop??"0"),right:parseFloat(i?.paddingRight??"0"),bottom:parseFloat(i?.paddingBottom??"0"),left:parseFloat(i?.paddingLeft??"0")},border:{top:parseFloat(i?.borderTopWidth??"0"),right:parseFloat(i?.borderRightWidth??"0"),bottom:parseFloat(i?.borderBottomWidth??"0"),left:parseFloat(i?.borderLeftWidth??"0")},margin:{top:parseFloat(i?.marginTop??"0"),right:parseFloat(i?.marginRight??"0"),bottom:parseFloat(i?.marginBottom??"0"),left:parseFloat(i?.marginLeft??"0")}})}ht(){this.St()}connect(t){if(!(t instanceof HTMLElement))throw Error("Invalid element");this.element=t,this.Ot=new ResizeObserver(this.Ht),this.Ot.observe(t),this.At=new MutationObserver(this.Ht),this.At.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.Ht,!0),window.addEventListener("resize",this.Ht),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.Ht),window.visualViewport.addEventListener("scroll",this.Ht))}disconnect(){this.Ot?.disconnect(),this.At?.disconnect(),this.Pt=()=>{},window.removeEventListener("scroll",this.Ht,!0),window.removeEventListener("resize",this.Ht),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.Ht),window.visualViewport.removeEventListener("scroll",this.Ht)),this.Ot=null,this.At=null,this.element=null}}class g extends r{constructor(t=null,s=null,i=null){super(),this.options=null,this.Ct=!1,this.Lt=null,this.node=null,this.It=null,this.Ft=null,this.parent=null,this.jt=null,this.Et=null,this.$t=null,this.Vt=null,this.kt=null,this.Rt=null,this.Dt=null,this.zt={_t:36,Bt:8,Ut:!0},this.Nt=i,t&&s&&this.initialize(t,s)}initialize(t,s){if(!this.Nt)throw Error("Popup requires a ModelManager instance.");this.jt=new u(s),this.Et=new c(s),this.$t=new d(s);const i=e.C({Gt:{tag:{node:"div",classList:"seui-popup",style:{maxHeight:s.panelHeight}},L:{yt:{tag:this.jt.node},Wt:{tag:{id:s.qt,node:"div",classList:"seui-options-container",role:"listbox"}},Kt:{tag:this.$t.node},Qt:{tag:this.Et.node}}}},null);this.node=i.view,this.kt=i.tags.Wt,this.parent=e.V(t),this.options=s,this.init(),this.Nt.load(this.kt,{isMultiple:s.multiple},s.virtualScroll?{Yt:this.node,_t:this.zt._t,Bt:this.zt.Bt,Ut:this.zt.Ut}:{});const h=this.Nt.Jt();this.Lt=h.Xt,this.Vt=h.Vt,this.jt.xt(()=>{h.Xt.Zt(!0)}),this.jt.Mt(()=>{h.Xt.Zt(!1)}),this.ts(),this.mount()}async ss(){this.options&&this.$t&&this.jt&&this.Lt&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Nt.es(!0),!1!==e.F(this.options.loadingfield)&&(this.Et.hide(),this.$t.show(this.Lt.ns().hs),this.rs()))}async ls(){this.options&&this.$t&&this.Lt&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Dt=setTimeout(()=>{this.Nt?.es(!1),this.$t?.hide();const t=this.Lt?.ns();this.us(t??void 0),this.rs()},this.options.animationtime))}ts(){this.Lt&&(this.Lt.cs(t=>{this.us(t)}),this.Lt.ds("items",()=>{const t=this.Lt.ns();this.us(t),this.rs()}))}us(t){if(!(this.Lt&&this.Et&&this.jt&&this.kt))return;const s=t??this.Lt.ns();s.isEmpty?(this.Et.show("nodata"),this.kt.classList.add("hide"),this.jt.hide()):s.hs?(this.Et.hide(),this.kt.classList.remove("hide"),this.jt.update()):(this.Et.show("notfound"),this.kt.classList.add("hide"),this.jt.hide())}ps(t,s){this.Lt?.gs(t,s)}fs(t,s){this.Lt?.ds(t,s)}bs(t){this.It=t}open(t=null,s){if(!(this.node&&this.options&&this.jt&&this.parent&&this.It))return;this.Ct||(document.body.appendChild(this.node),this.Ct=!0,this.Ft=new p,this.It.ys(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.jt.update(),s&&this.us();const i=this.ws(),{position:e,top:h,maxHeight:n,vs:o}=this.xs(i);this.It.expand({duration:this.options.animationtime,display:"flex",width:i.width,left:i.left,top:h,maxHeight:n,vs:o,position:e,Ms:()=>{if(!this.Ft||!this.parent)return;this.Ft.Pt=()=>{const t=this.ws();this.Ts(t)},this.Ft.connect(this.parent.container.tags.Os),t?.();const s=this.Vt;s?.resume?.()}})}close(t=null){if(!(this.Ct&&this.options&&this.Ft&&this.It))return;const s=this.Vt;s?.suspend?.(),this.Ft.disconnect(),this.It.collapse({duration:this.options.animationtime,Ms:t??void 0})}rs(){this.Ct&&this.Ft?.ht()}As(t,s){this.node&&(this.Rt=async()=>{const s=t.Hs();if(!s.Ss)return;const i=this.node;if(i.scrollHeight-i.scrollTop-i.clientHeight<100&&!s.Ps&&s.hasMore){const s=await t.Cs();!s.Ls&&s.message&&console.log("Load more:",s.message)}},this.node.addEventListener("scroll",this.Rt))}destroy(){if(!this.is(o.DESTROYED)){if(clearTimeout(this.Dt),this.Dt=null,this.node&&this.Rt&&(this.node.removeEventListener("scroll",this.Rt),this.Rt=null),this.Et.destroy(),this.$t.destroy(),this.jt.destroy(),this.Ft?.disconnect?.(),this.It?.ys?.(null),this.Nt?.es?.(!1),this.Vt?.clear?.(),this.node?.remove?.(),this.node)try{const t=e.T(this.node);this.node.replaceWith(t),t.remove()}catch(t){this.node.remove()}this.node=null,this.kt=null,this.Nt=null,this.jt=null,this.Et=null,this.$t=null,this.parent=null,this.options=null,this.Ct=!1,this.It=null,this.Ft=null,this.Vt=null,this.Lt=null,super.destroy()}}ws(){const t=this.parent.container.tags.Os,s=t.getBoundingClientRect(),i=window.getComputedStyle(t);return{width:s.width,height:s.height,top:s.top,left:s.left,padding:{top:parseFloat(i.paddingTop),right:parseFloat(i.paddingRight),bottom:parseFloat(i.paddingBottom),left:parseFloat(i.paddingLeft)},border:{top:parseFloat(i.borderTopWidth),right:parseFloat(i.borderRightWidth),bottom:parseFloat(i.borderBottomWidth),left:parseFloat(i.borderLeftWidth)}}}xs(t){const s=window.visualViewport,i=e.K(),h=s?.height??window.innerHeight,n=this.It.Is("flex").scrollHeight,o=parseFloat(this.options?.panelHeight??"220")||220,r=parseFloat(this.options?.panelMinHeight??"100")||100,l=h-(t.top+t.height)-3,a=t.top-3;let u="bottom",c=o,d=Math.min(n,c);const p=l-15;(d>=r?p>=r:p>=d)?(u="bottom",c=Math.min(l-15,o)):a>=Math.max(d,r)?(u="top",c=Math.min(a-15,o)):l>=a?(u="bottom",c=Math.max(l-15,r)):(u="top",c=Math.max(a-15,r)),d=Math.min(n,c);const g=s&&i?s.offsetTop:0;return{position:u,top:"bottom"===u?t.top+t.height+3+g:t.top-d-3+g,maxHeight:c,vs:d,Fs:n}}Ts(t){if(!this.options||!this.It)return;const{position:s,top:i,maxHeight:e,vs:h}=this.xs(t);this.It.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:i,maxHeight:e,vs:h,position:s,animate:!0})}}class f extends r{constructor(t=null){super(),this.gt=null,this.node=null,this.js=null,this.Es=null,this.options=null,this.$s=null,this.Vs=null,this.ks=null,this.options=t,t&&this.initialize(t)}initialize(t){this.gt=e.C({Rs:{tag:{node:"div",classList:["seui-searchbox","hide"]},L:{js:{tag:{id:e.m(),node:"input",type:"search",classList:["seui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",A:t.qt,P:"list"}}}}}),this.node=this.gt.view,this.js=this.gt.tags.js;let s=!1;const i=this.gt.tags.js;i.addEventListener("mousedown",t=>{t.stopPropagation()}),i.addEventListener("mouseup",t=>{t.stopPropagation()}),i.addEventListener("keydown",t=>{s=!1,"ArrowDown"===t.key||"Tab"===t.key?(t.preventDefault(),t.stopPropagation(),s=!0,this.$s?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),s=!0,this.$s?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),s=!0,this.Vs?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),s=!0,this.ks?.()),t.stopPropagation()}),i.addEventListener("input",()=>{s||this.Es?.(i.value,!0)}),this.init()}show(){this.node&&this.js&&this.options&&(this.node.classList.remove("hide"),this.js.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.js?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.gt&&(this.gt.tags.js.value="",this.Es?.("",t))}Ds(t){this.js&&(this.js.placeholder=e.G(t))}zs(t){this.js&&this.js.setAttribute("aria-activedescendant",t)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.gt=null,this.node=null,this.js=null,this.Es=null,this.options=null,this.$s=null,this.Vs=null,this.ks=null,super.destroy())}}class m{constructor(t=null){this._s=null,this.Bs=null,this.Us=!1,t&&this.ys(t)}ys(t){if("string"==typeof t){const s=document.querySelector(t);return void(s instanceof HTMLElement&&(this.element=s))}this.element=t}cancel(){return this._s&&(clearTimeout(this._s),this._s=null),this.Bs&&(clearTimeout(this.Bs),this.Bs=null),this.Us=!1,this}Is(t="flex"){if(!this.element)return{width:0,height:0,scrollHeight:0};const s={display:this.element.style.display,visibility:this.element.style.visibility,position:this.element.style.position,height:this.element.style.height,width:this.element.style.width};Object.assign(this.element.style,{display:t,visibility:"hidden",position:"fixed",height:"fit-content",width:"fit-content"});const i=window.getComputedStyle(this.element),e=parseFloat(i.borderTopWidth),h=parseFloat(i.borderBottomWidth),n=this.element.scrollHeight+e+h,o=this.element.getBoundingClientRect(),r={width:o.width,height:o.height+e+h,scrollHeight:n};return Object.assign(this.element.style,s),r}expand(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,display:i="flex",width:e,left:h,top:n,maxHeight:o,vs:r,position:l="bottom",Ms:a}=t;return Object.assign(this.element.style,{display:i,width:e+"px",left:h+"px",top:("bottom"===l?n:n+r)+"px",maxHeight:o+"px",height:"0px",opacity:"0",overflow:"hidden",transition:"none"}),this.element.classList.toggle("position-top","top"===l),this.element.classList.toggle("position-bottom","bottom"===l),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`top ${s}ms, height ${s}ms, opacity ${s}ms`,top:n+"px",height:r+"px",opacity:"1",overflow:r>=o?"auto":"hidden"}),this._s=setTimeout(()=>{this.element.style.transition="none",this.Us=!1,a?.()},s)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,Ms:i}=t,e=this.element.offsetHeight,h=this.element.offsetTop,n=this.element.classList.contains("position-top")?"top":"bottom",o=this.element.scrollHeight-this.element.offsetHeight>0,r="top"===n?h+e:h;return requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`height ${s}ms, top ${s}ms, opacity ${s}ms`,height:"0px",top:r+"px",opacity:"0",overflow:o?"auto":"hidden"}),this._s=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Us=!1,i?.()},s)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,display:i="block",Ms:e}=t;Object.assign(this.element.style,{transition:"none",display:i,width:"fit-content"});const h=this.Is(i).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${s}ms`,width:h+"px",overflow:"hidden"})}),this._s=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Us=!1,e?.()},s),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Us=!0;const{duration:s=200,Ms:i}=t,e=this.Is().width;return Object.assign(this.element.style,{transition:"none",width:e+"px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${s}ms`,width:"0px",overflow:"hidden"})}),this._s=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Us=!1,i?.()},s),this}resize(t){if(!this.element)return this;this.cancel();const{duration:s=200,width:i,left:e,top:h,maxHeight:n,vs:o,position:r="bottom",animate:l=!0,Ms:a}=t,u=(this.element.classList.contains("position-top")?"top":"bottom")!==r,c=this.element.scrollHeight>n;return this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),u&&(this.element.style.transition=`top ${s}ms ease-out, height ${s}ms ease-out, max-height ${s}ms ease-out;`),requestAnimationFrame(()=>{const t={width:i+"px",left:e+"px",top:h+"px",maxHeight:n+"px",height:o+"px",overflowY:c?"auto":"hidden"},r=Math.abs(this.element.offsetHeight-o);l&&(u||r>5)?t.transition=`height ${s}ms, top ${s}ms`:this.Bs=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},s),Object.assign(this.element.style,t),l&&(u||r>1)?this.Bs=setTimeout(()=>{this.element.style.transition=null,u&&delete this.element.style.transition,a?.()},s):(u&&delete this.element.style.transition,a?.())}),this}get Ns(){return this.Us}}class b extends r{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,s=null,i=null){super(),this.targetElement=null,this.view=null,this.position=-1,this.Tt=!1,this.Gs=!1,this.options=t,this.targetElement=s,this.view=i,this.init()}Ws(t){this.targetElement=t,this.update()}destroy(){this.is(o.DESTROYED)||(this.targetElement=null,this.view?.destroy(),this.view=null,this.Gs=!0,super.destroy())}}class y extends b{constructor(t,s){super(t,s??null,null),this.label="",this.items=[],this.collapsed=!1,this.qs=[],this.label=this.targetElement.label,this.collapsed=e.F(this.targetElement.dataset?.collapsed)}init(){super.init(),this.mount()}get value(){return this.items.map(t=>t.value)}get Ks(){return this.items.filter(t=>t.selected)}get Qs(){return this.items.filter(t=>t.visible)}get Ys(){return this.Qs.length>0}Ws(t){this.label=t.label,this.view?.Js(this.label),this.update()}update(){this.view&&(this.view.Js(this.label),this.view.Xs(this.collapsed)),super.update()}destroy(){this.is(o.DESTROYED)||(this.items.forEach(t=>{t.destroy()}),this.items=[],super.destroy())}Zs(t){this.qs.push(t)}ti(){this.collapsed=!this.collapsed,this.view?.Xs(this.collapsed),h.et([this,this.collapsed],...this.qs)}si(t){this.items.push(t),t.group=this}removeItem(t){const s=this.items.indexOf(t);s>-1&&(this.items.splice(s,1),t.group=null)}ii(){this.view?.ii()}}class w extends b{constructor(t,s=null,i=null){super(t,s,i),this.ei=[],this.hi=[],this.ni=[],this.oi=!0,this.ri=!1,this.group=null}init(){this.li=e.W(this.textContent.toLowerCase()),super.init(),this.mount()}get ai(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ai}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.ui=t,h.et([this,t],...this.ei)}get visible(){return this.oi}set visible(t){if(this.oi===t)return;this.oi=t;const s=this.view?.ci?.();s&&s.classList.toggle("hide",!t),h.et([this,t],...this.ni)}get ui(){return this.selected}set ui(t){const s=this.view?.view?.tags?.di,i=this.view?.ci?.();s&&(s.checked=t),i&&this.targetElement&&(i.classList.toggle("checked",!!t),i.setAttribute("aria-selected",t?"true":"false"),this.targetElement.toggleAttribute("selected",!!t)),this.targetElement&&(this.targetElement.selected=t),h.et([this,t],...this.hi)}get text(){const t=e.N(this.dataset?.mask??this.targetElement?.text??"");return this.options.allowHtml?t:e.G(t)}get textContent(){return this.options.allowHtml?e.G(this.text).trim():this.text.trim()}get dataset(){return this.targetElement?.dataset??{}}get pi(){return this.ri}set pi(t){const s=!!t,i=this.view?.ci?.();this.ri!==s&&(this.ri=s),i&&i.classList.toggle("highlight",s)}gi(t){this.ei.push(t)}fi(t){this.hi.push(t)}cs(t){this.ni.push(t)}update(){if(this.li=e.W(this.textContent.toLowerCase()),!this.view)return void super.update();const t=this.view.view.tags.mi;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const s=this.view.view.tags.bi;s&&this.hasImage&&(s.src!=this.ai&&(s.src=this.ai),s.alt!=this.text&&(s.alt=this.text)),this.targetElement&&(this.ui=this.targetElement.selected),super.update()}destroy(){this.is(o.DESTROYED)||(this.ei=[],this.hi=[],this.ni=[],this.group=null,this.li=null,super.destroy())}}class v extends r{constructor(t){super(),this.yi=[],this.wi=null,this.xi=null,this.options=null,this.Mi=0,this.options=t,this.init()}Ti(t){this.Oi=t}Ai(t){this.Hi=t}Si(t){this.is(o.INITIALIZED)&&this.mount(),this.yi=[];let s=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)s=new y(this.options,t),this.yi.push(s);else if("OPTION"===t.tagName){const i=new w(this.options,t),e=t.__parentGroup;e&&s&&e===s.targetElement?(s.si(i),i.group=s):(this.yi.push(i),s=null)}}),this.yi}async replace(t){this.Si(t),this.wi&&await this.wi.Pi(this.yi),this.refresh(!1)}notify(){this.wi&&this.refresh(!1)}load(t,s={},i={}){this.wi=new this.Oi(this.yi),Object.assign(this.wi,s),this.xi=new this.Hi(t),Object.assign(this.xi,i),this.xi.Ci(this.wi)}Li(t){const s=this.yi,i=[],e=new Map,h=new Map;s.forEach(t=>{t instanceof y?e.set(t.label,t):t instanceof w&&h.set(`${t.value}::${t.textContent}`,t)});let n=null,o=0;t.forEach(t=>{if("OPTGROUP"===t.tagName){const s=t,h=e.get(s.label);h?(h.label!==s.label&&h.Ws(s),h.position=o,h.items=[],n=h,i.push(h),e.delete(s.label)):(n=new y(this.options,s),n.position=o,i.push(n)),o++}else if("OPTION"===t.tagName){const s=t,e=`${s.value}::${s.text}`,r=h.get(e);if(r)r.Ws(s),r.position=o,s.__parentGroup&&n?(n.si(r),r.group=n):(r.group=null,i.push(r)),h.delete(e);else{const t=new w(this.options,s);t.position=o,s.__parentGroup&&n?(n.si(t),t.group=n):i.push(t)}o++}});let r=!0;0==this.Mi&&(r=!1),this.Mi=o,e.forEach(t=>{r=!1,t.destroy()}),h.forEach(t=>{r=!1,t.destroy()}),this.yi=i,this.wi&&this.wi.Ii(this.yi),this.refresh(r)}es(t){this.wi&&(this.wi.Fi=t)}refresh(t){this.xi&&(this.xi.refresh(t),this.update())}destroy(){this.is(o.DESTROYED)||(this.wi.destroy(),this.xi.destroy(),this.yi=[],this.Oi=null,this.wi=null,this.Hi=null,this.xi=null,this.options=null,this.Mi=0,super.destroy())}Jt(){return{ji:this.yi,Xt:this.wi,Vt:this.xi}}Ei(t){return this.wi?.$i(t)}Vi(t){return this.wi?.ki(t)}}class x extends r{constructor(t=null){super(),this.Ri=null,this.Xt=null,this.Ri=t,this.init()}Ci(t){this.Xt=t,t.gs("items",()=>{this.clear()}),t.ds("items",()=>{this.Di()}),t.mount(),this.mount(),this.Di()}clear(){this.Ri&&this.Ri.replaceChildren()}Di(){this.Xt&&this.Ri&&(this.Xt.zi(this.Ri),this.update())}refresh(t){this.Di()}destroy(){this.is(o.DESTROYED)||(this.Ri=null,this.Xt=null,super.destroy())}}class M extends r{constructor(t=null){super(),this.gt=null,this.node=null,this.options=null,this._i=null,this.Bi=null,this.Nt=null,this.Ui=[],t&&this.initialize(t)}initialize(t){this.options=t,this.init()}init(){this.state===o.NEW&&(this.gt=e.C({Ni:{tag:{node:"div",classList:["seui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.gt.view,super.init())}Gi(t){this._i=t,this.Bi=t.parentElement,this.Wi(),this.mount()}mount(){this.is(o.INITIALIZED)&&super.mount()}Wi(){this.Bi&&this.node&&this._i&&this.options&&this.Bi.insertBefore(this.node,"top"===this.options.accessoryStyle?this._i:this._i.nextSibling)}qi(t){this.Nt=t}Ki(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?t.forEach(t=>{e.C({Qi:{tag:{node:"div",classList:["accessory-item"]},L:{Yi:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:async s=>{s.preventDefault(),await(this.Nt?.Ei?.("select")),t.selected=!1}}},Ji:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)}):t=[],this.Ui=t,this.Xi(),this.update(),h.ht(window,"resize"))}update(){this.state===o.MOUNTED&&super.update()}Xi(){this.options?.accessoryVisible&&this.Ui.length>0&&this.options.multiple?this.show():this.hide()}show(){this.node?.classList.remove("hide")}hide(){this.node?.classList.add("hide")}destroy(){this.state!==o.DESTROYED&&(this.node?.remove(),this.gt=null,this.node=null,this.options=null,this._i=null,this.Bi=null,this.Nt=null,this.Ui=[],super.destroy())}}class T extends r{constructor(t,s,i){super(),this.Zi=null,this.te=null,this.se=null,this.ie=null,this.ee={currentPage:0,totalPages:1,hasMore:!1,Ps:!1,he:"",Ss:!1},this.initialize(t,s,i)}initialize(t,s,i){this.select=t,this.Nt=s,this.ie=i,this.init()}ne(){return!!this.Zi}async oe(t){if(!this.Zi)return{Ls:!1,items:[],message:"Ajax not configured"};const s=Array.isArray(t)?t:[t];if(0===s.length)return{Ls:!0,items:[]};try{const t=this.Zi;let i,e;if(i="function"==typeof t.re?t.re(s):{values:s.join(","),le:"1",..."function"==typeof t.data?t.data.bind(this.ie.ae.find(this.ie.container.targetElement))("",0):t.data??{}},"POST"===(t.method??"GET")){const s=new URLSearchParams;Object.keys(i).forEach(t=>s.append(t,i[t]+"")),e=await fetch(t.url,{method:"POST",body:s,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{const s=""+new URLSearchParams(i);e=await fetch(`${t.url}?${s}`)}if(!e.ok)throw Error("HTTP error! status: "+e.status);const h=await e.json(),n=this.ue(h);return this.update(),{Ls:!0,items:n.items}}catch(i){return console.error("Load by values error:",i),{Ls:!1,message:i?.message,items:[]}}}ce(t){const s=Array.from(this.select.options).map(t=>t.value);return{de:t.filter(t=>s.includes(t)),pe:t.filter(t=>!s.includes(t))}}ge(t){this.Zi=t}setPopup(t){this.se=t}Hs(){return{...this.ee}}fe(){this.ee={currentPage:0,totalPages:1,hasMore:!1,Ps:!1,he:"",Ss:this.ee.Ss}}clear(){this.ee.he="";const{ji:t}=this.Nt.Jt(),s=[];for(const i of t)i instanceof w?s.push(i):i instanceof y&&Array.isArray(i.items)&&s.push(...i.items);s.forEach(t=>{t.visible=!0})}async search(t,s=!1){return this.Zi?this.me(t,s):this.be(t)}async Cs(){return this.Zi?this.ee.Ps?{Ls:!1,message:"Already loading"}:this.ee.Ss?this.ee.hasMore?(this.ee.currentPage++,this.me(this.ee.he,!0)):{Ls:!1,message:"No more data"}:{Ls:!1,message:"Pagination not enabled"}:{Ls:!1,message:"Ajax not enabled"}}async be(t){this.ye(t)&&(this.ee.he=t);const s=((t??"")+"").toLowerCase(),i=e.W(s),{ji:h}=this.Nt.Jt(),n=[];for(const e of h)e instanceof w?n.push(e):e instanceof y&&Array.isArray(e.items)&&n.push(...e.items);let o=!1;return n.forEach(t=>{const e=""===s||t.li.includes(i);t.visible=e,e&&(o=!0)}),this.update(),{Ls:!0,we:o,isEmpty:0===n.length}}ye(t){return t!==this.ee.he}async me(t,s=!1){const i=this.Zi;this.ye(t)&&(this.fe(),this.ee.he=t,s=!1),this.ee.Ps=!0,this.se?.ss(),this.te?.abort(),this.te=new AbortController;const e=this.ee.currentPage,h=Array.from(this.select.selectedOptions).map(t=>t.value).join(",");let n;if("function"==typeof i.data){const s=this.ie?.ae?.find(this.ie?.container?.targetElement);n=i.data.call(s,t,e),n&&void 0===n.selectedValue&&(n.selectedValue=h)}else n={search:t,page:e,selectedValue:h,...i.data??{}};try{let t;if("POST"===(i.method??"GET")){const s=new URLSearchParams;Object.keys(n).forEach(t=>s.append(t,n[t]+"")),t=await fetch(i.url,{method:"POST",body:s,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.te.signal})}else{const s=""+new URLSearchParams(n);t=await fetch(`${i.url}?${s}`,{signal:this.te.signal})}const e=await t.json(),h=this.ue(e);return h.ve?(this.ee.Ss=!0,this.ee.currentPage=h.page,this.ee.totalPages=h.totalPages,this.ee.hasMore=h.hasMore):this.ee.Ss=!1,this.xe(h.items,!!i.keepSelected,s),this.ee.Ps=!1,this.se?.ls(),this.update(),{Ls:!0,we:h.items.length>0,isEmpty:0===h.items.length,ve:h.ve,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.ee.Ps=!1,this.se?.ls(),"AbortError"===o?.name?{Ls:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Ls:!1,message:o?.message})}}ue(t){let s=[],i=!1,e=0,h=1,n=!1;return t.object&&Array.isArray(t.object)?(s=t.object,void 0!==t.page&&(i=!0,e=parseInt(t.page??0,10),h=parseInt(t.totalPages??t.total_page??1,10),n=e<h-1)):t.data&&Array.isArray(t.data)?(s=t.data,void 0!==t.page&&(i=!0,e=parseInt(t.page??0,10),h=parseInt(t.totalPages??t.total_page??1,10),n=t.hasMore??e<h-1)):Array.isArray(t)?s=t:t.items&&Array.isArray(t.items)&&(s=t.items,t.pagination&&(i=!0,e=parseInt(t.pagination.page??0,10),h=parseInt(t.pagination.totalPages??t.pagination.total_page??1,10),n=t.pagination.hasMore??e<h-1)),{items:s.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.Me||t.group||t.label)return{type:"optgroup",label:t.label??t.name??t.title??"",data:t.data??{},options:(t.options??t.items??[]).map(t=>({value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:t.data??(t.imgsrc?{imgsrc:t.imgsrc}:{})}))};const s=t.data??{};return t?.imgsrc&&(s.imgsrc=t.imgsrc),{type:"option",value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:s}}),ve:i,page:e,totalPages:h,hasMore:n}}xe(t,s,i=!1){const e=this.select;let h=[];s&&(h=Array.from(e.selectedOptions).map(t=>t.value)),i||(e.innerHTML=""),t.forEach(t=>{if("option"!==t.type&&t.type||""!==t.value||""!==t.text)if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)e.appendChild(t);else if("optgroup"===t.type){const i=document.createElement("optgroup");i.label=t.label,t.data&&Object.keys(t.data).forEach(s=>{i.dataset[s]=t.data[s]+""}),Array.isArray(t.options)&&t.options.forEach(t=>{const e=document.createElement("option");e.value=t.value,e.text=t.text,t.data&&Object.keys(t.data).forEach(s=>{e.dataset[s]=t.data[s]+""}),(t.selected||s&&h.includes(e.value))&&(e.selected=!0),i.appendChild(e)}),e.appendChild(i)}else{const i=document.createElement("option");i.value=t.value,i.text=t.text,t.data&&Object.keys(t.data).forEach(s=>{i.dataset[s]=t.data[s]+""}),(t.selected||s&&h.includes(i.value))&&(i.selected=!0),e.appendChild(i)}})}destroy(){this.is(o.DESTROYED)||(this.select=null,this.Nt=null,this.Zi=null,this.te=null,this.se=null,this.ie=null,super.destroy())}}class O{constructor(t){this.Te=null,this.Oe=50,this.select=t,this.Ae=new MutationObserver(()=>{clearTimeout(this.Te),this.Te=setTimeout(()=>{this.He()},this.Oe)})}He(){this.Pt(this.select)}connect(){this.Ae.observe(this.select,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.Te&&clearTimeout(this.Te),this.Te=null,this.Ae.disconnect()}}class A{constructor(t){this.Te=null,this.element=t,this.Ae=new MutationObserver(t=>{let s=!1;for(const i of t)if("attributes"===i.type&&i.attributeName?.startsWith("data-")){s=!0;break}s&&(this.Te&&clearTimeout(this.Te),this.Te=setTimeout(()=>{this.Pt({...this.element.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.element.dataset})})}connect(){this.Ae.observe(this.element,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.Te&&clearTimeout(this.Te),this.Te=null,this.Ae.disconnect()}}class H extends r{constructor(t=[]){super(),this.items=[],this.Se=e.m(12),this.Fi=!1,this.items=t,this.init()}Pe(t,s,i){const e=s;t.Tt?e?.update?.():e?.mount?.()}gs(t,s){e.J.on(`${t}ing_${this.Se}`,s,{tt:0})}ds(t,s){e.J.on(`${t}_${this.Se}`,s,{tt:0})}ki(t,...s){return e.J.run(`${t}_${this.Se}`,...s)}$i(t,...s){return e.J.run(`${t}ing_${this.Se}`,...s)}Ce(t,s){return null}Le(){return this.items.length}async Ie(t){await this.$i("items",t),this.items=t,await this.ki("items",t),this.update()}async Pi(t){await this.Ie(t)}zi(t){for(let s=0;s<this.Le();s++){const i=this.items[s];let e=i.view;i.Tt||(e=this.Ce(t,i),i.view=e),this.Pe(i,e,s),i.Tt=!0}}Ii(t){}destroy(){this.is(o.DESTROYED)||(this.Vt=null,this.items.forEach(t=>{t?.destroy?.()}),this.items=[])}}class S extends r{constructor(t){super(),this.parent=null,this.view=null,this.parent=t,this.init()}ci(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}destroy(){this.is(o.DESTROYED)||(this.ci()?.remove?.(),this.parent=null,this.view=null,super.destroy())}}class P extends S{constructor(){super(...arguments),this.view=null}mount(){const t=e.m(7);this.view=e.C({Fe:{tag:{node:"div",classList:["seui-group"],role:"group",O:`seui-${t}-header`,id:`seui-${t}-group`},L:{je:{tag:{node:"div",classList:["seui-group-header"],role:"presentation",id:`seui-${t}-header`}},Ee:{tag:{node:"div",classList:["seui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view),super.mount()}update(){this.Js(),super.update()}Js(t=null){this.view&&null!==t&&(this.view.tags.je.textContent=t)}$e(){if(!this.view)throw Error("GroupView has not been rendered.");return this.view.tags.Ee}ii(){if(!this.view)return;const t=Array.from(this.view.tags.Ee.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",0===t.length)}Xs(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.je.setAttribute("aria-expanded",t?"false":"true"))}}class C extends S{constructor(t){super(t),this.view=null,this.config=null,this.Ve=null,this.ke=!1,this.initialize()}initialize(){const t=this;this.config={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.Ve=new Proxy(this.config,{set(s,i,e){if("string"!=typeof i)return!0;const h=i,n=s[h];return n!==e&&(s[h]=e,t.ke&&t.Re(h,e,n)),!0}}),this.init()}get isMultiple(){return this.config.isMultiple}set isMultiple(t){this.Ve.isMultiple=!!t}get hasImage(){return this.config.hasImage}set hasImage(t){this.Ve.hasImage=!!t}get De(){return this.Ve}set De(t){if(!t||!this.Ve||!this.config)return;const s={};void 0!==t.imageWidth&&t.imageWidth!==this.config.imageWidth&&(s.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.config.imageHeight&&(s.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.config.imageBorderRadius&&(s.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.config.imagePosition&&(s.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.config.labelValign&&(s.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.config.labelHalign&&(s.labelHalign=t.labelHalign),Object.keys(s).length>0&&Object.assign(this.Ve,s)}mount(){const t=["seui-option-view"],s=e.m(7),i="option_"+s;this.config.isMultiple&&t.push("multiple"),this.config.hasImage&&t.push("has-image","image-"+this.config.imagePosition);const h={di:{tag:{node:"input",type:this.config.isMultiple?"checkbox":"radio",classList:"allow-choice",id:i}},...this.config.hasImage&&{bi:{tag:{node:"img",classList:"option-image",style:{width:this.config.imageWidth,height:this.config.imageHeight,borderRadius:this.config.imageBorderRadius}}}},ze:{tag:{node:"label",htmlFor:i,classList:["align-vertical-"+this.config.labelValign,"align-horizontal-"+this.config.labelHalign]},L:{mi:{tag:{node:"div"}}}}};this.view=e.C({_e:{tag:{node:"div",id:`seui-${s}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},L:h}}),this.parent.appendChild(this.view.view),this.ke=!0,super.mount()}Re(t,s,i){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.di,o=e.tags?.ze;switch(t){case"isMultiple":{const t=!!s;h.classList.toggle("multiple",t),n&&n.type!==(t?"checkbox":"radio")&&(n.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!s;if(h.classList.toggle("has-image",t),t)h.classList.add("image-"+this.config.imagePosition),this.Be();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.bi;t?.remove(),e.tags.bi=null}break}case"imagePosition":this.config.hasImage&&(h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim(),h.classList.add("image-"+s));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const i=e.tags?.bi;i&&(i.style["imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius"]=s+"");break}case"labelValign":case"labelHalign":o&&(o.className=`align-vertical-${this.config.labelValign} align-horizontal-`+this.config.labelHalign)}}Be(){const t=this.view;if(!t||!t.view)return;if(t.tags?.bi)return;const s=t.view,i=t.tags?.ze,e=document.createElement("img");e.className="option-image",e.style.width=this.config.imageWidth,e.style.height=this.config.imageHeight,e.style.borderRadius=this.config.imageBorderRadius,i?.parentElement?s.insertBefore(e,i):s.appendChild(e),t.tags.bi=e}}class L extends H{constructor(t=[]){super(t),this.isMultiple=!1,this.Ue=[],this.Ne=-1,this.Ge=null,this.groups=[],this.We=[],this.qe()}init(){e.J.on("sche_vis_"+this.Se,()=>{const t=this.We.filter(t=>t.visible).length,s=this.We.length;this.Ue.forEach(i=>{i({Ke:t,Qe:s,hs:t>0,isEmpty:0===s})}),e.J.run("sche_vis_proxy_"+this.Se)},{tt:10}),super.init(),this.mount()}qe(){this.We=[],this.groups=[],this.items.forEach(t=>{t instanceof y?(this.groups.push(t),this.We.push(...t.items)):t instanceof w&&this.We.push(t)})}Ce(t,s){return s instanceof y?new P(t):new C(t)}Pe(t,s,i){t.position=i,t instanceof y?this.Ye(t,s,i):t instanceof w&&this.Je(t,s,i),t.Tt=!0}Ye(t,s,i){super.Pe(t,s,i),t.view=s;const e=s.view.tags.je;e.textContent=t.label,t.Tt||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.ti()}),t.Zs((t,s,i)=>{s.items.forEach(t=>{const s=t.view?.ci?.();s&&(s.style.display=i?"none":"")}),this.Xe(s,i)}));const h=s.$e();t.items.forEach((t,s)=>{let i=t.view;t.Tt&&i||(i=new C(h)),this.Je(t,i,s),t.Tt=!0}),s.Xs(t.collapsed),s.ii()}Je(t,s,i){if(s.isMultiple=this.isMultiple,s.hasImage=t.hasImage,s.De={imageWidth:t.options.imageWidth,imageHeight:t.options.imageHeight,imageBorderRadius:t.options.imageBorderRadius,imagePosition:t.options.imagePosition,labelValign:t.options.labelValign,labelHalign:t.options.labelHalign},t.Tt||super.Pe(t,s,i),t.view=s,t.hasImage){const i=s.view.tags.bi;i&&(i.src!==t.ai&&(i.src=t.ai),i.alt!==t.text&&(i.alt=t.text))}s.view.tags.mi.innerHTML=t.text,t.Tt||(s.view.tags._e.addEventListener("click",async s=>{s.stopPropagation(),s.preventDefault(),this.Fi||(this.isMultiple?(await this.$i("select"),t.selected=!t.selected):!0!==t.selected&&(await this.$i("select"),this.Ge&&(this.Ge.selected=!1),t.selected=!0))}),s.view.tags._e.title=t.textContent,s.view.tags._e.addEventListener("mouseenter",()=>{this.Fi||this.Ze(this.We.indexOf(t),!1)}),t.gi(()=>{this.ki("selected")}),t.fi((s,i,e)=>{e&&(this.Ge=t),this.ki("selected_internal")}),t.cs((t,s)=>{s.group?.ii(),this.th()})),t.selected&&(this.Ge=t,t.ui=!0)}async Ie(t){await this.$i("items",t),this.items=t,this.qe(),await this.ki("items",t),this.update()}async Pi(t){await this.Ie(t)}Ii(t){this.items=t,this.qe(),this.update()}destroy(){this.is(o.DESTROYED)||(e.J.clear("sche_vis_"+this.Se),this.groups.forEach(t=>{t.destroy()}),this.Ue=[],this.Ne=-1,this.Ge=null,this.groups=[],this.We=[],super.destroy())}sh(){return this.We.filter(t=>t.selected)}ih(){return this.We.find(t=>t.selected)}Zt(t){this.isMultiple&&this.We.forEach(s=>{s.selected=t})}cs(t){this.Ue.push(t)}th(){e.J.run("sche_vis_"+this.Se)}ns(){const t=this.We.filter(t=>t.visible).length,s=this.We.length;return{Ke:t,Qe:s,hs:t>0,isEmpty:0===s}}eh(){this.Ze(0)}navigate(t,s=!0){const i=this.We.filter(t=>t.visible);if(0===i.length)return;let e=i.findIndex(t=>t===this.We[this.Ne]);-1===e&&(e=-1);let h=e+t;h>=i.length&&(h=0),h<0&&(h=i.length-1);const n=this.We.indexOf(i[h]);this.Ze(n,s)}hh(){if(this.Ne>-1&&this.We[this.Ne]){const t=this.We[this.Ne];if(t.visible){const s=t.view?.ci?.();s&&s.click()}}}Ze(t,s=!0){let i=0;if("number"==typeof t)i=t;else if(t instanceof w){const s=this.We.indexOf(t);i=s>-1?s:0}else i=0;this.Ne>-1&&this.We[this.Ne]&&(this.We[this.Ne].pi=!1);for(let e=i;e<this.We.length;e++){const t=this.We[e];if(t?.visible){if(t.pi=!0,this.Ne=e,s){const s=t.view?.ci?.();s?s.scrollIntoView({block:"center",behavior:"smooth"}):this.Vt?.nh?.(e,{scrollIntoView:!0})}return void this.oh(e,t.view?.ci?.()?.id)}}}oh(t,s){}Xe(t,s){}}class I extends r{constructor(t=0){super(),this.rh=[],this.ah=0,this.initialize(t)}initialize(t){this.init(),this.reset(t)}reset(t){this.ah=t,this.rh=Array(t+1).fill(0)}add(t,s){for(let i=t;i<=this.ah;i+=i&-i)this.rh[i]+=s}uh(t){let s=0;for(let i=t;i>0;i-=i&-i)s+=this.rh[i];return s}dh(t,s){return s<t?0:this.uh(s)-this.uh(t-1)}ph(t){this.reset(t.length),t.forEach((t,s)=>this.add(s+1,t))}gh(t){let s=0,i=1;for(;i<<1<=this.ah;)i<<=1;let e=0;for(let h=i;0!==h;h>>=1){const i=s+h;i<=this.ah&&e+this.rh[i]<=t&&(s=i,e+=this.rh[i])}return s}}class F extends x{constructor(t=null){super(t),this.fh={Yt:void 0,_t:36,Bt:8,Ut:!0,mh:!0},this.bh=[],this.yh=new I(0),this.wh=new Map,this.xh=!1,this.start=0,this.end=-1,this.Mh=null,this.Th=null,this.updating=!1,this.Oh=!1,this.Ah=0,this.Hh=!1,this.Sh=!1,this.Ph=0,this.Ch=0,this.Lh=0,this.Ih=0}configure(t){this.fh={...this.fh,...t}}Ci(t){if(this.Xt&&this.dispose(),super.Ci(t),t.Vt=this,!this.Ri)return;this.Ri.replaceChildren();const s=e.C({Fh:{tag:{node:"div",classList:"seui-virtual-pad-top"}},jh:{tag:{node:"div",classList:"seui-virtual-items"}},Eh:{tag:{node:"div",classList:"seui-virtual-pad-bottom"}}},this.Ri);if(this.Fh=s.Fh,this.jh=s.jh,this.Eh=s.Eh,this.Yt=this.fh.Yt??this.Ri.closest(".seui-popup")??this.Ri.parentElement,!this.Yt)throw Error("VirtualRecyclerView: scrollEl not found");this.$h=this.Vh.bind(this),this.Yt.addEventListener("scroll",this.$h,{passive:!0}),this.refresh(!1),this.kh(),t?.cs?.(()=>this.Rh())}suspend(){this.Hh=!0,this.Dh(),this.Yt&&this.$h&&this.Yt.removeEventListener("scroll",this.$h),this.zh&&(this.zh.disconnect(),this.Sh=!0)}resume(){this.Hh=!1,this.Yt&&this.$h&&this.Yt.addEventListener("scroll",this.$h,{passive:!0}),this.Sh&&(this.kh(),this.Sh=!1),this._h()}refresh(t){if(!this.Xt||!this.Ri)return;t||this.Rh();const s=this.Xt.Le();if(this.Ah=s,0===s)return this.Bh(),void this.update();this.bh.length=s,this.xh||(this.Uh(),this.xh=!0),this.Nh(s),this._h(),this.update()}nh(t,s){this.Gh(t,t),s?.scrollIntoView&&this.Wh(t)}Wh(t){if((this.Xt?.Le?.()??0)<=0)return;const s=this.qh(t),i=this.Kh()+s,e=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight);this.Yt.scrollTop=Math.min(Math.max(0,i),e)}dispose(){this.Dh(),this.Yt&&this.$h&&this.Yt.removeEventListener("scroll",this.$h),this.zh?.disconnect(),this.wh.forEach(t=>t.remove()),this.wh.clear()}destroy(){this.is(o.DESTROYED)||(this.Bh(),this.dispose(),this.Fh.remove(),this.jh.remove(),this.Eh.remove(),this.Fh=null,this.jh=null,this.Eh=null,super.destroy())}Rh(){if(!this.Xt)return;const t=this.Xt.Le();t<=0||(this.suspend(),this.Bh(),this.Qh(),this.Yh(t),this.Nh(t),this.start=0,this.end=-1,this.resume())}Dh(){null!=this.Mh&&(cancelAnimationFrame(this.Mh),this.Mh=null),null!=this.Th&&(cancelAnimationFrame(this.Th),this.Th=null)}Bh(){this.wh.forEach(t=>t.remove()),this.wh.clear(),this.bh=[],this.yh.reset(0),this.Fh.style.height="0px",this.Eh.style.height="0px",this.xh=!1,this.Lh=0,this.Ih=0}Uh(){this.Jh(0);const t=this.wh.get(0);if(!t)return;const s=this.Xh(t);if(isNaN(s)||(this.fh._t=s),!this.fh.Ut){t.remove(),this.wh.delete(0);const s=this.Xt.items[0];s&&(s.Tt=!1,s.view=null)}}Zh(t){const s=this.Xt?.items?.[t];return s?.visible??!0}tn(t,s){for(let i=Math.max(0,t);i<s;i++)if(this.Zh(i))return i;return-1}Yh(t){this.Lh=0,this.Ih=0;for(let s=0;s<t;s++){if(!this.Zh(s))continue;const t=this.bh[s];null!=t&&(this.Lh+=t,this.Ih++)}}Kh(){const t=this.Ri.getBoundingClientRect(),s=this.Yt.getBoundingClientRect();return Math.max(0,t.top-s.top+this.Yt.scrollTop)}sn(){const t=performance.now();if(t-this.Ph<16)return this.Ch;const s=this.Yt.querySelector(".seui-option-handle:not(.hide)");return this.Ch=s?.offsetHeight??0,this.Ph=t,this.Ch}_h(){null!=this.Mh||this.Hh||(this.Mh=requestAnimationFrame(()=>{this.Mh=null,this.en()}))}Xh(t){const s=t.getBoundingClientRect(),i=getComputedStyle(t);return Math.max(1,s.height+(parseFloat(i.marginTop)||0)+(parseFloat(i.marginBottom)||0))}hn(){return this.fh.mh&&this.Ih>0?Math.max(1,this.Lh/this.Ih):this.fh._t}Nh(t){const s=this.hn(),i=Array.from({length:t},(t,i)=>this.Zh(i)?this.bh[i]??s:0);this.yh.ph(i)}nn(t,s){if(!this.Zh(t))return!1;const i=this.hn(),e=this.bh[t]??i;if(Math.abs(s-e)<=F.rn)return!1;const h=this.bh[t];return null==h?(this.Lh+=s,this.Ih++):this.Lh+=s-h,this.bh[t]=s,this.yh.add(t+1,s-e),!0}ln(t,s){const i=this.yh.gh(Math.max(0,t)),e=Math.min(s-1,i),h=this.tn(e,s);return-1===h?Math.max(0,e):h}an(t,s){s.setAttribute(F.un,t+"");const i=this.wh.get(t-1);if(i?.parentElement===this.jh)return void i.after(s);const e=this.wh.get(t+1);if(e?.parentElement===this.jh)return void this.jh.insertBefore(s,e);const h=Array.from(this.jh.children);for(const n of h){const i=n.getAttribute(F.un);if(i&&+i>t)return void this.jh.insertBefore(s,n)}this.jh.appendChild(s)}cn(t,s){if(s.parentElement!==this.jh)return void this.an(t,s);s.setAttribute(F.un,t+"");const i=s.previousElementSibling,e=s.nextElementSibling;(i&&+i.getAttribute(F.un)>t||e&&+e.getAttribute(F.un)<t)&&(s.remove(),this.an(t,s))}kh(){this.zh||(this.zh=new ResizeObserver(()=>{this.Oh||this.Hh||!this.Xt||null!=this.Th||(this.Th=requestAnimationFrame(()=>{this.Th=null,this.dn()}))}),this.zh.observe(this.jh))}dn(){if(!this.Xt)return;const t=this.Xt.Le();if(t<=0)return;let s=!1;for(let i=this.start;i<=this.end;i++){if(!this.Zh(i))continue;const t=this.Xt.items[i],e=t?.view?.ci?.();if(!e)continue;const h=this.Xh(e);this.nn(i,h)&&(s=!0)}s&&(this.fh.mh&&this.Nh(t),this._h())}Vh(){this._h()}en(){if(!this.updating&&!this.Hh){this.updating=!0;try{if(!this.Xt)return;const t=this.Xt.Le();if(t<=0)return;this.Ah!==t&&(this.Ah=t,this.bh.length=t,this.Nh(t));const s=this.Kh(),i=Math.max(0,this.Yt.scrollTop-s),e=this.sn(),h=Math.max(0,this.Yt.clientHeight-e),n=this.ln(i,t),o=this.qh(n),r=s+o-this.Yt.scrollTop,l=this.ln(i,t);if(-1===l)return void this.Bh();const a=this.hn(),u=this.fh.Bt*a;let c=this.tn(Math.min(t-1,this.yh.gh(Math.max(0,i-u))),t)??l,d=Math.min(t-1,this.yh.gh(i+h+u));if(c===this.start&&d===this.end)return;this.start=c,this.end=d,this.Oh=!0;try{this.Gh(this.start,this.end),this.pn(this.start,this.end),this.fh.Ut&&this.dn();const s=this.qh(this.start),i=this.gn(this.start,this.end),e=this.fn(t),h=Math.max(0,e-s-i);this.Fh.style.height=s+"px",this.Eh.style.height=h+"px"}finally{this.Oh=!1}const p=this.qh(n),g=this.Kh()+p-r,f=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight),m=Math.min(Math.max(0,g),f),b=Math.abs(p-o)>1,y=Math.abs(this.Yt.scrollTop-m);b&&y>.5&&y<100&&(this.Yt.scrollTop=m)}finally{this.updating=!1}}}Gh(t,s){for(let i=t;i<=s;i++)this.Jh(i)}Jh(t){if(!this.Zh(t)){const s=this.wh.get(t);return s?.parentElement===this.jh&&s.remove(),void this.wh.delete(t)}const s=this.Xt.items[t];if(!s)return;const i=this.wh.get(t);if(i)return void(s?.view?(this.cn(t,i),this.Xt.Pe(s,s.view,t)):(i.remove(),this.wh.delete(t)));if(s.Tt)s.view&&this.Xt.Pe(s,s.view,t);else{const i=this.Xt.Ce(this.jh,s);s.view=i,this.Xt.Pe(s,i,t),s.Tt=!0}const e=s.view?.ci?.();e&&(this.cn(t,e),this.wh.set(t,e))}pn(t,s){this.wh.forEach((i,e)=>{(e<t||e>s)&&(i.parentElement===this.jh&&i.remove(),this.wh.delete(e))})}Qh(){this.wh.forEach((t,s)=>{this.Zh(s)||(t.parentElement===this.jh&&t.remove(),this.wh.delete(s))})}qh(t){return this.yh.uh(t)}gn(t,s){return this.yh.dh(t+1,s+1)}fn(t){return this.yh.uh(t)}}F.rn=.5,F.un="data-vindex";class j extends r{constructor(t,s){super(),this.container={},this.oldValue=null,this.node=null,this.options=null,this.mn=null,this.isOpen=!1,this.bn=!1,this.yn=!1,this.wn=!1,this.ae=null,this.plugins=[],this.vn=null,t&&s&&this.initialize(t,s)}get isDisabled(){return!!this.options?.disabled}set isDisabled(t){this.options&&this.node&&(this.options.disabled=t,this.node.classList.toggle("disabled",t),this.node.setAttribute("aria-disabled",t+""),this.container.tags?.Os?.setAttribute("aria-disabled",t+""))}get xn(){return!!this.options?.readonly}set xn(t){this.options&&this.node&&(this.options.readonly=t,this.node.classList.toggle("readonly",t))}get isVisible(){return!!this.options?.visible}set isVisible(t){this.options&&this.node&&(this.options.visible=t,this.node.classList.toggle("invisible",!t))}initialize(t,s){const i=e.V(t);this.options=i.options,this.ae=s,this.init(t)}init(t){if(this.state!==o.NEW)return;if(!t||!this.options)return;const i=this.options,h=new l(i),n=new a,r=new f(i),effector=s(),u=new v(i),c=new M(i),d=new T(t,u,this),p=new O(t),m=new A(t);h.node&&(h.node.id=(i.Mn??"")+"");const b=e.C({Tn:{tag:{node:"div",classList:"seui-MAIN"},L:{Os:{tag:{node:"div",classList:"seui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.On()?.open())}},L:{An:{tag:h.node},Hn:{tag:n.node},Rs:{tag:r.node}}}}}},null);if(this.container=b,this.node=b.view,b.Sn=d,b.placeholder=h,b.Pn=n,b.Cn=r,b.effector=effector,b.targetElement=t,b.Ln=c,b.In=p,b.Fn=m,u.Ti(L),u.Ai(i.virtualScroll?F:x),u.Si(e.q(t)),u.on("onUpdate",()=>{b.se?.rs?.()}),this.mn=u,b.se=new g(t,i,u),b.se.bs(effector),b.se.As(d,i),b.se.fs("selected",()=>{this.On()?.change(null,!0)}),b.se.fs("selected_internal",()=>{this.On()?.change(null,!1)}),b.se.ps("select",()=>{this.oldValue=this.On()?.value??""}),c.Gi(b.tags.Os),c.qi(u),this.jn(t,b,i,d,r),this.En(p,m,t,u),this.plugins=this.ae?.$n?.()??[],this.plugins.length){const t=u.Jt(),s={ie:this,options:i,Xt:t.Xt,Vn:t.Vt,kn:b.tags,actions:this.On()};this.vn=s,this.Rn("init",t=>t.init?.(s))}this.isDisabled=e.F(i.disabled),this.xn=e.F(i.readonly),super.init()}mount(){if(this.state!==o.INITIALIZED)return;if(!this.node||!this.container.targetElement)return;const t=this.container.targetElement,s=this.container;t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,s.tags.Os),s.tags.Os.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.ot(t,s.tags.Os),t.classList.add("init"),this.On()?.change(null,!1),super.mount()}update(){this.state===o.MOUNTED&&(this.container.se?.rs?.(),super.update())}jn(t,s,i,h,n){const o=s.se.Lt;let r=null;const l=(t,n)=>{n||""!==t?(""!==t&&(this.yn=!0),h.search(t).then(t=>{clearTimeout(r),e.J.clear("sche_vis_proxy_"+o.Se),e.J.on("sche_vis_proxy_"+o.Se,()=>{s.se?.rs?.(),t?.we&&(r=setTimeout(()=>{o.eh(),s.se?.rs?.()},i.animationtime??0))},{tt:10})}).catch(t=>{console.error("Search error:",t)})):h.clear()};let a=null;n.Es=(t,e)=>{h.ye(t)&&(a&&clearTimeout(a),h.ne()?(s.se?.ss?.(),a=setTimeout(()=>{l(t,e)},i.delaysearchtime??0)):a=setTimeout(()=>{l(t,e)},10))},h.setPopup(s.se),n.$s=t=>{o.navigate(t)},n.Vs=()=>{o.hh()},n.ks=()=>{this.On()?.close(),s.tags.Os.focus()},o.oh=(t,s)=>{s&&n.zs(s)},o.Xe=()=>{s.se?.rs?.()},i.ajax&&(null==i.ajax?.keepSelected&&(i.ajax.keepSelected=i.keepSelected),h.ge(i.ajax))}En(t,s,i,h){t.connect(),t.Pt=t=>{h.Li(e.q(t)),this.On()?.refreshMask()},s.connect(),s.Pt=t=>{e.F(t.disabled)!==this.isDisabled&&(this.isDisabled=e.F(t.disabled)),e.F(t.readonly)!==this.xn&&(this.xn=e.F(t.readonly)),e.F(t.visible)!==this.isVisible&&(this.isVisible=e.F(t.visible??"1"))}}Dn(){if(this.wn)return;const t=this.container??{},{In:s,Fn:i}=t;this.plugins.length&&this.Rn("destroy",t=>t.destroy?.()),this.plugins=[],this.vn=null,s?.disconnect&&s.disconnect(),i?.disconnect&&i.disconnect(),this.wn=!0}destroy(){if(this.is(o.DESTROYED))return;this.Dn();const t=this.container;t.Sn.destroy(),t.Pn.destroy(),t.se.destroy(),t.Ln.destroy(),t.placeholder.destroy(),t.Cn.destroy(),this.mn.destroy(),this.node?.remove(),this.container={},this.node=null,this.options=null,this.mn=null,this.ae=null,this.oldValue=null,this.isOpen=!1,this.bn=!1,this.yn=!1,super.destroy()}On(){const t=this.container,s=this,i=()=>this.ae.find(t.targetElement),n=e.V(t.targetElement);if(!n)return null;const r=n.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(s){t.placeholder?.set(s),t.Cn?.Ds(s)},get oldValue(){return s.oldValue},set value(t){this.setValue(null,t,!0)},get value(){const t=this.valueArray,s=t.length;return s>1?t:0===s?"":t[0]},get valueArray(){const t=[];return s.zn().forEach(s=>{s.selected&&t.push(s.value)}),t},get valueString(){return this.valueArray.join(r.customDelimiter)},get valueOptions(){const t=[];return s.zn(!0).forEach(s=>{t.push(s)}),t},get mask(){const t=[];return s.zn(!0).forEach(s=>{t.push(s.text)}),t},get valueText(){const t=[];s.zn(!0).forEach(s=>{t.push(s.text)});const i=t.length;return i>1?t:0===i?"":t[0]},get isOpen(){return s.isOpen},getParent:()=>t.view.parentElement,valueDataset(t,i=null,e=!1){var h=[];if(s.zn(!0).forEach(t=>{h.push(i?t.dataset[i]:t.dataset)}),!e){if(0==h.length)return"";if(1==h.length)return h[0]}return h},selectAll(t,e=!0){if(!(r.multiple&&r.maxSelected>0&&s.zn().length>r.maxSelected)&&!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.et([i()],...r.on.beforeChange).isCancel)return;s.oldValue=this.value}s.zn().forEach(t=>{t.ui=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.et([i()],...r.on.beforeChange).isCancel)return;s.oldValue=this.value}s.zn().forEach(t=>{t.ui=!1}),this.change(!1,e)}},setValue(e=null,n,o=!0,l=!1){if(Array.isArray(n)||(n=[n]),0===(n=n.filter(t=>""!==t&&null!=t)).length)return s.zn().forEach(t=>t.ui=!1),void this.change(!1,o);if(r.multiple&&r.maxSelected>0&&n.length>r.maxSelected)console.warn(`Cannot select more than ${r.maxSelected} items`);else if(l||!this.disabled&&!this.readonly){if(t.Sn?.ne?.()){const{pe:i}=t.Sn.ce(n);if(i.length>0)return void(async()=>{r.loadingfield&&t.se?.ss?.();try{t.Sn.fe();const e=await t.Sn.oe(i);e.Ls&&e.items.length>0?(e.items.forEach(t=>{i.includes(t.value)&&(t.selected=!0)}),t.Sn.xe?.(e.items,!0,!0),setTimeout(()=>{s.zn().forEach(t=>{t.ui=n.some(s=>s==t.value)}),this.change(!1,!1)},100)):i.length>0&&console.warn(`Could not load ${i.length} values:`,i)}catch(e){console.error("Error loading missing values:",e)}finally{r.loadingfield&&t.se?.ls?.()}})()}if(o){if(h.et([i()],...r.on.beforeChange).isCancel)return;s.oldValue=this.value}s.zn().forEach(t=>{t.ui=n.some(s=>s==t.value)}),!r.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,o)}},open(){if(s.isOpen)return;const e=s.ae?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(h.et([i()],...r.on.beforeShow).isCancel)return;s.isOpen=!0,t.Pn.dt(!0);const n=t.se.Lt,o=n.ih();o?n.Ze(o,!1):n.eh(),s.bn&&!s.yn||!r?.ajax?t.se.open(null,!0):(t.Sn.fe(),t.se.ss(),s.bn=!0,s.yn=!1,setTimeout(()=>{t.se&&t.Sn&&t.Sn.search("").then(()=>t.se?.rs?.()).catch(t=>console.error("Initial ajax load error:",t))},r.animationtime),t.se.open(null,!1)),t.Cn.show();const l=t.tags.Os;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",r.qt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",r.Mn),r.multiple&&l.setAttribute("aria-multiselectable","true"),h.et([i()],...r.on.show),s.vn&&s.Rn("onOpen",t=>t._n?.(s.vn))},close(){s.isOpen&&(h.et([i()],...r.on.beforeClose).isCancel||(s.isOpen=!1,t.Pn.dt(!1),t.se.close(()=>{t.Cn.clear(!1)}),t.Cn.hide(),t.tags.Os.setAttribute("aria-expanded","false"),h.et([i()],...r.on.close),s.vn&&s.Rn("onClose",t=>t.Bn?.(s.vn))))},toggle(){s.isOpen?this.close():this.open()},change(e=null,n=!0){if(n){if(r.multiple&&r.maxSelected>0&&this.valueArray.length>r.maxSelected&&this.setValue(null,this.oldValue,!1,!0),this.disabled||this.readonly)return void this.setValue(null,this.oldValue,!1,!0);if(h.et([i(),this.value],...r.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}if(this.refreshMask(),t.Ln.Ki(this.valueOptions),n&&(t.targetElement&&h.ht(t.targetElement,"change"),h.et([i(),this.value],...r.on.change),s.options?.autoclose&&this.close()),s.is(o.MOUNTED)&&s.update(),s.vn&&s.mn){const t=s.mn.Jt();s.Rn("onChange",i=>i.Un?.(this.value,t.ji,t.Xt,s.vn))}},refreshMask(){let i=r.placeholder;!r.multiple&&s.zn().length>0&&(i=this.mask[0]),i??(i=r.placeholder),t.placeholder.set(i,!1),t.Cn.Ds(i)},on(t,s,i){r.on[s]||(r.on[s]=[]),r.on[s].push(i)},ajax(i,e){null==e.keepSelected&&(e.keepSelected=s.options.keepSelected),t.Sn.ge(e)},loadAjax:()=>new Promise((e,h)=>{t.se.ss(),t.Sn.fe(),s.bn=!0,s.yn=!1,t.se&&t.Sn?t.Sn.search("").then(()=>{t.se?.rs?.(),e(i())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(i())})};return this.Nn(l,"disabled","isDisabled"),this.Nn(l,"readonly","isReadOnly"),this.Nn(l,"visible","isVisible"),l}Nn(t,s,i){const e=this;Object.defineProperty(t,s,{get:()=>e[i],set(t){e[i]=!!t,e.container?.targetElement?.dataset&&(e.container.targetElement.dataset[s]=!!t+"")},enumerable:!0,configurable:!0})}zn(t=null){if(!this.mn)return[];const{ji:s}=this.mn.Jt(),i=[];for(const e of s)e instanceof w?i.push(e):e instanceof y&&Array.isArray(e.items)&&e.items.length&&i.push(...e.items);return"boolean"==typeof t?i.filter(s=>s.selected===t):i}Rn(t,s){this.plugins.length&&this.plugins.forEach(i=>{try{s(i)}catch(e){console.error(`Plugin "${i.id}" ${t} error:`,e)}})}}class E{constructor(){this.isActive=!1,this.Ae=null,this.actions=new Set}Gn(t){this.actions.add(t)}Wn(){this.actions.clear()}connect(t){if(this.isActive)return;this.isActive=!0;const s=t.toUpperCase(),i=t.toLowerCase();this.Ae=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===s&&this.qn(e),e.querySelectorAll(i).forEach(t=>this.qn(t))})}),this.Ae.observe(document.body,{childList:!0,subtree:!0})}disconnect(){this.isActive&&(this.isActive=!1,this.Ae?.disconnect(),this.Ae=null)}qn(t){for(const s of this.actions)s(t)}}class $ extends r{constructor(){super(),this.Kn=new Map,this.plugins=new Map,this.init()}init(){this.is(o.NEW)&&(this.Kn=new Map,this.plugins=new Map,super.init())}bind(t,s){this.is(o.NEW)&&this.init();const i=e.j(e.B(),s);i.on=i.on??{},i.on.load=i.on.load??[],this.Kn.set(t,i);const n=e.m();e.J.on(n,()=>{h.et([this.find(t)],...i.on.load),e.J.clear(n),i.on.load=[]});const r=e.v(t);let l=!1;r.forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e.R(t),this.Qn(t,i)&&(l=!0,e.J.run(n)))})()}),e.U().includes(t)||e.U().push(t),this.is(o.INITIALIZED)&&l&&this.mount(),this.is(o.MOUNTED)&&this.update()}mount(){this.state===o.INITIALIZED&&super.mount()}update(){this.state===o.MOUNTED&&super.update()}find(t="*"){const s={isEmpty:!0};if("*"===t&&""===(t=e.U().join(", ")))return s;const i=e.v(t);if(0===i.length)return s;const h=e.V(i[0]);if(!h||!h.action)return s;const n={};for(const e in h.action)n[e]=this.Yn(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.Jn(o,t.name,i);break;case"func":this.Xn(o,t.name,i)}}return o}$n(){return Array.from(this.plugins.values())}Zn(){this.so||(this.so=new E,this.so.Gn(t=>{this.Kn.forEach((s,i)=>{try{t.matches(i)&&(this.Qn(t,s),this.is(o.MOUNTED)&&this.update())}catch(e){console.warn("Invalid selector: "+i,e)}})})),this.so.connect("select")}destroy(t=null){null===t?this.io():"string"==typeof t?this.eo(t):t instanceof HTMLSelectElement&&this.ho(t),null!==t&&this.is(o.MOUNTED)&&this.update()}registerPlugin(t){t?.id&&this.plugins.set(t.id,t)}unregisterPlugin(t){t&&this.plugins.delete(t)}no(t){if(t)return this.plugins.get(t)}io(){this.state!==o.DESTROYED&&(e.U().forEach(t=>this.eo(t)),this.Kn.clear(),e.U().length=0,this.plugins.forEach(t=>{t.destroy?.(),t.oo?.()}),this.plugins.clear(),this.so?.disconnect(),this.plugins.clear(),super.destroy())}eo(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.ho(t)}),this.Kn.delete(t);const s=e.U(),i=s.indexOf(t);i>-1&&s.splice(i,1)}ho(t){const s=e.V(t);if(!s)return;const i=s.self;e._(t,s);const h=!!this.so;h&&this.so?.disconnect(),s.self?.Dn?.();const n=s.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.ro,n&&n.parentNode?n.parentNode.replaceChild(t,n):t.appendChild(t),e.$(t),h&&this.Kn.size>0&&this.so?.connect("select"),i?.destroy?.()}rebind(t,s){this.eo(t),this.bind(t,s),this.is(o.MOUNTED)&&this.update()}Qn(t,s){if(e.V(t)||e.D(t))return!1;const i=e.m(8),h=e.I(t,s);h.lo=i,h.qt=`seui-${i}-optionlist`,h.Mn=`seui-${i}-placeholder`;const n={options:h};e.k(t,n);const o=new j(t,this);return o.on("onMount",()=>{o.container.view&&o.container.view.addEventListener("mouseup",()=>{n.action?.toggle?.()})}),o.mount(),n.container=o.container,n.action=o.On(),n.self=o,!0}Yn(t,s){const i=Object.getOwnPropertyDescriptor(s,t);let e="variable";return i?.get||i?.set&&"function"!=typeof s[t]?e="get-set":"function"==typeof s[t]&&(e="func"),{type:e,name:t}}Jn(t,s,i){Object.defineProperty(t,s,{get(){const t=e.V(i[0]);return t.action?.[s]},set(t){i.forEach(i=>{const h=e.V(i);h?.action&&(h.action[s]=t)})},enumerable:!0,configurable:!0})}Xn(t,s,i){t[s]=(...n)=>{let o=null;for(let t=0;t<i.length;t++){const r=e.V(i[t]);if(!r?.action)continue;const l=h.it();if(o??(o=r.action[s](l.st,...n)),!l.token.isContinue)break}return o??t}}}if(void 0===globalThis.GLOBAL_SEUI){const k=new $;globalThis.GLOBAL_SEUI={version:"1.2.7",name:"SelectiveUI",bind:k.bind.bind(k),find:k.find.bind(k),destroy:k.destroy.bind(k),effector:s.bind(s),rebind:k.rebind.bind(k),registerPlugin:k.registerPlugin.bind(k),unregisterPlugin:k.unregisterPlugin.bind(k)};let R=!1;function init(){R||(R=!0,document.addEventListener("mousedown",()=>{const t=e.U();if(t.length>0){const s=k.find(t.join(", "));s.isEmpty||s.close()}}),k.Zn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",init):init()),console.log("[SelectiveUI] v1.2.7 loaded successfully")}else console.warn(`[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). Using existing instance. Please remove duplicate <script> tags.`);const version=globalThis.GLOBAL_SEUI.version,V=globalThis.GLOBAL_SEUI.name;t.bind=(t,s={})=>{globalThis.GLOBAL_SEUI.bind(t,s)},t.destroy=(t=null)=>{globalThis.GLOBAL_SEUI.destroy(t)},t.effector=t=>globalThis.GLOBAL_SEUI.effector(t),t.find=t=>globalThis.GLOBAL_SEUI.find(t),t.name=V,t.rebind=(t,s={})=>{globalThis.GLOBAL_SEUI.rebind(t,s)},t.registerPlugin=t=>{globalThis.GLOBAL_SEUI.registerPlugin(t)},t.unregisterPlugin=t=>{globalThis.GLOBAL_SEUI.unregisterPlugin(t)},t.version=version},"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).SelectiveUI={});
|
|
Binary file
|
package/dist/selective-ui.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Selective UI v1.2.
|
|
1
|
+
/*! Selective UI v1.2.7 | MIT License */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -3788,6 +3788,7 @@
|
|
|
3788
3788
|
*/
|
|
3789
3789
|
this.privOnCollapsedChanged = [];
|
|
3790
3790
|
this.label = this.targetElement.label;
|
|
3791
|
+
this.collapsed = Libs.string2Boolean(this.targetElement.dataset?.collapsed);
|
|
3791
3792
|
}
|
|
3792
3793
|
/**
|
|
3793
3794
|
* Initializes group state from the backing `<optgroup>` (if present) and mounts the model.
|
|
@@ -3804,7 +3805,6 @@
|
|
|
3804
3805
|
* @override
|
|
3805
3806
|
*/
|
|
3806
3807
|
init() {
|
|
3807
|
-
this.collapsed = Libs.string2Boolean(this.targetElement.dataset?.collapsed);
|
|
3808
3808
|
super.init();
|
|
3809
3809
|
this.mount();
|
|
3810
3810
|
}
|
|
@@ -5524,7 +5524,8 @@
|
|
|
5524
5524
|
.join(",");
|
|
5525
5525
|
let payload;
|
|
5526
5526
|
if (typeof cfg.data === "function") {
|
|
5527
|
-
|
|
5527
|
+
const selectiveInstance = this.selectBox?.Selective?.find(this.selectBox?.container?.targetElement);
|
|
5528
|
+
payload = cfg.data.call(selectiveInstance, keyword, page);
|
|
5528
5529
|
if (payload && typeof payload.selectedValue === "undefined")
|
|
5529
5530
|
payload.selectedValue = selectedValues;
|
|
5530
5531
|
}
|
|
@@ -10004,7 +10005,7 @@
|
|
|
10004
10005
|
*
|
|
10005
10006
|
* @internal
|
|
10006
10007
|
*/
|
|
10007
|
-
this.actions =
|
|
10008
|
+
this.actions = new Set();
|
|
10008
10009
|
}
|
|
10009
10010
|
/**
|
|
10010
10011
|
* Registers a callback invoked whenever a matching element is detected as added to the DOM.
|
|
@@ -10016,7 +10017,7 @@
|
|
|
10016
10017
|
* @param action - Function executed with the newly detected element.
|
|
10017
10018
|
*/
|
|
10018
10019
|
onDetect(action) {
|
|
10019
|
-
this.actions.
|
|
10020
|
+
this.actions.add(action);
|
|
10020
10021
|
}
|
|
10021
10022
|
/**
|
|
10022
10023
|
* Clears all registered detection callbacks.
|
|
@@ -10025,7 +10026,7 @@
|
|
|
10025
10026
|
* to scan mutations but will not invoke any listeners until new callbacks are registered.
|
|
10026
10027
|
*/
|
|
10027
10028
|
clearDetect() {
|
|
10028
|
-
this.actions
|
|
10029
|
+
this.actions.clear();
|
|
10029
10030
|
}
|
|
10030
10031
|
/**
|
|
10031
10032
|
* Starts observing the document for additions of elements matching the given tag name.
|
|
@@ -10099,7 +10100,9 @@
|
|
|
10099
10100
|
* @internal
|
|
10100
10101
|
*/
|
|
10101
10102
|
handle(element) {
|
|
10102
|
-
this.actions
|
|
10103
|
+
for (const action of this.actions) {
|
|
10104
|
+
action(element);
|
|
10105
|
+
}
|
|
10103
10106
|
}
|
|
10104
10107
|
}
|
|
10105
10108
|
|
|
@@ -10805,7 +10808,7 @@
|
|
|
10805
10808
|
if (typeof globalThis.GLOBAL_SEUI == "undefined") {
|
|
10806
10809
|
const SECLASS = new Selective();
|
|
10807
10810
|
globalThis.GLOBAL_SEUI = {
|
|
10808
|
-
version: "1.2.
|
|
10811
|
+
version: "1.2.7",
|
|
10809
10812
|
name: "SelectiveUI",
|
|
10810
10813
|
bind: SECLASS.bind.bind(SECLASS),
|
|
10811
10814
|
find: SECLASS.find.bind(SECLASS),
|
|
@@ -10838,7 +10841,7 @@
|
|
|
10838
10841
|
init();
|
|
10839
10842
|
}
|
|
10840
10843
|
}
|
|
10841
|
-
console.log(`[${"SelectiveUI"}] v${"1.2.
|
|
10844
|
+
console.log(`[${"SelectiveUI"}] v${"1.2.7"} loaded successfully`);
|
|
10842
10845
|
}
|
|
10843
10846
|
else {
|
|
10844
10847
|
console.warn(`[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). ` +
|