selective-ui 1.1.6 → 1.2.1
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.css +7 -1
- package/dist/selective-ui.css.map +1 -1
- package/dist/selective-ui.esm.js +794 -57
- 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.css +1 -1
- package/dist/selective-ui.min.css.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 +795 -58
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/css/components/popup.css +7 -1
- package/src/ts/adapter/mixed-adapter.ts +29 -18
- package/src/ts/components/empty-state.ts +5 -4
- package/src/ts/components/loading-state.ts +4 -4
- package/src/ts/components/option-handle.ts +4 -4
- package/src/ts/components/popup.ts +35 -6
- package/src/ts/components/searchbox.ts +2 -0
- package/src/ts/components/selectbox.ts +23 -9
- package/src/ts/core/base/adapter.ts +8 -5
- package/src/ts/core/base/model.ts +19 -1
- package/src/ts/core/base/recyclerview.ts +3 -1
- package/src/ts/core/base/virtual-recyclerview.ts +763 -0
- package/src/ts/core/model-manager.ts +24 -16
- package/src/ts/core/search-controller.ts +5 -8
- package/src/ts/models/option-model.ts +22 -3
- package/src/ts/services/effector.ts +7 -7
- package/src/ts/types/components/state.box.type.ts +1 -18
- package/src/ts/types/core/base/adapter.type.ts +14 -0
- package/src/ts/types/core/base/model.type.ts +5 -0
- package/src/ts/types/core/base/recyclerview.type.ts +3 -1
- package/src/ts/types/core/base/view.type.ts +6 -0
- package/src/ts/types/core/base/virtual-recyclerview.type.ts +66 -0
- package/src/ts/types/utils/istorage.type.ts +1 -0
- package/src/ts/utils/istorage.ts +3 -2
- package/src/ts/utils/libs.ts +26 -25
- package/src/ts/utils/selective.ts +7 -7
- package/src/ts/views/option-view.ts +8 -8
package/dist/selective-ui.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Selective UI v1.1
|
|
2
|
-
var t,i;t=this,i=function(t){"use strict";function i(t){return new g(t??null)}class s{constructor(){this.t={showPanel:!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:!0,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 T(t={}){return this.O(document.createElement(t.node??"div"),t,!0)}static O(t=document.documentElement,i=null,s=!1){const e={...i??{}},n=s?t:this.C(t.cloneNode(!0)),h=e.classList;return"string"==typeof h?n.classList.add(h):Array.isArray(h)&&n.classList.add(...h),delete e.classList,["style","dataset"].forEach(t=>{const i=e[t];i&&"object"==typeof i&&Object.assign(n[t],i),delete e[t]}),e.role&&(n.setAttribute("role",e.role+""),delete e.role),e.ariaLive&&(n.setAttribute("aria-live",e.ariaLive+""),delete e.ariaLive),e.A&&(n.setAttribute("aria-labelledby",e.A+""),delete e.A),e.S&&(n.setAttribute("aria-controls",e.S+""),delete e.S),e.L&&(n.setAttribute("aria-haspopup",e.L+""),delete e.L),e.P&&(n.setAttribute("aria-multiselectable",e.P+""),delete e.P),e.M&&(n.setAttribute("aria-autocomplete",e.M+""),delete e.M),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,i])=>{n.addEventListener(t,i)}),delete e.event),Object.entries(e).forEach(([t,i])=>{null===i?n.removeAttribute(t):n[t]=i}),n}static C(t){if(t instanceof Element)return t;throw new TypeError("Node is not an Element")}static H(t){return this.j(t)}static j(t,i=null,s=!1,e=!1,n={}){let h=null;for(const o in t){const l=t[o],r=l?.tag?.tagName?l.tag:this.T(l.tag);n[o]=r,l?.$&&this.j(l.$,r,!1,!1,n),i?s?i.prepend(r):i.append(r):e||h||(h=r)}return e||(n.id=this.m(7),i||(n={tags:n,view:h})),n}static I(t,i){const s=this.p(i);for(const e in s){const i=t[e];i?s[e]=i:void 0!==t?.dataset?.[e]&&(s[e]=t.dataset[e])}return s}static F(...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 _(t,i){this.l.i.set(t,i)}static D(t){return this.l.h.delete(t)}static N(t){return this.l.h.get(t)}static B(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??"",n=s.value??"";if(/^on/i.test(e))return void t.removeAttribute(e);/^(href|src|xlink:href)$/i.test(e)&&/^javascript:/i.test(n)&&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.T({node:"div",style:{height:i,opacity:"0"}});document.body.appendChild(e);const n=e.offsetHeight+"px";return e.remove(),n}}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,n=s.once??!1;this.tt.has(t)||this.tt.set(t,[]),this.tt.get(t).push({et:i,timeout:e,once:n})}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)return;this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t);for(let n=0;n<s.length;n++){const t=s[n];if(!t)continue;const h=e.get(n);h&&clearTimeout(h);const o=setTimeout(()=>{if(t.et(i.length>0?i:null),t.once){s[n]=void 0;const t=e.get(n);t&&clearTimeout(t),e.delete(n)}},t.timeout);e.set(n,o)}}clear(t){if(void 0===t)for(const i of Array.from(this.tt.keys()))this.off(i);else this.off(t)}};class n{static nt(){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 ht(t,...i){const{token:s,et:e}=this.nt();for(let n=0;n<i.length;n++){const h=i[n];if("function"==typeof h&&(t&&Array.isArray(t)?h(e,...t):h(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 lt(t,...i){if(Array.isArray(t))for(const s of t)"function"==typeof s&&s(...i)}}class h{static rt(t,i){const s=e.R(t);if(!s?.options)return;const n=s.options,h=n.minWidth,o=n.minHeight,l=Number.parseInt(n.width,10),r=Number.parseInt(n.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),l>0&&(a=n.width),r>0&&(c=n.height),Object.assign(i.style,{width:a,height:c,minWidth:h,minHeight:o})}}class o{constructor(t){this.node=null,this.ct=null,t&&this.init(t)}init(t){this.node=e.T({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.ct=t}get(){return this.ct?.placeholder??""}set(t,i=!0){if(!this.node||!this.ct)return;i&&(this.ct.placeholder=t);const s=e.W(t);this.node.innerHTML=this.ct.allowHtml?s:e.q(s)}}class l{constructor(){this.node=this.ut()}ut(){return e.T({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"})}dt(t){this.node.classList.toggle("drop-down",!!t)}}class r{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.ft=[],this.bt=[],t&&this.init(t)}init(t){this.gt=e.j({wt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},$:{yt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{n.lt(this.ft)}}},vt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{n.lt(this.bt)}}}}}}),this.node=this.gt.view,this.options=t}available(){return!!this.options&&e.V(this.options.multiple)&&e.V(this.options.selectall)}refresh(){this.node&&(this.available()?this.show():this.hide())}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}xt(t=null){"function"==typeof t&&this.ft.push(t)}Tt(t=null){"function"==typeof t&&this.bt.push(t)}}class a{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-empty-state","hide"],role:"status",ariaLive:"polite"})}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")}}class c{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"})}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")}}class u{constructor(){this.Ot=!1,this.element=null,this.Ct=null,this.At=null,this.Ot=!0,this.St=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.Ct=new ResizeObserver(this.St),this.Ct.observe(t),this.At=new MutationObserver(this.St),this.At.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.St,!0),window.addEventListener("resize",this.St),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.St),window.visualViewport.addEventListener("scroll",this.St))}disconnect(){this.Ct?.disconnect(),this.At?.disconnect(),this.Pt=()=>{},window.removeEventListener("scroll",this.St,!0),window.removeEventListener("resize",this.St),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.St),window.visualViewport.removeEventListener("scroll",this.St)),this.Ct=null,this.At=null,this.element=null}}class d{constructor(t=null,i=null,s=null){this.options=null,this.Mt=!1,this.Ht=null,this.node=null,this.jt=null,this.$t=null,this.Et=null,this.It=null,this.Ft=null,this.Vt=null,this.kt=null,this.Rt=null,this._t=null,this.Dt=null,this.Nt=s,t&&i&&this.init(t,i)}init(t,i){if(!this.Nt)throw Error("Popup requires a ModelManager instance.");this.It=new r(i),this.Ft=new a(i),this.Vt=new c(i);const s=e.j({Bt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},$:{wt:{tag:this.It.node},Ut:{tag:{id:i.zt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Gt:{tag:this.Vt.node},Wt:{tag:this.Ft.node}}}},null);this.node=s.view,this.Rt=s.tags.Ut,this.Et=e.R(t),this.options=i,this.Nt.load(this.Rt,{isMultiple:i.multiple});const n=this.Nt.qt();this.Ht=n.Jt,this.kt=n.kt,this.It.xt(()=>{n.Jt.Kt(!0)}),this.It.Tt(()=>{n.Jt.Kt(!1)}),this.Qt()}async Yt(){this.options&&this.Vt&&this.It&&this.Ht&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Nt.Xt(!0),!1!==e.V(this.options.loadingfield)&&(this.Ft.hide(),this.Vt.show(this.Ht.ti().Zt),this.ii()))}async si(){this.options&&this.Vt&&this.Ht&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Dt=setTimeout(()=>{this.Nt?.Xt(!1),this.Vt?.hide();const t=this.Ht?.ti();this.ei(t??void 0),this.ii()},200))}Qt(){this.Ht&&(this.Ht.ni(t=>{this.ei(t)}),this.Ht.hi("items",()=>{const t=this.Ht.ti();this.ei(t),this.ii()}))}ei(t){if(!(this.Ht&&this.Ft&&this.It&&this.Rt))return;const i=t??this.Ht.ti();i.isEmpty?(this.Ft.show("nodata"),this.Rt.classList.add("hide"),this.It.hide()):i.Zt?(this.Ft.hide(),this.Rt.classList.remove("hide"),this.It.refresh()):(this.Ft.show("notfound"),this.Rt.classList.add("hide"),this.It.hide())}oi(t,i){this.Ht?.li(t,i)}ri(t,i){this.Ht?.hi(t,i)}ai(t){this.jt=t}open(t=null,i){if(!(this.node&&this.options&&this.It&&this.Et&&this.jt))return;this.Mt||(document.body.appendChild(this.node),this.Mt=!0,this.$t=new u,this.jt.ci(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.It.refresh(),i&&this.ei();const s=this.ui(),{position:e,top:n,maxHeight:h,di:o}=this.pi(s);this.jt.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:n,maxHeight:h,di:o,position:e,gi:()=>{this.$t&&this.Et&&(this.$t.Pt=()=>{const t=this.ui();this.fi(t)},this.$t.connect(this.Et.container.tags.mi),t?.())}})}close(t=null){this.Mt&&this.options&&this.$t&&this.jt&&(this.$t.disconnect(),this.jt.collapse({duration:this.options.animationtime,gi:t??void 0}))}ii(){this.Mt&&this.$t?.ot()}bi(t,i){this.node&&(this._t=async()=>{const i=t.wi();if(!i.yi)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.xi&&i.hasMore){const i=await t.Ti();!i.Oi&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this._t))}Ci(){this.Dt&&(clearTimeout(this.Dt),this.Dt=null),this.node&&this._t&&(this.node.removeEventListener("scroll",this._t),this._t=null);try{this.$t?.disconnect()}catch(t){}this.$t=null;try{this.jt?.ci?.(null)}catch(t){}if(this.jt=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.Rt=null;try{this.Nt?.Xt?.(!1),this.kt?.clear?.(),this.kt=null,this.Ht=null,this.node.remove()}catch(t){}this.Nt=null,this.It=null,this.Ft=null,this.Vt=null,this.Et=null,this.options=null,this.Mt=!1}ui(){const t=this.Et.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)}}}pi(t){const i=window.visualViewport,s=e.Y(),n=i?.height??window.innerHeight,h=this.jt.Ai("flex").scrollHeight,o=parseFloat(this.options?.panelHeight??"220")||220,l=parseFloat(this.options?.panelMinHeight??"100")||100,r=n-(t.top+t.height)-3,a=t.top-3;let c="bottom",u=o,d=Math.min(h,u);const p=r-15;(d>=l?p>=l:p>=d)?(c="bottom",u=Math.min(r-15,o)):a>=Math.max(d,l)?(c="top",u=Math.min(a-15,o)):r>=a?(c="bottom",u=Math.max(r-15,l)):(c="top",u=Math.max(a-15,l)),d=Math.min(h,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,di:d,Si:h}}fi(t){if(!this.options||!this.jt)return;const{position:i,top:s,maxHeight:e,di:n}=this.pi(t);this.jt.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,di:n,position:i,animate:!0})}}class p{constructor(t=null){this.gt=null,this.node=null,this.Li=null,this.Pi=null,this.options=null,this.Mi=null,this.Hi=null,this.ji=null,this.options=t,t&&this.init(t)}init(t){this.gt=e.j({$i:{tag:{node:"div",classList:["selective-ui-searchbox","hide"]},$:{Li:{tag:{id:e.m(),node:"input",type:"search",classList:["selective-ui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",S:t.zt,M:"list"}}}}}),this.node=this.gt.view,this.Li=this.gt.tags.Li;let i=!1;const s=this.gt.tags.Li;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.Mi?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Mi?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Hi?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.())}),s.addEventListener("input",()=>{i||this.Pi?.(s.value,!0)})}show(){this.node&&this.Li&&this.options&&(this.node.classList.remove("hide"),this.Li.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.Li?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.gt&&(this.gt.tags.Li.value="",this.Pi?.("",t))}Ei(t){this.Li&&(this.Li.placeholder=e.q(t))}Ii(t){this.Li&&this.Li.setAttribute("aria-activedescendant",t)}}class g{constructor(t=null){this.Fi=null,this.Vi=null,this.ki=!1,t&&this.ci(t)}ci(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.Fi&&(clearTimeout(this.Fi),this.Fi=null),this.Vi&&(clearTimeout(this.Vi),this.Vi=null),this.ki=!1,this}Ai(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),n=parseFloat(s.borderBottomWidth),h=this.element.scrollHeight+e+n,o=this.element.getBoundingClientRect(),l={width:o.width,height:o.height+e+n,scrollHeight:h};return Object.assign(this.element.style,i),l}expand(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,display:s="flex",width:e,left:n,top:h,maxHeight:o,di:l,position:r="bottom",gi:a}=t;return Object.assign(this.element.style,{display:s,width:e+"px",left:n+"px",top:("bottom"===r?h:h+l)+"px",maxHeight:o+"px",height:"0px",opacity:"0",overflow:"hidden",transition:"none"}),this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`top ${i}ms, height ${i}ms, opacity ${i}ms`,top:h+"px",height:l+"px",opacity:"1",overflow:l>=o?"auto":"hidden"}),this.Fi=setTimeout(()=>{this.element.style.transition="none",this.ki=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,gi:s}=t,e=this.element.offsetHeight,n=this.element.offsetTop,h=this.element.classList.contains("position-top")?"top":"bottom",o=this.element.scrollHeight-this.element.offsetHeight>0,l="top"===h?n+e:n;return requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`height ${i}ms, top ${i}ms, opacity ${i}ms`,height:"0px",top:l+"px",opacity:"0",overflow:o?"auto":"hidden"}),this.Fi=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.ki=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,display:s="block",gi:e}=t;Object.assign(this.element.style,{transition:"none",display:s,width:"fit-content"});const n=this.Ai(s).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:n+"px",overflow:"hidden"})}),this.Fi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.ki=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,gi:s}=t,e=this.Ai().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.Fi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.ki=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.Vi&&clearTimeout(this.Vi);const{duration:i=200,width:s,left:e,top:n,maxHeight:h,di:o,position:l="bottom",animate:r=!0,gi:a}=t,c=(this.element.classList.contains("position-top")?"top":"bottom")!==l,u=this.element.scrollHeight>h;return this.element.classList.toggle("position-top","top"===l),this.element.classList.toggle("position-bottom","bottom"===l),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:n+"px",maxHeight:h+"px",height:o+"px",overflowY:u?"auto":"hidden"},l=Math.abs(this.element.offsetHeight-o);r&&(c||l>5)?t.transition=`height ${i}ms, top ${i}ms`:this.Vi=setTimeout(()=>{this.element?.style&&(this.element.style.transition="none")},i),Object.assign(this.element.style,t),r&&(c||l>1)?this.Vi=setTimeout(()=>{this.element.style.transition="none",c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())}),this}get Ri(){return this.ki}}class f{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){this.targetElement=null,this.view=null,this.position=-1,this.Ot=!1,this.options=t,this.targetElement=i,this.view=s}update(t){this.targetElement=t,this._i()}_i(){}}class m extends f{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.Di=[],i&&(this.label=i.label,this.collapsed=e.V(i.dataset?.collapsed))}get value(){return this.items.map(t=>t.value)}get Ni(){return this.items.filter(t=>t.selected)}get Bi(){return this.items.filter(t=>t.visible)}get Ui(){return this.Bi.length>0}update(t){this.label=t.label,this.view?.zi(this.label)}_i(){this.view&&(this.view.zi(this.label),this.view.Gi(this.collapsed))}Wi(t){this.Di.push(t)}qi(){this.collapsed=!this.collapsed,this.view?.Gi(this.collapsed),n.ht([this,this.collapsed],...this.Di)}Ji(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)}Ki(){this.view?.Ki()}}class b extends f{constructor(){super(...arguments),this.Qi=[],this.Yi=[],this.Xi=[],this.Zi=!0,this.ts=!1,this.group=null}get ss(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ss}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.es=t,n.ht([this,t],...this.Qi)}get visible(){return this.Zi}set visible(t){if(this.Zi===t)return;this.Zi=t;const i=this.view?.ns?.();i&&i.classList.toggle("hide",!t),n.ht([this,t],...this.Xi)}get es(){return this.selected}set es(t){const i=this.view?.view?.tags?.hs,s=this.view?.ns?.();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),n.ht([this,t],...this.Yi)}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 ls(){return this.ts}set ls(t){const i=!!t,s=this.view?.ns?.();this.ts!==i&&(this.ts=i),s&&s.classList.toggle("highlight",i)}rs(t){this.Qi.push(t)}cs(t){this.Yi.push(t)}ni(t){this.Xi.push(t)}_i(){if(!this.view)return;const t=this.view.view.tags.us;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.ds;i&&this.hasImage&&(i.src=this.ss,i.alt=this.text),this.targetElement&&(this.es=this.targetElement.selected)}}class w{constructor(t){this.ps=[],this.gs=null,this.fs=null,this.bs=null,this.options=null,this.options=t}ws(t){this.ys=t}vs(t){this.xs=t}Ts(t){const i=this.Os(t),s=i!==this.bs;return s&&(this.bs=i),s}Os(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")}Cs(t){this.ps=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new m(this.options,t),this.ps.push(i);else if("OPTION"===t.tagName){const s=t,e=new b(this.options,s),n=s.__parentGroup;n&&i&&n===i.targetElement?(i.Ji(e),e.group=i):(this.ps.push(e),i=null)}}),this.ps}replace(t){this.bs=null,this.Cs(t),this.gs&&this.gs.As(this.ps),this.refresh()}notify(){this.gs&&this.refresh()}load(t,i={},s={}){this.gs=new this.ys(this.ps),Object.assign(this.gs,i),this.fs=new this.xs(t),this.fs.Ss(this.gs),Object.assign(this.fs,s)}update(t){if(!this.Ts(t))return;const i=this.ps,s=[],e=new Map,n=new Map;i.forEach(t=>{t instanceof m?e.set(t.label,t):t instanceof b&&n.set(`${t.value}::${t.textContent}`,t)});let h=null,o=0;t.forEach(t=>{if("OPTGROUP"===t.tagName){const i=t,n=e.get(i.label);n?(n.label!==i.label&&n.update(i),n.position=o,n.items=[],h=n,s.push(n),e.delete(i.label)):(h=new m(this.options,i),h.position=o,s.push(h)),o++}else if("OPTION"===t.tagName){const i=t,e=`${i.value}::${i.text}`,l=n.get(e);if(l)l.update(i),l.position=o,i.__parentGroup&&h?(h.Ji(l),l.group=h):(l.group=null,s.push(l)),n.delete(e);else{const t=new b(this.options,i);t.position=o,i.__parentGroup&&h?(h.Ji(t),t.group=h):s.push(t)}o++}}),e.forEach(t=>{t.view?.ns?.()?.remove?.()}),n.forEach(t=>{t.view?.ns?.()?.remove?.()}),this.ps=s,this.gs&&this.gs.Ls(this.ps),this.onUpdated(),this.refresh()}onUpdated(){}Xt(t){this.gs&&(this.gs.Ps=t)}refresh(){this.fs&&(this.fs.refresh(),this.onUpdated())}qt(){return{Ms:this.ps,Jt:this.gs,kt:this.fs}}Hs(t){this.gs?.js(t)}$s(t){this.gs?.Es(t)}}class y{constructor(t=null){this.Is=null,this.Jt=null,this.Is=t}Fs(t){this.Is=t}Ss(t){this.Jt=t,t.li("items",()=>{this.clear()}),t.hi("items",()=>{this.Vs()}),this.Vs()}clear(){this.Is&&this.Is.replaceChildren()}Vs(){this.Jt&&this.Is&&this.Jt.ks(this.Is)}refresh(){this.Vs()}}class v{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.Rs=null,this._s=null,this.Ds=null,t&&this.init(t)}init(t){this.gt=e.j({Ns:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.gt.view,this.options=t}Bs(t){this.Rs=t,this._s=t.parentElement,this.Us()}Us(){this._s&&this.node&&this.Rs&&this.options&&this._s.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Rs:this.Rs.nextSibling)}zs(t){this.Ds=t}Gs(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?(this.node.classList.remove("hide"),t.forEach(t=>{e.j({Ws:{tag:{node:"div",classList:["accessory-item"]},$:{qs:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:i=>{i.preventDefault(),this.Ds?.Hs?.("select"),setTimeout(()=>{t.selected=!1},10)}}},Js:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)})):this.node.classList.add("hide"),n.ot(window,"resize"))}}class x{constructor(t,i,s){this.Ks=null,this.Qs=null,this.Ys=null,this.Xs=null,this.Zs={currentPage:0,totalPages:1,hasMore:!1,xi:!1,te:"",yi:!1},this.ie=t,this.Nt=i,this.Xs=s}se(){return!!this.Ks}async ee(t){if(!this.Ks)return{Oi:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Oi:!0,items:[]};try{const t=this.Ks;let s,e;if(s="function"==typeof t.ne?t.ne(i):{values:i.join(","),he:"1",..."function"==typeof t.data?t.data.bind(this.Xs.oe.find(this.Xs.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 n=await e.json();return{Oi:!0,items:this.le(n).items}}catch(s){return console.error("Load by values error:",s),{Oi:!1,message:s?.message,items:[]}}}re(t){const i=Array.from(this.ie.options).map(t=>t.value);return{ae:t.filter(t=>i.includes(t)),ce:t.filter(t=>!i.includes(t))}}ue(t){this.Ks=t}setPopup(t){this.Ys=t}wi(){return{...this.Zs}}de(){this.Zs={currentPage:0,totalPages:1,hasMore:!1,xi:!1,te:"",yi:this.Zs.yi}}clear(){this.Zs.te="";const{Ms:t}=this.Nt.qt(),i=[];for(const s of t)s instanceof b?i.push(s):s instanceof m&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.Ks?this.pe(t,i):this.ge(t)}async Ti(){return this.Ks?this.Zs.xi?{Oi:!1,message:"Already loading"}:this.Zs.yi?this.Zs.hasMore?(this.Zs.currentPage++,this.pe(this.Zs.te,!0)):{Oi:!1,message:"No more data"}:{Oi:!1,message:"Pagination not enabled"}:{Oi:!1,message:"Ajax not enabled"}}async ge(t){this.fe(t)&&(this.Zs.te=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{Ms:n}=this.Nt.qt(),h=[];for(const e of n)e instanceof b?h.push(e):e instanceof m&&Array.isArray(e.items)&&h.push(...e.items);let o=!1;return h.forEach(t=>{const n=((t.textContent??t.text??"")+"").toLowerCase(),h=e.J(n),l=""===i||n.includes(i)||h.includes(s);t.visible=l,l&&(o=!0)}),{Oi:!0,me:o,isEmpty:0===h.length}}fe(t){return t!==this.Zs.te}async pe(t,i=!1){const s=this.Ks;this.fe(t)&&(this.de(),this.Zs.te=t,i=!1),this.Zs.xi=!0,this.Ys?.Yt(),this.Qs?.abort(),this.Qs=new AbortController;const e=this.Zs.currentPage,n=Array.from(this.ie.selectedOptions).map(t=>t.value).join(",");let h;"function"==typeof s.data?(h=s.data.bind(this.Xs.oe.find(this.Xs.container.targetElement))(t,e),h&&void 0===h.selectedValue&&(h.selectedValue=n)):h={search:t,page:e,selectedValue:n,...s.data??{}};try{let t;if("POST"===(s.method??"GET")){const i=new URLSearchParams;Object.keys(h).forEach(t=>i.append(t,h[t]+"")),t=await fetch(s.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.Qs.signal})}else{const i=""+new URLSearchParams(h);t=await fetch(`${s.url}?${i}`,{signal:this.Qs.signal})}const e=await t.json(),n=this.le(e);return n.be?(this.Zs.yi=!0,this.Zs.currentPage=n.page,this.Zs.totalPages=n.totalPages,this.Zs.hasMore=n.hasMore):this.Zs.yi=!1,this.we(n.items,!!s.keepSelected,i),this.Zs.xi=!1,this.Ys?.si(),{Oi:!0,me:n.items.length>0,isEmpty:0===n.items.length,be:n.be,hasMore:n.hasMore,currentPage:n.page,totalPages:n.totalPages}}catch(o){return this.Zs.xi=!1,this.Ys?.si(),"AbortError"===o?.name?{Oi:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Oi:!1,message:o?.message})}}le(t){let i=[],s=!1,e=0,n=1,h=!1;return t.object&&Array.isArray(t.object)?(i=t.object,void 0!==t.page&&(s=!0,e=parseInt(t.page??0,10),n=parseInt(t.totalPages??t.total_page??1,10),h=e<n-1)):t.data&&Array.isArray(t.data)?(i=t.data,void 0!==t.page&&(s=!0,e=parseInt(t.page??0,10),n=parseInt(t.totalPages??t.total_page??1,10),h=t.hasMore??e<n-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),n=parseInt(t.pagination.totalPages??t.pagination.total_page??1,10),h=t.pagination.hasMore??e<n-1)),{items:i.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.ye||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}}),be:s,page:e,totalPages:n,hasMore:h}}we(t,i,s=!1){const e=this.ie;let n=[];i&&(n=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&&n.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&&n.includes(s.value))&&(s.selected=!0),e.appendChild(s)}}),e.dispatchEvent(new CustomEvent("options:changed"))}}class T{constructor(t){this.ve=null,this.xe=null,this.Te=50,this.ie=t,this.xe=this.Oe(),this.Ce=new MutationObserver(()=>{this.ve&&clearTimeout(this.ve),this.ve=setTimeout(()=>{this.Ae()},this.Te)}),t.addEventListener("options:changed",()=>{this.ve&&clearTimeout(this.ve),this.ve=setTimeout(()=>{this.Ae()},this.Te)})}Oe(){const t=Array.from(this.ie.options);return{length:t.length,values:t.map(t=>t.value).join(","),Se:t.map(t=>t.text).join(","),selected:t.map(t=>t.selected+"").join(",")}}Le(){const t=this.Oe(),i=JSON.stringify(t)!==JSON.stringify(this.xe);return i&&(this.xe=t),i}Ae(){this.Le()&&this.Pt(this.ie)}connect(){this.Ce.observe(this.ie,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.ve&&clearTimeout(this.ve),this.ve=null,this.Ce.disconnect()}}class O{constructor(t){this.ve=null,this.Pe=t,this.Ce=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.ve&&clearTimeout(this.ve),this.ve=setTimeout(()=>{this.Pt({...this.Pe.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.Pe.dataset})})}connect(){this.Ce.observe(this.Pe,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.ve&&clearTimeout(this.ve),this.ve=null,this.Ce.disconnect()}}class C{constructor(t=[]){this.items=[],this.Me=e.m(12),this.Ps=!1,this.items=t,this.He()}He(){}je(t,i,s){const e=i;t.Ot?e?.update?.():e?.Vs?.()}li(t,i){e.Z.on(`${t}ing_${this.Me}`,i,{st:1})}hi(t,i){e.Z.on(`${t}_${this.Me}`,i)}Es(t,...i){e.Z.run(`${t}_${this.Me}`,...i)}js(t,...i){e.Z.run(`${t}ing_${this.Me}`,...i)}$e(t,i){return null}Ee(){return this.items.length}Ie(t){this.js("items",t),this.items=t,this.Es("items",t)}As(t){this.Ie(t)}ks(t){for(let i=0;i<this.Ee();i++){const s=this.items[i];let e=s.view;s.Ot||(e=this.$e(t,s),s.view=e),this.je(s,e,i),s.Ot=!0}}Ls(t){}}class A{constructor(t){this.parent=null,this.view=null,this.parent=t}Vs(){}update(){}ns(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}}class S extends A{constructor(){super(...arguments),this.view=null}Vs(){const t=e.m(7);this.view=e.H({Fe:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},$:{Ve:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},ke:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view)}update(){this.zi()}zi(t=null){this.view&&null!==t&&(this.view.tags.Ve.textContent=t)}Re(){if(!this.view)throw Error("GroupView is not rendered.");return this.view.tags.ke}Ki(){if(!this.view)return;const t=Array.from(this.view.tags.ke.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",!(t.length>0))}Gi(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.Ve.setAttribute("aria-expanded",t?"false":"true"))}}class L extends A{constructor(t){super(t),this.view=null,this._e=null,this.De=null,this.Ne=!1,this.Be()}Be(){const t=this;this._e={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.De=new Proxy(this._e,{set(i,s,e){if("string"!=typeof s)return!0;const n=s,h=i[n];return h!==e&&(i[n]=e,t.Ne&&t.Ue(n,e,h)),!0}})}get isMultiple(){return this._e.isMultiple}set isMultiple(t){this.De.isMultiple=!!t}get hasImage(){return this._e.hasImage}set hasImage(t){this.De.hasImage=!!t}get ze(){return this.De}set ze(t){if(!t||!this.De||!this._e)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this._e.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this._e.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this._e.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this._e.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this._e.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this._e.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.De,i)}Vs(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this._e.isMultiple&&t.push("multiple"),this._e.hasImage&&(t.push("has-image"),t.push("image-"+this._e.imagePosition));const n={hs:{tag:{node:"input",type:this._e.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this._e.hasImage&&{ds:{tag:{node:"img",classList:"option-image",style:{width:this._e.imageWidth,height:this._e.imageHeight,borderRadius:this._e.imageBorderRadius}}}},Ge:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this._e.labelValign,"align-horizontal-"+this._e.labelHalign]},$:{us:{tag:{node:"div"}}}}};this.view=e.H({We:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},$:n}}),this.parent.appendChild(this.view.view),this.Ne=!0}Ue(t,i,s){const e=this.view;if(!e||!e.view)return;const n=e.view,h=e.tags?.hs,o=e.tags?.Ge;switch(t){case"isMultiple":{const t=!!i;n.classList.toggle("multiple",t),h&&h.type!==(t?"checkbox":"radio")&&(h.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!i;if(n.classList.toggle("has-image",t),t)n.classList.add("image-"+this._e.imagePosition),this.qe();else{n.className=n.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.ds;t&&(t.remove(),e.tags.ds=null)}break}case"imagePosition":this._e.hasImage&&(n.className=n.className.replace(/image-(top|right|bottom|left)/g,"").trim(),n.classList.add("image-"+i));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const s=e.tags?.ds;if(s){const e="imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius",n=i+"";s.style[e]!==n&&(s.style[e]=n)}break}case"labelValign":case"labelHalign":if(o){const t=`align-vertical-${this._e.labelValign} align-horizontal-${this._e.labelHalign}`;o.className!==t&&(o.className=t)}}}qe(){const t=this.view;if(!t||!t.view)return;const i=t.tags?.ds;if(i)return;const s=t.view,e=t.tags?.Ge,n=document.createElement("img");n.className="option-image",n.style.width=this._e.imageWidth,n.style.height=this._e.imageHeight,n.style.borderRadius=this._e.imageBorderRadius,e&&e.parentElement?s.insertBefore(n,e):s.appendChild(n),t.tags.ds=n}}class P extends C{constructor(t=[]){super(t),this.isMultiple=!1,this.Je=[],this.Ke=-1,this.Qe=null,this.groups=[],this.Ye=[],this.Xe()}Xe(){this.Ye=[],this.groups=[],this.items.forEach(t=>{t instanceof m?(this.groups.push(t),this.Ye.push(...t.items)):t instanceof b&&this.Ye.push(t)})}$e(t,i){return i instanceof m?new S(t):new L(t)}je(t,i,s){t.position=s,t instanceof m?this.Ze(t,i,s):t instanceof b&&this.tn(t,i,s),t.Ot=!0}Ze(t,i,s){super.je(t,i,s),t.view=i;const e=i.view.tags.Ve;e.textContent=t.label,t.Ot||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.qi()}),t.Wi((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.ns?.();i&&(i.style.display=s?"none":"")}),this.sn(i,s)}));const n=i.Re();t.items.forEach((t,i)=>{let s=t.view;t.Ot&&s||(s=new L(n)),this.tn(t,s,i),t.Ot=!0}),i.Gi(t.collapsed),i.Ki()}tn(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.ze={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.Ot||super.je(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.ds;s&&(s.src!==t.ss&&(s.src=t.ss),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.us.innerHTML=t.text,t.Ot||(i.view.tags.We.addEventListener("click",i=>{i.stopPropagation(),i.preventDefault(),this.Ps||(this.isMultiple?(this.js("select"),setTimeout(()=>{t.selected=!t.selected},5)):!0!==t.selected&&(this.js("select"),setTimeout(()=>{this.Qe&&(this.Qe.selected=!1),t.selected=!0},5)))}),i.view.tags.We.title=t.textContent,i.view.tags.We.addEventListener("mouseenter",()=>{this.Ps||this.en(this.Ye.indexOf(t),!1)}),t.rs(()=>{this.Es("selected")}),t.cs((i,s,e)=>{e&&(this.Qe=t),this.Es("selected_internal")}),t.ni((t,i)=>{i.group?.Ki(),this.nn()})),t.selected&&(this.Qe=t,t.es=!0)}Ie(t){this.js("items",t),this.items=t,this.Xe(),this.Es("items",t)}As(t){this.Ie(t)}Ls(t){this.items=t,this.Xe()}hn(){return this.Ye.filter(t=>t.selected)}ln(){return this.Ye.find(t=>t.selected)}Kt(t){this.isMultiple&&this.Ye.forEach(i=>{i.selected=t})}ni(t){this.Je.push(t)}nn(){const t=this.Ye.filter(t=>t.visible).length,i=this.Ye.length;this.Je.forEach(s=>{s({rn:t,an:i,Zt:t>0,isEmpty:0===i})})}ti(){const t=this.Ye.filter(t=>t.visible).length,i=this.Ye.length;return{rn:t,an:i,Zt:t>0,isEmpty:0===i}}cn(){this.en(0)}navigate(t,i=!0){const s=this.Ye.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.Ye[this.Ke]);-1===e&&(e=-1);let n=e+t;n>=s.length&&(n=0),n<0&&(n=s.length-1);const h=this.Ye.indexOf(s[n]);this.en(h,i)}un(){if(this.Ke>-1&&this.Ye[this.Ke]){const t=this.Ye[this.Ke];if(t.visible){const i=t.view?.ns?.();i&&i.click()}}}en(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof b){const i=this.Ye.indexOf(t);s=i>-1?i:0}else s=0;this.Ke>-1&&this.Ye[this.Ke]&&(this.Ye[this.Ke].ls=!1);for(let e=s;e<this.Ye.length;e++){const t=this.Ye[e];if(t.visible){if(t.ls=!0,this.Ke=e,i){const i=t.view?.ns?.();i&&i.scrollIntoView({block:"center",behavior:"smooth"})}return void this.dn(e,t.view?.ns?.()?.id)}}}dn(t,i){}sn(t,i){}}class M{constructor(t=null,i=null){this.container={},this.oldValue=null,this.node=null,this.options=null,this.pn=null,this.isOpen=!1,this.gn=!1,this.fn=!1,this.oe=null,t&&this.init(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 mn(){return!!this.options?.readonly}set mn(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))}init(t,s){const n=e.R(t).options,r=new o(n),a=new l,c=new p(n),effector=i(),u=new w(n),g=new v(n),f=new x(t,u,this),m=new T(t),b=new O(t);this.oe=s,this.options=n,r.node&&(r.node.id=(n.bn??"")+"");const C=e.j({wn:{tag:{node:"div",classList:"selective-ui-MAIN"},$:{mi:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.yn()?.open())}},$:{vn:{tag:r.node},xn:{tag:a.node},$i:{tag:c.node}}}}}},null);this.container=C,this.node=C.view,t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,C.tags.mi),g.Bs(C.tags.mi),g.zs(u),C.tags.mi.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),h.rt(t,C.tags.mi),t.classList.add("init"),u.ws(P),u.vs(y),u.Cs(e.K(t)),u.onUpdated=()=>{C.Tn?.ii?.()},this.pn=u,C.On=f,C.placeholder=r,C.Cn=a,C.An=c,C.effector=effector,C.targetElement=t,C.Sn=g,C.Ln=m,C.Pn=b,C.Tn=new d(t,n,u),C.Tn.ai(effector),C.Tn.bi(f,n),C.Tn.ri("selected",()=>{this.yn()?.change(null,!0)}),C.Tn.ri("selected_internal",()=>{this.yn()?.change(null,!1)}),C.Tn.oi("select",()=>{this.oldValue=this.yn()?.value??""}),this.yn()?.change(null,!1),m.connect(),m.Pt=t=>{u.update(e.K(t)),this.yn()?.refreshMask()},b.connect(),b.Pt=t=>{e.V(t.disabled)!==this.isDisabled&&(this.isDisabled=e.V(t.disabled)),e.V(t.readonly)!==this.mn&&(this.mn=e.V(t.readonly)),e.V(t.visible)!==this.isVisible&&(this.isVisible=e.V(t.visible??"1"))},t.addEventListener("options:changed",()=>{u.update(e.K(t)),this.yn()?.refreshMask(),C.Tn?.ii?.()}),n.ajax&&f.ue(n.ajax);const A=C.Tn.Ht,S=(t,i)=>{i||""!==t?(""!==t&&(this.fn=!0),f.search(t).then(t=>{C.Tn?.ii?.(),t?.me&&setTimeout(()=>{A.cn()},n.animationtime?n.animationtime+10:0)}).catch(t=>{console.error("Search error:",t)})):f.clear()};let L=null;c.Pi=(t,i)=>{f.fe(t)&&(f.se()?(L&&clearTimeout(L),C.Tn?.Yt?.(),L=setTimeout(()=>{S(t,i)},n.delaysearchtime??0)):S(t,i))},f.setPopup(C.Tn),c.Mi=t=>{A.navigate(t)},c.Hi=()=>{A.un()},c.ji=()=>{this.yn()?.close(),C.tags.mi.focus()},A.dn=(t,i)=>{i&&c.Ii(i)},A.sn=()=>{C.Tn?.ii?.()},this.isDisabled=e.V(n.disabled),this.mn=e.V(n.readonly)}Mn(){const t=this.container??{},{Ln:i,Pn:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}yn(){const t=this.container,i=this,s=()=>this.oe.find(t.targetElement),h=e.R(t.targetElement);if(!h)return null;const o=h.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.An?.Ei(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.Hn().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(o.customDelimiter)},get valueOptions(){const t=[];return i.Hn(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Hn(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Hn(!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 n=[];if(i.Hn(!0).forEach(t=>{n.push(s?t.dataset[s]:t.dataset)}),!e){if(0==n.length)return"";if(1==n.length)return n[0]}return n},selectAll(t,e=!0){if(!(o.multiple&&o.maxSelected>0&&i.Hn().length>o.maxSelected)&&!this.disabled&&!this.readonly&&o.multiple){if(e){if(n.ht([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Hn().forEach(t=>{t.es=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&o.multiple){if(e){if(n.ht([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Hn().forEach(t=>{t.es=!1}),this.change(!1,e)}},setValue(e=null,h,l=!0,r=!1){if(Array.isArray(h)||(h=[h]),0===(h=h.filter(t=>""!==t&&null!=t)).length)return i.Hn().forEach(t=>t.es=!1),void this.change(!1,l);if(o.multiple&&o.maxSelected>0&&h.length>o.maxSelected)console.warn(`Cannot select more than ${o.maxSelected} items`);else if(r||!this.disabled&&!this.readonly){if(t.On?.se?.()){const{ce:s}=t.On.re(h);if(s.length>0)return void(async()=>{o.loadingfield&&t.Tn?.Yt?.();try{t.On.de();const e=await t.On.ee(s);e.Oi&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.On.we?.(e.items,!0,!0),setTimeout(()=>{i.Hn().forEach(t=>{t.es=h.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{o.loadingfield&&t.Tn?.si?.()}})()}if(l){if(n.ht([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Hn().forEach(t=>{t.es=h.some(i=>i==t.value)}),!o.multiple&&h.length>0&&(t.targetElement.value=h[0]),this.change(!1,l)}},open(){if(i.isOpen)return;const e=i.oe?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(n.ht([s()],...o.on.beforeShow).isCancel)return;i.isOpen=!0,t.Cn.dt(!0);const h=t.Tn.Ht,l=h.ln();l?h.en(l,!1):h.cn(),i.gn&&!i.fn||!o?.ajax?t.Tn.open(null,!0):(t.On.de(),t.Tn.Yt(),i.gn=!0,i.fn=!1,setTimeout(()=>{t.Tn&&t.On&&t.On.search("").then(()=>t.Tn?.ii?.()).catch(t=>console.error("Initial ajax load error:",t))},o.animationtime),t.Tn.open(null,!1)),t.An.show();const r=t.tags.mi;r.setAttribute("aria-expanded","true"),r.setAttribute("aria-controls",o.zt),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-labelledby",o.bn),o.multiple&&r.setAttribute("aria-multiselectable","true"),n.ht([s()],...o.on.show)},close(){i.isOpen&&(n.ht([s()],...o.on.beforeClose).isCancel||(i.isOpen=!1,t.Cn.dt(!1),t.Tn.close(()=>{t.An.clear(!1)}),t.An.hide(),t.tags.mi.setAttribute("aria-expanded","false"),n.ht([s()],...o.on.close)))},toggle(){i.isOpen?this.close():this.open()},change(e=null,h=!0){if(h){if(o.multiple&&o.maxSelected>0&&this.valueArray.length>o.maxSelected&&this.setValue(null,this.oldValue,!1,!0),this.disabled||this.readonly)return void this.setValue(null,this.oldValue,!1,!0);if(n.ht([s(),this.value],...o.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.Sn.Gs(this.valueOptions),h&&(t.targetElement&&n.ot(t.targetElement,"change"),n.ht([s(),this.value],...o.on.change),i.options?.autoclose&&this.close())},refreshMask(){let s=o.placeholder;!o.multiple&&i.Hn().length>0&&(s=this.mask[0]),s??(s=o.placeholder),t.placeholder.set(s,!1),t.An.Ei(s)},on(t,i,s){o.on[i]||(o.on[i]=[]),o.on[i].push(s)},ajax(i,s){t.On.ue(s)},loadAjax:()=>new Promise((e,n)=>{t.Tn.Yt(),t.On.de(),i.gn=!0,i.fn=!1,t.Tn&&t.On?t.On.search("").then(()=>{t.Tn?.ii?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),n(t)}):e(s())})};return this.jn(l,"disabled","isDisabled"),this.jn(l,"readonly","isReadOnly"),this.jn(l,"visible","isVisible"),l}jn(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})}Hn(t=null){if(!this.pn)return[];const{Ms:i}=this.pn.qt(),s=[];for(const e of i)e instanceof b?s.push(e):e instanceof m&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}Ci(){this.container.Tn.Ci()}}class H{constructor(){this.$n=!1,this.Ce=null,this.En=[]}In(t){this.En.push(t)}Fn(){this.En=[]}start(t){if(this.$n)return;this.$n=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.Ce=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.Vn(e),e.querySelectorAll(s).forEach(t=>this.Vn(t))})}),this.Ce.observe(document.body,{childList:!0,subtree:!0})}stop(){this.$n&&(this.$n=!1,this.Ce?.disconnect(),this.Ce=null)}Vn(t){this.En.forEach(i=>i(t))}}class j{constructor(){this.kn=new Map}bind(t,i){const s=e.F(e.U(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.kn.set(t,s);const h=e.m();e.Z.on(h,()=>{n.ht([this.find(t)],...s.on.load),e.Z.clear(h),s.on.load=[]}),e.v(t).forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e.D(t),this.Rn(t,s)&&e.Z.run(h))})()}),e.G().includes(t)||e.G().push(t)}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 n=e.R(s[0]);if(!n||!n.action)return i;const h={};for(const e in n.action)h[e]=this._n(e,n.action);const o={isEmpty:!1};for(const e in h){const t=h[e];switch(t.type){case"get-set":this.Dn(o,t.name,s);break;case"func":this.Nn(o,t.name,s)}}return o}Bn(){this.Un=new H,this.Un.In(t=>{this.kn.forEach((i,s)=>{try{t.matches(s)&&this.Rn(t,i)}catch(e){console.warn("Invalid selector: "+s,e)}})}),this.Un.start("select")}destroy(t=null){null===t?this.zn():"string"==typeof t?this.Gn(t):t instanceof HTMLSelectElement&&this.Wn(t)}zn(){e.G().forEach(t=>this.Gn(t)),this.kn.clear(),e.G().length=0,this.Un?.stop()}Gn(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.Wn(t)}),this.kn.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}Wn(t){const i=e.R(t);if(!i)return;const s=i.container?.Tn;s?.Ci(),e.B(t,i);const n=!!this.Un;n&&this.Un?.stop();try{i.self?.Mn?.()}catch(o){}const h=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.qn,h&&h.parentNode?h.parentNode.replaceChild(t,h):document.body.appendChild(t),e.k(t),n&&this.kn.size>0&&this.Un?.start("select")}rebind(t,i){this.Gn(t),this.bind(t,i)}Rn(t,i){if(e.R(t)||e.N(t))return!1;const s=e.m(8),n=e.I(t,i);n.Jn=s,n.zt=`seui-${s}-optionlist`,n.bn=`seui-${s}-placeholder`;const h={options:n};e._(t,h);const o=new M(t,this);return h.container=o.container,h.action=o.yn(),h.self=o,o.container.view.addEventListener("mouseup",()=>{h.action?.toggle?.()}),!0}_n(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}}Dn(t,i,s){Object.defineProperty(t,i,{get(){const t=e.R(s[0]);return t.action?.[i]},set(t){s.forEach(s=>{const n=e.R(s);n?.action&&(n.action[i]=t)})},enumerable:!0,configurable:!0})}Nn(t,i,s){t[i]=(...h)=>{let o=null;for(let t=0;t<s.length;t++){const l=e.R(s[t]);if(!l?.action)continue;const r=n.nt();if(o??(o=l.action[i](r.et,...h)),!r.token.isContinue)break}return o??t}}}if(void 0===globalThis.GLOBAL_SEUI){const E=new j;globalThis.GLOBAL_SEUI={version:"1.1.6",name:"SelectiveUI",bind:E.bind.bind(E),find:E.find.bind(E),destroy:E.destroy.bind(E),effector:i.bind(i),rebind:E.rebind.bind(E)};let I=!1;function F(){I||(I=!0,document.addEventListener("mousedown",()=>{const t=e.G();if(t.length>0){const i=E.find(t.join(", "));i.isEmpty||i.close()}}),E.Bn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",F):F()),console.log("[SelectiveUI] v1.1.6 loaded successfully")}else console.warn(`[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). Using existing instance. Please remove duplicate <script> tags.`);const version=globalThis.GLOBAL_SEUI.version,$=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={});
|
|
1
|
+
/*! Selective UI v1.2.1 | MIT License */
|
|
2
|
+
var t,i;t=this,i=function(t){"use strict";function i(t){return new g(t??null)}class s{constructor(){this.t={showPanel:!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:!0,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 T(t={}){return this.O(document.createElement(t.node??"div"),t,!0)}static O(t=document.documentElement,i=null,s=!1){const e={...i??{}},h=s?t:this.M(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.C&&(h.setAttribute("aria-controls",e.C+""),delete e.C),e.S&&(h.setAttribute("aria-haspopup",e.S+""),delete e.S),e.H&&(h.setAttribute("aria-multiselectable",e.H+""),delete e.H),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 M(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.T(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]=i:void 0!==t?.dataset?.[e]&&(s[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 _(t){return this.l.i.get(t)}static R(t,i){this.l.i.set(t,i)}static D(t){return this.l.h.delete(t)}static N(t){return this.l.h.get(t)}static B(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 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.T({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)return;this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t);for(let h=0;h<s.length;h++){const t=s[h];if(!t)continue;const n=e.get(h);n&&clearTimeout(n);const o=setTimeout(()=>{if(t.et(i.length>0?i:null),t.once){s[h]=void 0;const t=e.get(h);t&&clearTimeout(t),e.delete(h)}},t.timeout);e.set(h,o)}}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._(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})}}class o{constructor(t){this.node=null,this.ct=null,t&&this.init(t)}init(t){this.node=e.T({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.ct=t}get(){return this.ct?.placeholder??""}set(t,i=!0){if(!this.node||!this.ct)return;i&&(this.ct.placeholder=t);const s=e.W(t);this.node.innerHTML=this.ct.allowHtml?s:e.q(s)}}class r{constructor(){this.node=this.ut()}ut(){return e.T({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"})}dt(t){this.node.classList.toggle("drop-down",!!t)}}class l{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.ft=[],this.bt=[],t&&this.init(t)}init(t){this.gt=e.I({wt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},F:{yt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.rt(this.ft)}}},vt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.rt(this.bt)}}}}}}),this.node=this.gt.view,this.options=t}available(){return!!this.options&&e.V(this.options.multiple)&&e.V(this.options.selectall)}refresh(){this.node&&(this.available()?this.show():this.hide())}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}xt(t=null){"function"==typeof t&&this.ft.push(t)}Tt(t=null){"function"==typeof t&&this.bt.push(t)}}class a{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-empty-state","hide"],role:"status",ariaLive:"polite"})}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")}}class c{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"})}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")}}class u{constructor(){this.Ot=!1,this.element=null,this.Mt=null,this.At=null,this.Ot=!0,this.Ct=this.St.bind(this)}Ht(t){}St(){const t=this.element;if(!t||"function"!=typeof t.getBoundingClientRect)return void this.Ht({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.Ht({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.St()}connect(t){if(!(t instanceof Element))throw Error("Invalid element");this.element=t,this.Mt=new ResizeObserver(this.Ct),this.Mt.observe(t),this.At=new MutationObserver(this.Ct),this.At.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.Mt?.disconnect(),this.At?.disconnect(),this.Ht=()=>{},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.Mt=null,this.At=null,this.element=null}}class d{constructor(t=null,i=null,s=null){this.options=null,this.Lt=!1,this.Pt=null,this.node=null,this.It=null,this.Et=null,this.Ft=null,this.jt=null,this.$t=null,this.Vt=null,this.kt=null,this._t=null,this.Rt=null,this.Dt=null,this.Nt={Bt:36,Ut:8,zt:!0},this.Gt=s,t&&i&&this.init(t,i)}init(t,i){if(!this.Gt)throw Error("Popup requires a ModelManager instance.");this.jt=new l(i),this.$t=new a(i),this.Vt=new c(i);const s=e.I({Wt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},F:{wt:{tag:this.jt.node},qt:{tag:{id:i.Jt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Kt:{tag:this.Vt.node},Qt:{tag:this.$t.node}}}},null);this.node=s.view,this._t=s.tags.qt,this.Ft=e._(t),this.options=i,this.Gt.load(this._t,{isMultiple:i.multiple},i.virtualScroll?{Yt:this.node,Bt:this.Nt.Bt,Ut:this.Nt.Ut,zt:this.Nt.zt}:{});const h=this.Gt.Xt();this.Pt=h.Zt,this.kt=h.kt,this.jt.xt(()=>{h.Zt.ti(!0)}),this.jt.Tt(()=>{h.Zt.ti(!1)}),this.ii()}async si(){this.options&&this.Vt&&this.jt&&this.Pt&&this.Gt&&(this.Dt&&clearTimeout(this.Dt),this.Gt.ei(!0),!1!==e.V(this.options.loadingfield)&&(this.$t.hide(),this.Vt.show(this.Pt.ni().hi),this.oi()))}async ri(){this.options&&this.Vt&&this.Pt&&this.Gt&&(this.Dt&&clearTimeout(this.Dt),this.Dt=setTimeout(()=>{this.Gt?.ei(!1),this.Vt?.hide();const t=this.Pt?.ni();this.li(t??void 0),this.oi()},200))}ii(){this.Pt&&(this.Pt.ai(t=>{this.li(t)}),this.Pt.ci("items",()=>{const t=this.Pt.ni();this.li(t),this.oi()}))}li(t){if(!(this.Pt&&this.$t&&this.jt&&this._t))return;const i=t??this.Pt.ni();i.isEmpty?(this.$t.show("nodata"),this._t.classList.add("hide"),this.jt.hide()):i.hi?(this.$t.hide(),this._t.classList.remove("hide"),this.jt.refresh()):(this.$t.show("notfound"),this._t.classList.add("hide"),this.jt.hide())}ui(t,i){this.Pt?.di(t,i)}pi(t,i){this.Pt?.ci(t,i)}gi(t){this.It=t}open(t=null,i){if(!(this.node&&this.options&&this.jt&&this.Ft&&this.It))return;this.Lt||(document.body.appendChild(this.node),this.Lt=!0,this.Et=new u,this.It.fi(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.jt.refresh(),i&&this.li();const s=this.mi(),{position:e,top:h,maxHeight:n,bi:o}=this.wi(s);this.It.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:h,maxHeight:n,bi:o,position:e,yi:()=>{if(!this.Et||!this.Ft)return;this.Et.Ht=()=>{const t=this.mi();this.xi(t)},this.Et.connect(this.Ft.container.tags.Ti),t?.();const i=this.kt;i?.resume?.()}})}close(t=null){if(!(this.Lt&&this.options&&this.Et&&this.It))return;const i=this.kt;i?.suspend?.(),this.Et.disconnect(),this.It.collapse({duration:this.options.animationtime,yi:t??void 0})}oi(){this.Lt&&this.Et?.ot()}Oi(t,i){this.node&&(this.Rt=async()=>{const i=t.Mi();if(!i.Ai)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.Ci&&i.hasMore){const i=await t.Si();!i.Hi&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this.Rt))}Li(){this.Dt&&(clearTimeout(this.Dt),this.Dt=null),this.node&&this.Rt&&(this.node.removeEventListener("scroll",this.Rt),this.Rt=null);try{this.Et?.disconnect()}catch(t){}this.Et=null;try{this.It?.fi?.(null)}catch(t){}if(this.It=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._t=null;try{this.Gt?.ei?.(!1),this.kt?.clear?.(),this.kt=null,this.Pt=null,this.node.remove()}catch(t){}this.Gt=null,this.jt=null,this.$t=null,this.Vt=null,this.Ft=null,this.options=null,this.Lt=!1}mi(){const t=this.Ft.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.Y(),h=i?.height??window.innerHeight,n=this.It.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,bi:d,Ii:n}}xi(t){if(!this.options||!this.It)return;const{position:i,top:s,maxHeight:e,bi:h}=this.wi(t);this.It.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,bi:h,position:i,animate:!0})}}class p{constructor(t=null){this.gt=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.init(t)}init(t){this.gt=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",C:t.Jt,L:"list"}}}}}),this.node=this.gt.view,this.Ei=this.gt.tags.Ei;let i=!1;const s=this.gt.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)})}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.gt&&(this.gt.tags.Ei.value="",this.Fi?.("",t))}_i(t){this.Ei&&(this.Ei.placeholder=e.q(t))}Ri(t){this.Ei&&this.Ei.setAttribute("aria-activedescendant",t)}}class g{constructor(t=null){this.Di=null,this.Ni=null,this.Bi=!1,t&&this.fi(t)}fi(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.Di&&(clearTimeout(this.Di),this.Di=null),this.Ni&&(clearTimeout(this.Ni),this.Ni=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,bi:r,position:l="bottom",yi: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.Di=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,yi: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.Di=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",yi: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.Di=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,yi: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.Di=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,bi:o,position:r="bottom",animate:l=!0,yi: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;`),setTimeout(()=>{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.Ni=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},i),Object.assign(this.element.style,t),l&&(c||r>1)?this.Ni=setTimeout(()=>{this.element.style.transition=null,c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())},20),this}get Ui(){return this.Bi}}class f{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){this.targetElement=null,this.view=null,this.position=-1,this.Ot=!1,this.zi=!1,this.options=t,this.targetElement=i,this.view=s}update(t){this.targetElement=t,this.Gi()}remove(){this.targetElement=null,this.view?.Wi()?.remove?.(),this.view=null,this.zi=!0,this.qi()}Gi(){}qi(){}}class m extends f{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.Ji=[],i&&(this.label=i.label,this.collapsed=e.V(i.dataset?.collapsed))}get value(){return this.items.map(t=>t.value)}get Ki(){return this.items.filter(t=>t.selected)}get Qi(){return this.items.filter(t=>t.visible)}get Yi(){return this.Qi.length>0}update(t){this.label=t.label,this.view?.Xi(this.label)}Gi(){this.view&&(this.view.Xi(this.label),this.view.Zi(this.collapsed))}ts(t){this.Ji.push(t)}ss(){this.collapsed=!this.collapsed,this.view?.Zi(this.collapsed),h.nt([this,this.collapsed],...this.Ji)}es(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)}hs(){this.view?.hs()}}class b extends f{constructor(t,i=null,s=null){super(t,i,s),this.ns=[],this.rs=[],this.ls=[],this.cs=!0,this.us=!1,this.group=null,(async()=>{this.ds=e.J(this.textContent.toLowerCase())})()}get ps(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ps}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.gs=t,h.nt([this,t],...this.ns)}get visible(){return this.cs}set visible(t){if(this.cs===t)return;this.cs=t;const i=this.view?.Wi?.();i&&i.classList.toggle("hide",!t),h.nt([this,t],...this.ls)}get gs(){return this.selected}set gs(t){const i=this.view?.view?.tags?.fs,s=this.view?.Wi?.();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.rs)}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.us}set bs(t){const i=!!t,s=this.view?.Wi?.();this.us!==i&&(this.us=i),s&&s.classList.toggle("highlight",i)}ws(t){this.ns.push(t)}ys(t){this.rs.push(t)}ai(t){this.ls.push(t)}Gi(){if(this.ds=e.J(this.textContent.toLowerCase()),!this.view)return;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.ps,i.alt=this.text),this.targetElement&&(this.gs=this.targetElement.selected)}}class w{constructor(t){this.Ts=[],this.Os=null,this.Ms=null,this.As=null,this.options=null,this.options=t}Cs(t){this.Ss=t}Hs(t){this.Ls=t}Ps(t){const i=this.Is(t),s=i!==this.As;return s&&(this.As=i),s}Is(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")}Es(t){this.Ts=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new m(this.options,t),this.Ts.push(i);else if("OPTION"===t.tagName){const s=t,e=new b(this.options,s),h=s.__parentGroup;h&&i&&h===i.targetElement?(i.es(e),e.group=i):(this.Ts.push(e),i=null)}}),this.Ts}replace(t){this.As=null,this.Es(t),this.Os&&this.Os.Fs(this.Ts),this.refresh(!1)}notify(){this.Os&&this.refresh(!1)}load(t,i={},s={}){this.Os=new this.Ss(this.Ts),Object.assign(this.Os,i),this.Ms=new this.Ls(t),Object.assign(this.Ms,s),this.Ms.js(this.Os)}update(t){if(!this.Ps(t))return;const i=this.Ts,s=[],e=new Map,h=new Map;i.forEach(t=>{t instanceof m?e.set(t.label,t):t instanceof b&&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.update(i),h.position=o,h.items=[],n=h,s.push(h),e.delete(i.label)):(n=new m(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.update(i),r.position=o,i.__parentGroup&&n?(n.es(r),r.group=n):(r.group=null,s.push(r)),h.delete(e);else{const t=new b(this.options,i);t.position=o,i.__parentGroup&&n?(n.es(t),t.group=n):s.push(t)}o++}});let r=!0;e.forEach(t=>{r=!1,t.remove()}),h.forEach(t=>{r=!1,t.remove()}),this.Ts=s,this.Os&&this.Os.$s(this.Ts),this.onUpdated(),this.refresh(r)}onUpdated(){}ei(t){this.Os&&(this.Os.Vs=t)}refresh(t){this.Ms&&(this.Ms.refresh(t),this.onUpdated())}Xt(){return{ks:this.Ts,Zt:this.Os,kt:this.Ms}}_s(t){this.Os?.Rs(t)}Ds(t){this.Os?.Ns(t)}}class y{constructor(t=null){this.Bs=null,this.Zt=null,this.Bs=t}Us(t){this.Bs=t}js(t){this.Zt=t,t.di("items",()=>{this.clear()}),t.ci("items",()=>{this.zs()}),this.zs()}clear(){this.Bs&&this.Bs.replaceChildren()}zs(){this.Zt&&this.Bs&&this.Zt.Gs(this.Bs)}refresh(t){this.zs()}}class v{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.Ws=null,this.qs=null,this.Js=null,t&&this.init(t)}init(t){this.gt=e.I({Ks:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.gt.view,this.options=t}Qs(t){this.Ws=t,this.qs=t.parentElement,this.Ys()}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.Js=t}Zs(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?(this.node.classList.remove("hide"),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:i=>{i.preventDefault(),this.Js?._s?.("select"),setTimeout(()=>{t.selected=!1},10)}}},se:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)})):this.node.classList.add("hide"),h.ot(window,"resize"))}}class x{constructor(t,i,s){this.ee=null,this.he=null,this.ne=null,this.oe=null,this.re={currentPage:0,totalPages:1,hasMore:!1,Ci:!1,le:"",Ai:!1},this.ae=t,this.Gt=i,this.oe=s}ce(){return!!this.ee}async ue(t){if(!this.ee)return{Hi:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Hi:!0,items:[]};try{const t=this.ee;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.oe.ge.find(this.oe.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();return{Hi:!0,items:this.fe(h).items}}catch(s){return console.error("Load by values error:",s),{Hi:!1,message:s?.message,items:[]}}}me(t){const i=Array.from(this.ae.options).map(t=>t.value);return{be:t.filter(t=>i.includes(t)),we:t.filter(t=>!i.includes(t))}}ye(t){this.ee=t}setPopup(t){this.ne=t}Mi(){return{...this.re}}ve(){this.re={currentPage:0,totalPages:1,hasMore:!1,Ci:!1,le:"",Ai:this.re.Ai}}clear(){this.re.le="";const{ks:t}=this.Gt.Xt(),i=[];for(const s of t)s instanceof b?i.push(s):s instanceof m&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.ee?this.xe(t,i):this.Te(t)}async Si(){return this.ee?this.re.Ci?{Hi:!1,message:"Already loading"}:this.re.Ai?this.re.hasMore?(this.re.currentPage++,this.xe(this.re.le,!0)):{Hi:!1,message:"No more data"}:{Hi:!1,message:"Pagination not enabled"}:{Hi:!1,message:"Ajax not enabled"}}async Te(t){this.Oe(t)&&(this.re.le=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{ks:h}=this.Gt.Xt(),n=[];for(const e of h)e instanceof b?n.push(e):e instanceof m&&Array.isArray(e.items)&&n.push(...e.items);let o=!1;return n.forEach(t=>{const e=""===i||t.ds.includes(s);t.visible=e,e&&(o=!0)}),{Hi:!0,Me:o,isEmpty:0===n.length}}Oe(t){return t!==this.re.le}async xe(t,i=!1){const s=this.ee;this.Oe(t)&&(this.ve(),this.re.le=t,i=!1),this.re.Ci=!0,this.ne?.si(),this.he?.abort(),this.he=new AbortController;const e=this.re.currentPage,h=Array.from(this.ae.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof s.data?(n=s.data.bind(this.oe.ge.find(this.oe.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.he.signal})}else{const i=""+new URLSearchParams(n);t=await fetch(`${s.url}?${i}`,{signal:this.he.signal})}const e=await t.json(),h=this.fe(e);return h.Ae?(this.re.Ai=!0,this.re.currentPage=h.page,this.re.totalPages=h.totalPages,this.re.hasMore=h.hasMore):this.re.Ai=!1,this.Ce(h.items,!!s.keepSelected,i),this.re.Ci=!1,this.ne?.ri(),{Hi:!0,Me: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.re.Ci=!1,this.ne?.ri(),"AbortError"===o?.name?{Hi:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Hi:!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.Se||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}}Ce(t,i,s=!1){const e=this.ae;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)}}),e.dispatchEvent(new CustomEvent("options:changed"))}}class T{constructor(t){this.He=null,this.Le=null,this.Pe=50,this.ae=t,this.Le=this.Ie(),this.Ee=new MutationObserver(()=>{this.He&&clearTimeout(this.He),this.He=setTimeout(()=>{this.Fe()},this.Pe)}),t.addEventListener("options:changed",()=>{this.He&&clearTimeout(this.He),this.He=setTimeout(()=>{this.Fe()},this.Pe)})}Ie(){const t=Array.from(this.ae.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.Ht(this.ae)}connect(){this.Ee.observe(this.ae,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Ht(t){}disconnect(){this.He&&clearTimeout(this.He),this.He=null,this.Ee.disconnect()}}class O{constructor(t){this.He=null,this.Ve=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.He&&clearTimeout(this.He),this.He=setTimeout(()=>{this.Ht({...this.Ve.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Ht({...this.Ve.dataset})})}connect(){this.Ee.observe(this.Ve,{attributes:!0,attributeOldValue:!0})}Ht(t){}disconnect(){this.He&&clearTimeout(this.He),this.He=null,this.Ee.disconnect()}}class M{constructor(t=[]){this.items=[],this.ke=e.m(12),this.Vs=!1,this.items=t,this._e()}_e(){}Re(t,i,s){const e=i;t.Ot?e?.update?.():e?.zs?.()}di(t,i){e.Z.on(`${t}ing_${this.ke}`,i,{st:1})}ci(t,i){e.Z.on(`${t}_${this.ke}`,i)}Ns(t,...i){e.Z.run(`${t}_${this.ke}`,...i)}Rs(t,...i){e.Z.run(`${t}ing_${this.ke}`,...i)}De(t,i){return null}Ne(){return this.items.length}Be(t){this.Rs("items",t),this.items=t,this.Ns("items",t)}Fs(t){this.Be(t)}Gs(t){for(let i=0;i<this.Ne();i++){const s=this.items[i];let e=s.view;s.Ot||(e=this.De(t,s),s.view=e),this.Re(s,e,i),s.Ot=!0}}$s(t){}}class A{constructor(t){this.parent=null,this.view=null,this.parent=t}zs(){}update(){}Wi(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}}class C extends A{constructor(){super(...arguments),this.view=null}zs(){const t=e.m(7);this.view=e.P({Ue:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},F:{ze:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},Ge:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view)}update(){this.Xi()}Xi(t=null){this.view&&null!==t&&(this.view.tags.ze.textContent=t)}We(){if(!this.view)throw Error("GroupView is not rendered.");return this.view.tags.Ge}hs(){if(!this.view)return;const t=Array.from(this.view.tags.Ge.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",!(t.length>0))}Zi(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.ze.setAttribute("aria-expanded",t?"false":"true"))}}class S extends A{constructor(t){super(t),this.view=null,this.qe=null,this.Je=null,this.Ke=!1,this.Qe()}Qe(){const t=this;this.qe={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.Je=new Proxy(this.qe,{set(i,s,e){if("string"!=typeof s)return!0;const h=s,n=i[h];return n!==e&&(i[h]=e,t.Ke&&t.Ye(h,e,n)),!0}})}get isMultiple(){return this.qe.isMultiple}set isMultiple(t){this.Je.isMultiple=!!t}get hasImage(){return this.qe.hasImage}set hasImage(t){this.Je.hasImage=!!t}get Xe(){return this.Je}set Xe(t){if(!t||!this.Je||!this.qe)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this.qe.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.qe.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.qe.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.qe.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.qe.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.qe.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.Je,i)}zs(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this.qe.isMultiple&&t.push("multiple"),this.qe.hasImage&&(t.push("has-image"),t.push("image-"+this.qe.imagePosition));const h={fs:{tag:{node:"input",type:this.qe.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this.qe.hasImage&&{xs:{tag:{node:"img",classList:"option-image",style:{width:this.qe.imageWidth,height:this.qe.imageHeight,borderRadius:this.qe.imageBorderRadius}}}},Ze:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this.qe.labelValign,"align-horizontal-"+this.qe.labelHalign]},F:{vs:{tag:{node:"div"}}}}};this.view=e.P({th:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},F:h}}),this.parent.appendChild(this.view.view),this.Ke=!0}Ye(t,i,s){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.fs,o=e.tags?.Ze;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.qe.imagePosition),this.ih();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.xs;t&&(t.remove(),e.tags.xs=null)}break}case"imagePosition":this.qe.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;if(s){const e="imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius",h=i+"";s.style[e]!==h&&(s.style[e]=h)}break}case"labelValign":case"labelHalign":if(o){const t=`align-vertical-${this.qe.labelValign} align-horizontal-${this.qe.labelHalign}`;o.className!==t&&(o.className=t)}}}ih(){const t=this.view;if(!t||!t.view)return;const i=t.tags?.xs;if(i)return;const s=t.view,e=t.tags?.Ze,h=document.createElement("img");h.className="option-image",h.style.width=this.qe.imageWidth,h.style.height=this.qe.imageHeight,h.style.borderRadius=this.qe.imageBorderRadius,e&&e.parentElement?s.insertBefore(h,e):s.appendChild(h),t.tags.xs=h}}class H extends M{constructor(t=[]){super(t),this.isMultiple=!1,this.sh=[],this.eh=-1,this.hh=null,this.groups=[],this.nh=[],this.oh(),e.Z.on("sche_vis_"+this.ke,()=>{const t=this.nh.filter(t=>t.visible).length,i=this.nh.length;this.sh.forEach(s=>{s({rh:t,ah:i,hi:t>0,isEmpty:0===i})}),e.Z.run("sche_vis_proxy_"+this.ke)},{st:10})}oh(){this.nh=[],this.groups=[],this.items.forEach(t=>{t instanceof m?(this.groups.push(t),this.nh.push(...t.items)):t instanceof b&&this.nh.push(t)})}De(t,i){return i instanceof m?new C(t):new S(t)}Re(t,i,s){t.position=s,t instanceof m?this.uh(t,i,s):t instanceof b&&this.dh(t,i,s),t.Ot=!0}uh(t,i,s){super.Re(t,i,s),t.view=i;const e=i.view.tags.ze;e.textContent=t.label,t.Ot||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.ss()}),t.ts((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.Wi?.();i&&(i.style.display=s?"none":"")}),this.ph(i,s)}));const h=i.We();t.items.forEach((t,i)=>{let s=t.view;t.Ot&&s||(s=new S(h)),this.dh(t,s,i),t.Ot=!0}),i.Zi(t.collapsed),i.hs()}dh(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.Xe={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.Ot||super.Re(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.xs;s&&(s.src!==t.ps&&(s.src=t.ps),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.vs.innerHTML=t.text,t.Ot||(i.view.tags.th.addEventListener("click",i=>{i.stopPropagation(),i.preventDefault(),this.Vs||(this.isMultiple?(this.Rs("select"),setTimeout(()=>{t.selected=!t.selected},5)):!0!==t.selected&&(this.Rs("select"),setTimeout(()=>{this.hh&&(this.hh.selected=!1),t.selected=!0},5)))}),i.view.tags.th.title=t.textContent,i.view.tags.th.addEventListener("mouseenter",()=>{this.Vs||this.gh(this.nh.indexOf(t),!1)}),t.ws(()=>{this.Ns("selected")}),t.ys((i,s,e)=>{e&&(this.hh=t),this.Ns("selected_internal")}),t.ai((t,i)=>{i.group?.hs(),this.fh()})),t.selected&&(this.hh=t,t.gs=!0)}Be(t){this.Rs("items",t),this.items=t,this.oh(),this.Ns("items",t)}Fs(t){this.Be(t)}$s(t){this.items=t,this.oh()}mh(){return this.nh.filter(t=>t.selected)}bh(){return this.nh.find(t=>t.selected)}ti(t){this.isMultiple&&this.nh.forEach(i=>{i.selected=t})}ai(t){this.sh.push(t)}fh(){e.Z.run("sche_vis_"+this.ke)}ni(){const t=this.nh.filter(t=>t.visible).length,i=this.nh.length;return{rh:t,ah:i,hi:t>0,isEmpty:0===i}}wh(){this.gh(0)}navigate(t,i=!0){const s=this.nh.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.nh[this.eh]);-1===e&&(e=-1);let h=e+t;h>=s.length&&(h=0),h<0&&(h=s.length-1);const n=this.nh.indexOf(s[h]);this.gh(n,i)}yh(){if(this.eh>-1&&this.nh[this.eh]){const t=this.nh[this.eh];if(t.visible){const i=t.view?.Wi?.();i&&i.click()}}}gh(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof b){const i=this.nh.indexOf(t);s=i>-1?i:0}else s=0;this.eh>-1&&this.nh[this.eh]&&(this.nh[this.eh].bs=!1);for(let e=s;e<this.nh.length;e++){const t=this.nh[e];if(t?.visible){if(t.bs=!0,this.eh=e,i){const i=t.view?.Wi?.();i?i.scrollIntoView({block:"center",behavior:"smooth"}):this.kt?.xh?.(e,{scrollIntoView:!0})}return void this.Th(e,t.view?.Wi?.()?.id)}}}Th(t,i){}ph(t,i){}}class L{constructor(t=0){this.Oh=[],this.n=0,this.reset(t)}reset(t){this.n=t,this.Oh=Array(t+1).fill(0)}add(t,i){for(let s=t;s<=this.n;s+=s&-s)this.Oh[s]+=i}Mh(t){let i=0;for(let s=t;s>0;s-=s&-s)i+=this.Oh[s];return i}Ah(t,i){return i<t?0:this.Mh(i)-this.Mh(t-1)}Ch(t){this.reset(t.length),t.forEach((t,i)=>this.add(i+1,t))}Sh(t){let i=0,s=1;for(;s<<1<=this.n;)s<<=1;let e=0;for(let h=s;0!==h;h>>=1){const s=i+h;s<=this.n&&e+this.Oh[s]<=t&&(i=s,e+=this.Oh[s])}return i}}class P extends y{constructor(t=null){super(t),this.Hh={Yt:void 0,Bt:36,Ut:8,zt:!0,Lh:!0},this.Ph=[],this.Ih=new L(0),this.Eh=new Map,this.Fh=!1,this.start=0,this.end=-1,this.jh=null,this.$h=null,this.Vh=!1,this.kh=!1,this._h=0,this.Rh=!1,this.Dh=!1,this.Nh=0,this.Bh=0,this.Uh=0,this.zh=0}configure(t){this.Hh={...this.Hh,...t}}js(t){if(this.Zt&&this.dispose(),super.js(t),t.kt=this,!this.Bs)return;this.Bs.replaceChildren();const i=e.I({Gh:{tag:{node:"div",classList:"selective-ui-virtual-pad-top"}},Wh:{tag:{node:"div",classList:"selective-ui-virtual-items"}},qh:{tag:{node:"div",classList:"selective-ui-virtual-pad-bottom"}}},this.Bs);if(this.Gh=i.Gh,this.Wh=i.Wh,this.qh=i.qh,this.Yt=this.Hh.Yt??this.Bs.closest(".selective-ui-popup")??this.Bs.parentElement,!this.Yt)throw Error("VirtualRecyclerView: scrollEl not found");this.Jh=this.Kh.bind(this),this.Yt.addEventListener("scroll",this.Jh,{passive:!0}),this.refresh(!1),this.Qh(),t?.ai?.(()=>this.Yh())}suspend(){this.Rh=!0,this.Xh(),this.Yt&&this.Jh&&this.Yt.removeEventListener("scroll",this.Jh),this.Zh&&(this.Zh.disconnect(),this.Dh=!0)}resume(){this.Rh=!1,this.Yt&&this.Jh&&this.Yt.addEventListener("scroll",this.Jh,{passive:!0}),this.Dh&&(this.Qh(),this.Dh=!1),this.tn()}refresh(t){if(!this.Zt||!this.Bs)return;t||this.Yh();const i=this.Zt.Ne();this._h=i,0!==i?(this.Ph.length=i,this.Fh||(this.sn(),this.Fh=!0),this.en(i),this.tn()):this.hn()}xh(t,i){this.nn(t,t),i?.scrollIntoView&&this.rn(t)}rn(t){if((this.Zt?.Ne?.()??0)<=0)return;const i=this.ln(t),s=this.an()+i,e=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight);this.Yt.scrollTop=Math.min(Math.max(0,s),e)}dispose(){this.Xh(),this.Yt&&this.Jh&&this.Yt.removeEventListener("scroll",this.Jh),this.Zh?.disconnect(),this.Eh.forEach(t=>t.remove()),this.Eh.clear()}Yh(){if(!this.Zt)return;const t=this.Zt.Ne();t<=0||(this.suspend(),this.hn(),this.cn(),this.un(t),this.en(t),this.start=0,this.end=-1,this.resume())}Xh(){null!=this.jh&&(cancelAnimationFrame(this.jh),this.jh=null),null!=this.$h&&(cancelAnimationFrame(this.$h),this.$h=null)}hn(){this.Eh.forEach(t=>t.remove()),this.Eh.clear(),this.Ph=[],this.Ih.reset(0),this.Gh.style.height="0px",this.qh.style.height="0px",this.Fh=!1,this.Uh=0,this.zh=0}sn(){this.dn(0);const t=this.Eh.get(0);if(!t)return;const i=this.pn(t);if(isNaN(i)||(this.Hh.Bt=i),!this.Hh.zt){t.remove(),this.Eh.delete(0);const i=this.Zt.items[0];i&&(i.Ot=!1,i.view=null)}}gn(t){const i=this.Zt?.items?.[t];return i?.visible??!0}fn(t,i){for(let s=Math.max(0,t);s<i;s++)if(this.gn(s))return s;return-1}un(t){this.Uh=0,this.zh=0;for(let i=0;i<t;i++){if(!this.gn(i))continue;const t=this.Ph[i];null!=t&&(this.Uh+=t,this.zh++)}}an(){const t=this.Bs.getBoundingClientRect(),i=this.Yt.getBoundingClientRect();return t.top-i.top+this.Yt.scrollTop}mn(){const t=performance.now();if(t-this.Nh<16)return this.Bh;const i=this.Yt.querySelector(".selective-ui-option-handle:not(.hide)");return this.Bh=i?.offsetHeight??0,this.Nh=t,this.Bh}tn(){null!=this.jh||this.Rh||(this.jh=requestAnimationFrame(()=>{this.jh=null,this.bn()}))}pn(t){const i=t.getBoundingClientRect(),s=getComputedStyle(t);return Math.max(1,i.height+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}wn(){return this.Hh.Lh&&this.zh>0?Math.max(1,this.Uh/this.zh):this.Hh.Bt}en(t){const i=this.wn(),s=Array.from({length:t},(t,s)=>this.gn(s)?this.Ph[s]??i:0);this.Ih.Ch(s)}yn(t,i){if(!this.gn(t))return!1;const s=this.wn(),e=this.Ph[t]??s;if(Math.abs(i-e)<=P.vn)return!1;const h=this.Ph[t];return null==h?(this.Uh+=i,this.zh++):this.Uh+=i-h,this.Ph[t]=i,this.Ih.add(t+1,i-e),!0}xn(t,i){const s=this.Ih.Sh(Math.max(0,t)),e=Math.min(i-1,s),h=this.fn(e,i);return-1===h?Math.max(0,e):h}Tn(t,i){i.setAttribute(P.On,t+"");const s=this.Eh.get(t-1);if(s?.parentElement===this.Wh)return void s.after(i);const e=this.Eh.get(t+1);if(e?.parentElement===this.Wh)return void this.Wh.insertBefore(i,e);const h=Array.from(this.Wh.children);for(const n of h){const s=n.getAttribute(P.On);if(s&&+s>t)return void this.Wh.insertBefore(i,n)}this.Wh.appendChild(i)}Mn(t,i){if(i.parentElement!==this.Wh)return void this.Tn(t,i);i.setAttribute(P.On,t+"");const s=i.previousElementSibling,e=i.nextElementSibling;(s&&+s.getAttribute(P.On)>t||e&&+e.getAttribute(P.On)<t)&&(i.remove(),this.Tn(t,i))}Qh(){this.Zh||(this.Zh=new ResizeObserver(()=>{this.kh||this.Rh||!this.Zt||null!=this.$h||(this.$h=requestAnimationFrame(()=>{this.$h=null,this.An()}))}),this.Zh.observe(this.Wh))}An(){if(!this.Zt)return;const t=this.Zt.Ne();if(t<=0)return;let i=!1;for(let s=this.start;s<=this.end;s++){if(!this.gn(s))continue;const t=this.Zt.items[s],e=t?.view?.Wi?.();if(!e)continue;const h=this.pn(e);this.yn(s,h)&&(i=!0)}i&&(this.Hh.Lh&&this.en(t),this.tn())}Kh(){this.tn()}bn(){if(!this.Vh&&!this.Rh){this.Vh=!0;try{if(!this.Zt)return;const t=this.Zt.Ne();if(t<=0)return;this._h!==t&&(this._h=t,this.Ph.length=t,this.en(t));const i=this.an(),s=Math.max(0,this.Yt.scrollTop-i),e=this.mn(),h=Math.max(0,this.Yt.clientHeight-e),n=this.xn(s,t),o=i+this.ln(n)-this.Yt.scrollTop,r=this.xn(s,t);if(-1===r)return void this.hn();const l=this.wn(),a=this.Hh.Ut*l;let c=this.fn(Math.min(t-1,this.Ih.Sh(Math.max(0,s-a))),t)??r,u=Math.min(t-1,this.Ih.Sh(s+h+a));if(c===this.start&&u===this.end)return;this.start=c,this.end=u,this.kh=!0;try{this.nn(this.start,this.end),this.Cn(this.start,this.end),this.Hh.zt&&this.An();const i=this.ln(this.start),s=this.Sn(this.start,this.end),e=this.Hn(t),h=Math.max(0,e-i-s);this.Gh.style.height=i+"px",this.qh.style.height=h+"px"}finally{this.kh=!1}const d=this.ln(n),p=this.an()+d-o,g=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight),f=Math.min(Math.max(0,p),g);Math.abs(this.Yt.scrollTop-f)>.5&&(this.Yt.scrollTop=f)}finally{this.Vh=!1}}}nn(t,i){for(let s=t;s<=i;s++)this.dn(s)}dn(t){if(!this.gn(t)){const i=this.Eh.get(t);return i?.parentElement===this.Wh&&i.remove(),void this.Eh.delete(t)}const i=this.Zt.items[t];if(!i)return;const s=this.Eh.get(t);if(s)return void(i?.view?(this.Mn(t,s),this.Zt.Re(i,i.view,t)):(s.remove(),this.Eh.delete(t)));if(i.Ot)i.view&&this.Zt.Re(i,i.view,t);else{const s=this.Zt.De(this.Wh,i);i.view=s,this.Zt.Re(i,s,t),i.Ot=!0}const e=i.view?.Wi?.();e&&(this.Mn(t,e),this.Eh.set(t,e))}Cn(t,i){this.Eh.forEach((s,e)=>{(e<t||e>i)&&(s.parentElement===this.Wh&&s.remove(),this.Eh.delete(e))})}cn(){this.Eh.forEach((t,i)=>{this.gn(i)||(t.parentElement===this.Wh&&t.remove(),this.Eh.delete(i))})}ln(t){return this.Ih.Mh(t)}Sn(t,i){return this.Ih.Ah(t+1,i+1)}Hn(t){return this.Ih.Mh(t)}}P.vn=.5,P.On="data-vindex";class I{constructor(t=null,i=null){this.container={},this.oldValue=null,this.node=null,this.options=null,this.Ln=null,this.isOpen=!1,this.Pn=!1,this.In=!1,this.ge=null,t&&this.init(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 En(){return!!this.options?.readonly}set En(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))}init(t,s){const h=e._(t).options,l=new o(h),a=new r,c=new p(h),effector=i(),u=new w(h),g=new v(h),f=new x(t,u,this),m=new T(t),b=new O(t);this.ge=s,this.options=h,l.node&&(l.node.id=(h.Fn??"")+"");const M=e.I({jn:{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.$n()?.open())}},F:{Vn:{tag:l.node},kn:{tag:a.node},ki:{tag:c.node}}}}}},null);this.container=M,this.node=M.view,t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,M.tags.Ti),g.Qs(M.tags.Ti),g.Xs(u),M.tags.Ti.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.lt(t,M.tags.Ti),t.classList.add("init"),u.Cs(H),u.Hs(h.virtualScroll?P:y),u.Es(e.K(t)),u.onUpdated=()=>{M._n?.oi?.()},this.Ln=u,M.Rn=f,M.placeholder=l,M.Dn=a,M.Nn=c,M.effector=effector,M.targetElement=t,M.Bn=g,M.Un=m,M.zn=b,M._n=new d(t,h,u),M._n.gi(effector),M._n.Oi(f,h),M._n.pi("selected",()=>{this.$n()?.change(null,!0)}),M._n.pi("selected_internal",()=>{this.$n()?.change(null,!1)}),M._n.ui("select",()=>{this.oldValue=this.$n()?.value??""}),this.$n()?.change(null,!1),m.connect(),m.Ht=t=>{u.update(e.K(t)),this.$n()?.refreshMask()},b.connect(),b.Ht=t=>{e.V(t.disabled)!==this.isDisabled&&(this.isDisabled=e.V(t.disabled)),e.V(t.readonly)!==this.En&&(this.En=e.V(t.readonly)),e.V(t.visible)!==this.isVisible&&(this.isVisible=e.V(t.visible??"1"))},t.addEventListener("options:changed",()=>{u.update(e.K(t)),this.$n()?.refreshMask(),M._n?.oi?.()}),h.ajax&&f.ye(h.ajax);const A=M._n.Pt;let C=null;const S=(t,i)=>{i||""!==t?(""!==t&&(this.In=!0),f.search(t).then(t=>{clearTimeout(C),e.Z.on("sche_vis_proxy_"+A.ke,()=>{M._n?.oi?.(),t?.Me&&(C=setTimeout(()=>{A.wh(),M._n?.oi?.()},h.animationtime??0))},{st:10})}).catch(t=>{console.error("Search error:",t)})):f.clear()};let L=null;c.Fi=(t,i)=>{f.Oe(t)&&(L&&clearTimeout(L),f.ce()?(M._n?.si?.(),L=setTimeout(()=>{S(t,i)},h.delaysearchtime??0)):L=setTimeout(()=>{S(t,i)},10))},f.setPopup(M._n),c.ji=t=>{A.navigate(t)},c.$i=()=>{A.yh()},c.Vi=()=>{this.$n()?.close(),M.tags.Ti.focus()},A.Th=(t,i)=>{i&&c.Ri(i)},A.ph=()=>{M._n?.oi?.()},this.isDisabled=e.V(h.disabled),this.En=e.V(h.readonly)}Gn(){const t=this.container??{},{Un:i,zn:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}$n(){const t=this.container,i=this,s=()=>this.ge.find(t.targetElement),n=e._(t.targetElement);if(!n)return null;const o=n.options,r={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.Nn?._i(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.Wn().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(o.customDelimiter)},get valueOptions(){const t=[];return i.Wn(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Wn(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Wn(!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.Wn(!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(!(o.multiple&&o.maxSelected>0&&i.Wn().length>o.maxSelected)&&!this.disabled&&!this.readonly&&o.multiple){if(e){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Wn().forEach(t=>{t.gs=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&o.multiple){if(e){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Wn().forEach(t=>{t.gs=!1}),this.change(!1,e)}},setValue(e=null,n,r=!0,l=!1){if(Array.isArray(n)||(n=[n]),0===(n=n.filter(t=>""!==t&&null!=t)).length)return i.Wn().forEach(t=>t.gs=!1),void this.change(!1,r);if(o.multiple&&o.maxSelected>0&&n.length>o.maxSelected)console.warn(`Cannot select more than ${o.maxSelected} items`);else if(l||!this.disabled&&!this.readonly){if(t.Rn?.ce?.()){const{we:s}=t.Rn.me(n);if(s.length>0)return void(async()=>{o.loadingfield&&t._n?.si?.();try{t.Rn.ve();const e=await t.Rn.ue(s);e.Hi&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.Rn.Ce?.(e.items,!0,!0),setTimeout(()=>{i.Wn().forEach(t=>{t.gs=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{o.loadingfield&&t._n?.ri?.()}})()}if(r){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Wn().forEach(t=>{t.gs=n.some(i=>i==t.value)}),!o.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,r)}},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()],...o.on.beforeShow).isCancel)return;i.isOpen=!0,t.Dn.dt(!0);const n=t._n.Pt,r=n.bh();r?n.gh(r,!1):n.wh(),i.Pn&&!i.In||!o?.ajax?t._n.open(null,!0):(t.Rn.ve(),t._n.si(),i.Pn=!0,i.In=!1,setTimeout(()=>{t._n&&t.Rn&&t.Rn.search("").then(()=>t._n?.oi?.()).catch(t=>console.error("Initial ajax load error:",t))},o.animationtime),t._n.open(null,!1)),t.Nn.show();const l=t.tags.Ti;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",o.Jt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",o.Fn),o.multiple&&l.setAttribute("aria-multiselectable","true"),h.nt([s()],...o.on.show)},close(){i.isOpen&&(h.nt([s()],...o.on.beforeClose).isCancel||(i.isOpen=!1,t.Dn.dt(!1),t._n.close(()=>{t.Nn.clear(!1)}),t.Nn.hide(),t.tags.Ti.setAttribute("aria-expanded","false"),h.nt([s()],...o.on.close)))},toggle(){i.isOpen?this.close():this.open()},change(e=null,n=!0){if(n){if(o.multiple&&o.maxSelected>0&&this.valueArray.length>o.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],...o.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.Bn.Zs(this.valueOptions),n&&(t.targetElement&&h.ot(t.targetElement,"change"),h.nt([s(),this.value],...o.on.change),i.options?.autoclose&&this.close())},refreshMask(){let s=o.placeholder;!o.multiple&&i.Wn().length>0&&(s=this.mask[0]),s??(s=o.placeholder),t.placeholder.set(s,!1),t.Nn._i(s)},on(t,i,s){o.on[i]||(o.on[i]=[]),o.on[i].push(s)},ajax(i,s){t.Rn.ye(s)},loadAjax:()=>new Promise((e,h)=>{t._n.si(),t.Rn.ve(),i.Pn=!0,i.In=!1,t._n&&t.Rn?t.Rn.search("").then(()=>{t._n?.oi?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(s())})};return this.qn(r,"disabled","isDisabled"),this.qn(r,"readonly","isReadOnly"),this.qn(r,"visible","isVisible"),r}qn(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})}Wn(t=null){if(!this.Ln)return[];const{ks:i}=this.Ln.Xt(),s=[];for(const e of i)e instanceof b?s.push(e):e instanceof m&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}Li(){this.container._n.Li()}}class E{constructor(){this.Jn=!1,this.Ee=null,this.Kn=[]}Qn(t){this.Kn.push(t)}Yn(){this.Kn=[]}start(t){if(this.Jn)return;this.Jn=!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.Xn(e),e.querySelectorAll(s).forEach(t=>this.Xn(t))})}),this.Ee.observe(document.body,{childList:!0,subtree:!0})}stop(){this.Jn&&(this.Jn=!1,this.Ee?.disconnect(),this.Ee=null)}Xn(t){this.Kn.forEach(i=>i(t))}}class F{constructor(){this.Zn=new Map}bind(t,i){const s=e.$(e.U(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.Zn.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=[]}),e.v(t).forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e.D(t),this.io(t,s)&&e.Z.run(n))})()}),e.G().includes(t)||e.G().push(t)}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._(s[0]);if(!h||!h.action)return i;const n={};for(const e in h.action)n[e]=this.so(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.eo(o,t.name,s);break;case"func":this.ho(o,t.name,s)}}return o}no(){this.oo=new E,this.oo.Qn(t=>{this.Zn.forEach((i,s)=>{try{t.matches(s)&&this.io(t,i)}catch(e){console.warn("Invalid selector: "+s,e)}})}),this.oo.start("select")}destroy(t=null){null===t?this.ro():"string"==typeof t?this.lo(t):t instanceof HTMLSelectElement&&this.ao(t)}ro(){e.G().forEach(t=>this.lo(t)),this.Zn.clear(),e.G().length=0,this.oo?.stop()}lo(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.ao(t)}),this.Zn.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}ao(t){const i=e._(t);if(!i)return;const s=i.container?._n;s?.Li(),e.B(t,i);const h=!!this.oo;h&&this.oo?.stop();try{i.self?.Gn?.()}catch(o){}const n=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.co,n&&n.parentNode?n.parentNode.replaceChild(t,n):document.body.appendChild(t),e.k(t),h&&this.Zn.size>0&&this.oo?.start("select")}rebind(t,i){this.lo(t),this.bind(t,i)}io(t,i){if(e._(t)||e.N(t))return!1;const s=e.m(8),h=e.j(t,i);h.uo=s,h.Jt=`seui-${s}-optionlist`,h.Fn=`seui-${s}-placeholder`;const n={options:h};e.R(t,n);const o=new I(t,this);return n.container=o.container,n.action=o.$n(),n.self=o,o.container.view.addEventListener("mouseup",()=>{n.action?.toggle?.()}),!0}so(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}}eo(t,i,s){Object.defineProperty(t,i,{get(){const t=e._(s[0]);return t.action?.[i]},set(t){s.forEach(s=>{const h=e._(s);h?.action&&(h.action[i]=t)})},enumerable:!0,configurable:!0})}ho(t,i,s){t[i]=(...n)=>{let o=null;for(let t=0;t<s.length;t++){const r=e._(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 $=new F;globalThis.GLOBAL_SEUI={version:"1.2.1",name:"SelectiveUI",bind:$.bind.bind($),find:$.find.bind($),destroy:$.destroy.bind($),effector:i.bind(i),rebind:$.rebind.bind($)};let V=!1;function k(){V||(V=!0,document.addEventListener("mousedown",()=>{const t=e.G();if(t.length>0){const i=$.find(t.join(", "));i.isEmpty||i.close()}}),$.no())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",k):k()),console.log("[SelectiveUI] v1.2.1 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,j=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=j,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
|