zidan-select 2.2.4 → 2.3.0

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.
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * ZidanForm Select-only v2.3.0
3
+ * Zero-dependency select / combobox / tags enhancement. Every other control family is omitted.
4
+ * Pairs with plugin-select-core.css and plugin-select-theme.css.
5
+ *
6
+ * Generated by scripts/build.mjs — edit zidan-form.js instead.
7
+ * https://github.com/akhtar1985/zidan-select
8
+ * MIT License © akhtar1985
9
+ *
10
+ * Classic <script> adds window.ZidanForm plus window.ZidanSelect / zidanSelect / initZidanSelects.
11
+ */(function(m,C){"use strict";var u=C(m);typeof window!="undefined"&&(window.ZidanForm=u.ZidanForm,u.ZidanSelect&&(window.ZidanSelect=u.ZidanSelect,window.zidanSelect=u.zidanSelect,window.initZidanSelects=u.initZidanSelects),u.zidanField&&(window.zidanField=u.zidanField),u.initZidanForms&&(window.initZidanForms=u.initZidanForms),u.registerIcon&&(window.registerZidanIcon=u.registerIcon)),typeof module!="undefined"&&module.exports&&(module.exports=u)})(typeof window!="undefined"?window:this,function(m){"use strict";var C="2.3.0";if(m&&m.ZidanForm&&m.ZidanForm.__zidanFormGuard===C)return m.ZidanForm.api;var u=typeof document!="undefined"?document:null,M=["classic-clean","floating-label","soft-pill","bordered-brutalist","glass-elevated"],T=["auto","none","vanilla","bootstrap","tailwind","bulma","foundation"],V=["default","modern","minimal","dark","glass"],q=["stacked","inline","card","compact","floating","outlined"],at=["checkbox","radio","radio-group","file","input","textarea"],H="[data-zidan], [data-zidan-checkbox], [data-zidan-switch], [data-zidan-radio], [data-zidan-radio-group], [data-zidan-file], [data-zidan-input], [data-zidan-textarea], .zidan-field",N="[data-zidan-select], .zidan-select",ot="[data-zidan-form], .zidan-form",I=["default","thin","fancy","hover","hidden"],O="zidan:",U=0;function lt(t){return U+=1,(t||"zs")+"-"+U.toString(36)+Math.random().toString(36).slice(2,6)}function j(t,e){return!!(t&&t.classList&&t.classList.contains(e))}function B(t,e){return!t||!e||e.split(/\s+/).forEach(function(i){i&&t.classList.add(i)}),t}function v(t,e,i,r){var n=u.createElement(t);return e&&(n.className=e),i&&Object.keys(i).forEach(function(s){var o=i[s];o==null||o===!1||(s==="text"?n.textContent=String(o):n.setAttribute(s,o===!0?"":String(o)))}),r!=null&&(n.textContent=String(r)),n}function S(t){return t==null||t===""?[]:Array.isArray(t)?t.slice():[t]}function Et(t){return!!(t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function")}function ht(t){if(!t)return!1;var e=t.closest?t.closest("[dir]"):null,i=e?e.getAttribute("dir"):"";if(!i&&u&&u.documentElement&&(i=u.documentElement.getAttribute("dir")||""),i)return String(i).toLowerCase()==="rtl";try{return!!(m.getComputedStyle&&m.getComputedStyle(t).direction==="rtl")}catch{return!1}}function y(t){return!!(t&&typeof t=="object"&&t.nodeType===1)}function E(t,e){if(t==null||t==="")return e;var i=String(t).toLowerCase();return!(i==="false"||i==="0"||i==="no"||i==="off")}function z(){for(var t={},e=0;e<arguments.length;e++)(function(i){!i||typeof i!="object"||Object.keys(i).forEach(function(r){i[r]!==void 0&&(t[r]=i[r])})})(arguments[e]);return t}function K(t){if(!t||!t.getAttribute)return null;var e=t.getAttribute("data-zidan-options");if(!e)return null;try{var i=JSON.parse(e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch(r){return typeof console!="undefined"&&console.warn&&console.warn("[ZidanForm] ignoring invalid data-zidan-options JSON on",t,r),null}}function ut(t,e,i){return Math.min(i,Math.max(e,t))}function dt(t,e){return String(t).replace(/\{(\w+)\}/g,function(i,r){return e&&e[r]!==void 0&&e[r]!==null?String(e[r]):i})}var G={text:'<path d="M4 7h16M4 12h10M4 17h13"/>',mail:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/>',phone:'<path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8.1 9.9a16 16 0 0 0 6 6l1.3-1.2a2 2 0 0 1 2.1-.5c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2Z"/>',user:'<circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/>',lock:'<rect x="4" y="10" width="16" height="11" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',calendar:'<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M16 3v4M8 3v4M3 11h18"/>',clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',link:'<path d="M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"/><path d="M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"/>',hash:'<path d="M4 9h16M4 15h16M10 3 8 21M16 3l-2 18"/>',palette:'<path d="M12 3a9 9 0 0 0 0 18h1.5a2.5 2.5 0 0 0 0-5H12a2 2 0 0 1 0-4h4a5 5 0 0 0 0-10Z"/><circle cx="8.5" cy="8.5" r="1"/><circle cx="8" cy="14" r="1"/>',sliders:'<path d="M4 7h16M4 17h16"/><circle cx="9" cy="7" r="2.5"/><circle cx="15" cy="17" r="2.5"/>',file:'<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/>',upload:'<path d="M12 16V4"/><path d="m7 9 5-5 5 5"/><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/>',eye:'<path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6-10-6-10-6Z"/><circle cx="12" cy="12" r="3"/>',"eye-off":'<path d="m3 3 18 18"/><path d="M10.6 6.2A9.9 9.9 0 0 1 12 6c6.5 0 10 6 10 6a17 17 0 0 1-3.1 3.6"/><path d="M6.4 6.7C3.5 8.4 2 12 2 12s3.5 6 10 6c1.7 0 3.2-.4 4.5-1"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2"/>',check:'<path d="m4 12.5 5 5L20 6.5"/>',x:'<path d="M6 6l12 12M18 6 6 18"/>',plus:'<path d="M12 5v14M5 12h14"/>',minus:'<path d="M5 12h14"/>',"chevron-down":'<path d="m6 9 6 6 6-6"/>',"chevron-up":'<path d="m6 15 6-6 6 6"/>',"chevron-left":'<path d="m15 6-6 6 6 6"/>',"chevron-right":'<path d="m9 6 6 6-6 6"/>',alert:'<path d="M12 9v4"/><path d="M12 17h.01"/><path d="M10.3 3.9 2.6 17.4A2 2 0 0 0 4.3 20h15.4a2 2 0 0 0 1.7-2.6L13.7 3.9a2 2 0 0 0-3.4 0Z"/>',info:'<circle cx="12" cy="12" r="9"/><path d="M12 11v5"/><path d="M12 8h.01"/>',globe:'<circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3a15 15 0 0 1 0 18 15 15 0 0 1 0-18Z"/>',"map-pin":'<path d="M20 10c0 6-8 12-8 12S4 16 4 10a8 8 0 1 1 16 0Z"/><circle cx="12" cy="10" r="3"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/>',refresh:'<path d="M20 11a8 8 0 0 0-14.9-3.9L3 10"/><path d="M3 5v5h5"/><path d="M4 13a8 8 0 0 0 14.9 3.9L21 14"/><path d="M21 19v-5h-5"/>',trash:'<path d="M4 7h16"/><path d="M9 7V4h6v3"/><path d="M6 7l1 13h10l1-13"/><path d="M10 11v5M14 11v5"/>'},x={};Object.keys(G).forEach(function(t){x[t]=G[t]});var ct="http://www.w3.org/2000/svg",ft={svg:1,g:1,path:1,circle:1,rect:1,line:1,polyline:1,polygon:1,ellipse:1,title:1,defs:1,clipPath:1,clippath:1,mask:1};function pt(t){if(typeof t!="string"||!t.trim())return"";var e;try{if(typeof m.DOMParser=="undefined")return"";e=new m.DOMParser().parseFromString(t,"image/svg+xml")}catch{return""}if(!e||!e.documentElement)return"";var i=e.documentElement;if(String(i.nodeName).toLowerCase()!=="svg"||e.getElementsByTagName("parsererror").length)return"";var r=function(n){Array.prototype.slice.call(n.children||[]).forEach(function(s){var o=String(s.nodeName);if(o!==o.toLowerCase()&&(o=o.toLowerCase()),!ft[o]){s.parentNode.removeChild(s);return}Array.prototype.slice.call(s.attributes||[]).forEach(function(l){var h=String(l.name).toLowerCase();h.indexOf("on")===0&&s.removeAttribute(l.name),(h==="href"||h==="xlink:href")&&!/^#/.test(l.value)&&s.removeAttribute(l.name),/url\s*\(\s*['"]?\s*(?:https?:|\/\/)/i.test(l.value)&&s.removeAttribute(l.name)}),r(s)})};return r(i),i.outerHTML}function F(t){var e=t;return/^\s*</.test(e)&&!/^\s*<svg/i.test(e)?e='<svg xmlns="'+ct+'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">'+e+"</svg>":/^\s*<svg/i.test(e)||(e=""),pt(e)}function St(t,e){var i="",r="";if(typeof t=="string"&&t?(r=t,/^\s*</.test(t)?i=F(t)||F('<path d="M4 12h16"/>'):x[t]&&(i=F(x[t])||"")):t&&typeof t=="object"&&t.name&&(r=t.name,i=F(x[t.name]||"")),!i)return null;var n=u.createElement("span");e&&(n.className=e),n.setAttribute("data-zs-icon",r||"custom");try{n.innerHTML=i}catch{return null}var s=n.firstChild;return s&&(s.setAttribute("focusable","false"),s.setAttribute("aria-hidden","true"),s.setAttribute("width","18"),s.setAttribute("height","18")),n}var vt={text:"text",email:"mail",password:"lock",number:"hash",tel:"phone",url:"link",search:"search",date:"calendar",time:"clock","datetime-local":"calendar",month:"calendar",week:"calendar",range:"sliders",color:"palette"};function Ct(t){return vt[t]||""}function Y(t,e){return typeof a!="undefined"&&(!t||typeof e!="string")?a:(t&&typeof e=="string"&&(x[String(t)]=e),typeof a!="undefined"?a:p)}function W(t,e,i,r,n){if(e&&e[i]!==void 0&&e[i]!==null)return e[i];if(t&&r&&t.getAttribute){var s=t.getAttribute("data-zidan-"+r);if(s!==null&&s!=="")return s}return n}function Tt(t,e,i,r,n){if(e&&e[i]!==void 0&&e[i]!==null)return!!e[i];if(t&&r&&t.getAttribute){var s=t.getAttribute("data-zidan-"+r);if(s!==null)return E(s,n)}return n}function zt(t,e,i,r,n){var s=W(t,e,i,r,n);if(s==null||s==="")return n;var o=parseFloat(s);return isFinite(o)?o:n}function xt(t,e,i,r,n){var s=W(t,e,i,r,null);return s==null||s===""?n:Array.isArray(s)?s.slice():String(s).split(",").map(function(o){return o.trim()}).filter(Boolean)}var D={required:"This field is required.",email:"Enter a valid email address.",url:"Enter a valid URL.",pattern:"The value does not match the expected format.",min:"Value must be at least {min}.",max:"Value must be at most {max}.",step:"Value must be a multiple of {step}.",minlength:"Use at least {minlength} characters.",maxlength:"Use at most {maxlength} characters.",badInput:"Enter a valid value.",phone:"Enter a valid phone number for {country}.",integer:"Enter a whole number.",date:"Enter a valid date.",weekend:"Weekends are not available \u2014 pick a weekday.",dateDisabled:"This date is not available.",fileType:"This file type is not allowed.",fileSize:"This file is too large.",fileCount:"Too many files.",pending:"Checking\u2026",generic:"Please check this field."};function Lt(t,e){if(!t||!t.validity||t.validity.valid)return"";var i=t.validity,r=e||D,n=String(t.type||"").toLowerCase(),s="",o={min:t.getAttribute("min"),max:t.getAttribute("max"),step:t.getAttribute("step")};return i.valueMissing?s="required":i.typeMismatch?s=n==="email"?"email":n==="url"?"url":"generic":i.patternMismatch?s="pattern":i.rangeUnderflow?s="min":i.rangeOverflow?s="max":i.stepMismatch?s="step":i.tooShort?(s="minlength",o.minlength=t.getAttribute("minlength")):i.tooLong?(s="maxlength",o.maxlength=t.getAttribute("maxlength")):(i.badInput||i.customError)&&(s="badInput"),s?dt(r[s]||D[s]||r.generic,o):t.validationMessage||r.generic}var X=["valueMissing","typeMismatch","patternMismatch","rangeUnderflow","rangeOverflow","stepMismatch","tooShort","tooLong","badInput","fileMissing"];function At(t){var e=t&&t.validity;if(!e)return!1;for(var i=0;i<X.length;i+=1)if(e[X[i]])return!0;return!1}function R(t,e){for(var i=t;i&&i.nodeType===1;){for(var r=0;r<e.length;r+=1){var n=i.getAttribute(e[r]);if(n)return n}i=i.parentElement}return""}function J(t,e,i){var r=String(t||"").toLowerCase();return e.indexOf(r)===-1?i:r}function mt(t,e){var i=e||{},r=i.theme||R(t,["data-zidan-theme","data-zs-theme"]);!r&&u&&(r=u.documentElement.getAttribute("data-zs-theme")||"");var n=i.framework||R(t,["data-zidan-framework","data-zs-framework"]);!n&&u&&(n=u.documentElement.getAttribute("data-zs-framework")||"");var s=i.layout||R(t,["data-zidan-layout","data-zs-layout"]);return{theme:J(r,V,"default"),framework:J(n,T,"none"),layout:s?String(s).toLowerCase():""}}function gt(t,e){var i=null;function r(){var n=arguments;clearTimeout(i),i=setTimeout(function(){i=null,t.apply(null,n)},e)}return r.cancel=function(){clearTimeout(i),i=null},r}var w={mode:null,layout:"classic-clean",themeFramework:"auto",id:null,name:null,disabled:!1,required:!1,options:null,value:null,label:null,placeholder:null,multiple:!1,searchable:null,clearable:!1,closeOnSelect:null,maxDropdownHeight:280,noResultsText:"No results found",emptyText:"No options",loadingText:"Searching\u2026",clearText:"Clear selection",fetchOptions:null,debounce:250,minChars:0,allowFreeText:!1,searchValues:!0,fetchPageSize:0,autoLoadMore:!0,cacheResults:!0,loadMoreText:"Load more",maxTags:1/0,minTagLength:1,maxTagLength:1/0,caseSensitive:!1,delimiters:[","],commitOnTab:!1,commitOnBlur:!1,suggestions:null,valueDelimiter:",",customClasses:{},validation:null,scrollbar:"default",filterOption:null,renderOption:null,renderSelected:null,renderTag:null,validateTag:null,formatTag:null,onInit:null,onChange:null,onSelect:null,onOpen:null,onClose:null,onTagAdd:null,onTagRemove:null,onLoadMore:null,onError:null};function a(t,e){if(!(this instanceof a))return new a(t,e);if(!u)throw new Error("ZidanSelect requires a DOM environment.");var i=typeof t=="string"?u.querySelector(t):t;if(!y(i))throw new Error("ZidanSelect: target element not found.");i.__zidanSelect instanceof a&&i.__zidanSelect.destroy(),this.el=i,this.opts=this._normalizeOptions(e||{}),this.mode=this.opts.mode,this.layout=this.opts.layout,this.id=this.opts.id||lt("zs"),this.isMount=/^(DIV|SPAN|SECTION|ARTICLE|FORM-FIELD)$/i.test(i.tagName)||(i.hasAttribute("data-zidan-select")||j(i,"zidan-select"))&&!/^(SELECT|INPUT|TEXTAREA)$/i.test(i.tagName),this.native=this.isMount?null:i,this.syncEl=null,this.items=[],this.value_=[],this.tags=[],this.activeIndex=-1,this.opened=!1,this.loading=!1,this.error=null,this.query="",this.rendered=[],this.listeners=new Map,this.asyncController=null,this.asyncItems=null,this.asyncQuery="",this.asyncPage=0,this.hasMore=!1,this.fetchingMore=!1,this.loadMoreError=null,this._fetchCache=Object.create(null),this._cacheKeys=[],this.timer=null,this.savedInputText="",this.disabled_=!!this.opts.disabled,this.destroyed=!1,this.resizeObserver=null,this._prepareData(),this._build(),this._prepareSync(),this._bind(),this._setInitialValue(),this._render(),this._observeResize(),i.__zidanSelect=this,this.emit("init",{instance:this,mode:this.mode,layout:this.layout,framework:this.framework}),this.call("onInit",{instance:this,mode:this.mode,value:this.getValue()})}a.prototype._normalizeOptions=function(t){t=z(K(this.el),t);var e=this.el.dataset||{},i=this.el.tagName==="SELECT",r=/tags/i.test(e.zidanSelect||"")||/tags/i.test(e.zidanMode||""),n=t.mode||e.zidanMode||e.zidanSelect||(r?"tags":"select");n=String(n).toLowerCase(),(n==="multi"||n==="multiselect")&&(n="select"),["select","combobox","tags"].indexOf(n)===-1&&(n="select");var s=i?this.el.multiple:!1,o=t.themeFramework||e.zidanFramework||"auto";o=String(o).toLowerCase(),T.indexOf(o)===-1&&(o="auto");var l=t.layout||e.zidanLayout||"classic-clean";l=String(l).toLowerCase(),M.indexOf(l)===-1&&(l="classic-clean");var h=t.scrollbar||e.zidanScrollbar||w.scrollbar;h=String(h).toLowerCase(),I.indexOf(h)===-1&&(h=w.scrollbar);var c=function(f,g){return t[f]!==void 0&&t[f]!==null?t[f]:g},b=n==="tags"?"Add a tag\u2026":n==="combobox"?"Type to search\u2026":"Select an option\u2026",d={};return Object.keys(w).forEach(function(f){d[f]=w[f]}),d.mode=n,d.layout=l,d.themeFramework=o,d.multiple=n==="tags"?!0:c("multiple",s||E(e.zidanMultiple,!1)),d.searchable=c("searchable",E(e.zidanSearchable,n!=="select")),d.clearable=c("clearable",E(e.zidanClearable,!1)),d.disabled=c("disabled",E(e.zidanDisabled,i?this.el.disabled:!1)),d.placeholder=c("placeholder",e.zidanPlaceholder||this.el.getAttribute&&this.el.getAttribute("placeholder")||b),d.label=c("label",e.zidanLabel||null),d.name=c("name",e.zidanName||this.el.getAttribute&&this.el.getAttribute("name")||null),d.allowFreeText=c("allowFreeText",E(e.zidanAllowFreeText,n==="tags")),d.maxTags=c("maxTags",e.zidanMaxTags?parseInt(e.zidanMaxTags,10)||1/0:w.maxTags),d.minTagLength=c("minTagLength",e.zidanMinTagLength?parseInt(e.zidanMinTagLength,10)||1:w.minTagLength),d.maxTagLength=c("maxTagLength",e.zidanMaxTagLength?parseInt(e.zidanMaxTagLength,10)||1/0:w.maxTagLength),d.caseSensitive=c("caseSensitive",E(e.zidanCaseSensitive,!1)),d.validation=c("validation",e.zidanValidation||null),d.options=c("options",null),d.suggestions=c("suggestions",null),d.fetchPageSize=c("fetchPageSize",e.zidanFetchPageSize?parseInt(e.zidanFetchPageSize,10)||0:w.fetchPageSize),d.autoLoadMore=c("autoLoadMore",E(e.zidanAutoLoadMore,w.autoLoadMore)),d.cacheResults=c("cacheResults",E(e.zidanCacheResults,w.cacheResults)),d.loadMoreText=c("loadMoreText",e.zidanLoadMoreText||w.loadMoreText),Object.keys(t).forEach(function(f){t[f]!==void 0&&(d[f]=t[f])}),d.mode=n,d.layout=l,d.themeFramework=o,d.scrollbar=h,d.theme||(d.theme=e.zidanTheme||e.zsTheme||""),n==="combobox"&&(d.searchable=!0),n==="tags"&&d.searchable===!1&&(d.searchable=!0),n==="tags"&&(d.multiple=!0),d},a.prototype._prepareData=function(){var t=this.opts.options;if(!t&&this.el.tagName==="SELECT"&&(t=this._optionsFromSelect(this.el)),t||(t=this.opts.suggestions||[]),this.items=this._normalizeItems(t),this.mode==="tags"){var e=this.opts.suggestions||this.opts.options;!e&&this.el.tagName==="SELECT"&&(e=this._optionsFromSelect(this.el)),this.suggestions=this._normalizeItems(e||[])}},a.prototype._optionsFromSelect=function(t){var e=[];return Array.prototype.slice.call(t.children||[]).forEach(function(i){if(i.tagName==="OPTGROUP"){var r=i.label||"";Array.prototype.slice.call(i.children).forEach(function(n){n.tagName==="OPTION"&&e.push({value:n.value,label:n.textContent.trim(),group:r,disabled:n.disabled})})}else i.tagName==="OPTION"&&e.push({value:i.value,label:i.textContent.trim(),disabled:i.disabled})}),e},a.prototype._normalizeItems=function(t){var e=S(t),i=[],r=this;return e.forEach(function(n,s){if(n!=null){if(typeof n=="string"||typeof n=="number"){i.push({value:String(n),label:String(n),group:null,disabled:!1});return}if(typeof n=="object"&&Array.isArray(n.options)){var o=n.label!==void 0?String(n.label):n.group||"";r._normalizeItems(n.options).forEach(function(h){h.group=o,i.push(h)});return}if(typeof n=="object"){var l=n.value!==void 0?n.value:n.label!==void 0?n.label:s;i.push({value:String(l),label:n.label!==void 0?String(n.label):String(l),group:n.group!==void 0?String(n.group):null,disabled:!!n.disabled,data:n.data})}}}),i},a.prototype._resolveFramework=function(){if(this.opts.themeFramework&&this.opts.themeFramework!=="auto")return this.opts.themeFramework;if(!u)return"vanilla";try{var t=m.getComputedStyle(u.documentElement),e=t.getPropertyValue("--bs-body-bg");if(e&&e.trim())return"bootstrap";for(var i=u.styleSheets||[],r=0;r<i.length;r+=1){var n=i[r].href||"";if(/bootstrap(\.min)?\.css/i.test(n))return"bootstrap";if(/tailwind/i.test(n))return"tailwind"}if(u.body&&m.getComputedStyle(u.body).getPropertyValue("--tw-ring-offset-shadow")!=="")return"tailwind";if(u.querySelector(".btn-primary, .form-select, .form-control, .navbar"))return"bootstrap"}catch{}return"vanilla"},a.prototype._applyCustomClass=function(t,e){var i=this.opts.customClasses||{},r=i[e];return r&&B(t,r),t},a.prototype._toggleCustomClass=function(t,e,i){var r=this.opts.customClasses||{},n=r[e];return n&&String(n).split(/\s+/).forEach(function(s){s&&(i?t.classList.add(s):t.classList.remove(s))}),t},a.prototype._build=function(){var t=this,e=this.opts;this.framework=this._resolveFramework();var i=this.el.parentNode&&this.el.parentNode.classList&&this.el.parentNode.classList.contains("zs-root--mount"),r=mt(this.el,{theme:e.theme,framework:e.themeFramework,layout:e.layout});this.theme=r.theme;var n=v("div","zs-root");n.id=this.id+"-root",n.setAttribute("data-zs-theme",this.theme),n.setAttribute("data-zs-layout",this.layout),n.setAttribute("data-zs-framework",this.framework),n.setAttribute("data-zs-mode",this.mode),n.setAttribute("data-zs-scrollbar",e.scrollbar||"default"),ht(this.el)&&n.setAttribute("dir","rtl"),n.classList.add("zs-root--"+this.mode),this.mode==="tags"&&n.classList.add("zs-root--multiple"),e.multiple&&this.mode==="select"&&n.classList.add("zs-root--multiple"),this.layout==="floating-label"&&n.classList.add("zs-root--labeled"),this._applyCustomClass(n,"root");var s=v("div","zs-control");this.framework==="bootstrap"&&(s.classList.add("form-control","zs-bootstrap-control"),this.el.tagName==="SELECT"&&s.classList.add("form-select")),this._applyCustomClass(s,"control");var o=v("div","zs-chips");o.hidden=!0;var l=u.createElement("input");l.type="text",l.className="zs-input",l.id=this.id+"-input",l.autocomplete="off",l.spellcheck=!1,l.setAttribute("role","combobox"),l.setAttribute("aria-expanded","false"),l.setAttribute("aria-controls",this.id+"-listbox"),l.setAttribute("aria-autocomplete",e.searchable||this.mode!=="select"?"list":"none"),l.setAttribute("aria-haspopup","listbox"),(e.ariaLabel||e.label)&&l.setAttribute("aria-label",e.ariaLabel||e.label),e.disabled&&(l.disabled=!0),this._applyCustomClass(l,"input");var h=null;e.label&&(h=v("label","zs-label",{for:l.id}),h.textContent=e.label,this.layout!=="floating-label"&&n.classList.add("zs-root--has-static-label"));var c=v("button","zs-clear",{type:"button",tabindex:"-1","aria-label":e.clearText,title:e.clearText});c.innerHTML='<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true" focusable="false"><path d="M3 3l10 10M13 3L3 13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>',c.hidden=!0;var b=v("span","zs-arrow",{"aria-hidden":"true"});b.innerHTML='<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" focusable="false"><path d="M3.5 6l4.5 4.5L12.5 6" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',s.appendChild(o),s.appendChild(l),s.appendChild(c),s.appendChild(b),h&&(this.layout==="floating-label"?s.insertBefore(h,o):n.appendChild(h));var d=v("div","zs-dropdown");d.id=this.id+"-listbox",d.setAttribute("role","listbox"),this.mode!=="tags"&&d.setAttribute("aria-multiselectable",String(!!(e.multiple||this.mode==="tags"))),this._applyCustomClass(d,"dropdown");var f=v("div","zs-live",{"aria-live":"polite","aria-atomic":"true"});n.appendChild(s),n.appendChild(d),n.appendChild(f),this.framework==="bootstrap"&&(e.validation==="invalid"&&s.classList.add("is-invalid"),e.validation==="valid"&&s.classList.add("is-valid"),(this.mode==="tags"||e.multiple)&&n.classList.add("zs-root--bootstrap")),this.isMount?(i||this.el.classList.add("zs-root--mount"),this.el.appendChild(n)):this.el.parentNode.insertBefore(n,this.el),this.root=n,this.controlEl=s,this.chipsEl=o,this.input=l,this.dropdown=d,this.clearBtn=c,this.arrowEl=b,this.labelEl=h,this.liveEl=f},a.prototype._prepareSync=function(){var t=this,e=this.opts;if(this.native)this.native.tagName==="SELECT"?(this.syncEl=this.native,this.native.multiple&&(this.opts.multiple=!0,this.root.classList.add("zs-root--multiple")),this.native.hidden=!0,this.native.classList.add("zs-native"),this.native.setAttribute("tabindex","-1"),this.native.setAttribute("aria-hidden","true")):(this.syncEl=this.native,this.native.hidden=!0,this.native.setAttribute("tabindex","-1"),this.native.setAttribute("aria-hidden","true")),e.required&&this.input.setAttribute("aria-required","true"),this.form=this.native.closest?this.native.closest("form"):null;else if(e.name){var i=v("input","zs-hidden",{type:"hidden",name:e.name});this.root.appendChild(i),this.syncEl=i,this.form=this.el.closest?this.el.closest("form"):null}else this.form=this.el.closest?this.el.closest("form"):null;return this.form&&(this.onFormReset=function(){setTimeout(function(){t._handleFormReset()},0)},this.form.addEventListener("reset",this.onFormReset)),this.syncEl},a.prototype._setInitialValue=function(){var t=this.opts,e=t.value;if(e==null&&(this.native&&this.native.tagName==="SELECT"?e=this.native.multiple?Array.prototype.filter.call(this.native.options,function(r){return r.selected}).map(function(r){return r.value}):this.native.value:this.native&&(e=this.native.value)),this.mode==="tags"){var i=e;typeof i=="string"&&i&&!Array.isArray(i)&&this.syncEl&&this.syncEl.tagName!=="SELECT"&&(i=i.split(t.valueDelimiter)),S(i).forEach(function(r){this._addTagObject(String(r),{silent:!0})},this);return}e==null||e===""||this._setValueInternal(e,{silent:!0})},a.prototype._handleFormReset=function(){var t;if(this.native&&this.native.tagName==="SELECT"?t=this.native.multiple?Array.prototype.filter.call(this.native.options,function(e){return e.selected}).map(function(e){return e.value}):this.native.value:this.native?t=this.native.value:this.opts.value!==null&&this.opts.value!==void 0&&(t=this.opts.value),this.mode==="tags"){this.value_=[],S(t).forEach(function(e){this._addTagObject(e,{silent:!0})},this),this._render(),this._syncNative();return}this._setValueInternal(t,{silent:!0}),this._render()},a.prototype._hasValue=function(t){for(var e=this.opts.caseSensitive?String(t):String(t).toLowerCase(),i=0;i<this.value_.length;i+=1){var r=this.opts.caseSensitive?this.value_[i].value:this.value_[i].value.toLowerCase();if(r===e)return!0}return!1},a.prototype._itemFor=function(t){for(var e=String(t),i=0;i<this.items.length;i+=1)if(this.items[i].value===e)return this.items[i];for(var r=0;r<this.value_.length;r+=1)if(this.value_[r].value===e)return this.value_[r];return{value:e,label:e}},a.prototype._setValueInternal=function(t,e){var i=e||{},r=this.getValue(),n=this,s=S(t),o=[];if(s.forEach(function(h){if(!(h==null||h==="")){if(typeof h=="object"){o.push({value:String(h.value!==void 0?h.value:h.label),label:String(h.label!==void 0?h.label:h.value),data:h.data});return}for(var c=String(h),b=null,d=0;d<n.items.length;d+=1)if(n.items[d].value===c){b=n.items[d];break}o.push(b?{value:b.value,label:b.label,data:b.data}:{value:c,label:c})}}),!this.opts.multiple&&this.mode!=="tags"&&(o=o.slice(0,1)),this.value_=o,o.length&&this.opts.validation==="invalid"&&(this.opts.validation=null),this._render(),this._syncNative(),!i.silent){var l=this.getValue();l!==r&&JSON.stringify(l)!==JSON.stringify(r)&&(this.emit("change",{value:l,previousValue:r,instance:this}),this.call("onChange",{value:l,previousValue:r,instance:this}))}return this},a.prototype._syncNative=function(){var t=this.syncEl;if(t){var e=this.value_.map(function(l){return l.value});if(t.tagName==="SELECT"){var i;if(t.multiple){for(i=0;i<t.options.length;i+=1)t.options[i].selected=e.indexOf(t.options[i].value)!==-1;var r=Array.prototype.map.call(t.options,function(l){return l.value});e.forEach(function(l){if(r.indexOf(l)===-1){var h=u.createElement("option");h.value=l,h.textContent=l,h.selected=!0,t.appendChild(h)}})}else{var n=e[0];if(n===void 0)t.value="";else{var s=!1;for(i=0;i<t.options.length;i+=1)if(t.options[i].value===n){s=!0;break}if(!s){var o=u.createElement("option");o.value=n,o.textContent=this._itemFor(n).label,t.appendChild(o)}t.value=n}}}else t.value=this.opts.multiple||this.mode==="tags"?e.join(this.opts.valueDelimiter):e[0]||""}},a.prototype._render=function(){var t=this.opts,e=this.value_.length>0;this.root.classList.toggle("zs-root--has-value",e),this.root.classList.toggle("zs-root--open",this.opened),this.root.classList.toggle("zs-root--disabled",!!this.disabled_),this.root.classList.toggle("zs-root--invalid",t.validation==="invalid"),this.root.classList.toggle("zs-root--valid",t.validation==="valid"),t.validation==="invalid"?this.root.setAttribute("data-zs-validation","invalid"):t.validation==="valid"?this.root.setAttribute("data-zs-validation","valid"):this.root.removeAttribute("data-zs-validation"),t.validation==="invalid"?this.input.setAttribute("aria-invalid","true"):t.validation==="valid"?this.input.setAttribute("aria-invalid","false"):this.input.removeAttribute("aria-invalid"),(this.el.required||t.required)&&this.input.setAttribute("aria-required","true"),t.validation==="invalid"?this.controlEl.classList.add("is-invalid"):this.controlEl.classList.remove("is-invalid"),t.validation==="valid"?this.controlEl.classList.add("is-valid"):this.controlEl.classList.remove("is-valid"),this._toggleCustomClass(this.controlEl,"invalid",t.validation==="invalid"),this._renderChips(),this._renderInputValue();var i=t.clearable&&e&&!this.disabled_;return this.clearBtn.hidden=!i,this.clearBtn.tabIndex=i?0:-1,this.input.disabled=!!this.disabled_,this.input.setAttribute("aria-expanded",String(this.opened)),this.root.classList.toggle("zs-root--placeholder",!this.input.value&&!e),this},a.prototype._renderChips=function(){var t=this,e=this.mode==="tags"||!!this.opts.multiple,i=this.chipsEl;i.textContent="",i.hidden=!e,e&&(this.value_.forEach(function(r,n){var s=v("span","zs-chip",{"data-zs-index":n});t.framework==="bootstrap"&&B(s,"badge rounded-pill"),t._applyCustomClass(s,"chip");var o,l=typeof t.opts.renderTag=="function"&&t.mode==="tags"?t.opts.renderTag({value:r.value,label:r.label},{index:n,instance:t,disabled:t.disabled_}):null;if(t.mode==="select"&&typeof t.opts.renderSelected=="function"&&(l=t.opts.renderSelected({value:r.value,label:r.label},{index:n,instance:t})),l)if(y(l))o=l,s.appendChild(o);else{var h=v("span","zs-chip-label");h.innerHTML=String(l),s.appendChild(h)}else o=v("span","zs-chip-label",null,r.label),s.appendChild(o);var c=v("button","zs-chip-remove",{type:"button","aria-label":"Remove "+r.label,title:"Remove "+r.label,"data-zs-remove":n});c.innerHTML='<svg viewBox="0 0 16 16" width="10" height="10" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',t._applyCustomClass(c,"chipRemove"),s.appendChild(c),i.appendChild(s)}),this.root.classList.toggle("zs-root--has-value",this.value_.length>0))},a.prototype._renderInputValue=function(){var t=this.mode!=="tags"&&!this.opts.multiple;if(!t){this.input.placeholder=this.value_.length?"":this.opts.placeholder||"",this.opened?this.input.value=this.query:this.input.value="";return}if(this.opened&&this.opts.searchable){this.input.value=this.query,this.input.placeholder=this.opts.placeholder||"";return}if(this.opened&&!this.opts.searchable){this.input.value=this.value_.length?this.value_[0].label:"",this.input.placeholder=this.opts.placeholder||"";return}this.input.value=this.value_.length?this.value_[0].label:"",this.input.placeholder=this.opts.placeholder||"",this.value_.length||(this.input.value="")},a.prototype._sourceItems=function(){return this.mode==="tags"?this.suggestions||[]:typeof this.opts.fetchOptions=="function"&&this.asyncItems?this.asyncItems:this.items},a.prototype._visibleItems=function(){var t=this,e=this.query.trim(),i=this._sourceItems(),r=!!this.opts.caseSensitive,n=typeof this.opts.fetchOptions=="function"&&!!this.asyncItems;return!e||n&&typeof this.opts.filterOption!="function"?i.slice():i.filter(function(s){if(typeof t.opts.filterOption=="function")return!!t.opts.filterOption(s,e,{instance:t,mode:t.mode,caseSensitive:r,selected:t._hasValue(s.value)});var o=r?s.label:s.label.toLowerCase(),l=r?e:e.toLowerCase();if(o.indexOf(l)!==-1)return!0;if(t.opts.searchValues){var h=r?s.value:s.value.toLowerCase();if(h.indexOf(l)!==-1)return!0}return!1})},a.prototype._renderDropdown=function(){var t=this;if(this.opened){var e=this.dropdown.scrollTop;if(this.dropdown.textContent="",this.rendered=[],this.loading){var i=v("div","zs-state zs-state--loading",{role:"status"});i.appendChild(v("span","zs-spinner",{"aria-hidden":"true"})),i.appendChild(v("span","zs-state-text",null,this.opts.loadingText)),this.dropdown.appendChild(i)}else if(this.error){var r=v("div","zs-state zs-state--error",{role:"status"},this.error.message||"Something went wrong.");this.dropdown.appendChild(r)}else{var n=this._visibleItems();if(n.length){var o=null;n.forEach(function(h,c){if(h.group&&h.group!==o){var b=v("div","zs-group",{role:"presentation"},h.group);t.dropdown.appendChild(b),o=h.group}var d=t._hasValue(h.value),f=v("div","zs-option",{role:"option",id:t.id+"-opt-"+c,"data-zs-option":c});f.setAttribute("aria-selected",String(d)),h.disabled&&(f.setAttribute("aria-disabled","true"),f.classList.add("zs-option--disabled")),d&&f.classList.add("zs-option--selected"),t._applyCustomClass(f,"option"),d&&t._applyCustomClass(f,"selected"),h.disabled&&t._applyCustomClass(f,"disabled");var g=null;typeof t.opts.renderOption=="function"&&(g=t.opts.renderOption(h,{index:c,selected:d,active:c===t.activeIndex,query:t.query,instance:t})),g&&y(g)?f.appendChild(g):g!=null&&g!==""?f.innerHTML=String(g):f.appendChild(v("span","zs-option-label",null,h.label)),c===t.activeIndex&&(f.classList.add("zs-option--active"),t._applyCustomClass(f,"active")),t.rendered.push({element:f,item:h,index:c}),t.dropdown.appendChild(f)})}else{var s=this.query?this.opts.noResultsText:this.opts.emptyText;this.dropdown.appendChild(v("div","zs-state zs-state--empty",{role:"status"},s)),this.emit("no-results",{query:this.query,instance:this})}if(this.hasMore){var l=v("button","zs-more",{type:"button"});this.fetchingMore?(l.appendChild(v("span","zs-spinner",{"aria-hidden":"true"})),l.appendChild(v("span",null,null,this.opts.loadingText||"Loading\u2026")),l.disabled=!0,l.setAttribute("aria-busy","true")):(l.textContent=this.loadMoreError||this.opts.loadMoreText,this.loadMoreError&&l.classList.add("zs-more--error")),this.dropdown.appendChild(l)}}this.dropdown.scrollTop=e,this._updateActiveDescendant(!1),this.opened&&this._position()}},a.prototype._updateActiveDescendant=function(t){var e=this.rendered[this.activeIndex];if(e){if(this.input.setAttribute("aria-activedescendant",e.element.id),t!==!1){var i=e.element.offsetTop,r=i+e.element.offsetHeight;i<this.dropdown.scrollTop?this.dropdown.scrollTop=i-4:r>this.dropdown.scrollTop+this.dropdown.clientHeight&&(this.dropdown.scrollTop=r-this.dropdown.clientHeight+4)}}else this.input.removeAttribute("aria-activedescendant")},a.prototype._position=function(){if(this.opened){var t=this.controlEl.getBoundingClientRect(),e=m.innerHeight||u.documentElement.clientHeight,i=e-t.bottom-12,r=t.top-12,n=i<160&&r>i;this.root.classList.toggle("zs-root--dropup",n);var s=n?r:i,o=ut(s,120,this.opts.maxDropdownHeight||280);this.dropdown.style.maxHeight=Math.max(120,o)+"px";var l=t.width;this.dropdown.style.minWidth=l+"px",this.root.classList.contains("zs-root--mount")&&(this.dropdown.style.left="0px",this.dropdown.style.right="0px")}},a.prototype.open=function(){if(this.destroyed||this.disabled_||this.opened)return this;if(this.opened=!0,this.query="",this.activeIndex=-1,this.loadMoreError=null,this.fetchingMore=!1,(this.mode==="combobox"||this.mode==="select"&&this.opts.searchable)&&(this.savedInputText=this.input.value),this.root.classList.add("zs-root--open"),this.dropdown.setAttribute("data-zs-visible","true"),this._render(),this._renderDropdown(),this._position(),this.emit("open",{instance:this}),this.call("onOpen",{instance:this}),typeof this.opts.fetchOptions=="function"&&(!this.asyncItems||this.asyncQuery!==""))this._fetch("");else if(this.mode!=="tags"){var t=this._firstEnabledIndex();t!==-1&&(this.activeIndex=t,this._renderDropdown())}if(this.opts.searchable&&!this.disabled_)try{this.input.select()}catch{this.input.focus()}var e=this._visibleItems();return this.announce(e.length+" option"+(e.length===1?"":"s")+" available"),this},a.prototype.close=function(){return this.destroyed||!this.opened?this:(this.opened=!1,this.root.classList.remove("zs-root--open"),this.dropdown.removeAttribute("data-zs-visible"),this.activeIndex=-1,this.query="",typeof this.opts.fetchOptions=="function"&&(this.asyncController&&(this.asyncController.abort(),this.asyncController=null),this.loading=!1,this.fetchingMore=!1,this.loadMoreError=null),this._render(),this.emit("close",{instance:this}),this.call("onClose",{instance:this}),this)},a.prototype.toggle=function(){return this.opened?this.close():this.open()},a.prototype._firstEnabledIndex=function(){for(var t=this._visibleItems(),e=0;e<t.length;e+=1)if(!t[e].disabled)return e;return-1},a.prototype._selectRendered=function(t){var e=this.rendered[t];return!e||e.item.disabled?!1:(this._selectItem(e.item),!0)},a.prototype._selectItem=function(t){if(!t||t.disabled)return this;var e=this.getValue();if(this.mode==="tags")return this.addTag(t.label),this.query="",this._renderDropdown(),this;if(this.mode==="combobox"&&this.opts.allowFreeText)this._setValueInternal([t.value]);else if(this.opts.multiple){if(this._hasValue(t.value)){this.value_=this.value_.filter(function(n){return n.value!==t.value}),this._render(),this._syncNative();var i=this.getValue();return JSON.stringify(i)!==JSON.stringify(e)&&(this.emit("change",{value:i,previousValue:e,instance:this}),this.call("onChange",{value:i,previousValue:e,instance:this})),this._renderDropdown(),this}this._setValueInternal(this.value_.concat([t]))}else this._setValueInternal([t]);this.emit("select",{value:this.getValue(),item:t,instance:this}),this.call("onSelect",{value:this.getValue(),item:t,instance:this});var r=this.opts.closeOnSelect===null?!this.opts.multiple:this.opts.closeOnSelect;return r?this.close():this.opened&&this._renderDropdown(),this},a.prototype._cacheKey=function(t,e){return t+"\0"+e},a.prototype._cacheGet=function(t,e){if(!this.opts.cacheResults)return null;var i=this._cacheKey(t,e),r=this._fetchCache[i];if(!r)return null;var n=this._cacheKeys.indexOf(i);return n!==-1&&(this._cacheKeys.splice(n,1),this._cacheKeys.push(i)),r},a.prototype._cacheSet=function(t,e,i){if(this.opts.cacheResults){var r=this._cacheKey(t,e);this._fetchCache[r]=i;var n=this._cacheKeys.indexOf(r);n!==-1&&this._cacheKeys.splice(n,1),this._cacheKeys.push(r);for(var s=a.cacheLimit||50;this._cacheKeys.length>s;)delete this._fetchCache[this._cacheKeys.shift()]}},a.prototype.clearCache=function(){return this._fetchCache=Object.create(null),this._cacheKeys=[],this},a.prototype._readFetchPayload=function(t,e,i){var r=t,n=!1;return t&&!Array.isArray(t)&&typeof t=="object"?(r=t.items||t.options||t.results||[],t.hasMore!==void 0?n=!!t.hasMore:t.total!==void 0&&i>0?n=(e+1)*i<Number(t.total):i>0&&(n=S(r).length>=i)):i>0&&(n=S(r).length>=i),{items:this._normalizeItems(r),hasMore:n}},a.prototype._applyCachedPage=function(t,e,i){var r=this._cacheGet(t,e);return r?(this.loading=!1,this.fetchingMore=!1,this.loadMoreError=null,this.error=null,this.asyncQuery=t,this.asyncPage=e,this.asyncItems=i?(this.asyncItems||[]).concat(r.items):r.items.slice(),this.hasMore=!!r.hasMore,i||(this.activeIndex=-1),this._renderDropdown(),!0):!1},a.prototype._fetch=function(t,e,i){var r=this;if(typeof this.opts.fetchOptions!="function")return Promise.resolve([]);if(t=t==null?"":String(t),e=e==null?0:parseInt(e,10)||0,i=!!i,i&&(this.loading||this.fetchingMore||!this.hasMore))return Promise.resolve([]);var n=this._cacheGet(t,e);if(n&&(!i||this.hasMore))return this.asyncController&&this.asyncController.abort(),this.asyncController=null,this._applyCachedPage(t,e,i),Promise.resolve(this._visibleItems());this.asyncController&&this.asyncController.abort();var s=typeof AbortController!="undefined"?new AbortController:null;this.asyncController=s,this.loading=!i,this.fetchingMore=i,this.error=null,this.loadMoreError=null,i||(this.hasMore=!1,this.asyncPage=0,this.announce(this.opts.loadingText)),this._renderDropdown();var o,l=new Promise(function(f){o=f});s&&s.signal.addEventListener&&s.signal.addEventListener("abort",function(){o([])}),i&&(this.emit("load-more",{page:e,query:t,instance:this}),this.call("onLoadMore",{page:e,query:t,instance:this}));var h=this.opts.fetchPageSize>0?this.opts.fetchPageSize:0,c=function(f){if(!(s&&s.signal.aborted)){r.loading=!1,r.fetchingMore=!1,r.loadMoreError=null,r.error=null;var g=r._readFetchPayload(f,e,h);r.asyncQuery=t,r.asyncPage=e,r.asyncItems=i?(r.asyncItems||[]).concat(g.items):g.items,r.hasMore=g.hasMore,r._cacheSet(t,e,{items:g.items,hasMore:g.hasMore}),i||(r.activeIndex=-1),r._renderDropdown();var st=r._visibleItems().length;r.announce(st+" result"+(st===1?"":"s")),o(r._visibleItems())}},b=function(f){if(f&&f.name==="AbortError"){o([]);return}if(s&&s.signal.aborted){o([]);return}var g=f&&f.message||"Unable to load options.";r.loading=!1,r.fetchingMore=!1,i?r.loadMoreError=g:r.error={message:g},r.emit("error",{error:f,message:g,instance:r}),r.call("onError",{error:f,message:g,instance:r}),r._renderDropdown(),o([])};try{var d=this.opts.fetchOptions(t,s?s.signal:void 0,{page:e,pageSize:h,append:i,instance:this});d&&typeof d.then=="function"?d.then(c).catch(b):c(d)}catch(f){b(f)}return l},a.prototype.loadMore=function(){return typeof this.opts.fetchOptions!="function"?this:this.loading||this.fetchingMore||!this.hasMore?this:this._fetch(this.asyncQuery||this.query||"",this.asyncPage+1,!0)},a.prototype.hasMoreResults=function(){return!!this.hasMore},a.prototype.getAsyncState=function(){return{query:this.asyncQuery,page:this.asyncPage,hasMore:!!this.hasMore,loading:!!this.loading,fetchingMore:!!this.fetchingMore,error:this.error?this.error.message:null}},a.prototype.refreshOptions=function(){return this.clearCache(),typeof this.opts.fetchOptions!="function"?this:(this.asyncItems=null,this.asyncQuery="",this.asyncPage=0,this.hasMore=!1,this.opened?this._fetch(this.query,0,!1):this)},a.prototype._tagError=function(t){this.announce(t),this.emit("error",{message:t,instance:this}),this.call("onError",{message:t,instance:this}),this.root.classList.add("zs-root--shake");var e=this.root;setTimeout(function(){e.classList.remove("zs-root--shake")},320)},a.prototype._addTagObject=function(t,e){var i=e||{},r=this.opts,n=String(t==null?"":t).trim();if(!n)return!1;if(this.value_.length>=r.maxTags)return i.silent||this._tagError("You can add up to "+r.maxTags+" tags."),!1;if(n.length<r.minTagLength)return i.silent||this._tagError("Tags need at least "+r.minTagLength+" character"+(r.minTagLength===1?"":"s")+"."),!1;if(n.length>r.maxTagLength)return i.silent||this._tagError("Tags can be at most "+r.maxTagLength+" characters."),!1;if(this._hasValue(n))return i.silent||this._tagError('"'+n+'" is already added.'),!1;var s=n;if(typeof r.formatTag=="function"){var o=r.formatTag(n,{instance:this,tags:this.getTags()});typeof o=="string"&&o&&(s=o)}if(typeof r.validateTag=="function"){var l=r.validateTag(s,this.getTags(),{instance:this});if(l===!1)return i.silent||this._tagError('"'+s+'" is not allowed.'),!1;if(typeof l=="string")return i.silent||this._tagError(l),!1}var h={value:s,label:s};return this.value_.push(h),this.query="",this.opts.validation==="invalid"&&(this.opts.validation=null),i.silent||(this._render(),this._syncNative(),this.opened&&this._renderDropdown(),this.announce(s+" added. "+this.value_.length+" tag"+(this.value_.length===1?"":"s")+" total."),this.emit("tag-add",{tag:s,value:this.getTags(),instance:this}),this.call("onTagAdd",{tag:s,value:this.getTags(),instance:this}),this.emit("change",{value:this.getTags(),instance:this}),this.call("onChange",{value:this.getTags(),instance:this})),!0},a.prototype.addTag=function(t){var e=this._addTagObject(t,{});return this._render(),this.opened&&this._renderDropdown(),e},a.prototype.removeTag=function(t){var e=typeof t=="number"?t:this.value_.findIndex(function(r){return String(r.value)===String(t)||String(r.label)===String(t)});if(e<0||e>=this.value_.length)return!1;var i=this.value_.splice(e,1)[0];return this._render(),this._syncNative(),this.opened&&this._renderDropdown(),this.announce(i.label+" removed. "+this.value_.length+" tag"+(this.value_.length===1?"":"s")+" remaining."),this.emit("tag-remove",{tag:i.value,value:this.getTags(),instance:this}),this.call("onTagRemove",{tag:i.value,value:this.getTags(),instance:this}),this.emit("change",{value:this.getTags(),instance:this}),this.call("onChange",{value:this.getTags(),instance:this}),this.input.focus(),!0},a.prototype.getTags=function(){return this.value_.map(function(t){return t.value})},a.prototype._onKeyDown=function(t){if(!this.destroyed){var e=t.key,i=this._visibleItems();if(e==="ArrowDown"||e==="ArrowUp"){if(t.preventDefault(),!this.opened){this.open();return}if(!i.length)return;for(var r=e==="ArrowDown"?1:-1,n=this.activeIndex,s=0;s<i.length&&(n+=r,n<0&&(n=i.length-1),n>=i.length&&(n=0),!!i[n].disabled);s+=1);this.activeIndex=n,this._renderDropdown();return}if(e==="Home"||e==="End"){if(!this.opened)return;t.preventDefault();var o=-1,l;if(e==="Home"){for(l=0;l<i.length;l+=1)if(!i[l].disabled){o=l;break}}else for(l=i.length-1;l>=0;l-=1)if(!i[l].disabled){o=l;break}this.activeIndex=o,this._renderDropdown();return}if(e==="Enter"){if(this.opened){if(t.preventDefault(),this.activeIndex>=0){this._selectRendered(this.activeIndex),this.mode==="tags"&&(this.query="");return}if(this.mode==="tags"){this._commitTypedTag();return}if((this.mode==="combobox"||this.mode==="select")&&this.opts.allowFreeText){var h=this.query.trim();h&&(this._setValueInternal([h]),this.emit("select",{value:this.getValue(),item:{value:h,label:h},instance:this}),this.call("onSelect",{value:this.getValue(),item:{value:h,label:h},instance:this}),this.close());return}i.length===1&&this._selectRendered(0);return}if(this.mode==="tags"&&this.query.trim()){t.preventDefault(),this._commitTypedTag();return}t.preventDefault(),this.open();return}if(e==="Escape"){this.opened&&(t.preventDefault(),this.close());return}if(e==="Tab"){this.mode==="tags"&&this.opts.commitOnTab&&this.query.trim()&&this._commitTypedTag(),this.opened&&this.close();return}if(e==="Backspace"){if(this.mode==="tags"&&!this.input.value&&!this.query&&this.value_.length){t.preventDefault(),this.removeTag(this.value_.length-1);return}!this.input.value&&this.opened&&this.close();return}e==="Delete"&&this.opts.clearable&&this.value_.length&&(t.preventDefault(),this.clear())}},a.prototype._commitTypedTag=function(){var t=this.input.value,e=this._splitTags(t),i=!1;return e.forEach(function(r){this._addTagObject(r,{})&&(i=!0)},this),this.input.value="",this.query="",this._render(),this._syncNative(),this.opened&&this._renderDropdown(),i},a.prototype._splitTags=function(t){var e=String(t||""),i=this.opts.delimiters||[],r=[e];return i.forEach(function(n){n&&(r=r.reduce(function(s,o){return s.concat(o.split(n))},[]))}),r.map(function(n){return n.trim()}).filter(Boolean)},a.prototype._bind=function(){var t=this;this.onInput=function(){var e=t.input.value;if(t.query=e,t.opened?(typeof t.opts.fetchOptions=="function"&&t.query.length>=(t.opts.minChars||0)&&(t.opts.debounce>0?t.debouncedFetch(t.query):t._fetch(t.query)),t.activeIndex=t.mode==="tags"?-1:t._firstEnabledIndex(),t._renderDropdown()):(t.open(),t.query=e,t.input.value=e,t._renderDropdown()),t.mode==="tags"){var i=t.opts.delimiters||[],r=i.some(function(n){return n&&e.indexOf(n)!==-1});r&&t._commitTypedTag()}},this.onKeyDown=function(e){t._onKeyDown(e)},this.onFocus=function(){t.disabled_||(t.root.classList.add("zs-root--focus"),(t.mode==="combobox"||t.mode==="tags"||t.mode==="select"&&t.opts.searchable)&&(t.opened||t.open()))},this.onBlur=function(){t.root.classList.remove("zs-root--focus"),setTimeout(function(){t.destroyed||t.root.contains(u.activeElement)||(t.mode==="tags"&&t.query.trim()&&t.opts.commitOnBlur&&t._commitTypedTag(),t.mode==="combobox"&&t.opts.allowFreeText&&t.query.trim()&&t._setValueInternal([t.query.trim()]),t.query="",t.close(),t._render())},0)},this.onControlClick=function(e){if(!t.disabled_){var i=e.target;if(!(i.closest&&i.closest(".zs-clear"))&&!(i.closest&&i.closest(".zs-chip-remove"))){if(t.opened){if(!t.opts.searchable&&!t.input.readOnly)return;t.opts.searchable||t.close();return}t.open()}}},this.onControlMouseDown=function(e){if(e.target!==t.input){if(e.target.closest&&(e.target.closest(".zs-chip-remove")||e.target.closest(".zs-clear"))){e.preventDefault();return}(e.target===t.controlEl||e.target.closest&&e.target.closest(".zs-chips"))&&(e.preventDefault(),t.input.focus())}},this.onClearClick=function(e){e.preventDefault(),e.stopPropagation(),t.clear()},this.onChipsClick=function(e){var i=e.target.closest?e.target.closest("[data-zs-remove]"):null;if(i){e.preventDefault(),e.stopPropagation();var r=parseInt(i.getAttribute("data-zs-remove"),10);if(!isNaN(r))if(t.mode==="tags")t.removeTag(r);else{var n=t.value_[r];if(!n)return;var s=t.getValue();t.value_.splice(r,1),t._render(),t._syncNative(),t.emit("change",{value:t.getValue(),previousValue:s,item:n,instance:t}),t.call("onChange",{value:t.getValue(),previousValue:s,item:n,instance:t}),t.announce(n.label+" removed."),t.opened&&t._renderDropdown()}}},this.onDropdownMouseDown=function(e){e.preventDefault()},this.onDropdownClick=function(e){var i=e.target.closest?e.target.closest(".zs-more"):null;if(i){e.preventDefault(),e.stopPropagation(),t.loadMore();return}var r=e.target.closest?e.target.closest("[data-zs-option]"):null;if(r){e.preventDefault();var n=parseInt(r.getAttribute("data-zs-option"),10);isNaN(n)||(t.activeIndex=n,t._selectRendered(n),t.mode==="tags"&&t.input.focus())}},this.onDocumentPointerDown=function(e){if(t.opened){var i=e.composedPath?e.composedPath():[];i.indexOf(t.root)===-1&&(t.root.contains(e.target)||(t.close(),t._render()))}},this.onWindowResize=function(){t.opened&&t._position()},this.onDropdownScroll=function(){if(!(!t.opts.autoLoadMore||!t.opened||!t.hasMore)&&!(t.loading||t.fetchingMore)){var e=t.dropdown;e.scrollTop+e.clientHeight>=e.scrollHeight-24&&t.loadMore()}},this.debouncedFetch=gt(function(e){t._fetch(e)},this.opts.debounce),this.el&&this.el.addEventListener&&(this.onNativeInvalid=function(){t.setValidation("invalid"),t.input&&t.input.focus&&t.input.focus()},this.el.addEventListener("invalid",this.onNativeInvalid)),this.input.addEventListener("input",this.onInput),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur),this.controlEl.addEventListener("click",this.onControlClick),this.controlEl.addEventListener("mousedown",this.onControlMouseDown),this.chipsEl.addEventListener("click",this.onChipsClick),this.clearBtn.addEventListener("click",this.onClearClick),this.dropdown.addEventListener("mousedown",this.onDropdownMouseDown),this.dropdown.addEventListener("click",this.onDropdownClick),this.dropdown.addEventListener("scroll",this.onDropdownScroll),u.addEventListener("pointerdown",this.onDocumentPointerDown,!0),m.addEventListener("resize",this.onWindowResize)},a.prototype._observeResize=function(){if(typeof ResizeObserver!="undefined"){var t=this;this.resizeObserver=new ResizeObserver(function(){t.opened&&t._position()}),this.resizeObserver.observe(this.controlEl)}},a.prototype.getValue=function(){if(this.mode==="tags")return this.getTags();var t=this.value_.map(function(e){return e.value});return this.opts.multiple?t:t.length?t[0]:null},a.prototype.setValue=function(t,e){var i=e||{};if(this.mode==="tags"){var r=typeof t=="string"?this._splitTags(t):S(t),n=this.getTags();if(this.value_=[],r.forEach(function(o){this._addTagObject(o,{silent:!0})},this),this.value_.length&&this.opts.validation==="invalid"&&(this.opts.validation=null),this._render(),this._syncNative(),!i.silent){var s=this.getTags();JSON.stringify(s)!==JSON.stringify(n)&&(this.emit("change",{value:s,previousValue:n,instance:this}),this.call("onChange",{value:s,previousValue:n,instance:this}))}return this.opened&&this._renderDropdown(),this}return this._setValueInternal(t,i)},a.prototype.clear=function(){return this.mode==="tags"?this.value_.length?(this.value_=[],this._render(),this._syncNative(),this.announce("All tags removed."),this.emit("change",{value:[],instance:this}),this.call("onChange",{value:[],instance:this}),this.opened&&this._renderDropdown(),this):this:(this._setValueInternal([],{}),this._render(),this)},a.prototype.setOptions=function(t){var e=this._normalizeItems(t);if(this.mode==="tags")this.suggestions=e;else{this.items=e;var i=this;if(this.value_=this.value_.filter(function(r){for(var n=0;n<i.items.length;n+=1)if(i.items[n].value===r.value)return!0;return i.opts.allowFreeText}),this.native&&this.native.tagName==="SELECT"){for(;this.native.firstChild;)this.native.removeChild(this.native.firstChild);this.items.forEach(function(r){var n=u.createElement("option");n.value=r.value,n.textContent=r.label,r.disabled&&(n.disabled=!0),i.native.appendChild(n)})}}return this.asyncItems=null,this.asyncPage=0,this.hasMore=!1,this.loadMoreError=null,this.clearCache(),this.activeIndex=-1,this._render(),this._syncNative(),this.opened&&this._renderDropdown(),this},a.prototype.enable=function(){return this.disabled_=!1,this._render(),this},a.prototype.disable=function(){return this.disabled_=!0,this.close(),this._render(),this},a.prototype.setLayout=function(t){var e=String(t||"").toLowerCase();if(M.indexOf(e)===-1)throw new Error('ZidanSelect: unknown layout "'+t+'". Use: '+M.join(", "));return this.layout=e,this.opts.layout=e,this.root.setAttribute("data-zs-layout",e),this.root.classList.toggle("zs-root--labeled",e==="floating-label"),this._position(),this},a.prototype.setFramework=function(t){var e=String(t||"").toLowerCase();if(T.indexOf(e)===-1)throw new Error('ZidanSelect: unknown framework "'+t+'". Use: '+T.join(", "));return this.opts.themeFramework=e,this.framework=e==="auto"?this._resolveFramework():e,this.root.setAttribute("data-zs-framework",this.framework),this.controlEl.classList.toggle("form-control",this.framework==="bootstrap"),this.controlEl.classList.toggle("zs-bootstrap-control",this.framework==="bootstrap"),this.controlEl.classList.toggle("form-select",this.framework==="bootstrap"&&this.el.tagName==="SELECT"),this._applyCustomClass(this.root,"root"),this._render(),this},a.prototype.setScrollbar=function(t){var e=String(t||"").toLowerCase();if(I.indexOf(e)===-1)throw new Error('ZidanSelect: unknown scrollbar "'+t+'". Use: '+I.join(", "));return this.opts.scrollbar=e,this.root&&this.root.setAttribute("data-zs-scrollbar",e),this},a.prototype.setValidation=function(t){return this.opts.validation=t,this._render(),this},a.prototype.on=function(t,e){var i=this._eventName(t);return this.root.addEventListener(i,e),this.listeners.has(i)||this.listeners.set(i,[]),this.listeners.get(i).push(e),this},a.prototype.off=function(t,e){var i=this._eventName(t),r=this.listeners.get(i)||[];if(e)this.root.removeEventListener(i,e),this.listeners.set(i,r.filter(function(s){return s!==e}));else{var n=this.root;r.forEach(function(s){n.removeEventListener(i,s)}),this.listeners.set(i,[])}return this},a.prototype._eventName=function(t){var e=String(t||"");return e.indexOf(O)===0?e:O+e},a.prototype.emit=function(t,e){if(!this.root||!u)return this;var i;try{i=new CustomEvent(O+t,{bubbles:!0,cancelable:!1,detail:e||{}})}catch{i=u.createEvent("CustomEvent"),i.initCustomEvent(O+t,!0,!1,e||{})}return this.root.dispatchEvent(i),this},a.prototype.call=function(t,e){var i=this.opts[t];if(typeof i=="function")try{return i(e)}catch(r){this.emit("error",{error:r,message:r&&r.message||String(r),callback:t,instance:this});return}},a.prototype.announce=function(t){!this.liveEl||!t||(this.liveEl.textContent="",this.liveEl.textContent=t)},a.prototype.destroy=function(){if(this.destroyed)return this;this.destroyed=!0,this.debouncedFetch&&this.debouncedFetch.cancel(),this.asyncController&&this.asyncController.abort(),this.clearCache(),this.resizeObserver&&this.resizeObserver.disconnect(),this.form&&this.onFormReset&&this.form.removeEventListener("reset",this.onFormReset),u.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),m.removeEventListener("resize",this.onWindowResize),this.el&&this.onNativeInvalid&&this.el.removeEventListener("invalid",this.onNativeInvalid),this.emit("destroy",{instance:this}),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.native?(this.native.hidden=!1,this.native.classList.remove("zs-native"),this.native.removeAttribute("tabindex"),this.native.removeAttribute("aria-hidden")):this.el.classList&&this.el.classList.contains("zs-root--mount")&&this.el.classList.remove("zs-root--mount"),this.el.__zidanSelect===this&&delete this.el.__zidanSelect,this.listeners.clear();var t=a.instances.indexOf(this);return t!==-1&&a.instances.splice(t,1),this},a.prototype.isOpen=function(){return this.opened},a.prototype.refresh=function(){return this._render(),this.opened&&this._renderDropdown(),this};function L(t){if(!y(t))return null;var e=String(t.getAttribute("data-zidan")||"").toLowerCase();if(at.indexOf(e)!==-1)return e;if(t.hasAttribute("data-zidan-radio-group"))return"radio-group";if(t.hasAttribute("data-zidan-radio"))return"radio";if(t.hasAttribute("data-zidan-checkbox")||t.hasAttribute("data-zidan-switch"))return"checkbox";if(t.hasAttribute("data-zidan-file"))return"file";if(t.hasAttribute("data-zidan-textarea"))return"textarea";if(t.hasAttribute("data-zidan-input"))return"input";var i=String(t.type||"").toLowerCase();if(i==="checkbox")return"checkbox";if(i==="radio")return"radio";if(i==="file")return"file";if(j(t,"zidan-field")){if(t.tagName==="FIELDSET")return t.querySelector('input[type="radio"]')?"radio-group":null;if(t.tagName==="TEXTAREA")return"textarea";if(t.tagName!=="INPUT"||i==="radio")return null;if(typeof TEXT_TYPES!="undefined"&&TEXT_TYPES.indexOf(i)!==-1)return"input"}return null}function k(t,e,i){var r=z(K(t),i);if(t.__zidanField&&!r.force)return t.__zidanField;switch(e){case"checkbox":return typeof ZidanCheckbox!="undefined"?new ZidanCheckbox(t,r):null;case"radio":case"radio-group":return typeof ZidanRadioGroup!="undefined"?new ZidanRadioGroup(t,r):null;case"file":return typeof ZidanFileUpload!="undefined"?new ZidanFileUpload(t,r):null;case"input":case"textarea":return typeof ZidanTextField!="undefined"?new ZidanTextField(t,r):null;default:return null}}function Q(t,e){var i=[];typeof t=="string"?i=Array.prototype.slice.call(u.querySelectorAll(t)):y(t)?i=[t]:t&&typeof t.length=="number"&&(i=Array.prototype.slice.call(t));var r=[];return i.forEach(function(n){if(!n.__zidanField){var s=L(n)||it(n);if(s){s==="radio"&&!n.hasAttribute("data-zidan-radio")&&(s="radio-group");var o=k(n,s,e||{});o&&r.push(o)}}}),r.length===1?r[0]:r}function $(t,e){var i=[];return t.forEach(function(r){if(!(!y(r)||r.__zidanField)){var n=L(r);if(n){n==="radio"&&(n="radio-group");var s=k(r,n,e||{});s&&i.push(s)}}}),i}function A(t,e){var i=t||u;if(!i||!i.querySelectorAll)return[];var r=Array.prototype.slice.call(i.querySelectorAll(H));return y(i)&&i.matches&&i.matches(H)&&r.unshift(i),$(r,e)}var p={version:C,__zidanFormGuard:C,themes:V,frameworks:T.slice(),fieldLayouts:q,fields:[],_register:function(t){p.fields.indexOf(t)===-1&&p.fields.push(t)},_unregister:function(t){var e=p.fields.indexOf(t);e!==-1&&p.fields.splice(e,1)},get:function(t){var e=typeof t=="string"?u.querySelector(t):t;return y(e)&&e.__zidanField||null},init:function(t,e){return A(t||u,e||{})},field:Q,refresh:function(t){return A(t||u,{}),p.fields.slice().forEach(function(e){e.update()}),p.fields.slice()},destroyAll:function(){return p.fields.slice().forEach(function(t){t.destroy()}),p.fields=[],typeof a!="undefined"&&a.destroyAll&&a.destroyAll(),p},observe:function(t,e){var i=t||u.body;if(!i||!m.MutationObserver)return null;var r=new m.MutationObserver(function(n){n.forEach(function(s){Array.prototype.slice.call(s.addedNodes).forEach(function(o){y(o)&&(L(o)&&k(o,L(o)==="radio"?"radio-group":L(o),e||{}),o.querySelectorAll&&A(o,e||{}))})}),p.fields.slice().forEach(function(s){s.el.isConnected||s.destroy()}),typeof a!="undefined"&&a.instances.slice().forEach(function(s){s.el.isConnected||s.destroy()})});return r.observe(i,{childList:!0,subtree:!0}),r}};p.api=null,p.registerIcon=Y,p.icons=x,typeof PHONE_COUNTRIES!="undefined"&&(p.phoneCountries=PHONE_COUNTRIES,p.phoneFormats=PHONE_FORMATS.slice(),p.formatPhone=formatPhone,p.detectPhoneCountry=detectPhoneCountry),p.messages=D,p.variants={},typeof CHECKBOX_VARIANTS!="undefined"&&(p.variants.checkbox=CHECKBOX_VARIANTS.slice()),typeof SWITCH_STYLES!="undefined"&&(p.variants.switch=SWITCH_STYLES.slice()),typeof RADIO_VARIANTS!="undefined"&&(p.variants.radio=RADIO_VARIANTS.slice()),typeof FILE_VARIANTS!="undefined"&&(p.variants.file=FILE_VARIANTS.slice()),typeof RANGE_VARIANTS!="undefined"&&(p.variants.range=RANGE_VARIANTS.slice()),typeof STEPPER_MODES!="undefined"&&(p.stepperModes=STEPPER_MODES.slice()),p.fieldLayouts=q.slice(),typeof a!="undefined"&&(a.version=C,a.__zidanSelectGuard=C,a.layouts=M.slice(),a.frameworks=T.slice(),a.scrollbars=I.slice(),a.defaults=w,a.cacheLimit=50,a.get=function(t){var e=typeof t=="string"?u.querySelector(t):t;return y(e)&&e.__zidanSelect||null},a.instances=[],a.destroyAll=function(){a.instances.slice().forEach(function(t){t.destroy()}),a.instances=[]});function yt(t,e){var i=[];typeof t=="string"?i=Array.prototype.slice.call(u.querySelectorAll(t)):t&&typeof t.length=="number"&&!y(t)&&t!==m?i=Array.prototype.slice.call(t):y(t)&&(i=[t]);var r=i.map(function(n){var s=new a(n,e||{});return a.instances.push(s),s});return r.length===1?r[0]:r}function P(t,e){return t.filter(function(i){return y(i)&&!i.__zidanSelect}).map(function(i){return a.instances.push(new a(i,e||{})),i.__zidanSelect})}function tt(t,e){var i=t||u;if(!i||!i.querySelectorAll)return[];var r=Array.prototype.slice.call(i.querySelectorAll(N));return y(i)&&i.matches&&i.matches(N)&&r.unshift(i),P(r,e)}function Z(t,e){S(t).forEach(function(i){i&&(typeof i=="string"?e(i,null):i.selector&&e(String(i.selector),i.options||null))})}function et(t,e){Z(t,function(i,r){P(Array.prototype.slice.call(u.querySelectorAll(i)),z(e,r))})}function bt(t,e){Z(t,function(i,r){var n=z(e,r);Array.prototype.slice.call(u.querySelectorAll(i)).forEach(function(s){if(!(!y(s)||s.__zidanField)){var o=L(s)||it(s);o&&(o==="radio"&&(o="radio-group"),k(s,o,n))}})})}function it(t){return typeof TEXT_TYPES=="undefined"||!y(t)?null:t.tagName==="TEXTAREA"?"textarea":t.tagName!=="INPUT"?null:TEXT_TYPES.indexOf(String(t.type).toLowerCase())!==-1?"input":null}function _t(t,e){if(typeof a=="undefined")return[];var i=N+", select",r=Array.prototype.slice.call(t.querySelectorAll(i));return y(t)&&t.matches&&t.matches(i)&&r.unshift(t),P(r,e)}function rt(t,e,i){y(t)&&(_t(t,e),typeof ZidanFileUpload!="undefined"&&$(Array.prototype.slice.call(t.querySelectorAll('input[type="file"]')),i),(typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof ZidanFileUpload!="undefined"||typeof ZidanTextField!="undefined")&&A(t,i))}function wt(t,e,i){Array.prototype.slice.call(u.querySelectorAll(ot)).forEach(function(r){rt(r,e,i)}),Z(t,function(r,n){Array.prototype.slice.call(u.querySelectorAll(r)).forEach(function(s){rt(s,z(e,n),z(i,n))})})}function nt(){if(u){var t=m.ZIDAN_FORM_CONFIG||m.ZIDAN_SELECT_CONFIG||{};if(t.autoInit!==!1&&!(m.ZidanSelect&&m.ZidanSelect.autoInit===!1)&&u.documentElement.getAttribute("data-zidan-auto-init")!=="false"){var e=typeof a!="undefined",i=typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof ZidanFileUpload!="undefined"||typeof ZidanTextField!="undefined",r=t.options||{},n=t.fieldOptions||t.fields||{};e&&(t.selector?et(t.selector,r):et(t.targets||t.selectors,r)),i&&bt(t.fieldTargets,n),wt(t.formTargets,r,n),e&&!t.selector&&tt(u,r),i&&A(u,n)}}}u&&(u.readyState==="loading"?u.addEventListener("DOMContentLoaded",nt):setTimeout(nt,0));var _={ZidanForm:p,registerIcon:Y};return typeof a!="undefined"&&(_.ZidanSelect=a,_.zidanSelect=yt,_.initZidanSelects=tt),(typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof ZidanFileUpload!="undefined"||typeof ZidanTextField!="undefined")&&(_.zidanField=Q,_.initZidanForms=A),typeof ZidanCheckbox!="undefined"&&(_.ZidanCheckbox=ZidanCheckbox),typeof ZidanRadioGroup!="undefined"&&(_.ZidanRadioGroup=ZidanRadioGroup),typeof ZidanFileUpload!="undefined"&&(_.ZidanFileUpload=ZidanFileUpload),typeof ZidanTextField!="undefined"&&(_.ZidanTextField=ZidanTextField),typeof formatPhone=="function"&&(_.formatPhone=formatPhone,_.detectPhoneCountry=detectPhoneCountry),p.api=_,_});