selective-ui 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/selective-ui.esm.js +4174 -1237
- 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 +4175 -1238
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/ts/adapter/mixed-adapter.ts +247 -91
- package/src/ts/components/accessorybox.ts +164 -67
- package/src/ts/components/directive.ts +53 -24
- package/src/ts/components/option-handle.ts +121 -54
- package/src/ts/components/placeholder.ts +70 -32
- package/src/ts/components/popup/empty-state.ts +68 -32
- package/src/ts/components/popup/loading-state.ts +70 -30
- package/src/ts/components/popup/popup.ts +0 -1
- package/src/ts/components/searchbox.ts +185 -46
- package/src/ts/components/selectbox.ts +309 -30
- package/src/ts/core/base/adapter.ts +158 -77
- package/src/ts/core/base/fenwick.ts +147 -0
- package/src/ts/core/base/lifecycle.ts +118 -35
- package/src/ts/core/base/model.ts +94 -36
- package/src/ts/core/base/recyclerview.ts +0 -1
- package/src/ts/core/base/view.ts +54 -23
- package/src/ts/core/base/virtual-recyclerview.ts +360 -278
- package/src/ts/core/model-manager.ts +162 -81
- package/src/ts/core/search-controller.ts +164 -91
- package/src/ts/global.ts +1 -1
- package/src/ts/index.ts +1 -1
- package/src/ts/models/group-model.ts +138 -32
- package/src/ts/models/option-model.ts +184 -48
- package/src/ts/services/dataset-observer.ts +72 -10
- package/src/ts/services/ea-observer.ts +87 -10
- package/src/ts/services/effector.ts +181 -32
- package/src/ts/services/refresher.ts +30 -6
- package/src/ts/services/resize-observer.ts +132 -15
- package/src/ts/services/select-observer.ts +115 -50
- package/src/ts/types/utils/ievents.type.ts +6 -1
- package/src/ts/utils/callback-scheduler.ts +112 -34
- package/src/ts/utils/ievents.ts +91 -29
- package/src/ts/utils/selective.ts +330 -61
- package/src/ts/views/group-view.ts +137 -26
- package/src/ts/views/option-view.ts +262 -50
package/dist/selective-ui.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Selective UI v1.2.
|
|
2
|
-
var t,i;t=this,i=function(t){"use strict";function i(t){return new m(t??null)}class s{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 s),this.u}static p(t){if(null===t||"object"!=typeof t)return t;const i=Array.isArray(t)?[]:{};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=this.p(t[s]));return i}static m(t=6){let i="";for(let s=0;s<t;s++)i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return i}static v(t){if(!t)return[];if("string"==typeof t){const i=document.querySelectorAll(t);return Array.from(i)}return t instanceof Element?[t]:t instanceof NodeList||Array.isArray(t)?Array.from(t):[]}static O(t={}){return this.M(document.createElement(t.node??"div"),t,!0)}static M(t=document.documentElement,i=null,s=!1){const e={...i??{}},h=s?t:this.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 i=e[t];i&&"object"==typeof i&&Object.assign(h[t],i),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.A&&(h.setAttribute("aria-labelledby",e.A+""),delete e.A),e.S&&(h.setAttribute("aria-controls",e.S+""),delete e.S),e.H&&(h.setAttribute("aria-haspopup",e.H+""),delete e.H),e.C&&(h.setAttribute("aria-multiselectable",e.C+""),delete e.C),e.L&&(h.setAttribute("aria-autocomplete",e.L+""),delete e.L),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,i])=>{h.addEventListener(t,i)}),delete e.event),Object.entries(e).forEach(([t,i])=>{null===i?h.removeAttribute(t):h[t]=i}),h}static T(t){if(t instanceof Element)return t;throw new TypeError("Node is not an Element")}static P(t){return this.I(t)}static I(t,i=null,s=!1,e=!1,h={}){let n=null;for(const o in t){const r=t[o],l=r?.tag?.tagName?r.tag:this.O(r.tag);h[o]=l,r?.F&&this.I(r.F,l,!1,!1,h),i?s?i.prepend(l):i.append(l):e||n||(n=l)}return e||(h.id=this.m(7),i||(h={tags:h,view:n})),h}static j(t,i){const s=this.p(i);for(const e in s){const i=t[e];i?s[e]="boolean"==typeof s[e]?this.$(i):i:void 0!==t?.dataset?.[e]&&(s[e]="boolean"==typeof s[e]?this.$(t.dataset[e]):t.dataset[e])}return s}static V(...t){if(0===t.length)return{};if(1===t.length)return this.p(t[0]);const i=this.p(t[0]);for(let s=1;s<t.length;s++){const e=t[s];for(const t in e)if("on"===t){const s=e[t];for(const e in s)i[t][e].push(s[e])}else i[t]=e[t]}return i}static $(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 k(t){return this.l.i.delete(t)}static R(t){return this.l.i.get(t)}static D(t,i){this.l.i.set(t,i)}static _(t){return this.l.h.delete(t)}static N(t){return this.l.h.get(t)}static U(t,i){this.l.h.set(t,i)}static B(){return this.l.t}static G(){return this.l.o}static W(t){if(null==t)return"";let i=(t+"").replace(/<`/g,"<").replace(/`>/g,">").replace(/\<\`/g,"<").replace(/\`\>/g,">").trim();const s=globalThis?.document;if(!s||"function"!=typeof s.createElement)return i=i.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,""),i=i.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,""),i=i.replace(/\s([a-z-:]+)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,""),i;const e=s.createElement("div");return e.innerHTML=i,e.querySelectorAll("script, style, iframe, object, embed, link").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const i in t.attributes){const s=t.attributes[i],e=s.name??"",h=s.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 q(t){const i=document.createElement("DIV");i.innerHTML=t;const s=i.textContent??i.innerText??"";return i.remove(),s.trim()}static J(t){return null==t?"":(t+"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"d")}static K(t){const i=[];return Array.from(t.children).forEach(t=>{if("OPTGROUP"===t.tagName){const s=t;i.push(s),Array.from(s.children).forEach(t=>{t.__parentGroup=s,i.push(t)})}else"OPTION"===t.tagName&&i.push(t)}),i}static Y(){const t=navigator.userAgent;return/iP(hone|ad|od)/.test(t)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1}static X(t){const i=(t+"").trim();if(i.endsWith("px"))return i;if(i.endsWith("vh"))return window.innerHeight*parseFloat(i)/100+"px";if(i.endsWith("vw"))return window.innerWidth*parseFloat(i)/100+"px";const s=parseFloat(getComputedStyle(document.documentElement).fontSize);if(i.endsWith("rem"))return s*parseFloat(i)+"px";const e=this.O({node:"div",style:{height:i,opacity:"0"}});document.body.appendChild(e);const h=e.offsetHeight+"px";return e.remove(),h}}e.u=null,e.Z=new class{constructor(){this.tt=new Map,this.it=new Map}on(t,i,s={}){const e=s.st??50,h=s.once??!1;this.tt.has(t)||this.tt.set(t,[]),this.tt.get(t).push({et:i,timeout:e,once:h})}off(t){const i=this.it.get(t);if(i){for(const t of i.values())clearTimeout(t);i.clear(),this.it.delete(t)}this.tt.delete(t)}run(t,...i){const s=this.tt.get(t);if(!s||0===s.length)return Promise.resolve();this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t),h=[];for(let n=0;n<s.length;n++){const t=s[n];if(!t)continue;const o=e.get(n);o&&clearTimeout(o);const r=new Promise(h=>{const o=setTimeout(async()=>{try{const s=t.et(i.length>0?i:null);s instanceof Promise&&await s}catch{}finally{if(t.once){s[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 i of Array.from(this.tt.keys()))this.off(i);else this.off(t)}};class h{static ht(){const t={isContinue:!0,isCancel:!1};return{token:{get isContinue(){return t.isContinue},get isCancel(){return t.isCancel}},et:{stopPropagation(){t.isContinue=!1},cancel(){t.isCancel=!0,t.isContinue=!1}}}}static nt(t,...i){const{token:s,et:e}=this.ht();for(let h=0;h<i.length;h++){const n=i[h];if("function"==typeof n&&(t&&Array.isArray(t)?n(e,...t):n(e),s.isCancel||!s.isContinue))break}return s}static ot(t,i,s={bubbles:!0,cancelable:!0}){const e=new Event(i,s);return t.dispatchEvent(e),e}static rt(t,...i){if(Array.isArray(t))for(const s of t)"function"==typeof s&&s(...i)}}class n{static lt(t,i){const s=e.R(t);if(!s?.options)return;const h=s.options,n=h.minWidth,o=h.minHeight,r=Number.parseInt(h.width,10),l=Number.parseInt(h.height,10);let a=t.offsetWidth+"px",c=t.offsetHeight+"px";const u=getComputedStyle(t);"0px"===a&&"auto"!==u.width&&(a=u.width),"0px"===c&&"auto"!==u.height&&(c=u.height),r>0&&(a=h.width),l>0&&(c=h.height),Object.assign(i.style,{width:a,height:c,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.ct=new Map,this.ct.set("onInit",new Set),this.ct.set("onMount",new Set),this.ct.set("onUpdate",new Set),this.ct.set("onDestroy",new Set)}on(t,i){return this.ct.get(t).add(i),this}off(t,i){return this.ct.get(t).delete(i),this}emit(t,i){const s={state:this.state,ut:i};for(const h of this.ct.get(t))try{h(s)}catch(e){this.dt(e,t)}}dt(t,i){console.error(`[Lifecycle:${i}]`,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.gt()}getState(){return this.state}is(t){return this.state===t}gt(){for(const t of this.ct.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.O({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.options=t,this.init()}get(){return this.options?.placeholder??""}set(t,i=!0){if(!this.node||!this.options)return;i&&(this.options.placeholder=t);const s=e.W(t);this.node.innerHTML=this.options.allowHtml?s:e.q(s)}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.O({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"}),super.init(),this.mount()}ft(t){this.node.classList.toggle("drop-down",!!t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.node=null,super.destroy())}}class c extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.options=null,this.yt=[],this.wt=[],t&&this.initialize(t)}initialize(t){this.bt=e.I({vt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},F:{xt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.rt(this.yt)}}},Ot:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.rt(this.wt)}}}}}}),this.node=this.bt.view,this.options=t,this.init()}available(){return!!this.options&&e.$(this.options.multiple)&&e.$(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")}Mt(t=null){"function"==typeof t&&this.yt.push(t)}Tt(t=null){"function"==typeof t&&this.wt.push(t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.options=null,this.yt=null,this.wt=null,this.node=null,super.destroy())}}class u extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.O({node:"div",classList:["selective-ui-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.O({node:"div",classList:["selective-ui-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.At=!1,this.element=null,this.St=null,this.Ht=null,this.At=!0,this.Ct=this.Lt.bind(this)}Pt(t){}Lt(){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 i=t.getBoundingClientRect(),s="undefined"!=typeof window&&"function"==typeof window.getComputedStyle?window.getComputedStyle(t):null;this.Pt({width:i?.width??0,height:i?.height??0,top:i?.top??0,left:i?.left??0,padding:{top:parseFloat(s?.paddingTop??"0"),right:parseFloat(s?.paddingRight??"0"),bottom:parseFloat(s?.paddingBottom??"0"),left:parseFloat(s?.paddingLeft??"0")},border:{top:parseFloat(s?.borderTopWidth??"0"),right:parseFloat(s?.borderRightWidth??"0"),bottom:parseFloat(s?.borderBottomWidth??"0"),left:parseFloat(s?.borderLeftWidth??"0")},margin:{top:parseFloat(s?.marginTop??"0"),right:parseFloat(s?.marginRight??"0"),bottom:parseFloat(s?.marginBottom??"0"),left:parseFloat(s?.marginLeft??"0")}})}ot(){this.Lt()}connect(t){if(!(t instanceof Element))throw Error("Invalid element");this.element=t,this.St=new ResizeObserver(this.Ct),this.St.observe(t),this.Ht=new MutationObserver(this.Ct),this.Ht.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.Ct,!0),window.addEventListener("resize",this.Ct),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.Ct),window.visualViewport.addEventListener("scroll",this.Ct))}disconnect(){this.St?.disconnect(),this.Ht?.disconnect(),this.Pt=()=>{},window.removeEventListener("scroll",this.Ct,!0),window.removeEventListener("resize",this.Ct),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.Ct),window.visualViewport.removeEventListener("scroll",this.Ct)),this.St=null,this.Ht=null,this.element=null}}class g extends r{constructor(t=null,i=null,s=null){super(),this.options=null,this.It=!1,this.Et=null,this.node=null,this.Ft=null,this.jt=null,this.parent=null,this.$t=null,this.Vt=null,this.kt=null,this.Rt=null,this.Dt=null,this.zt=null,this._t=null,this.Nt={Ut:36,Bt:8,Gt:!0},this.Wt=s,t&&i&&this.initialize(t,i)}initialize(t,i){if(!this.Wt)throw Error("Popup requires a ModelManager instance.");this.$t=new c(i),this.Vt=new u(i),this.kt=new d(i);const s=e.I({qt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},F:{vt:{tag:this.$t.node},Jt:{tag:{id:i.Kt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Qt:{tag:this.kt.node},Yt:{tag:this.Vt.node}}}},null);this.node=s.view,this.Dt=s.tags.Jt,this.parent=e.R(t),this.options=i,this.init(),this.Wt.load(this.Dt,{isMultiple:i.multiple},i.virtualScroll?{Xt:this.node,Ut:this.Nt.Ut,Bt:this.Nt.Bt,Gt:this.Nt.Gt}:{});const h=this.Wt.Zt();this.Et=h.ti,this.Rt=h.Rt,this.$t.Mt(()=>{h.ti.ii(!0)}),this.$t.Tt(()=>{h.ti.ii(!1)}),this.si(),this.mount()}async ei(){this.options&&this.kt&&this.$t&&this.Et&&this.Wt&&(this._t&&clearTimeout(this._t),this.Wt.hi(!0),!1!==e.$(this.options.loadingfield)&&(this.Vt.hide(),this.kt.show(this.Et.oi().ni),this.ri()))}async li(){this.options&&this.kt&&this.Et&&this.Wt&&(this._t&&clearTimeout(this._t),this._t=setTimeout(()=>{this.Wt?.hi(!1),this.kt?.hide();const t=this.Et?.oi();this.ai(t??void 0),this.ri()},this.options.animationtime))}si(){this.Et&&(this.Et.ci(t=>{this.ai(t)}),this.Et.ui("items",()=>{const t=this.Et.oi();this.ai(t),this.ri()}))}ai(t){if(!(this.Et&&this.Vt&&this.$t&&this.Dt))return;const i=t??this.Et.oi();i.isEmpty?(this.Vt.show("nodata"),this.Dt.classList.add("hide"),this.$t.hide()):i.ni?(this.Vt.hide(),this.Dt.classList.remove("hide"),this.$t.update()):(this.Vt.show("notfound"),this.Dt.classList.add("hide"),this.$t.hide())}di(t,i){this.Et?.pi(t,i)}gi(t,i){this.Et?.ui(t,i)}fi(t){this.Ft=t}open(t=null,i){if(!(this.node&&this.options&&this.$t&&this.parent&&this.Ft))return;this.It||(document.body.appendChild(this.node),this.It=!0,this.jt=new p,this.Ft.mi(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.$t.update(),i&&this.ai();const s=this.bi(),{position:e,top:h,maxHeight:n,yi:o}=this.wi(s);this.Ft.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:h,maxHeight:n,yi:o,position:e,xi:()=>{if(!this.jt||!this.parent)return;this.jt.Pt=()=>{const t=this.bi();this.Oi(t)},this.jt.connect(this.parent.container.tags.Mi),t?.();const i=this.Rt;i?.resume?.()}})}close(t=null){if(!(this.It&&this.options&&this.jt&&this.Ft))return;const i=this.Rt;i?.suspend?.(),this.jt.disconnect(),this.Ft.collapse({duration:this.options.animationtime,xi:t??void 0})}ri(){this.It&&this.jt?.ot()}Ti(t,i){this.node&&(this.zt=async()=>{const i=t.Ai();if(!i.Si)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.Hi&&i.hasMore){const i=await t.Ci();!i.Li&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this.zt))}destroy(){if(!this.is(o.DESTROYED)){this._t&&(clearTimeout(this._t),this._t=null),this.node&&this.zt&&(this.node.removeEventListener("scroll",this.zt),this.zt=null),this.Vt.destroy(),this.kt.destroy(),this.$t.destroy(),this.Rt.destroy();try{this.jt?.disconnect()}catch(t){}this.jt=null;try{this.Ft?.mi?.(null)}catch(t){}if(this.Ft=null,this.node)try{const t=this.node.cloneNode(!0);this.node.replaceWith(t),t.remove()}catch(t){this.node.remove()}this.node=null,this.Dt=null;try{this.Wt?.hi?.(!1),this.Rt?.clear?.(),this.Rt=null,this.Et=null,this.node.remove()}catch(t){}this.Wt=null,this.$t=null,this.Vt=null,this.kt=null,this.parent=null,this.options=null,this.It=!1,super.destroy()}}bi(){const t=this.parent.container.tags.Mi,i=t.getBoundingClientRect(),s=window.getComputedStyle(t);return{width:i.width,height:i.height,top:i.top,left:i.left,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},border:{top:parseFloat(s.borderTopWidth),right:parseFloat(s.borderRightWidth),bottom:parseFloat(s.borderBottomWidth),left:parseFloat(s.borderLeftWidth)}}}wi(t){const i=window.visualViewport,s=e.Y(),h=i?.height??window.innerHeight,n=this.Ft.Pi("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 c="bottom",u=o,d=Math.min(n,u);const p=l-15;(d>=r?p>=r:p>=d)?(c="bottom",u=Math.min(l-15,o)):a>=Math.max(d,r)?(c="top",u=Math.min(a-15,o)):l>=a?(c="bottom",u=Math.max(l-15,r)):(c="top",u=Math.max(a-15,r)),d=Math.min(n,u);const g=i&&s?i.offsetTop:0;return{position:c,top:"bottom"===c?t.top+t.height+3+g:t.top-d-3+g,maxHeight:u,yi:d,Ii:n}}Oi(t){if(!this.options||!this.Ft)return;const{position:i,top:s,maxHeight:e,yi:h}=this.wi(t);this.Ft.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,yi:h,position:i,animate:!0})}}class f extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.Ei=null,this.Fi=null,this.options=null,this.ji=null,this.$i=null,this.Vi=null,this.options=t,t&&this.initialize(t)}initialize(t){this.bt=e.I({ki:{tag:{node:"div",classList:["selective-ui-searchbox","hide"]},F:{Ei:{tag:{id:e.m(),node:"input",type:"search",classList:["selective-ui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",S:t.Kt,L:"list"}}}}}),this.node=this.bt.view,this.Ei=this.bt.tags.Ei;let i=!1;const s=this.bt.tags.Ei;s.addEventListener("mousedown",t=>{t.stopPropagation()}),s.addEventListener("mouseup",t=>{t.stopPropagation()}),s.addEventListener("keydown",t=>{i=!1,"ArrowDown"===t.key||"Tab"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.$i?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),i=!0,this.Vi?.()),t.stopPropagation()}),s.addEventListener("input",()=>{i||this.Fi?.(s.value,!0)}),this.init()}show(){this.node&&this.Ei&&this.options&&(this.node.classList.remove("hide"),this.Ei.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.Ei?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.bt&&(this.bt.tags.Ei.value="",this.Fi?.("",t))}Ri(t){this.Ei&&(this.Ei.placeholder=e.q(t))}Di(t){this.Ei&&this.Ei.setAttribute("aria-activedescendant",t)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.bt=null,this.node=null,this.Ei=null,this.Fi=null,this.options=null,this.ji=null,this.$i=null,this.Vi=null,super.destroy())}}class m{constructor(t=null){this.zi=null,this._i=null,this.Ni=!1,t&&this.mi(t)}mi(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.zi&&(clearTimeout(this.zi),this.zi=null),this._i&&(clearTimeout(this._i),this._i=null),this.Ni=!1,this}Pi(t="flex"){if(!this.element)return{width:0,height:0,scrollHeight:0};const i={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 s=window.getComputedStyle(this.element),e=parseFloat(s.borderTopWidth),h=parseFloat(s.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,i),r}expand(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,display:s="flex",width:e,left:h,top:n,maxHeight:o,yi:r,position:l="bottom",xi:a}=t;return Object.assign(this.element.style,{display:s,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 ${i}ms, height ${i}ms, opacity ${i}ms`,top:n+"px",height:r+"px",opacity:"1",overflow:r>=o?"auto":"hidden"}),this.zi=setTimeout(()=>{this.element.style.transition="none",this.Ni=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,xi:s}=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 ${i}ms, top ${i}ms, opacity ${i}ms`,height:"0px",top:r+"px",opacity:"0",overflow:o?"auto":"hidden"}),this.zi=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Ni=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,display:s="block",xi:e}=t;Object.assign(this.element.style,{transition:"none",display:s,width:"fit-content"});const h=this.Pi(s).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:h+"px",overflow:"hidden"})}),this.zi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Ni=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,xi:s}=t,e=this.Pi().width;return Object.assign(this.element.style,{transition:"none",width:e+"px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:"0px",overflow:"hidden"})}),this.zi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Ni=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.cancel();const{duration:i=200,width:s,left:e,top:h,maxHeight:n,yi:o,position:r="bottom",animate:l=!0,xi:a}=t,c=(this.element.classList.contains("position-top")?"top":"bottom")!==r,u=this.element.scrollHeight>n;return this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),c&&(this.element.style.transition=`top ${i}ms ease-out, height ${i}ms ease-out, max-height ${i}ms ease-out;`),requestAnimationFrame(()=>{const t={width:s+"px",left:e+"px",top:h+"px",maxHeight:n+"px",height:o+"px",overflowY:u?"auto":"hidden"},r=Math.abs(this.element.offsetHeight-o);l&&(c||r>5)?t.transition=`height ${i}ms, top ${i}ms`:this._i=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},i),Object.assign(this.element.style,t),l&&(c||r>1)?this._i=setTimeout(()=>{this.element.style.transition=null,c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())}),this}get Ui(){return this.Ni}}class b extends r{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){super(),this.targetElement=null,this.view=null,this.position=-1,this.At=!1,this.Bi=!1,this.options=t,this.targetElement=i,this.view=s,this.init()}Gi(t){this.targetElement=t,this.update()}Wi(){}destroy(){this.is(o.DESTROYED)||(this.targetElement=null,this.view?.destroy(),this.view=null,this.Bi=!0,super.destroy())}}class y extends b{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.qi=[]}init(){this.targetElement&&(this.label=this.targetElement.label,this.collapsed=e.$(this.targetElement.dataset?.collapsed)),super.init(),this.mount()}get value(){return this.items.map(t=>t.value)}get Ji(){return this.items.filter(t=>t.selected)}get Ki(){return this.items.filter(t=>t.visible)}get Qi(){return this.Ki.length>0}Gi(t){this.label=t.label,this.view?.Yi(this.label),this.update()}update(){this.view&&(this.view.Yi(this.label),this.view.Xi(this.collapsed)),super.update()}destroy(){this.is(o.DESTROYED)||(this.items.forEach(t=>{t.destroy()}),this.items=[],super.destroy())}Zi(t){this.qi.push(t)}ts(){this.collapsed=!this.collapsed,this.view?.Xi(this.collapsed),h.nt([this,this.collapsed],...this.qi)}ss(t){this.items.push(t),t.group=this}removeItem(t){const i=this.items.indexOf(t);i>-1&&(this.items.splice(i,1),t.group=null)}es(){this.view?.es()}}class w extends b{constructor(t,i=null,s=null){super(t,i,s),this.hs=[],this.ns=[],this.rs=[],this.ls=!0,this.cs=!1,this.group=null}init(){this.us=e.J(this.textContent.toLowerCase()),super.init(),this.mount()}get ds(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ds}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.ps=t,h.nt([this,t],...this.hs)}get visible(){return this.ls}set visible(t){if(this.ls===t)return;this.ls=t;const i=this.view?.gs?.();i&&i.classList.toggle("hide",!t),h.nt([this,t],...this.rs)}get ps(){return this.selected}set ps(t){const i=this.view?.view?.tags?.fs,s=this.view?.gs?.();i&&(i.checked=t),s&&this.targetElement&&(s.classList.toggle("checked",!!t),s.setAttribute("aria-selected",t?"true":"false"),this.targetElement.toggleAttribute("selected",!!t)),this.targetElement&&(this.targetElement.selected=t),h.nt([this,t],...this.ns)}get text(){const t=e.W(this.dataset?.mask??this.targetElement?.text??"");return this.options.allowHtml?t:e.q(t)}get textContent(){return this.options.allowHtml?e.q(this.text).trim():this.text.trim()}get dataset(){return this.targetElement?.dataset??{}}get bs(){return this.cs}set bs(t){const i=!!t,s=this.view?.gs?.();this.cs!==i&&(this.cs=i),s&&s.classList.toggle("highlight",i)}ys(t){this.hs.push(t)}ws(t){this.ns.push(t)}ci(t){this.rs.push(t)}update(){if(this.us=e.J(this.textContent.toLowerCase()),!this.view)return void super.update();const t=this.view.view.tags.vs;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.xs;i&&this.hasImage&&(i.src=this.ds,i.alt=this.text),this.targetElement&&(this.ps=this.targetElement.selected),super.update()}destroy(){this.is(o.DESTROYED)||(this.hs=[],this.ns=[],this.rs=[],this.group=null,this.us=null,super.destroy())}}class v{constructor(t){this.Os=[],this.Ms=null,this.Ts=null,this.As=null,this.options=null,this.Ss=0,this.options=t}Hs(t){this.Cs=t}Ls(t){this.Ps=t}Is(t){const i=this.Es(t),s=i!==this.As;return s&&(this.As=i),s}Es(t){return t.map(t=>{if("OPTGROUP"===t.tagName){const i=t,s=Array.from(i.children).map(t=>`${t.value}:${t.text}:${t.selected}`).join("\n");return`G:${i.label}:${s}`}return`O:${t.value}:${t.text}:${t.selected}`}).join("\n\n")}Fs(t){this.Os=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new y(this.options,t),this.Os.push(i);else if("OPTION"===t.tagName){const s=t,e=new w(this.options,s),h=s.__parentGroup;h&&i&&h===i.targetElement?(i.ss(e),e.group=i):(this.Os.push(e),i=null)}}),this.Os}async replace(t){this.As=null,this.Fs(t),this.Ms&&await this.Ms.js(this.Os),this.refresh(!1)}notify(){this.Ms&&this.refresh(!1)}load(t,i={},s={}){this.Ms=new this.Cs(this.Os),Object.assign(this.Ms,i),this.Ts=new this.Ps(t),Object.assign(this.Ts,s),this.Ts.$s(this.Ms)}update(t){if(!this.Is(t))return;const i=this.Os,s=[],e=new Map,h=new Map;i.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 i=t,h=e.get(i.label);h?(h.label!==i.label&&h.Gi(i),h.position=o,h.items=[],n=h,s.push(h),e.delete(i.label)):(n=new y(this.options,i),n.position=o,s.push(n)),o++}else if("OPTION"===t.tagName){const i=t,e=`${i.value}::${i.text}`,r=h.get(e);if(r)r.Gi(i),r.position=o,i.__parentGroup&&n?(n.ss(r),r.group=n):(r.group=null,s.push(r)),h.delete(e);else{const t=new w(this.options,i);t.position=o,i.__parentGroup&&n?(n.ss(t),t.group=n):s.push(t)}o++}});let r=!0;0==this.Ss&&(r=!1),this.Ss=o,e.forEach(t=>{r=!1,t.destroy()}),h.forEach(t=>{r=!1,t.destroy()}),this.Os=s,this.Ms&&this.Ms.Vs(this.Os),this.refresh(r)}onUpdated(){}hi(t){this.Ms&&(this.Ms.ks=t)}refresh(t){this.Ts&&(this.Ts.refresh(t),this.onUpdated())}Zt(){return{Rs:this.Os,ti:this.Ms,Rt:this.Ts}}Ds(t){return this.Ms?.zs(t)}_s(t){return this.Ms?.Ns(t)}}class x extends r{constructor(t=null){super(),this.Us=null,this.ti=null,this.Us=t,this.init()}$s(t){this.ti=t,t.pi("items",()=>{this.clear()}),t.ui("items",()=>{this.Bs()}),t.mount(),this.mount(),this.Bs()}clear(){this.Us&&this.Us.replaceChildren()}Bs(){this.ti&&this.Us&&(this.ti.Gs(this.Us),this.update())}refresh(t){this.Bs()}destroy(){this.is(o.DESTROYED)||(this.ti?.destroy?.(),this.Us=null,this.ti=null,super.destroy())}}class O extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.options=null,this.Ws=null,this.qs=null,this.Wt=null,this.Js=[],t&&this.initialize(t)}initialize(t){this.options=t,this.init()}init(){this.state===o.NEW&&(this.bt=e.I({Ks:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.bt.view,super.init())}Qs(t){this.Ws=t,this.qs=t.parentElement,this.Ys(),this.mount()}mount(){this.is(o.INITIALIZED)&&super.mount()}Ys(){this.qs&&this.node&&this.Ws&&this.options&&this.qs.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Ws:this.Ws.nextSibling)}Xs(t){this.Wt=t}Zs(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?t.forEach(t=>{e.I({te:{tag:{node:"div",classList:["accessory-item"]},F:{ie:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:async i=>{i.preventDefault(),await(this.Wt?.Ds?.("select")),t.selected=!1}}},se:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)}):t=[],this.Js=t,this.ee(),this.update(),h.ot(window,"resize"))}update(){this.state===o.MOUNTED&&super.update()}ee(){this.options?.accessoryVisible&&this.Js.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.bt=null,this.node=null,this.options=null,this.Ws=null,this.qs=null,this.Wt=null,this.Js=[],super.destroy())}}class M extends r{constructor(t,i,s){super(),this.he=null,this.ne=null,this.oe=null,this.re=null,this.le={currentPage:0,totalPages:1,hasMore:!1,Hi:!1,ae:"",Si:!1},this.initialize(t,i,s)}initialize(t,i,s){this.select=t,this.Wt=i,this.re=s,this.init()}ce(){return!!this.he}async ue(t){if(!this.he)return{Li:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Li:!0,items:[]};try{const t=this.he;let s,e;if(s="function"==typeof t.de?t.de(i):{values:i.join(","),pe:"1",..."function"==typeof t.data?t.data.bind(this.re.ge.find(this.re.container.targetElement))("",0):t.data??{}},"POST"===(t.method??"GET")){const i=new URLSearchParams;Object.keys(s).forEach(t=>i.append(t,s[t]+"")),e=await fetch(t.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{const i=""+new URLSearchParams(s);e=await fetch(`${t.url}?${i}`)}if(!e.ok)throw Error("HTTP error! status: "+e.status);const h=await e.json(),n=this.fe(h);return this.update(),{Li:!0,items:n.items}}catch(s){return console.error("Load by values error:",s),{Li:!1,message:s?.message,items:[]}}}me(t){const i=Array.from(this.select.options).map(t=>t.value);return{be:t.filter(t=>i.includes(t)),ye:t.filter(t=>!i.includes(t))}}we(t){this.he=t}setPopup(t){this.oe=t}Ai(){return{...this.le}}ve(){this.le={currentPage:0,totalPages:1,hasMore:!1,Hi:!1,ae:"",Si:this.le.Si}}clear(){this.le.ae="";const{Rs:t}=this.Wt.Zt(),i=[];for(const s of t)s instanceof w?i.push(s):s instanceof y&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.he?this.xe(t,i):this.Oe(t)}async Ci(){return this.he?this.le.Hi?{Li:!1,message:"Already loading"}:this.le.Si?this.le.hasMore?(this.le.currentPage++,this.xe(this.le.ae,!0)):{Li:!1,message:"No more data"}:{Li:!1,message:"Pagination not enabled"}:{Li:!1,message:"Ajax not enabled"}}async Oe(t){this.Me(t)&&(this.le.ae=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{Rs:h}=this.Wt.Zt(),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=""===i||t.us.includes(s);t.visible=e,e&&(o=!0)}),this.update(),{Li:!0,Te:o,isEmpty:0===n.length}}Me(t){return t!==this.le.ae}async xe(t,i=!1){const s=this.he;this.Me(t)&&(this.ve(),this.le.ae=t,i=!1),this.le.Hi=!0,this.oe?.ei(),this.ne?.abort(),this.ne=new AbortController;const e=this.le.currentPage,h=Array.from(this.select.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof s.data?(n=s.data.bind(this.re.ge.find(this.re.container.targetElement))(t,e),n&&void 0===n.selectedValue&&(n.selectedValue=h)):n={search:t,page:e,selectedValue:h,...s.data??{}};try{let t;if("POST"===(s.method??"GET")){const i=new URLSearchParams;Object.keys(n).forEach(t=>i.append(t,n[t]+"")),t=await fetch(s.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.ne.signal})}else{const i=""+new URLSearchParams(n);t=await fetch(`${s.url}?${i}`,{signal:this.ne.signal})}const e=await t.json(),h=this.fe(e);return h.Ae?(this.le.Si=!0,this.le.currentPage=h.page,this.le.totalPages=h.totalPages,this.le.hasMore=h.hasMore):this.le.Si=!1,this.Se(h.items,!!s.keepSelected,i),this.le.Hi=!1,this.oe?.li(),this.update(),{Li:!0,Te:h.items.length>0,isEmpty:0===h.items.length,Ae:h.Ae,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.le.Hi=!1,this.oe?.li(),"AbortError"===o?.name?{Li:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Li:!1,message:o?.message})}}fe(t){let i=[],s=!1,e=0,h=1,n=!1;return t.object&&Array.isArray(t.object)?(i=t.object,void 0!==t.page&&(s=!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)?(i=t.data,void 0!==t.page&&(s=!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)?i=t:t.items&&Array.isArray(t.items)&&(i=t.items,t.pagination&&(s=!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:i.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.He||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 i=t.data??{};return t?.imgsrc&&(i.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:i}}),Ae:s,page:e,totalPages:h,hasMore:n}}Se(t,i,s=!1){const e=this.select;let h=[];i&&(h=Array.from(e.selectedOptions).map(t=>t.value)),s||(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 s=document.createElement("optgroup");s.label=t.label,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),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(i=>{e.dataset[i]=t.data[i]+""}),(t.selected||i&&h.includes(e.value))&&(e.selected=!0),s.appendChild(e)}),e.appendChild(s)}else{const s=document.createElement("option");s.value=t.value,s.text=t.text,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),(t.selected||i&&h.includes(s.value))&&(s.selected=!0),e.appendChild(s)}})}destroy(){this.is(o.DESTROYED)||(this.select=null,this.Wt=null,this.he=null,this.ne=null,this.oe=null,this.re=null,super.destroy())}}class T{constructor(t){this.Ce=null,this.Le=null,this.Pe=50,this.select=t,this.Le=this.Ie(),this.Ee=new MutationObserver(()=>{this.Ce&&clearTimeout(this.Ce),this.Ce=setTimeout(()=>{this.Fe()},this.Pe)})}Ie(){const t=Array.from(this.select.options);return{length:t.length,values:t.map(t=>t.value).join(","),je:t.map(t=>t.text).join(","),selected:t.map(t=>t.selected+"").join(",")}}$e(){const t=this.Ie(),i=JSON.stringify(t)!==JSON.stringify(this.Le);return i&&(this.Le=t),i}Fe(){this.$e()&&this.Pt(this.select)}connect(){this.Ee.observe(this.select,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.Ce&&clearTimeout(this.Ce),this.Ce=null,this.Ee.disconnect()}}class A{constructor(t){this.Ce=null,this.element=t,this.Ee=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.Ce&&clearTimeout(this.Ce),this.Ce=setTimeout(()=>{this.Pt({...this.element.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.element.dataset})})}connect(){this.Ee.observe(this.element,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.Ce&&clearTimeout(this.Ce),this.Ce=null,this.Ee.disconnect()}}class S extends r{constructor(t=[]){super(),this.items=[],this.Ve=e.m(12),this.ks=!1,this.items=t,this.init()}ke(t,i,s){const e=i;t.At?e?.update?.():e?.mount?.()}pi(t,i){e.Z.on(`${t}ing_${this.Ve}`,i,{st:0})}ui(t,i){e.Z.on(`${t}_${this.Ve}`,i,{st:0})}Ns(t,...i){return e.Z.run(`${t}_${this.Ve}`,...i)}zs(t,...i){return e.Z.run(`${t}ing_${this.Ve}`,...i)}Re(t,i){return null}De(){return this.items.length}async ze(t){await this.zs("items",t),this.items=t,await this.Ns("items",t),this.update()}async js(t){await this.ze(t)}Gs(t){for(let i=0;i<this.De();i++){const s=this.items[i];let e=s.view;s.At||(e=this.Re(t,s),s.view=e),this.ke(s,e,i),s.At=!0}}Vs(t){}destroy(){this.is(o.DESTROYED)||(this.Rt=null,this.items.forEach(t=>{t?.destroy?.()}),this.items=[])}}class H extends r{constructor(t){super(),this.parent=null,this.view=null,this.parent=t,this.init()}gs(){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.gs()?.remove?.(),this.parent=null,this.view=null,super.destroy())}}class C extends H{constructor(){super(...arguments),this.view=null}mount(){const t=e.m(7);this.view=e.P({_e:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},F:{Ne:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},Ue:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view),super.mount()}update(){this.Yi(),super.update()}Yi(t=null){this.view&&null!==t&&(this.view.tags.Ne.textContent=t)}Be(){if(!this.view)throw Error("GroupView has not been rendered.");return this.view.tags.Ue}es(){if(!this.view)return;const t=Array.from(this.view.tags.Ue.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",0===t.length)}Xi(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.Ne.setAttribute("aria-expanded",t?"false":"true"))}}class L extends H{constructor(t){super(t),this.view=null,this.config=null,this.Ge=null,this.We=!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.Ge=new Proxy(this.config,{set(i,s,e){if("string"!=typeof s)return!0;const h=s,n=i[h];return n!==e&&(i[h]=e,t.We&&t.qe(h,e,n)),!0}}),this.init()}get isMultiple(){return this.config.isMultiple}set isMultiple(t){this.Ge.isMultiple=!!t}get hasImage(){return this.config.hasImage}set hasImage(t){this.Ge.hasImage=!!t}get Je(){return this.Ge}set Je(t){if(!t||!this.Ge||!this.config)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this.config.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.config.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.config.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.config.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.config.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.config.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.Ge,i)}mount(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this.config.isMultiple&&t.push("multiple"),this.config.hasImage&&t.push("has-image","image-"+this.config.imagePosition);const h={fs:{tag:{node:"input",type:this.config.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this.config.hasImage&&{xs:{tag:{node:"img",classList:"option-image",style:{width:this.config.imageWidth,height:this.config.imageHeight,borderRadius:this.config.imageBorderRadius}}}},Ke:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this.config.labelValign,"align-horizontal-"+this.config.labelHalign]},F:{vs:{tag:{node:"div"}}}}};this.view=e.P({Qe:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},F:h}}),this.parent.appendChild(this.view.view),this.We=!0,super.mount()}qe(t,i,s){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.fs,o=e.tags?.Ke;switch(t){case"isMultiple":{const t=!!i;h.classList.toggle("multiple",t),n&&n.type!==(t?"checkbox":"radio")&&(n.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!i;if(h.classList.toggle("has-image",t),t)h.classList.add("image-"+this.config.imagePosition),this.Ye();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.xs;t?.remove(),e.tags.xs=null}break}case"imagePosition":this.config.hasImage&&(h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim(),h.classList.add("image-"+i));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const s=e.tags?.xs;s&&(s.style["imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius"]=i+"");break}case"labelValign":case"labelHalign":o&&(o.className=`align-vertical-${this.config.labelValign} align-horizontal-`+this.config.labelHalign)}}Ye(){const t=this.view;if(!t||!t.view)return;if(t.tags?.xs)return;const i=t.view,s=t.tags?.Ke,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,s?.parentElement?i.insertBefore(e,s):i.appendChild(e),t.tags.xs=e}}class P extends S{constructor(t=[]){super(t),this.isMultiple=!1,this.Xe=[],this.Ze=-1,this.th=null,this.groups=[],this.ih=[],this.sh()}init(){e.Z.on("sche_vis_"+this.Ve,()=>{const t=this.ih.filter(t=>t.visible).length,i=this.ih.length;this.Xe.forEach(s=>{s({eh:t,hh:i,ni:t>0,isEmpty:0===i})}),e.Z.run("sche_vis_proxy_"+this.Ve)},{st:10}),super.init(),this.mount()}sh(){this.ih=[],this.groups=[],this.items.forEach(t=>{t instanceof y?(this.groups.push(t),this.ih.push(...t.items)):t instanceof w&&this.ih.push(t)})}Re(t,i){return i instanceof y?new C(t):new L(t)}ke(t,i,s){t.position=s,t instanceof y?this.nh(t,i,s):t instanceof w&&this.oh(t,i,s),t.At=!0}nh(t,i,s){super.ke(t,i,s),t.view=i;const e=i.view.tags.Ne;e.textContent=t.label,t.At||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.ts()}),t.Zi((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.gs?.();i&&(i.style.display=s?"none":"")}),this.rh(i,s)}));const h=i.Be();t.items.forEach((t,i)=>{let s=t.view;t.At&&s||(s=new L(h)),this.oh(t,s,i),t.At=!0}),i.Xi(t.collapsed),i.es()}oh(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.Je={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.At||super.ke(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.xs;s&&(s.src!==t.ds&&(s.src=t.ds),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.vs.innerHTML=t.text,t.At||(i.view.tags.Qe.addEventListener("click",async i=>{i.stopPropagation(),i.preventDefault(),this.ks||(this.isMultiple?(await this.zs("select"),t.selected=!t.selected):!0!==t.selected&&(await this.zs("select"),this.th&&(this.th.selected=!1),t.selected=!0))}),i.view.tags.Qe.title=t.textContent,i.view.tags.Qe.addEventListener("mouseenter",()=>{this.ks||this.ah(this.ih.indexOf(t),!1)}),t.ys(()=>{this.Ns("selected")}),t.ws((i,s,e)=>{e&&(this.th=t),this.Ns("selected_internal")}),t.ci((t,i)=>{i.group?.es(),this.uh()})),t.selected&&(this.th=t,t.ps=!0)}async ze(t){await this.zs("items",t),this.items=t,this.sh(),await this.Ns("items",t),this.update()}async js(t){await this.ze(t)}Vs(t){this.items=t,this.sh(),this.update()}destroy(){this.is(o.DESTROYED)||(e.Z.clear("sche_vis_"+this.Ve),this.groups.forEach(t=>{t.destroy()}),this.Xe=[],this.Ze=-1,this.th=null,this.groups=[],this.ih=[],super.destroy())}dh(){return this.ih.filter(t=>t.selected)}ph(){return this.ih.find(t=>t.selected)}ii(t){this.isMultiple&&this.ih.forEach(i=>{i.selected=t})}ci(t){this.Xe.push(t)}uh(){e.Z.run("sche_vis_"+this.Ve)}oi(){const t=this.ih.filter(t=>t.visible).length,i=this.ih.length;return{eh:t,hh:i,ni:t>0,isEmpty:0===i}}gh(){this.ah(0)}navigate(t,i=!0){const s=this.ih.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.ih[this.Ze]);-1===e&&(e=-1);let h=e+t;h>=s.length&&(h=0),h<0&&(h=s.length-1);const n=this.ih.indexOf(s[h]);this.ah(n,i)}fh(){if(this.Ze>-1&&this.ih[this.Ze]){const t=this.ih[this.Ze];if(t.visible){const i=t.view?.gs?.();i&&i.click()}}}ah(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof w){const i=this.ih.indexOf(t);s=i>-1?i:0}else s=0;this.Ze>-1&&this.ih[this.Ze]&&(this.ih[this.Ze].bs=!1);for(let e=s;e<this.ih.length;e++){const t=this.ih[e];if(t?.visible){if(t.bs=!0,this.Ze=e,i){const i=t.view?.gs?.();i?i.scrollIntoView({block:"center",behavior:"smooth"}):this.Rt?.mh?.(e,{scrollIntoView:!0})}return void this.bh(e,t.view?.gs?.()?.id)}}}bh(t,i){}rh(t,i){}}class I extends r{constructor(t=0){super(),this.yh=[],this.wh=0,this.initialize(t)}initialize(t){this.init(),this.reset(t)}reset(t){this.wh=t,this.yh=Array(t+1).fill(0)}add(t,i){for(let s=t;s<=this.wh;s+=s&-s)this.yh[s]+=i}xh(t){let i=0;for(let s=t;s>0;s-=s&-s)i+=this.yh[s];return i}Oh(t,i){return i<t?0:this.xh(i)-this.xh(t-1)}Mh(t){this.reset(t.length),t.forEach((t,i)=>this.add(i+1,t))}Th(t){let i=0,s=1;for(;s<<1<=this.wh;)s<<=1;let e=0;for(let h=s;0!==h;h>>=1){const s=i+h;s<=this.wh&&e+this.yh[s]<=t&&(i=s,e+=this.yh[s])}return i}}class E extends x{constructor(t=null){super(t),this.Ah={Xt:void 0,Ut:36,Bt:8,Gt:!0,Sh:!0},this.Hh=[],this.Ch=new I(0),this.Lh=new Map,this.Ph=!1,this.start=0,this.end=-1,this.Ih=null,this.Eh=null,this.updating=!1,this.Fh=!1,this.jh=0,this.$h=!1,this.Vh=!1,this.kh=0,this.Rh=0,this.Dh=0,this.zh=0}configure(t){this.Ah={...this.Ah,...t}}$s(t){if(this.ti&&this.dispose(),super.$s(t),t.Rt=this,!this.Us)return;this.Us.replaceChildren();const i=e.I({_h:{tag:{node:"div",classList:"selective-ui-virtual-pad-top"}},Nh:{tag:{node:"div",classList:"selective-ui-virtual-items"}},Uh:{tag:{node:"div",classList:"selective-ui-virtual-pad-bottom"}}},this.Us);if(this._h=i._h,this.Nh=i.Nh,this.Uh=i.Uh,this.Xt=this.Ah.Xt??this.Us.closest(".selective-ui-popup")??this.Us.parentElement,!this.Xt)throw Error("VirtualRecyclerView: scrollEl not found");this.Bh=this.Gh.bind(this),this.Xt.addEventListener("scroll",this.Bh,{passive:!0}),this.refresh(!1),this.Wh(),t?.ci?.(()=>this.qh())}suspend(){this.$h=!0,this.Jh(),this.Xt&&this.Bh&&this.Xt.removeEventListener("scroll",this.Bh),this.Kh&&(this.Kh.disconnect(),this.Vh=!0)}resume(){this.$h=!1,this.Xt&&this.Bh&&this.Xt.addEventListener("scroll",this.Bh,{passive:!0}),this.Vh&&(this.Wh(),this.Vh=!1),this.Qh()}refresh(t){if(!this.ti||!this.Us)return;t||this.qh();const i=this.ti.De();if(this.jh=i,0===i)return this.Yh(),void this.update();this.Hh.length=i,this.Ph||(this.Xh(),this.Ph=!0),this.Zh(i),this.Qh(),this.update()}mh(t,i){this.tn(t,t),i?.scrollIntoView&&this.sn(t)}sn(t){if((this.ti?.De?.()??0)<=0)return;const i=this.en(t),s=this.hn()+i,e=Math.max(0,this.Xt.scrollHeight-this.Xt.clientHeight);this.Xt.scrollTop=Math.min(Math.max(0,s),e)}dispose(){this.Jh(),this.Xt&&this.Bh&&this.Xt.removeEventListener("scroll",this.Bh),this.Kh?.disconnect(),this.Lh.forEach(t=>t.remove()),this.Lh.clear()}destroy(){this.is(o.DESTROYED)||(this.Yh(),this.dispose(),this._h.remove(),this.Nh.remove(),this.Uh.remove(),this._h=null,this.Nh=null,this.Uh=null,super.destroy())}qh(){if(!this.ti)return;const t=this.ti.De();t<=0||(this.suspend(),this.Yh(),this.nn(),this.rn(t),this.Zh(t),this.start=0,this.end=-1,this.resume())}Jh(){null!=this.Ih&&(cancelAnimationFrame(this.Ih),this.Ih=null),null!=this.Eh&&(cancelAnimationFrame(this.Eh),this.Eh=null)}Yh(){this.Lh.forEach(t=>t.remove()),this.Lh.clear(),this.Hh=[],this.Ch.reset(0),this._h.style.height="0px",this.Uh.style.height="0px",this.Ph=!1,this.Dh=0,this.zh=0}Xh(){this.ln(0);const t=this.Lh.get(0);if(!t)return;const i=this.an(t);if(isNaN(i)||(this.Ah.Ut=i),!this.Ah.Gt){t.remove(),this.Lh.delete(0);const i=this.ti.items[0];i&&(i.At=!1,i.view=null)}}cn(t){const i=this.ti?.items?.[t];return i?.visible??!0}un(t,i){for(let s=Math.max(0,t);s<i;s++)if(this.cn(s))return s;return-1}rn(t){this.Dh=0,this.zh=0;for(let i=0;i<t;i++){if(!this.cn(i))continue;const t=this.Hh[i];null!=t&&(this.Dh+=t,this.zh++)}}hn(){const t=this.Us.getBoundingClientRect(),i=this.Xt.getBoundingClientRect();return Math.max(0,t.top-i.top+this.Xt.scrollTop)}dn(){const t=performance.now();if(t-this.kh<16)return this.Rh;const i=this.Xt.querySelector(".selective-ui-option-handle:not(.hide)");return this.Rh=i?.offsetHeight??0,this.kh=t,this.Rh}Qh(){null!=this.Ih||this.$h||(this.Ih=requestAnimationFrame(()=>{this.Ih=null,this.pn()}))}an(t){const i=t.getBoundingClientRect(),s=getComputedStyle(t);return Math.max(1,i.height+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}gn(){return this.Ah.Sh&&this.zh>0?Math.max(1,this.Dh/this.zh):this.Ah.Ut}Zh(t){const i=this.gn(),s=Array.from({length:t},(t,s)=>this.cn(s)?this.Hh[s]??i:0);this.Ch.Mh(s)}fn(t,i){if(!this.cn(t))return!1;const s=this.gn(),e=this.Hh[t]??s;if(Math.abs(i-e)<=E.mn)return!1;const h=this.Hh[t];return null==h?(this.Dh+=i,this.zh++):this.Dh+=i-h,this.Hh[t]=i,this.Ch.add(t+1,i-e),!0}bn(t,i){const s=this.Ch.Th(Math.max(0,t)),e=Math.min(i-1,s),h=this.un(e,i);return-1===h?Math.max(0,e):h}yn(t,i){i.setAttribute(E.wn,t+"");const s=this.Lh.get(t-1);if(s?.parentElement===this.Nh)return void s.after(i);const e=this.Lh.get(t+1);if(e?.parentElement===this.Nh)return void this.Nh.insertBefore(i,e);const h=Array.from(this.Nh.children);for(const n of h){const s=n.getAttribute(E.wn);if(s&&+s>t)return void this.Nh.insertBefore(i,n)}this.Nh.appendChild(i)}vn(t,i){if(i.parentElement!==this.Nh)return void this.yn(t,i);i.setAttribute(E.wn,t+"");const s=i.previousElementSibling,e=i.nextElementSibling;(s&&+s.getAttribute(E.wn)>t||e&&+e.getAttribute(E.wn)<t)&&(i.remove(),this.yn(t,i))}Wh(){this.Kh||(this.Kh=new ResizeObserver(()=>{this.Fh||this.$h||!this.ti||null!=this.Eh||(this.Eh=requestAnimationFrame(()=>{this.Eh=null,this.xn()}))}),this.Kh.observe(this.Nh))}xn(){if(!this.ti)return;const t=this.ti.De();if(t<=0)return;let i=!1;for(let s=this.start;s<=this.end;s++){if(!this.cn(s))continue;const t=this.ti.items[s],e=t?.view?.gs?.();if(!e)continue;const h=this.an(e);this.fn(s,h)&&(i=!0)}i&&(this.Ah.Sh&&this.Zh(t),this.Qh())}Gh(){this.Qh()}pn(){if(!this.updating&&!this.$h){this.updating=!0;try{if(!this.ti)return;const t=this.ti.De();if(t<=0)return;this.jh!==t&&(this.jh=t,this.Hh.length=t,this.Zh(t));const i=this.hn(),s=Math.max(0,this.Xt.scrollTop-i),e=this.dn(),h=Math.max(0,this.Xt.clientHeight-e),n=this.bn(s,t),o=this.en(n),r=i+o-this.Xt.scrollTop,l=this.bn(s,t);if(-1===l)return void this.Yh();const a=this.gn(),c=this.Ah.Bt*a;let u=this.un(Math.min(t-1,this.Ch.Th(Math.max(0,s-c))),t)??l,d=Math.min(t-1,this.Ch.Th(s+h+c));if(u===this.start&&d===this.end)return;this.start=u,this.end=d,this.Fh=!0;try{this.tn(this.start,this.end),this.On(this.start,this.end),this.Ah.Gt&&this.xn();const i=this.en(this.start),s=this.Mn(this.start,this.end),e=this.Tn(t),h=Math.max(0,e-i-s);this._h.style.height=i+"px",this.Uh.style.height=h+"px"}finally{this.Fh=!1}const p=this.en(n),g=this.hn()+p-r,f=Math.max(0,this.Xt.scrollHeight-this.Xt.clientHeight),m=Math.min(Math.max(0,g),f),b=Math.abs(p-o)>1,y=Math.abs(this.Xt.scrollTop-m);b&&y>.5&&y<100&&(this.Xt.scrollTop=m)}finally{this.updating=!1}}}tn(t,i){for(let s=t;s<=i;s++)this.ln(s)}ln(t){if(!this.cn(t)){const i=this.Lh.get(t);return i?.parentElement===this.Nh&&i.remove(),void this.Lh.delete(t)}const i=this.ti.items[t];if(!i)return;const s=this.Lh.get(t);if(s)return void(i?.view?(this.vn(t,s),this.ti.ke(i,i.view,t)):(s.remove(),this.Lh.delete(t)));if(i.At)i.view&&this.ti.ke(i,i.view,t);else{const s=this.ti.Re(this.Nh,i);i.view=s,this.ti.ke(i,s,t),i.At=!0}const e=i.view?.gs?.();e&&(this.vn(t,e),this.Lh.set(t,e))}On(t,i){this.Lh.forEach((s,e)=>{(e<t||e>i)&&(s.parentElement===this.Nh&&s.remove(),this.Lh.delete(e))})}nn(){this.Lh.forEach((t,i)=>{this.cn(i)||(t.parentElement===this.Nh&&t.remove(),this.Lh.delete(i))})}en(t){return this.Ch.xh(t)}Mn(t,i){return this.Ch.Oh(t+1,i+1)}Tn(t){return this.Ch.xh(t)}}E.mn=.5,E.wn="data-vindex";class F extends r{constructor(t=null,i=null){super(),this.container={},this.oldValue=null,this.node=null,this.options=null,this.An=null,this.isOpen=!1,this.Sn=!1,this.Hn=!1,this.ge=null,t&&i&&this.initialize(t,i)}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?.Mi?.setAttribute("aria-disabled",t+""))}get Cn(){return!!this.options?.readonly}set Cn(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,i){const s=e.R(t);this.options=s.options,this.ge=i,this.init(t)}init(t){if(this.state!==o.NEW)return;if(!t||!this.options)return;const s=this.options,h=new l(s),n=new a,r=new f(s),effector=i(),c=new v(s),u=new O(s),d=new M(t,c,this),p=new T(t),m=new A(t);h.node&&(h.node.id=(s.Ln??"")+"");const b=e.I({Pn:{tag:{node:"div",classList:"selective-ui-MAIN"},F:{Mi:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.In()?.open())}},F:{En:{tag:h.node},Fn:{tag:n.node},ki:{tag:r.node}}}}}},null);this.container=b,this.node=b.view,b.jn=d,b.placeholder=h,b.$n=n,b.Vn=r,b.effector=effector,b.targetElement=t,b.kn=u,b.Rn=p,b.Dn=m,c.Hs(P),c.Ls(s.virtualScroll?E:x),c.Fs(e.K(t)),c.onUpdated=()=>{b.oe?.ri?.()},this.An=c,b.oe=new g(t,s,c),b.oe.fi(effector),b.oe.Ti(d,s),b.oe.gi("selected",()=>{this.In()?.change(null,!0)}),b.oe.gi("selected_internal",()=>{this.In()?.change(null,!1)}),b.oe.di("select",()=>{this.oldValue=this.In()?.value??""}),u.Qs(b.tags.Mi),u.Xs(c),this.zn(t,b,s,d,r),this._n(p,m,t,c),this.isDisabled=e.$(s.disabled),this.Cn=e.$(s.readonly),super.init()}mount(){if(this.state!==o.INITIALIZED)return;if(!this.node||!this.container.targetElement)return;const t=this.container.targetElement,i=this.container;t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,i.tags.Mi),i.tags.Mi.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.lt(t,i.tags.Mi),t.classList.add("init"),this.In()?.change(null,!1),super.mount()}update(){this.state===o.MOUNTED&&(this.container.oe?.ri?.(),super.update())}zn(t,i,s,h,n){const o=i.oe.Et;let r=null;const l=(t,n)=>{n||""!==t?(""!==t&&(this.Hn=!0),h.search(t).then(t=>{clearTimeout(r),e.Z.clear("sche_vis_proxy_"+o.Ve),e.Z.on("sche_vis_proxy_"+o.Ve,()=>{i.oe?.ri?.(),t?.Te&&(r=setTimeout(()=>{o.gh(),i.oe?.ri?.()},s.animationtime??0))},{st:10})}).catch(t=>{console.error("Search error:",t)})):h.clear()};let a=null;n.Fi=(t,e)=>{h.Me(t)&&(a&&clearTimeout(a),h.ce()?(i.oe?.ei?.(),a=setTimeout(()=>{l(t,e)},s.delaysearchtime??0)):a=setTimeout(()=>{l(t,e)},10))},h.setPopup(i.oe),n.ji=t=>{o.navigate(t)},n.$i=()=>{o.fh()},n.Vi=()=>{this.In()?.close(),i.tags.Mi.focus()},o.bh=(t,i)=>{i&&n.Di(i)},o.rh=()=>{i.oe?.ri?.()},s.ajax&&h.we(s.ajax)}_n(t,i,s,h){t.connect(),t.Pt=t=>{h.update(e.K(t)),this.In()?.refreshMask()},i.connect(),i.Pt=t=>{e.$(t.disabled)!==this.isDisabled&&(this.isDisabled=e.$(t.disabled)),e.$(t.readonly)!==this.Cn&&(this.Cn=e.$(t.readonly)),e.$(t.visible)!==this.isVisible&&(this.isVisible=e.$(t.visible??"1"))}}Nn(){const t=this.container??{},{Rn:i,Dn:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}destroy(){if(this.is(o.DESTROYED))return;this.Nn();const t=this.container;t.jn.destroy(),t.$n.destroy(),t.oe.destroy(),t.kn.destroy(),t.placeholder.destroy(),t.Vn.destroy(),this.node?.remove(),this.container={},this.node=null,this.options=null,this.An=null,this.ge=null,this.oldValue=null,this.isOpen=!1,this.Sn=!1,this.Hn=!1,super.destroy()}In(){const t=this.container,i=this,s=()=>this.ge.find(t.targetElement),n=e.R(t.targetElement);if(!n)return null;const r=n.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.Vn?.Ri(i)},get oldValue(){return i.oldValue},set value(t){this.setValue(null,t,!0)},get value(){const t=this.valueArray,i=t.length;return i>1?t:0===i?"":t[0]},get valueArray(){const t=[];return i.Un().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(r.customDelimiter)},get valueOptions(){const t=[];return i.Un(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Un(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Un(!0).forEach(i=>{t.push(i.text)});const s=t.length;return s>1?t:0===s?"":t[0]},get isOpen(){return i.isOpen},getParent:()=>t.view.parentElement,valueDataset(t,s=null,e=!1){var h=[];if(i.Un(!0).forEach(t=>{h.push(s?t.dataset[s]: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&&i.Un().length>r.maxSelected)&&!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Un().forEach(t=>{t.ps=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Un().forEach(t=>{t.ps=!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 i.Un().forEach(t=>t.ps=!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.jn?.ce?.()){const{ye:s}=t.jn.me(n);if(s.length>0)return void(async()=>{r.loadingfield&&t.oe?.ei?.();try{t.jn.ve();const e=await t.jn.ue(s);e.Li&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.jn.Se?.(e.items,!0,!0),setTimeout(()=>{i.Un().forEach(t=>{t.ps=n.some(i=>i==t.value)}),this.change(!1,!1)},100)):s.length>0&&console.warn(`Could not load ${s.length} values:`,s)}catch(e){console.error("Error loading missing values:",e)}finally{r.loadingfield&&t.oe?.li?.()}})()}if(o){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Un().forEach(t=>{t.ps=n.some(i=>i==t.value)}),!r.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,o)}},open(){if(i.isOpen)return;const e=i.ge?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(h.nt([s()],...r.on.beforeShow).isCancel)return;i.isOpen=!0,t.$n.ft(!0);const n=t.oe.Et,o=n.ph();o?n.ah(o,!1):n.gh(),i.Sn&&!i.Hn||!r?.ajax?t.oe.open(null,!0):(t.jn.ve(),t.oe.ei(),i.Sn=!0,i.Hn=!1,setTimeout(()=>{t.oe&&t.jn&&t.jn.search("").then(()=>t.oe?.ri?.()).catch(t=>console.error("Initial ajax load error:",t))},r.animationtime),t.oe.open(null,!1)),t.Vn.show();const l=t.tags.Mi;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",r.Kt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",r.Ln),r.multiple&&l.setAttribute("aria-multiselectable","true"),h.nt([s()],...r.on.show)},close(){i.isOpen&&(h.nt([s()],...r.on.beforeClose).isCancel||(i.isOpen=!1,t.$n.ft(!1),t.oe.close(()=>{t.Vn.clear(!1)}),t.Vn.hide(),t.tags.Mi.setAttribute("aria-expanded","false"),h.nt([s()],...r.on.close)))},toggle(){i.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.nt([s(),this.value],...r.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.kn.Zs(this.valueOptions),n&&(t.targetElement&&h.ot(t.targetElement,"change"),h.nt([s(),this.value],...r.on.change),i.options?.autoclose&&this.close()),i.is(o.MOUNTED)&&i.update()},refreshMask(){let s=r.placeholder;!r.multiple&&i.Un().length>0&&(s=this.mask[0]),s??(s=r.placeholder),t.placeholder.set(s,!1),t.Vn.Ri(s)},on(t,i,s){r.on[i]||(r.on[i]=[]),r.on[i].push(s)},ajax(i,s){t.jn.we(s)},loadAjax:()=>new Promise((e,h)=>{t.oe.ei(),t.jn.ve(),i.Sn=!0,i.Hn=!1,t.oe&&t.jn?t.jn.search("").then(()=>{t.oe?.ri?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(s())})};return this.Bn(l,"disabled","isDisabled"),this.Bn(l,"readonly","isReadOnly"),this.Bn(l,"visible","isVisible"),l}Bn(t,i,s){const e=this;Object.defineProperty(t,i,{get:()=>e[s],set(t){e[s]=!!t,e.container?.targetElement?.dataset&&(e.container.targetElement.dataset[i]=!!t+"")},enumerable:!0,configurable:!0})}Un(t=null){if(!this.An)return[];const{Rs:i}=this.An.Zt(),s=[];for(const e of i)e instanceof w?s.push(e):e instanceof y&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}}class j{constructor(){this.isActive=!1,this.Ee=null,this.actions=[]}Gn(t){this.actions.push(t)}Wn(){this.actions=[]}connect(t){if(this.isActive)return;this.isActive=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.Ee=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.qn(e),e.querySelectorAll(s).forEach(t=>this.qn(t))})}),this.Ee.observe(document.body,{childList:!0,subtree:!0})}disconnect(){this.isActive&&(this.isActive=!1,this.Ee?.disconnect(),this.Ee=null)}qn(t){this.actions.forEach(i=>i(t))}}class $ extends r{constructor(){super(),this.Jn=new Map,this.init()}init(){this.is(o.NEW)&&(this.Jn=new Map,super.init())}bind(t,i){this.is(o.NEW)&&this.init();const s=e.V(e.B(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.Jn.set(t,s);const n=e.m();e.Z.on(n,()=>{h.nt([this.find(t)],...s.on.load),e.Z.clear(n),s.on.load=[]});const r=e.v(t);let l=!1;r.forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e._(t),this.Kn(t,s)&&(l=!0,e.Z.run(n)))})()}),e.G().includes(t)||e.G().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 i={isEmpty:!0};if("*"===t&&""===(t=e.G().join(", ")))return i;const s=e.v(t);if(0===s.length)return i;const h=e.R(s[0]);if(!h||!h.action)return i;const n={};for(const e in h.action)n[e]=this.Qn(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.Yn(o,t.name,s);break;case"func":this.Xn(o,t.name,s)}}return o}Zn(){this.io||(this.io=new j,this.io.Gn(t=>{this.Jn.forEach((i,s)=>{try{t.matches(s)&&(this.Kn(t,i),this.is(o.MOUNTED)&&this.update())}catch(e){console.warn("Invalid selector: "+s,e)}})})),this.io.connect("select")}destroy(t=null){null===t?this.so():"string"==typeof t?this.eo(t):t instanceof HTMLSelectElement&&this.ho(t),null!==t&&this.is(o.MOUNTED)&&this.update()}so(){this.state!==o.DESTROYED&&(e.G().forEach(t=>this.eo(t)),this.Jn.clear(),e.G().length=0,this.io?.disconnect(),super.destroy())}eo(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.ho(t)}),this.Jn.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}ho(t){const i=e.R(t);if(!i)return;const s=i.self;e.U(t,i);const h=!!this.io;h&&this.io?.disconnect();try{i.self?.Nn?.()}catch(o){}const n=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.no,n&&n.parentNode?n.parentNode.replaceChild(t,n):t.appendChild(t),e.k(t),h&&this.Jn.size>0&&this.io?.connect("select"),s?.destroy?.()}rebind(t,i){this.eo(t),this.bind(t,i),this.is(o.MOUNTED)&&this.update()}Kn(t,i){if(e.R(t)||e.N(t))return!1;const s=e.m(8),h=e.j(t,i);h.oo=s,h.Kt=`seui-${s}-optionlist`,h.Ln=`seui-${s}-placeholder`;const n={options:h};e.D(t,n);const o=new F(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.In(),n.self=o,!0}Qn(t,i){const s=Object.getOwnPropertyDescriptor(i,t);let e="variable";return s?.get||s?.set&&"function"!=typeof i[t]?e="get-set":"function"==typeof i[t]&&(e="func"),{type:e,name:t}}Yn(t,i,s){Object.defineProperty(t,i,{get(){const t=e.R(s[0]);return t.action?.[i]},set(t){s.forEach(s=>{const h=e.R(s);h?.action&&(h.action[i]=t)})},enumerable:!0,configurable:!0})}Xn(t,i,s){t[i]=(...n)=>{let o=null;for(let t=0;t<s.length;t++){const r=e.R(s[t]);if(!r?.action)continue;const l=h.ht();if(o??(o=r.action[i](l.et,...n)),!l.token.isContinue)break}return o??t}}}if(void 0===globalThis.GLOBAL_SEUI){const k=new $;globalThis.GLOBAL_SEUI={version:"1.2.4",name:"SelectiveUI",bind:k.bind.bind(k),find:k.find.bind(k),destroy:k.destroy.bind(k),effector:i.bind(i),rebind:k.rebind.bind(k)};let R=!1;function D(){R||(R=!0,document.addEventListener("mousedown",()=>{const t=e.G();if(t.length>0){const i=k.find(t.join(", "));i.isEmpty||i.close()}}),k.Zn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",D):D()),console.log("[SelectiveUI] v1.2.4 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,i={})=>{globalThis.GLOBAL_SEUI.bind(t,i)},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,i={})=>{globalThis.GLOBAL_SEUI.rebind(t,i)},t.version=version},"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).SelectiveUI={});
|
|
1
|
+
/*! Selective UI v1.2.5 | MIT License */
|
|
2
|
+
var t,i;t=this,i=function(t){"use strict";function i(t){return new m(t??null)}class s{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 s),this.u}static p(t){if(null===t||"object"!=typeof t)return t;const i=Array.isArray(t)?[]:{};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=this.p(t[s]));return i}static m(t=6){let i="";for(let s=0;s<t;s++)i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return i}static v(t){if(!t)return[];if("string"==typeof t){const i=document.querySelectorAll(t);return Array.from(i)}return t instanceof Element?[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,i=null,s=!1){const e={...i??{}},h=s?t:this.O(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 i=e[t];i&&"object"==typeof i&&Object.assign(h[t],i),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.A&&(h.setAttribute("aria-labelledby",e.A+""),delete e.A),e.S&&(h.setAttribute("aria-controls",e.S+""),delete e.S),e.H&&(h.setAttribute("aria-haspopup",e.H+""),delete e.H),e.C&&(h.setAttribute("aria-multiselectable",e.C+""),delete e.C),e.L&&(h.setAttribute("aria-autocomplete",e.L+""),delete e.L),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,i])=>{h.addEventListener(t,i)}),delete e.event),Object.entries(e).forEach(([t,i])=>{null===i?h.removeAttribute(t):h[t]=i}),h}static O(t){if(t instanceof Element)return t;throw new TypeError("Node is not an Element")}static P(t){return this.I(t)}static I(t,i=null,s=!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?.F&&this.I(r.F,l,!1,!1,h),i?s?i.prepend(l):i.append(l):e||n||(n=l)}return e||(h.id=this.m(7),i||(h={tags:h,view:n})),h}static j(t,i){const s=this.p(i);for(const e in s){const i=t[e];i?s[e]="boolean"==typeof s[e]?this.V(i):i:void 0!==t?.dataset?.[e]&&(s[e]="boolean"==typeof s[e]?this.V(t.dataset[e]):t.dataset[e])}return s}static $(...t){if(0===t.length)return{};if(1===t.length)return this.p(t[0]);const i=this.p(t[0]);for(let s=1;s<t.length;s++){const e=t[s];for(const t in e)if("on"===t){const s=e[t];for(const e in s)i[t][e].push(s[e])}else i[t]=e[t]}return i}static V(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 k(t){return this.l.i.delete(t)}static R(t){return this.l.i.get(t)}static D(t,i){this.l.i.set(t,i)}static _(t){return this.l.h.delete(t)}static B(t){return this.l.h.get(t)}static N(t,i){this.l.h.set(t,i)}static U(){return this.l.t}static G(){return this.l.o}static W(t){if(null==t)return"";let i=(t+"").replace(/<`/g,"<").replace(/`>/g,">").replace(/\<\`/g,"<").replace(/\`\>/g,">").trim();const s=globalThis?.document;if(!s||"function"!=typeof s.createElement)return i=i.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,""),i=i.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,""),i=i.replace(/\s([a-z-:]+)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,""),i;const e=s.createElement("div");return e.innerHTML=i,e.querySelectorAll("script, style, iframe, object, embed, link").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const i in t.attributes){const s=t.attributes[i],e=s.name??"",h=s.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 q(t){const i=document.createElement("DIV");i.innerHTML=t;const s=i.textContent??i.innerText??"";return i.remove(),s.trim()}static K(t){return null==t?"":(t+"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"d")}static Y(t){const i=[];return Array.from(t.children).forEach(t=>{if("OPTGROUP"===t.tagName){const s=t;i.push(s),Array.from(s.children).forEach(t=>{t.__parentGroup=s,i.push(t)})}else"OPTION"===t.tagName&&i.push(t)}),i}static J(){const t=navigator.userAgent;return/iP(hone|ad|od)/.test(t)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1}static X(t){const i=(t+"").trim();if(i.endsWith("px"))return i;if(i.endsWith("vh"))return window.innerHeight*parseFloat(i)/100+"px";if(i.endsWith("vw"))return window.innerWidth*parseFloat(i)/100+"px";const s=parseFloat(getComputedStyle(document.documentElement).fontSize);if(i.endsWith("rem"))return s*parseFloat(i)+"px";const e=this.M({node:"div",style:{height:i,opacity:"0"}});document.body.appendChild(e);const h=e.offsetHeight+"px";return e.remove(),h}}e.u=null,e.Z=new class{constructor(){this.tt=new Map,this.it=new Map}on(t,i,s={}){const e=s.st??50,h=s.once??!1;this.tt.has(t)||this.tt.set(t,[]),this.tt.get(t).push({et:i,timeout:e,once:h})}off(t){const i=this.it.get(t);if(i){for(const t of i.values())clearTimeout(t);i.clear(),this.it.delete(t)}this.tt.delete(t)}run(t,...i){const s=this.tt.get(t);if(!s||0===s.length)return Promise.resolve();this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t),h=[];for(let n=0;n<s.length;n++){const t=s[n];if(!t)continue;const o=e.get(n);o&&clearTimeout(o);const r=new Promise(h=>{const o=setTimeout(async()=>{try{const s=t.et(i.length>0?i:null);s instanceof Promise&&await s}catch{}finally{if(t.once){s[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 i of Array.from(this.tt.keys()))this.off(i);else this.off(t)}};class h{static ht(){const t={isContinue:!0,isCancel:!1};return{token:{get isContinue(){return t.isContinue},get isCancel(){return t.isCancel}},et:{stopPropagation(){t.isContinue=!1},cancel(){t.isCancel=!0,t.isContinue=!1}}}}static nt(t,...i){const{token:s,et:e}=this.ht();for(let h=0;h<i.length;h++){const n=i[h];if("function"==typeof n&&(t&&Array.isArray(t)?n(e,...t):n(e),s.isCancel||!s.isContinue))break}return s}static ot(t,i,s={bubbles:!0,cancelable:!0}){const e=new Event(i,s);return t.dispatchEvent(e),e}static rt(t,...i){if(Array.isArray(t))for(const s of t)"function"==typeof s&&s(...i)}}class n{static lt(t,i){const s=e.R(t);if(!s?.options)return;const h=s.options,n=h.minWidth,o=h.minHeight,r=Number.parseInt(h.width,10),l=Number.parseInt(h.height,10);let a=t.offsetWidth+"px",c=t.offsetHeight+"px";const u=getComputedStyle(t);"0px"===a&&"auto"!==u.width&&(a=u.width),"0px"===c&&"auto"!==u.height&&(c=u.height),r>0&&(a=h.width),l>0&&(c=h.height),Object.assign(i.style,{width:a,height:c,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.ct=new Map,this.ct.set("onInit",new Set),this.ct.set("onMount",new Set),this.ct.set("onUpdate",new Set),this.ct.set("onDestroy",new Set)}on(t,i){return this.ct.get(t).add(i),this}off(t,i){return this.ct.get(t).delete(i),this}emit(t,i){const s={state:this.state,ut:i};for(const h of this.ct.get(t))try{h(s)}catch(e){this.dt(e,t)}}dt(t,i){console.error(`[Lifecycle:${i}]`,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.gt()}getState(){return this.state}is(t){return this.state===t}gt(){for(const t of this.ct.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:"selective-ui-placeholder",innerHTML:t.placeholder}),this.options=t,this.init()}get(){return this.options?.placeholder??""}set(t,i=!0){if(!this.node||!this.options)return;i&&(this.options.placeholder=t);const s=e.W(t);this.node.innerHTML=this.options.allowHtml?s:e.q(s)}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:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"}),super.init(),this.mount()}ft(t){this.node.classList.toggle("drop-down",!!t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.node=null,super.destroy())}}class c extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.options=null,this.yt=[],this.wt=[],t&&this.initialize(t)}initialize(t){this.bt=e.I({vt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},F:{xt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.rt(this.yt)}}},Mt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.rt(this.wt)}}}}}}),this.node=this.bt.view,this.options=t,this.init()}available(){return!!this.options&&e.V(this.options.multiple)&&e.V(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")}Tt(t=null){"function"==typeof t&&this.yt.push(t)}Ot(t=null){"function"==typeof t&&this.wt.push(t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.options=null,this.yt=null,this.wt=null,this.node=null,super.destroy())}}class u 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:["selective-ui-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:["selective-ui-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.At=!1,this.element=null,this.St=null,this.Ht=null,this.At=!0,this.Ct=this.Lt.bind(this)}Pt(t){}Lt(){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 i=t.getBoundingClientRect(),s="undefined"!=typeof window&&"function"==typeof window.getComputedStyle?window.getComputedStyle(t):null;this.Pt({width:i?.width??0,height:i?.height??0,top:i?.top??0,left:i?.left??0,padding:{top:parseFloat(s?.paddingTop??"0"),right:parseFloat(s?.paddingRight??"0"),bottom:parseFloat(s?.paddingBottom??"0"),left:parseFloat(s?.paddingLeft??"0")},border:{top:parseFloat(s?.borderTopWidth??"0"),right:parseFloat(s?.borderRightWidth??"0"),bottom:parseFloat(s?.borderBottomWidth??"0"),left:parseFloat(s?.borderLeftWidth??"0")},margin:{top:parseFloat(s?.marginTop??"0"),right:parseFloat(s?.marginRight??"0"),bottom:parseFloat(s?.marginBottom??"0"),left:parseFloat(s?.marginLeft??"0")}})}ot(){this.Lt()}connect(t){if(!(t instanceof Element))throw Error("Invalid element");this.element=t,this.St=new ResizeObserver(this.Ct),this.St.observe(t),this.Ht=new MutationObserver(this.Ct),this.Ht.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.Ct,!0),window.addEventListener("resize",this.Ct),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.Ct),window.visualViewport.addEventListener("scroll",this.Ct))}disconnect(){this.St?.disconnect(),this.Ht?.disconnect(),this.Pt=()=>{},window.removeEventListener("scroll",this.Ct,!0),window.removeEventListener("resize",this.Ct),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.Ct),window.visualViewport.removeEventListener("scroll",this.Ct)),this.St=null,this.Ht=null,this.element=null}}class g extends r{constructor(t=null,i=null,s=null){super(),this.options=null,this.It=!1,this.Et=null,this.node=null,this.Ft=null,this.jt=null,this.parent=null,this.Vt=null,this.$t=null,this.kt=null,this.Rt=null,this.Dt=null,this.zt=null,this._t=null,this.Bt={Nt:36,Ut:8,Gt:!0},this.Wt=s,t&&i&&this.initialize(t,i)}initialize(t,i){if(!this.Wt)throw Error("Popup requires a ModelManager instance.");this.Vt=new c(i),this.$t=new u(i),this.kt=new d(i);const s=e.I({qt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},F:{vt:{tag:this.Vt.node},Kt:{tag:{id:i.Qt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Yt:{tag:this.kt.node},Jt:{tag:this.$t.node}}}},null);this.node=s.view,this.Dt=s.tags.Kt,this.parent=e.R(t),this.options=i,this.init(),this.Wt.load(this.Dt,{isMultiple:i.multiple},i.virtualScroll?{Xt:this.node,Nt:this.Bt.Nt,Ut:this.Bt.Ut,Gt:this.Bt.Gt}:{});const h=this.Wt.Zt();this.Et=h.ti,this.Rt=h.Rt,this.Vt.Tt(()=>{h.ti.ii(!0)}),this.Vt.Ot(()=>{h.ti.ii(!1)}),this.si(),this.mount()}async ei(){this.options&&this.kt&&this.Vt&&this.Et&&this.Wt&&(this._t&&clearTimeout(this._t),this.Wt.hi(!0),!1!==e.V(this.options.loadingfield)&&(this.$t.hide(),this.kt.show(this.Et.oi().ni),this.ri()))}async li(){this.options&&this.kt&&this.Et&&this.Wt&&(this._t&&clearTimeout(this._t),this._t=setTimeout(()=>{this.Wt?.hi(!1),this.kt?.hide();const t=this.Et?.oi();this.ai(t??void 0),this.ri()},this.options.animationtime))}si(){this.Et&&(this.Et.ci(t=>{this.ai(t)}),this.Et.ui("items",()=>{const t=this.Et.oi();this.ai(t),this.ri()}))}ai(t){if(!(this.Et&&this.$t&&this.Vt&&this.Dt))return;const i=t??this.Et.oi();i.isEmpty?(this.$t.show("nodata"),this.Dt.classList.add("hide"),this.Vt.hide()):i.ni?(this.$t.hide(),this.Dt.classList.remove("hide"),this.Vt.update()):(this.$t.show("notfound"),this.Dt.classList.add("hide"),this.Vt.hide())}di(t,i){this.Et?.pi(t,i)}gi(t,i){this.Et?.ui(t,i)}fi(t){this.Ft=t}open(t=null,i){if(!(this.node&&this.options&&this.Vt&&this.parent&&this.Ft))return;this.It||(document.body.appendChild(this.node),this.It=!0,this.jt=new p,this.Ft.mi(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.Vt.update(),i&&this.ai();const s=this.bi(),{position:e,top:h,maxHeight:n,yi:o}=this.wi(s);this.Ft.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:h,maxHeight:n,yi:o,position:e,xi:()=>{if(!this.jt||!this.parent)return;this.jt.Pt=()=>{const t=this.bi();this.Mi(t)},this.jt.connect(this.parent.container.tags.Ti),t?.();const i=this.Rt;i?.resume?.()}})}close(t=null){if(!(this.It&&this.options&&this.jt&&this.Ft))return;const i=this.Rt;i?.suspend?.(),this.jt.disconnect(),this.Ft.collapse({duration:this.options.animationtime,xi:t??void 0})}ri(){this.It&&this.jt?.ot()}Oi(t,i){this.node&&(this.zt=async()=>{const i=t.Ai();if(!i.Si)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.Hi&&i.hasMore){const i=await t.Ci();!i.Li&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this.zt))}destroy(){if(!this.is(o.DESTROYED)){this._t&&(clearTimeout(this._t),this._t=null),this.node&&this.zt&&(this.node.removeEventListener("scroll",this.zt),this.zt=null),this.$t.destroy(),this.kt.destroy(),this.Vt.destroy();try{this.jt?.disconnect()}catch(t){}this.jt=null;try{this.Ft?.mi?.(null)}catch(t){}if(this.Ft=null,this.node)try{const t=this.node.cloneNode(!0);this.node.replaceWith(t),t.remove()}catch(t){this.node.remove()}this.node=null,this.Dt=null;try{this.Wt?.hi?.(!1),this.Rt?.clear?.(),this.Rt=null,this.Et=null,this.node.remove()}catch(t){}this.Wt=null,this.Vt=null,this.$t=null,this.kt=null,this.parent=null,this.options=null,this.It=!1,super.destroy()}}bi(){const t=this.parent.container.tags.Ti,i=t.getBoundingClientRect(),s=window.getComputedStyle(t);return{width:i.width,height:i.height,top:i.top,left:i.left,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},border:{top:parseFloat(s.borderTopWidth),right:parseFloat(s.borderRightWidth),bottom:parseFloat(s.borderBottomWidth),left:parseFloat(s.borderLeftWidth)}}}wi(t){const i=window.visualViewport,s=e.J(),h=i?.height??window.innerHeight,n=this.Ft.Pi("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 c="bottom",u=o,d=Math.min(n,u);const p=l-15;(d>=r?p>=r:p>=d)?(c="bottom",u=Math.min(l-15,o)):a>=Math.max(d,r)?(c="top",u=Math.min(a-15,o)):l>=a?(c="bottom",u=Math.max(l-15,r)):(c="top",u=Math.max(a-15,r)),d=Math.min(n,u);const g=i&&s?i.offsetTop:0;return{position:c,top:"bottom"===c?t.top+t.height+3+g:t.top-d-3+g,maxHeight:u,yi:d,Ii:n}}Mi(t){if(!this.options||!this.Ft)return;const{position:i,top:s,maxHeight:e,yi:h}=this.wi(t);this.Ft.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,yi:h,position:i,animate:!0})}}class f extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.Ei=null,this.Fi=null,this.options=null,this.ji=null,this.Vi=null,this.$i=null,this.options=t,t&&this.initialize(t)}initialize(t){this.bt=e.I({ki:{tag:{node:"div",classList:["selective-ui-searchbox","hide"]},F:{Ei:{tag:{id:e.m(),node:"input",type:"search",classList:["selective-ui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",S:t.Qt,L:"list"}}}}}),this.node=this.bt.view,this.Ei=this.bt.tags.Ei;let i=!1;const s=this.bt.tags.Ei;s.addEventListener("mousedown",t=>{t.stopPropagation()}),s.addEventListener("mouseup",t=>{t.stopPropagation()}),s.addEventListener("keydown",t=>{i=!1,"ArrowDown"===t.key||"Tab"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Vi?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),i=!0,this.$i?.()),t.stopPropagation()}),s.addEventListener("input",()=>{i||this.Fi?.(s.value,!0)}),this.init()}show(){this.node&&this.Ei&&this.options&&(this.node.classList.remove("hide"),this.Ei.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.Ei?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.bt&&(this.bt.tags.Ei.value="",this.Fi?.("",t))}Ri(t){this.Ei&&(this.Ei.placeholder=e.q(t))}Di(t){this.Ei&&this.Ei.setAttribute("aria-activedescendant",t)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.bt=null,this.node=null,this.Ei=null,this.Fi=null,this.options=null,this.ji=null,this.Vi=null,this.$i=null,super.destroy())}}class m{constructor(t=null){this.zi=null,this._i=null,this.Bi=!1,t&&this.mi(t)}mi(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.zi&&(clearTimeout(this.zi),this.zi=null),this._i&&(clearTimeout(this._i),this._i=null),this.Bi=!1,this}Pi(t="flex"){if(!this.element)return{width:0,height:0,scrollHeight:0};const i={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 s=window.getComputedStyle(this.element),e=parseFloat(s.borderTopWidth),h=parseFloat(s.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,i),r}expand(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,display:s="flex",width:e,left:h,top:n,maxHeight:o,yi:r,position:l="bottom",xi:a}=t;return Object.assign(this.element.style,{display:s,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 ${i}ms, height ${i}ms, opacity ${i}ms`,top:n+"px",height:r+"px",opacity:"1",overflow:r>=o?"auto":"hidden"}),this.zi=setTimeout(()=>{this.element.style.transition="none",this.Bi=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,xi:s}=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 ${i}ms, top ${i}ms, opacity ${i}ms`,height:"0px",top:r+"px",opacity:"0",overflow:o?"auto":"hidden"}),this.zi=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Bi=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,display:s="block",xi:e}=t;Object.assign(this.element.style,{transition:"none",display:s,width:"fit-content"});const h=this.Pi(s).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:h+"px",overflow:"hidden"})}),this.zi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Bi=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,xi:s}=t,e=this.Pi().width;return Object.assign(this.element.style,{transition:"none",width:e+"px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:"0px",overflow:"hidden"})}),this.zi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Bi=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.cancel();const{duration:i=200,width:s,left:e,top:h,maxHeight:n,yi:o,position:r="bottom",animate:l=!0,xi:a}=t,c=(this.element.classList.contains("position-top")?"top":"bottom")!==r,u=this.element.scrollHeight>n;return this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),c&&(this.element.style.transition=`top ${i}ms ease-out, height ${i}ms ease-out, max-height ${i}ms ease-out;`),requestAnimationFrame(()=>{const t={width:s+"px",left:e+"px",top:h+"px",maxHeight:n+"px",height:o+"px",overflowY:u?"auto":"hidden"},r=Math.abs(this.element.offsetHeight-o);l&&(c||r>5)?t.transition=`height ${i}ms, top ${i}ms`:this._i=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},i),Object.assign(this.element.style,t),l&&(c||r>1)?this._i=setTimeout(()=>{this.element.style.transition=null,c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())}),this}get Ni(){return this.Bi}}class b extends r{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){super(),this.targetElement=null,this.view=null,this.position=-1,this.At=!1,this.Ui=!1,this.options=t,this.targetElement=i,this.view=s,this.init()}Gi(t){this.targetElement=t,this.update()}destroy(){this.is(o.DESTROYED)||(this.targetElement=null,this.view?.destroy(),this.view=null,this.Ui=!0,super.destroy())}}class y extends b{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.Wi=[],this.label=this.targetElement.label}init(){this.collapsed=e.V(this.targetElement.dataset?.collapsed),super.init(),this.mount()}get value(){return this.items.map(t=>t.value)}get qi(){return this.items.filter(t=>t.selected)}get Ki(){return this.items.filter(t=>t.visible)}get Qi(){return this.Ki.length>0}Gi(t){this.label=t.label,this.view?.Yi(this.label),this.update()}update(){this.view&&(this.view.Yi(this.label),this.view.Ji(this.collapsed)),super.update()}destroy(){this.is(o.DESTROYED)||(this.items.forEach(t=>{t.destroy()}),this.items=[],super.destroy())}Xi(t){this.Wi.push(t)}Zi(){this.collapsed=!this.collapsed,this.view?.Ji(this.collapsed),h.nt([this,this.collapsed],...this.Wi)}ts(t){this.items.push(t),t.group=this}removeItem(t){const i=this.items.indexOf(t);i>-1&&(this.items.splice(i,1),t.group=null)}ss(){this.view?.ss()}}class w extends b{constructor(t,i=null,s=null){super(t,i,s),this.es=[],this.hs=[],this.ns=[],this.rs=!0,this.ls=!1,this.group=null}init(){this.cs=e.K(this.textContent.toLowerCase()),super.init(),this.mount()}get us(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.us}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.ds=t,h.nt([this,t],...this.es)}get visible(){return this.rs}set visible(t){if(this.rs===t)return;this.rs=t;const i=this.view?.ps?.();i&&i.classList.toggle("hide",!t),h.nt([this,t],...this.ns)}get ds(){return this.selected}set ds(t){const i=this.view?.view?.tags?.gs,s=this.view?.ps?.();i&&(i.checked=t),s&&this.targetElement&&(s.classList.toggle("checked",!!t),s.setAttribute("aria-selected",t?"true":"false"),this.targetElement.toggleAttribute("selected",!!t)),this.targetElement&&(this.targetElement.selected=t),h.nt([this,t],...this.hs)}get text(){const t=e.W(this.dataset?.mask??this.targetElement?.text??"");return this.options.allowHtml?t:e.q(t)}get textContent(){return this.options.allowHtml?e.q(this.text).trim():this.text.trim()}get dataset(){return this.targetElement?.dataset??{}}get fs(){return this.ls}set fs(t){const i=!!t,s=this.view?.ps?.();this.ls!==i&&(this.ls=i),s&&s.classList.toggle("highlight",i)}bs(t){this.es.push(t)}ys(t){this.hs.push(t)}ci(t){this.ns.push(t)}update(){if(this.cs=e.K(this.textContent.toLowerCase()),!this.view)return void super.update();const t=this.view.view.tags.ws;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.vs;i&&this.hasImage&&(i.src=this.us,i.alt=this.text),this.targetElement&&(this.ds=this.targetElement.selected),super.update()}destroy(){this.is(o.DESTROYED)||(this.es=[],this.hs=[],this.ns=[],this.group=null,this.cs=null,super.destroy())}}class v extends r{constructor(t){super(),this.xs=[],this.Ms=null,this.Ts=null,this.options=null,this.Os=0,this.options=t,this.init()}As(t){this.Ss=t}Hs(t){this.Cs=t}Ls(t){this.is(o.INITIALIZED)&&this.mount(),this.xs=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new y(this.options,t),this.xs.push(i);else if("OPTION"===t.tagName){const s=t,e=new w(this.options,s),h=s.__parentGroup;h&&i&&h===i.targetElement?(i.ts(e),e.group=i):(this.xs.push(e),i=null)}}),this.xs}async replace(t){this.Ls(t),this.Ms&&await this.Ms.Ps(this.xs),this.refresh(!1)}notify(){this.Ms&&this.refresh(!1)}load(t,i={},s={}){this.Ms=new this.Ss(this.xs),Object.assign(this.Ms,i),this.Ts=new this.Cs(t),Object.assign(this.Ts,s),this.Ts.Is(this.Ms)}Es(t){const i=this.xs,s=[],e=new Map,h=new Map;i.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 i=t,h=e.get(i.label);h?(h.label!==i.label&&h.Gi(i),h.position=o,h.items=[],n=h,s.push(h),e.delete(i.label)):(n=new y(this.options,i),n.position=o,s.push(n)),o++}else if("OPTION"===t.tagName){const i=t,e=`${i.value}::${i.text}`,r=h.get(e);if(r)r.Gi(i),r.position=o,i.__parentGroup&&n?(n.ts(r),r.group=n):(r.group=null,s.push(r)),h.delete(e);else{const t=new w(this.options,i);t.position=o,i.__parentGroup&&n?(n.ts(t),t.group=n):s.push(t)}o++}});let r=!0;0==this.Os&&(r=!1),this.Os=o,e.forEach(t=>{r=!1,t.destroy()}),h.forEach(t=>{r=!1,t.destroy()}),this.xs=s,this.Ms&&this.Ms.Fs(this.xs),this.refresh(r)}hi(t){this.Ms&&(this.Ms.js=t)}refresh(t){this.Ts&&(this.Ts.refresh(t),this.update())}destroy(){this.is(o.DESTROYED)||(this.Ms.destroy(),this.Ts.destroy(),this.xs=[],this.Ss=null,this.Ms=null,this.Cs=null,this.Ts=null,this.options=null,this.Os=0,super.destroy())}Zt(){return{Vs:this.xs,ti:this.Ms,Rt:this.Ts}}$s(t){return this.Ms?.ks(t)}Rs(t){return this.Ms?.Ds(t)}}class x extends r{constructor(t=null){super(),this.zs=null,this.ti=null,this.zs=t,this.init()}Is(t){this.ti=t,t.pi("items",()=>{this.clear()}),t.ui("items",()=>{this._s()}),t.mount(),this.mount(),this._s()}clear(){this.zs&&this.zs.replaceChildren()}_s(){this.ti&&this.zs&&(this.ti.Bs(this.zs),this.update())}refresh(t){this._s()}destroy(){this.is(o.DESTROYED)||(this.zs=null,this.ti=null,super.destroy())}}class M extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.options=null,this.Ns=null,this.Us=null,this.Wt=null,this.Gs=[],t&&this.initialize(t)}initialize(t){this.options=t,this.init()}init(){this.state===o.NEW&&(this.bt=e.I({Ws:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.bt.view,super.init())}qs(t){this.Ns=t,this.Us=t.parentElement,this.Ks(),this.mount()}mount(){this.is(o.INITIALIZED)&&super.mount()}Ks(){this.Us&&this.node&&this.Ns&&this.options&&this.Us.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Ns:this.Ns.nextSibling)}Qs(t){this.Wt=t}Ys(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?t.forEach(t=>{e.I({Js:{tag:{node:"div",classList:["accessory-item"]},F:{Xs:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:async i=>{i.preventDefault(),await(this.Wt?.$s?.("select")),t.selected=!1}}},Zs:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)}):t=[],this.Gs=t,this.te(),this.update(),h.ot(window,"resize"))}update(){this.state===o.MOUNTED&&super.update()}te(){this.options?.accessoryVisible&&this.Gs.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.bt=null,this.node=null,this.options=null,this.Ns=null,this.Us=null,this.Wt=null,this.Gs=[],super.destroy())}}class T extends r{constructor(t,i,s){super(),this.ie=null,this.se=null,this.ee=null,this.he=null,this.ne={currentPage:0,totalPages:1,hasMore:!1,Hi:!1,oe:"",Si:!1},this.initialize(t,i,s)}initialize(t,i,s){this.select=t,this.Wt=i,this.he=s,this.init()}re(){return!!this.ie}async le(t){if(!this.ie)return{Li:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Li:!0,items:[]};try{const t=this.ie;let s,e;if(s="function"==typeof t.ae?t.ae(i):{values:i.join(","),ce:"1",..."function"==typeof t.data?t.data.bind(this.he.ue.find(this.he.container.targetElement))("",0):t.data??{}},"POST"===(t.method??"GET")){const i=new URLSearchParams;Object.keys(s).forEach(t=>i.append(t,s[t]+"")),e=await fetch(t.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{const i=""+new URLSearchParams(s);e=await fetch(`${t.url}?${i}`)}if(!e.ok)throw Error("HTTP error! status: "+e.status);const h=await e.json(),n=this.de(h);return this.update(),{Li:!0,items:n.items}}catch(s){return console.error("Load by values error:",s),{Li:!1,message:s?.message,items:[]}}}pe(t){const i=Array.from(this.select.options).map(t=>t.value);return{ge:t.filter(t=>i.includes(t)),fe:t.filter(t=>!i.includes(t))}}me(t){this.ie=t}setPopup(t){this.ee=t}Ai(){return{...this.ne}}be(){this.ne={currentPage:0,totalPages:1,hasMore:!1,Hi:!1,oe:"",Si:this.ne.Si}}clear(){this.ne.oe="";const{Vs:t}=this.Wt.Zt(),i=[];for(const s of t)s instanceof w?i.push(s):s instanceof y&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.ie?this.ye(t,i):this.we(t)}async Ci(){return this.ie?this.ne.Hi?{Li:!1,message:"Already loading"}:this.ne.Si?this.ne.hasMore?(this.ne.currentPage++,this.ye(this.ne.oe,!0)):{Li:!1,message:"No more data"}:{Li:!1,message:"Pagination not enabled"}:{Li:!1,message:"Ajax not enabled"}}async we(t){this.ve(t)&&(this.ne.oe=t);const i=((t??"")+"").toLowerCase(),s=e.K(i),{Vs:h}=this.Wt.Zt(),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=""===i||t.cs.includes(s);t.visible=e,e&&(o=!0)}),this.update(),{Li:!0,xe:o,isEmpty:0===n.length}}ve(t){return t!==this.ne.oe}async ye(t,i=!1){const s=this.ie;this.ve(t)&&(this.be(),this.ne.oe=t,i=!1),this.ne.Hi=!0,this.ee?.ei(),this.se?.abort(),this.se=new AbortController;const e=this.ne.currentPage,h=Array.from(this.select.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof s.data?(n=s.data.bind(this.he.ue.find(this.he.container.targetElement))(t,e),n&&void 0===n.selectedValue&&(n.selectedValue=h)):n={search:t,page:e,selectedValue:h,...s.data??{}};try{let t;if("POST"===(s.method??"GET")){const i=new URLSearchParams;Object.keys(n).forEach(t=>i.append(t,n[t]+"")),t=await fetch(s.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.se.signal})}else{const i=""+new URLSearchParams(n);t=await fetch(`${s.url}?${i}`,{signal:this.se.signal})}const e=await t.json(),h=this.de(e);return h.Me?(this.ne.Si=!0,this.ne.currentPage=h.page,this.ne.totalPages=h.totalPages,this.ne.hasMore=h.hasMore):this.ne.Si=!1,this.Te(h.items,!!s.keepSelected,i),this.ne.Hi=!1,this.ee?.li(),this.update(),{Li:!0,xe:h.items.length>0,isEmpty:0===h.items.length,Me:h.Me,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.ne.Hi=!1,this.ee?.li(),"AbortError"===o?.name?{Li:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Li:!1,message:o?.message})}}de(t){let i=[],s=!1,e=0,h=1,n=!1;return t.object&&Array.isArray(t.object)?(i=t.object,void 0!==t.page&&(s=!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)?(i=t.data,void 0!==t.page&&(s=!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)?i=t:t.items&&Array.isArray(t.items)&&(i=t.items,t.pagination&&(s=!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:i.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.Oe||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 i=t.data??{};return t?.imgsrc&&(i.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:i}}),Me:s,page:e,totalPages:h,hasMore:n}}Te(t,i,s=!1){const e=this.select;let h=[];i&&(h=Array.from(e.selectedOptions).map(t=>t.value)),s||(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 s=document.createElement("optgroup");s.label=t.label,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),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(i=>{e.dataset[i]=t.data[i]+""}),(t.selected||i&&h.includes(e.value))&&(e.selected=!0),s.appendChild(e)}),e.appendChild(s)}else{const s=document.createElement("option");s.value=t.value,s.text=t.text,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),(t.selected||i&&h.includes(s.value))&&(s.selected=!0),e.appendChild(s)}})}destroy(){this.is(o.DESTROYED)||(this.select=null,this.Wt=null,this.ie=null,this.se=null,this.ee=null,this.he=null,super.destroy())}}class O{constructor(t){this.Ae=null,this.Se=50,this.select=t,this.He=new MutationObserver(()=>{clearTimeout(this.Ae),this.Ae=setTimeout(()=>{this.Ce()},this.Se)})}Ce(){this.Pt(this.select)}connect(){this.He.observe(this.select,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.Ae&&clearTimeout(this.Ae),this.Ae=null,this.He.disconnect()}}class A{constructor(t){this.Ae=null,this.element=t,this.He=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.Ae&&clearTimeout(this.Ae),this.Ae=setTimeout(()=>{this.Pt({...this.element.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.element.dataset})})}connect(){this.He.observe(this.element,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.Ae&&clearTimeout(this.Ae),this.Ae=null,this.He.disconnect()}}class S extends r{constructor(t=[]){super(),this.items=[],this.Le=e.m(12),this.js=!1,this.items=t,this.init()}Pe(t,i,s){const e=i;t.At?e?.update?.():e?.mount?.()}pi(t,i){e.Z.on(`${t}ing_${this.Le}`,i,{st:0})}ui(t,i){e.Z.on(`${t}_${this.Le}`,i,{st:0})}Ds(t,...i){return e.Z.run(`${t}_${this.Le}`,...i)}ks(t,...i){return e.Z.run(`${t}ing_${this.Le}`,...i)}Ie(t,i){return null}Ee(){return this.items.length}async Fe(t){await this.ks("items",t),this.items=t,await this.Ds("items",t),this.update()}async Ps(t){await this.Fe(t)}Bs(t){for(let i=0;i<this.Ee();i++){const s=this.items[i];let e=s.view;s.At||(e=this.Ie(t,s),s.view=e),this.Pe(s,e,i),s.At=!0}}Fs(t){}destroy(){this.is(o.DESTROYED)||(this.Rt=null,this.items.forEach(t=>{t?.destroy?.()}),this.items=[])}}class H extends r{constructor(t){super(),this.parent=null,this.view=null,this.parent=t,this.init()}ps(){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.ps()?.remove?.(),this.parent=null,this.view=null,super.destroy())}}class C extends H{constructor(){super(...arguments),this.view=null}mount(){const t=e.m(7);this.view=e.P({je:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},F:{Ve:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},$e:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view),super.mount()}update(){this.Yi(),super.update()}Yi(t=null){this.view&&null!==t&&(this.view.tags.Ve.textContent=t)}ke(){if(!this.view)throw Error("GroupView has not been rendered.");return this.view.tags.$e}ss(){if(!this.view)return;const t=Array.from(this.view.tags.$e.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",0===t.length)}Ji(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.Ve.setAttribute("aria-expanded",t?"false":"true"))}}class L extends H{constructor(t){super(t),this.view=null,this.config=null,this.Re=null,this.De=!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.Re=new Proxy(this.config,{set(i,s,e){if("string"!=typeof s)return!0;const h=s,n=i[h];return n!==e&&(i[h]=e,t.De&&t.ze(h,e,n)),!0}}),this.init()}get isMultiple(){return this.config.isMultiple}set isMultiple(t){this.Re.isMultiple=!!t}get hasImage(){return this.config.hasImage}set hasImage(t){this.Re.hasImage=!!t}get _e(){return this.Re}set _e(t){if(!t||!this.Re||!this.config)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this.config.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.config.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.config.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.config.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.config.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.config.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.Re,i)}mount(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this.config.isMultiple&&t.push("multiple"),this.config.hasImage&&t.push("has-image","image-"+this.config.imagePosition);const h={gs:{tag:{node:"input",type:this.config.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this.config.hasImage&&{vs:{tag:{node:"img",classList:"option-image",style:{width:this.config.imageWidth,height:this.config.imageHeight,borderRadius:this.config.imageBorderRadius}}}},Be:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this.config.labelValign,"align-horizontal-"+this.config.labelHalign]},F:{ws:{tag:{node:"div"}}}}};this.view=e.P({Ne:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},F:h}}),this.parent.appendChild(this.view.view),this.De=!0,super.mount()}ze(t,i,s){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.gs,o=e.tags?.Be;switch(t){case"isMultiple":{const t=!!i;h.classList.toggle("multiple",t),n&&n.type!==(t?"checkbox":"radio")&&(n.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!i;if(h.classList.toggle("has-image",t),t)h.classList.add("image-"+this.config.imagePosition),this.Ue();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.vs;t?.remove(),e.tags.vs=null}break}case"imagePosition":this.config.hasImage&&(h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim(),h.classList.add("image-"+i));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const s=e.tags?.vs;s&&(s.style["imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius"]=i+"");break}case"labelValign":case"labelHalign":o&&(o.className=`align-vertical-${this.config.labelValign} align-horizontal-`+this.config.labelHalign)}}Ue(){const t=this.view;if(!t||!t.view)return;if(t.tags?.vs)return;const i=t.view,s=t.tags?.Be,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,s?.parentElement?i.insertBefore(e,s):i.appendChild(e),t.tags.vs=e}}class P extends S{constructor(t=[]){super(t),this.isMultiple=!1,this.Ge=[],this.We=-1,this.qe=null,this.groups=[],this.Ke=[],this.Qe()}init(){e.Z.on("sche_vis_"+this.Le,()=>{const t=this.Ke.filter(t=>t.visible).length,i=this.Ke.length;this.Ge.forEach(s=>{s({Ye:t,Je:i,ni:t>0,isEmpty:0===i})}),e.Z.run("sche_vis_proxy_"+this.Le)},{st:10}),super.init(),this.mount()}Qe(){this.Ke=[],this.groups=[],this.items.forEach(t=>{t instanceof y?(this.groups.push(t),this.Ke.push(...t.items)):t instanceof w&&this.Ke.push(t)})}Ie(t,i){return i instanceof y?new C(t):new L(t)}Pe(t,i,s){t.position=s,t instanceof y?this.Xe(t,i,s):t instanceof w&&this.Ze(t,i,s),t.At=!0}Xe(t,i,s){super.Pe(t,i,s),t.view=i;const e=i.view.tags.Ve;e.textContent=t.label,t.At||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.Zi()}),t.Xi((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.ps?.();i&&(i.style.display=s?"none":"")}),this.th(i,s)}));const h=i.ke();t.items.forEach((t,i)=>{let s=t.view;t.At&&s||(s=new L(h)),this.Ze(t,s,i),t.At=!0}),i.Ji(t.collapsed),i.ss()}Ze(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i._e={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.At||super.Pe(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.vs;s&&(s.src!==t.us&&(s.src=t.us),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.ws.innerHTML=t.text,t.At||(i.view.tags.Ne.addEventListener("click",async i=>{i.stopPropagation(),i.preventDefault(),this.js||(this.isMultiple?(await this.ks("select"),t.selected=!t.selected):!0!==t.selected&&(await this.ks("select"),this.qe&&(this.qe.selected=!1),t.selected=!0))}),i.view.tags.Ne.title=t.textContent,i.view.tags.Ne.addEventListener("mouseenter",()=>{this.js||this.ih(this.Ke.indexOf(t),!1)}),t.bs(()=>{this.Ds("selected")}),t.ys((i,s,e)=>{e&&(this.qe=t),this.Ds("selected_internal")}),t.ci((t,i)=>{i.group?.ss(),this.sh()})),t.selected&&(this.qe=t,t.ds=!0)}async Fe(t){await this.ks("items",t),this.items=t,this.Qe(),await this.Ds("items",t),this.update()}async Ps(t){await this.Fe(t)}Fs(t){this.items=t,this.Qe(),this.update()}destroy(){this.is(o.DESTROYED)||(e.Z.clear("sche_vis_"+this.Le),this.groups.forEach(t=>{t.destroy()}),this.Ge=[],this.We=-1,this.qe=null,this.groups=[],this.Ke=[],super.destroy())}eh(){return this.Ke.filter(t=>t.selected)}hh(){return this.Ke.find(t=>t.selected)}ii(t){this.isMultiple&&this.Ke.forEach(i=>{i.selected=t})}ci(t){this.Ge.push(t)}sh(){e.Z.run("sche_vis_"+this.Le)}oi(){const t=this.Ke.filter(t=>t.visible).length,i=this.Ke.length;return{Ye:t,Je:i,ni:t>0,isEmpty:0===i}}nh(){this.ih(0)}navigate(t,i=!0){const s=this.Ke.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.Ke[this.We]);-1===e&&(e=-1);let h=e+t;h>=s.length&&(h=0),h<0&&(h=s.length-1);const n=this.Ke.indexOf(s[h]);this.ih(n,i)}oh(){if(this.We>-1&&this.Ke[this.We]){const t=this.Ke[this.We];if(t.visible){const i=t.view?.ps?.();i&&i.click()}}}ih(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof w){const i=this.Ke.indexOf(t);s=i>-1?i:0}else s=0;this.We>-1&&this.Ke[this.We]&&(this.Ke[this.We].fs=!1);for(let e=s;e<this.Ke.length;e++){const t=this.Ke[e];if(t?.visible){if(t.fs=!0,this.We=e,i){const i=t.view?.ps?.();i?i.scrollIntoView({block:"center",behavior:"smooth"}):this.Rt?.rh?.(e,{scrollIntoView:!0})}return void this.ah(e,t.view?.ps?.()?.id)}}}ah(t,i){}th(t,i){}}class I extends r{constructor(t=0){super(),this.uh=[],this.dh=0,this.initialize(t)}initialize(t){this.init(),this.reset(t)}reset(t){this.dh=t,this.uh=Array(t+1).fill(0)}add(t,i){for(let s=t;s<=this.dh;s+=s&-s)this.uh[s]+=i}ph(t){let i=0;for(let s=t;s>0;s-=s&-s)i+=this.uh[s];return i}gh(t,i){return i<t?0:this.ph(i)-this.ph(t-1)}fh(t){this.reset(t.length),t.forEach((t,i)=>this.add(i+1,t))}mh(t){let i=0,s=1;for(;s<<1<=this.dh;)s<<=1;let e=0;for(let h=s;0!==h;h>>=1){const s=i+h;s<=this.dh&&e+this.uh[s]<=t&&(i=s,e+=this.uh[s])}return i}}class E extends x{constructor(t=null){super(t),this.bh={Xt:void 0,Nt:36,Ut:8,Gt:!0,yh:!0},this.wh=[],this.xh=new I(0),this.Mh=new Map,this.Th=!1,this.start=0,this.end=-1,this.Oh=null,this.Ah=null,this.updating=!1,this.Sh=!1,this.Hh=0,this.Ch=!1,this.Lh=!1,this.Ph=0,this.Ih=0,this.Eh=0,this.Fh=0}configure(t){this.bh={...this.bh,...t}}Is(t){if(this.ti&&this.dispose(),super.Is(t),t.Rt=this,!this.zs)return;this.zs.replaceChildren();const i=e.I({jh:{tag:{node:"div",classList:"selective-ui-virtual-pad-top"}},Vh:{tag:{node:"div",classList:"selective-ui-virtual-items"}},$h:{tag:{node:"div",classList:"selective-ui-virtual-pad-bottom"}}},this.zs);if(this.jh=i.jh,this.Vh=i.Vh,this.$h=i.$h,this.Xt=this.bh.Xt??this.zs.closest(".selective-ui-popup")??this.zs.parentElement,!this.Xt)throw Error("VirtualRecyclerView: scrollEl not found");this.kh=this.Rh.bind(this),this.Xt.addEventListener("scroll",this.kh,{passive:!0}),this.refresh(!1),this.Dh(),t?.ci?.(()=>this.zh())}suspend(){this.Ch=!0,this._h(),this.Xt&&this.kh&&this.Xt.removeEventListener("scroll",this.kh),this.Bh&&(this.Bh.disconnect(),this.Lh=!0)}resume(){this.Ch=!1,this.Xt&&this.kh&&this.Xt.addEventListener("scroll",this.kh,{passive:!0}),this.Lh&&(this.Dh(),this.Lh=!1),this.Nh()}refresh(t){if(!this.ti||!this.zs)return;t||this.zh();const i=this.ti.Ee();if(this.Hh=i,0===i)return this.Uh(),void this.update();this.wh.length=i,this.Th||(this.Gh(),this.Th=!0),this.Wh(i),this.Nh(),this.update()}rh(t,i){this.qh(t,t),i?.scrollIntoView&&this.Kh(t)}Kh(t){if((this.ti?.Ee?.()??0)<=0)return;const i=this.Qh(t),s=this.Yh()+i,e=Math.max(0,this.Xt.scrollHeight-this.Xt.clientHeight);this.Xt.scrollTop=Math.min(Math.max(0,s),e)}dispose(){this._h(),this.Xt&&this.kh&&this.Xt.removeEventListener("scroll",this.kh),this.Bh?.disconnect(),this.Mh.forEach(t=>t.remove()),this.Mh.clear()}destroy(){this.is(o.DESTROYED)||(this.Uh(),this.dispose(),this.jh.remove(),this.Vh.remove(),this.$h.remove(),this.jh=null,this.Vh=null,this.$h=null,super.destroy())}zh(){if(!this.ti)return;const t=this.ti.Ee();t<=0||(this.suspend(),this.Uh(),this.Jh(),this.Xh(t),this.Wh(t),this.start=0,this.end=-1,this.resume())}_h(){null!=this.Oh&&(cancelAnimationFrame(this.Oh),this.Oh=null),null!=this.Ah&&(cancelAnimationFrame(this.Ah),this.Ah=null)}Uh(){this.Mh.forEach(t=>t.remove()),this.Mh.clear(),this.wh=[],this.xh.reset(0),this.jh.style.height="0px",this.$h.style.height="0px",this.Th=!1,this.Eh=0,this.Fh=0}Gh(){this.Zh(0);const t=this.Mh.get(0);if(!t)return;const i=this.tn(t);if(isNaN(i)||(this.bh.Nt=i),!this.bh.Gt){t.remove(),this.Mh.delete(0);const i=this.ti.items[0];i&&(i.At=!1,i.view=null)}}sn(t){const i=this.ti?.items?.[t];return i?.visible??!0}en(t,i){for(let s=Math.max(0,t);s<i;s++)if(this.sn(s))return s;return-1}Xh(t){this.Eh=0,this.Fh=0;for(let i=0;i<t;i++){if(!this.sn(i))continue;const t=this.wh[i];null!=t&&(this.Eh+=t,this.Fh++)}}Yh(){const t=this.zs.getBoundingClientRect(),i=this.Xt.getBoundingClientRect();return Math.max(0,t.top-i.top+this.Xt.scrollTop)}hn(){const t=performance.now();if(t-this.Ph<16)return this.Ih;const i=this.Xt.querySelector(".selective-ui-option-handle:not(.hide)");return this.Ih=i?.offsetHeight??0,this.Ph=t,this.Ih}Nh(){null!=this.Oh||this.Ch||(this.Oh=requestAnimationFrame(()=>{this.Oh=null,this.nn()}))}tn(t){const i=t.getBoundingClientRect(),s=getComputedStyle(t);return Math.max(1,i.height+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}rn(){return this.bh.yh&&this.Fh>0?Math.max(1,this.Eh/this.Fh):this.bh.Nt}Wh(t){const i=this.rn(),s=Array.from({length:t},(t,s)=>this.sn(s)?this.wh[s]??i:0);this.xh.fh(s)}ln(t,i){if(!this.sn(t))return!1;const s=this.rn(),e=this.wh[t]??s;if(Math.abs(i-e)<=E.an)return!1;const h=this.wh[t];return null==h?(this.Eh+=i,this.Fh++):this.Eh+=i-h,this.wh[t]=i,this.xh.add(t+1,i-e),!0}cn(t,i){const s=this.xh.mh(Math.max(0,t)),e=Math.min(i-1,s),h=this.en(e,i);return-1===h?Math.max(0,e):h}un(t,i){i.setAttribute(E.dn,t+"");const s=this.Mh.get(t-1);if(s?.parentElement===this.Vh)return void s.after(i);const e=this.Mh.get(t+1);if(e?.parentElement===this.Vh)return void this.Vh.insertBefore(i,e);const h=Array.from(this.Vh.children);for(const n of h){const s=n.getAttribute(E.dn);if(s&&+s>t)return void this.Vh.insertBefore(i,n)}this.Vh.appendChild(i)}pn(t,i){if(i.parentElement!==this.Vh)return void this.un(t,i);i.setAttribute(E.dn,t+"");const s=i.previousElementSibling,e=i.nextElementSibling;(s&&+s.getAttribute(E.dn)>t||e&&+e.getAttribute(E.dn)<t)&&(i.remove(),this.un(t,i))}Dh(){this.Bh||(this.Bh=new ResizeObserver(()=>{this.Sh||this.Ch||!this.ti||null!=this.Ah||(this.Ah=requestAnimationFrame(()=>{this.Ah=null,this.gn()}))}),this.Bh.observe(this.Vh))}gn(){if(!this.ti)return;const t=this.ti.Ee();if(t<=0)return;let i=!1;for(let s=this.start;s<=this.end;s++){if(!this.sn(s))continue;const t=this.ti.items[s],e=t?.view?.ps?.();if(!e)continue;const h=this.tn(e);this.ln(s,h)&&(i=!0)}i&&(this.bh.yh&&this.Wh(t),this.Nh())}Rh(){this.Nh()}nn(){if(!this.updating&&!this.Ch){this.updating=!0;try{if(!this.ti)return;const t=this.ti.Ee();if(t<=0)return;this.Hh!==t&&(this.Hh=t,this.wh.length=t,this.Wh(t));const i=this.Yh(),s=Math.max(0,this.Xt.scrollTop-i),e=this.hn(),h=Math.max(0,this.Xt.clientHeight-e),n=this.cn(s,t),o=this.Qh(n),r=i+o-this.Xt.scrollTop,l=this.cn(s,t);if(-1===l)return void this.Uh();const a=this.rn(),c=this.bh.Ut*a;let u=this.en(Math.min(t-1,this.xh.mh(Math.max(0,s-c))),t)??l,d=Math.min(t-1,this.xh.mh(s+h+c));if(u===this.start&&d===this.end)return;this.start=u,this.end=d,this.Sh=!0;try{this.qh(this.start,this.end),this.fn(this.start,this.end),this.bh.Gt&&this.gn();const i=this.Qh(this.start),s=this.mn(this.start,this.end),e=this.bn(t),h=Math.max(0,e-i-s);this.jh.style.height=i+"px",this.$h.style.height=h+"px"}finally{this.Sh=!1}const p=this.Qh(n),g=this.Yh()+p-r,f=Math.max(0,this.Xt.scrollHeight-this.Xt.clientHeight),m=Math.min(Math.max(0,g),f),b=Math.abs(p-o)>1,y=Math.abs(this.Xt.scrollTop-m);b&&y>.5&&y<100&&(this.Xt.scrollTop=m)}finally{this.updating=!1}}}qh(t,i){for(let s=t;s<=i;s++)this.Zh(s)}Zh(t){if(!this.sn(t)){const i=this.Mh.get(t);return i?.parentElement===this.Vh&&i.remove(),void this.Mh.delete(t)}const i=this.ti.items[t];if(!i)return;const s=this.Mh.get(t);if(s)return void(i?.view?(this.pn(t,s),this.ti.Pe(i,i.view,t)):(s.remove(),this.Mh.delete(t)));if(i.At)i.view&&this.ti.Pe(i,i.view,t);else{const s=this.ti.Ie(this.Vh,i);i.view=s,this.ti.Pe(i,s,t),i.At=!0}const e=i.view?.ps?.();e&&(this.pn(t,e),this.Mh.set(t,e))}fn(t,i){this.Mh.forEach((s,e)=>{(e<t||e>i)&&(s.parentElement===this.Vh&&s.remove(),this.Mh.delete(e))})}Jh(){this.Mh.forEach((t,i)=>{this.sn(i)||(t.parentElement===this.Vh&&t.remove(),this.Mh.delete(i))})}Qh(t){return this.xh.ph(t)}mn(t,i){return this.xh.gh(t+1,i+1)}bn(t){return this.xh.ph(t)}}E.an=.5,E.dn="data-vindex";class F extends r{constructor(t,i){super(),this.container={},this.oldValue=null,this.node=null,this.options=null,this.yn=null,this.isOpen=!1,this.wn=!1,this.vn=!1,this.ue=null,t&&i&&this.initialize(t,i)}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?.Ti?.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,i){const s=e.R(t);this.options=s.options,this.ue=i,this.init(t)}init(t){if(this.state!==o.NEW)return;if(!t||!this.options)return;const s=this.options,h=new l(s),n=new a,r=new f(s),effector=i(),c=new v(s),u=new M(s),d=new T(t,c,this),p=new O(t),m=new A(t);h.node&&(h.node.id=(s.Mn??"")+"");const b=e.I({Tn:{tag:{node:"div",classList:"selective-ui-MAIN"},F:{Ti:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.On()?.open())}},F:{An:{tag:h.node},Sn:{tag:n.node},ki:{tag:r.node}}}}}},null);this.container=b,this.node=b.view,b.Hn=d,b.placeholder=h,b.Cn=n,b.Ln=r,b.effector=effector,b.targetElement=t,b.Pn=u,b.In=p,b.En=m,c.As(P),c.Hs(s.virtualScroll?E:x),c.Ls(e.Y(t)),c.on("onUpdate",()=>{b.ee?.ri?.()}),this.yn=c,b.ee=new g(t,s,c),b.ee.fi(effector),b.ee.Oi(d,s),b.ee.gi("selected",()=>{this.On()?.change(null,!0)}),b.ee.gi("selected_internal",()=>{this.On()?.change(null,!1)}),b.ee.di("select",()=>{this.oldValue=this.On()?.value??""}),u.qs(b.tags.Ti),u.Qs(c),this.Fn(t,b,s,d,r),this.jn(p,m,t,c),this.isDisabled=e.V(s.disabled),this.xn=e.V(s.readonly),super.init()}mount(){if(this.state!==o.INITIALIZED)return;if(!this.node||!this.container.targetElement)return;const t=this.container.targetElement,i=this.container;t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,i.tags.Ti),i.tags.Ti.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.lt(t,i.tags.Ti),t.classList.add("init"),this.On()?.change(null,!1),super.mount()}update(){this.state===o.MOUNTED&&(this.container.ee?.ri?.(),super.update())}Fn(t,i,s,h,n){const o=i.ee.Et;let r=null;const l=(t,n)=>{n||""!==t?(""!==t&&(this.vn=!0),h.search(t).then(t=>{clearTimeout(r),e.Z.clear("sche_vis_proxy_"+o.Le),e.Z.on("sche_vis_proxy_"+o.Le,()=>{i.ee?.ri?.(),t?.xe&&(r=setTimeout(()=>{o.nh(),i.ee?.ri?.()},s.animationtime??0))},{st:10})}).catch(t=>{console.error("Search error:",t)})):h.clear()};let a=null;n.Fi=(t,e)=>{h.ve(t)&&(a&&clearTimeout(a),h.re()?(i.ee?.ei?.(),a=setTimeout(()=>{l(t,e)},s.delaysearchtime??0)):a=setTimeout(()=>{l(t,e)},10))},h.setPopup(i.ee),n.ji=t=>{o.navigate(t)},n.Vi=()=>{o.oh()},n.$i=()=>{this.On()?.close(),i.tags.Ti.focus()},o.ah=(t,i)=>{i&&n.Di(i)},o.th=()=>{i.ee?.ri?.()},s.ajax&&(null==s.ajax?.keepSelected&&(s.ajax.keepSelected=s.keepSelected),h.me(s.ajax))}jn(t,i,s,h){t.connect(),t.Pt=t=>{h.Es(e.Y(t)),this.On()?.refreshMask()},i.connect(),i.Pt=t=>{e.V(t.disabled)!==this.isDisabled&&(this.isDisabled=e.V(t.disabled)),e.V(t.readonly)!==this.xn&&(this.xn=e.V(t.readonly)),e.V(t.visible)!==this.isVisible&&(this.isVisible=e.V(t.visible??"1"))}}Vn(){const t=this.container??{},{In:i,En:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}destroy(){if(this.is(o.DESTROYED))return;this.Vn();const t=this.container;t.Hn.destroy(),t.Cn.destroy(),t.ee.destroy(),t.Pn.destroy(),t.placeholder.destroy(),t.Ln.destroy(),this.yn.destroy(),this.node?.remove(),this.container={},this.node=null,this.options=null,this.yn=null,this.ue=null,this.oldValue=null,this.isOpen=!1,this.wn=!1,this.vn=!1,super.destroy()}On(){const t=this.container,i=this,s=()=>this.ue.find(t.targetElement),n=e.R(t.targetElement);if(!n)return null;const r=n.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.Ln?.Ri(i)},get oldValue(){return i.oldValue},set value(t){this.setValue(null,t,!0)},get value(){const t=this.valueArray,i=t.length;return i>1?t:0===i?"":t[0]},get valueArray(){const t=[];return i.$n().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(r.customDelimiter)},get valueOptions(){const t=[];return i.$n(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.$n(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.$n(!0).forEach(i=>{t.push(i.text)});const s=t.length;return s>1?t:0===s?"":t[0]},get isOpen(){return i.isOpen},getParent:()=>t.view.parentElement,valueDataset(t,s=null,e=!1){var h=[];if(i.$n(!0).forEach(t=>{h.push(s?t.dataset[s]: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&&i.$n().length>r.maxSelected)&&!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.$n().forEach(t=>{t.ds=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.$n().forEach(t=>{t.ds=!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 i.$n().forEach(t=>t.ds=!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.Hn?.re?.()){const{fe:s}=t.Hn.pe(n);if(s.length>0)return void(async()=>{r.loadingfield&&t.ee?.ei?.();try{t.Hn.be();const e=await t.Hn.le(s);e.Li&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.Hn.Te?.(e.items,!0,!0),setTimeout(()=>{i.$n().forEach(t=>{t.ds=n.some(i=>i==t.value)}),this.change(!1,!1)},100)):s.length>0&&console.warn(`Could not load ${s.length} values:`,s)}catch(e){console.error("Error loading missing values:",e)}finally{r.loadingfield&&t.ee?.li?.()}})()}if(o){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.$n().forEach(t=>{t.ds=n.some(i=>i==t.value)}),!r.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,o)}},open(){if(i.isOpen)return;const e=i.ue?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(h.nt([s()],...r.on.beforeShow).isCancel)return;i.isOpen=!0,t.Cn.ft(!0);const n=t.ee.Et,o=n.hh();o?n.ih(o,!1):n.nh(),i.wn&&!i.vn||!r?.ajax?t.ee.open(null,!0):(t.Hn.be(),t.ee.ei(),i.wn=!0,i.vn=!1,setTimeout(()=>{t.ee&&t.Hn&&t.Hn.search("").then(()=>t.ee?.ri?.()).catch(t=>console.error("Initial ajax load error:",t))},r.animationtime),t.ee.open(null,!1)),t.Ln.show();const l=t.tags.Ti;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.nt([s()],...r.on.show)},close(){i.isOpen&&(h.nt([s()],...r.on.beforeClose).isCancel||(i.isOpen=!1,t.Cn.ft(!1),t.ee.close(()=>{t.Ln.clear(!1)}),t.Ln.hide(),t.tags.Ti.setAttribute("aria-expanded","false"),h.nt([s()],...r.on.close)))},toggle(){i.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.nt([s(),this.value],...r.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.Pn.Ys(this.valueOptions),n&&(t.targetElement&&h.ot(t.targetElement,"change"),h.nt([s(),this.value],...r.on.change),i.options?.autoclose&&this.close()),i.is(o.MOUNTED)&&i.update()},refreshMask(){let s=r.placeholder;!r.multiple&&i.$n().length>0&&(s=this.mask[0]),s??(s=r.placeholder),t.placeholder.set(s,!1),t.Ln.Ri(s)},on(t,i,s){r.on[i]||(r.on[i]=[]),r.on[i].push(s)},ajax(s,e){null==e.keepSelected&&(e.keepSelected=i.options.keepSelected),t.Hn.me(e)},loadAjax:()=>new Promise((e,h)=>{t.ee.ei(),t.Hn.be(),i.wn=!0,i.vn=!1,t.ee&&t.Hn?t.Hn.search("").then(()=>{t.ee?.ri?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(s())})};return this.kn(l,"disabled","isDisabled"),this.kn(l,"readonly","isReadOnly"),this.kn(l,"visible","isVisible"),l}kn(t,i,s){const e=this;Object.defineProperty(t,i,{get:()=>e[s],set(t){e[s]=!!t,e.container?.targetElement?.dataset&&(e.container.targetElement.dataset[i]=!!t+"")},enumerable:!0,configurable:!0})}$n(t=null){if(!this.yn)return[];const{Vs:i}=this.yn.Zt(),s=[];for(const e of i)e instanceof w?s.push(e):e instanceof y&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}}class j{constructor(){this.isActive=!1,this.He=null,this.actions=[]}Rn(t){this.actions.push(t)}Dn(){this.actions=[]}connect(t){if(this.isActive)return;this.isActive=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.He=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.zn(e),e.querySelectorAll(s).forEach(t=>this.zn(t))})}),this.He.observe(document.body,{childList:!0,subtree:!0})}disconnect(){this.isActive&&(this.isActive=!1,this.He?.disconnect(),this.He=null)}zn(t){this.actions.forEach(i=>i(t))}}class V extends r{constructor(){super(),this._n=new Map,this.init()}init(){this.is(o.NEW)&&(this._n=new Map,super.init())}bind(t,i){this.is(o.NEW)&&this.init();const s=e.$(e.U(),i);s.on=s.on??{},s.on.load=s.on.load??[],this._n.set(t,s);const n=e.m();e.Z.on(n,()=>{h.nt([this.find(t)],...s.on.load),e.Z.clear(n),s.on.load=[]});const r=e.v(t);let l=!1;r.forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e._(t),this.Bn(t,s)&&(l=!0,e.Z.run(n)))})()}),e.G().includes(t)||e.G().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 i={isEmpty:!0};if("*"===t&&""===(t=e.G().join(", ")))return i;const s=e.v(t);if(0===s.length)return i;const h=e.R(s[0]);if(!h||!h.action)return i;const n={};for(const e in h.action)n[e]=this.Nn(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.Un(o,t.name,s);break;case"func":this.Gn(o,t.name,s)}}return o}Wn(){this.qn||(this.qn=new j,this.qn.Rn(t=>{this._n.forEach((i,s)=>{try{t.matches(s)&&(this.Bn(t,i),this.is(o.MOUNTED)&&this.update())}catch(e){console.warn("Invalid selector: "+s,e)}})})),this.qn.connect("select")}destroy(t=null){null===t?this.Kn():"string"==typeof t?this.Qn(t):t instanceof HTMLSelectElement&&this.Yn(t),null!==t&&this.is(o.MOUNTED)&&this.update()}Kn(){this.state!==o.DESTROYED&&(e.G().forEach(t=>this.Qn(t)),this._n.clear(),e.G().length=0,this.qn?.disconnect(),super.destroy())}Qn(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.Yn(t)}),this._n.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}Yn(t){const i=e.R(t);if(!i)return;const s=i.self;e.N(t,i);const h=!!this.qn;h&&this.qn?.disconnect();try{i.self?.Vn?.()}catch(o){}const n=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.Jn,n&&n.parentNode?n.parentNode.replaceChild(t,n):t.appendChild(t),e.k(t),h&&this._n.size>0&&this.qn?.connect("select"),s?.destroy?.()}rebind(t,i){this.Qn(t),this.bind(t,i),this.is(o.MOUNTED)&&this.update()}Bn(t,i){if(e.R(t)||e.B(t))return!1;const s=e.m(8),h=e.j(t,i);h.Xn=s,h.Qt=`seui-${s}-optionlist`,h.Mn=`seui-${s}-placeholder`;const n={options:h};e.D(t,n);const o=new F(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}Nn(t,i){const s=Object.getOwnPropertyDescriptor(i,t);let e="variable";return s?.get||s?.set&&"function"!=typeof i[t]?e="get-set":"function"==typeof i[t]&&(e="func"),{type:e,name:t}}Un(t,i,s){Object.defineProperty(t,i,{get(){const t=e.R(s[0]);return t.action?.[i]},set(t){s.forEach(s=>{const h=e.R(s);h?.action&&(h.action[i]=t)})},enumerable:!0,configurable:!0})}Gn(t,i,s){t[i]=(...n)=>{let o=null;for(let t=0;t<s.length;t++){const r=e.R(s[t]);if(!r?.action)continue;const l=h.ht();if(o??(o=r.action[i](l.et,...n)),!l.token.isContinue)break}return o??t}}}if(void 0===globalThis.GLOBAL_SEUI){const k=new V;globalThis.GLOBAL_SEUI={version:"1.2.5",name:"SelectiveUI",bind:k.bind.bind(k),find:k.find.bind(k),destroy:k.destroy.bind(k),effector:i.bind(i),rebind:k.rebind.bind(k)};let R=!1;function D(){R||(R=!0,document.addEventListener("mousedown",()=>{const t=e.G();if(t.length>0){const i=k.find(t.join(", "));i.isEmpty||i.close()}}),k.Wn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",D):D()),console.log("[SelectiveUI] v1.2.5 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,$=globalThis.GLOBAL_SEUI.name;t.bind=(t,i={})=>{globalThis.GLOBAL_SEUI.bind(t,i)},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=$,t.rebind=(t,i={})=>{globalThis.GLOBAL_SEUI.rebind(t,i)},t.version=version},"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).SelectiveUI={});
|
|
Binary file
|